Initial OpenSolaris release: X-src-20060331 nv_37
authorAlan Coopersmith <Alan.Coopersmith@Sun.COM>
Fri, 31 Mar 2006 16:09:50 -0800
changeset 0 b949c5054bc4
child 1 b66154b9e467
Initial OpenSolaris release: X-src-20060331
XORG_NV/build_src_tree
XORG_NV/buildit
XORG_NV/make_release_packages
XORG_NV/newPkRev
XORG_NV/other_masters
XORG_NV/packages/SUNWxorg-cfg/depend
XORG_NV/packages/SUNWxorg-cfg/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-cfg/prototype
XORG_NV/packages/SUNWxorg-client-docs/depend
XORG_NV/packages/SUNWxorg-client-docs/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-client-docs/prototype
XORG_NV/packages/SUNWxorg-client-programs/depend
XORG_NV/packages/SUNWxorg-client-programs/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-client-programs/prototype
XORG_NV/packages/SUNWxorg-clientlibs/depend
XORG_NV/packages/SUNWxorg-clientlibs/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-clientlibs/prototype
XORG_NV/packages/SUNWxorg-compatlinks/depend
XORG_NV/packages/SUNWxorg-compatlinks/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-compatlinks/prototype
XORG_NV/packages/SUNWxorg-devel-docs/depend
XORG_NV/packages/SUNWxorg-devel-docs/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-devel-docs/prototype
XORG_NV/packages/SUNWxorg-doc/depend
XORG_NV/packages/SUNWxorg-doc/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-doc/prototype_com
XORG_NV/packages/SUNWxorg-doc/prototype_i386
XORG_NV/packages/SUNWxorg-graphics-ddx/depend
XORG_NV/packages/SUNWxorg-graphics-ddx/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-graphics-ddx/prototype_com
XORG_NV/packages/SUNWxorg-graphics-ddx/prototype_i386
XORG_NV/packages/SUNWxorg-headers/depend
XORG_NV/packages/SUNWxorg-headers/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-headers/prototype
XORG_NV/packages/SUNWxorg-mesa/depend
XORG_NV/packages/SUNWxorg-mesa/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-mesa/prototype
XORG_NV/packages/SUNWxorg-server/depend
XORG_NV/packages/SUNWxorg-server/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-server/prototype
XORG_NV/packages/SUNWxorg-tsol-module/depend
XORG_NV/packages/SUNWxorg-tsol-module/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-tsol-module/prototype
XORG_NV/packages/SUNWxorg-xkb/depend
XORG_NV/packages/SUNWxorg-xkb/pkginfo.tmpl
XORG_NV/packages/SUNWxorg-xkb/prototype
XORG_NV/packages/common_files/copyright
XORG_NV/packages/pkgversion
XORG_NV/packages/upgrade-Xorg
XORG_NV/sun-src/stsf/SUNW-build
XORG_NV/sun-src/stsf/interface/BUILD
XORG_NV/sun-src/xc/config/cf/host.def
XORG_NV/sun-src/xc/config/cf/sun.cf
XORG_NV/sun-src/xc/config/cf/xorg.cf
XORG_NV/sun-src/xc/config/cf/xorgsite.def
XORG_NV/sun-src/xc/config/mapfiles/mapfile_pga_i386
XORG_NV/sun-src/xc/config/mapfiles/mapfile_pga_sparc
XORG_NV/sun-src/xc/config/sun-manpage-templates/attributes
XORG_NV/sun-src/xc/config/sun-manpage-templates/table-prepend
XORG_NV/sun-src/xc/doc/man/Xv/localdefines
XORG_NV/sun-src/xc/fonts/encodings/localdefines
XORG_NV/sun-src/xc/include/extensions/interactive.h
XORG_NV/sun-src/xc/include/extensions/interactiveCommon.h
XORG_NV/sun-src/xc/include/extensions/localmacros
XORG_NV/sun-src/xc/lib/GL/GL/localdefines
XORG_NV/sun-src/xc/lib/GL/mesa/drivers/osmesa/localdefines
XORG_NV/sun-src/xc/lib/GLw/localdefines
XORG_NV/sun-src/xc/lib/Imakefile
XORG_NV/sun-src/xc/lib/X11/spec/X11.spec
XORG_NV/sun-src/xc/lib/X11/spec/versions
XORG_NV/sun-src/xc/lib/Xaw/Text.c
XORG_NV/sun-src/xc/lib/Xaw/TextAction.c
XORG_NV/sun-src/xc/lib/Xaw/localdefines
XORG_NV/sun-src/xc/lib/Xevie/localdefines
XORG_NV/sun-src/xc/lib/Xfixes/localdefines
XORG_NV/sun-src/xc/lib/Xft/localdefines
XORG_NV/sun-src/xc/lib/Xrandr/localdefines
XORG_NV/sun-src/xc/lib/Xtsol/Imakefile
XORG_NV/sun-src/xc/lib/Xtsol/Xtsol.c
XORG_NV/sun-src/xc/lib/Xtsol/Xtsol.h
XORG_NV/sun-src/xc/lib/Xtsol/Xtsolproto.h
XORG_NV/sun-src/xc/lib/Xtsol/spec/Xtsol.spec
XORG_NV/sun-src/xc/lib/Xtsol/spec/versions
XORG_NV/sun-src/xc/lib/Xv/localdefines
XORG_NV/sun-src/xc/lib/XvMC/localdefines
XORG_NV/sun-src/xc/lib/Xxf86misc/localdefines
XORG_NV/sun-src/xc/lib/Xxf86vm/localdefines
XORG_NV/sun-src/xc/lib/font/Type1/fontfcn.c
XORG_NV/sun-src/xc/lib/xkbfile/spec/versions
XORG_NV/sun-src/xc/lib/xkbfile/spec/xkbfile.spec
XORG_NV/sun-src/xc/programs/Xserver/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/SunExt/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/SunExt/interactive.c
XORG_NV/sun-src/xc/programs/Xserver/SunExt/modules/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/SunExt/modules/iamodule.c
XORG_NV/sun-src/xc/programs/Xserver/Xext/extmod/modinit.c
XORG_NV/sun-src/xc/programs/Xserver/dix/dispatch.c
XORG_NV/sun-src/xc/programs/Xserver/dix/events.c
XORG_NV/sun-src/xc/programs/Xserver/dix/localdefines
XORG_NV/sun-src/xc/programs/Xserver/dix/property.c
XORG_NV/sun-src/xc/programs/Xserver/dix/window.c
XORG_NV/sun-src/xc/programs/Xserver/fb/localmacros
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/atKeynames.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/localdefines
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86str.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/ddc/edid.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_2dtool.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_2dtool.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_accel.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_cursor.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_cursor.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_driver.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_mode.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_mode.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_tool.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_vgatool.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_vgatool.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64accel.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_hw.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/etc/localdefines
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/etc/sun_extramodes
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/fbdevhw/localmacros
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/getconfig/getconfig.pl
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/getconfig/localdefines
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/getconfig/localmacros
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/loader/localdefines
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_apm.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_loginfo.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_xkbtable.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_xkbtable.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/xkbtable.map
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/vbe/vbe_module.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/XOrgCfg.cpp
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/dummygen.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loadmod.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/localdefines
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/localmacros
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/text-mode.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/Cards
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/localdefines
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/localmacros
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/xorgconfig.c
XORG_NV/sun-src/xc/programs/Xserver/include/extnsionst.h
XORG_NV/sun-src/xc/programs/Xserver/include/propertyst.h
XORG_NV/sun-src/xc/programs/Xserver/include/selection.h
XORG_NV/sun-src/xc/programs/Xserver/lbx/lbxprop.c
XORG_NV/sun-src/xc/programs/Xserver/localdefines
XORG_NV/sun-src/xc/programs/Xserver/os/auth.c
XORG_NV/sun-src/xc/programs/Xserver/os/connection.c
XORG_NV/sun-src/xc/programs/Xserver/os/dtlogin.c
XORG_NV/sun-src/xc/programs/Xserver/os/localdefines
XORG_NV/sun-src/xc/programs/Xserver/os/utils.c
XORG_NV/sun-src/xc/programs/Xserver/tsol/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/tsol/TrustedExtensionsPolicy
XORG_NV/sun-src/xc/programs/Xserver/tsol/module/Imakefile
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsol.h
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolextension.c
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolinfo.h
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolmodule.c
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolpolicy.c
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolpolicy.h
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolpriv.h
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolprotocol.c
XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolutils.c
XORG_NV/sun-src/xc/programs/glxgears/localdefines
XORG_NV/sun-src/xc/programs/glxinfo/localdefines
XORG_NV/sun-src/xc/programs/localdefines
XORG_NV/sun-src/xc/programs/xgamma/localdefines
XORG_NV/sun-src/xc/programs/xkbcomp/compat/japan
XORG_NV/sun-src/xc/programs/xkbcomp/compat/mousekeys
XORG_NV/sun-src/xc/programs/xkbcomp/geometry/sun
XORG_NV/sun-src/xc/programs/xkbcomp/keycodes/sun
XORG_NV/sun-src/xc/programs/xkbcomp/keymap/sun/all
XORG_NV/sun-src/xc/programs/xkbcomp/keymap/sun/localmacros
XORG_NV/sun-src/xc/programs/xkbcomp/rules/xorg
XORG_NV/sun-src/xc/programs/xkbcomp/rules/xorg.lst
XORG_NV/sun-src/xc/programs/xkbcomp/rules/xorg.xml
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/de
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/nl
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/ca
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/cs
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/cz
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/de
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/dk
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/es
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/fi
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/fr
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/gb
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/gr
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/hu
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/it
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/jp
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/ko
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/localmacros
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/lt
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/lv
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/nl
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/no
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/pl
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/pt
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/ru
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/se
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/solaris
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/sw
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/tr
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/tuv
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/tw
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/us
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/tr
XORG_NV/sun-src/xc/programs/xkbcomp/symbols/tr_f
XORG_NV/sun-src/xc/programs/xrandr/localdefines
XORG_NV/sun-src/xc/programs/xvidtune/localdefines
XORG_NV/sun-src/xc/programs/xvinfo/localdefines
buildit
download-tarballs
make_release_packages
newPkRev
open-src/Makefile
open-src/common/Makefile.inc
open-src/common/mapfiles/map.noexbss
open-src/common/sunman-stability
open-src/font/bitstream-vera/Makefile
open-src/lib/Xft/Makefile
open-src/lib/Xft/cjk-embolden.patch
open-src/lib/Xft/mapfile.scope
open-src/lib/Xft/xft.pc.patch
open-src/lib/Xft/xftcore-6261221.patch
open-src/lib/fontconfig/Makefile
open-src/lib/fontconfig/fc-cache.xml
open-src/lib/fontconfig/fix-fonts.conf.pl
open-src/lib/fontconfig/fontconfig-2.2.3.patch
open-src/lib/fontconfig/fontconfig-2.3.2.patch
open-src/lib/fontconfig/fontdirs
open-src/lib/fontconfig/fonts.conf.append
open-src/lib/fontconfig/fonts.conf.preuser
open-src/lib/fontconfig/libfontconfig.3lib
open-src/lib/fontconfig/sunman-notes-fc-cache
open-src/lib/freetype/Makefile
open-src/lib/freetype/freetype-2.1.10.patch
packages/SUNWfontconfig-docs/copyright.add
packages/SUNWfontconfig-docs/depend
packages/SUNWfontconfig-docs/pkginfo.tmpl
packages/SUNWfontconfig-docs/prototype
packages/SUNWfontconfig-root/copyright.add
packages/SUNWfontconfig-root/depend
packages/SUNWfontconfig-root/pkginfo.tmpl
packages/SUNWfontconfig-root/prototype
packages/SUNWfontconfig/copyright.add
packages/SUNWfontconfig/depend
packages/SUNWfontconfig/pkginfo.tmpl
packages/SUNWfontconfig/prototype
packages/SUNWfreetype2/copyright.add
packages/SUNWfreetype2/depend
packages/SUNWfreetype2/pkginfo.tmpl
packages/SUNWfreetype2/prototype
packages/SUNWxwxft/copyright.add
packages/SUNWxwxft/depend
packages/SUNWxwxft/pkginfo.tmpl
packages/SUNWxwxft/prototype
packages/copyright
packages/pkgversion
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/build_src_tree	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,324 @@
+#!/usr/perl5/bin/perl -w
+#
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)build_src_tree 1.8     05/12/22 SMI"
+#
+# Creates a directory containing links to the source files needed to build
+# the X.org monolithic tree for Solaris.  Source files are linked to the X.org
+# master source tree from the X.org workspace, with files replaced by the ones
+# in the sun-src directory if they overlap.
+#
+# Command line options:
+#	-d path Destination directory to build links in
+#	-f	Force replacing existing files/links in target directory
+#	-i	Interactive - ask to replace existing files/links in target
+#	-n	Don't actually do anything, just report
+#	-p path	Only do partial tree under specified path
+#	-q	Quieter
+#	-v	More Verbose
+
+require 5.6.1;                          # minimal Perl version required
+use strict;                             # 
+use diagnostics;                        #
+use File::Find;
+use Getopt::Std;
+use Cwd;
+
+# Directory to build with links
+my $LINK_DIR = "build";
+
+# Command line options
+my $verbose = 1;
+my $doit = 1;
+my $forceit = 0;
+my $askme = 0;
+my @parts;
+
+my %opts;
+getopts('d:finp:qv', \%opts);
+
+if (exists $opts{"v"}) {
+  if (exists $opts{"q"}) {
+    print STDERR "$0: -v and -q are incompatible options\n";
+    exit 1;
+  }
+  $verbose = 2;
+} elsif (exists $opts{"q"}) {
+  $verbose = 0;
+}
+
+if (exists $opts{"d"}) {
+  $LINK_DIR = $opts{"d"};
+}
+
+if (exists $opts{"n"}) {
+  $doit = 0;
+}
+
+if (exists $opts{"f"}) {
+  $forceit = 1;
+}
+
+if (exists $opts{"i"}) {
+  $askme = 1;
+}
+
+if ($verbose) {
+  print ("Linking source trees into $LINK_DIR\n");
+}
+
+my $targetbase = cwd() . "/$LINK_DIR";
+my $target;
+my $part;
+
+# Directory with Sun customizations
+my $sunsrc = "sun-src";
+
+# non-modified sources are linked to directory listed in config file 
+# "other_masters"
+
+my %master_vars = ();
+my %other_masters = ();
+my $lineno = 0;
+open(XORG_SRC, "<other_masters") or die "$0: Can't open other_masters: $!\n";
+while ($_ = <XORG_SRC>) {
+  $lineno++;
+  next if $_ =~ /^\#/;
+  next if $_ =~ /^\s*$/;
+  chomp $_;
+  $_ =~ s|\s+$||;	
+  $_ =~ s|/$||;	# Strip trailing slash for readability
+  if ($_ =~ /^(\w+)=(\S+)$/) { # Variable definition
+    $master_vars{$1} = $2;
+  } else {
+    my ($s, $m) = split;
+    while ($m =~ /\$\((\w+)\)/) {
+      my $varname = $1;
+      if (exists $master_vars{$varname}) {
+	$m =~ s/\$\($varname\)/$master_vars{$varname}/g;
+      } else {
+	die "$0: Undefined variable \$($varname) on other_masters line $lineno\n";
+      }
+    }
+    $other_masters{$s} = $m;
+  }
+}
+close(XORG_SRC);
+
+if (exists $opts{"p"}) {
+  @parts = split(/[,: ]+/, $opts{"p"});
+} else {
+  @parts = keys %other_masters;
+}
+
+my %files_seen = ();
+my $badlinks = 0;
+
+for my $p ( @parts ) {
+  my @searchlist = ();
+
+  my $master_src_top;
+
+  $part = $p;
+
+  if (! exists $other_masters{$p}) {
+    print STDERR "$0: $part not found in other_masters file,\n";
+    next;
+  } else {
+    $master_src_top = $other_masters{$p};
+  }
+
+  # Handle tarballs
+  if ( $master_src_top =~ m/^tarball:(\S+)$/ ) {
+    my $tarball = $1;
+    my $unpacked = "unpacked/$tarball";
+
+    $unpacked =~ s/\.tar\.bz2$//;
+
+    if (! -d $unpacked ) {
+      do_mkdirP($unpacked);
+      if ($verbose) {
+	print "Unpacking tarball $tarball to $unpacked...\n"
+      }
+      system("(cd $unpacked ; /usr/sfw/bin/gtar -jxf ../../tarballs/$tarball)");
+    }
+    $master_src_top = $unpacked;
+  }
+
+  if (! -e "$master_src_top/$part" && ! -e "$sunsrc/$part" ) {
+    print STDERR "$0: $part not found in either place.\n";
+    exit 1;
+  }
+
+  $target = "$targetbase/$part";
+  my $targetdir = $target;
+
+  if (! -d "$master_src_top/$part" && ! -d "$sunsrc/$part" ) {
+    $targetdir =~ s|/[^/]+$||;
+  } 
+  if (! -d $targetdir) {
+    do_mkdirP($targetdir);
+  }
+
+  if (-e "$master_src_top/$part") {
+    unshift(@searchlist, "$master_src_top/$part");
+  }
+
+  if (-e "$sunsrc/$part") {
+    unshift(@searchlist, "$sunsrc/$part");
+  }
+
+  find({wanted => \&make_links, preprocess => \&skip_CVS_and_SCCS}, @searchlist);
+
+}
+
+if ($doit) {
+  system("cp other_masters $targetbase/.master_srcs");
+}
+
+
+if ($askme == 0) {
+  print "$badlinks files that were not properly linked.\n";
+}
+
+#### End of main program, subroutines follow...
+
+sub skip_CVS_and_SCCS {
+  return grep {$_ ne "CVS" && $_ ne "SCCS"} @_;
+}
+
+sub make_links {
+  my $sourcepath = "$File::Find::dir/$_";
+  $sourcepath =~ s|/\.$||;
+  $sourcepath =~ s|//|/|g;
+  my $path = $sourcepath;
+  $path =~ s|$File::Find::topdir(/?)||;
+  my $targetpath = "$target/$path";
+  $targetpath =~ s|/$||;
+
+  if (-d $_) {
+    if ($verbose) {
+      if ($_ eq ".") {
+	print "Starting tree $File::Find::topdir\n";
+      } elsif ($verbose == 2) {
+	print "Entering directory $path\n";
+      }
+    }
+    if (! -d $targetpath) {
+      do_mkdir($targetpath);
+    }
+  } else {
+    return if (exists $files_seen{"$part/$path"});
+    $files_seen{"$part/$path"} = 1;
+    
+    if ($verbose > 1) {
+      print $targetpath, "\n";
+    }
+    
+    if ($sourcepath !~ m|^/|) {		# If source path is not absolute path
+      my $depth = $path;		# add ../'s to make it the right depth
+      if ($part) {
+	$depth = "$part/$depth";
+      }
+      $depth =~ s|[^/]+/|../|g;
+      $depth =~ s|/[^/]+$||;
+      $sourcepath = "$depth/../$sourcepath";
+    }      
+
+
+    if (-e $targetpath) {		# If target already exists
+      if (-l $targetpath) {		# Check to see if it's a symlink
+	my $l = readlink($targetpath);	#  and if so, where it points to
+	if ($l eq $sourcepath) {
+	  return;
+	} else {
+	  $badlinks++;
+
+	  if ($forceit) {
+	    print STDERR "Undoing old link from $part/$path to $l.\n";
+	  } else {
+	    print STDERR "$part/$path is linked to $l, should be $sourcepath.\n";
+	    return;
+	  }
+	}
+      } else {
+	$badlinks++;
+	if ($forceit) {
+	  print STDERR "Moving old file found at $part/$path.\n";
+	} else {
+	  print STDERR "$part/$path is a file, not a symlink\n";
+	  return;
+	}
+      }
+      my $bak = 1;
+      while (-e "$targetpath.bak$bak") {
+	$bak++;
+      }
+      rename $targetpath, "$targetpath.bak$bak";
+    }
+    symlink $sourcepath, $targetpath or print STDERR "$0: can't symlink $sourcepath to $targetpath: $!\n";
+  }
+}
+    
+
+sub do_mkdir {
+  my $d;
+  foreach $d (@_) {
+    if ($doit) {
+      mkdir $d or print STDERR "$0: could not mkdir $d\n";
+    } else {
+      if ($verbose) {
+	print "Would run: mkdir $d\n";
+      }
+    }
+  }
+}
+
+# Equivalent of "mkdir -p"
+sub do_mkdirP {
+  my $d;
+  my $p = "";
+  foreach $d (split /\/+/,$_[0]) {
+    $p .= "$d/";
+    next if -d $p;
+
+    if ($doit) {
+      mkdir $p or print STDERR "$0: could not mkdir $p\n";
+    } else {
+      if ($verbose) {
+	print "Would run: mkdir $p\n";
+      }
+    }
+  }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/buildit	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,141 @@
+#!/bin/sh 
+#
+# buildit
+# Script for building Xorg tree for Solaris
+#
+###########################################################################
+#
+# Copyright 2006 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.
+#
+###########################################################################
+#
+# ident "@(#)buildit 1.12     06/03/28 SMI"
+#
+
+
+CLOBBER=0
+MAKE_PKGS=0
+
+set -- `getopt cp $*`
+if [ $? != 0 ]
+then
+    echo USAGE: $0 [-c]
+    exit 2
+fi
+
+for i in $* ; do 
+    case $i in
+	-c)     CLOBBER=1; shift;;
+	-p)     MAKE_PKGS=1; shift;;
+    esac
+done
+
+
+# Add /opt/sfw/bin to path for GNU tools for external modules
+PATH=$PATH:/opt/sfw/bin
+export PATH
+
+if [ $CLOBBER = 0 ] ; then
+    for b in 32 64 ; do
+	if [ -d build_$b ] ; then
+	    cmp -s other_masters build_$b/.master_srcs
+	    if [ $? != 0 ] ; then 
+		echo "Master sources changed since last build of build_$b"
+		echo "A 'clobber' build will be needed to remove and rebuild"  
+		echo "the build directories.   Save any files you need from the"
+		echo "build directories and then run $0 with the -c option."
+		exit 1
+	    fi
+	fi
+    done
+fi
+
+[ -d log ] || mkdir log
+
+# Append all further output & errors to the log file
+exec > log/buildit-XW 2>&1
+
+echo "------------------------------------------------------------------------------"
+echo "Start time: "
+date
+START=`perl -e 'print time'`
+echo "Building on: "
+uname -a
+echo "Using this compiler: "
+which cc
+cc -V
+
+if [ $CLOBBER = 1 ] ; then
+    /bin/rm -rf unpacked build
+fi
+
+chmod +x build_src_tree
+
+MACH=`uname -p`
+
+for b in 32 64 ; do
+
+    if [ $CLOBBER = 1 ] ; then
+	/bin/rm -rf build_$b
+    else
+	if [ "$MACH" = "i386" ]; then
+	    /bin/rm -rf build_$b/proto-i386-svr4
+	else
+	    /bin/rm -rf build_$b/proto-sun4-svr4
+	fi
+    fi
+
+    
+    ./build_src_tree -d build_$b
+
+    cd build_$b
+
+    cd xc
+    if [ $b = 64 ] ; then
+	BOOTSTRAPCFLAGS="-xarch=generic64"
+    fi
+    make -e -k World BOOTSTRAPCFLAGS=$BOOTSTRAPCFLAGS
+    #make -k install.ln
+    make -k install
+    make -k install.man
+    cd ..
+
+    cd ..
+done
+
+echo ""
+date
+echo "\nFinished building the X.org Foundation tree for Solaris.\n"
+echo ""
+echo "Finish time: "
+date
+perl -e '$runtime=time-$ARGV[0];printf("Runtime: %d:%02d\n", $runtime/3600, ($runtime%3600)/60); ' $START
+
+if [ $MAKE_PKGS = 1 ] ; then
+    ./make_release_packages
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/make_release_packages	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,265 @@
+#! /bin/sh
+#
+###########################################################################
+#
+# Copyright 2006 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.
+#
+###########################################################################
+#
+# ident "@(#)make_release_packages 1.19     06/03/06 SMI"
+#
+# make_release_packages:
+#
+#	Create and fill a package staging area for X
+#
+#	This script should be run from the base of the build tree.
+#	It takes no parameters.
+#
+#	Example:
+#	    cd /export/home/username/XORG_WS
+#	    ./make_release_packages
+#
+#   To build a subset of packages
+#	env PACKAGE_LIST="packages" ./make_release_packages
+#
+###########################################################################
+
+#   Make sure that we aren't affected by the personal environment of
+#   whoever is running this script
+PATH=/opt/SUNWspro/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:.
+SHELL=/bin/sh
+
+MACH=`uname -p`
+DATE=`date +0.%Y.%m.%d`
+
+SOURCEDIR=`pwd`
+
+cd $SOURCEDIR/packages
+
+# Get build version from pkgversion
+if [ -f pkgversion ] ; then
+    . pkgversion
+else
+    echo "Error: $SOURCEDIR/packages/pkgversion not found.  Cannot continue."
+    exit 1
+fi
+
+if [ "x${VERSION}" = "x" ] ; then
+    echo "VERSION not set in $SOURCEDIR/packages/pkgversion - run newPkRev"
+    exit 1
+fi
+
+if [ "x${BUILD}" = "x" ] ; then
+    echo "BUILD not set in $SOURCEDIR/packages/pkgversion - run newPkRev"
+    exit 1
+fi
+
+DECIMAL_BUILD=`echo ${BUILD} | awk '{print $1 / 100.0}'`
+echo "Building packages for X11 version ${VERSION} build ${DECIMAL_BUILD}"
+
+#
+# Trusted Extensions packages do not get built by default.
+# export BUILD_XTSOL=yes and run this script 
+#
+if [ x$BUILD_XTSOL = xyes ] ; then
+    TSOL_PACKAGE="SUNWxorg-tsol-module"
+fi
+
+
+#   List of official (deliverable) X-window packages
+XW_CLIENT_PACKAGE_LIST="SUNWxorg-clientlibs SUNWxorg-headers SUNWxorg-compatlinks SUNWxorg-client-programs SUNWxorg-client-docs SUNWxorg-devel-docs"
+XW_SERVER_PACKAGE_LIST="SUNWxorg-doc SUNWxorg-server SUNWxorg-graphics-ddx SUNWxorg-xkb SUNWxorg-cfg SUNWxorg-mesa $TSOL_PACKAGE"
+
+XW_L10N_PACKAGES=" "
+
+# Packages from XW_PACKAGELIST with platform-specific prototype files
+XW_PLT_PACKAGES="SUNWxorg-graphics-ddx SUNWxorg-doc"
+
+# L10N packages are normally only built on sparc since they only have text
+# files that are the same for both platforms
+# Server packages are only built for x86 currently
+if [ "$MACH" = "sparc" ]; then
+	XW_PACKAGE_LIST="$XW_CLIENT_PACKAGE_LIST $XW_L10N_PACKAGES"
+else
+	XW_PACKAGE_LIST="$XW_CLIENT_PACKAGE_LIST $XW_SERVER_PACKAGE_LIST"
+fi
+
+# dtlogin integration package is currently only built for Solaris 9/Metropolis
+# special release
+if [ "x${VERSION}" = "x6.7.0.5.9" ] ; then
+    XW_PACKAGE_LIST="$XW_PACKAGE_LIST SUNWxorg-dtlogin-integration"
+fi
+
+EXTRA_PACKAGES=" "
+
+#   To build a subset of packages
+#	PACKAGE_LIST="packages" make_release_packages
+#
+: ${PACKAGE_LIST:="$XW_PACKAGE_LIST $EXTRA_PACKAGES $XW_L10N_PACKAGES"}
+
+: ${PACKAGE_DIR:=$SOURCEDIR/proto-packages}
+
+# Which platform name do we use for 64-bit?
+if [ "$MACH" = "sparc" ]; then
+    PLAT_64="sparcv9"
+else 
+    if [ "$MACH" = "i386" ]; then
+	PLAT_64="amd64"
+    else
+	echo "Unknown architecture - not SPARC nor i386."
+	exit 1
+    fi
+fi
+
+#   Next, create the staging area.  Make sure that the logs directory
+#   is writeable by everyone because it is likely that we will need to
+#   write into it as root across an NFS link...
+#
+echo 'Removing old proto-packages and recreating'
+/bin/rm -rf $PACKAGE_DIR
+/bin/mkdir $PACKAGE_DIR
+/bin/mkdir $PACKAGE_DIR/logs
+/bin/chmod a+w $PACKAGE_DIR/logs
+
+
+#  Now copy the package description info
+echo 'Copying package descriptions'
+
+#   We can't just use `sccs get SCCS' because it will punt if it hits
+#   a file which is being edited (writeable).
+#   
+for F in SCCS/s.*
+do
+    /usr/ccs/bin/get -s $F
+done
+
+#/bin/cp i.* r.* $PACKAGE_DIR >/dev/null 2>&1
+
+for package in common_files $PACKAGE_LIST 
+do
+    cd $package
+
+    #   See above about sccs usage
+    for F in SCCS/s.*
+    do
+	/usr/ccs/bin/get $F >/dev/null 2>&1
+    done
+
+    /bin/mkdir $PACKAGE_DIR/$package
+    /bin/cp p* d* lib* i.* r.* M* $PACKAGE_DIR/$package >/dev/null 2>&1
+
+    if [ $package != "common_files" ] ; then
+    # We keep the master copyright in the common_files copyright file
+    # Packages that need additional copyright have copyright.add files
+    # that we then merge here
+	if [ -f copyright.add ] ; then
+	    cat ../common_files/copyright copyright.add > \
+		$PACKAGE_DIR/$package/copyright
+	else
+	    cp ../common_files/copyright $PACKAGE_DIR/$package/copyright
+	fi
+    fi
+    cd ..
+done
+
+
+#   Now move into the package staging area and build the packages.
+cd $PACKAGE_DIR
+
+if [ "$MACH" = "sparc" ]; then
+    PROTOMACH=sun4
+    SUBDIR64=sparcv9
+else
+    PROTOMACH=${MACH}
+    SUBDIR64=amd64
+fi
+
+PROTODIR=$SOURCEDIR/build_32/proto-${PROTOMACH}-svr4
+
+/bin/rm -f etc usr
+
+/bin/ln -s $PROTODIR/usr usr
+/bin/ln -s $PROTODIR/etc etc
+
+for D in /usr/X11/lib /usr/lib ; do
+    /bin/rm -f ${PROTODIR}${D}/${SUBDIR64}
+    /bin/ln -s ../../../../../build_64/proto-${PROTOMACH}-svr4${D}/${SUBDIR64} ${PROTODIR}${D}/${SUBDIR64}
+done
+
+LOGfile=logs/package_build
+
+echo '---Building packages'
+XW_PLT_PAT="`echo $XW_PLT_PACKAGES | tr ' ' '|'`"
+
+# Variables to pass to pkgmk for use in prototype files
+# They must start with lowercase letters to be resolved at pkgmk time
+PKGMK_VARS="plat_64=${PLAT_64}"
+
+for package in $PACKAGE_LIST
+do
+	cd $package
+	date
+	echo "******** Making the $package package ********"
+
+	cat pkginfo.tmpl | sed -e '/ARCH/s/ISA/'$MACH'/' -e 's/SUNW_PRODVERS=.*$/SUNW_PRODVERS='${VERSION}/ -e 's/VERSION=.*$/VERSION='${VERSION}.${BUILD},REV=${DATE}/ > pkginfo
+	if [ -f Makefile ]; then
+		echo make all
+		/usr/ccs/bin/make SOURCEDIR=$SOURCEDIR/packages all
+	fi
+
+	eval "case $package in
+	$XW_PLT_PAT)
+		if [ ! -f prototype_$MACH ]; then
+		    ln -s prototype_com prototype_$MACH
+		fi
+		echo /usr/bin/pkgmk -f prototype_$MACH -d $PACKAGE_DIR/$package -o ${PKGMK_VARS}
+		/usr/bin/pkgmk -f prototype_$MACH -d $PACKAGE_DIR/$package -o ${PKGMK_VARS}
+		;;
+	*)
+		echo /usr/bin/pkgmk -d $PACKAGE_DIR/$package -o ${PKGMK_VARS}
+		/usr/bin/pkgmk -d $PACKAGE_DIR/$package -o ${PKGMK_VARS}
+		;;
+	esac"
+
+	chmod -R a+rX $PACKAGE_DIR/$package
+	
+	echo "******** Done Making the $package package ********"
+	cd ..
+done >$LOGfile 2>&1
+
+echo result log is in $PACKAGE_DIR/$LOGfile
+
+# Create an installdir with symlinks to SUNW* pkgs
+cd $PACKAGE_DIR
+mkdir installdir
+cd installdir
+ln -s ../SUNW*/SUNW* .
+cp $SOURCEDIR/packages/upgrade-Xorg .
+chmod +x upgrade-Xorg
+
+exit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/newPkRev	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)newPkRev 1.5     05/11/01 SMI"
+#
+
+if [ x${1}x = "xx" ] ; then
+	echo need a build number
+	exit
+fi
+
+# X11 version number 
+XVERSION="6.9.0"
+OSVERSION=`uname -r | awk -F. '{printf "%s.%s",$1,$2}'`
+VERSION="${XVERSION}.${OSVERSION}"
+
+sccs edit pkgversion
+echo VERSION=\"$VERSION\" > pkgversion
+echo BUILD=\"$1\" >> pkgversion
+sccs delget -y"VERSION=${VERSION}.${1}" pkgversion
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/other_masters	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,51 @@
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# 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.
+#
+###########################################################################
+#
+# ident "%Z%%M% %I%     %E% SMI"
+#
+# Configuration file for build_src_links script
+#
+# Format of each line:
+# <subdirectory or file>	<source to link to for those contents>
+#
+# Sources may be one of these formats:
+# 	tarball:<filename>	unpacked from <filename> in tarballs/ directory
+#	<pathname>		path to a directory containing the files
+#	-			no master, only local copies from sun-srcs
+#
+# Variables may be defined as:
+# <name>=<value>
+# and referenced as $(<name>) in the source (right) side of link lines
+
+XORG_MASTER=tarball:X11R6.9.0-src.tar.bz2
+
+# X.Org base release
+xc				   		$(XORG_MASTER)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-cfg/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,41 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.3     05/11/07 SMI"
+#
+# X.Org Foundation X server for Solaris
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWxwrtl	X Window System & Graphics Runtime Library Links in /usr/lib
+P SUNWxorg-server	X.Org Foundation Xserver
+P SUNWxorg-clientlibs	X.Org Foundation X Client Libraries
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-cfg/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.5     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-cfg"
+NAME="X.Org Foundation Xserver configuration tool"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="Configuration tool for X Window System server based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-cfg/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,84 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype 1.13     05/11/07 SMI"
+#
+# X.Org server configuration tool
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+
+!search $HOME/bin
+d none X11/bin				0755 root bin
+f none X11/bin/xorgcfg			0755 root bin
+
+!search $HOME/lib
+d none X11/lib 				0755 root bin
+d none X11/lib/xorgcfg 			0755 root bin
+f none X11/lib/xorgcfg/libXaw.so.8.0=$HOME/lib/libXaw.so.8.0	0644 root bin
+
+!search $HOME/lib/X11/app-defaults
+d none X11/lib/X11			0755 root bin
+d none X11/lib/X11/app-defaults		0755 root bin
+f none X11/lib/X11/app-defaults/XOrgCfg	0444 root bin
+
+!search $HOME/include/X11/pixmaps
+d none X11/include			0755 root bin
+d none X11/include/X11			0755 root bin
+d none X11/include/X11/pixmaps		0755 root bin
+f none X11/include/X11/pixmaps/card.xpm	0444 root bin
+f none X11/include/X11/pixmaps/mouse.xpm	0444 root bin
+f none X11/include/X11/pixmaps/computer.xpm	0444 root bin
+f none X11/include/X11/pixmaps/keyboard.xpm	0444 root bin
+f none X11/include/X11/pixmaps/monitor.xpm	0444 root bin
+
+!search $HOME/include/X11/bitmaps
+d none X11/include			0755 root bin
+d none X11/include/X11			0755 root bin
+d none X11/include/X11/bitmaps		0755 root bin
+f none X11/include/X11/bitmaps/card.xbm	0444 root bin
+f none X11/include/X11/bitmaps/up.xbm	0444 root bin
+f none X11/include/X11/bitmaps/down.xbm	0444 root bin
+f none X11/include/X11/bitmaps/left.xbm	0444 root bin
+f none X11/include/X11/bitmaps/right.xbm	0444 root bin
+f none X11/include/X11/bitmaps/shorter.xbm	0444 root bin
+f none X11/include/X11/bitmaps/narrower.xbm	0444 root bin
+f none X11/include/X11/bitmaps/wider.xbm	0444 root bin
+f none X11/include/X11/bitmaps/taller.xbm	0444 root bin
+f none X11/include/X11/bitmaps/mouse.xbm	0444 root bin
+f none X11/include/X11/bitmaps/keyboard.xbm	0444 root bin
+f none X11/include/X11/bitmaps/monitor.xbm	0444 root bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-client-docs/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.2     05/11/07 SMI"
+#
+# X.Org Foundation Xserver documentation
+
+P SUNWcsr       Core Solaris, (Root)
+P SUNWcsu       Core Solaris, (Usr)
+P SUNWcsl       Core Solaris, (Shared Libs)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-client-docs/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.2     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-client-docs"
+NAME="X.Org Foundation X client programs documentation"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="Documentation for X Window System client programs based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-client-docs/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,56 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype 1.3     05/11/07 SMI"
+#
+# X.Org Foundation X clients for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+d none X11/share 0755 root bin
+
+d none X11/share/man 0755 root bin
+s none X11/man=share/man
+
+!search $HOME/share/man/man1
+d none X11/share/man/man1 0755 root bin
+f none X11/share/man/man1/glxgears.1 0444 root bin
+f none X11/share/man/man1/glxinfo.1 0444 root bin
+f none X11/share/man/man1/xgamma.1 0444 root bin
+f none X11/share/man/man1/xrandr.1 0444 root bin
+f none X11/share/man/man1/xvidtune.1 0444 root bin
+f none X11/share/man/man1/xvinfo.1 0444 root bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-client-programs/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,43 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.2     05/11/07 SMI"
+#
+# X.Org Foundation X client programs for Solaris
+
+P SUNWcsr		Core Solaris, (Root)
+P SUNWcsu		Core Solaris, (Usr)
+P SUNWcsl		Core Solaris, (Shared Libs)
+P SUNWlibms		Sun Compilers Bundled shared libm
+P SUNWxwplt		X Window System platform software
+P SUNWxorg-clientlibs	X.Org Foundation X Client Libraries
+P SUNWxwrtl		X Window System & Graphics Runtime Library Links in /usr/lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-client-programs/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.2     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-client-programs"
+NAME="X.Org Foundation X Client Programs"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="X Window System client programs based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-client-programs/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,56 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype 1.3     05/11/07 SMI"
+#
+# X.Org Foundation X client programs for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 				0755 root bin
+
+!search $HOME/bin
+d none X11/bin 				0755 root bin
+f none X11/bin/xgamma	 		0755 root bin
+f none X11/bin/xrandr	 		0755 root bin
+f none X11/bin/xvidtune	 		0755 root bin
+f none X11/bin/xvinfo	 		0755 root bin
+
+d none X11/lib 				0755 root bin
+d none X11/lib/X11			0755 root bin
+
+!search $HOME/lib/X11/app-defaults
+d none X11/lib/X11/app-defaults		0755 root bin
+f none X11/lib/X11/app-defaults/Xvidtune 0644 root bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-clientlibs/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.3     05/11/07 SMI"
+#
+# X.Org Foundation X libraries for Solaris
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWlibms	Sun Compilers Bundled shared libm
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-clientlibs/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+#########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.3     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-clientlibs"
+NAME="X.Org Foundation X Client Libraries"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="X Window System client libraries based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-clientlibs/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,74 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype 1.9     05/11/07 SMI"
+#
+# X.Org Foundation X client libraries for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+
+!search $HOME/lib
+d none X11/lib 				0755 root bin
+f none X11/lib/libXrandr.so.2 		0644 root bin
+s none X11/lib/libXrandr.so=libXrandr.so.2
+f none X11/lib/libXv.so.1	 		0644 root bin
+s none X11/lib/libXv.so=libXv.so.1
+f none X11/lib/libXvMC.so.1	 		0644 root bin
+s none X11/lib/libXvMC.so=libXvMC.so.1
+f none X11/lib/libxkbfile.so.5          0644 root bin
+s none X11/lib/libxkbfile.so=libxkbfile.so.5
+f none X11/lib/libXxf86misc.so.1		0644 root bin
+s none X11/lib/libXxf86misc.so=libXxf86misc.so.1
+f none X11/lib/libXxf86vm.so.1			0644 root bin
+s none X11/lib/libXxf86vm.so=libXxf86vm.so.1
+
+
+!search $HOME/lib/$plat_64
+d none X11/lib/$plat_64				0755 root bin
+s none X11/lib/64=$plat_64
+f none X11/lib/$plat_64/libXrandr.so.2	 		0644 root bin
+s none X11/lib/$plat_64/libXrandr.so=libXrandr.so.2
+f none X11/lib/$plat_64/libXv.so.1	 		0644 root bin
+s none X11/lib/$plat_64/libXv.so=libXv.so.1
+f none X11/lib/$plat_64/libXvMC.so.1	 		0644 root bin
+s none X11/lib/$plat_64/libXvMC.so=libXvMC.so.1
+f none X11/lib/$plat_64/libxkbfile.so.5  	        0644 root bin
+s none X11/lib/$plat_64/libxkbfile.so=libxkbfile.so.5
+f none X11/lib/$plat_64/libXxf86misc.so.1		0644 root bin
+s none X11/lib/$plat_64/libXxf86misc.so=libXxf86misc.so.1
+f none X11/lib/$plat_64/libXxf86vm.so.1			0644 root bin
+s none X11/lib/$plat_64/libXxf86vm.so=libXxf86vm.so.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-compatlinks/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.2     05/11/07 SMI"
+#
+# X11 Compatbility Symlinks
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-compatlinks/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.2     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-compatlinks"
+NAME="X11 Compatibility Links"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="Symbolic links for X Window System software compatibility with other releases"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-compatlinks/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype 1.2     05/11/07 SMI"
+#
+# Symlinks for compatibility with X11 delivery locations on other systems
+
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 				0755 root bin
+d none X11/lib 				0755 root bin
+d none X11/bin 				0755 root bin
+
+s none X11R6=X11
+s none lib/X11=../X11/lib
+s none bin/X11=../X11/bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-devel-docs/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.2     05/11/07 SMI"
+#
+# X.Org Foundation client libraries developer documentation
+
+P SUNWcsr       Core Solaris, (Root)
+P SUNWcsu       Core Solaris, (Usr)
+P SUNWcsl       Core Solaris, (Shared Libs)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-devel-docs/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.2     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-devel-docs"
+NAME="X.Org Foundation client API documentation"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="Documentation for programming clients using X Window System libraries based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-devel-docs/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,138 @@
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)prototype 1.2     05/11/02 SMI"
+#
+# X.Org Foundation X client library documentation for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+d none X11/share 0755 root bin
+d none X11/share/man 0755 root bin
+s none X11/man=share/man
+
+!search $HOME/share/man/man3
+d none X11/share/man/man3 0755 root bin
+f none X11/share/man/man3/Xfixes.3 0444 root bin
+f none X11/share/man/man3/Xft.3 0444 root bin
+
+!search $HOME/share/man/man3Xrandr
+d none X11/share/man/man3Xrandr 0755 root bin
+f none X11/share/man/man3Xrandr/Xrandr.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRConfig.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRConfigCurrentConfiguration.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRConfigCurrentRate.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRConfigRates.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRConfigRotations.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRConfigSizes.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRConfigTimes.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRFreeScreenConfigInfo.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRGetScreenInfo.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRQueryExtension.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRQueryVersion.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRRootToScreen.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRScreenConfig.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRSelectInput.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRSetScreenConfig.3Xrandr 0444 root bin
+f none X11/share/man/man3Xrandr/XRRSetScreenConfigAndRate.3Xrandr 0444 root bin
+
+!search $HOME/share/man/man3Xevie
+d none X11/share/man/man3Xevie 0755 root bin
+f none X11/share/man/man3Xevie/Xevie.3Xevie 0444 root bin
+f none X11/share/man/man3Xevie/XevieEnd.3Xevie 0444 root bin
+f none X11/share/man/man3Xevie/XevieQueryVersion.3Xevie 0444 root bin
+f none X11/share/man/man3Xevie/XevieSelectInput.3Xevie 0444 root bin
+f none X11/share/man/man3Xevie/XevieSendEvent.3Xevie 0444 root bin
+f none X11/share/man/man3Xevie/XevieStart.3Xevie 0444 root bin
+
+!search $HOME/share/man/man3Xv
+d none X11/share/man/man3Xv 0755 root bin
+f none X11/share/man/man3Xv/Xv.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvFreeAdaptorInfo.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvFreeEncodingInfo.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvGetPortAttribute.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvGetStill.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvGetVideo.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvGrabPort.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvPortNotify.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvPutStill.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvPutVideo.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvQueryAdaptors.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvQueryBestSize.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvQueryEncodings.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvQueryExtension.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvSelectPortNotify.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvSelectVideoNotify.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvSetPortAttribute.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvStopVideo.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvUngrabPort.3Xv 0444 root bin
+f none X11/share/man/man3Xv/XvVideoNotify.3Xv 0444 root bin
+
+!search $HOME/share/man/man3Xxf86vm
+d none X11/share/man/man3Xxf86vm 0755 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidMode.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeDeleteModeLine.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetAllModeLines.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetDotClocks.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetGamma.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetGammaRamp.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetGammaRampSize.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetModeLine.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetMonitor.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetPermissions.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeGetViewPort.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeLockModeSwitch.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeModModeLine.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeQueryExtension.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeQueryVersion.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeSetClientVersion.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeSetGamma.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeSetGammaRamp.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeSetViewPort.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeSwitchMode.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeSwitchToMode.3Xxf86vm 0444 root bin
+f none X11/share/man/man3Xxf86vm/XF86VidModeValidateModeLine.3Xxf86vm 0444 root bin
+
+!search $HOME/share/man/man3Xxf86misc
+d none X11/share/man/man3Xxf86misc 0755 root bin
+f none X11/share/man/man3Xxf86misc/XF86Misc.3Xxf86misc 0444 root bin
+f none X11/share/man/man3Xxf86misc/XF86MiscGetKbdSettings.3Xxf86misc 0444 root bin
+f none X11/share/man/man3Xxf86misc/XF86MiscGetMouseSettings.3Xxf86misc 0444 root bin
+f none X11/share/man/man3Xxf86misc/XF86MiscQueryExtension.3Xxf86misc 0444 root bin
+f none X11/share/man/man3Xxf86misc/XF86MiscQueryVersion.3Xxf86misc 0444 root bin
+f none X11/share/man/man3Xxf86misc/XF86MiscSetKbdSettings.3Xxf86misc 0444 root bin
+f none X11/share/man/man3Xxf86misc/XF86MiscSetMouseSettings.3Xxf86misc 0444 root bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-doc/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.3     05/11/07 SMI"
+#
+# X.Org Foundation Xserver documentation
+
+P SUNWcsr       Core Solaris, (Root)
+P SUNWcsu       Core Solaris, (Usr)
+P SUNWcsl       Core Solaris, (Shared Libs)
+P SUNWxwman	X Window System online user man pages
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-doc/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,48 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.4     05/11/07 SMI"
+#
+PKG="SUNWxorg-doc"
+NAME="X.Org Foundation Xserver documentation"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="Documentation for X Window System server based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-doc/prototype_com	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,92 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype_com 1.13     05/11/07 SMI"
+#
+# X.Org Foundation X server for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+d none X11/share 0755 root bin
+
+!search $HOME/share/doc
+d none X11/share/doc 0755 root bin
+f none X11/share/doc/LICENSE 0444 root bin
+#f none X11/share/doc/README.DRI 0444 root bin
+f none X11/share/doc/README.XKB-Config 0444 root bin
+f none X11/share/doc/README.XKB-Enhancing 0444 root bin
+f none X11/share/doc/README.ati 0444 root bin
+f none X11/share/doc/README.fonts 0444 root bin
+f none X11/share/doc/README.mouse 0444 root bin
+f none X11/share/doc/RELNOTES 0444 root bin
+
+!search $HOME/lib/X11/xkb
+d none X11/lib 0755 root bin
+d none X11/lib/X11 0755 root bin
+s none X11/lib/X11/doc=../../share/doc
+d none X11/lib/X11/xkb 0755 root bin
+s none X11/lib/X11/xkb/README.config=../../../share/doc/README.XKB-Config
+s none X11/lib/X11/xkb/README.enhancing=../../../share/doc/README.XKB-Enhancing
+
+d none X11/share/man 0755 root bin
+s none X11/man=share/man
+
+!search $HOME/share/man/man1
+d none X11/share/man/man1 0755 root bin
+f none X11/share/man/man1/Xorg.1 0444 root bin
+f none X11/share/man/man1/getconfig.1 0444 root bin
+f none X11/share/man/man1/gtf.1 0444 root bin
+f none X11/share/man/man1/pcitweak.1 0444 root bin
+f none X11/share/man/man1/scanpci.1 0444 root bin
+f none X11/share/man/man1/xkbcomp.1 0444 root bin
+f none X11/share/man/man1/xorgcfg.1 0444 root bin
+f none X11/share/man/man1/xorgconfig.1 0444 root bin
+
+!search $HOME/share/man/man4
+d none X11/share/man/man4 0755 root bin
+f none X11/share/man/man4/xorg.conf.4 0444 root bin
+f none X11/share/man/man4/getconfig.4 0444 root bin
+
+!search $HOME/share/man/man7
+d none X11/share/man/man7 0755 root bin
+f none X11/share/man/man7/kbd.7 0444 root bin
+f none X11/share/man/man7/keyboard.7 0444 root bin
+f none X11/share/man/man7/mouse.7 0444 root bin
+f none X11/share/man/man7/vesa.7 0444 root bin
+f none X11/share/man/man7/vga.7 0444 root bin
+f none X11/share/man/man7/void.7 0444 root bin
+f none X11/share/man/man7/wacom.7 0444 root bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-doc/prototype_i386	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,90 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype_i386 1.5     05/11/07 SMI"
+#
+# X.Org Foundation X server for Solaris
+
+# Include ISA independent files (prototype_com)
+#
+!include prototype_com
+
+!search $HOME/share/doc
+f none X11/share/doc/README.I128 0444 root bin
+f none X11/share/doc/README.SiS 0444 root bin
+f none X11/share/doc/README.apm 0444 root bin
+f none X11/share/doc/README.chips 0444 root bin
+f none X11/share/doc/README.cyrix 0444 root bin
+f none X11/share/doc/README.i740 0444 root bin
+f none X11/share/doc/README.i810 0444 root bin
+f none X11/share/doc/README.newport 0444 root bin
+f none X11/share/doc/README.r128 0444 root bin
+f none X11/share/doc/README.rapidaccess 0444 root bin
+f none X11/share/doc/README.rendition 0444 root bin
+f none X11/share/doc/README.s3virge 0444 root bin
+
+!search $HOME/share/man/man7
+f none X11/share/man/man7/apm.7 0444 root bin
+f none X11/share/man/man7/chips.7 0444 root bin
+f none X11/share/man/man7/cirrus.7 0444 root bin
+f none X11/share/man/man7/citron.7 0444 root bin
+f none X11/share/man/man7/cyrix.7 0444 root bin
+f none X11/share/man/man7/dmc.7 0444 root bin
+f none X11/share/man/man7/dynapro.7 0444 root bin
+f none X11/share/man/man7/elographics.7 0444 root bin
+f none X11/share/man/man7/fpit.7 0444 root bin
+f none X11/share/man/man7/glint.7 0444 root bin
+f none X11/share/man/man7/i128.7 0444 root bin
+f none X11/share/man/man7/i740.7 0444 root bin
+f none X11/share/man/man7/i810.7 0444 root bin
+f none X11/share/man/man7/mga.7 0444 root bin
+f none X11/share/man/man7/microtouch.7 0444 root bin
+f none X11/share/man/man7/mutouch.7 0444 root bin
+f none X11/share/man/man7/neomagic.7 0444 root bin
+f none X11/share/man/man7/nsc.7 0444 root bin
+f none X11/share/man/man7/nv.7 0444 root bin
+f none X11/share/man/man7/palmax.7 0444 root bin
+f none X11/share/man/man7/penmount.7 0444 root bin
+f none X11/share/man/man7/r128.7 0444 root bin
+f none X11/share/man/man7/radeon.7 0444 root bin
+f none X11/share/man/man7/rendition.7 0444 root bin
+f none X11/share/man/man7/s3virge.7 0444 root bin
+f none X11/share/man/man7/savage.7 0444 root bin
+f none X11/share/man/man7/siliconmotion.7 0444 root bin
+f none X11/share/man/man7/sis.7 0444 root bin
+f none X11/share/man/man7/tdfx.7 0444 root bin
+f none X11/share/man/man7/tek4957.7 0444 root bin
+f none X11/share/man/man7/trident.7 0444 root bin
+f none X11/share/man/man7/tseng.7 0444 root bin
+f none X11/share/man/man7/via.7 0444 root bin
+f none X11/share/man/man7/vmware.7 0444 root bin
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-graphics-ddx/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.2     05/11/07 SMI"
+#
+# X.Org Foundation X server graphics driver modules for Solaris
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWesu	Extended System Utilities
+P SUNWxorg-server	X.org Foundation Xserver
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-graphics-ddx/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.3     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-graphics-ddx"
+NAME="X.Org Foundation Xserver Graphics Device Modules"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="Graphics device DDX modules for X Window System server based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-graphics-ddx/prototype_com	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,54 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype_com 1.3     05/11/07 SMI"
+#
+# X.Org Foundation X server for Solaris Graphics Device DDX modules
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+d none X11/lib 0755 root bin
+d none X11/lib/X11 0755 root bin
+d none X11/lib/modules 0755 root bin
+
+!search $HOME/lib/modules/drivers
+d none X11/lib/modules/drivers 0755 root bin
+f none X11/lib/modules/drivers/ati_drv.so 0755 root bin
+f none X11/lib/modules/drivers/atimisc_drv.so 0755 root bin
+f none X11/lib/modules/drivers/radeon_drv.so 0755 root bin
+f none X11/lib/modules/drivers/r128_drv.so 0755 root bin
+f none X11/lib/modules/drivers/vesa_drv.so 0755 root bin
+f none X11/lib/modules/drivers/vga_drv.so 0755 root bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-graphics-ddx/prototype_i386	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,90 @@
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)prototype_i386 1.6     06/03/21 SMI"
+#
+# X.Org Foundation X server for Solaris
+
+# Include ISA independent files (prototype_com)
+#
+!include prototype_com
+
+!search $HOME/lib/modules/
+d none X11/lib/modules 0755 root bin
+f none X11/lib/modules/v10002d.uc 0444 root bin
+f none X11/lib/modules/v20002d.uc 0444 root bin
+
+!search $HOME/lib/modules/drivers
+d none X11/lib/modules/drivers 0755 root bin
+f none X11/lib/modules/drivers/apm_drv.so 0755 root bin
+f none X11/lib/modules/drivers/ark_drv.so 0755 root bin
+f none X11/lib/modules/drivers/ast_drv.so 0755 root bin
+f none X11/lib/modules/drivers/chips_drv.so 0755 root bin
+f none X11/lib/modules/drivers/cirrus_alpine.so 0755 root bin
+f none X11/lib/modules/drivers/cirrus_drv.so 0755 root bin
+f none X11/lib/modules/drivers/cirrus_laguna.so 0755 root bin
+f none X11/lib/modules/drivers/cyrix_drv.so 0755 root bin
+f none X11/lib/modules/drivers/glint_drv.so 0755 root bin
+f none X11/lib/modules/drivers/i128_drv.so 0755 root bin
+f none X11/lib/modules/drivers/i740_drv.so 0755 root bin
+f none X11/lib/modules/drivers/i810_drv.so 0755 root bin
+f none X11/lib/modules/drivers/mga_drv.so 0755 root bin
+f none X11/lib/modules/drivers/neomagic_drv.so 0755 root bin
+f none X11/lib/modules/drivers/nsc_drv.so 0755 root bin
+f none X11/lib/modules/drivers/nv_drv.so 0755 root bin
+f none X11/lib/modules/drivers/rendition_drv.so 0755 root bin
+f none X11/lib/modules/drivers/riva128.so 0755 root bin
+f none X11/lib/modules/drivers/s3_drv.so 0755 root bin
+f none X11/lib/modules/drivers/s3virge_drv.so 0755 root bin
+f none X11/lib/modules/drivers/savage_drv.so 0755 root bin
+f none X11/lib/modules/drivers/siliconmotion_drv.so 0755 root bin
+f none X11/lib/modules/drivers/sis_drv.so 0755 root bin
+f none X11/lib/modules/drivers/tdfx_drv.so 0755 root bin
+f none X11/lib/modules/drivers/tga_drv.so 0755 root bin
+f none X11/lib/modules/drivers/trident_drv.so 0755 root bin
+f none X11/lib/modules/drivers/tseng_drv.so 0755 root bin
+f none X11/lib/modules/drivers/via_drv.so 0755 root bin
+f none X11/lib/modules/drivers/vmware_drv.so 0755 root bin
+
+!search $HOME/lib/modules/multimedia
+d none X11/lib/modules/multimedia 0755 root bin
+f none X11/lib/modules/multimedia/bt829_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/fi1236_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/msp3430_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/tda8425_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/tda9850_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/tda9885_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/theatre200_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/theatre_detect_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/theatre_drv.so 0755 root bin
+f none X11/lib/modules/multimedia/uda1380_drv.so 0755 root bin
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-headers/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.3     05/11/07 SMI"
+#
+# Header files for X.Org Foundation X libraries for Solaris
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWxwinc	X Window System include files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-headers/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,48 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.3     05/11/07 SMI"
+
+PKG="SUNWxorg-headers"
+NAME="X.Org Foundation X11 client headers"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="X Window System client library header files based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-headers/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,71 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)prototype 1.5     05/11/07 SMI"
+#
+# X.Org Foundation X client libraries for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+
+d none X11/include				0755 root bin
+d none X11/include/X11				0755 root bin
+
+!search $HOME/include/X11/extensions
+d none X11/include/X11/extensions		0755 root bin
+f none X11/include/X11/extensions/Xv.h		0444 root bin
+f none X11/include/X11/extensions/Xvlib.h	0444 root bin
+f none X11/include/X11/extensions/Xvproto.h	0444 root bin
+f none X11/include/X11/extensions/XvMC.h	0444 root bin
+f none X11/include/X11/extensions/XvMClib.h	0444 root bin
+f none X11/include/X11/extensions/XvMCproto.h	0444 root bin
+
+f none X11/include/X11/extensions/Xrandr.h	0444 root bin
+f none X11/include/X11/extensions/randr.h	0444 root bin
+f none X11/include/X11/extensions/randrproto.h	0444 root bin
+
+# libxkbfile
+f none X11/include/X11/extensions/XKBbells.h	0444 root bin
+f none X11/include/X11/extensions/XKBconfig.h	0444 root bin
+f none X11/include/X11/extensions/XKBfile.h	0444 root bin
+f none X11/include/X11/extensions/XKBrules.h	0444 root bin
+f none X11/include/X11/extensions/XKBsrv.h	0444 root bin
+
+f none X11/include/X11/extensions/xf86misc.h	0444 root bin
+f none X11/include/X11/extensions/xf86mscstr.h	0444 root bin
+f none X11/include/X11/extensions/xf86vmode.h	0444 root bin
+f none X11/include/X11/extensions/xf86vmstr.h	0444 root bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-mesa/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.3     05/11/07 SMI"
+#
+# Mesa OpenGL workalike for Xorg on Solaris
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWlibms	Sun Compilers Bundled shared libm
+P SUNWxorg-server X.Org Foundation Xserver
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-mesa/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.4     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-mesa"
+NAME="Xorg Server Mesa Modules and Libraries"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="Server modules and client libraries for X Window System GLX extension based on Mesa open source project"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-mesa/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,198 @@
+##########################################################################
+#
+# Copyright 2006 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.
+#
+##########################################################################
+#
+# ident	"@(#)prototype	1.9	06/02/03 SMI"
+#
+# Mesa - OpenGL Workalike for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+
+# X client-side components
+!search $HOME/lib
+d none X11/lib 0755 root bin
+d none X11/lib/mesa 0755 root bin
+f none X11/lib/mesa/libGL.so.1 0755 root bin
+s none X11/lib/mesa/libGL.so=libGL.so.1 0755 root bin
+f none X11/lib/mesa/libGLU.so.1 0755 root bin
+s none X11/lib/mesa/libGLU.so=libGLU.so.1 0755 root bin
+f none X11/lib/mesa/libGLw.so.1 0755 root bin
+s none X11/lib/mesa/libGLw.so=libGLw.so.1 0755 root bin
+f none X11/lib/mesa/libOSMesa.so.4.0 0755 root bin
+s none X11/lib/mesa/libOSMesa.so=libOSMesa.so.4.0 0755 root bin
+
+!search $HOME/lib/amd64
+d none X11/lib/mesa/amd64 0755 root bin
+s none X11/lib/mesa/64=amd64
+f none X11/lib/mesa/amd64/libGL.so.1 0755 root bin
+s none X11/lib/mesa/amd64/libGL.so=libGL.so.1 0755 root bin
+f none X11/lib/mesa/amd64/libGLU.so.1 0755 root bin
+s none X11/lib/mesa/amd64/libGLU.so=libGLU.so.1 0755 root bin
+f none X11/lib/mesa/amd64/libGLw.so.1 0755 root bin
+s none X11/lib/mesa/amd64/libGLw.so=libGLw.so.1 0755 root bin
+f none X11/lib/mesa/amd64/libOSMesa.so.4.0 0755 root bin
+s none X11/lib/mesa/amd64/libOSMesa.so=libOSMesa.so.4.0 0755 root bin
+
+s none X11/lib/libGL.so=GL/libGL.so 0755 root bin
+s none X11/lib/libGL.so.1=GL/libGL.so.1 0755 root bin
+s none X11/lib/libGLU.so=GL/libGLU.so 0755 root bin
+s none X11/lib/libGLU.so.1=GL/libGLU.so.1 0755 root bin
+s none X11/lib/libGLw.so=GL/libGLw.so 0755 root bin
+s none X11/lib/libGLw.so.1=GL/libGLw.so.1 0755 root bin
+d none X11/lib/GL 0755 root bin
+s none X11/lib/GL/libGL.so=libGL.so.1 0755 root bin
+s none X11/lib/GL/libGL.so.1=../../../../var/run/opengl/lib/libGL.so.1 0755 root bin
+s none X11/lib/GL/libGLU.so=../mesa/libGLU.so 0755 root bin
+s none X11/lib/GL/libGLU.so.1=../mesa/libGLU.so.1 0755 root bin
+s none X11/lib/GL/libGLw.so=../mesa/libGLw.so 0755 root bin
+s none X11/lib/GL/libGLw.so.1=../mesa/libGLw.so.1 0755 root bin
+s none X11/lib/GL/libOSMesa.so.4.0=../mesa/libOSMesa.so.4.0 0755 root bin
+s none X11/lib/GL/libOSMesa.so=libOSMesa.so.4.0 0755 root bin
+
+d none X11/lib/amd64 0755 root bin
+s none X11/lib/64=amd64
+s none X11/lib/amd64/libGL.so=../GL/amd64/libGL.so 0755 root bin
+s none X11/lib/amd64/libGL.so.1=../GL/amd64/libGL.so.1 0755 root bin
+s none X11/lib/amd64/libGLU.so=../GL/amd64/libGLU.so 0755 root bin
+s none X11/lib/amd64/libGLU.so.1=../GL/amd64/libGLU.so.1 0755 root bin
+s none X11/lib/amd64/libGLw.so=../GL/amd64/libGLw.so 0755 root bin
+s none X11/lib/amd64/libGLw.so.1=../GL/amd64/libGLw.so.1 0755 root bin
+d none X11/lib/GL/amd64 0755 root bin
+s none X11/lib/GL/amd64/libGL.so=libGL.so.1 0755 root bin
+s none X11/lib/GL/amd64/libGL.so.1=../../../../../var/run/opengl/lib/amd64/libGL.so.1 0755 root bin
+s none X11/lib/GL/amd64/libGLU.so=../../mesa/amd64/libGLU.so 0755 root bin
+s none X11/lib/GL/amd64/libGLU.so.1=../../mesa/amd64/libGLU.so.1 0755 root bin
+s none X11/lib/GL/amd64/libGLw.so=../../mesa/amd64/libGLw.so 0755 root bin
+s none X11/lib/GL/amd64/libGLw.so.1=../../mesa/amd64/libGLw.so.1 0755 root bin
+s none X11/lib/GL/amd64/libOSMesa.so.4.0=../../mesa/amd64/libOSMesa.so.4.0 0755 root bin
+s none X11/lib/GL/amd64/libOSMesa.so=libOSMesa.so.4.0 0755 root bin
+
+
+!search $HOME/include/GL
+d none X11/include 0755 root bin
+d none X11/include/mesa 0755 root bin
+f none X11/include/mesa/gl.h 0755 root bin
+f none X11/include/mesa/glext.h 0755 root bin
+f none X11/include/mesa/glu.h 0755 root bin
+f none X11/include/mesa/glx.h 0755 root bin
+f none X11/include/mesa/glxext.h 0755 root bin
+f none X11/include/mesa/glxint.h 0755 root bin
+f none X11/include/mesa/glxmd.h 0755 root bin
+f none X11/include/mesa/glxproto.h 0755 root bin
+f none X11/include/mesa/glxtokens.h 0755 root bin
+f none X11/include/mesa/osmesa.h 0755 root bin
+f none X11/include/mesa/GLwDrawA.h 0755 root bin
+f none X11/include/mesa/GLwDrawAP.h 0755 root bin
+f none X11/include/mesa/GLwMDrawA.h 0755 root bin
+f none X11/include/mesa/GLwMDrawAP.h 0755 root bin
+d none X11/include/GL 0755 root bin
+s none X11/include/GL/gl.h=../../../../var/run/opengl/include/gl.h 0755 root bin
+s none X11/include/GL/glext.h=../../../var/run/opengl/include/glxext.h  0755 root bin
+s none X11/include/GL/glu.h=../mesa/glu.h 0755 root bin
+s none X11/include/GL/glx.h=../../../../var/run/opengl/include/glx.h 0755 root bin
+s none X11/include/GL/glxext.h=../../../../var/run/opengl/include/glxext.h 0755 root bin
+s none X11/include/GL/glxint.h=../mesa/glxint.h 0755 root bin
+s none X11/include/GL/glxmd.h=../mesa/glxmd.h 0755 root bin
+s none X11/include/GL/glxproto.h=../mesa/glxproto.h 0755 root bin
+s none X11/include/GL/glxtokens.h=../mesa/glxtokens.h 0755 root bin
+s none X11/include/GL/osmesa.h=../mesa/osmesa.h 0755 root bin
+s none X11/include/GL/GLwDrawA.h=../mesa/GLwDrawA.h 0755 root bin
+s none X11/include/GL/GLwDrawAP.h=../mesa/GLwDrawAP.h 0755 root bin
+s none X11/include/GL/GLwMDrawA.h=../mesa/GLwMDrawA.h 0755 root bin
+s none X11/include/GL/GLwMDrawAP.h=../mesa/GLwMDrawAP.h 0755 root bin
+
+
+# X client-side programs
+!search $HOME/bin
+d none X11/bin 0755 root bin
+f none X11/bin/glxinfo 0755 root bin
+
+# X client-side demo programs
+!search $HOME/bin
+d none X11/demo 0755 root bin
+f none X11/demo/glxgears 0755 root bin
+
+# X server-side components
+d none X11/lib/modules 0755 root bin
+d none X11/lib/modules/extensions 0755 root bin
+!search $HOME/lib/modules/extensions
+d none X11/lib/modules/extensions/mesa 0755 root bin
+f none X11/lib/modules/extensions/mesa/libGLcore.so 0755 root bin
+f none X11/lib/modules/extensions/mesa/libglx.so 0755 root bin
+s none X11/lib/modules/extensions/GL=mesa 0755 root bin
+s none X11/lib/modules/extensions/libGLcore.so=GL/libGLcore.so 0755 root bin
+s none X11/lib/modules/extensions/libglx.so=../../../../../var/run/opengl/server/libglx.so 0755 root bin
+
+# "legacy" SPARC links for GLU/GLw headers and libraries
+
+d none lib 0755 root bin
+d none lib 0755 root bin
+s none lib/libGL.so=../X11/lib/libGL.so 0755 root bin
+s none lib/libGL.so.1=../X11/lib/libGL.so.1 0755 root bin
+s none lib/libGLU.so=../X11/lib/libGLU.so 0755 root bin
+s none lib/libGLU.so.1=../X11/lib/libGLU.so.1 0755 root bin
+s none lib/libGLw.so=../X11/lib/libGLw.so 0755 root bin
+s none lib/libGLw.so.1=../X11/lib/libGLw.so.1 0755 root bin
+d none lib/amd64 0755 root bin
+s none lib/amd64/libGL.so=../../X11/lib/amd64/libGL.so 0755 root bin
+s none lib/amd64/libGL.so.1=../../X11/lib/amd64/libGL.so.1 0755 root bin
+s none lib/amd64/libGLU.so=../../X11/lib/amd64/libGLU.so 0755 root bin
+s none lib/amd64/libGLU.so.1=../../X11/lib/amd64/libGLU.so.1 0755 root bin
+s none lib/amd64/libGLw.so=../../X11/lib/amd64/libGLw.so 0755 root bin
+s none lib/amd64/libGLw.so.1=../../X11/lib/amd64/libGLw.so.1 0755 root bin
+
+d none openwin 0755 root bin
+d none openwin/lib 0755 root bin
+s none openwin/lib/libGL.so=../../X11/lib/libGL.so 0755 root bin
+s none openwin/lib/libGL.so.1=../../X11/lib/libGL.so.1 0755 root bin
+s none openwin/lib/libGLU.so=../../X11/lib/libGLU.so 0755 root bin
+s none openwin/lib/libGLU.so.1=../../X11/lib/libGLU.so.1 0755 root bin
+s none openwin/lib/libGLw.so=../../X11/lib/libGLw.so 0755 root bin
+s none openwin/lib/libGLw.so.1=../../X11/lib/libGLw.so.1 0755 root bin
+d none openwin/lib/amd64 0755 root bin
+s none openwin/lib/amd64/libGL.so=../../../X11/lib/amd64/libGL.so 0755 root bin
+s none openwin/lib/amd64/libGL.so.1=../../../X11/lib/amd64/libGL.so.1 0755 root bin
+s none openwin/lib/amd64/libGLU.so=../../../X11/lib/amd64/libGLU.so 0755 root bin
+s none openwin/lib/amd64/libGLU.so.1=../../../X11/lib/amd64/libGLU.so.1 0755 root bin
+s none openwin/lib/amd64/libGLw.so=../../../X11/lib/amd64/libGLw.so 0755 root bin
+s none openwin/lib/amd64/libGLw.so.1=../../../X11/lib/amd64/libGLw.so.1 0755 root bin
+
+d none include 0755 root bin
+s none include/GL=../X11/include/GL
+d none openwin 0755 root bin
+d none openwin/share 0755 root bin
+d none openwin/share/include 0755 root bin
+s none openwin/share/include/GL=../../../X11/include/GL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-server/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,46 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.5     05/11/07 SMI"
+#
+# X.Org Foundation X server for Solaris
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWperl584usr Perl 5.8.4 programming language (non-core)
+P SUNWesu	Extended System Utilities
+P SUNWxwfnt	X Window System Fonts
+P SUNWlibms	Sun Compilers Bundled shared libm
+P SUNWzlib	The Zip compression library
+P SUNWxorg-xkb	X.org Foundation Xserver keyboard layouts
+P SUNWxsvc	Xserver pseudo driver
+P SUNWstsf	Standard Type Services Framework
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-server/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,49 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.4     05/11/07 SMI"
+#
+
+PKG="SUNWxorg-server"
+NAME="X.Org Foundation Xserver"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="X Window System server based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-server/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,242 @@
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)prototype 1.15     06/03/28 SMI"
+#
+# X.Org Foundation X server for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+
+!search $HOME/bin
+d none X11/bin 0755 root bin
+f none X11/bin/Xorg 4755 root bin
+f none X11/bin/gtf 0555 root bin
+f none X11/bin/pcitweak 0555 root bin
+f none X11/bin/scanpci 0555 root bin
+f none X11/bin/xorgconfig 0555 root bin
+
+d none X11/lib 0755 root bin
+
+!search $HOME/lib/X11 
+d none X11/lib/X11 0755 root bin
+f none X11/lib/X11/Options 0444 root bin
+f none X11/lib/X11/XKeysymDB 0444 root bin
+s none X11/lib/X11/rgb.txt=../../../openwin/lib/X11/rgb.txt
+f none X11/lib/X11/Cards 0444 root bin
+
+d none X11/lib/X11/fonts 0755 root bin
+s none X11/lib/X11/fonts/F3bitmaps=../../../../openwin/lib/X11/fonts/F3bitmaps
+s none X11/lib/X11/fonts/TrueType=../../../../openwin/lib/X11/fonts/TrueType
+s none X11/lib/X11/fonts/Type1=../../../../openwin/lib/X11/fonts/Type1
+s none X11/lib/X11/fonts/misc=../../../../openwin/lib/X11/fonts/misc
+s none X11/lib/X11/fonts/75dpi=../../../../openwin/lib/X11/fonts/75dpi
+s none X11/lib/X11/fonts/100dpi=../../../../openwin/lib/X11/fonts/100dpi
+
+!search $HOME/lib/X11/fonts/encodings
+d none X11/lib/X11/fonts/encodings 0755 root bin
+f none X11/lib/X11/fonts/encodings/adobe-dingbats.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/adobe-standard.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/adobe-symbol.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/ansi-1251.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/armscii-8.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/dec-special.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/encodings.dir 0444 root bin
+f none X11/lib/X11/fonts/encodings/ibm-cp437.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/ibm-cp850.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/ibm-cp852.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/ibm-cp866.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/iso8859-11.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/iso8859-13.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/iso8859-16.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/iso8859-6.16.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/iso8859-6.8x.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1250.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1251.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1252.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1253.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1254.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1255.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1256.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1257.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-cp1258.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/microsoft-win3.1.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/mulearabic-0.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/mulearabic-1.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/mulearabic-2.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/mulelao-1.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/tcvn-0.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/tis620-2.enc 0444 root bin
+f none X11/lib/X11/fonts/encodings/viscii1.1-1.enc 0444 root bin
+
+!search $HOME/lib/X11/fonts/encodings/large
+d none X11/lib/X11/fonts/encodings/large 0755 root bin
+f none X11/lib/X11/fonts/encodings/large/big5.eten-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/big5hkscs-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/encodings.dir 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/gb18030.2000-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/gb18030.2000-1.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/gb2312.1980-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/gbk-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/jisx0201.1976-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/jisx0208.1990-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/jisx0212.1990-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/ksc5601.1987-0.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/ksc5601.1992-3.enc.gz 0444 root bin
+f none X11/lib/X11/fonts/encodings/large/sun.unicode.india-0.enc.gz 0444 root bin
+
+!search $HOME/lib/X11/getconfig
+d none X11/lib/X11/getconfig 0755 root bin
+f none X11/lib/X11/getconfig/getconfig=$HOME/bin/getconfig-sun 0555 root bin
+f none X11/lib/X11/getconfig/cfg.sample 0444 root bin
+f none X11/lib/X11/getconfig/xorg.cfg 0444 root bin
+
+!search $HOME/lib/X11/xserver
+d none X11/lib/X11/xserver 0755 root bin
+f none X11/lib/X11/xserver/SecurityPolicy 0444 root bin
+
+!search $HOME/lib/modules/
+d none X11/lib/modules 0755 root bin
+f none X11/lib/modules/libafb.so 0755 root bin
+f none X11/lib/modules/libcfb.so 0755 root bin
+f none X11/lib/modules/libcfb16.so 0755 root bin
+f none X11/lib/modules/libcfb32.so 0755 root bin
+f none X11/lib/modules/libddc.so 0755 root bin
+f none X11/lib/modules/libexa.so 0755 root bin
+f none X11/lib/modules/libfb.so 0755 root bin
+f none X11/lib/modules/libi2c.so 0755 root bin
+f none X11/lib/modules/libint10.so 0755 root bin
+f none X11/lib/modules/liblayer.so 0755 root bin
+f none X11/lib/modules/libmfb.so 0755 root bin
+f none X11/lib/modules/libpcidata.so 0755 root bin
+f none X11/lib/modules/librac.so 0755 root bin
+f none X11/lib/modules/libramdac.so 0755 root bin
+f none X11/lib/modules/libscanpci.so 0755 root bin
+f none X11/lib/modules/libshadow.so 0755 root bin
+f none X11/lib/modules/libshadowfb.so 0755 root bin
+f none X11/lib/modules/libvbe.so 0755 root bin
+f none X11/lib/modules/libvgahw.so 0755 root bin
+f none X11/lib/modules/libxaa.so 0755 root bin
+f none X11/lib/modules/libxf1bpp.so 0755 root bin
+f none X11/lib/modules/libxf4bpp.so 0755 root bin
+f none X11/lib/modules/libxf8_16bpp.so 0755 root bin
+f none X11/lib/modules/libxf8_32bpp.so 0755 root bin
+
+# !search $HOME/lib/modules/codeconv
+# d none X11/lib/modules/codeconv 0755 root bin
+# f none X11/lib/modules/codeconv/libARABIC.so 0755 root bin
+# f none X11/lib/modules/codeconv/libARMSCII8.so 0755 root bin
+# f none X11/lib/modules/codeconv/libBIG5.so 0755 root bin
+# f none X11/lib/modules/codeconv/libBIG5HKSCS.so 0755 root bin
+# f none X11/lib/modules/codeconv/libDOSENCODING.so 0755 root bin
+# f none X11/lib/modules/codeconv/libGB18030.so 0755 root bin
+# f none X11/lib/modules/codeconv/libGB2312.so 0755 root bin
+# f none X11/lib/modules/codeconv/libGBK.so 0755 root bin
+# f none X11/lib/modules/codeconv/libGEORGIAN.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_1.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_10.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_11.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_13.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_14.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_15.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_2.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_3.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_4.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_5.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_6.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_7.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_8.so 0755 root bin
+# f none X11/lib/modules/codeconv/libISO8859_9.so 0755 root bin
+# f none X11/lib/modules/codeconv/libJISX0201.so 0755 root bin
+# f none X11/lib/modules/codeconv/libJISX0208.so 0755 root bin
+# f none X11/lib/modules/codeconv/libJISX0212.so 0755 root bin
+# f none X11/lib/modules/codeconv/libKOI8.so 0755 root bin
+# f none X11/lib/modules/codeconv/libKSC5601.so 0755 root bin
+# f none X11/lib/modules/codeconv/libKSCJOHAB.so 0755 root bin
+# f none X11/lib/modules/codeconv/libMULEENCODING.so 0755 root bin
+# f none X11/lib/modules/codeconv/libTCVN.so 0755 root bin
+# f none X11/lib/modules/codeconv/libVISCII.so 0755 root bin
+
+!search $HOME/lib/modules/drivers
+d none X11/lib/modules/drivers 0755 root bin
+f none X11/lib/modules/drivers/dummy_drv.so 0755 root bin
+
+!search $HOME/lib/modules/extensions
+d none X11/lib/modules/extensions 0755 root bin
+f none X11/lib/modules/extensions/libIA.so 0755 root bin
+f none X11/lib/modules/extensions/libdbe.so 0755 root bin
+f none X11/lib/modules/extensions/libextmod.so 0755 root bin
+f none X11/lib/modules/extensions/librecord.so 0755 root bin
+f none X11/lib/modules/extensions/libxtrap.so 0755 root bin
+
+!search $HOME/lib/modules/fonts
+d none X11/lib/modules/fonts 0755 root bin
+f none X11/lib/modules/fonts/libbitmap.so 0755 root bin
+f none X11/lib/modules/fonts/libbitstream.so 0755 root bin
+#f none X11/lib/modules/fonts/libfreetype.so 0755 root bin
+#f none X11/lib/modules/fonts/libspeedo.so 0755 root bin
+f none X11/lib/modules/fonts/libtype1.so 0755 root bin
+#f none X11/lib/modules/fonts/libxtt.so 0755 root bin
+
+!search $HOME/lib/modules/input
+d none X11/lib/modules/input 0755 root bin
+f none X11/lib/modules/input/acecad_drv.so 0755 root bin
+f none X11/lib/modules/input/calcomp_drv.so 0755 root bin
+f none X11/lib/modules/input/citron_drv.so 0755 root bin
+f none X11/lib/modules/input/digitaledge_drv.so 0755 root bin
+f none X11/lib/modules/input/dmc_drv.so 0755 root bin
+f none X11/lib/modules/input/dynapro_drv.so 0755 root bin
+f none X11/lib/modules/input/elographics_drv.so 0755 root bin
+f none X11/lib/modules/input/fpit_drv.so 0755 root bin
+f none X11/lib/modules/input/hyperpen_drv.so 0755 root bin
+f none X11/lib/modules/input/js_x_drv.so 0755 root bin
+f none X11/lib/modules/input/kbd_drv.so 0755 root bin
+f none X11/lib/modules/input/keyboard_drv.so 0755 root bin
+f none X11/lib/modules/input/magellan_drv.so 0755 root bin
+f none X11/lib/modules/input/microtouch_drv.so 0755 root bin
+f none X11/lib/modules/input/mouse_drv.so 0755 root bin
+f none X11/lib/modules/input/mutouch_drv.so 0755 root bin
+f none X11/lib/modules/input/palmax_drv.so 0755 root bin
+f none X11/lib/modules/input/penmount_drv.so 0755 root bin
+f none X11/lib/modules/input/spaceorb_drv.so 0755 root bin
+f none X11/lib/modules/input/summa_drv.so 0755 root bin
+f none X11/lib/modules/input/tek4957_drv.so 0755 root bin
+f none X11/lib/modules/input/void_drv.so 0755 root bin
+f none X11/lib/modules/input/wacom_drv.so 0755 root bin
+
+!search $HOME/lib/modules/linux
+d none X11/lib/modules/linux 0755 root bin
+f none X11/lib/modules/linux/libfbdevhw.so 0755 root bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-tsol-module/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,38 @@
+#
+# Copyright 2006 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.
+# 
+# ident "@(#)depend	1.2	06/03/06 SMI"
+#
+# Xorg Trusted Extensions
+#
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWxorg-server X.Org Foundation Xserver
+P SUNWxwts	X Trusted Extensions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-tsol-module/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,46 @@
+#
+# Copyright 2006 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.
+#
+#ident "@(#)pkginfo.tmpl	1.2 06/03/06"
+# 
+
+PKG="SUNWxorg-tsol-module"
+NAME="Xorg Server Trusted Extensions"
+ARCH="ISA"
+VERSION=0.1,REV=0.2005.10.10
+CATEGORY="system"
+DESC="Trusted Extensions module the Xorg X Server"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Trusted Extensions for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-tsol-module/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,50 @@
+#
+# Copyright 2006 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.
+#
+# ident "@(#)prototype	1.3	06/03/06 SMI"
+#
+# Xorg Trusted Extensions
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+# Trusted Extensions loadable module
+d none X11 0755 root bin
+d none X11/lib/modules 0755 root bin
+d none X11/lib/modules/extensions 0755 root bin
+
+!search $HOME/lib/modules/extensions
+f none X11/lib/modules/extensions/libxtsol.so 0755 root bin
+
+!search $HOME/lib/X11/xserver
+d none X11/lib/X11/xserver 0755 root bin
+f none X11/lib/X11/xserver/TrustedExtensionsPolicy 0444 root bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-xkb/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)depend 1.2     05/11/07 SMI"
+#
+# X.Org Foundation X server XKB configuration files for Solaris
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWxwplt	X Window System platform software
+P SUNWxwrtl	X Window System & Graphics Runtime Library Links in /usr/lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-xkb/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,48 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)pkginfo.tmpl 1.4     05/11/07 SMI"
+
+PKG="SUNWxorg-xkb"
+NAME="X.Org Foundation Xserver keyboard layouts"
+ARCH="ISA"
+VERSION=0.1,REV=0.2000.02.02
+CATEGORY="system"
+DESC="XKB configuration files and keyboard layout data files for X Window System server based on X.Org Foundation open source release"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGVERS=1.0
+SUNW_PRODNAME="X.Org Foundation X11 for Solaris"
+SUNW_PRODVERS=1.0
+SUNW_PKGTYPE=usr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/SUNWxorg-xkb/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,502 @@
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)prototype 1.13     05/11/09 SMI"
+#
+# X.Org Foundation XKB configuration files for Solaris
+
+!HOME=../usr/X11
+
+i pkginfo
+i depend
+i copyright
+
+d none X11 0755 root bin
+d none X11/lib 0755 root bin
+d none X11/lib/X11 0755 root bin
+
+!search $HOME/lib/X11/xkb
+d none X11/lib/X11/xkb 0755 root bin
+f none X11/lib/X11/xkb/README 0444 root bin
+f none X11/lib/X11/xkb/compat.dir 0444 root bin
+f none X11/lib/X11/xkb/geometry.dir 0444 root bin
+f none X11/lib/X11/xkb/keycodes.dir 0444 root bin
+f none X11/lib/X11/xkb/keymap.dir 0444 root bin
+f none X11/lib/X11/xkb/symbols.dir 0444 root bin
+f none X11/lib/X11/xkb/types.dir 0444 root bin
+f none X11/lib/X11/xkb/xkbtable.map 0444 root bin
+#s none X11/lib/X11/xkb/xkbcomp=../../../../openwin/lib/X11/xkb/xkbcomp
+f none X11/lib/X11/xkb/xkbcomp 0755 root bin
+
+!search $HOME/lib/X11/xkb/compat
+d none X11/lib/X11/xkb/compat 0755 root bin
+f none X11/lib/X11/xkb/compat/README 0444 root bin
+f none X11/lib/X11/xkb/compat/accessx 0444 root bin
+f none X11/lib/X11/xkb/compat/basic 0444 root bin
+f none X11/lib/X11/xkb/compat/complete 0444 root bin
+f none X11/lib/X11/xkb/compat/default 0444 root bin
+f none X11/lib/X11/xkb/compat/iso9995 0444 root bin
+f none X11/lib/X11/xkb/compat/japan 0444 root bin
+f none X11/lib/X11/xkb/compat/keypad 0444 root bin
+f none X11/lib/X11/xkb/compat/ledcaps 0444 root bin
+f none X11/lib/X11/xkb/compat/lednum 0444 root bin
+f none X11/lib/X11/xkb/compat/ledscroll 0444 root bin
+f none X11/lib/X11/xkb/compat/misc 0444 root bin
+f none X11/lib/X11/xkb/compat/mousekeys 0444 root bin
+f none X11/lib/X11/xkb/compat/norepeat 0444 root bin
+f none X11/lib/X11/xkb/compat/pc 0444 root bin
+f none X11/lib/X11/xkb/compat/pc98 0444 root bin
+f none X11/lib/X11/xkb/compat/xfree86 0444 root bin
+f none X11/lib/X11/xkb/compat/xtest 0444 root bin
+
+!search $HOME/lib/X11/xkb/compiled
+d none X11/lib/X11/xkb/compiled 0755 root bin
+f none X11/lib/X11/xkb/compiled/README 0444 root bin
+
+!search $HOME/lib/X11/xkb/geometry
+d none X11/lib/X11/xkb/geometry 0755 root bin
+f none X11/lib/X11/xkb/geometry/README 0444 root bin
+f none X11/lib/X11/xkb/geometry/amiga 0444 root bin
+f none X11/lib/X11/xkb/geometry/ataritt 0444 root bin
+f none X11/lib/X11/xkb/geometry/chicony 0444 root bin
+f none X11/lib/X11/xkb/geometry/dell 0444 root bin
+f none X11/lib/X11/xkb/geometry/everex 0444 root bin
+f none X11/lib/X11/xkb/geometry/fujitsu 0444 root bin
+f none X11/lib/X11/xkb/geometry/hp 0444 root bin
+f none X11/lib/X11/xkb/geometry/keytronic 0444 root bin
+f none X11/lib/X11/xkb/geometry/kinesis 0444 root bin
+f none X11/lib/X11/xkb/geometry/macintosh 0444 root bin
+f none X11/lib/X11/xkb/geometry/microsoft 0444 root bin
+f none X11/lib/X11/xkb/geometry/nec 0444 root bin
+f none X11/lib/X11/xkb/geometry/northgate 0444 root bin
+f none X11/lib/X11/xkb/geometry/pc 0444 root bin
+f none X11/lib/X11/xkb/geometry/sony 0444 root bin
+f none X11/lib/X11/xkb/geometry/sun 0444 root bin
+f none X11/lib/X11/xkb/geometry/winbook 0444 root bin
+
+!search $HOME/lib/X11/xkb/geometry/digital
+d none X11/lib/X11/xkb/geometry/digital 0755 root bin
+f none X11/lib/X11/xkb/geometry/digital/lk 0444 root bin
+f none X11/lib/X11/xkb/geometry/digital/pc 0444 root bin
+f none X11/lib/X11/xkb/geometry/digital/unix 0444 root bin
+
+!search $HOME/lib/X11/xkb/geometry/ibm
+d none X11/lib/X11/xkb/geometry/ibm 0755 root bin
+f none X11/lib/X11/xkb/geometry/ibm/thinkpad 0444 root bin
+
+!search $HOME/lib/X11/xkb/geometry/sgi
+d none X11/lib/X11/xkb/geometry/sgi 0755 root bin
+f none X11/lib/X11/xkb/geometry/sgi/O2 0444 root bin
+f none X11/lib/X11/xkb/geometry/sgi/indigo 0444 root bin
+f none X11/lib/X11/xkb/geometry/sgi/indy 0444 root bin
+
+!search $HOME/lib/X11/xkb/keycodes
+d none X11/lib/X11/xkb/keycodes 0755 root bin
+f none X11/lib/X11/xkb/keycodes/README 0444 root bin
+f none X11/lib/X11/xkb/keycodes/aliases 0444 root bin
+f none X11/lib/X11/xkb/keycodes/amiga 0444 root bin
+f none X11/lib/X11/xkb/keycodes/ataritt 0444 root bin
+f none X11/lib/X11/xkb/keycodes/fujitsu 0444 root bin
+f none X11/lib/X11/xkb/keycodes/hp 0444 root bin
+f none X11/lib/X11/xkb/keycodes/ibm 0444 root bin
+f none X11/lib/X11/xkb/keycodes/macintosh 0444 root bin
+f none X11/lib/X11/xkb/keycodes/powerpcps2 0444 root bin
+f none X11/lib/X11/xkb/keycodes/sony 0444 root bin
+f none X11/lib/X11/xkb/keycodes/sun 0444 root bin
+f none X11/lib/X11/xkb/keycodes/xfree86 0444 root bin
+f none X11/lib/X11/xkb/keycodes/xfree98 0444 root bin
+
+!search $HOME/lib/X11/xkb/keycodes/digital
+d none X11/lib/X11/xkb/keycodes/digital 0755 root bin
+f none X11/lib/X11/xkb/keycodes/digital/lk 0444 root bin
+f none X11/lib/X11/xkb/keycodes/digital/pc 0444 root bin
+
+!search $HOME/lib/X11/xkb/keycodes/sgi
+d none X11/lib/X11/xkb/keycodes/sgi 0755 root bin
+f none X11/lib/X11/xkb/keycodes/sgi/indigo 0444 root bin
+f none X11/lib/X11/xkb/keycodes/sgi/indy 0444 root bin
+f none X11/lib/X11/xkb/keycodes/sgi/iris 0444 root bin
+
+!search $HOME/lib/X11/xkb/keymap
+d none X11/lib/X11/xkb/keymap 0755 root bin
+f none X11/lib/X11/xkb/keymap/README 0444 root bin
+f none X11/lib/X11/xkb/keymap/amiga 0444 root bin
+f none X11/lib/X11/xkb/keymap/ataritt 0444 root bin
+f none X11/lib/X11/xkb/keymap/macintosh 0444 root bin
+f none X11/lib/X11/xkb/keymap/sony 0444 root bin
+f none X11/lib/X11/xkb/keymap/xfree86 0444 root bin
+f none X11/lib/X11/xkb/keymap/xfree98 0444 root bin
+
+!search $HOME/lib/X11/xkb/keymap/digital
+d none X11/lib/X11/xkb/keymap/digital 0755 root bin
+f none X11/lib/X11/xkb/keymap/digital/us 0444 root bin
+
+!search $HOME/lib/X11/xkb/keymap/sgi
+d none X11/lib/X11/xkb/keymap/sgi 0755 root bin
+f none X11/lib/X11/xkb/keymap/sgi/be 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/bg 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/ca 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/cz 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/cz_qwerty 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/de 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/de_CH 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/dk 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/dvorak 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/en_US 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/es 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/fi 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/fr 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/fr_CH 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/gb 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/hu 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/it 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/jp 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/no 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/pl 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/pt 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/ru 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/se 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/sk 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/sk_qwerty 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/th 0444 root bin
+f none X11/lib/X11/xkb/keymap/sgi/us 0444 root bin
+
+!search $HOME/lib/X11/xkb/keymap/sun
+d none X11/lib/X11/xkb/keymap/sun 0755 root bin
+f none X11/lib/X11/xkb/keymap/sun/all 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/de 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/es 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/fi 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/fr 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/no 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/pl 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/ru 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/se 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/uk 0444 root bin
+f none X11/lib/X11/xkb/keymap/sun/us 0444 root bin
+
+!search $HOME/lib/X11/xkb/rules
+d none X11/lib/X11/xkb/rules 0755 root bin
+f none X11/lib/X11/xkb/rules/README 0444 root bin
+f none X11/lib/X11/xkb/rules/sgi 0444 root bin
+f none X11/lib/X11/xkb/rules/sgi.lst 0444 root bin
+f none X11/lib/X11/xkb/rules/sun 0444 root bin
+f none X11/lib/X11/xkb/rules/sun.lst 0444 root bin
+s none X11/lib/X11/xkb/rules/xfree86=xorg
+s none X11/lib/X11/xkb/rules/xfree86.lst=xorg.lst
+s none X11/lib/X11/xkb/rules/xfree86.xml=xorg.xml
+f none X11/lib/X11/xkb/rules/xorg 0444 root bin
+f none X11/lib/X11/xkb/rules/xorg-it.lst 0444 root bin
+f none X11/lib/X11/xkb/rules/xorg.lst 0444 root bin
+f none X11/lib/X11/xkb/rules/xorg.xml 0444 root bin
+
+!search $HOME/lib/X11/xkb/semantics
+d none X11/lib/X11/xkb/semantics 0755 root bin
+f none X11/lib/X11/xkb/semantics/basic 0444 root bin
+f none X11/lib/X11/xkb/semantics/complete 0444 root bin
+f none X11/lib/X11/xkb/semantics/default 0444 root bin
+f none X11/lib/X11/xkb/semantics/xtest 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols
+d none X11/lib/X11/xkb/symbols 0755 root bin
+f none X11/lib/X11/xkb/symbols/README 0444 root bin
+f none X11/lib/X11/xkb/symbols/al 0444 root bin
+f none X11/lib/X11/xkb/symbols/altwin 0444 root bin
+f none X11/lib/X11/xkb/symbols/am 0444 root bin
+f none X11/lib/X11/xkb/symbols/apple 0444 root bin
+f none X11/lib/X11/xkb/symbols/ar 0444 root bin
+f none X11/lib/X11/xkb/symbols/az 0444 root bin
+f none X11/lib/X11/xkb/symbols/be 0444 root bin
+f none X11/lib/X11/xkb/symbols/ben 0444 root bin
+f none X11/lib/X11/xkb/symbols/bg 0444 root bin
+f none X11/lib/X11/xkb/symbols/br 0444 root bin
+f none X11/lib/X11/xkb/symbols/bs 0444 root bin
+f none X11/lib/X11/xkb/symbols/by 0444 root bin
+f none X11/lib/X11/xkb/symbols/ca 0444 root bin
+f none X11/lib/X11/xkb/symbols/ca_enhanced 0444 root bin
+f none X11/lib/X11/xkb/symbols/capslock 0444 root bin
+f none X11/lib/X11/xkb/symbols/compose 0444 root bin
+f none X11/lib/X11/xkb/symbols/ctrl 0444 root bin
+f none X11/lib/X11/xkb/symbols/cz 0444 root bin
+f none X11/lib/X11/xkb/symbols/cz_qwerty 0444 root bin
+f none X11/lib/X11/xkb/symbols/czsk 0444 root bin
+f none X11/lib/X11/xkb/symbols/de 0444 root bin
+f none X11/lib/X11/xkb/symbols/de_CH 0444 root bin
+f none X11/lib/X11/xkb/symbols/dev 0444 root bin
+f none X11/lib/X11/xkb/symbols/dk 0444 root bin
+f none X11/lib/X11/xkb/symbols/dvorak 0444 root bin
+f none X11/lib/X11/xkb/symbols/ee 0444 root bin
+f none X11/lib/X11/xkb/symbols/el 0444 root bin
+f none X11/lib/X11/xkb/symbols/en_US 0444 root bin
+f none X11/lib/X11/xkb/symbols/es 0444 root bin
+f none X11/lib/X11/xkb/symbols/eurosign 0444 root bin
+f none X11/lib/X11/xkb/symbols/fi 0444 root bin
+f none X11/lib/X11/xkb/symbols/fo 0444 root bin
+f none X11/lib/X11/xkb/symbols/fr 0444 root bin
+f none X11/lib/X11/xkb/symbols/fr_CH 0444 root bin
+f none X11/lib/X11/xkb/symbols/gb 0444 root bin
+f none X11/lib/X11/xkb/symbols/ge_la 0444 root bin
+f none X11/lib/X11/xkb/symbols/ge_ru 0444 root bin
+f none X11/lib/X11/xkb/symbols/group 0444 root bin
+f none X11/lib/X11/xkb/symbols/guj 0444 root bin
+f none X11/lib/X11/xkb/symbols/gur 0444 root bin
+f none X11/lib/X11/xkb/symbols/hr 0444 root bin
+f none X11/lib/X11/xkb/symbols/hr_US 0444 root bin
+f none X11/lib/X11/xkb/symbols/hu 0444 root bin
+f none X11/lib/X11/xkb/symbols/hu_US 0444 root bin
+f none X11/lib/X11/xkb/symbols/hu_qwerty 0444 root bin
+f none X11/lib/X11/xkb/symbols/ie 0444 root bin
+f none X11/lib/X11/xkb/symbols/il 0444 root bin
+f none X11/lib/X11/xkb/symbols/il_phonetic 0444 root bin
+f none X11/lib/X11/xkb/symbols/inet 0444 root bin
+f none X11/lib/X11/xkb/symbols/ir 0444 root bin
+f none X11/lib/X11/xkb/symbols/is 0444 root bin
+f none X11/lib/X11/xkb/symbols/iso9995-3 0444 root bin
+f none X11/lib/X11/xkb/symbols/it 0444 root bin
+f none X11/lib/X11/xkb/symbols/iu 0444 root bin
+f none X11/lib/X11/xkb/symbols/jp 0444 root bin
+f none X11/lib/X11/xkb/symbols/kan 0444 root bin
+f none X11/lib/X11/xkb/symbols/keypad 0444 root bin
+f none X11/lib/X11/xkb/symbols/la 0444 root bin
+f none X11/lib/X11/xkb/symbols/level3 0444 root bin
+f none X11/lib/X11/xkb/symbols/lo 0444 root bin
+f none X11/lib/X11/xkb/symbols/lock 0444 root bin
+f none X11/lib/X11/xkb/symbols/lt 0444 root bin
+f none X11/lib/X11/xkb/symbols/lt_std 0444 root bin
+f none X11/lib/X11/xkb/symbols/lv 0444 root bin
+f none X11/lib/X11/xkb/symbols/mk 0444 root bin
+f none X11/lib/X11/xkb/symbols/ml 0444 root bin
+f none X11/lib/X11/xkb/symbols/mm 0444 root bin
+f none X11/lib/X11/xkb/symbols/mt 0444 root bin
+f none X11/lib/X11/xkb/symbols/mt_us 0444 root bin
+f none X11/lib/X11/xkb/symbols/nl 0444 root bin
+f none X11/lib/X11/xkb/symbols/no 0444 root bin
+f none X11/lib/X11/xkb/symbols/ogham 0444 root bin
+f none X11/lib/X11/xkb/symbols/ori 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc104 0444 root bin
+f none X11/lib/X11/xkb/symbols/pl 0444 root bin
+f none X11/lib/X11/xkb/symbols/pl2 0444 root bin
+f none X11/lib/X11/xkb/symbols/pt 0444 root bin
+f none X11/lib/X11/xkb/symbols/ralt 0444 root bin
+f none X11/lib/X11/xkb/symbols/ro 0444 root bin
+f none X11/lib/X11/xkb/symbols/ro2 0444 root bin
+f none X11/lib/X11/xkb/symbols/ru 0444 root bin
+f none X11/lib/X11/xkb/symbols/sapmi 0444 root bin
+f none X11/lib/X11/xkb/symbols/se 0444 root bin
+f none X11/lib/X11/xkb/symbols/se_FI 0444 root bin
+f none X11/lib/X11/xkb/symbols/se_NO 0444 root bin
+f none X11/lib/X11/xkb/symbols/se_SE 0444 root bin
+f none X11/lib/X11/xkb/symbols/si 0444 root bin
+f none X11/lib/X11/xkb/symbols/sk 0444 root bin
+f none X11/lib/X11/xkb/symbols/sk_qwerty 0444 root bin
+f none X11/lib/X11/xkb/symbols/sr 0444 root bin
+f none X11/lib/X11/xkb/symbols/srvr_ctrl 0444 root bin
+f none X11/lib/X11/xkb/symbols/syr 0444 root bin
+f none X11/lib/X11/xkb/symbols/syr_phonetic 0444 root bin
+f none X11/lib/X11/xkb/symbols/tel 0444 root bin
+f none X11/lib/X11/xkb/symbols/th 0444 root bin
+f none X11/lib/X11/xkb/symbols/th_pat 0444 root bin
+f none X11/lib/X11/xkb/symbols/th_tis 0444 root bin
+f none X11/lib/X11/xkb/symbols/tj 0444 root bin
+f none X11/lib/X11/xkb/symbols/tml 0444 root bin
+f none X11/lib/X11/xkb/symbols/tr 0444 root bin
+f none X11/lib/X11/xkb/symbols/tr_f 0444 root bin
+f none X11/lib/X11/xkb/symbols/ua 0444 root bin
+f none X11/lib/X11/xkb/symbols/us 0444 root bin
+f none X11/lib/X11/xkb/symbols/us_group2 0444 root bin
+f none X11/lib/X11/xkb/symbols/us_group3 0444 root bin
+f none X11/lib/X11/xkb/symbols/us_intl 0444 root bin
+f none X11/lib/X11/xkb/symbols/uz 0444 root bin
+f none X11/lib/X11/xkb/symbols/vn 0444 root bin
+f none X11/lib/X11/xkb/symbols/yu 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/digital
+d none X11/lib/X11/xkb/symbols/digital 0755 root bin
+f none X11/lib/X11/xkb/symbols/digital/lk 0444 root bin
+f none X11/lib/X11/xkb/symbols/digital/pc 0444 root bin
+f none X11/lib/X11/xkb/symbols/digital/us 0444 root bin
+f none X11/lib/X11/xkb/symbols/digital/vt 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/fujitsu
+d none X11/lib/X11/xkb/symbols/fujitsu 0755 root bin
+f none X11/lib/X11/xkb/symbols/fujitsu/jp 0444 root bin
+f none X11/lib/X11/xkb/symbols/fujitsu/us 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/hp
+d none X11/lib/X11/xkb/symbols/hp 0755 root bin
+f none X11/lib/X11/xkb/symbols/hp/us 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/macintosh
+d none X11/lib/X11/xkb/symbols/macintosh 0755 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/de 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/de_CH 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/dk 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/es 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/fi 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/fr 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/fr_CH 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/gb 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/it 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/nl 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/no 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/pt 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/se 0444 root bin
+f none X11/lib/X11/xkb/symbols/macintosh/us 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/nec
+d none X11/lib/X11/xkb/symbols/nec 0755 root bin
+f none X11/lib/X11/xkb/symbols/nec/jp 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/pc
+d none X11/lib/X11/xkb/symbols/pc 0755 root bin
+f none X11/lib/X11/xkb/symbols/pc/al 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/am 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ara 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/az 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ba 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/bd 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/be 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/bg 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/br 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/bt 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/by 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ca 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ch 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/cz 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/de 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/dk 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ee 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/es 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/fi 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/fo 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/fr 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/gb 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ge 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/gr 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/hr 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/hu 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ie 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/il 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/in 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ir 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/is 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/it 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/jp 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/kg 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/la 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/latam 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/latin 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/lk 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/lt 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/lv 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/mao 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/mkd 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/mm 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/mn 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/mt 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/nl 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/no 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/pc 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/pk 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/pl 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/pt 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ro 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ru 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/se 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/si 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/sk 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/srp 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/sy 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/th 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/tj 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/tr 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/ua 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/us 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/uz 0444 root bin
+f none X11/lib/X11/xkb/symbols/pc/vn 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/sgi
+d none X11/lib/X11/xkb/symbols/sgi 0755 root bin
+f none X11/lib/X11/xkb/symbols/sgi/jp 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/sony
+d none X11/lib/X11/xkb/symbols/sony 0755 root bin
+f none X11/lib/X11/xkb/symbols/sony/us 0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/sun
+d none X11/lib/X11/xkb/symbols/sun 0755 root bin
+f none X11/lib/X11/xkb/symbols/sun/ca   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/cs   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/cz   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/de   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/dk   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/es   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/fi   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/fr   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/gb   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/gr   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/hu   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/it   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/jp   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/ko   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/lt   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/lv   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/nl   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/no   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/pl   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/pt   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/ru   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/se   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/solaris      0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/sw   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/tr   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/tuv  0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/tw   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/us   0444 root bin
+f none X11/lib/X11/xkb/symbols/sun/usb	0444 root bin
+
+!search $HOME/lib/X11/xkb/symbols/xfree68
+d none X11/lib/X11/xkb/symbols/xfree68 0755 root bin
+f none X11/lib/X11/xkb/symbols/xfree68/amiga 0444 root bin
+f none X11/lib/X11/xkb/symbols/xfree68/ataritt 0444 root bin
+
+!search $HOME/lib/X11/xkb/types
+d none X11/lib/X11/xkb/types 0755 root bin
+f none X11/lib/X11/xkb/types/README 0444 root bin
+f none X11/lib/X11/xkb/types/basic 0444 root bin
+f none X11/lib/X11/xkb/types/caps 0444 root bin
+f none X11/lib/X11/xkb/types/complete 0444 root bin
+f none X11/lib/X11/xkb/types/default 0444 root bin
+f none X11/lib/X11/xkb/types/extra 0444 root bin
+f none X11/lib/X11/xkb/types/iso9995 0444 root bin
+f none X11/lib/X11/xkb/types/mousekeys 0444 root bin
+f none X11/lib/X11/xkb/types/numpad 0444 root bin
+f none X11/lib/X11/xkb/types/pc 0444 root bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/common_files/copyright	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,5 @@
+Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+Use is subject to license terms.
+
+Portions of this software package are covered by additional copyright notices 
+and licenses listed in the file /usr/X11/lib/X11/doc/LICENSE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/pkgversion	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2 @@
+VERSION="6.9.0.5.11"
+BUILD="0000"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/packages/upgrade-Xorg	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,238 @@
+#!/bin/ksh
+#
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)upgrade-Xorg 1.13     05/11/01 SMI"
+#
+# Description: This script upgrades Xorg software on a Solaris 10 or Nevada
+#	       system. It should be run as root from a Xorg package area.
+#
+# Arguments:	-a 	Install all supported packages.  This is now the
+#			default, so this option does nothing any more.
+#		-q	Be quiet and don't report packages that aren't 
+#			installed.
+#
+#
+###
+
+    # Update this when X package version number changes
+    XVERS="6.9.0"
+
+###
+#  
+#   First check for a correct upgrade environment. 
+#
+###
+
+    MACH=`uname -p`
+    OSREV=`uname -r`
+
+    DATE=`LANG=C date '+%d%b%y-%H:%M:%S'`
+
+    USER=`/bin/id | grep root | wc -l`
+    if [ $USER -eq 0 ]
+    then
+	echo ""
+        echo "You must be root to run this script"
+        echo ""
+        exit 1
+    fi
+
+
+    X_BASE_PKG=SUNWxorg-clientlibs/pkginfo
+
+    if [ -f ${X_BASE_PKG} ]; then
+        X_VERSION=`grep PRODVERS ${X_BASE_PKG} | /bin/cut -f2 -d= | /bin/cut -f1-3 -d.`
+        X_OSREV=`grep PRODVERS ${X_BASE_PKG} | /bin/cut -f2 -d= | /bin/cut -f5- -d.`
+	X_BUILD=`nawk '/^VERSION=/ {FS="[,.]+" ; print $6/100}' ${X_BASE_PKG} `
+    else
+	echo ""
+        echo "Cannot find base X package -- ${X_BASE_PKG}" 
+	echo "You need to run this script from the X ${XVERS} package area"
+        echo ""
+        exit 1
+    fi
+
+    if [ -z "${X_VERSION}" ]; then
+	echo ""
+        echo "Cannot find ${X_BASE_PKG} package version." 
+	echo "It should have a X ${XVERS} version string"
+        echo ""
+        exit 1
+    else
+      if [ "${X_VERSION}" != "${XVERS}" ]; then
+	echo ""
+        echo "${X_BASE_PKG} package has wrong version (${X_VERSION})." 
+	echo "It should have a X ${XVERS} version string"
+        echo ""
+        #exit 1
+      fi
+    fi
+
+    case "X$(uname -r)" in
+
+	X5.10)
+	PKG_UPGRADE_LOG=/var/tmp/SunSoft_X${XVERS}_B${X_BUILD}_upgrade.log.${DATE}
+	if [ $(grep -c XF86 /usr/openwin/lib/X11/XKeysymDB) -lt 145 ] ; then
+	    echo "You must install SUNWxwplt from s10_58 or later before upgrading to this"
+ 	    echo "version of Xorg.  You can do this via an OS upgrade or via the commands:"
+	    echo " cd /net/xserver.sfbay/export/x-re/pkgs2/X_S10_milestone/x86/B58"
+	    echo "../upgrade-X -a"
+	    exit 1
+	fi
+	;;
+
+	X5.10.1)
+	PKG_UPGRADE_LOG=/var/tmp/SunSoft_X${XVERS}_B${X_BUILD}_upgrade.log.${DATE}
+	;;
+
+	X5.11)
+	PKG_UPGRADE_LOG=/var/tmp/SunSoft_X${XVERS}_B${X_BUILD}_upgrade.log.${DATE}
+	;;
+
+	*)
+	echo "Incorrect Solaris version number"
+	echo "Xorg ${XVERS} is only supported on Solaris 10 or later"
+	exit 1
+	;;
+    esac
+
+####
+#
+#   Process command line options
+#
+####
+
+INSTALLALL=1
+QUIET=0
+
+while getopts agq flag ; do
+    case $flag in
+      a)	INSTALLALL=1 ;;
+      q)	QUIET=1 ;;
+      ?)	printf "Usage: %s [-agq]\n"  $0
+		exit 1 ;;
+    esac
+done
+
+####
+#
+#   List of packages to upgrade
+#
+####        
+
+#   List of official (deliverable) X-window packages
+XW_CLIENT_PACKAGE_LIST="SUNWxorg-clientlibs SUNWxorg-headers SUNWxorg-compatlinks SUNWxorg-client-programs SUNWxorg-client-docs SUNWxorg-devel-docs"
+XW_SERVER_PACKAGE_LIST="SUNWxorg-doc SUNWxorg-server SUNWxorg-graphics-ddx SUNWxorg-xkb SUNWxorg-cfg"
+
+if [ "${MACH}" = "sparc" ] ; then
+    PKGS="${XW_CLIENT_PACKAGE_LIST}"
+    GL_PKGS=""
+else
+    PKGS="${XW_CLIENT_PACKAGE_LIST} ${XW_SERVER_PACKAGE_LIST}"
+    GL_PKGS="SUNWxorg-mesa"
+fi
+    
+# Old packages to remove and not replace - none yet
+#    REM_PKGS=""
+
+    pkg_list="${PKGS} ${GL_PKGS}"
+
+
+###
+#
+#   Do the upgrade
+#
+###
+
+    echo ""
+    echo "Starting Xorg ${XVERS} Build ${X_BUILD} for Solaris ${X_OSREV} upgrade."
+    echo "  An upgrade log file can be found at:"
+    echo "    $PKG_UPGRADE_LOG"
+    echo ""
+
+    VERBOSE="-n -a /tmp/admin.$$"
+
+    cat >/tmp/admin.$$ <<EOF
+basedir=default
+mail=
+runlevel=quit
+conflict=nocheck
+setuid=nocheck
+action=nocheck
+partial=nocheck
+instance=unique
+idepend=nocheck
+rdepend=nocheck
+space=quit
+EOF
+
+
+#    for pkg in $REM_PKGS
+#    do
+#	/bin/pkginfo -q ${pkg}
+#	FOUNDPKG=$?
+#	if [ $FOUNDPKG -eq 0 ]; then
+#	    /usr/sbin/pkgrm $VERBOSE ${pkg}.* 2>&1 | tee -a $PKG_UPGRADE_LOG | grep $pkg
+#	fi
+#    done
+
+    for pkg in $pkg_list
+    do
+	/bin/pkginfo -q ${pkg}
+	FOUNDPKG=$?
+	if [ $FOUNDPKG -eq 0 ]; then
+	    /usr/sbin/pkgrm $VERBOSE ${pkg}.\* 2>&1 | tee -a $PKG_UPGRADE_LOG | grep $pkg
+	fi
+
+	if [ $FOUNDPKG -eq 0 -o $INSTALLALL -eq 1 ]; then
+	  if [ -e $pkg ] ; then
+	    /usr/sbin/pkgadd $VERBOSE  -d `pwd` $pkg 2>&1 | tee -a $PKG_UPGRADE_LOG | grep $pkg
+	    echo ""
+	  else
+	    if [ $QUIET -eq 0 ] ; then
+	        echo "No replacement found for $pkg"
+	    fi
+	  fi
+	else
+	    if [ $QUIET -eq 0 ] ; then
+	      if [ -d $pkg ] ; then
+	    	echo "Warning:  ${pkg} not currently installed - not installing new ${pkg}."
+  	    	echo "  Run upgrade-X -a to install all new packages."
+		echo ""
+	      fi
+	    fi
+	fi
+    done
+
+    echo "Xorg ${XVERS} upgrade is complete"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/stsf/SUNW-build	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,95 @@
+#! /usr/bin/ksh
+#
+###########################################################################
+#
+# Copyright 2005 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.
+#
+###########################################################################
+#
+# ident "@(#)SUNW-build 1.17     05/11/03 SMI"
+#
+# Sets options for building STSF for inclusion in Solaris
+# Only available flag is -64 to do a 64-bit build
+
+PATH=$PATH:/opt/sfw/bin
+export PATH
+MACH=`uname -p`
+ARCH=`arch | sed s/i86pc/i386/`
+
+DROPIN_FLAGS=""
+
+if [ "x${1}" == "x-64" ] ; then
+    if [ "$MACH" == "sparc" ] ; then
+	ARCH_CFLAGS="-xtarget=ultra2 -xarch=v9"
+    	INST_LIB_SUBDIR="/sparcv9"
+    else
+        if [ "$MACH" == "i386" ] ; then
+	    ARCH_CFLAGS="-xarch=generic64"
+	    INST_LIB_SUBDIR="/amd64"
+	else
+	    echo "Don't know how to produce 64-bit code for $MACH platform."
+	    exit 1
+	fi
+    fi
+    LIB_SUBDIR="/64"
+    DROPIN_FLAGS="--enable-dropins=no"
+fi
+
+DEBUG_FLAGS="--disable-debug-flags"
+
+if [ "x${1}" == "x-d" ] ; then
+    DEBUG_FLAGS="--disable-optimizer-flags"
+else
+    if [ "$MACH" == "i386" ] ; then
+	if [ "x${ARCH_CFLAGS}" == "x" ] ; then
+	    ARCH_CFLAGS="-xpentium"
+	fi
+
+# -xregs=no%frameptr is required on x86 when compiling at -xO4 or higher to 
+# avoid losing stack frame pointers so you can't get stack traces or debug 
+	ARCH_CFLAGS="${ARCH_CFLAGS} -xregs=no%frameptr"
+    fi
+fi
+
+TARGETDIR=`pwd`"/../proto-${ARCH}-svr4/usr"
+
+LD_LIBRARY_PATH=${TARGETDIR}/lib${LIB_SUBDIR}:${TARGETDIR}/sfw/lib${LIB_SUBDIR}:${TARGETDIR}/lib/fontconfig${LIB_SUBDIR}:${LD_LIBRARY_PATH:-/usr/lib${LIB_SUBDIR}}
+export LD_LIBRARY_PATH
+
+CC=cc \
+ARCH_CFLAGS="${ARCH_CFLAGS}" \
+CPPFLAGS="-I${TARGETDIR}/include -I${TARGETDIR}/sfw/include -I${TARGETDIR}/sfw/include/freetype2" \
+FTLDFLAGS="-L${TARGETDIR}/sfw/lib${LIB_SUBDIR} -R/usr/sfw/lib${LIB_SUBDIR}" \
+ST_LIB_PATH="/usr/lib/ST${LIB_SUBDIR}" \
+LIB_SUBDIR="${LIB_SUBDIR}" \
+PKG_CONFIG_PATH="${TARGETDIR}/lib${LIB_SUBDIR}/pkgconfig:/usr/lib/pkgconfig" \
+/bin/sh ./configure --prefix=/usr ${DEBUG_FLAGS} --enable-fontconfig --with-default-scaler-path=/usr/lib/ST/dropins${LIB_SUBDIR} ${DROPIN_FLAGS}
+
+gmake -k clean
+gmake -k LIB_SUBDIR="${LIB_SUBDIR}" TARGETLIBDIR="/usr/lib${LIB_SUBDIR}" TARGETSCALERDIR="/usr/lib/ST/dropins${INST_LIB_SUBDIR}" TARGETLIBEXECDIR="/usr/lib/ST${LIB_SUBDIR}"
+gmake -k install TARGETDIR=${TARGETDIR} TARGETLIBDIR="${TARGETDIR}/lib${INST_LIB_SUBDIR}"  TARGETSCALERDIR="${TARGETDIR}/lib/ST/dropins${INST_LIB_SUBDIR}" TARGETLIBEXECDIR="${TARGETDIR}/lib/ST${INST_LIB_SUBDIR}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/stsf/interface/BUILD	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1 @@
+0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/cf/host.def	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,277 @@
+XCOMM #########################################################################
+XCOMM
+XCOMM Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM #########################################################################
+XCOMM
+XCOMM ident "@(#)host.def 1.46     06/03/28 SMI"
+XCOMM
+
+/* Settings for official Solaris package builds */
+
+#define SunSolarisXorgBuilds	YES
+#define BuildLikeSun		YES
+
+#ifndef LibManSuffix
+#define LibManSuffix		3
+#endif
+
+/* Don't waste time building things we don't need in 64-bit builds */
+#if defined(Sparc64Architecture) || defined(AMD64Architecture)
+# define BuildDocs		NO
+# define BuildFonts		NO
+# define BuildClients		NO
+# define BuildXprint		NO
+#endif
+
+/* 64-bit X server doesn't built correctly on SPARC yet */
+#if defined(Sparc64Architecture)
+# define BuildServer		NO
+# define CompilerServerExtraDefines /* Don't need .il files when not building server */
+#endif
+
+#define UseExportLists		NO	/* Use spec files instead */
+#define HasWeakSymbols		YES
+#define GLwUseXmStubs		NO
+#define MotifDir		/usr/dt
+
+#ifdef SparcArchitecture
+#define BuildGlxExt		NO      /* Don't build GL on SPARC */
+#define BuildXDriInfo		NO
+#endif
+
+/* Used in error messages in the form "send the error log to ____" */
+#define BuilderEmailAddr	"your technical support contact"
+/* Used in error messages in the form "check ____  for latest version" */
+#define VendorSupportAddress	"http://sunsolve.sun.com/"
+#define XVendorWebSupport	http://sunsolve.sun.com/
+
+#define XVendorString		"Sun Microsystems, Inc."
+
+#define VendorDefines -DSUNSOFT -DXVENDORNAME='"$(VENDORNAME)"' -DXVENDORNAMESHORT='"$(VENDORNAMESHORT)"' -DMODULEVENDORSTRING='"Sun Microsystems, Inc."' -DXORG_CUSTOM_VERSION='"$(SUN_XORG_CUSTOM_VERSION)"'
+
+#define SunXOrgVersionNumber	1.2
+
+/* Install into package building area */
+PWD:sh=pwd
+#if defined(i386Architecture) || defined(AMD64Architecture)
+DESTDIR=$(PWD)/$(TOP)/../proto-i386-svr4
+#else
+DESTDIR=$(PWD)/$(TOP)/../proto-sun4-svr4
+#endif
+
+/* Use existing Solaris fonts in /usr/openwin for now */
+#define DefaultFontPath $(FONTDIR)/TrueType/,$(FONTDIR)/Type1/,$(FONTDIR)/Type1/sun/,$(FONTDIR)/F3bitmaps/,$(FONTDIR)/misc/,$(FONTDIR)/100dpi/,$(FONTDIR)/75dpi/
+
+#ifndef OSMajorVersion
+# define OSMajorVersion	DefaultOSMajorVersion
+#endif
+#ifndef OSMinorVersion
+# define OSMinorVersion	DefaultOSMinorVersion
+#endif
+#ifndef OSTeenyVersion
+# define OSTeenyVersion	DefaultOSTeenyVersion
+#endif
+
+/* Set optimizer flags for correct Sun cc version */
+#if HasSunC 
+/* # define UseCCMakeDepend	YES  XXX: FIXME
+# define DependFlags		-cc $(CC) -d -xM */
+# ifndef OSServerExtraDefines
+#  ifdef SparcArchitecture
+#   define OSServerExtraDefines -D__sparc__
+#  endif
+# endif
+#endif
+
+#ifdef AfterVendorCF
+/* This has to be done after xorg.cf loads so it gets the version defines */
+# ifndef XorgVersionString
+#  include <xorg.cf>
+# endif
+XCOMM String stored in binaries for identification - view with /usr/ccs/bin/mcs -p
+#if OSMinorVersion < 10
+/* Too long of a string breaks builds on Solaris 9 for some reason */
+      MCS_BUILD_ID = Sun Xorg Release SunXOrgVersionNumber (X.Org X11R/**/XorgVersionString - `date +'%e %B %Y'`)
+#else
+#if OSTeenyVersion != 0 
+      SOLARIS_VERSION:sh = printf "%s.%s" OSMinorVersion OSTeenyVersion
+#else
+      SOLARIS_VERSION = OSMinorVersion
+#endif
+
+      MCS_BUILD_ID = Sun Xorg Release SunXOrgVersionNumber (X.Org X11R/**/XorgVersionString for Solaris $(SOLARIS_VERSION), built `date +'%e %B %Y'`)
+#endif
+      SUN_XORG_CUSTOM_VERSION = Sun Xorg Release SunXOrgVersionNumber for Solaris $(SOLARIS_VERSION)
+
+#undef HasXdmAuth
+#define HasXdmAuth		NO	/* Not in libXdmcp yet */
+
+
+#endif
+
+/* Extra linker flags we like to use */
+#ifndef ExtraLoadFlags
+# ifdef SparcArchitecture
+#  if OSMinorVersion == 9
+XCOMM Solaris 9 sparc linker causes build failures when used with normal
+XCOMM mapfile_pga_sparc so we just use this one for S9 sparc builds 
+#   define MapFilePGA /usr/lib/ld/map.noexstk
+#  else
+#   define MapFilePGA $(CONFIGSRC)/mapfiles/mapfile_pga_sparc
+#  endif
+# else
+#  define MapFilePGA $(CONFIGSRC)/mapfiles/mapfile_pga_i386
+# endif
+       MAPFILE_PGA = MapFilePGA
+/* ExtraLoadFlags apply to all binaries - programs & libraries */
+# define ExtraLoadFlags -M $(MAPFILE_PGA) -z combreloc -z lazyload -mr,"$(MCS_BUILD_ID)"
+/* ExtraLoadOptions only apply to programs */
+# define ExtraLoadOptions -B direct
+#endif
+
+/* Make loadable modules link to their own symbols first to avoid cross-module
+   symbol clashes */
+#if HasSunC 
+MODULE_GCC_FLAGS = -xldscope=symbolic
+#endif
+
+/* Follow Solaris conventions for shared libs naming - single digit versions */
+#define SharedXvRev 1
+#define SharedXvMCRev 1
+#define SharedXrandrRev 2
+#define SharedGlxRev 1
+#define SharedGluRev 1
+#define SharedGLwRev 1
+#define SharedOSMesaRev 4
+#define SharedxkbfileRev 5
+#define SharedX11Rev 4
+#define SharedXxf86miscRev 1
+#define SharedXxf86vmRev 1
+
+#define NormalLibxkbui YES
+#define SharedLibxkbui NO
+
+#define BuildGLULibrary BuildGlxExt
+#define SharedGLPreLib -L/usr/openwin/lib -R/usr/openwin/lib -R/usr/X11/lib
+
+/* Override sv4Lib.rules SharedLibraryTarget to use specfiles */
+#ifndef SharedLibraryTarget
+# define SharedLibraryTarget(libname,rev,solist,down,up)		@@\
+AllTarget(Concat(down/lib,libname.so.rev))				@@\
+									@@\
+Concat(down/lib,libname.so.rev):  solist $(EXTRALIBRARYDEPS)	down/$(VERSMAPFILE)		@@\
+	$(RM) $@~							@@\
+	LinkWithExports(libname,rev,solist $(SHLIBVERSMAPFLAG),down,up)	@@\
+	$(RM) $@ 							@@\
+	$(MV) $@~ $@							@@\
+	@if $(SOSYMLINK); then (set -x; \				@@\
+	  $(RM) Concat(down/lib,libname.so); \				@@\
+	  $(LN) Concat(lib,libname.so.rev) Concat(down/lib,libname.so)); fi @@\
+	LinkBuildLibrary(Concat(lib,libname.so.rev))			@@\
+	LinkBuildLibraryMaybe(Concat(lib,libname.so),$(SOSYMLINK))	@@\
+									@@\
+VersMapfileRule($(VERSMAPFILE),libname,spec/libname.spec,down)		@@\
+									@@\
+clean::									@@\
+	$(RM) Concat(lib,libname.so.rev) Concat(lib,libname.so)	down/$(VERSMAPFILE)
+#endif /* SharedLibraryTarget */
+
+#ifndef SharedLibraryVersMapfileFlag
+# define SharedLibraryVersMapfileFlag -M $(VERSMAPFILE)
+#endif
+    SHLIBVERSMAPFLAG = SharedLibraryVersMapfileFlag
+
+#ifndef VersMapfileName
+# define VersMapfileName   mapfile-vers
+#endif
+	 VERSMAPFILE = VersMapfileName
+
+#ifdef i386Architecture
+# define MachType i386
+#elif defined(AMD64Architecture)
+# define MachType amd64
+#elif defined(Sparc64Architecture)
+# define MachType sparcv9
+#else
+# define MachType sparc
+#endif
+                MACH = MachType
+
+/*
+ * VersMapfileRule - generate rules to make versioning mapfiles for linking
+ */
+#ifndef VersMapfileRule
+#define VersMapfileRule(versmapfile,libname,specfiles,down)             @@\
+down/versmapfile::                                                      @@\
+        if [ -d spec ] ; then /usr/lib/abi/spec2map -a $(MACH) -l libname -v spec/versions -o $@ specfiles ; fi @@\
+        if [ ! -f $@ ] ; then touch $@ ; fi
+#endif
+
+#ifndef CppManTarget
+XCOMM Support for adding attributes sections to man pages
+XCOMM Required by ARC for all interfaces with External stability
+XCOMM
+XCOMM To use this, add to the localdefines or Imakefile lines such as:
+XCOMM	SUNMANDEFS = -D__package__=SUNWpackage-name -D__stability__=External
+XCOMM  SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+XCOMM    SUNMANEND = $(SUNMAN_ATTRIBUTES_APPEND)
+
+
+    SUNMAN_TABLE_PREPEND = $(CONFIGSRC)/sun-manpage-templates/table-prepend
+SUNMAN_ATTRIBUTES_APPEND = $(CONFIGSRC)/sun-manpage-templates/attributes
+
+#define CppManTarget(name,defs)						@@\
+AllTarget(name.$(MANNEWSUFFIX))						@@\
+									@@\
+name.$(MANNEWSUFFIX): name.$(MANSRCSUFFIX) $(SUNMANSTART) $(SUNMANEND)	@@\
+	RemoveFile($@)							@@\
+	if test -z "$(PREPROCESSMANPAGES)" ; then \			@@\
+	   cd `dirname name` && \					@@\
+	   $(LN) `basename name.$(MANSRCSUFFIX)` `basename $@`; \	@@\
+	else \								@@\
+	     ClearmakeOSName \
+	     cat $(SUNMANSTART) name.$(MANSRCSUFFIX) $(SUNMANEND) \	@@\
+		| $(RAWCPP) CppNoLineInfoOption $(MANDEFS) defs $(SUNMANDEFS) \	@@\
+		| $(PERL) -pe 'BEGIN { $$/ = undef; } s/\n\.\\\"\s*\n+\.\\\"\n/\n.\\"\n/g;' \	@@\
+	     	| CppSedMagic >$@; \					@@\
+	fi								@@\
+									@@\
+clean::									@@\
+	RemoveFile(name.$(MANNEWSUFFIX))
+#endif /* CppManTarget */
+
+/* Automatically add Sun external stability sections to all driver modules */
+#ifndef InstallModuleManPage
+#define InstallModuleManPage(module)                                    @@\
+ SUNMANDEFS = -D__package__=SUNWxorg-server -D__stability__=External	@@\
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)					@@\
+  SUNMANEND = $(SUNMAN_ATTRIBUTES_APPEND)				@@\
+									@@\
+InstallGenManPage(module,$(DRIVERMANDIR),$(DRIVERMANSUFFIX))
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/cf/sun.cf	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,972 @@
+XCOMM $XdotOrg: xc/config/cf/sun.cf,v 1.34 2005/12/03 17:20:48 alanc Exp $
+XCOMM platform:  $Xorg: sun.cf,v 1.4 2000/08/17 19:41:48 cpqbld Exp $
+
+
+
+
+XCOMM platform:  $XFree86: xc/config/cf/sun.cf,v 3.70 2004/01/13 02:42:51 tsi Exp $
+
+#ifndef OSName
+# define OSName		DefaultOSName
+#endif
+#ifndef OSMajorVersion
+# define OSMajorVersion	DefaultOSMajorVersion
+#endif
+#ifndef OSMinorVersion
+# define OSMinorVersion	DefaultOSMinorVersion
+#endif
+#ifndef OSTeenyVersion
+# define OSTeenyVersion	DefaultOSTeenyVersion
+#endif
+XCOMM operating system:  OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVersion)
+
+/* For various reasons, Sun uses different settings when compiling the 
+ * X Window System packages included in Solaris than are normally used
+ * by most people building the X.Org software releases.   Sun also has
+ * two different X server hierarchies in Solaris - Xsun in /usr/openwin
+ * and Xorg in /usr/X11.
+ *
+ * If you want to try to match Sun's settings as closely as possible
+ * add this setting to your host.def:
+ *  #define BuildLikeSun YES
+ *
+ * If you're trying to match the openwin directory layout as well, you'll 
+ * need to also add:
+ *  #define ProjectRoot /usr/openwin
+ * otherwise it will use /usr/X11.  (Note that these settings match closer
+ * to Sun's Xorg delivery in /usr/X11 than the older X11R6.6-based delivery
+ * in /usr/openwin though.)
+ */
+#ifndef BuildLikeSun
+# define BuildLikeSun NO
+#endif
+
+#if BuildLikeSun
+# ifndef ProjectRoot
+#  define ProjectRoot		/usr/X11
+# endif
+# ifndef DocDir
+#  define DocDir		Concat(ProjectRoot,/share/doc)
+# endif
+# ifndef ManDirectoryRoot
+#  define ManDirectoryRoot	Concat(ProjectRoot,/share/man)
+# endif
+# ifndef ManSuffix
+#  define ManSuffix		1
+# endif
+# ifndef LibraryCCOptions
+#  if DoSharedLib && defined(SharedLibraryCCOptions)
+#   define LibraryCCOptions SharedLibraryCCOptions ArchLibraryCCOptions
+#  else
+#   define LibraryCCOptions DefaultCCOptions ArchLibraryCCOptions
+#  endif
+# endif
+#endif
+
+/* Flag passed to makestrs in Xt build to control string array names in the
+ * libXt headers.   -solarisabinames matches those used in the libXt in 
+ * Solaris, but not in other OS'es.
+ */
+#ifndef SolarisABIFlag
+# if BuildLikeSun
+#  define SolarisABIFlag -solarisabinames
+# else
+#  define SolarisABIFlag /**/
+# endif
+#endif
+
+/*
+ * Compiler setup.  This sun.cf file knows what options to use with 
+ * certain compilers, including Sun C, CenterLine C, and gcc.  It 
+ * also understands how to set some of the options for various C++
+ * compilers, including Sun C++ and CenterLine C++.
+ *
+ * === C Compiler Setup ==========================================
+ *
+ * For SunPro C, define HasSunC to YES in site.def.  
+ * For CenterLine C, define HasCenterLineC to YES in site.def
+ * For gcc, gcc2 or gcc3, define HasGcc, HasGcc2 or HasGcc3 to YES in site.def
+ * For other compilers, define HasSunC to NO in site.def, then 
+ *    provide appropriate values for the various compiler related
+ *    configuration varibles used here.
+ * 
+ * If you don't tell us which C compiler you have, we assume you have 
+ * the SunPro C compiler under Solaris 2.x, and the bundled /bin/cc 
+ * under SunOS 4.1.x
+ *
+ * === C++ Compiler Setup ==========================================
+ *
+ * For SunPro C++, define HasSunCplusplus to YES in site.def
+ * For CenterLine C++, define HasCenterLineCplusplus to YES in site.def
+ * For Gnu g++ 2.6.x, define HasGcc2ForCplusplus to YES in site.def
+ * For other compilers, define HasCplusplus to YES in site.def, and 
+ *    check to see if you need to provide values for CplusplusOptions
+ *    and/or DefaultCplusplusOptions.
+ *
+ * In any case, you may also need to set CplusplusDependIncludes.
+ *
+ * If you say you have the SunPro C++ compiler, we assume you have 
+ * version 3.0.x of the compiler.  If you have version 4.0.x instead, 
+ * define CplusplusCompilerMajorVersion as 4 in site.def.
+ *
+ */
+
+#ifndef HasGcc3
+#define HasGcc3 NO
+#endif
+#ifndef HasGcc2
+#define HasGcc2 HasGcc3
+#endif
+#ifndef HasGcc
+#define HasGcc HasGcc2
+#endif
+
+#ifndef HasSunC
+# if HasCenterLineC || HasGcc || HasGcc2 || HasGcc3 || (OSMajorVersion < 5)
+#  define HasSunC NO
+# else
+#  define HasSunC YES
+# endif
+#endif
+
+#if HasSunC 
+# ifndef CCompilerMajorVersion
+#  define CCompilerMajorVersion DefaultSunProCCompilerMajorVersion
+# endif
+# ifndef CCompilerMinorVersion
+#  define CCompilerMinorVersion DefaultSunProCCompilerMinorVersion
+# endif
+XCOMM SunPro C CCompilerMajorVersion./**/CCompilerMinorVersion
+
+/* Choose some reasonable default optimizer flags based on compiler & 
+   OS versions */
+# ifndef OptimizedCDebugFlags
+#  if (CCompilerMajorVersion > 5) || \
+	(CCompilerMajorVersion == 5 && CCompilerMinorVersion > 2)
+#   define OptimizedCDebugFlags -xO4 -xbuiltin=%all -xlibmil -xstrconst ArchOptimizedFlags
+#  else
+#   define OptimizedCDebugFlags -xO4 -xstrconst ArchOptimizedFlags
+#  endif
+# endif
+# ifndef ArchOptimizedFlags
+#  if OSMajorVersion == 5 
+#   if defined(SparcArchitecture) && !defined(Sparc64Architecture)
+#    if OSMinorVersion > 9 /* Solaris 10 and later only run on UltraSPARC's */
+#     define ArchOptimizedFlags -xarch=v8plus
+#    else
+#     define ArchOptimizedFlags -xarch=v8
+#    endif
+#   elif defined(i386Architecture) || defined(AMD64Architecture)
+#    if (CCompilerMajorVersion > 5) || \
+	(CCompilerMajorVersion == 5 && CCompilerMinorVersion >= 7)
+/* -xregs=no%frameptr is required on x86 when compiling at -xO4 or higher to
+ * avoid losing stack frame pointers so you can't get stack traces or debug.
+ * This may lose a small bit of performance, so you can override by adding
+ * #define FramePtrFlags -xregs=frameptr if you care about performance more 
+ * than debuggability.
+ */
+#     ifndef FramePtrFlags
+#      define FramePtrFlags -xregs=no%frameptr
+#     endif
+#    endif
+#    ifndef FramePtrFlags
+#     define FramePtrFlags /* */
+#    endif
+#    if defined(i386Architecture) && (OSMinorVersion > 8)
+       /* Solaris 9 and later require Pentium or better */
+#      define ArchOptimizedFlags -xpentium FramePtrFlags
+#    else
+#     define ArchOptimizedFlags FramePtrFlags
+#    endif
+#   endif
+#  endif
+#  ifndef ArchOptimizedFlags
+#   define ArchOptimizedFlags /**/
+#  endif
+# endif
+# ifndef DefaultCDebugFlags
+#  define DefaultCDebugFlags OptimizedCDebugFlags
+# endif
+# ifndef SharedLibraryLdCmd
+#  define SharedLibraryLdCmd $(CC)
+# endif
+/* Flags for lint version included with Sun C compilers */
+# if OSMajorVersion >= 5
+#  ifndef LintLibFlag
+#   define LintLibFlag -y -o
+#  endif
+#  ifndef LintOpts
+#   define LintOpts -b -h -u -erroff=E_INDISTING_FROM_TRUNC2 $(LINTSECFLAG) ExtraLibraries MathLibrary -lc
+#  endif
+#  ifndef LintSecFlag
+#   if (CCompilerMajorVersion > 5) || \
+       (CCompilerMajorVersion == 5 && CCompilerMinorVersion >= 6)
+#    define LintSecFlag -errsecurity=standard
+#   else
+#    define LintSecFlag /**/
+#   endif
+#  endif
+      LINTSECFLAG = LintSecFlag
+#  ifndef LintLibReferences
+#   define LintLibReferences(varname,libname,libsource)                    @@\
+       Concat(LINT,varname) = _UseCat(-L $(LINTLIBDIR) -l, -L libsource -l,libname)
+#  endif
+
+# endif /* Lint Flags for Solaris */
+
+#endif /* HasSunC */
+
+#ifndef ArchLibraryCCOptions
+# if HasSunC && defined(SparcArchitecture) && CCompilerMajorVersion > 3
+#  define ArchLibraryCCOptions -xregs=no%appl
+# else
+#  define ArchLibraryCCOptions
+# endif
+#endif /* ArchLibraryCCOptions */
+
+/* we used to have this here :
+ *
+ * #if HasSunC 
+ * # ifndef CCompilerMajorVersion
+ * #  define CCompilerMajorVersion 3
+ * #  define DefaultCDebugFlags	-xO3
+ * #  define OptimizedCDebugFlags	-xO3
+ * # endif
+ * #endif
+ */
+
+#ifndef HasSunCplusplus
+# define HasSunCplusplus HasSunC	/* ??? */
+#endif
+#if HasSunCplusplus
+# ifndef HasCplusplus
+#  define HasCplusplus YES
+#  define OptimizedCplusplusDebugFlags	-xO4 -xbuiltin=%all -xlibmil
+# endif
+# ifndef CplusplusCompilerMajorVersion
+#  ifdef DefaultSunProCplusplusCompilerMajorVersion
+#   define CplusplusCompilerMajorVersion DefaultSunProCplusplusCompilerMajorVersion
+#  else
+#   define CplusplusCompilerMajorVersion 3
+#  endif
+# endif
+# ifndef CplusplusCompilerMinorVersion
+#  ifdef DefaultSunProCplusplusCompilerMinorVersion
+#   define CplusplusCompilerMinorVersion DefaultSunProCplusplusCompilerMinorVersion
+#  else
+#   define CplusplusCompilerMinorVersion 0
+#  endif
+# endif
+# ifndef CplusplusLibC
+#  if CplusplusCompilerMajorVersion >= 5
+#   define CplusplusLibC -norunpath -lCrun
+#  endif
+# endif
+XCOMM SunPro C++ CplusplusCompilerMajorVersion./**/CplusplusCompilerMinorVersion
+#endif
+
+/* we used to have this here :
+ *
+ * # ifndef CplusplusCompilerMajorVersion
+ * #  define CplusplusCompilerMajorVersion	4
+ * # endif
+ */
+
+#if HasCenterLineC
+# ifndef CcCmd
+#  define CcCmd clcc
+# endif
+#endif
+
+#if HasCenterLineCplusplus
+# ifndef HasCplusplus
+#  define HasCplusplus YES
+# endif
+# ifndef DefaultCplusplusOptions
+#  define DefaultCplusplusOptions -Xa
+# endif
+# ifndef CplusplusOptions
+#  define CplusplusOptions -Xa
+# endif
+#endif
+
+#if OSMajorVersion < 4 || (OSMajorVersion == 4 && OSMinorVersion < 1)
+/* We do not guarantee this will work */
+# define BootstrapCFlags	-DNOSTDHDRS
+# define StandardDefines	-DNOSTDHDRS
+# define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
+#endif
+
+#if OSMajorVersion == 4 
+# if OSMinorVersion == 1
+#  define HasPoll		YES
+# endif
+# if OSMinorVersion > 1 || (OSMinorVersion == 1 && OSTeenyVersion > 1)
+/* You ALSO need this if you have Sun ld patch 100170-06 or later to 4.1.1 */
+#  define SunPost411FCSLd	YES
+# endif
+#endif
+
+/* The Xsun server was not building for SunOS 5.7 due to 
+   includes of <sys/cg2reg.h>. 
+*/
+#if OSMajorVersion < 5 
+# define IncludeCG2HeaderDefine	-DINCLUDE_CG2_HEADER
+#else
+# define IncludeCG2HeaderDefine /**/
+#endif
+
+#if defined(i386Architecture) || defined(AMD64Architecture)
+# if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 8))
+#  define OSServerExtraDefines	-D__SOL8__
+# endif
+#endif
+
+#if !HasGcc 
+# if HasSunC
+#  if defined(AMD64Architecture)
+#   define AsmArch amd64
+#   define AsmFlags -xarch=amd64
+#  elif defined(i386Architecture)
+#   define AsmArch ia32
+#   define AsmFlags /**/
+#  elif defined(Sparc64Architecture)
+#   define AsmArch sparcv8plus
+#   define AsmFlags -xarch=v9
+#  elif defined(SparcArchitecture)
+#   define AsmArch sparcv8plus
+#   define AsmFlags -xarch=v8plus
+#  endif
+#  ifndef CompilerServerExtraDefines
+#   define CompilerServerExtraDefines $(SERVERSRC)/hw/xfree86/os-support/sunos/AsmArch.il
+#  endif
+# endif
+#endif
+
+#ifndef CompilerServerExtraDefines
+# define CompilerServerExtraDefines /**/
+#endif
+
+#ifndef OSServerExtraDefines
+# define OSServerExtraDefines	/**/
+#endif
+
+#ifndef ArchServerExtraDefines
+# if defined(Sparc64Architecture) || defined(AMD64Architecture)
+#  define ArchServerExtraDefines -D_XSERVER64
+# else
+#  define ArchServerExtraDefines /**/
+# endif
+#endif
+
+#define ServerOSDefines		XFree86ServerOSDefines IncludeCG2HeaderDefine
+#define ServerExtraDefines	AllocateLocalDefines XFree86ServerDefines \
+				CompilerServerExtraDefines \
+				OSServerExtraDefines ArchServerExtraDefines
+
+#ifndef HasPerl
+/* Solaris 8 comes with perl.  Earlier versions don't. */
+# if (OSMajorVersion == 5) && (OSMinorVersion >= 8)
+#  define HasPerl		YES
+# else
+#  define HasPerl		NO
+# endif
+#endif
+
+#ifndef XkbServerDefines
+# if BuildLikeSun
+#  define XkbServerDefines  -DXKB_ALWAYS_USES_SOFT_REPEAT \
+	-DXKM_OUTPUT_DIR='"/var/run/xkb/"' -DXKM_OUTPUT_DIR_MODE=0775 \
+	-DMAKE_XKM_OUTPUT_DIR
+# else
+#  define XkbServerDefines  -DXKB_ALWAYS_USES_SOFT_REPEAT
+# endif
+#endif
+
+#if OSMajorVersion > 4
+# define ConnectionFlags		-DTCPCONN -DUNIXCONN -DLOCALCONN
+# if HasSunC
+#  ifdef DefaultSunProCCompilerDir
+#   ifndef  CcCmd
+#    define CcCmd		DefaultSunProCCompilerDir/cc
+#   endif
+#  endif
+#  ifdef DefaultSunProCplusplusCompilerDir
+#   ifndef  CplusplusCmd
+#    define CplusplusCmd	DefaultSunProCplusplusCompilerDir/CC
+#   endif
+#   ifndef  CplusplusFilt
+#    define CplusplusFilt	DefaultSunProCplusplusCompilerDir/c++filt
+#   endif
+#   ifndef  CplusplusWhatdir
+#    define CplusplusWhatdir	DefaultSunProCplusplusCompilerDir/whatdir
+#   endif
+#  else /* DefaultSunProCplusplusCompilerDir not defined */
+#   ifndef  CplusplusWhatdir
+#    define CplusplusWhatdir	whatdir
+#   endif
+#  endif /* DefaultSunProCplusplusCompilerDir */
+#  ifndef  CplusplusDependIncludes
+#   if CplusplusCompilerMajorVersion > 3
+#    define CplusplusDependIncludes	-I`CplusplusWhatdir CC`/../include/CC
+#   elif CplusplusCompilerMajorVersion > 2
+#    define CplusplusDependIncludes	-I/opt/SUNWspro/SC3.0/include/CC
+#   else
+#    define CplusplusDependIncludes	-I/opt/SUNWspro/SC2.0.1/include/CC
+#   endif
+#  endif 
+# endif /* HasSunC */
+
+# if HasSunC && (CCompilerMajorVersion < 3)
+#  define BootstrapCFlags	-DSVR4
+# else
+#  define BootstrapCFlags	/* none needed */
+# endif
+# ifndef XawI18nDefines
+#  if OSMinorVersion < 4
+#   define XawI18nDefines    -DHAS_WCTYPE_H -DHAS_ISW_FUNCS
+#  else
+#   define XawI18nDefines    -DHAS_WCHAR_H -DHAS_ISW_FUNCS
+#  endif
+# endif
+# if OSMinorVersion > 3
+#  define InstallCmd	    /usr/ucb/install
+# endif
+#ifndef LargefileDefines
+# if (OSMajorVersion > 5) || (OSMajorVersion == 5 && OSMinorVersion >= 6)
+#  define LargefileDefines -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+# else
+#  define LargefileDefines /* */
+# endif
+#endif
+# ifdef AMD64Architecture
+#  define StandardDefines	-Dsun -DSVR4 -D__EXTENSIONS__ -D__amd64 XtsolDefines
+#  define ToolkitStringsABIOptions	-intelabi SolarisABIFlag
+# elif defined(i386Architecture)
+#  if (OSMajorVersion < 4) || ((OSMajorVersion == 5) && (OSMinorVersion <= 5))
+#   define StandardDefines	-Dsun -Di386 -DSVR4 -D__EXTENSIONS__ -D__i386 \
+				-D__SOL64__ LargefileDefines XtsolDefines
+#  else
+#   define StandardDefines	-Dsun -Di386 -DSVR4 -D__EXTENSIONS__ -D__i386 \
+                                LargefileDefines XtsolDefines
+#  endif
+#  define ToolkitStringsABIOptions	-intelabi SolarisABIFlag
+# else
+#  define StandardDefines	  -Dsun -Dsparc -DSVR4 -D__EXTENSIONS__ LargefileDefines
+#  define ToolkitStringsABIOptions	-sparcabi SolarisABIFlag
+# endif
+# define ExtraLibraries    -lsocket -lnsl
+# define HasWeakSymbols	  YES
+# if OSMinorVersion > 1
+#  ifndef ThreadedX
+#   define ThreadedX	  YES
+#  endif
+#  define MTSafeAPIDefines	-DXUSE_MTSAFE_API -DXUSE_NETDB_R_API
+#  if HasSunC && CCompilerMajorVersion > 2
+#   define ThreadsCompileFlags -mt
+#  else
+#   define SystemMTDefines -D_REENTRANT
+#   define ThreadsLibraries -lthread
+#  endif
+#  if HasSunCplusplus && CplusplusCompilerMajorVersion > 3
+#   define ThreadsCplusplusCompileFlags -mt
+#  else
+#   define CplusplusSystemMTDefines -D_REENTRANT
+#   define ThreadsCplusplusLibraries -lthread
+#  endif
+# endif 		/* OSMinorVersion > 1 */
+# ifndef UseExportLists
+#  if (OSMinorVersion > 4) && !HasGcc2
+#   define UseExportLists YES
+#  else
+#   define UseExportLists NO
+#  endif
+# endif
+# if OSMinorVersion > 5 /* Solaris 2.6 and later */
+#  define HasSnprintf YES
+# endif
+# if OSMinorVersion > 7 /* Solaris 8 and later */
+#  define HasStrlcat	YES
+#  define HasStrcasecmp	YES
+#  define HasVarRun	YES
+# endif
+# if OSMinorVersion > 9 /* Solaris 10 and later */
+#  define HasSetenv	YES
+#  define HasGetpeerucred YES
+#  define HasGetoptLong YES
+#  define DlLibrary	-lc  /* dlopen() is in libc in Solaris 10 */
+# endif
+# define HasVFork	NO
+# define HasDlopen	YES
+# define InstallXloadSetGID	NO /* libkstat doesn't require gid kmem */
+# define InstKmemFlags	-g sys -m 2711
+# define ShLibIncludeFile <sunLib.tmpl>
+# define LinkerRuntimeLibraryPathFlag(path) Concat(-R,path)
+# define RpathLoadFlags LinkerRuntimeLibraryPathFlag($(USRLIBDIRPATH))
+/*
+ * Set flags for position independent code before including sv4Lib.rules
+ * if the compiler in use doesn't use standard SVR4 flags
+ */
+# if HasSunC || HasCenterLineC
+#  define PositionIndependentCFlags -Kpic
+#  define LargePositionIndependentCFlags -KPIC
+#  ifdef Sparc64Architecture
+#   define LargePICTable YES
+#  endif
+# endif
+# if HasSunCplusplus || HasCenterLineCplusplus
+#  define PositionIndependentCplusplusFlags -pic
+#  define LargePositionIndependentCplusplusFlags -PIC
+# endif
+/* As is done in sco5.cf, we lie and say Solaris has NCURSES, since
+ * the system curses is close enough for xorgcfg's purposes.  xorgcfg
+ * should not depend on the NCURSES package but rather on a "capable curses", 
+ * of which NCURSES is just one.
+ */
+#define	HasNCurses		YES
+#define NCursesLibName		-lcurses
+#else /* not OSMajorVersion > 4 */
+#define InstKmemFlags	  -g kmem -m 2711
+#include <sunLib.rules>
+#endif /* OSMajorVersion > 4 (else) */
+
+/* Solaris 10 includes FreeType already.  It's also available in GNOME 2.0 for
+ * Solaris 8 & 9, and in Solaris 9 4/03 and later, but there's no easy way to
+ * detect that in imake, so users of those releases who want to use the 
+ * installed FreeType instead of the one in this tree should copy the following
+ * two settings to their host.def.  Those who want to use the in-tree copy
+ * regardless of OS version should add "#define HasFreetype2 NO" to host.def.
+ */
+#ifndef HasFreetype2
+# if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 10))
+#  define HasFreetype2 YES 
+#  ifndef Freetype2Dir
+#   define Freetype2Dir /usr/sfw
+#  endif
+# else
+#  define HasFreetype2 NO
+# endif
+#endif
+
+#ifndef HasExpat
+# if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 10))
+#  define HasExpat YES 
+#  ifndef ExpatDir
+#   define ExpatDir /usr/sfw
+#  endif
+# else
+#  define HasExpat NO
+# endif
+#endif
+
+/* Solaris 10 includes fontconfig, but not the fcprivate.h header needed by
+ * Xft1 library.
+ */
+#ifndef HasFontconfig
+# define HasFontconfig NO
+#endif
+
+/* libpng was in /usr/sfw/lib on Solaris 9, moved to /usr/lib in Solaris 10 */
+#ifndef HasLibpng
+# if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 9))
+#  define HasLibpng YES 
+#  if !defined(LibpngDir) && ((OSMajorVersion == 5) && (OSMinorVersion == 9))
+#   define LibpngDir /usr/sfw
+#  endif
+# else
+#  define HasLibpng NO
+# endif
+#endif
+
+#ifndef HasZlib
+# if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 8))
+#  define HasZlib YES
+# else
+#  define HasZlib NO
+# endif
+#endif
+
+#ifndef TroffCmd
+# if !(HasGroff)
+#  define TroffCmd troff -Tpost
+# endif
+#endif
+
+#define BuildLibPathVar	  LD_LIBRARY_PATH
+#define HasNdbm		  YES
+#define HasShm		  YES
+#define HasSecureRPC	  YES
+#define SetTtyGroup	  YES
+#define HasPutenv	  YES
+#define HasMkstemp        YES
+#if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 8))
+#define HasDevRandom	  YES	/* /dev/random is in Solaris 8 patches 	*/
+#define PollDevRandom	  YES	/* /dev/random is poll()able on Solaris */
+#endif
+#if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 9))
+# define HasIssetugid	  YES
+#endif
+#if defined(Sun3Architecture) || defined(SparcArchitecture) || defined(Sparc64Architecture)
+# ifndef Xsun24Server
+#  define Xsun24Server	  NO		/* color, mono, multiple depths */
+# endif
+# ifndef XsunServer
+#  define XsunServer	  NO		/* color and mono, 8 bit only */
+# endif
+# ifndef XsunMonoServer
+#  define XsunMonoServer	  NO		/* monochrome only */
+# endif
+# ifndef XorgServer
+#  define XorgServer	(!(Xsun24Server || XsunServer || XsunMonoServer))
+# endif 
+# undef BuildXF86DRI
+# define BuildXF86DRI     NO
+# if (OSMajorVersion > 4)
+#  if !defined(AsOutputArchSize) || \
+      ((AsOutputArchSize != 32) && (AsOutputArchSize != 64))
+#   undef AsOutputArchSize
+#   define AsOutputArchSize	32
+#  endif
+#  ifndef AsVISOption
+#   if AsOutputArchSize == 32
+#    ifdef UseGas
+#     define AsVISOption		-Av8plusa
+#    else
+#     define AsVISOption		-xarch=v8plusa
+#    endif
+#   else
+#    ifdef UseGas
+#     define AsVISOption		-Av9a
+#    else
+#     define AsVISOption		-xarch=v9a
+#    endif
+#   endif
+#  endif
+# endif
+#endif /* SPARC or Sun3/M68k */
+
+/* Hooks for Trusted Extensions */
+#ifndef XtsolDefines
+#define XtsolDefines -DTSOL
+#else
+#define XtsolDefines /**/
+#endif
+
+#ifndef BuildXtsol	/* libXtsol */
+#define BuildXtsol	YES
+#endif
+
+#ifndef BuildTsolExt	/* Loadable tsol module */
+#define BuildTsolExt	NO
+#endif
+
+#if OSMajorVersion >= 4
+#define HasUsableFileMap YES
+#endif
+
+#ifndef UseDeprecatedKeyboardDriver
+#define UseDeprecatedKeyboardDriver YES
+#endif
+
+#if HasGcc
+# if OSMajorVersion > 4
+#  ifndef DefaultCCOptions
+#   ifdef UseInstalled
+#    define DefaultCCOptions -DNO_ASM
+#   elif OSMinorVersion > 6
+#    define DefaultCCOptions -DNO_ASM GccWarningOptions
+#   elif OSMinorVersion > 3
+#    define DefaultCCOptions -DNO_ASM GccWarningOptions -ansi -pedantic
+#   else
+#    define DefaultCCOptions -DNO_ASM
+#   endif
+#  endif
+# endif
+# if HasGcc2
+#  ifndef CcCmd
+#   define CcCmd gcc
+#  endif
+#  ifndef AsCmd
+#   define AsCmd CcCmd -c -x assembler
+#  endif
+#  ifndef OptimizedCDebugFlags
+#   ifdef i386Architecture
+#    define OptimizedCDebugFlags DefaultGcc2i386Opt
+#   elif defined(AMD64Architecture)
+#    define OptimizedCDebugFlags DefaultGcc2AMD64Opt
+#   else
+#    define OptimizedCDebugFlags -O2
+#   endif
+#  endif
+#  if !defined(SharedLibraryLoadFlags) && !defined(SharedLibraryLdCmd)
+#   if OSMajorVersion == 5 && OSMinorVersion > 6 && defined(i386Architecture)
+    /* This is to work around what appears to be a PIC bug in some gcc/egcs
+       versions that shows up with the Solaris 7/x86 <ctype.h>. */
+#    define SharedLibraryLdCmd $(LD)
+#    define SharedLibraryLoadFlags -G -z textwarn
+#   else
+#    define SharedLibraryLdCmd $(CC)
+#    define SharedLibraryLoadFlags -shared -z text
+#   endif
+#  endif
+# else
+#  define SharedLibraryCcCmd cc
+#  define ExtraLoadFlags -B/usr/bin/
+#  define AllocateLocalDefines /**/
+
+.c.o:
+	ClearmakeOSName	$(CC) -c $(CFLAGS) $*.c
+
+# endif /* HasGcc2 (else) */
+
+#else /* not HasGcc */
+
+# define AllocateLocalDefines -DINCLUDE_ALLOCA_H
+
+/* Set up compiler-dependent options for Sun C */
+/*
+ * To build 64-bit binaries define Sparc64Architecture or AMD64Architecture
+ * in your site.def or host.def file.
+ */
+# if HasSunC
+#  ifdef Sun3Architecture
+#   ifndef DefaultCCOptions
+#    define DefaultCCOptions -f68881 -pipe
+#   endif
+#  else	/* not defined(Sun3Architecture) */
+#   if OSMajorVersion < 5
+#    ifndef DefaultCCOptions
+#     define DefaultCCOptions -pipe
+#    endif
+#   else /* OSMajorVersion >= 5*/
+#     ifndef DefaultXArchOptions
+#      ifdef Sparc64Architecture
+#	define DefaultXArchOptions -xarch=v9
+#      elif defined(AMD64Architecture)
+#	define DefaultXArchOptions -xarch=generic64
+#      else
+#       define DefaultXArchOptions /* */
+#     endif
+#     ifndef DefaultCCOptions
+#      define DefaultCCOptions -Xa -v DefaultXArchOptions -z lazyload -z combreloc -xstrconst -xildoff
+#     endif
+#     ifndef DefaultCplusplusOptions
+#      define DefaultCplusplusOptions DefaultXArchOptions -z lazyload -z combreloc -xildoff
+#     endif
+#     ifndef SharedLibraryLoadFlags
+#      define SharedLibraryLoadFlags -G DefaultXArchOptions -z text $(EXTRA_LOAD_FLAGS)
+#     endif
+#    endif
+#   endif	
+#  endif	
+# endif
+
+/* Set compiler-dependent options for CenterLine C */
+
+# if HasCenterLineC
+#  ifndef DefaultCCOptions
+#   define DefaultCCOptions -Xt -w1 -DANSICPP -U__HIGHC__
+#  endif
+#  ifndef NeedConstPrototypes
+#   define NeedConstPrototypes YES
+#  endif
+#  ifndef NeedNestedPrototypes
+#   define NeedNestedPrototypes YES
+#  endif
+#  ifndef NeedVarargsPrototypes
+#   define NeedVarargsPrototypes YES
+#  endif
+# endif
+
+
+#endif /* HasGcc (else) */
+
+#if OSMajorVersion < 5
+# define SharedAllocateLocalDefines -DINCLUDE_ALLOCA_H
+# define LibraryCCOptions /* don't want special floating point */
+#else /* OSMajorVersion >= 5, i.e. Solaris 2.0 & later */
+/* Only load libraries when needed on Solaris 7 & later */
+# if OSMinorVersion >= 7 
+#  define LazyLoadFlag -z lazyload -z combreloc
+# else
+#  define LazyLoadFlag /* */
+# endif
+/* Link with extra mapfiles for some performance & security enhancements */
+#ifndef MapfileFlag
+# if HasSunC
+#  define MapfileFlag -M
+# else
+#  define MapfileFlag -Wl,-M,
+# endif
+#endif
+#ifndef Mapfile_BssAlign
+# if OSMinorVersion >= 9
+#  define Mapfile_BssAlign $(MAPFILEFLAG)/usr/lib/ld/map.bssalign
+# else
+#  define Mapfile_BssAlign /**/
+# endif
+#endif
+#ifndef Mapfile_PageAlign
+# if OSMinorVersion >= 10
+#  define Mapfile_PageAlign $(MAPFILEFLAG)/usr/lib/ld/map.pagealign
+# else
+#  define Mapfile_PageAlign /**/
+# endif
+#endif
+#ifndef Mapfile_NoExStack
+# if OSMinorVersion >= 9
+#  define Mapfile_NoExStack $(MAPFILEFLAG)/usr/lib/ld/map.noexstk
+# else
+#  define Mapfile_NoExStack /**/
+# endif
+#endif
+#ifndef Mapfile_NoExData
+# if defined(SparcArchitecture)
+/* SPARC archictecture requires PLT section in .data be executable, so
+   we can only make .bss, not all of .data no-exec on SPARC */
+#   define Mapfile_NoExData /**/
+# else
+#  if OSMinorVersion >= 10
+#   define Mapfile_NoExData $(MAPFILEFLAG)/usr/lib/ld/map.noexdata
+#  else
+#   define Mapfile_NoExData /**/
+#  endif
+# endif
+#endif
+       MAPFILEFLAG = MapfileFlag
+  MAPFILES_FOR_ALL = Mapfile_PageAlign Mapfile_NoExData
+MAPFILES_FOR_PROGS = Mapfile_BssAlign Mapfile_NoExStack
+/* ExtraLoadFlags apply to all binaries - programs & libraries */
+# ifndef ExtraLoadFlags
+#  define ExtraLoadFlags LazyLoadFlag $(MAPFILES_FOR_ALL)
+# endif
+/* ExtraLoadOptions only apply to programs */
+# ifndef ExtraLoadOptions
+#  define ExtraLoadOptions -B direct $(MAPFILES_FOR_PROGS)
+# endif
+#endif /* OSMajorVersion < 5 */
+
+/* 64-bit build support */
+#ifndef Solaris64bitSubdir
+# ifdef Sparc64Architecture
+#  define Solaris64bitSubdir	sparcv9
+# elif defined(AMD64Architecture)
+#  define Solaris64bitSubdir	amd64
+# endif
+#endif
+
+#ifdef Solaris64bitSubdir
+# define LibDirName Concat3(lib,/,Solaris64bitSubdir)
+#endif
+
+#if OSMajorVersion > 4
+# include <svr4.cf>
+#endif
+
+#ifndef ManKeywordsTarget
+# define ManKeywordsTarget(manpath)					@@\
+man_keywords::								@@\
+	catman -M $(DESTDIR)manpath -w
+#endif
+
+#if !defined(UsePamLibrary)
+# if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 4))
+#  define UsePamLibrary		YES
+# endif
+#endif
+
+/* PAM appeared in SunOS 5.6 */
+#if !defined(HasPam)
+# if (OSMajorVersion > 5) || (OSMajorVersion == 5 && OSMinorVersion >= 6)
+#  define HasPam		YES
+# endif
+#endif
+
+#ifndef PamLibraries
+#define PamLibraries		-lpam
+#endif
+
+#ifndef HasMotif
+/* Solaris's Motif depends on Solaris libX11 and won't work with libX11 built
+ * from this tree, so only use it when using libX11 from outside the tree.
+ */
+# define HasMotif (defined(UseInstalled) || UseInstalledX11)
+# define MotifDir /usr/dt
+#endif /* !HasMotif */
+#ifndef HasMotif2
+/* Solaris's Motif2 version is broken and misses XmPrintShell
+ * (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1366) */
+# define HasMotif2 NO
+#endif /* !HasMotif2 */
+
+#define MotifDefines			\
+	-DNO_ISDIR -DNO_REGCOMP -DNO_ALLOCA -DBOGUS_MB_MAX -DNO_CONST
+#define PamUnixDefines		-DPAM_NIS
+#define TtLargePICTable		YES
+#define DtSvcDefines		-DXK_MISCELLANY -DMULTIBYTE -DNO_REGCOMP
+#define DtSearchDefines		-DI18N_MSG DtSvcDefines
+#define DtWidgetDefines		DtSearchDefines
+#define DtPrintDefines		DtSearchDefines
+
+#define baseDtMailDefines	\
+	-DSunOS=OSMajorVersion\#\#OSMinorVersion -DMMAP_NORESERVE -DSPRO_V2
+#if !defined(i386Architecture) && !defined(AMD64Architecture)
+# define DtMailDefines		baseDtMailDefines
+#else
+# define DtMailDefines		-DBIG_ENDIAN baseDtMailDefines
+#endif
+
+#define ArchitectureDefines	-DSUN_ARCHITECTURE
+
+#define TtClientExtraLibs	ExtraLibraries -ldl -lintl
+
+#define ExportListGenSource	elistgen.sun
+#define ShlibExportListOpt(filename)	-M filename
+
+#define CdeProjectDefines \
+	-DMULTIBYTE -DNLS16 -DMESSAGE_CAT -D_XOPEN_VERSION=4 \
+	-D_XOPEN_SOURCE -D__EXTENSIONS__ \
+	-DOSMAJORVERSION=OSMajorVersion -DOSMINORVERSION=OSMinorVersion
+
+
+/*
+ * Turn off HTML manpages like we do under NetBSD.
+ */
+#ifndef	BuildHtmlManPages
+#define	BuildHtmlManPages	NO
+#endif
+
+/*
+ * Turn off seperate configuration directories.
+ */
+#ifndef	UseSeparateConfDir
+#define	UseSeparateConfDir	NO
+#endif
+
+/* Hackery for building modules as Solaris shared objects with dependencies */
+#if MakeDllModules && DoLoadableServer
+
+/* If you change this, you will need to change find-deps.pl to match */
+#define DlModuleDependencyName(module) Concat(module,_deps)
+
+#define DlModuleTarget(module,deplist,modlist)                          @@\
+DepDynamicModuleTarget(module,deplist DlModuleDependencyName(module),modlist LazyLoadFlag `cat DlModuleDependencyName(module)`) @@\
+									@@\
+DlModuleDependencyName(module):						@@\
+	touch $@							@@\
+									@@\
+clean::                                                                 @@\
+        RemoveFile(DlModuleDependencyName(module))
+
+#define ObjectModuleTarget(module,objects)				@@\
+DlModuleTarget(Concat(module,_drv.so), objects, objects)
+
+#define LibraryModuleTarget(module,objects)				@@\
+NormalLibraryTarget(module, objects)					@@\
+DlModuleTarget(Concat3(lib,module,.so), objects, objects)
+
+#define DepLibraryModuleTarget(module,deplist,objects)			@@\
+NormalDepLibraryTarget(module, deplist, objects)			@@\
+DlModuleTarget(Concat3(lib,module,.so), deplist, objects)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/cf/xorg.cf	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1689 @@
+XCOMM $XdotOrg: xc/config/cf/xorg.cf,v 1.53 2005/10/03 16:08:44 alanc Exp $
+/*
+ * This configuration file contains all of the configuration
+ * information for the Xorg based X Servers.
+ *
+ * Most of these settings can be overridden in a vendor.cf or the
+ * BeforeVendor part of the site.def file.
+ */
+XCOMM $Xorg: xfree86.cf,v 1.4 2000/08/17 19:41:49 cpqbld Exp $
+
+/* Get and set version information. */
+
+#include "date.def"
+#include "xorgversion.def"
+
+#if !defined(XorgVersionString) && \
+    defined(XORG_VERSION_MAJOR) && defined(XORG_VERSION_MINOR) && \
+    defined(XORG_VERSION_PATCH) && defined(XORG_VERSION_SNAP)
+# if XORG_VERSION_SNAP == 0
+#  if XORG_VERSION_PATCH == 0
+#   define XorgVersionString `echo XORG_VERSION_MAJOR XORG_VERSION_MINOR | sed 's/ /./g'`
+#  else 
+#   define XorgVersionString `echo XORG_VERSION_MAJOR XORG_VERSION_MINOR XORG_VERSION_PATCH | sed 's/ /./g'`
+#  endif
+# else
+#  define XorgVersionString `echo XORG_VERSION_MAJOR XORG_VERSION_MINOR XORG_VERSION_PATCH XORG_VERSION_SNAP | sed 's/ /./g'`
+# endif
+#endif
+
+#if !defined(XORG_DATE) && defined(XF86_DATE)
+# define XORG_DATE XF86_DATE
+#endif
+
+/*
+ * Xorg versions are M.m.P.s, and XorgVersion is:
+ *
+ *    M * 10000000 + m * 100000 + P * 1000 + s
+ *
+ */
+
+#ifndef XorgVersion
+#  define XorgVersion (((XORG_VERSION_MAJOR) * 10000000) + ((XORG_VERSION_MINOR) * 100000) + ((XORG_VERSION_PATCH) * 1000) + XORG_VERSION_SNAP)
+#endif
+
+#ifndef VersionDefines
+# define VersionDefines -DXORG_VERSION_CURRENT="$(XORG_VERSION_CURRENT)"
+#endif
+
+/* Place the version of the relevant changelog file here */
+#ifndef ReleaseVersion
+# define ReleaseVersion  RELEASE-1
+#endif
+
+XORG_VERSION_CURRENT = XorgVersion
+RELEASE_VERSION = ReleaseVersion
+
+#if !defined(XorgManVersionString) && \
+    defined(XORG_VERSION_MAJOR) && defined(XORG_VERSION_MINOR) && \
+    defined(XORG_VERSION_PATCH) && defined(XORG_VERSION_SNAP)
+# if XORG_VERSION_SNAP == 0
+#define XorgManVersionString `echo XORG_VERSION_MAJOR XORG_VERSION_MINOR XORG_VERSION_PATCH | sed -e 's/ /./g' -e 's/^/Version\\\ /'`
+#else
+#define XorgManVersionString `echo XORG_VERSION_MAJOR XORG_VERSION_MINOR XORG_VERSION_PATCH XORG_VERSION_SNAP | sed -e 's/ /./g' -e 's/^/Version\\\ /'`
+# endif
+#endif
+
+#if !defined(XorgDateString) && defined(XORG_DATE)
+# define XorgDateString XORG_DATE
+#endif
+
+#if !defined(XFree86DateString) && defined(XorgDateString)
+# define XFree86DateString XorgDateString
+#endif
+
+#ifndef BuildDateCmd
+# define BuildDateCmd	date +m%d
+#endif
+
+#if !defined(BuildDate)
+# define BuildDate 	`BuildDateCmd`
+#endif
+
+#ifndef ChangelogDateCmd
+# define ChangelogDateCmd if tail $(CHANGELOGFILE) 2>/dev/null | \	@@\
+	fgrep '$$XdotOrg:' >/dev/null 2>&1; then \			@@\
+	  tail $(CHANGELOGFILE) | fgrep '$$XdotOrg:' | \		@@\
+	  sed s,'.* \([0-9][0-9]*\)/\([0-9][0-9]*\)/\([0-9][0-9]*\).*,\1\2\3,'; \ @@\
+	else echo 0; fi
+#endif
+
+#if !defined(ChangelogDate)
+# define ChangelogDate	`ChangelogDateCmd`
+#endif
+
+#ifndef XVendorString
+# define XVendorString	"The X.Org Foundation"
+#endif
+
+#ifndef XVendorRelease
+# define XVendorRelease	XorgVersion
+#endif
+
+#ifndef XVendorManVersionString
+#define XVendorManVersionString XorgManVersionString
+#endif
+
+#ifndef XVendorManNameString
+#define XVendorManNameString X.Org
+#endif
+
+/*
+ * This enables some settings for developers.
+ */
+
+#ifndef XFree86Devel
+# if !defined(PatheticCpp) || !PatheticCpp
+#  if (XorgVersion % 1000)
+#   define XFree86Devel		YES
+#  else
+#   define XFree86Devel		NO
+#  endif
+# else
+#  define XFree86Devel		NO	/* Assume the worst */
+# endif
+#endif
+
+#ifndef BuildDebug
+# define BuildDebug 		YES
+#endif
+
+/*
+ * settings for the config file parser
+ */
+
+#ifndef XConfigFile
+#define XConfigFile		xorg.conf
+#endif
+#ifndef XConfigDir
+#define XConfigDir		$(LIBDIR)
+#endif
+#ifndef XLogFile
+#define XLogFile		Xorg
+#endif
+#ifndef XServerName
+# define XServerName		Xorg
+#endif
+
+/*
+ * BuildXFree86ConfigTools:
+ *
+ * Turning this on allows the XFree86 config tools to build when
+ * BuildServersOnly is YES.  This requires more than the servonly CVS
+ * module.  This cannot be used to disable building the config tools with
+ * a full build.
+ */
+#ifndef BuildXFree86ConfigTools
+#ifdef BuildServersOnly
+#define BuildXFree86ConfigTools		!BuildServersOnly
+#else
+#define BuildXFree86ConfigTools		YES
+#endif
+#endif
+
+#ifndef BuildLibrariesForConfigTools
+#define BuildLibrariesForConfigTools	BuildXFree86ConfigTools
+#endif
+
+#if BuildXFree86ConfigTools && BuildLibrariesForConfigTools
+#define BuildLibraries		YES
+#define BuildXF86MiscLibrary	YES
+#define BuildXF86VidModeLibrary	YES
+#define BuildXKBlib		YES
+#define BuildXKBfilelib		YES
+#define BuildXKBuilib		YES
+#endif
+
+/*
+ * When this is set, modules are always built separately from the libraries
+ * that statically link into an Xserver.  This is for platforms where the
+ * module and native object formats are different (e.g., OS/2).
+ */
+#ifndef BuildModuleInSubdir
+#define BuildModuleInSubdir	NO
+#endif
+
+#ifndef DoLoadableServer
+#define DoLoadableServer	NO
+#endif
+
+#ifndef MakeDllModules
+#if DoLoadableServer
+#define MakeDllModules		YES
+#else
+#define MakeDllModules		NO
+#endif
+#endif 
+
+/*
+ * Default settings for which X Servers to build.
+ */
+
+/* OS.cf files may set this for OS-specific input drivers */
+#ifndef OSXInputDrivers
+#define OSXInputDrivers /**/
+#endif
+
+/* This may be set in host.def for 3rd party input drivers */
+#ifndef ExtraXInputDrivers
+#define ExtraXInputDrivers /**/
+#endif
+
+/* XInput drivers */
+#ifndef XInputDrivers
+#define XInputDrivers		mouse keyboard acecad calcomp citron \
+				digitaledge dmc dynapro elographics tek4957 \
+				microtouch mutouch penmount spaceorb summa \
+				wacom void magellan /* magictouch */ hyperpen \
+				jamstudio fpit \
+				palmax OSXInputDrivers ExtraXInputDrivers
+#endif
+
+
+/* Deprecated keyboard driver */
+#ifndef UseDeprecatedKeyboardDriver
+#define UseDeprecatedKeyboardDriver NO
+#endif
+
+/* <linux/input.h> support mainly for USB support */
+#ifndef HasLinuxInput
+# define HasLinuxInput NO
+#endif
+
+/* OS.cf files may set this for OS-specific drivers */
+#ifndef XF86OSCardDrivers
+#define XF86OSCardDrivers /**/
+#endif
+
+/* This may be set in host.def for 3rd party drivers */
+#ifndef XF86ExtraCardDrivers
+#define XF86ExtraCardDrivers /**/
+#endif
+
+/* OS.cf files may set this for OS-specific drivers */
+#ifndef HasAgpGart
+#define HasAgpGart NO
+#endif
+
+/* Some DRI drivers are disabled because they are either insecure or unusable on
+ * this architecture.  This switch allows you to enable building these drivers.
+ */
+#ifndef BuildDevelDRIDrivers
+#define BuildDevelDRIDrivers NO
+#endif
+
+/* The glide driver only works for the loadable server at the moment */
+#ifndef HasGlide2
+#define HasGlide2 NO
+#endif
+#if HasGlide2 && DoLoadableServer
+#define GlideDriver glide
+#else
+#define GlideDriver /**/
+#endif
+
+/*
+ * There are three parameters that determine where and how the Matrox HAL
+ * library is used:
+ *
+ *   HaveMatroxHal  -- You have the HALlib.a binary library installed
+ *                     in xfree86/drivers/mga/HALlib, and you want it to
+ *                     be used.
+ *                     Default: NO
+ *
+ *   BuildMatroxHal -- You have the source for the HALlib library (installed
+ *                     in xfree86/drivers/mga/hallib), and want to build and
+ *                     use it.
+ *                     Default: NO
+ *
+ *   UseMatroxHal   -- You want to build support for loading/using the HAL
+ *                     library into the mga driver.  For module server builds
+ *                     you don't need to have the HALlib library to do this.
+ *                     but you want to build support for loading it and using
+ *                     it into the mga driver module.
+ *                     Default: YES for loadable server build
+ *                              (HaveMatroxHal || BuildMatroxHal) for static
+ */
+
+#ifndef HaveMatroxHal
+#define HaveMatroxHal NO
+#endif
+
+#ifndef BuildMatroxHal
+#define BuildMatroxHal NO
+#endif
+
+#ifndef UseMatroxHal
+#if DoLoadableServer
+#define UseMatroxHal YES
+#else
+#define UseMatroxHal (HaveMatroxHal || BuildMatroxHal)
+#endif
+#endif
+
+/*
+ * Many architectures share common X Server pieces.  List them here.
+ */
+#if defined(i386Architecture) || defined(ia64Architecture) || \
+    defined(AMD64Architecture) || defined(SparcArchitecture) || \
+    defined(Sparc64Architecture) || defined(MipsArchitecture) || \
+    defined(AlphaArchitecture) || defined(PpcArchitecture) || \
+    defined(Mc68020Architecture) || defined(Arm32Architecture) || \
+    defined(HPArchitecture) || defined(SuperHArchitecture)
+# ifndef XorgServer
+#  define XorgServer		YES
+# endif
+/* 1bpp module */
+# ifndef XF1Bpp
+#  define XF1Bpp		YES
+# endif
+/* 4bpp module */
+# ifndef XF4Bpp
+#  define XF4Bpp		YES
+# endif
+/* 8/32bpp overlay module */
+# ifndef XF8_32Bpp
+#  define XF8_32Bpp		YES
+# endif
+/* 8/16bpp dual fb module */
+# ifndef XF8_16Bpp
+#  define XF8_16Bpp		YES
+# endif
+/* shadow fb module */
+# ifndef XFShadowFB
+#  define XFShadowFB		YES
+# endif
+/* fbdevhw module */
+# ifndef XF86FBDevHw
+#  define XF86FBDevHw		YES
+# endif
+/* XAA module */
+# ifndef XF86XAA
+#  define XF86XAA		YES
+# endif
+/* Exa module */
+# ifndef XF86EXA
+#  define XF86EXA		YES
+# endif
+/* ramdac module */
+# ifndef XF86Ramdac
+#  define XF86Ramdac		YES
+# endif
+/* I2C module */
+# ifndef XF86I2C
+#  define XF86I2C		YES
+# endif
+/* DDC module */
+# ifndef XF86DDC
+#  define XF86DDC		YES
+# endif
+/* RAC (Resource Access Control) module */
+# ifndef XF86RAC
+#  define XF86RAC		YES
+# endif
+/* int10 module */
+# ifndef XF86Int10
+#  define XF86Int10		YES
+# endif
+/* vbe module */
+# ifndef XF86VBE
+#  define XF86VBE		YES
+# endif
+#endif
+
+/*
+ * Intel x86 and ia64 drivers
+ */
+#if defined(i386Architecture) || defined(ia64Architecture)
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+/* Amiga framebuffer module.  Required by vesa module. */
+# ifndef XF86AFB
+#  define XF86AFB		YES
+# endif
+
+/*
+ * Drivers under development, but not ready for binary releases, or
+ * drivers included on this platform only for build testing.
+ */
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers		imstt newport
+#  else
+#   define DevelDrivers		/**/
+#  endif
+# endif
+
+/* Pure PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  /* Don't build the nsc driver on IA64 */
+#  ifndef ia64Architecture
+#   define i386Drivers		nsc i810
+#  else
+#   define i386Drivers		/**/
+#  endif
+#  define XF86CardDrivers	ast mga glint nv tga s3 s3virge sis rendition \
+				neomagic i740 tdfx savage \
+				cirrus vmware tseng trident chips apm \
+				GlideDriver i128 i386Drivers \
+				ati DevelDrivers ark \
+				cyrix siliconmotion via \
+				vesa vga \
+				dummy XF86OSCardDrivers XF86ExtraCardDrivers
+# endif
+
+# ifndef DevelDRIDrivers
+#  define DevelDRIDrivers	ffb mach64 unichrome
+# endif
+
+# ifndef DriDrivers
+#  ifndef ia64Architecture
+#   define i386DRIDrivers i810 i915 sis
+#  else
+   /* SiS is 64-bit unclean as of this writing. */
+#   define i386DRIDrivers /**/
+#  endif
+#  define DriDrivers		i386DRIDrivers mga r128 radeon r200 tdfx
+# endif
+#endif /* i386Architecture || ia64Architecture */
+
+#if defined(AMD64Architecture)
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+/* Amiga framebuffer module.  Required by vesa module. */
+# ifndef XF86AFB
+#  define XF86AFB		YES
+# endif
+
+/*
+ * Drivers under development, but not ready for binary releases, or
+ * drivers included on this platform only for build testing.
+ */
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers         /**/
+#  else
+#   define DevelDrivers         /**/
+#  endif
+# endif
+
+/* Pure PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers	ast mga glint nv tga s3 s3virge sis rendition \
+				neomagic tdfx savage cirrus tseng trident \
+				chips apm i128 ati ark cyrix siliconmotion \
+				vga dummy vesa i810 vmware \
+				XF86OSCardDrivers XF86ExtraCardDrivers DevelDrivers
+# endif
+
+/* SiS is 64-bit unclean as of this writing. */
+# ifndef DriDrivers
+#  define DriDrivers		i915 mga r128 radeon r200 tdfx
+# endif
+#endif /*AMD64Arcitecture*/
+
+/* SPARC and UltraSPARC drivers */
+
+#if  (defined(SparcArchitecture) || defined(Sparc64Architecture)) && \
+    !defined(LynxOSArchitecture) && \
+    !defined(NetBSDArchitecture) && \
+    !defined(OpenBSDArchitecture)
+/* 8/32wid fb module */
+# ifndef XF8_32Wid
+#  define XF8_32Wid		YES
+# endif
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+/* Amiga framebuffer module.  Required by vesa module. */
+# ifndef XF86AFB
+#  define XF86AFB		YES
+# endif
+
+# ifndef DevelDrivers
+#  if XFree86Devel
+   /*
+    * Some of these are compiled just for the fun of it.  Undoubtedly some
+    * require changes (or even removal) for things like endianness, etc.  Move
+    * those known to work into the main XF86CardDrivers #define.
+    */
+#   define DevelDrivers		apm ark chips cirrus i128 i740 i810 imstt \
+				neomagic newport nv rendition s3virge savage \
+				siliconmotion tga trident vmware dummy
+#  else
+#   define DevelDrivers		/* */
+#  endif
+# endif
+
+/* Pure SBUS and PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  ifdef SunArchitecture
+#   define XF86CardDrivers	/* sunffb */ sunleo suncg6 suncg3 suncg14 \
+				suntcx sunbw2 glint mga tdfx ati vesa vga \
+				dummy XF86OSCardDrivers XF86ExtraCardDrivers \
+				DevelDrivers
+#  else
+#   define XF86CardDrivers	sunffb sunleo suncg6 suncg3 suncg14 suntcx \
+				sunbw2 glint mga tdfx ati vesa vga dummy \
+				XF86OSCardDrivers XF86ExtraCardDrivers \
+				DevelDrivers
+#  endif
+# endif
+# ifndef DriDrivers
+#  define DriDrivers		ffb
+# endif
+
+#endif
+
+/* Sparc64 Drivers */
+#if defined(OpenBSDArchitecture) && defined(Sparc64Architecture)
+/* Amiga framebuffer module */
+# ifndef XF86AFB
+#  define XF86AFB		NO
+# endif
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+# ifndef UseX86Emu
+#  define UseX86Emu		NO
+# endif
+
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers		/* */
+#  else
+#   define DevelDrivers		/* */
+#  endif
+# endif
+
+/* Pure PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers	ati dummy \
+				DevelDrivers \
+				XF86OSCardDrivers XF86ExtraCardDrivers
+# endif
+#endif /* OpenBSDArchitecture && Sparc64Architecture */
+
+/* MIPS drivers */
+
+#ifdef MipsArchitecture
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers		/* */
+#  else
+#   define DevelDrivers		/* */
+#  endif
+# endif
+
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers	mga glint nv s3 s3virge sis savage \
+				trident chips tdfx ati dummy \
+				DevelDrivers newport \
+				XF86OSCardDrivers XF86ExtraCardDrivers
+# endif
+#endif /* MipsArchitecture */
+
+/*
+ * DEC Alpha drivers
+ */
+#ifdef AlphaArchitecture
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers		/* */
+#  else
+#   define DevelDrivers		/* */
+#  endif
+# endif
+
+/* Pure PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers	mga tdfx glint s3 s3virge rendition tga ati \
+				savage nv cirrus DevelDrivers siliconmotion  \
+				vga dummy XF86OSCardDrivers \
+				XF86ExtraCardDrivers
+# endif
+/*
+ *  Glide is available for Alpha, therefore build tdfx DRM module.
+ *  SiS is 64-bit unclean as of this writing. 
+ */  
+# ifndef DriDrivers
+#  define DriDrivers		tdfx mga r128 radeon r200
+# endif
+#endif /* AlphaArchitecture */
+
+/*
+ * Motorola 68k and PowerPC drivers
+ */
+#if defined(PpcArchitecture) || defined(Mc68020Architecture)
+/* Amiga framebuffer module */
+# ifndef XF86AFB
+#  define XF86AFB		YES
+# endif
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers		imstt
+#  else
+#   define DevelDrivers		/* */
+#  endif
+# endif
+
+/* Pure PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers	ati mga glint nv s3 s3virge sis savage\
+				trident chips tdfx \
+				DevelDrivers vga dummy \
+				XF86OSCardDrivers XF86ExtraCardDrivers
+# endif
+/*  The tdfx driver needs Glide, which is not available for PPC. */
+# ifndef DriDrivers
+#  define DriDrivers		mga r128 radeon r200
+# endif
+#endif  /* PpcArchitecture || Mc68020Architecture */
+
+/*
+ * Intel StrongARM and Hewlett-Packard PA-RISC
+ */
+#if defined(Arm32Architecture) || defined(HPArchitecture)
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers		/* */
+#  else
+#   define DevelDrivers		/* */
+#  endif
+# endif
+
+/* Pure PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers	ati mga glint nv s3 s3virge sis savage\
+				trident chips tdfx \
+				DevelDrivers vga dummy \
+				XF86OSCardDrivers XF86ExtraCardDrivers
+# endif
+# ifndef DriDrivers
+#  define DriDrivers		mga r128 radeon r200
+# endif
+#endif
+
+/* SuperH drivers */
+#if defined(SuperHArchitecture)
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers		XF86OSCardDrivers XF86ExtraCardDrivers
+# endif
+#endif
+
+/*
+ * For PowerPC 64bit systems
+ * only libraries are strictly needed
+ */
+#if defined(Ppc64Architecture)
+# ifndef XorgServer
+#  define XorgServer		YES
+# endif
+/* 1bpp module */
+# ifndef XF1Bpp
+#  define XF1Bpp		NO
+# endif
+/* 4bpp module */
+# ifndef XF4Bpp
+#  define XF4Bpp		NO
+# endif
+/* 8/32bpp overlay module */
+# ifndef XF8_32Bpp
+#  define XF8_32Bpp		YES
+# endif
+/* 8/16bpp dual fb module */
+# ifndef XF8_16Bpp
+#  define XF8_16Bpp		YES
+# endif
+/* shadow fb module */
+# ifndef XFShadowFB
+#  define XFShadowFB		YES
+# endif
+/* fbdevhw module */
+# ifndef XF86FBDevHw
+#  define XF86FBDevHw		YES
+# endif
+/* XAA module */
+# ifndef XF86XAA
+#  define XF86XAA		YES
+# endif
+/* Exa module */
+# ifndef XF86EXA
+#  define XF86EXA		YES
+# endif
+/* ramdac module */
+# ifndef XF86Ramdac
+#  define XF86Ramdac		YES
+# endif
+/* I2C module */
+# ifndef XF86I2C
+#  define XF86I2C		YES
+# endif
+/* DDC module */
+# ifndef XF86DDC
+#  define XF86DDC		YES
+# endif
+/* RAC (Resource Access Control) module */
+# ifndef XF86RAC
+#  define XF86RAC		YES
+# endif
+/* int10 module */
+# ifndef XF86Int10
+#  define XF86Int10		YES
+# endif
+/* vbe module */
+# ifndef XF86VBE
+#  define XF86VBE		YES
+# endif
+
+/* vgahw module */
+# ifndef XF86VgaHw
+#  define XF86VgaHw		YES
+# endif
+/* Amiga framebuffer module */
+# ifndef XF86AFB
+#  define XF86AFB		NO
+# endif
+
+# ifndef DevelDrivers
+#  if XFree86Devel
+#   define DevelDrivers		
+#  else
+#   define DevelDrivers		/* */
+#  endif
+# endif
+
+/* Pure PCI drivers should go first */
+# ifndef XF86CardDrivers
+#  define XF86CardDrivers	ati mga dummy \
+				DevelDrivers \
+				XF86OSCardDrivers XF86ExtraCardDrivers
+# endif
+# define TdfxDriDriver		/**/
+# ifndef DriDrivers
+#  define DriDrivers		r128
+# endif
+#endif /* Ppc64Architecture */
+
+/*
+ * For Mips/Arc platforms, the default is to build all modules which
+ * are supported on this platform.
+ */
+#ifdef ArcArchitecture
+# ifndef XorgServer
+#  define XorgServer		YES
+# endif
+#endif
+
+#if BuildDebug
+# define DebugDefines -DBUILDDEBUG
+#else
+# define DebugDefines /**/
+#endif
+
+#ifndef XorgServer
+# define XorgServer		NO
+#endif
+#if !XorgServer
+# undef DoLoadableServer
+# define DoLoadableServer	NO
+#endif
+
+/*
+ * Fbdev module defines.  They are set to indicate the fb types supported
+ * on different architectures.
+ */
+#ifndef XF86AFB
+# define XF86AFB		NO
+#endif
+#ifndef XF86ILBM
+# define XF86ILBM		NO
+#endif
+#ifndef XF86IPLAN2P2
+# define XF86IPLAN2P2		NO
+#endif
+#ifndef XF86IPLAN2P4
+# define XF86IPLAN2P4		NO
+#endif
+#ifndef XF86IPLAN2P8
+# define XF86IPLAN2P8		NO
+#endif
+#if XF86AFB
+AFB_DEFS = -DUSE_AFB
+#endif
+#if XF86ILBM
+ILBM_DEFS = -DUSE_ILBM
+#endif
+#if XF86IPLAN2P2
+IPLAN2P2_DEFS = -DUSE_IPLAN2P2
+#endif
+#if XF86IPLAN2P4
+IPLAN2P4_DEFS = -DUSE_IPLAN2P4
+#endif
+#if XF86IPLAN2P8
+IPLAN2P8_DEFS = -DUSE_IPLAN2P8
+#endif
+#ifndef FbdevDefines
+# define FbdevDefines $(AFB_DEFS) $(ILBM_DEFS) $(IPLAN2P2_DEFS) \
+		     $(IPLAN2P4_DEFS) $(IPLAN2P8_DEFS)
+#endif
+
+/*
+ * The default is to install the X servers setuid-root on most OSs.
+ * It the servers are only started by xdm, they should not be setuid-root.
+ */
+#if !defined(i386MachArchitecture) && !defined(OS2Architecture)
+# ifndef InstallXserverSetUID
+#  define InstallXserverSetUID	YES
+# endif
+#endif
+
+/*
+ * Build GLX server interface
+ *   --- Doesn't work for 1-bit and 4-bit servers
+ */
+#ifndef BuildGlxExt
+#  define BuildGlxExt	YES
+#endif
+
+#ifndef BuildXF86DRI
+#define BuildXF86DRI	NO
+#endif
+
+#ifndef GlxUseSGISI
+#define GlxUseSGISI	NO
+#endif
+
+#if BuildXF86DRI
+
+#ifndef DriDrivers
+#define DriDrivers /**/
+#endif
+
+#ifndef DevelDRIDrivers
+#define DevelDRIDrivers /**/
+#endif
+
+#ifndef BuildGLXLibrary
+#  if defined (BuildServersOnly) && BuildServersOnly
+#    define BuildGLXLibrary	NO
+#  else
+#    define BuildGLXLibrary	YES
+#  endif
+#endif
+
+/*
+ * One and ONLY one of the GlxBuiltIn* drivers can be defined to be YES.
+ * If more than one are defined, the compilation will fail with multiply
+ * defined references of GLX and OpenGL functions.
+ */
+
+/*
+ * The first is a built-in driver that does software rendering client-side
+ * and renders to the X server via Xlib.
+ */
+
+#  ifndef GlxBuiltInXMesa
+#    define GlxBuiltInXMesa         NO
+#  endif
+
+/*
+ * The rest are hardware-specific DRI drivers.
+ */
+#  ifndef GlxBuiltInGamma
+#    define GlxBuiltInGamma        NO
+#  endif
+#  ifndef GlxBuiltInTdfx
+#    define GlxBuiltInTdfx         NO
+#  endif
+#  ifndef GlxBuiltInMga
+#    define GlxBuiltInMga          NO
+#  endif
+#  ifndef GlxBuiltInI810
+#    define GlxBuiltInI810         NO
+#  endif
+#  ifndef GlxBuiltInI915
+#    define GlxBuiltInI915         NO
+#  endif
+#  ifndef GlxBuiltInR128
+#    define GlxBuiltInR128         NO
+#  endif
+#  ifndef GlxBuiltInRadeon
+#    define GlxBuiltInRadeon       NO
+#  endif
+#  ifndef GlxBuiltInR200
+#    define GlxBuiltInR200         NO
+#  endif
+#  ifndef GlxBuiltInFfb
+#    define GlxBuiltInFfb          NO
+#  endif
+#  ifndef GlxBuiltInSIS
+#    define GlxBuiltInSIS          NO
+#  endif
+
+#  if GlxBuiltInTdfx || \
+      GlxBuiltInMga || \
+      GlxBuiltInI810 || \
+      GlxBuiltInI915 || \
+      GlxBuiltInR128 || \
+      GlxBuiltInRadeon || \
+      GlxBuiltInR200 || \
+      GlxBuiltInFfb || \
+      GlxBuiltInSIS
+#    define GlxDriverUsesMesa      YES
+#  else
+#    define GlxDriverUsesMesa      NO
+#  endif
+
+#  if GlxBuiltInGamma || \
+      GlxBuiltInTdfx || \
+      GlxBuiltInMga || \
+      GlxBuiltInI810 || \
+      GlxBuiltInI915 || \
+      GlxBuiltInR128 || \
+      GlxBuiltInRadeon || \
+      GlxBuiltInR200 || \
+      GlxBuiltInFfb || \
+      GlxBuiltInSIS
+#    define GlxUseBuiltInDRIDriver YES
+#    define DRIDynLoadDefines /**/
+#  else
+#    define GlxUseBuiltInDRIDriver NO
+#    define DRIDynLoadDefines -DGLX_USE_DLOPEN
+#  endif
+
+#  if GlxUseBuiltInDRIDriver
+#    undef DriDrivers
+#    if GlxBuiltInGamma
+#      define DriDrivers gamma
+#    endif
+#    if GlxBuiltInTdfx
+#      define DriDrivers tdfx
+#    endif
+#    if GlxBuiltInMga
+#      define DriDrivers mga
+#    endif
+#    if GlxBuiltInI810
+#      define DriDrivers i810
+#    endif
+#    if GlxBuiltInI915
+#      define DriDrivers i915
+#    endif
+#    if GlxBuiltInR128
+#      define DriDrivers r128
+#    endif
+#    if GlxBuiltInRadeon
+#      define DriDrivers radeon
+#    endif
+#    if GlxBuiltInR200
+#      define DriDrivers r200
+#    endif
+#    if GlxBuiltInSIS
+#      define DriDrivers sis
+#    endif
+#    if GlxBuiltInFfb
+#      define DriDrivers ffb
+#    endif
+#  endif
+
+#endif
+
+/*
+ * This enables building DRI support into video drivers, which can be done
+ * even on platforms that don't have functional DRI support.
+ *
+ * Defining BuildXF86DRIDriverSupport to YES will not work until we have a
+ * separate set of defines set up for building driver-only support for the
+ * DRI.
+ */
+#ifndef BuildXF86DRIDriverSupport
+# define BuildXF86DRIDriverSupport NO
+#endif
+
+#if BuildGlxExt
+
+#  if BuildXF86DRI
+#    define DRIDefines -DXF86DRI -DGLX_DIRECT_RENDERING DRIDynLoadDefines
+#  else
+#    define DRIDefines /**/
+#  endif
+#  if defined(GlxUseSGISI) && GlxUseSGISI
+#    define GlxCoreLibDefines -DGLX_USE_SGI_SI
+#  else
+#    define GlxCoreLibDefines -DGLX_USE_MESA
+#  endif
+
+#  if defined(SparcArchitecture)  \
+   || defined (Sparc64Architecture) \
+   || defined(ia64Architecture) \
+   || defined(s390xArchitecture) \
+   || defined(AMD64Architecture)
+#    define GlxArchDefines -D__GLX_ALIGN64
+#  elif defined(AlphaArchitecture)
+/* On the Alpha we need to ensure floating point accuracy for 3D */
+#    define GlxArchDefines -D__GLX_ALIGN64 -mieee
+#  elif defined(DarwinArchitecture)
+/* GLX contains lots of uninitialized globals, which can upset Darwin */
+#    define GlxArchDefines -fno-common
+#  else
+#    define GlxArchDefines /**/
+#  endif
+
+#  ifndef GlxExtraDefines
+#    define GlxExtraDefines DRIDefines GlxCoreLibDefines GlxArchDefines
+#  endif
+
+#else
+
+/* If we are not building GLX, then make sure the DRI is not built */
+#  undef  BuildXF86DRI
+#  define BuildXF86DRI   NO
+#  undef  BuildXF86DRIDriverSupport
+#  define BuildXF86DRIDriverSupport NO
+
+#endif
+
+#if !BuildXF86DRI
+# define GlxUseBuiltInDRIDriver NO	/* For libOSmesa */
+#endif
+
+# ifndef UseX86Emu
+#  define UseX86Emu		YES
+# endif
+
+#define X86INT10_STUB   0
+#define X86EMU_GENERIC  1
+#define X86VM           2
+#define X86EMU_OS       3
+
+#ifndef XF86INT10_BUILD
+# if UseX86Emu
+#  define XF86INT10_BUILD		X86EMU_GENERIC
+# else
+#  define XF86INT10_BUILD		X86INT10_STUB
+# endif
+#endif
+/*
+ * Build the Rush extension library (non standard extension for cooperation
+ * between glide library and X server). Enabled by default only for Linux.
+ */
+#ifndef BuildXF86RushExt
+# define BuildXF86RushExt	NO
+#endif
+
+#ifndef BuildDBElib
+# define BuildDBElib	YES
+#endif
+
+#ifndef BuildRECORDlib
+# define BuildRECORDlib	YES
+#endif
+
+#ifndef BuildXKBlib
+# define BuildXKBlib	YES
+#endif
+
+#ifndef BuildScreenSaverExt
+# define BuildScreenSaverExt	YES
+#endif
+
+/*
+ * Build XInput support
+ */
+#ifndef BuildXInputExt
+# define BuildXInputExt		YES
+#endif
+
+/* Build Xinerama (aka panoramiX) extension */
+#ifndef BuildXinerama
+# define BuildXinerama		YES
+#endif
+
+/* Build Render extension */
+#ifndef BuildRender
+# define BuildRender		YES
+#endif
+
+#if 0
+#ifndef JoystickSupport
+# define JoystickSupport	NO
+#endif
+#endif
+
+#if 0
+/*
+ * Build the extra extension libs even when not including the extra extensions
+ * in the servers
+ */
+#ifndef BuildScreenSaverLibrary
+# define BuildScreenSaverLibrary   YES
+#endif
+#ifndef BuildXF86MiscLibrary
+# define BuildXF86MiscLibrary	YES
+#endif
+#ifndef BuildXF86DGALibrary
+# define BuildXF86DGALibrary	YES
+#endif
+#ifndef BuildXF86VidModeLibrary
+# define BuildXF86VidModeLibrary YES
+#endif
+#ifndef BuildXvLibrary
+# define BuildXvLibrary		YES
+#endif
+#ifndef BuildXvMCLibrary
+# define BuildXvMCLibrary	YES
+#endif
+#ifndef BuildGLXLibrary
+# define BuildGLXLibrary	YES
+#endif
+#ifndef BuildXResLibrary
+# define BuildXResLibrary       YES
+#endif
+#endif
+
+/*
+ * Build the XFree86-VidMode extension
+ */
+#ifndef BuildXF86VidModeExt
+# define BuildXF86VidModeExt		YES
+#endif
+
+/* Don't build this now because the interface hasn't been done yet */
+/*
+ * Build the XFree86-Misc extension
+ */
+#ifndef BuildXF86MiscExt
+# define BuildXF86MiscExt		YES
+#endif
+
+/*
+ * Build the XFree86-Bigfont extension
+ */
+#ifndef BuildXF86BigfontExt
+# define BuildXF86BigfontExt		YES
+#endif
+
+/*
+ * Build the XFree86 DGA support
+ */
+#ifndef BuildXF86DGA
+# define BuildXF86DGA			YES
+#endif
+
+/*
+ * Build the DPMS extension support
+ */
+#ifndef BuildDPMSExt
+# define BuildDPMSExt			YES
+#endif
+
+/*
+ * Build the X Video Extension
+ */
+#ifndef BuildXvExt
+# define BuildXvExt			YES
+#endif
+
+/*
+ * Build the X Video Motion Compensation Extension
+ */
+#ifndef BuildXvMCExt
+# define BuildXvMCExt			YES
+#endif
+
+/*
+ * Build the X-Resource Extension 
+ */
+#ifndef BuildXResExt
+# define BuildXResExt                   YES
+#endif
+
+#if Malloc0ReturnsNull
+# ifndef XtMalloc0ReturnsNullDefines
+#  define XtMalloc0ReturnsNullDefines	Malloc0ReturnsNullDefines -DXTMALLOC_BC
+# endif
+#endif
+
+#ifndef UseInternalMalloc
+# define UseInternalMalloc	NO
+#endif
+
+#ifndef HasDlsymBug
+# define HasDlsymBug		NO
+#endif
+
+#ifndef HasMTRRSupport
+# define HasMTRRSupport		NO
+#endif
+
+/*
+ * Build the font server
+ */
+#ifndef BuildFontServer
+# define BuildFontServer	YES
+#endif
+
+/*
+ * Include fonts support
+ */
+#ifndef BuildSpeedo
+# define BuildSpeedo		NO
+#endif
+
+#ifndef BuildType1
+# define BuildType1		NO
+#endif
+
+#ifndef BuildCID
+# define BuildCID		YES
+#endif
+
+#ifndef BuildFreeType
+# define BuildFreeType		YES
+#endif
+
+/*
+ * By default, build all of the fonts.
+ */
+#ifndef Build75DpiFonts
+# define Build75DpiFonts	YES
+#endif
+#ifndef Build100DpiFonts
+# define Build100DpiFonts	YES
+#endif
+#ifndef BuildSpeedoFonts
+# define BuildSpeedoFonts	NO
+#endif
+#ifndef BuildType1Fonts
+# define BuildType1Fonts	YES
+#endif
+#ifndef BuildCIDFonts
+# define BuildCIDFonts		YES
+#endif
+#ifndef BuildTrueTypeFonts
+# define BuildTrueTypeFonts	YES
+#endif
+#ifndef BuildCyrillicFonts
+# define BuildCyrillicFonts	YES
+#endif
+
+/*
+ * Build scanpci?
+ */
+#ifndef SystemV
+#define SystemV			NO
+#endif
+#ifndef SystemV4
+#define SystemV4		NO
+#endif
+#ifndef BuildScanpci
+# if SystemV || SystemV4 || \
+    (defined(LinuxArchitecture) && !defined(Mc68020Architecture)) || \
+    defined(i386BsdArchitecture) || defined(LynxOSArchitecture) || \
+    defined(OS2Architecture) || defined(GNUMachArchitecture) || \
+    (defined(KFreeBSDArchitecture) && defined(i386Architecture))
+#   define BuildScanpci		YES
+# else
+#   define BuildScanpci		NO
+# endif
+#endif
+
+#ifndef CompressAllFonts
+# define CompressAllFonts	YES
+#endif
+
+#ifndef GzipFontCompression
+# define GzipFontCompression	YES
+#endif
+
+/* Disable stripping installed programs for this release. */
+#ifndef StripInstalledPrograms
+# define StripInstalledPrograms	NO
+#endif
+
+#ifndef InstallJapaneseDocs
+#define InstallJapaneseDocs	NO
+#endif
+
+#if BuildXF86DGA
+# define XFree86DGADefines	-DXFreeXDGA
+#else
+# define XFree86DGADefines	/**/
+#endif
+
+#if BuildXvExt
+# define XFree86XvDefines	-DXvExtension
+#else
+# define XFree86XvDefines	/**/
+#endif
+
+#if BuildXvMCExt
+# define XFree86XvMCDefines	-DXvMCExtension
+#else
+# define XFree86XvMCDefines	/**/
+#endif
+
+#if BuildXResExt
+# define XFree86XResDefines     -DXResExtension
+#else
+# define XFree86XResDefines     /**/
+#endif
+
+#ifndef DlopenHack
+# define DlopenHack		-DDLOPEN_HACK
+#endif
+
+#ifndef ExtraLoaderDefines
+# if MakeDllModules
+#  define ExtraLoaderDefines	DlopenHack
+# else
+#  define ExtraLoaderDefines	/**/
+# endif
+#endif
+
+#if DoLoadableServer
+# define XFree86LoaderDefines	-DXFree86LOADER ExtraLoaderDefines
+#else
+# define XFree86LoaderDefines	/**/
+#endif
+
+#ifndef HasBsdMake
+#define HasBsdMake		NO
+#endif
+
+#ifndef MakeHasPosixVariableSubstitutions
+# if !HasBsdMake && !defined(SunArchitecture)
+#  define MakeHasPosixVariableSubstitutions	NO
+# else
+#  define MakeHasPosixVariableSubstitutions	YES
+# endif
+#endif
+
+#ifndef UseSmartScheduler
+#define UseSmartScheduler YES
+#endif
+
+#if UseSmartScheduler
+#define SmartScheduleDefines -DSMART_SCHEDULE
+#else
+#define SmartScheduleDefines /**/
+#endif
+
+/* Server defines required for all OSs */
+#ifndef XFree86ServerDefines
+# define XFree86ServerDefines	-DAVOID_GLYPHBLT -DPIXPRIV -DSINGLEDEPTH \
+				XFree86DGADefines XFree86XvDefines \
+				XFree86LoaderDefines -DXFree86Server \
+				VidModeExtensionDefines \
+				XFree86XvMCDefines \
+				SmartScheduleDefines \
+				DebugDefines XFree86XResDefines \
+				-DX_BYTE_ORDER=$(X_BYTE_ORDER) \
+				VersionDefines
+#endif
+
+#ifndef XFree86ServerOSDefines
+# define XFree86ServerOSDefines	-DDDXOSINIT -DSERVER_LOCK -DDDXOSFATALERROR \
+				-DDDXOSVERRORF
+#endif
+
+#ifndef XFree86ConsoleDefines
+# if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) || (defined(KFreeBSDArchitecture) && defined(i386Architecture))
+#  define XFree86ConsoleDefines	-DPCCONS_SUPPORT -DSYSCONS_SUPPORT -DPCVT_SUPPORT
+# elif defined(KFreeBSDArchitecture)
+#  define XFree86ConsoleDefines -DSYSCONS_SUPPORT
+# else
+#  define XFree86ConsoleDefines	/**/
+# endif
+#endif
+
+/* Support for USB mouse */
+#ifndef UsbMouseSupport
+# define UsbMouseSupport NO
+#endif
+/* Does this OS have libusb ? */
+#ifndef HasLibUsb
+# define HasLibUsb	NO
+#endif
+
+#ifndef UseServerLock
+# define UseServerLock	YES
+#endif
+
+#ifndef XnestServer
+# define XnestServer		YES
+#endif
+#ifndef XVirtualFramebufferServer
+# define XVirtualFramebufferServer	YES
+#endif
+
+#ifndef ServerExtraDefines
+# define ServerExtraDefines	XFree86ServerDefines
+#endif
+
+#ifndef ServerOSDefines
+# define ServerOSDefines	XFree86ServerOSDefines
+#endif
+
+#ifndef DriverSDKDir
+# define DriverSDKDir     $(USRLIBDIR)/Server
+#endif
+
+#ifndef DriverSDKModuleDir
+# define DriverSDKModuleDir     $(USRLIBDIR)/Server/modules
+#endif
+
+#ifndef DriverSDKIncludeDir
+# define DriverSDKIncludeDir     $(USRLIBDIR)/Server/include
+#endif
+
+DRIVERSDKDIR = DriverSDKDir
+DRIVERSDKMODULEDIR = DriverSDKModuleDir
+DRIVERSDKINCLUDEDIR = DriverSDKIncludeDir
+
+/*
+ * Some commonly refered to directories are defined here.
+ */
+
+       XF86SRC = $(SERVERSRC)/hw/xfree86
+    XF86COMSRC = $(XF86SRC)/common
+ XF86PARSERSRC = $(XF86SRC)/parser
+     XF86OSSRC = $(XF86SRC)/os-support
+ XF86DRIVERSRC = $(XF86SRC)/drivers
+     DRIVERSRC = $(XF86DRIVERSRC)
+
+/*
+ * Installed location of the XFree86 documentation
+ */
+
+        XFREE86DOCDIR = $(DOCDIR)
+      XFREE86PSDOCDIR = $(DOCPSDIR)
+     XFREE86PDFDOCDIR = $(DOCPDFDIR)
+    XFREE86HTMLDOCDIR = $(DOCHTMLDIR)
+XFREE86JAPANESEDOCDIR = $(DOCDIR)/Japanese
+
+/*
+ * Other stuff used in the X Server source.
+ */
+
+#ifndef OtherIConfigFiles
+# define OtherIConfigFiles $(IRULESRC)/xfree86.cf $(IRULESRC)/xf86.rules
+#endif
+
+#ifndef UseRgbTxt
+# define UseRgbTxt	YES
+#endif
+
+#ifndef ManSuffix
+# define ManSuffix	1
+#endif
+
+/*
+ * GNU Compiler stuff
+ */
+#ifndef HasGcc3
+# define HasGcc3 NO
+#endif
+#ifndef HasGcc2
+# define HasGcc2 HasGcc3
+#endif
+#ifndef HasGcc
+# define HasGcc HasGcc2
+#endif
+#ifndef HasGcc2ForCplusplus
+# define HasGcc2ForCplusplus HasGcc2
+#endif
+
+#if HasGcc
+# ifndef Gcc28Warnings
+#  if (GccMajorVersion > 2) || \
+      ((GccMajorVersion == 2) && (GccMinorVersion >= 8))
+#   define Gcc28Warnings -Wundef
+#  else
+#   define Gcc28Warnings /* */
+#  endif
+# ifndef HasGcc34
+#  if (((GccMajorVersion == 3) && (GccMinorVersion >= 4)) ||	\
+ 	(GccMajorVersion > 3))
+#   define HasGcc34 YES
+#  else
+#   define HasGcc34 NO
+#  endif
+# endif
+# endif
+# ifndef GccWarningOptions
+#  if XFree86Devel
+#   define GccWarningOptions -Wall -Wpointer-arith -Wstrict-prototypes \
+			  -Wmissing-prototypes -Wmissing-declarations \
+			  -Wredundant-decls -Wnested-externs Gcc28Warnings
+#  else
+#   define GccWarningOptions -Wall -Wpointer-arith Gcc28Warnings
+#  endif
+# endif
+# ifndef DefaultCCOptions
+#  if defined(UseInstalled)
+#   define DefaultCCOptions /* -ansi */
+#  else
+#   define DefaultCCOptions -ansi GccWarningOptions
+#  endif
+# endif
+# if defined(UseInstalled)
+#  ifndef UseGccMakeDepend
+#   define UseGccMakeDepend YES
+#  endif
+# endif
+#endif
+
+/* Make imake noisier.  Note that this is ineffective for 3.0 <= GCC <= 3.2 */
+#ifndef ImakeWarningFlags
+# ifdef Gcc28Warnings
+#  define ImakeWarningFlags Gcc28Warnings
+# else
+#  define ImakeWarningFlags /* */
+# endif
+#endif
+
+#if  ((GccMajorVersion == 3) &&  (GccMinorVersion >= 1)) || (GccMajorVersion > 3)
+# define GccAliasingArgs      -fno-strict-aliasing
+#else
+# define GccAliasingArgs      /* */
+#endif
+
+#if HasGcc2 && defined(i386Architecture)
+# ifndef DefaultGcc2i386Opt
+#  define DefaultGcc2i386Opt -O2 -fno-strength-reduce GccAliasingArgs
+# endif
+#endif
+
+#if HasGcc2 && defined(AMD64Architecture)
+# ifndef DefaultGcc2AMD64Opt
+#  define DefaultGcc2AMD64Opt -O2 -fno-strength-reduce GccAliasingArgs
+# endif
+#endif
+
+#if HasGcc2 && defined(AlphaArchitecture)
+# ifndef DefaultGcc2AxpOpt
+#  define DefaultGcc2AxpOpt -O2 GccAliasingArgs
+# endif
+#endif
+
+#if HasGcc2 && defined(Ppc64Architecture)
+# ifndef DefaultGcc2Ppc64Opt
+#  define DefaultGcc2Ppc64Opt -O2 GccAliasingArgs
+# endif
+#endif
+
+#if HasGcc2 && defined(MipsArchitecture)
+# ifndef DefaultGcc2MipsOpt
+#  define DefaultGcc2MipsOpt -O2 GccAliasingArgs
+# endif
+#endif
+
+#if HasGcc2 && defined(PpcArchitecture)
+# ifndef DefaultGcc2PpcOpt
+#  define DefaultGcc2PpcOpt -O2 GccAliasingArgs
+# endif
+#endif
+
+#ifndef DefaultGcc2DebugOpt
+# define DefaultGcc2DebugOpt -g
+#endif
+
+#ifndef DebuggableLibraries
+# define DebuggableLibraries NO
+#endif
+
+#if HasGcc2 && DebuggableLibraries
+# define LibraryDebugOpt DefaultGcc2DebugOpt
+#endif
+
+/*
+ * Some versions of gcc have optimisation bugs that cause problems building
+ * some files.  The definitions here cover those.
+ */
+
+#ifndef Egcs112Bug
+  /* Not exactly precise, but it'll do for now... */
+# if HasGcc2 && defined(i386Architecture) && \
+     (GccMajorVersion == 2) && (GccMinorVersion > 8)
+#  define Egcs112Bug YES
+# else
+#  define Egcs112Bug NO
+# endif
+#endif
+
+#ifdef i386Architecture
+# ifndef HasX86Support
+#  define HasX86Support YES
+# endif
+# ifndef HasMMXSupport
+#  define HasMMXSupport YES
+# endif
+# ifndef HasSSESupport
+#  define HasSSESupport NO
+# endif
+# ifndef Has3DNowSupport
+#  define Has3DNowSupport NO
+# endif
+#elif defined (AMD64Architecture)
+# ifndef HasX86Support
+#  define HasX86Support NO
+# endif
+# ifndef HasMMXSupport
+#  define HasMMXSupport NO
+# endif
+# ifndef HasSSESupport
+#  define HasSSESupport NO
+# endif
+# ifndef Has3DNowSupport
+#  define Has3DNowSupport NO
+# endif
+#else 
+# ifndef HasX86Support
+#  define HasX86Support NO
+# endif
+# ifndef HasMMXSupport
+#  define HasMMXSupport NO
+# endif
+# ifndef HasSSESupport
+#  define HasSSESupport NO
+# endif
+# ifndef Has3DNowSupport
+#  define Has3DNowSupport NO
+# endif
+#endif
+
+#ifndef StaticNeedsPicForShared
+# if defined (AMD64Architecture)\
+  || defined (AlphaArchitecture) \
+  || defined (ia64Architecture) \
+  || defined (PpcArchitecture) \
+  || defined (SparcArchitecture) \
+  || defined (s390xArchitecture) 
+#  define StaticNeedsPicForShared YES
+# else
+#  define StaticNeedsPicForShared NO
+# endif
+#endif
+
+#if (defined(SparcArchitecture) || defined(Sparc64Architecture)) \
+    && !defined(LargePositionIndependentCFlags) \
+    && defined(HasGcc)
+# define LargePositionIndependentCFlags -fPIC
+#endif
+
+#ifndef XF8_32Wid
+# define XF8_32Wid		NO
+#endif
+
+#if CrossCompiling
+#include <cross.def>
+#endif
+#include <xf86.rules>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/cf/xorgsite.def	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,768 @@
+XCOMM $XFree86: xc/config/cf/xf86site.def,v 3.186 2003/06/25 18:06:22 eich Exp $
+/******************************************************************************/
+/*
+ * This file is to provide a quick method for most people to change the
+ * behaviour of their Xorg installation without having to fully
+ * understand the workings of site.def and all the various '.cf' files.
+ *
+ * In the vast majority of cases, it should not be necessary to use this
+ * file at all or change it in any way.
+ *
+ * This file is divided into two sections.  The first contains settings
+ * that end-users might reasonably change.  The second contains settings
+ * that developers might want to change.
+ *
+ * IMPORTANT NOTE:  In all cases changing the defaults may cause problems
+ * and/or unexpected side-effects.  If you don't understand what a setting
+ * does, then it's best to not change it.  If you make changes and have
+ * problems, verify that those problems are also present when using an
+ * empty host.def file and unchanged version of this file before reporting
+ * them.
+ *
+ * A good way to use this file is to copy it to host.def, and make the
+ * changes there.  That way, future patches to this file won't fail.
+ * The host.def file will never be patched.
+ *
+ * The distributed version of this file MUST contain no uncommented
+ * definitions.  Default definitions belong in xorg.cf, or <vendor>.cf
+ * files.
+ */
+/******************************************************************************/
+
+/*
+ * If you have build-specific modifications in your host.def file, but
+ * want an empty host.def file installed when doing 'make install',
+ * uncomment the following
+ *
+#define InstallEmptyHostDef
+ */
+
+/*
+ * Which servers to build.  There is only Xorg server.
+ * It can be disabled by the following.
+ *
+#define XorgServer		NO
+ */
+
+/*
+ * To disable building the Xnest server, uncomment this.
+ *
+#define XnestServer		NO
+ */
+
+/*
+ * To disable building Xvfb, uncomment this.
+ *
+#define XVirtualFramebufferServer	NO
+ */
+
+/*
+ * To enable building Xdmx, uncomment this.
+ *
+#define XdmxServer YES
+ */
+
+/*
+ * To disable building Xprt, uncomment this.
+ *
+#define XprtServer NO
+ */
+
+/*
+ * Set the default server (ie the one that gets the sym-link to "X")
+ *
+#define ServerToInstall		Xorg
+ */
+
+/*
+ * If you only run the X server under xdm the X servers don't need to be
+ * installed SetUID, and you may comment out the lines below.  If you run
+ * the servers by hand (with xinit or startx), then they do need to be
+ * installed SetUID on most platforms.
+ *
+ * Consult your system administrator before making the X server setuid.
+ *
+#define InstallXserverSetUID	NO
+ */
+
+
+/*
+ * Server configuration parameters.  The defaults are shown here:
+ */
+
+/*
+ * Which drivers to build.  When building a static server, each of these
+ * will be included in it.  When building the loadable server each of these
+ * modules will be built.
+ *
+#define XF86CardDrivers		ast mga glint nv tga s3virge sis rendition \
+				neomagic i740 tdfx savage \
+				cirrus vmware tseng trident chips apm \
+				GlideDriver fbdev i128 \
+				ati DevelDrivers ark cyrix \
+				siliconmotion \
+				vesa vga XF86OSCardDrivers XF86ExtraCardDrivers
+ */
+
+/*
+ * To add third party drivers to the standard driver list, set the
+ * following.
+ *
+#define XF86ExtraCardDrivers	extradriver1 extradriver2 ...
+ */
+
+/*
+ * Select the XInput devices you want by uncommenting this.
+ *
+#define XInputDrivers		mouse keyboard acecad calcomp citron \
+				digitaledge dmc dynapro elographics \
+				microtouch mutouch penmount spaceorb summa \
+				wacom void magictouch aiptek
+ */
+
+/* To enable building of development DRI drivers (insecure, or not
+ * useful on the chosen architecture, uncomment this define.
+#define BuildDevelDRIDrivers YES
+ */
+
+/*
+ * To use the deprecated, old keyboard driver, uncomment this.  But
+ * even better, make the new keyboard driver (hw/xfree86/input/keyboard)
+ * work for your architechture.  The old driver will be removed in the
+ * next release.
+ *
+#define UseDeprecatedKeyboardDriver YES
+ */
+
+/*
+ * There are three parameters that determine where and how the Matrox HAL
+ * library is used:
+ *
+ *   HaveMatroxHal  -- You have the HALlib.a binary library installed
+ *                     in xfree86/drivers/mga/HALlib, and you want it to
+ *                     be used.
+ *                     Default: NO
+ *
+ *   BuildMatroxHal -- You have the source for the HALlib library (installed
+ *                     in xfree86/drivers/mga/hallib), and want to build and
+ *                     use it.
+ *                     Default: NO
+ *
+ *   UseMatroxHal   -- You want to build support for loading/using the HAL
+ *                     library into the mga driver.  For module server builds
+ *                     you don't need to have the HALlib library to do this.
+ *                     but you want to build support for loading it and using
+ *                     it into the mga driver module.
+ *                     Default: YES for loadable server build
+ *                              (HaveMatroxHal || BuildMatroxHal) for static
+ */
+
+/*
+ * To disable use of the Matrox HAL library, uncomment this:
+ *
+#define UseMatroxHal		NO
+ */
+
+/*
+ * If you have the HALlib.a binary installed in xfree86/drivers/mga/HALlib,
+ * uncomment this:
+ *
+#define HaveMatroxHal		YES
+ */
+
+/*
+ * If you have the HALlib source code installed in xfree86/drivers/mga/hallib,
+ * uncomment this:
+#define BuildMatroxHal		YES
+ */
+
+/*
+ * To disable building the font server, uncomment this.
+ *
+#define BuildFontServer		NO
+ */
+
+/*
+ * Speedo fonts have been disabled by default in this release.
+ * To re-enable support for Speedo fonts, uncomment this.
+ *
+#define BuildSpeedo		YES
+ */
+
+/*
+ * To disable support for CID fonts, uncomment this.
+ *
+#define BuildCID		NO
+ */
+
+/*
+ * To disable support for TrueType fonts, uncomment these.
+ *
+#define BuildFreeType		NO
+ */
+
+/*
+ * To set non-default build options for the underlying FreeType libraries,
+ * add them here and uncomment.
+ *
+#define Freetype2BuildDefines	-DFREETYPE_BUILD_DEFINES
+ */
+
+/*
+ * To build the FreeType libraries with the TrueType byte code interpreter
+ * enabled, uncomment this.  Note that there are patent issues related to the
+ * TrueType byte code interpreter, and we only recommend you enabling this
+ * if you are sure that there are no legal impediments to you doing so.  See
+ * <http://www.freetype.org/patents.html> for further information.
+ *
+#define Freetype2BuildDefines -DTT_CONFIG_OPTION_BYTECODE_INTERPRETER
+ */
+
+/*
+ * Do you want to Build Fonts (Usually you only want to build and install
+ * fonts once, if this is a first time install you will want to build the
+ * fonts)
+ *
+#define BuildFonts		NO
+ */
+
+/*
+ * To not build/install the 75dpi fonts, uncomment the following
+ *
+#define Build75DpiFonts		NO
+ */
+
+/*
+ * To not build/install the 100dpi fonts, uncomment the following
+ *
+#define Build100DpiFonts	NO
+ */
+
+/*
+ * To build/install the Speedo fonts, uncomment the following
+ * (see setting above about Speedo support as well)
+ *
+#define BuildSpeedoFonts	YES
+ */
+
+/*
+ * To not build/install the Type1 fonts, uncomment the following
+ *
+#define BuildType1Fonts		NO
+ */
+
+/*
+ * To not build/install the CID fonts, uncomment the following
+ *
+#define BuildCIDFonts		NO
+ */
+
+/*
+ * To not build/install the True Type fonts, uncomment the following
+ *
+#define BuildTrueTypeFonts	NO
+ */
+
+/*
+ * To not build/install the Cyrillic fonts, uncomment the following
+ *
+#define BuildCyrillicFonts	NO
+ */
+
+/*
+ * To not install the local font directory, uncomment the following
+ *
+#define MakeLocalFontDir	NO
+ */
+
+/*
+ * To build only the servers with a cut-down source tree, uncomment
+ * this.
+ *
+#define BuildServersOnly	YES
+ */
+
+/*
+ * By default, the sample config files for xinit, xdm and xfs are installed
+ * only when there is no pre-existing version installed.  Uncommenting the
+ * following lines will force the sample versions to be installed even if
+ * it means over-writing existing versions.
+ *
+#define InstallXinitConfig	YES
+#define InstallXdmConfig	YES
+#define InstallFSConfig		YES
+ */
+
+/*
+ * By default the application defaults files are always installed.
+ * Uncommenting the the following will prevent exising application
+ * defaults files from being over-written.
+ *
+#define InstallAppDefFiles	NO
+ */
+
+/*
+ * Undefine the following if you don't want to have config files and
+ * app-defaults installed in a separate directory (i.e. /etc/X11).
+ *
+#define UseSeparateConfDir NO
+ */
+
+/* 
+ * To enable building the glide driver, you need to define 
+ * HasGlide2 to YES and set the Glide2IncDir variable. 
+ * HasGlide2 is per default NO.
+ *
+#define HasGlide2 YES
+ */
+
+/*
+ * Set the path to your Glide include files.
+ *
+#define Glide2IncDir /usr/include/glide
+ */
+
+/* 
+ * Have glide 3?
+ *
+#define HasGlide3 YES
+ */
+
+/*
+ * Set the path to your Glide 3 include files.
+ *
+#define Glide3IncDir /usr/include/glide3
+ */
+
+
+
+/*
+ * Unless you're a developer you shouldn't need to change anything
+ * beyond this point.
+ */
+
+/*
+ * If you want to enable some developer settings, like more verbose
+ * compiler warnings, uncomment this.
+ *
+#define XFree86Devel	YES
+*/
+
+/*
+ * The default optimisation flags for GCC 2.x.  -fno-strength-reduce is
+ * here to work around a bug in -O2 for GCC 2.x on i386 platforms.
+ * If you are using a version that doesn't have this bug, you can
+ * uncomment the following line, and remove '-fno-strength-reduce'
+ * If you are building binaries for a 486, it may be beneficial to add
+ * -m486
+ *
+#define DefaultGcc2i386Opt	-O2 -fno-strength-reduce
+ */
+
+/*
+ * This allows the GCC warning flags to be set.  The default is shown here.
+ *
+#define GccWarningOptions -Wall -Wpointer-arith -Wstrict-prototypes \
+                          -Wmissing-prototypes -Wmissing-declarations \
+                          -Wredundant-decls -Wnested-externs
+ */
+
+/* 
+ * Sun Compiler stuff.. 
+ *
+#define HasSunC                         YES
+#define HasSunCplusplus                 YES
+#define CplusplusCompilerMajorVersion   5
+#define CplusplusCompilerMinorVersion   0
+#define CCompilerMajorVersion           5
+#define CCompilerMinorVersion           0
+ */
+
+/*
+ * Optimized Sun Compiler Build.
+ *
+#define DefaultCDebugFlags              -xO4 -xtarget=pentium_pro
+#define OptimizedCDebugFlags            -xO4 -xtarget=pentium_pro
+ */
+
+/* 
+ * Debuggable Sun Compiler Build. 
+ * Note: This builds _EVERYTHING_ as debuggable
+ *
+#define DefaultCDebugFlags              -g -xs
+#define OptimizedCDebugFlags            -g -xs
+ */
+
+/*
+ * For Linux, this should match the Binutils version you have.  This example
+ * is for 2.6.0.7.  See linux.cf for the default setting.
+ *
+ * This should automatically get set correctly by imake.
+ *
+#define LinuxBinUtilsMajorVersion	26
+ */
+
+/*
+ * For Linux, these should match the libc version you have.  This example
+ * is for libc.5.4.x.  See linux.cf for the default setting.
+ *
+ * This should automatically get set correctly by imake.
+ *
+#define LinuxCLibMajorVersion	5
+#define LinuxClibMinorVersion	4
+ */
+
+/*
+ * If you want to use the GNU malloc library, uncomment this
+ *
+#define UseGnuMalloc		YES
+ */
+
+/*
+ * Set this to whatever is required to access the GNU malloc library.
+ * The default is '-lgmalloc' unless is specified in the OS's .cf file.
+ *
+#define GnuMallocLibrary	-L/usr/local/lib -lgmalloc
+ */
+
+/*
+ * To enable the internal Xserver malloc, uncomment this
+ *
+#define UseInternalMalloc	YES
+ */
+
+/*
+ * Some Linux releases don't have a libtermcap.  In this case you may need
+ * to uncomment the following
+ *
+#define TermcapLibrary		-lncurses
+ */
+
+/*
+ * Build a server that dynamically loads the modules by setting
+ * this to YES.  This defaults to YES on most platforms.  A static server
+ * can be built by setting this to NO.
+ *
+#define DoLoadableServer	NO
+ */
+
+/*
+ * This release defaults to building dlopen() style modules instead of the 
+ * previously standard loader modules.
+ * 
+ * Uncomment the following to return to the XFree86 custom loader modules.
+ *
+#define MakeDllModules		NO
+ */
+
+/*
+ * Build XAA.  This can be disabled with:
+ *
+#define XF86XAA			NO
+ */
+
+/*
+ * Build vgahw.  This can be disabled with:
+ *
+#define XF86VgaHw		NO
+ */
+
+/*
+ * Build xf1bpp.  This can be disabled with:
+ *
+#define XF1Bpp			NO
+ */
+
+/*
+ * Build xf4bpp.  This can be disabled with:
+ *
+#define XF4Bpp			NO
+ */
+
+
+/*
+ * BSD Console driver support (for FreeBSD and NetBSD).
+ *
+ * By default, support is included for pccons and pcvt for NetBSD, and
+ * pccons, syscons and pcvt for FreeBSD.
+ *
+ * To change the list of supported drivers, set the following parameter.
+ * Possible values are -DPCCONS_SUPPORT, -DSYSCONS_SUPPORT, -DPCVT_SUPPORT.
+ * The following example includes support for syscons and pcvt only.
+ *
+#define XFree86ConsoleDefines	-DSYSCONS_SUPPORT -DPCVT_SUPPORT
+ */
+
+/*
+ * To link the X server with a dynamic version of the Xfont library,
+ * uncomment this.
+ *
+#define XserverStaticFontLib	NO
+ */
+
+/*
+ * To enable binary compatibility with previous versions of the font
+ * encoding support, uncomment this.
+ *
+#define FontencCompatibility    YES
+ */
+
+/*
+ * To disable building XInput support, uncomment this
+ *
+#define BuildXInputExt		NO
+ */
+
+/*
+ * Uncomment this for joystick support.
+ *
+ * Note: Joystick support is broken, so don't enable this.
+ *
+#define JoystickSupport YES
+ */
+
+/*
+ * To disable the ScreenSaver Extension, uncomment this line.
+ *
+#define BuildScreenSaverExt	NO
+ */
+
+/* 
+ * If you don't want to build Xinerama support, uncomment this.
+ *
+#define BuildXinerama		NO
+ */
+
+/*
+ * If you don't want to build support for the GLX extension, uncomment this.
+ *
+#define BuildGlxExt             NO
+ */
+
+/*
+ * If you want to build the xf86rush extension, uncomment this line.
+ * This isn't recommended.
+ *
+#define BuildXF86RushExt	YES
+ */
+
+/*
+ * If you want to build the client library for the xf86rush extension,
+ * uncomment this line.  This isn't recommended.
+ *
+#define BuildXF86RushLibrary	NO
+ */
+
+/*
+ * If you are running NetBSD 0.9C or later, and have the aperture driver
+ * installed, uncomment this.
+ *
+#define HasNetBSDApertureDriver	YES
+ */
+
+/*
+ * If you are running SVR3 and have the mmap driver installed (for linear
+ * framebuffer access) uncomment this.
+ *
+#define HasSVR3mmapDrv	YES
+ */
+
+/*
+ * If you are using an SVR3 (like ISC 4.x) which supports long file names,
+ * you can uncomment this to have manual pages installed under their
+ * full names
+ *
+#define ExpandManNames		YES
+ */
+
+/*
+ * For a POSIXized build on Interactive uncomment this
+ * Could be used with gcc 'till Version 2.6.3
+ * Should be used with gcc 2.7.2. 
+ *
+#define UsePosix		YES
+ */
+
+/*
+ * If you don't want XDMAUTH support (if you don't have Wraphelp.c), 
+ *  comment this out.
+ *
+ */
+#define HasXdmAuth		YES
+
+/*
+ * If you have Linux DECnet support, and want to build XFree86 with support
+ * for connections over DECnet, uncomment this.
+ *
+#define HasDECnet		YES
+ */
+
+/*
+ * To build static and shared libraries with debugging information, uncomment
+ * this. Assumes you have Gcc2.
+ * (If you don't have Gcc2, you can use the DebugLib{X11,Xt,Xaw,...} variables
+ * to build debugging versions of the libraries separately.)
+ *
+#define DebuggableLibraries	YES
+*/
+
+/*
+ * To forceably build static libraries in addition to shared libraries,
+ * uncomment this.
+ *
+#define ForceNormalLib		YES
+ */
+
+/*
+ * Uncomment this if your default tools (eg, gcc, ld, as, etc) are
+ * not the Linux ELF versions.
+ *
+#define LinuxElfDefault		NO
+ */
+
+/*
+ * To use ELF format shared libraries for supported OSs, uncomment this.
+ *
+ * For Linux the default setting of this is the same as the setting of
+ * LinuxElfDefault.
+ *
+ * For FreeBSD this should automatically be set correctly by imake.  Only
+ * change it here if you need to override the automatic setting.
+ *
+#define UseElfFormat		YES
+ */
+
+/*
+ * For FreeBSD/ELF (FreeBSD 3.0) it is possible to also build and install
+ * a.out compatibility libraries.  To enable that, uncomment this.
+ *
+#define BuildAoutLibraries	YES
+ */
+
+/*
+ * If you have trouble with make bombing out in Xlib, try uncommenting this.
+ * You will not get dependencies as a result, but better than nothing.
+ *
+#define MakeHashTableBug        YES
+ */
+
+/*
+ * If you do not want your man pages compress under SVR3 systems that
+ * support it, uncomment this.
+ *
+#define CompressManPages        NO
+ */
+
+/*
+ * If you have sgmlfmt (the XFree86 doctools package) and want to build
+ * formatted docs from the SGML source, uncomment this.
+ *
+#define HasSgmlFmt		YES
+ */
+
+/*
+ * To disable building some document formats, uncomment some of these.
+ *
+#define BuildLinuxDocText	NO
+#define BuildLinuxDocHtml	NO
+#define BuildLinuxDocPS		NO
+ */
+
+/*
+ * To install Japanese versions of the documentation uncomment this.
+ * Note: The Japanese documentation consists of a subset of the
+ * XFree86 3.1 docs.
+ *
+#define InstallJapaneseDocs	YES
+ */
+
+/*
+ * To build/install X specs docs, uncomment the following.
+ * The SpecsDocDirs setting here is recommended because it covers
+ * the docs that XFree86 has changed or added.
+ *
+#define BuildSpecsDocs		YES
+#define SpecsDocDirs		CTEXT GL ICCCM X11 Xext Xmu Xv XvMC i18n
+ */
+
+/*
+ * To build all specs docs, not just those listed in SpecsDocDirs, uncomment
+ * the following.
+ *
+#define BuildAllSpecsDocs	YES
+ */
+
+/*
+ * If your system doesn't support vm86() mode and you have
+ * libx86emu set library path here
+ *
+#define X86EMU_LIBPATH /usr/local/lib
+ */ 
+
+/*
+ * Most platforms default to using an already installed FreeType 2 library.
+ * To use the one included in this release instead, uncomment the following.
+ *
+#define HasFreetype2 NO
+ */
+
+/* 
+ * To use a FreeType library already installed outside the default search
+ * paths, uncomment the following and set the path as needed.
+ *
+#define HasFreetype2 YES
+#define Freetype2Dir /usr/local
+ */
+
+
+/*
+ * Most platforms default to using an already installed Fontconfig library.
+ * To use the one included in this release instead, uncomment the following.
+ *
+#define HasFontconfig NO
+ */
+
+/* 
+ * To use a Fontconfig library already installed outside the default search
+ * paths, uncomment the following and set the path as needed.
+#define HasFontconfig YES
+#define FontconfigDir /usr/local
+ */
+
+
+/*
+ * Most platforms default to using an already installed Expat library.
+ * To use the one included in this release instead, uncomment the following.
+ *
+#define HasExpat NO
+ */
+
+/* 
+ * To use a Expat library already installed outside the default search
+ * paths, uncomment the following and set the path as needed.
+#define HasExpat YES
+#define ExpatDir /usr/local
+ */
+
+
+/*
+ * Most platforms default to using an already installed PNG library.
+ * To use the one included in this release instead, uncomment the following.
+ *
+#define HasLibpng NO
+ */
+
+/* 
+ * To use a PNG library already installed outside the default search
+ * paths, uncomment the following and set the path as needed.
+#define HasLibpng YES
+#define LibpngDir /usr/local
+ */
+
+
+/*
+ * Most platforms default to using an already installed xterm program.
+ * To use the one included in this release instead, uncomment the following.
+ *
+#define BuildXterm YES
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/mapfiles/mapfile_pga_i386	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,41 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)mapfile_pga_i386 1.3     05/11/07 SMI"
+#
+# 4291411: make data sections start on page boundaries to reduce # of pages
+#  needed to map into memory  (fix based on on_28 fix for 4218947)
+data = R0x1000;
+# 4471940: mark stacks as non-executable to help prevent buffer overflows
+# (fix based on on_81 fix for 4396664)
+stack = STACK ?RW;
+# Make data section non-executable for further buffer overflow protection
+data = ?RW;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/mapfiles/mapfile_pga_sparc	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,43 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)mapfile_pga_sparc 1.5     05/11/07 SMI"
+#
+# 4291411: make data sections start on page boundaries to reduce # of pages
+#  needed to map into memory  (fix based on on_28 fix for 4218947)
+data = R0x2000;
+# 4471940: mark stacks as non-executable to help prevent buffer overflows
+# (fix based on on_81 fix for 4396664)
+stack = STACK ?RW;
+# Make bss section non-executable for further buffer overflow protection
+# (can't make whole data section non-exec on SPARC since that includes PLT
+#  which must be executable on SPARC).  
+bss = ?RW;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/sun-manpage-templates/attributes	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,48 @@
+.\" Begin Sun update
+.\" /*
+.\" Copyright 2005 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.
+.\"
+.\" ident "@(#)attributes 1.2     05/11/08 SMI" 
+.\" */
+.\"
+
+.SH ATTRIBUTES
+See
+.BR attributes (5)
+for descriptions of the following attributes:
+.sp
+.TS
+box;
+cbp-1 | cbp-1
+l | l .
+ATTRIBUTE TYPE	ATTRIBUTE VALUE
+=
+Availability 	__package__ 
+Interface Stability 	__stability__ 
+.TE 
+.\" End Sun update
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/config/sun-manpage-templates/table-prepend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,36 @@
+'\" t
+.\" /* 
+.\" This file needs to be prepended to any man page that is having a
+.\" table added, such as via the sun-manpage-templates/attributes file,
+.\" that doesn't already have one, so that man pre-processes it via tbl.
+.\"
+.\" Copyright 2005 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.
+.\"
+.\" ident "@(#)table-prepend 1.2     05/11/08 SMI"
+.\" */
+.\"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/doc/man/Xv/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,41 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/07 SMI"
+XCOMM
+
+#define LibManSuffix 3Xv
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-clientlibs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/fonts/encodings/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,37 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/07 SMI"
+XCOMM
+
+/* Don't compress encodings */
+#define EncObjComp(basename)	EncObj(basename)
+#define CompEncodingTarget(basename)	/* */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/include/extensions/interactive.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,114 @@
+/*
+ * Copyright 1994 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.
+ */
+
+/************************************************************
+	Protocol defs for XIA extension
+********************************************************/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#ifndef _INTERACTIVE_H
+#define _INTERACTIVE_H
+
+#pragma ident	"@(#)interactive.h	35.3	05/08/31 SMI"
+
+#include <X11/Xproto.h>
+
+#include "interactiveCommon.h"
+
+#define X_IAQueryVersion                0
+#define X_IASetProcessInfo              1
+#define X_IAGetProcessInfo              2
+
+#define IANumberEvents                  0
+#define IANumberErrors                  0
+
+typedef int ConnectionPidRec;
+typedef int * ConnectionPidPtr;
+
+#define IANAME "SolarisIA"
+
+#define IA_MAJOR_VERSION	1	/* current version numbers */
+#define IA_MINOR_VERSION	1
+
+typedef struct _IAQueryVersion {
+    CARD8	reqType;		/* always IAReqCode */
+    CARD8	IAReqType;		/* always X_IAQueryVersion */
+    CARD16	length B16;
+} xIAQueryVersionReq;
+#define sz_xIAQueryVersionReq	4
+
+typedef struct {
+    BYTE	type;			/* X_Reply */
+    CARD8	pad;			/* padding */
+    CARD16	sequenceNumber B16;
+    CARD32	length B32;
+    CARD16	majorVersion B16;	/* major version of IA protocol */
+    CARD16	minorVersion B16;	/* minor version of IA protocol */
+    CARD32	pad1 B32;
+    CARD32	pad2 B32;
+    CARD32	pad3 B32;
+    CARD32	pad4 B32;
+    CARD32	pad5 B32;
+} xIAQueryVersionReply;
+#define sz_xIAQueryVersionReply	32
+
+typedef struct _IASetProcessInfo {
+    CARD8	reqType;		/* Always IAReqCode */
+    CARD8	connectionAttrType;	/* What attribute */
+    CARD16	length B16;		/* Request length */
+    CARD32	flags B32;		/* Request flags */
+    CARD32	uid B32;		/* requestor's uid */
+} xIASetProcessInfoReq;
+#define sz_xIASetProcessInfoReq	12	
+
+typedef struct _IAGetProcessInfo {
+    CARD8	reqType;		/* Always IAReqCode */
+    CARD8	connectionAttrType;	/* What attribute */
+    CARD16	length;			/* Request length */
+    CARD32	flags B32;		/* Request flags */
+} xIAGetProcessInfoReq;
+#define sz_xIAGetProcessInfoReq	8
+
+typedef struct {
+    BYTE	type;			/* X_Reply */
+    CARD8	pad;			/* padding */
+    CARD16	sequenceNumber B16;
+    CARD32	length B32;
+    CARD32	count B32;
+    CARD32	pad1 B32;
+    CARD32	pad2 B32;
+    CARD32	pad3 B32;
+    CARD32	pad4 B32;
+    CARD32	pad5 B32;
+} xIAGetProcessInfoReply;
+
+#define sz_xIAGetProcessInfo 32
+
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/include/extensions/interactiveCommon.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright 1994 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.
+ */
+
+#ifndef _INTERACTIVECOMMON_H
+#define _INTERACTIVECOMMON_H
+
+#pragma ident	"@(#)interactiveCommon.h	35.3	05/08/31 SMI"
+
+
+#define INTERACTIVE_INFO		0x1
+#define INTERACTIVE_SETTING		0x2
+
+
+#endif	/* _INTERACTIVECOMMON_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/include/extensions/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+XCOMM #########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM #########################################################################
+XCOMM
+XCOMM ident "@(#)localmacros 1.1     05/11/04 SMI"
+XCOMM
+
+XCOMM Headers for SolarisIA extension
+
+INTERACTIVE_HEADERS=interactive.h interactiveCommon.h 
+
+BuildIncludes($(INTERACTIVE_HEADERS),X11/extensions,../..)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/GL/GL/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,36 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.4     05/11/03 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/X11/LibDirName -R/usr/X11/LibDirName
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/GL/mesa/drivers/osmesa/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/07 SMI"
+XCOMM
+
+/* Large PIC tables needed for SPARC builds */
+#if defined(sparc) || defined(SparcArchitecture)
+# define LargePICTable YES
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/GLw/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,36 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.4     05/11/03 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib $(MOTIFLIB) -L$(USRLIBDIR) -R$(USRLIBDIR) $(GLXLIB)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,254 @@
+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 BuildXtsol
+XTSOLDIR = Xtsol
+#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) $(XTSOLDIR) \
+	     $(XCURSORLIBDIR) $(COMPOSITELIBDIR)
+
+SUBDIRS = $(BERKDIR) xtrans $(LINTSUBDIRS) $(FONTSUBDIR) $(FONTENCSUBDIR) \
+          $(FONTCACHELIBDIR)
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(LINTSUBDIRS))
+MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/X11/spec/X11.spec	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,4295 @@
+#########################################################################
+#
+# Copyright 2005 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.
+#
+#########################################################################
+#
+# ident "@(#)X11.spec 1.9     05/11/08 SMI"
+#
+# lib/X11/spec/X11.spec
+#
+
+Function	XESetBeforeFlush
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XSetAuthorization
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsCIELabColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsCIELuvColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsCIEXYZColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsCIEuvYColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsCIExyYColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsLinearRGBFunctionSet
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsRGBColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsRGBiColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsTekHVCColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Data		XcmsUNDEFINEDColorSpace
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XAllocID
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XAllocIDs
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XAllocTemp
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XAsyncErrorHandler
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDefaultError
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDefaultIOError
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDefaultOpenIM
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDefaultOpenOM
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDefaultWireError
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDeq
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDeqAsyncHandler
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XDisconnectDisplay
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XEatData
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XEnq
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XError
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XErrorFunction
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XEventToWire
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XEventsQueued
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XFlush
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XFreeAtomTable
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XFreeDisplayLock_fn
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XFreeDisplayStructure
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XFreeExtData
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XFreeMutex_fn
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XFreeTemp
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XGetAsyncData
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XGetAsyncReply
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XGetBitsPerPixel
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XGetHostname
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XGetLCValues
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XGetScanlinePad
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XHeadOfDisplayList
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XIOError
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XIOErrorFunction
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XInitDisplayLock_fn
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XInitImageFuncPtrs
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XInitKeysymDB
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XKeyInitialize
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XKeysymToModifiers
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XLockMutex_fn
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XOpenLC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XParseBaseFontNameList
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XProcessWindowAttributes
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XReadEvents
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XRegisterFilterByMask
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XRegisterFilterByType
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XRegisterInternalConnection
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XReverse_Bytes
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XScreenOfWindow
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XSendClientPrefix
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XSetClipRectangles
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XSetImage
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XTranslateKey
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XTranslateKeySym
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XUnknownNativeEvent
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XUnknownWireEvent
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XUnlockMutex_fn
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XUnregisterFilter
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XUnregisterInternalConnection
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XUnresolveColor
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XUpdateAtomCache
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XUpdateGCCache
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XVIDtoVisual
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XWireToEvent
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_Xdebug
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_Xevent_to_mask
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_Xglobal_lock
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XlcCompileResourceList
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XlcGetValues
+Version		SUNWprivate
+Arch		all
+End
+
+Data		_XlcSetValues
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XActivateScreenSaver
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XAddConnectionWatch
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XAddExtension
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XAddHost
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAddHosts
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAddPixel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAddToExtensionList
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XAddToSaveSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllPlanes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocClassHint
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocColorCells
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocColorPlanes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocIconSize
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocNamedColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocSizeHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocStandardColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllocWMHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAllowEvents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAutoRepeatOff
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XAutoRepeatOn
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XBaseFontNameListOfFontSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XBell
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XBitmapBitOrder
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XBitmapPad
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XBitmapUnit
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XBlackPixel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XBlackPixelOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCellsOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangeActivePointerGrab
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangeGC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangeKeyboardControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangeKeyboardMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangePointerControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangeProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangeSaveSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XChangeWindowAttributes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCheckIfEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCheckMaskEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCheckTypedEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCheckTypedWindowEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCheckWindowEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCirculateSubwindows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCirculateSubwindowsDown
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCirculateSubwindowsUp
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XClearArea
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XClearWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XClipBox
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCloseDisplay
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCloseIM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCloseOM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XConfigureWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XConnectionNumber
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XContextDependentDrawing
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XContextualDrawing
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XConvertCase
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XConvertSelection
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCopyArea
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCopyColormapAndFree
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCopyGC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCopyPlane
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateBitmapFromData
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateFontCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateFontSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateGC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateGlyphCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateIC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateImage
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateOC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreatePixmap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreatePixmapCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreatePixmapFromBitmapData
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateSimpleWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XCreateWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultColormapOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultDepth
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultDepthOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultGC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultGCOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultRootWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultScreenOfDisplay
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultVisual
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefaultVisualOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDefineCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDeleteContext
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDeleteModifiermapEntry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDeleteProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDestroyIC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDestroyImage
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDestroyOC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDestroyRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDestroySubwindows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDestroyWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDirectionalDependentDrawing
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XDisableAccessControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayCells
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayHeight
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayHeightMM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayKeycodes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayMotionBufferSize
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayOfIM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayOfOM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayPlanes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayWidth
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDisplayWidthMM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDoesBackingStore
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDoesSaveUnders
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawArc
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawArcs
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawImageString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawImageString16
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawLine
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawLines
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawPoint
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawPoints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawRectangle
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawRectangles
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawSegments
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawString16
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawText
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XDrawText16
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XEHeadOfExtensionList
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetCloseDisplay
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetCopyGC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetCreateFont
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetCreateGC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetError
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetErrorString
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetEventToWire
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetFlushGC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetFreeFont
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetFreeGC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetPrintErrorValues
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetWireToError
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XESetWireToEvent
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XEmptyRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XEnableAccessControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XEqualRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XEventMaskOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XEventsQueued
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XExtendedMaxRequestSize
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XExtentsOfFontSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFetchBuffer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFetchBytes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFetchName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFillArc
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFillArcs
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFillPolygon
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFillRectangle
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFillRectangles
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFilterEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFindContext
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFindOnExtensionList
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XFlush
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFlushGC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFontsOfFontSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XForceScreenSaver
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFree
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeExtensionList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeFont
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeFontInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeFontNames
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeFontPath
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeFontSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeGC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeModifiermap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreePixmap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XFreeStringList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGContextFromGC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetAtomName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetAtomNames
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetClassHint
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetCommand
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetDefault
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetErrorDatabaseText
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetErrorText
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetFontPath
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetFontProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetGCValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetICValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetIMValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetIconName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetIconSizes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetImage
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetInputFocus
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetKeyboardControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetKeyboardMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetModifierMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetMotionEvents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetNormalHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetOCValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetOMValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetPixel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetPointerControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetPointerMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetRGBColormaps
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetScreenSaver
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetSelectionOwner
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetSizeHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetStandardColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetSubImage
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetTextProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetTransientForHint
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetVisualInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMClientMachine
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMColormapWindows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMIconName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMNormalHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMProtocols
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWMSizeHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWindowAttributes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetWindowProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGetZoomHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGrabButton
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGrabKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGrabKeyboard
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGrabPointer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XGrabServer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XHeightMMOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XHeightOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XIMOfIC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XIconifyWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XIfEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XImageByteOrder
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XInitExtension
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XInitImage
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XInitThreads
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XInsertModifiermapEntry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XInstallColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XInternAtom
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XInternAtoms
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XInternalConnectionNumbers
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XIntersectRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XKeycodeToKeysym
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XKeysymToKeycode
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XKeysymToString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XKillClient
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLastKnownRequestProcessed
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListDepths
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListExtensions
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListFonts
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListFontsWithInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListHosts
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListInstalledColormaps
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListPixmapFormats
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XListProperties
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLoadFont
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLoadQueryFont
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLocaleOfFontSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLocaleOfIM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLocaleOfOM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLockDisplay
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XLookupColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLookupKeysym
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLookupString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XLowerWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMapRaised
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMapSubwindows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMapWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMaskEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMatchVisualInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMaxCmapsOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMaxRequestSize
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMinCmapsOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMoveResizeWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XMoveWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XNewModifiermap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XNextEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XNextRequest
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XNoOp
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XOMOfOC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XOffsetRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XOpenDisplay
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XOpenIM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XOpenOM
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XParseColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XParseGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPeekEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPeekIfEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPending
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPlanesOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPointInRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPolygonRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XProcessInternalConnection
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XProtocolRevision
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XProtocolVersion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPutBackEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPutImage
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XPutPixel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQLength
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryBestCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryBestSize
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryBestStipple
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryBestTile
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryExtension
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryFont
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryKeymap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryPointer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryTextExtents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryTextExtents16
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XQueryTree
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRaiseWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XReadBitmapFile
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XReadBitmapFileData
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XRebindKeysym
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRecolorCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XReconfigureWMWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRectInRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRefreshKeyboardMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRegisterIMInstantiateCallback
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRemoveConnectionWatch
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XRemoveFromSaveSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRemoveHost
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRemoveHosts
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XReparentWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XResetScreenSaver
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XResizeWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XResourceManagerString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRestackWindows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRootWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRootWindowOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRotateBuffers
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XRotateWindowProperties
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSaveContext
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XScreenCount
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XScreenNumberOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XScreenOfDisplay
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XScreenResourceString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSelectInput
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSendEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XServerVendor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetAccessControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetAfterFunction
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetArcMode
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetBackground
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetClassHint
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetClipMask
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetClipOrigin
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetClipRectangles
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetCloseDownMode
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetCommand
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetDashes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetErrorHandler
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetFillRule
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetFillStyle
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetFont
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetFontPath
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetForeground
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetFunction
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetGraphicsExposures
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetICFocus
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetICValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetIMValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetIOErrorHandler
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetIconName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetIconSizes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetInputFocus
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetLineAttributes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetLocaleModifiers
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetModifierMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetNormalHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetOCValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetOMValues
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetPlaneMask
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetPointerMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetRGBColormaps
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetScreenSaver
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetSelectionOwner
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetSizeHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetStandardColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetStandardProperties
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetState
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetStipple
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetSubwindowMode
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetTSOrigin
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetTextProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetTile
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetTransientForHint
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMClientMachine
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMColormapWindows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMIconName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMNormalHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMProperties
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMProtocols
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWMSizeHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWindowBackground
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWindowBackgroundPixmap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWindowBorder
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWindowBorderPixmap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWindowBorderWidth
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetWindowColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSetZoomHints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XShrinkRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStoreBuffer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStoreBytes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStoreColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStoreColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStoreName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStoreNamedColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStringListToTextProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XStringToKeysym
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSubImage
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSubtractRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSupportsLocale
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSync
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XSynchronize
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTextExtents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTextExtents16
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTextPropertyToStringList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTextWidth
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTextWidth16
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTranslateCoordinates
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUndefineCursor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUngrabButton
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUngrabKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUngrabKeyboard
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUngrabPointer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUngrabServer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUninstallColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUnionRectWithRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUnionRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUnloadFont
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUnlockDisplay
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XUnmapSubwindows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUnmapWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUnregisterIMInstantiateCallback
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XUnsetICFocus
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XVaCreateNestedList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XVendorRelease
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XVisualIDFromVisual
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWMGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWarpPointer
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWhitePixel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWhitePixelOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWidthMMOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWidthOfScreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWindowEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWithdrawWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XWriteBitmapFile
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XXorRegion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XauDisposeAuth
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XauFileName
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XauGetBestAuthByAddr
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XauReadAuth
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsAddColorSpace
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsAddFunctionSet
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsAllocColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsAllocNamedColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCCCOfColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELabClipL
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELabClipLab
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELabClipab
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELabQueryMaxC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELabQueryMaxL
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELabQueryMaxLC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELabQueryMinL
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELabToCIEXYZ
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELabWhiteShiftColors
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELuvClipL
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELuvClipLuv
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELuvClipuv
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELuvQueryMaxC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELuvQueryMaxL
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELuvQueryMaxLC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELuvQueryMinL
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCIELuvToCIEuvY
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIELuvWhiteShiftColors
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIEXYZToCIELab
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIEXYZToCIEuvY
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIEXYZToCIExyY
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIEXYZToRGBi
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIEuvYToCIELuv
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIEuvYToCIEXYZ
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIEuvYToTekHVC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsCIExyYToCIEXYZ
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsClientWhitePointOfCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsConvertColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsCreateCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsDefaultCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsDisplayOfCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsFormatOfPrefix
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsFreeCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsLookupColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsPrefixOfFormat
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsQueryBlack
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsQueryBlue
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsQueryColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsQueryColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsQueryGreen
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsQueryRed
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsQueryWhite
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsRGBToRGBi
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsRGBiToCIEXYZ
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsRGBiToRGB
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsScreenNumberOfCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsScreenWhitePointOfCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsSetCCCOfColormap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsSetCompressionProc
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsSetWhiteAdjustProc
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsSetWhitePoint
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsStoreColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsStoreColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsTekHVCClipC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsTekHVCClipV
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsTekHVCClipVC
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsTekHVCQueryMaxC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsTekHVCQueryMaxV
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsTekHVCQueryMaxVC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsTekHVCQueryMaxVSamples
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsTekHVCQueryMinV
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XcmsTekHVCToCIEuvY
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsTekHVCWhiteShiftColors
+Version		SUNWprivate
+Arch		all
+End
+
+Function	XcmsVisualOfCCC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddDeviceLedInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomColor
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomDoodad
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomKeyAlias
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomOutline
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomOverlay
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomOverlayKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomOverlayRow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomRow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomSection
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddGeomShape
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAddKeyType
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocClientMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocCompatMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocDeviceInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomDoodads
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomKeyAliases
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomKeys
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomOutlines
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomOverlayKeys
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomOverlayRows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomOverlays
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomPoints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomProps
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomRows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomSectionDoodads
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomSections
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeomShapes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocIndicatorMaps
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocKeyboard
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocNames
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbAllocServerMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbApplyCompatMapToKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbApplyVirtualModChanges
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbBell
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbBellEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbChangeDeviceInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbChangeEnabledControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbChangeKeycodeRange
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbChangeMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbChangeNames
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbChangeTypesOfKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbComputeEffectiveMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbComputeRowBounds
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbComputeSectionBounds
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbComputeShapeBounds
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbComputeShapeTop
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbCopyKeyType
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbCopyKeyTypes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbDeviceBell
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbDeviceBellEvent
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFindOverlayForKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbForceBell
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbForceDeviceBell
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeClientMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeCompatMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeComponentList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeDeviceInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomColors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomDoodads
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomKeyAliases
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomKeys
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomOutlines
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomOverlayKeys
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomOverlayRows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomOverlays
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomPoints
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomProperties
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomRows
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomSections
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeomShapes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeIndicatorMaps
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeKeyboard
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeNames
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbFreeServerMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetAutoRepeatRate
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetAutoResetControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetCompatMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetDetectableAutoRepeat
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetDeviceButtonActions
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetDeviceInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetDeviceInfoChanges
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetDeviceLedInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetIndicatorMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetIndicatorState
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyActions
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyBehaviors
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyExplicitComponents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyModifierMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeySyms
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyTypes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyVirtualModMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyboard
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetKeyboardByName
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetMapChanges
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetNamedDeviceIndicator
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetNamedGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetNamedIndicator
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetNames
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetPerClientControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetState
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetUpdatedMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetVirtualMods
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbGetXlibControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbIgnoreExtension
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbInitCanonicalKeyTypes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbKeyTypesForCoreSymbols
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbKeycodeToKeysym
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbKeysymToModifiers
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbLatchGroup
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbLatchModifiers
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbLibraryVersion
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbListComponents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbLockGroup
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbLockModifiers
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbLookupKeyBinding
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbLookupKeySym
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbNoteControlsChanges
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbNoteDeviceChanges
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbNoteMapChanges
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbNoteNameChanges
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbOpenDisplay
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbQueryExtension
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbRefreshKeyboardMapping
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbResizeDeviceButtonActions
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbResizeKeyActions
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbResizeKeySyms
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbResizeKeyType
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSelectEventDetails
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSelectEvents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetAtomFuncs
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetAutoRepeatRate
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetAutoResetControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetCompatMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetDebuggingFlags
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetDetectableAutoRepeat
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetDeviceButtonActions
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetDeviceInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetDeviceLedInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetGeometry
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetIgnoreLockMods
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetIndicatorMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetMap
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetNamedDeviceIndicator
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetNamedIndicator
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetNames
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetPerClientControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetServerInternalMods
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbSetXlibControls
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbToControl
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbTranslateKey
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbTranslateKeyCode
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbTranslateKeySym
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbUpdateActionVirtualMods
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbUpdateKeyTypeVirtualMods
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbUpdateMapFromCore
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbUseExtension
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbVirtualModsToReal
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XkbXlibControlsImplemented
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbDrawImageString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbDrawString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbDrawText
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbLookupString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbResetIC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbSetWMProperties
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbTextEscapement
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbTextExtents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbTextListToTextProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbTextPerCharExtents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XmbTextPropertyToTextList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	_XSetLastRequestRead
+Version		SUNWprivate
+Arch		all
+End
+
+Function	Xpermalloc
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmCombineDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmCombineFileDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmDestroyDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmEnumerateDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmGetDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmGetFileDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmGetResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmGetStringDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmInitialize
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmLocaleOfDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmMergeDatabases
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmParseCommand
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmPermStringToQuark
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmPutFileDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmPutLineResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmPutResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmPutStringResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmQGetResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmQGetSearchList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmQGetSearchResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmQPutResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmQPutStringResource
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmQuarkToString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmSetDatabase
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmStringToBindingQuarkList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmStringToQuark
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmStringToQuarkList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XrmUniqueQuark
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcDrawImageString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcDrawString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcDrawText
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcFreeStringList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcLookupString
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcResetIC
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcTextEscapement
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcTextExtents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcTextListToTextProperty
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcTextPerCharExtents
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XwcTextPropertyToTextList
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	_XAllocScratch
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XFlushGCCache
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XRead
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XReadPad
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XReply
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XSend
+Version		SUNWprivate
+Arch		all
+End
+
+Function	_XData32
+Version		SUNWprivate
+Arch		sparcv9 amd64
+End
+
+Function	_XRead32
+Version		SUNWprivate
+Arch		sparcv9 amd64
+End
+
+Function	_XkbReadBufferCopy32
+Version		SUNWprivate
+Arch		sparcv9 amd64
+End
+
+Function	_XkbReadCopyData32
+Version		SUNWprivate
+Arch		sparcv9 amd64
+End
+
+Function	_XkbWriteCopyData32
+Version		SUNWprivate
+Arch		sparcv9 amd64
+End
+
+Function	Xutf8TextPropertyToTextList
+Version		SUNWprivate
+Arch		all
+End
+
+Function	Xutf8LookupString
+Version		SUNWprivate
+Arch		all
+End
+
+Function	Xutf8TextListToTextProperty
+Version		SUNWprivate
+Arch		all
+End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/X11/spec/versions	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,52 @@
+#########################################################################
+#
+# Copyright 2005 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.
+#
+#########################################################################
+#
+# ident "@(#)versions 1.3     05/11/08 SMI"
+#
+#lib/X11/spec/versions
+#
+
+amd64 {
+	SUNW_1.1;
+	SUNWprivate;
+}
+i386 {
+	SUNW_1.1;
+	SUNWprivate;
+}
+sparc {
+	SUNW_1.1;
+	SUNWprivate;
+}
+sparcv9 {
+	SUNW_1.1;
+	SUNWprivate;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xaw/Text.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,4168 @@
+/* $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 
+	/* Do not support XA_UTF8_STRING */
+	/*
+	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;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xaw/TextAction.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,4432 @@
+/* $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 
+	/* Do not support XA_UTF8_STRING */
+	/*
+	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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xaw/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,37 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+XCOMM  Link with native libraries	
+#define LdPreLib /**/
+#define ExtraLdPreLib /**/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xevie/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/03 SMI"
+XCOMM
+
+#define LibManSuffix    3Xevie 
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxwplt -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xfixes/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,38 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxwplt -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xft/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,38 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/03 SMI"
+XCOMM
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxwxft -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xrandr/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,43 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.7     05/11/03 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/openwin/sfw/LibDirName -R/usr/openwin/sfw/LibDirName
+
+#define LibManSuffix    3Xrandr
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-clientlibs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xtsol/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,68 @@
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM 
+XCOMM ########################################################################
+XCOMM @(#)Imakefile	1.6 03/07/06 SMI
+
+#define DoSharedLib HasSharedLibraries
+#define DoExtraLib DoSharedLib
+#define LibName Xtsol
+#define SoRev	SOXTSOLREV
+#define SharedXtsolRev 1
+#define LibHeaders NO
+
+    HEADERSPublic = Xtsol.h Xtsolproto.h 
+
+SharedLibReferences(EXTENSION,Xtsol,$(LIBSRC)/Xtsol,SOXTSOLREV,SharedXtsolRev)
+
+#include <Threads.tmpl>
+
+INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I. -I$(TOP)/onproto/usr/include
+
+SRCS = Xtsol.c
+
+OBJS = Xtsol.o
+
+LINTLIBS = $(LINTXLIB)
+
+SPECFILES = spec/Xtsol.spec
+
+#include <Library.tmpl>
+
+all::
+
+.NO_PARALLEL:
+
+DependTarget()
+
+BuildIncludes($(HEADERSPublic),X11/extensions,../..)
+BuildIncludes($(HEADERSPublic),tsol,..)
+InstallMultipleFlags($(HEADERSPublic),$(INCDIR)/X11/extensions,$(INSTINCFLAGS))
+InstallMultipleFlags($(HEADERSPublic),$(INCDIR)/tsol,$(INSTINCFLAGS))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xtsol/Xtsol.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,770 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)Xtsol.c 1.6     06/03/07 SMI"
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <tsol/label.h>
+#include <sys/tsol/label_macro.h>
+
+#include <X11/Xlibint.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "Xext.h"
+#include "extutil.h"
+
+#define _XTSOL_SERVER
+
+#include "Xtsolproto.h"
+#include "Xtsol.h"
+
+#define SL_SIZE (sizeof (blevel_t))
+
+
+/*
+ * Initialiazation routine
+ */
+static int TsolInitialized = False;
+static int X_TsolExtensionCode;
+
+#define TsolCheckExtension(dpy)\
+    {\
+        if (!TsolInitialized)\
+            if (InitializeTsol(dpy) == 0)\
+            {\
+                return 0;\
+            }\
+    }
+
+static int
+InitializeTsol(dpy)
+    register Display *dpy;
+{
+    int tmp;
+    int event;
+
+    if (XQueryExtension(dpy, TSOLNAME, &X_TsolExtensionCode, &event, &tmp))
+    {
+        TsolInitialized = True;
+	return 1;
+    }
+    else 
+    {
+        TsolInitialized = False;
+        return 0; /* Failure */
+    }
+}
+
+/*
+ * returns true if win is trusted path
+ */
+Bool
+XTSOLIsWindowTrusted(dpy, win)
+    Display *dpy;
+    Window win;
+{
+    XTsolClientAttributes    clientattr;
+    Status result;
+    extern Status XTSOLgetClientAttributes(Display *, XID, XTsolClientAttributes *);
+
+    TsolCheckExtension(dpy);
+
+    result = XTSOLgetClientAttributes(dpy, win, &clientattr);
+
+    return (result ? clientattr.trustflag : False);
+}
+
+Status
+XTSOLsetPolyInstInfo(dpy, sl, uidp, enabled)
+    register Display *dpy;
+    m_label_t *sl;
+    uid_t *uidp;
+    int enabled;
+{
+    register xSetPolyInstInfoReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetPolyInstInfo, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetPolyInstInfo;
+    req->uid = (CARD32 )*uidp;
+    req->enabled = (CARD32 )enabled;
+    req->sllength = (CARD16 )SL_SIZE;
+    req->length = (CARD16 ) (4 + ((int)(req->sllength) / 4));
+    Data(dpy, (char *)sl, SL_SIZE);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+}
+
+Status
+XTSOLsetPropLabel(dpy, win, property, sl)
+    register Display *dpy;
+    register Window win;
+    Atom property;
+    m_label_t *sl;
+{
+    register xSetPropLabelReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetPropLabel, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetPropLabel;
+    req->id = win;
+    req->atom = property;
+    req->labelType = (CARD16) RES_SL;
+    req->sllength = SL_SIZE;
+    req->illength = 0;
+    req->length = 5 + (int)(req->sllength / 4);
+    Data(dpy, (char *)sl, SL_SIZE);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+}
+
+Status
+XTSOLsetPropUID(dpy, win, property, uidp)
+    register Display *dpy;
+    register Window win;
+    Atom property;
+    uid_t *uidp;
+{
+    register xSetPropUIDReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetPropUID, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetPropUID;
+    req->length = 4;
+    req->id = win;
+    req->atom = property;
+    req->uid = *uidp;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+}
+
+Status
+XTSOLsetResLabel(dpy, object, resourceFlag, sl)
+    register Display *dpy;
+    register XID object;
+    ResourceType resourceFlag;
+    m_label_t *sl;
+{
+    register xSetResLabelReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetResLabel, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetResLabel;
+    req->id = object;
+    req->resourceType = (CARD16) resourceFlag;
+    req->labelType = (CARD16) RES_SL;
+    req->sllength = SL_SIZE;
+    req->illength = 0;
+    req->length = 4 + (int)(req->sllength / 4);
+    Data(dpy, (char *)sl, SL_SIZE);
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+}
+
+Status
+XTSOLsetResUID(dpy, object, resourceFlag, uidp)
+    register Display *dpy;
+    register XID object;
+    ResourceType resourceFlag;
+    uid_t *uidp;
+{
+    register xSetResUIDReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetResUID, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetResUID;
+    req->length = 4;
+    req->id = object;
+    req->resourceType = (CARD16) resourceFlag;
+    req->uid = *uidp;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+}
+
+Status
+XTSOLsetSSHeight(dpy, screen_num, newHeight)
+    Display *dpy;
+    int screen_num;
+    int newHeight;
+{
+    register xSetResUIDReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetResUID, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetResUID;
+    req->length = 4;
+    req->id = screen_num;
+    req->resourceType = STRIPEHEIGHT;
+    req->uid = newHeight;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+}
+
+Status
+XTSOLsetSessionHI(dpy, sl)
+    Display *dpy;
+    bclear_t *sl;
+{
+    register xSetResLabelReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetResLabel, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetResLabel;
+    req->id = 0;
+    req->resourceType = SESSIONHI;
+    req->labelType = RES_SL;
+    req->sllength = SL_SIZE;
+    req->illength = 0;
+    req->length = 4 + (int)(req->sllength / 4);
+    Data(dpy, (char *)sl, SL_SIZE);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+
+}
+
+Status
+XTSOLsetSessionLO(dpy, sl)
+    Display *dpy;
+    m_label_t *sl;
+{
+    register xSetResLabelReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetResLabel, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetResLabel;
+    req->id = 0;
+    req->resourceType = SESSIONLO;
+    req->labelType = RES_SL;
+    req->sllength = SL_SIZE;
+    req->illength = 0;
+    req->length = 4 + (int)(req->sllength / 4);
+    Data(dpy, (char *)sl, SL_SIZE);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+
+}
+
+Status
+XTSOLsetWorkstationOwner(dpy, uidp)
+    Display *dpy;
+    uid_t *uidp;
+{    
+    register xSetResUIDReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(SetResUID, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_SetResUID;
+    req->length = 4;
+    req->id = 0;
+    req->resourceType = RES_OUID;
+    req->uid = *uidp;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+}
+
+/*
+ * make the window a trusted path window
+ */
+Status
+XTSOLMakeTPWindow(dpy, win) 
+    Display *dpy;
+    Window win;
+{
+    register xMakeTPWindowReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(MakeTPWindow, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_MakeTPWindow;
+    req->id = win;
+    req->length = 2;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+
+}
+
+/*
+ * Turn on the trusted bit of window
+ */
+Status
+XTSOLMakeTrustedWindow(dpy, win) 
+    Display *dpy;
+    Window win;
+{
+    register xMakeTrustedWindowReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(MakeTrustedWindow, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_MakeTrustedWindow;
+    req->id = win;
+    req->length = 2;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+
+}
+
+/*
+ * Turn off the  trusted bit of window
+ */
+Status
+XTSOLMakeUntrustedWindow(dpy, win) 
+    Display *dpy;
+    Window win;
+{
+    register xMakeUntrustedWindowReq *req;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(MakeUntrustedWindow, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_MakeUntrustedWindow;
+    req->id = win;
+    req->length = 2;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return 1;
+
+}
+
+/*
+ * get resource attributes. 
+ */
+Status
+XTSOLgetClientAttributes(dpy, xid, clientattr)
+    register Display *dpy;
+    XID xid;    /* window id of client */
+    XTsolClientAttributes    *clientattr;
+{
+    register xGetClientAttributesReq *req;
+    xGetClientAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetClientAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetClientAttributes;
+    req->length = 2;
+    req->id = xid;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xTrue); 
+    if (status)
+    {
+        /* copy the data to user struct */
+        if (rep.trustflag == (BYTE)1)
+            clientattr->trustflag = 1;
+        else
+            clientattr->trustflag = 0;
+        clientattr->uid = (uid_t) rep.uid;
+        clientattr->gid = (gid_t) rep.gid;
+        clientattr->pid = (pid_t) rep.pid;
+        clientattr->auditid = (au_id_t) rep.auditid;
+        clientattr->sessionid = (u_long) rep.sessionid;
+        clientattr->iaddr = (u_long) rep.iaddr;
+    }
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
+
+Status
+XTSOLgetClientLabel(dpy, object, sl)
+    register Display *dpy;
+    register XID object;
+    m_label_t *sl;
+{
+    register xGetClientLabelReq *req;
+    xGenericReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetClientLabel, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetClientLabel;
+    req->length = 3;
+    req->id = object;
+    req->mask = RES_LABEL;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xFalse);
+    if (status)
+    {
+        if ((int)(rep.data00+rep.data01) > 0)
+        {
+            _XRead (dpy, (char *) sl, rep.data00);
+        }
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
+
+Status
+XTSOLgetPropAttributes(dpy, window, property, propattrp)
+    register Display *dpy;
+    Window window;
+    Atom property;
+    XTsolPropAttributes *propattrp;
+{
+    register xGetPropAttributesReq *req;
+    xGetPropAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetPropAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetPropAttributes;
+    req->length = 4;
+    req->id = window;
+    req->atom = property;
+    req->mask = RES_ALL;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xFalse); 
+    if (status)
+    {
+        /* copy the data to user struct */
+        propattrp->uid = rep.uid;
+        /* read the label info */
+        if (rep.sllength > 0)
+            _XRead (dpy, (char *) (propattrp->sl), rep.sllength);
+    }
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
+
+Status
+XTSOLgetPropLabel(dpy, win, property, sl)
+    register Display *dpy;
+    register Window win;
+    Atom property;
+    m_label_t *sl;
+{
+    register xGetPropAttributesReq *req;
+    xGetPropAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetPropAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetPropAttributes;
+    req->length = 4;
+    req->id = win;
+    req->atom = property;
+    req->mask = RES_LABEL;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xFalse); 
+    if (status)
+    {
+        /* copy the data to user struct */
+        /* read the label info */
+        if ((int)(rep.sllength) > 0)
+            _XRead (dpy, (char *) sl, rep.sllength);
+    }
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+    
+}
+
+Status
+XTSOLgetPropUID(dpy, win, property, uidp)
+    register Display *dpy;
+    register Window win;
+    Atom property;
+    uid_t *uidp;
+{
+    register xGetPropAttributesReq *req;
+    xGetPropAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetPropAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetPropAttributes;
+    req->length = 4;
+    req->id = win;
+    req->atom = property;
+    req->mask = RES_UID;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xTrue); 
+    if (status)
+    {
+        /* copy the data to user struct */
+        *uidp = rep.uid;
+    }
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
+
+Status
+XTSOLgetResAttributes(dpy, object, resourceFlag, resattrp)
+    register Display *dpy;
+    register XID object;
+    ResourceType resourceFlag;
+    XTsolResAttributes *resattrp;
+{
+    register xGetResAttributesReq *req;
+    xGetResAttributesReply rep;
+    Status status;
+    
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetResAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetResAttributes;
+    req->length = 3;
+    req->id = object;
+    req->resourceType = (CARD16) resourceFlag;
+    req->mask = RES_ALL;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xFalse);
+    if (status)
+    {
+        /* copy the data to user struct */
+        resattrp->uid = rep.uid;
+        resattrp->ouid = rep.owneruid;
+        /* read the label info */
+        if (rep.sllength > 0)
+            _XRead (dpy, (char *) (resattrp->sl), rep.sllength);
+    }
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
+
+/*
+ * get resource label. 
+ */
+Status
+XTSOLgetResLabel(dpy, object, resourceFlag, sl)
+    register Display *dpy;
+    register XID object;
+    ResourceType resourceFlag;
+    m_label_t *sl;
+{
+    register xGetResAttributesReq *req;
+    xGetResAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetResAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetResAttributes;
+    req->length = 3;
+    req->id = object;
+    req->resourceType = (CARD16) resourceFlag;
+    req->mask = RES_LABEL;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xFalse); 
+    if (status)
+    {
+        if ((int)(rep.sllength) > 0) 
+        {
+            _XRead (dpy, (char *) sl, rep.sllength);
+        }
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
+
+Status
+XTSOLgetResUID(dpy, object, resourceFlag, uidp)
+    register Display *dpy;
+    register XID object;
+    ResourceType resourceFlag;
+    uid_t *uidp;
+{
+    register xGetResAttributesReq *req;
+    xGetResAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetResAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetResAttributes;
+    req->length = 3;
+    req->id = object;
+    req->resourceType = (CARD16) resourceFlag;
+    req->mask = RES_UID;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xTrue); 
+    if (status)
+    {
+        /* copy the data to user struct */
+        *uidp = rep.uid;
+    }
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
+
+Status
+XTSOLgetSSHeight(dpy, screen_num, newHeight)
+    Display *dpy;
+    int screen_num;
+    int *newHeight;
+{
+    register xGetResAttributesReq *req;
+    xGetResAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetResAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetResAttributes;
+    req->length = 3;
+    req->id = screen_num;
+    req->resourceType = STRIPEHEIGHT;
+    req->mask = RES_STRIPE;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xTrue);
+    if (status)
+    {
+        /* copy the data to user struct */
+        *newHeight = rep.uid;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+
+}
+
+Status 
+XTSOLgetWorkstationOwner(dpy, uidp)
+    Display *dpy;
+    uid_t *uidp;
+{
+    register xGetResAttributesReq *req;
+    xGetResAttributesReply rep;
+    Status status;
+
+    TsolCheckExtension(dpy);
+    LockDisplay(dpy);
+    GetReq(GetResAttributes, req);
+
+    req->reqType = (CARD8) X_TsolExtensionCode;
+    req->minorCode = X_GetResAttributes;
+    req->length = 3;
+    req->mask = RES_OUID;
+
+    status = _XReply (dpy, (xReply *)&rep, 0, xTrue); 
+    if (status)
+    {
+        /* copy the data to user struct */
+        *uidp = rep.owneruid;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return status;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xtsol/Xtsol.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,292 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)Xtsol.h 1.6     06/03/07 SMI"
+
+#ifndef _XTSOL_H_
+#define _XTSOL_H_
+
+#include <sys/types.h>
+#include <bsm/audit.h>
+#include <X11/Xmd.h>
+#include <tsol/label.h>
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+typedef enum { IsWindow, IsPixmap, IsColormap } ResourceType;
+
+/*
+ * Name of the Trusted Solaris extension
+ */
+#define TSOLNAME "SUN_TSOL"
+
+/* 
+ * Resource value masks
+ * The following resource masks are obsolete:
+ * RES_IL        2      # information label
+ * RES_IIL       4      # input info  label
+ */
+
+#define RES_SL        1      /* sensitivity label */
+#define RES_UID       8      /* user id     */
+#define RES_OUID     16      /* owner uid */
+#define RES_STRIPE   32      /* screen stripe */
+#define RES_LABEL    (RES_SL)
+#define RES_ALL      (RES_SL|RES_UID|RES_OUID)
+
+
+typedef struct _XTsolResAttributes {
+    CARD32     ouid;         /* owner uid */
+    CARD32     uid;
+    m_label_t  *sl;           /* sensitivity label */
+} XTsolResAttributes;
+
+typedef struct _XTsolPropAttributes {
+    CARD32     uid;
+    m_label_t  *sl;           /* sensitivity label */
+} XTsolPropAttributes;
+
+/*
+ * Client Attributes
+ */
+typedef struct _XTsolClientAttributes {
+    int      trustflag;      /* true, if client masked as trusted */
+    uid_t    uid;            /* owner uid */
+    gid_t    gid;            /* group id */
+    pid_t    pid;            /* process id */
+    u_long   sessionid;      /* session id */
+    au_id_t  auditid;        /* audit id */
+    u_long   iaddr;          /* internet addr */
+} XTsolClientAttributes;
+
+/*
+ * Trusted X Server Interfaces
+ * Status value 0 means failure, else success
+ * Status is defined in Xlib.h for user includes.
+ */
+
+#ifndef Status
+#define Status int
+#endif
+
+#ifndef _XTSOL_SERVER
+
+extern Bool XTSOLIsWindowTrusted(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win
+#endif
+);
+
+extern Status XTSOLsetPolyInstInfo(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    m_label_t *sl,
+    uid_t *uidp,
+    int enabled
+#endif
+);
+
+extern Status XTSOLsetPropLabel(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win,
+    Atom property,
+    m_label_t *sl
+#endif
+);
+
+extern Status XTSOLsetPropUID(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win,
+    Atom property,
+    uid_t *uidp
+#endif
+);
+
+extern Status XTSOLsetResLabel(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    XID object,
+    ResourceType resourceFlag,
+    m_label_t *sl
+#endif
+);
+
+extern Status XTSOLsetResUID(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    XID object,
+    ResourceType resourceFlag,
+    uid_t *uidp
+#endif
+);
+
+extern Status XTSOLsetSSHeight(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    int screen_num,
+    int newHeight
+#endif
+);
+
+extern Status XTSOLgetSSHeight(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    int screen_num,
+    int *newHeight
+#endif
+);
+
+extern Status XTSOLsetSessionHI(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    bclear_t *sl
+#endif
+);
+
+extern Status XTSOLsetSessionLO(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    m_label_t *sl
+#endif
+);
+
+extern Status XTSOLsetWorkstationOwner(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    uid_t *uidp
+#endif
+);
+
+extern Status XTSOLgetClientAttributes(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    XID xid,
+    XTsolClientAttributes *clientattr
+#endif
+);
+
+extern Status XTSOLgetClientLabel(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    XID xid,
+    m_label_t *sl
+#endif
+);
+
+extern Status XTSOLgetPropAttributes(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window window,
+    Atom property,
+    XTsolPropAttributes *propattrp
+#endif
+);
+
+extern Status XTSOLgetPropLabel(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win,
+    Atom property,
+    m_label_t *sl
+#endif
+);
+
+extern Status XTSOLgetPropUID(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win,
+    Atom property,
+    uid_t *uidp
+#endif
+);
+
+extern Status XTSOLgetResAttributes(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    XID object,
+    ResourceType resourceFlag,
+    XTsolResAttributes *resattrp
+#endif
+);
+
+extern Status XTSOLgetResLabel(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    XID object,
+    ResourceType resourceFlag,
+    m_label_t *sl
+#endif
+);
+
+extern Status XTSOLgetResUID(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    XID object,
+    ResourceType resourceFlag,
+    uid_t *uidp
+#endif
+);
+
+extern Status XTSOLgetWorkstationOwner(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    uid_t *uidp
+#endif
+);
+
+extern Status XTSOLMakeTPWindow(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win
+#endif
+);
+
+extern Status XTSOLMakeTrustedWindow(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win
+#endif
+);
+
+extern Status XTSOLMakeUntrustedWindow(
+#if NeedFunctionPrototypes
+    Display *dpy,
+    Window win
+#endif
+);
+
+#endif /* _XTSOL_SERVER */
+
+_XFUNCPROTOEND
+
+#endif /* _XTSOL_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xtsol/Xtsolproto.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,242 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)Xtsolproto.h 1.5     06/03/07 SMI"
+
+/*
+ * X Server Trusted Extensions
+ */
+
+#ifndef _XTSOLPROTO_H
+#define _XTSOLPROTO_H
+
+#define TSOL_NUM_EVENTS		0	/* New events defined by this extension */
+#define TSOL_NUM_ERRORS		0	/* New errors defined by this extension */
+
+/* extension request minor codes */
+#define X_SetClearance            2
+#define X_SetPolyInstInfo         3
+#define X_SetPropLabel            4
+#define X_SetPropUID              5
+#define X_SetResLabel             6    
+#define X_SetResUID               7
+#define X_SetTrusted              8
+#define X_GetClientAttributes     9
+#define X_GetClientLabel         10
+#define X_GetPropAttributes      11
+#define X_GetResAttributes       12
+#define X_MakeTPWindow           13
+#define X_MakeTrustedWindow      14
+#define X_MakeUntrustedWindow    15
+#define X_TSOLIntern             16
+
+/* extension request sizes */
+#define sz_xSetClearanceReq           0
+#define sz_xSetPolyInstInfoReq       16
+#define sz_xSetPropLabelReq          20
+#define sz_xSetPropUIDReq            16
+#define sz_xSetResLabelReq           16
+#define sz_xSetResUIDReq             16
+#define sz_xSetTrustedReq             0
+#define sz_xGetClientAttributesReq    8
+#define sz_xGetClientLabelReq        12
+#define sz_xGetPropAttributesReq     16
+#define sz_xGetResAttributesReq      12
+#define sz_xMakeTPWindowReq           8
+#define sz_xMakeTrustedWindowReq      8
+#define sz_xMakeUntrustedWindowReq    8
+#define sz_xTSOLInternReq             0
+
+
+/* extension reply sizes */
+#define sz_xGetClientAttributesReply  32
+#define sz_xGetPropAttributesReply    32
+#define sz_xGetResAttributesReply     32
+#define sz_xTSOLInternReply            0
+
+
+/* extension request encoding format */
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 3                  */
+    CARD16 length                B16;    /* = 18; packet size=72 */
+    CARD32 uid                   B32;    /* user id              */
+    CARD32 enabled               B32;    /* enable matching      */
+    CARD16 sllength              B16;    /* length of SL         */
+    CARD16 pad1                  B16;    /* padding              */
+} xSetPolyInstInfoReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 4                  */
+    CARD16 length                B16;    /* = 18; packet size=72 */
+    CARD32 id                    B32;    /* resource ID          */
+    CARD32 atom                  B32;    /* atom ID              */
+    CARD16 labelType             B16;
+    CARD16 pad1                  B16;
+    CARD16 sllength              B16;    /* length of SL         */
+    CARD16 illength              B16;    /* length of IL         */
+} xSetPropLabelReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 5                  */
+    CARD16 length                B16;    /* = 4; packet size= 16 */
+    CARD32 id                    B32;    /* resource ID          */
+    CARD32 atom                  B32;    /* atom  ID             */
+    CARD32 uid                   B16;    /* UID                  */
+} xSetPropUIDReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 6                  */
+    CARD16 length                B16;    /* = 17; packet size=68 */
+    CARD32 id                    B32;    /* resource ID          */
+    CARD16 resourceType          B16;    /* 0:window, 1:pixmap   */
+    CARD16 labelType             B16;    /*                      */
+    CARD16 sllength              B16;    /* length of SL         */
+    CARD16 illength              B16;    /* length of IL or IIL  */
+} xSetResLabelReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 7                  */
+    CARD16 length                B16;    /* = 4; packet size= 16 */
+    CARD32 id                    B32;    /* resource ID          */
+    CARD16 resourceType          B16;    /* 0:window, 1:pixmap   */
+    CARD16 pad1                  B16;    /* not used             */
+    CARD32 uid                   B16;
+} xSetResUIDReq;
+
+typedef struct {
+    CARD8  reqType;                      /* Extension major code */
+    BYTE   minorCode;                    /* = 9                  */
+    CARD16 length                B16;    /* = 4; packet size=16  */
+    CARD32 id                    B32;    /* Client ID            */
+} xGetClientAttributesReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 10                 */
+    CARD16 length                B16;    /* = 4; packet size= 16 */
+    CARD32 id                    B32;    /* client ID            */
+    CARD16 mask                  B16;
+    CARD16 pad;
+} xGetClientLabelReq;
+
+typedef struct {
+    CARD8  reqType;                      /* Extension major code */
+    BYTE   minorCode;                    /* = 11                 */
+    CARD16 length                B16;    /* = 4; packet size=16  */
+    CARD32 id                    B32;    /* resource ID          */
+    CARD32 atom                  B32;    /* resource ID          */
+    CARD16 mask                  B16;
+    CARD16 pad                   B16;    /* not used             */
+} xGetPropAttributesReq;
+
+typedef struct {
+    CARD8  reqType;                      /* Extension major code */
+    BYTE   minorCode;                    /* = 12                 */
+    CARD16 length                B16;    /* = 3; packet size=12  */
+    CARD32 id                    B32;    /* resource ID          */
+    CARD16 resourceType          B16;    /* 0:window; 1:pixmap   */
+    CARD16 mask                  B16;
+} xGetResAttributesReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 13                 */
+    CARD16 length                B16;    /* = 4; packet size= 16 */
+    CARD32 id                    B32;    /* resource ID          */
+} xMakeTPWindowReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 14                 */
+    CARD16 length                B16;    /* = 4; packet size= 16 */
+    CARD32 id                    B32;    /* resource ID          */
+} xMakeTrustedWindowReq;
+
+typedef struct {
+    CARD8  reqType;                      /* extension major code */
+    BYTE   minorCode;                    /* = 15                 */
+    CARD16 length                B16;    /* = 4; packet size= 16 */
+    CARD32 id                    B32;    /* resource ID          */
+} xMakeUntrustedWindowReq;
+ 
+/* extension reply encoding format */
+typedef struct {
+    BYTE   type;                         /* = X_Reply            */
+    BYTE   trustflag;                    /* set if client masked as trusted */
+    CARD16 sequenceNumber        B16;
+    CARD32 length                B32;    /* = 4;                 */
+    CARD32 uid                   B32;
+    CARD32 pid                   B32;
+    CARD32 gid                   B32;
+    CARD32 auditid               B32;
+    CARD32 sessionid             B32;
+    CARD32 iaddr;                        /* internet address    */
+} xGetClientAttributesReply;
+
+typedef struct {
+    BYTE   type;                         /* = X_Reply            */
+    BYTE   pad1;                         /* not used             */
+    CARD16 sequenceNumber        B16;
+    CARD32 length                B32;    /* = 4;                 */
+    CARD32 uid                   B32;
+    CARD16 sllength              B16;
+    CARD16 illength              B16;
+    CARD32 pad2                  B32;
+    CARD32 pad3                  B32;
+    CARD32 pad4                  B32;
+    CARD32 pad5                  B32;
+} xGetPropAttributesReply;
+
+typedef struct {
+    BYTE   type;                         /* = X_Reply            */
+    BYTE   pad1;                         /* not used             */
+    CARD16 sequenceNumber        B16;
+    CARD32 length                B32;    /* = 4;                 */
+    CARD32 uid                   B32;
+    CARD32 owneruid              B32;
+    CARD16 sllength              B16;
+    CARD16 illength              B16;
+    CARD16 iillength             B16;
+    CARD16 pad2                  B16;
+    CARD32 pad3                  B32;
+    CARD32 pad4                  B32;
+} xGetResAttributesReply;
+
+
+#define DOOWNERUID       1000
+#define SESSIONHI        1010
+#define SESSIONLO        1020
+#define STRIPEHEIGHT     1030
+#define INPUTIL          1040
+
+#endif /* _XTSOLPROTO_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xtsol/spec/Xtsol.spec	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,145 @@
+#
+# Copyright 2006 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.
+# 
+
+# ident   "@(#)Xtsol.spec 1.4     06/03/07 SMI"
+
+Function	XTSOLIsWindowTrusted
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetPolyInstInfo
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetPropLabel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetPropUID
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetResLabel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetResUID
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetSSHeight
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetSSHeight
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetSessionHI
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetSessionLO
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLsetWorkstationOwner
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetClientAttributes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetClientLabel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetPropAttributes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetPropLabel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetPropUID
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetResAttributes
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetResLabel
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetResUID
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLgetWorkstationOwner
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLMakeTPWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLMakeTrustedWindow
+Version		SUNW_1.1
+Arch		all
+End
+
+Function	XTSOLMakeUntrustedWindow
+Version		SUNW_1.1
+Arch		all
+End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xtsol/spec/versions	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,45 @@
+#
+# Copyright 2006 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.
+# 
+#
+
+# ident   "@(#)versions 1.2     06/03/07 SMI"
+#
+
+i386 {
+	SUNW_1.1;
+	SUNWprivate;
+}
+sparc {
+	SUNW_1.1;
+	SUNWprivate;
+}
+sparcv9 {
+	SUNW_1.1;
+	SUNWprivate;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xv/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,36 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.6     05/11/02 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib /**/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/XvMC/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,36 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.6     05/11/02 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib /**/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xxf86misc/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,44 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib /**/
+#define ExtraLdPreLib /**/
+
+#define LibManSuffix	3Xxf86misc
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-clientlibs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/Xxf86vm/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,43 @@
+XCOMM ##########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ##########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.6     05/11/02 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib /**/
+
+#define LibManSuffix    3Xxf86vm
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-clientlibs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/font/Type1/fontfcn.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,762 @@
+/* $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.               */
+/***================================================================***/
+#define HNUM 27
+
+char *hebrew[][2] = {
+        {"afii57664", "alef"},
+        {"afii57665", "bet"},
+        {"afii57666", "gimel"},
+        {"afii57667", "dalet"},
+        {"afii57668", "he"},
+        {"afii57669", "vav"},
+        {"afii57670", "zayin"},
+        {"afii57671", "het"},
+        {"afii57672", "tet"},
+        {"afii57673", "yod"},
+        {"afii57674", "kaffinal"},
+        {"afii57675", "kaf"},
+        {"afii57676", "lamed"},
+        {"afii57677", "memfinal"},
+        {"afii57678", "mem"},
+        {"afii57679", "nunfinal"},
+        {"afii57680", "nun"},
+        {"afii57681", "samekh"},
+        {"afii57682", "ayin"},
+        {"afii57683", "pefinal"},
+        {"afii57684", "pe"},
+        {"afii57685", "tsadifinal"},
+        {"afii57686", "tsadi"},
+        {"afii57687", "qof"},
+        {"afii57688", "resh"},
+        {"afii57689", "shin"},
+        {"afii57690", "tav"}
+};
+
+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);
+  }
+  /* Fix for CR6206898 */
+  if(strncmp(keyP->data.valueP, "afii", 4) == 0) {
+      int pos = -1;
+      int size = 0;
+      for(i=0;i<HNUM;i++) {
+        if(strncmp(keyP->data.valueP, hebrew[i][0], keyP->len) == 0) {
+            pos = i;
+            break;
+        }
+      }
+      if(pos ==  -1)
+        return(0);
+      size = strlen(hebrew[pos][1]);
+      for (i=1;i<=n;i++) {
+        if((size == dictP[i].key.len) &&
+           (strncmp(dictP[i].key.data.valueP, hebrew[pos][1], dictP[i].key.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/xkbfile/spec/versions	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,48 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)versions 1.3     05/11/08 SMI"
+#
+# lib/xkbfile/spec/versions
+#
+
+amd64 {
+	SUNWprivate;
+}
+i386 {
+	SUNWprivate;
+}
+sparc {
+	SUNWprivate;
+}
+sparcv9 {
+	SUNWprivate;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/lib/xkbfile/spec/xkbfile.spec	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,490 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+#
+# ident "@(#)xkbfile.spec 1.3     05/11/08 SMI"
+#
+# lib/xkbfile/spec/xkbfile.spec
+#
+
+Function		XkbAccessXDetailText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbActionText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbActionTypeText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbAtomGetString
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbAtomText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbBehaviorText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFAddModByName
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFAddPrivate
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFApplyMods
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFApplyRtrnValues
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFBindMods
+Version	SUNWprivate
+Arch		all
+End
+
+Data		XkbCFDflts
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFDup
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFFree
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFFreeRtrn
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFParse
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFReportError
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbCFScan
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbChangeAtomDisplay
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbChangeKbdDisplay
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbConfigText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbControlsMaskText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbConvertGetByNameComponents
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbConvertXkbComponents
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbDetermineFileType
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbDoodadTypeText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbEnsureSafeMapName
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbFindKeycodeByName
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbFreeOrderedDrawables
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbGeomFPText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbGetOrderedDrawables
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbIMWhichStateMaskText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbIndentText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbInitAtoms
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbInternAtom
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbKeyNameText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbKeysymText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbLookupCanonicalRGBColor
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbLookupGroupAndLevel
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbMergeFile
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbModIndexText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbModMaskText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbNKNDetailMaskText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbNameMatchesPattern
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_AddRule
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_AddVarDesc
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_AddVarDescCopy
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_AddVarToDescribe
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_Create
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_Free
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_GetComponents
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_GetNamesProp
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_Load
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_LoadDescriptions
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_LoadDescriptionsByName
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_LoadRules
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_LoadRulesByName
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbRF_SetNamesProp
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbReadFromServer
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbSIMatchText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbStdBell
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbStdBellEvent
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbStringText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbVModIndexText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbVModMaskText
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteCFile
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteToServer
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBCompatMap
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBFile
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBGeometry
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBKeyTypes
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBKeycodes
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBKeymap
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBKeymapForNames
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBLayout
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBSemantics
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKBSymbols
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkbWriteXKMFile
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkmFindTOCEntry
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkmProbe
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkmReadFile
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkmReadFileSection
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkmReadFileSectionName
+Version	SUNWprivate
+Arch		all
+End
+
+Function		XkmReadTOC
+Version	SUNWprivate
+Arch		all
+End
+
+Function		_XkbDupString
+Version	SUNWprivate
+Arch		all
+End
+
+Data		_XkbErrCode
+Version	SUNWprivate
+Arch		all
+End
+
+Data		_XkbErrData
+Version	SUNWprivate
+Arch		all
+End
+
+Data		_XkbErrLocation
+Version	SUNWprivate
+Arch		all
+End
+
+Data		_XkbErrMessages
+Version	SUNWprivate
+Arch		all
+End
+
+Function		_XkbKSCheckCase
+Version	SUNWprivate
+Arch		all
+End
+
+Function		_XkbStrCaseCmp
+Version	SUNWprivate
+Arch		all
+End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1245 @@
+XCOMM $XdotOrg: xc/programs/Xserver/Imakefile,v 1.37 2005/11/18 18:15:23 ajax Exp $
+XCOMM $Xorg: Imakefile,v 1.4 2001/03/14 18:42:02 pookie Exp $
+/*
+ * Server Master Makefile
+ */
+XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.296 2003/11/23 06:47:00 torrey Exp $
+
+#ifndef InstallXserverSetUID
+#define InstallXserverSetUID NO
+#endif
+#define InstallServerSetUID InstallXserverSetUID
+
+#include <Server.tmpl>
+
+/* On most systems the linker requires the libraries in dependency order. 
+   But we have no real order because there are cycles. We fix this by adding
+   some libraries twice on the commandline. dependLib will add the 
+   dependency library to the commandline if the link order is important */ 
+#if 1 /* This is currently enabled for all systems */
+#define dependLib(x) x
+#else
+#define dependLib(x)
+#endif
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+/* Do not strip server binaries */
+INSTPGMFLAGS = 
+#endif
+
+#define PreFbLibs $(DIX) $(OS) $(XPDDX)
+#define PreFbLibsNoFont $(DIX) $(OS)
+#define BarePostFbLibs $(MFB) $(XPFBLIBS) $(MI)
+#define PostFbLibs BarePostFbLibs $(EXTENSIONS)
+#define NoMfbBarePostFbLibs $(XPFBLIBS) $(MI)
+#if !BuildXinerama
+#define NoMfbPostFbLibs NoMfbBarePostFbLibs $(EXTENSIONS)
+#else
+#define NoMfbPostFbLibs $(EXTENSIONS) NoMfbBarePostFbLibs $(EXTENSIONS)
+#endif
+
+#define MFBBareLibs PreFbLibs BarePostFbLibs
+#define NoMFBBareLibs PreFbLibs NoMfbBarePostFbLibs
+#define MFBLibs PreFbLibs PostFbLibs
+#define NoMFBLibs PreFbLibs NoMfbPostFbLibs
+#define CFBLibs PreFbLibs $(CFB) PostFbLibs
+#define CFB4Libs PreFbLibs $(CFB4) PostFbLibs
+#define CFB8Libs PreFbLibs $(CFB8) PostFbLibs
+#define CFB16Libs PreFbLibs $(CFB16) PostFbLibs
+#define CFB24Libs PreFbLibs $(CFB24) PostFbLibs
+#define CFB32Libs PreFbLibs $(CFB32) PostFbLibs
+
+#define NoMFBCFBLibs PreFbLibs $(CFB) NoMfbPostFbLibs
+#define NoMFBCFB8Libs PreFbLibs $(CFB8) NoMfbPostFbLibs
+#define FbPostFbLibs  $(FB) NoMfbPostFbLibs
+#define FBLibs PreFbLibs FbPostFbLibs
+
+#define MiExtLibs $(SHADOW)
+
+#define AllFBLibs PreFbLibs $(FB) $(CFB) PostFbLibs
+
+#if BuildGlxExt
+# if BuildXF86DRI && ((defined(XF86Server) && XF86Server) \
+	|| (defined(XorgServer) && XorgServer))
+      DRILIB = GL/dri/ModuleLibraryTargetName(dri)
+# else
+      DRILIB = 
+# endif
+# if GlxUseSGISI
+      GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+               GL/sgi-si/ModuleLibraryTargetName(GLcore) \
+               $(DRILIB)
+# else
+#  if defined(GlxUseWindows) && GlxUseWindows
+      XWin_GL.exe.GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+               GL/windows/ModuleLibraryTargetName(GLcore)
+#  endif /* GlxUseWindows */
+#  if defined(Win32Architecture) && defined(GlxUseWindows) && GlxUseWindows
+      GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+               GL/windows/ModuleLibraryTargetName(GLcore)
+#  elif DoLoadableServer
+      GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+               GL/mesa/GLcore/ModuleLibraryTargetName(GLcore)
+#  else
+      GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+               GL/mesa/GLcore/ModuleLibraryTargetName(GLcore) \
+               $(DRILIB)
+#  endif
+# endif
+      GLXDIR = GL
+# if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+      GLXEXT = $(if $([email protected]),$([email protected]), $(GLXLIB))
+# else
+      GLXEXT = $(GLXLIB)
+# endif
+#endif
+
+#if BuildXInputExt
+      XINPUTEXT = Xi/LibraryTargetName(xinput)
+          XIDIR = Xi
+#endif
+#if BuildXKB
+         XKBEXT = xkb/LibraryTargetName(xkb) dependLib($(OS))
+         XKBDIR = xkb
+#if (defined(XFree86Version) || defined(XorgVersion))
+    XF86XKBOBJS = xkb/xf86KillSrv.o xkb/xf86VT.o xkb/xf86Private.o
+#endif
+#endif
+#if BuildLBX
+         LBXEXT = lbx/LibraryTargetName(lbx) \
+                  $(TOP)/lib/lbxutil/LibraryTargetName(lbxutil)
+        LBXDIRS = lbx
+#endif
+#if BuildDBE
+         DBEEXT = dbe/LibraryTargetName(dbe)
+#endif
+#if BuildDBE || BuildDBElib
+         DBEDIR = dbe
+#endif
+#if BuildRECORD
+      RECORDEXT = record/LibraryTargetName(record)
+#endif
+#if BuildRECORD || BuildRECORDlib
+      RECORDDIR = record
+#endif
+#if BuildXTrap
+       XTRAPEXT = XTrap/LibraryTargetName(xtrap)
+       XTRAPDIR = XTrap
+#endif
+#if BuildTsolExt
+         XTSOLDIR = tsol
+#endif
+#ifdef SiteExtensionLibs
+       SITEEXTS = SiteExtensionLibs
+#endif
+#ifdef SiteExtensionDirs
+    SITEEXTDIRS = SiteExtensionDirs
+#endif
+#if DoLoadableServer && HasDlopen
+          LIBDL = DlLibrary
+#endif
+       LIBREGEX = RegexLibrary
+
+#if DoLoadableServer
+    LIBCWRAPPER = os/libcwrapper.o
+#endif
+
+#if BuildXprint
+
+XPCONFIGDIR = XpConfig
+
+#ifndef XpRasterDDX
+#define XpRasterDDX YES
+#endif
+#ifndef XpColorPclDDX
+#define XpColorPclDDX YES
+#endif
+#ifndef XpMonoPclDDX
+#define XpMonoPclDDX NO
+#endif
+#ifndef XpPostScriptDDX
+#define XpPostScriptDDX YES
+#endif
+
+#if XpRasterDDX
+XPRASTLIB = Xprint/raster/LibraryTargetName(raster)
+#endif
+#if XpColorPclDDX
+XPPCLLIB = Xprint/pcl/LibraryTargetName(pcl)
+#endif
+#if XpMonoPclDDX
+XPMPCLLIB = Xprint/pcl-mono/LibraryTargetName(pcl)
+#endif
+#if XpPostScriptDDX
+XPPSLIB = Xprint/ps/LibraryTargetName(ps)
+#endif
+
+XPDDXLIBS = Xprint/LibraryTargetName(printer) \
+	    $(XPRASTLIB) $(XPPCLLIB) $(XPMPCLLIB) $(XPPSLIB)
+XPDDXFBLIBS = $(MFB) $(CFB32)
+#if !PrintOnlyServer
+      XPFBLIBS = $(XPDDXFBLIBS)
+      XPDDX = $(XPDDXLIBS)
+#endif
+      XPDDXDIR = Xprint
+#endif
+#if !BuildXprint || PrintOnlyServer
+XPFBLIBS = dix/LibraryTargetName(xpstubs)
+#endif
+
+#if BuildRender
+      RENDERDIR = render
+      RENDERLIB = $(RENDERDIR)/librender.a
+#endif
+#if BuildRandR
+      RANDRDIR = randr
+      RANDRLIB = $(RANDRDIR)/librandr.a
+#endif
+#if BuildXfixes
+      FIXESDIR = xfixes
+      FIXESLIB = $(FIXESDIR)/libxfixes.a
+#endif
+#if BuildDamage
+      DAMAGEDIR = damageext
+      DAMAGELIB = $(DAMAGEDIR)/libdamage.a
+#endif
+#if BuildComposite
+          CWDIR = miext/cw
+   COMPOSITEDIR = composite
+   COMPOSITELIB = $(COMPOSITEDIR)/libcomposite.a
+#if DoLoadableServer
+             CW = miext/cw/ModuleLibraryTargetName(cw)
+#else
+             CW = miext/cw/LibraryTargetName(cw)
+#endif
+#endif
+#if DoLoadableServer
+     EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+		  $(OTHEREXTS) $(RANDRLIB) $(RENDERLIB)
+   LOADABLEEXTS = $(MISCEXT) $(DBEEXT) $(RECORDEXT) $(GLXEXT) $(XTRAPEXT) 
+        MISCEXT = Xext/LibraryTargetName(ext)
+      OTHEREXTS = Xext/LibraryTargetName(exts) $(XKBEXT) $(XINPUTEXT) \
+                  $(LBXEXT) $(SITEEXTS)
+#else
+     EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+		  $(OTHEREXTS) $(GLXEXT) $(RANDRLIB) $(RENDERLIB)
+      OTHEREXTS = Xext/LibraryTargetName(ext) $(XKBEXT) $(XINPUTEXT) \
+                  $(LBXEXT) $(DBEEXT) $(RECORDEXT) $(SITEEXTS) $(XTRAPEXT)
+#endif
+        EXTDIRS = Xext $(XKBDIR) $(XIDIR) $(GLXDIR) \
+                  $(LBXDIRS) $(DBEDIR) $(RECORDDIR) $(SITEEXTDIRS) \
+                  $(RANDRDIR) $(RENDERDIR) $(XTRAPDIR) $(XPCONFIGDIR) \
+		  $(FIXESDIR) $(DAMAGEDIR) $(CWDIR) $(COMPOSITEDIR) $(XTSOLDIR)
+#if BuildLBX || GzipFontCompression
+           ZLIB = GzipLibrary
+#endif
+             OS = os/LibraryTargetName(os)
+        BSDEMUL = $(DEPXBSDLIB)
+#if DoLoadableServer
+            MFB = mfb/ModuleLibraryTargetName(mfb)
+             FB = fb/ModuleLibraryTargetName(fb)
+#if XF8_32Wid
+            CFB = cfb/ModuleLibraryTargetName(cfb) \
+		  cfb16/ModuleLibraryTargetName(cfb16) \
+		  cfb24/ModuleLibraryTargetName(cfb24) \
+		  cfb32/ModuleLibraryTargetName(cfb32)
+#else
+            CFB = cfb/ModuleLibraryTargetName(cfb) \
+		  cfb16/ModuleLibraryTargetName(cfb16) \
+		  cfb32/ModuleLibraryTargetName(cfb32)
+#endif
+           CFB8 = cfb/ModuleLibraryTargetName(cfb)
+           CFB4 = cfb/ModuleLibraryTargetName(cfb) \
+		  cfb4/ModuleLibraryTargetName(cfb4)
+          CFB16 = cfb/ModuleLibraryTargetName(cfb) \
+		  cfb16/ModuleLibraryTargetName(cfb16)
+          CFB24 = cfb/ModuleLibraryTargetName(cfb) \
+		  cfb24/ModuleLibraryTargetName(cfb24)
+          CFB32 = cfb/ModuleLibraryTargetName(cfb) \
+		  cfb32/ModuleLibraryTargetName(cfb32)
+         DAMAGE = miext/damage/ModuleLibraryTargetName(damage)
+         SHADOW = miext/shadow/ModuleLibraryTargetName(shadow)
+          LAYER = miext/layer/ModuleLibraryTargetName(layer) 
+#else 
+            MFB = mfb/LibraryTargetName(mfb)
+             FB = fb/LibraryTargetName(fb)
+#if XF8_32Wid
+            CFB = cfb16/LibraryTargetName(cfb16) \
+		  cfb24/LibraryTargetName(cfb24) \
+		  cfb32/LibraryTargetName(cfb32) \
+		  cfb/LibraryTargetName(cfb)
+#else
+            CFB = cfb16/LibraryTargetName(cfb16) \
+		  cfb32/LibraryTargetName(cfb32) \
+		  cfb/LibraryTargetName(cfb)
+#endif
+           CFB8 = cfb/LibraryTargetName(cfb)
+           CFB4 = cfb4/LibraryTargetName(cfb4) \
+		  cfb/LibraryTargetName(cfb)
+          CFB16 = cfb16/LibraryTargetName(cfb16) \
+		  cfb/LibraryTargetName(cfb)
+          CFB24 = cfb24/LibraryTargetName(cfb24) \
+		  cfb/LibraryTargetName(cfb)
+          CFB32 = cfb32/LibraryTargetName(cfb32) \
+		  cfb/LibraryTargetName(cfb)
+         DAMAGE = miext/damage/LibraryTargetName(damage)
+         SHADOW = miext/shadow/LibraryTargetName(shadow)
+          LAYER = miext/layer/LibraryTargetName(layer) 
+#endif
+#if !HasFfs && (defined(mingwArchitecture) || defined(cygwinArchitecture))
+             /* Order of libraries is important when linking in mingw or
+              * cygwin. libmi.a requires ffs from libdix.a. So it is added
+              * after libmi.a on the commandline */
+             MI = mi/LibraryTargetName(mi) $(DIX)
+#else
+             MI = mi/LibraryTargetName(mi)
+#endif
+   MIINITEXTOBJ = mi/miinitext.o
+            DIX = dix/LibraryTargetName(dix)
+       FONTBASE = $(FONTLIBSRC)/fontbase.o \
+		  $(FONTLIBSRC)/LibraryTargetName(fontbase)
+#if XserverStaticFontLib
+           FONT = $(FONTLIBSRC)/LibraryTargetName(Xfont) $(FREETYPE2LIB)
+#else
+           FONT = $(LDPRELIB) $(XFONTLIB) $(FREETYPE2LIB)
+#endif
+       FONTLIBS = $(FONT) $(XPFBLIBS)
+#if UsbMouseSupport 
+#if !HasLibUsb
+            USB = $(XF86OSSRC)/bsd/libusb/LibraryTargetName(usb)
+#else
+            USB = UsbHidLib
+#endif
+#endif
+#ifdef ServerExtraSysLibs
+   EXTRASYSLIBS = ServerExtraSysLibs
+#endif
+#if HasPam && HasPamMisc
+        PAMLIBS = PamLibraries PamMiscLibraries
+#endif
+#if !(SystemV4 || defined(SGIArchitecture) || UseRgbTxt)
+       DBMLIBS = DBMLibrary
+#endif
+        SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries $(DBMLIBS) $(USB) \
+		  $(PAMLIBS)  $(XAUTHLIB) $(XDMCPLIB) $(EXTRASYSLIBS)
+#if !HasCbrt
+           CBRT = mi/LibraryTargetName(cbrt)
+#endif
+        STDDIRS = include dix os mi $(XPDDXDIR) $(EXTDIRS)
+          FBDIR = fb
+         MFBDIR = mfb
+        CFB4DIR = cfb4
+        CFB8DIR = cfb
+       CFB16DIR = cfb16
+       CFB24DIR = cfb24
+       CFB32DIR = cfb32
+         AFBDIR = afb
+
+XCOMM
+XCOMM This turns off the default rule for compiling .c files because
+XCOMM this makefile does not really know how to build it.  This is really
+XCOMM just a hack because of the Sun version of make and nfs.
+XCOMM
+.c.o:
+
+.s.o:
+
+/*  		  Build rule blocks, add one for each server
+ *  
+ *  If a server needs mfb, its build block should have a line like:
+ *  MFBSUBDIR = mfb
+ *  Similarly, its build block should have:
+ *  CFB4SUBDIR  = cfb4  (if the server needs 4 bit cfb)
+ *  CFB8SUBDIR  = cfb   (8 bit cfb)
+ *  CFB16SUBDIR = cfb16 (16 bit cfb)
+ *  CFB24SUBDIR = cfb24 (24 bit cfb)
+ *  CFB32SUBDIR = cfb32 (32 bit cfb)
+ *  
+ *  If a server does not need all of the above components, simply
+ *  omit the relevant lines from the build block.
+ *  
+ *  If these guidelines are followed, a make at the top of the server
+ *  tree should result in each subdirectory being built only once,
+ *  even if multiple servers that share subdirectories are being built.
+ */
+
+#if defined(XdecServer) && XdecServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM
+MFBSUBDIR  = mfb
+CFB8SUBDIR = cfb
+DECWSDDXDIR = hw/dec/ws
+DECDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS = hw/dec/ws/init.o hw/dec/ws/sdepthinit.o
+DECLIBS = hw/dec/ws/LibraryTargetName(dec) CFB8Libs
+ServerTarget(Xdec,$(DECDIRS),$(DECOBJS), \
+	$(DECLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec
+#endif
+#endif /* XdecServer */
+
+
+#if defined(XdecMultiDepthServer) && XdecMultiDepthServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM Supports 8, 12, and 24 bit pixmaps
+XCOMM
+MFBSUBDIR   = mfb
+CFB8SUBDIR  = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+DECWSDDXDIR  = hw/dec/ws
+DECDIRS1 = $(STDDIRS) $(MFBDIR) \
+	   $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+	   $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS1 = hw/dec/ws/init.o hw/dec/ws/mdepthinit.o
+DECLIBS1 = hw/dec/ws/LibraryTargetName(dec) CFBLibs
+ServerTarget(Xdec_md,$(DECDIRS1),$(DECOBJS1), \
+	$(DECLIBS1),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec_md
+#endif
+#endif /* XdecMultiDepthServer */
+
+
+#if defined(XsunServer) && XsunServer
+XCOMM
+XCOMM Sun server
+XCOMM
+MFBSUBDIR  = mfb
+CFB8SUBDIR = cfb
+SUNDDXDIR = hw/sun
+#if DoLoadableServer
+SUNOBJS = hw/sun/sunInit.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif (defined(XF86Server) && XF86Server) \
+	|| (defined(XorgServer) && XorgServer)
+SUNOBJS = hw/sun/sunInit.o hw/sun/stubs.o
+#else
+SUNOBJS = hw/sun/sunInit.o
+#endif
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(SUNDDXDIR) $(DEPDIRS)
+SUNLIBS = hw/sun/LibraryTargetName(sun) CFB8Libs
+SUNSYSLIBS = $(FONTLIBS) $(WIDECHARSYSLIB) $(SYSLIBS)
+SetUIDServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+	$(LIBCWRAPPER) $(SUNLIBS) $(LOADABLEEXTS),$(SUNSYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunServer */
+
+
+#if defined(Xsun24Server) && Xsun24Server
+XCOMM
+XCOMM Sun multiple pixmap depth (8, 12, 24) server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+SUNDDXDIR = hw/sun
+SUN24DIRS = $(STDDIRS) $(MFBDIR) \
+	    $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+	    $(SUNDDXDIR) $(DEPDIRS)
+#if DoLoadableServer
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif defined(XF86Server) && XF86Server  \
+	|| (defined(XorgServer) && XorgServer)
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/stubs.o
+#else
+SUN24OBJS = hw/sun/sunInitMulti.o
+#endif
+SUN24LIBS = hw/sun/LibraryTargetName(sun) CFBLibs
+SetUIDServerTarget(Xsun24,$(SUN24DIRS),$(SUN24OBJS), \
+	$(LIBCWRAPPER) $(SUN24LIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun24
+#endif
+#endif /* Xsun24Server */
+
+
+#if defined(XsunMonoServer) && XsunMonoServer
+XCOMM
+XCOMM Sun monochrome server
+XCOMM
+MFBSUBDIR = mfb
+SUNDDXDIR = hw/sun
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(SUNDDXDIR) $(DEPDIRS)
+#if defined(XF86Server) && XF86Server  \
+	|| (defined(XorgServer) && XorgServer)
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o hw/sun/stubs.o
+#else
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o
+#endif
+SUNMLIBS = hw/sun/LibraryTargetName(sun) MFBBareLibs $(EXTENSIONS)
+SetUIDServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+	$(LIBCWRAPPER) $(SUNMLIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunMonoServer */
+
+
+#if defined(XsunLynxServer) && XsunLynxServer
+XCOMM
+XCOMM Sun server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+LYNXDDXDIR = hw/sunLynx
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNOBJS = hw/sunLynx/sunLyInit.o
+SUNLIBS = hw/sunLynx/libsun.a CFB8Libs
+ServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+	$(SUNLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunLynxServer */
+
+
+#if defined(XsunLynxMonoServer) && XsunLynxMonoServer
+XCOMM
+XCOMM Sun monochrome server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+LYNXDDXDIR = hw/sunLynx
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNMOBJS = hw/sunLynx/sunInitMono.o hw/sunLynx/sunInExMono.o
+SUNMLIBS = hw/sunLynx/libsun.a MFBBareLibs $(OTHEREXTS)
+ServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+	$(SUNMLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunLynxMonoServer */
+
+
+#if HasParallelMake
+XCOMM
+XCOMM force non-parallel build of XF86 servers to prevent MUTEX overrides
+XCOMM
+#if defined(XF86Server) && XF86Server
+XF86SERVER = XFree86
+#endif
+#if defined(XorgServer) && XorgServer
+XF86SERVER = Xorg
+#endif
+#if defined(XnestServer) && XnestServer
+XNEST = Xnext
+#endif
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XVFB = Xvfb
+#endif
+#if XdmxServer
+XDMX = Xdmx
+#endif
+#if defined(XWinServer) && XWinServer && !MakeDllModules
+XWIN = XWin
+#endif
+#if (defined(XF86Server) && XF86Server) || \
+    (defined(XorgServer) && XorgServer) || \
+    (defined(XnestServer) && XnestServer) || \
+    (defined(XVirtualFramebufferServer) && XVirtualFramebufferServer) || \
+    (defined(XdmxServer) && XdmxServer) || \
+    (!MakeDllModules && defined(XWinServer) && XWinServer)
+MakeMutex($(XF86SERVER) $(XNEST) $(XVFB) $(XWIN))
+#endif
+MakeMutex($(STDDIRS) mfb fb cfb cfb16 cfb24 cfb32)
+#endif
+
+
+#if defined(XF86Server) && XF86Server
+XCOMM
+XCOMM XFree86 Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR  = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = XFree86.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR  = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+		    $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+		    $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+		    $(MIDAMAGEDIR)
+XF86INIT   = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB  = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+              $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+	      $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+	      $(XF8_16BPPLIB) \
+	      $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS  = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+	    $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB) 
+#else
+XF86LIBS  = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+	    $(XF86PARSLIB) $(XF86OSLIB) 
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+	       $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+	       NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+		 $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+		 $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+		 $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+	@if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(XFree86,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+	$(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(XFree86)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall XFree86
+#endif
+#endif        /* XF86Server */
+
+#if defined(XorgServer) && XorgServer
+XCOMM
+XCOMM Xorg Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR  = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+#if XF8_32Wid
+CFB24SUBDIR = cfb24
+#endif
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = Xorg.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR  = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+		    $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+		    $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+		    $(MIDAMAGEDIR)
+XF86INIT   = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB  = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+              $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+	      $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+	      $(XF8_16BPPLIB) \
+	      $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS  = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+	    $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB) 
+#else
+XF86LIBS  = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+	    $(XF86PARSLIB) $(XF86OSLIB) 
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+	       $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+	       NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+		 $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+		 $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+		 $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+	@if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(Xorg,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+	$(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(Xorg)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall Xorg
+#endif
+#endif        /* XorgServer */
+
+#if defined(XprtServer) && XprtServer
+XCOMM
+XCOMM Print Server
+XCOMM
+MFBSUBDIR  = mfb
+CFB8SUBDIR = cfb
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+XPSUBDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB32DIR) $(DEPDIRS) \
+	    $(MIDAMAGEDIR)
+XPOBJS = Xprint/ddxInit.o Xprint/dpmsstubs.o Xprint/miinitext.o
+#if PrintOnlyServer
+XPLIBS = PreFbLibs $(XPDDXLIBS) $(XPDDXFBLIBS) PostFbLibs
+#else
+XPLIBS = PreFbLibs PostFbLibs
+#endif
+#if (defined(SunArchitecture) || defined(SparcArchitecture)) && \
+    defined(SVR4Architecture)
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB) -lw
+#else
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB)
+#endif
+#if HasParallelMake
+MakeMutex($(XPSUBDIRS) $(XPOBJS) $(XPLIBS) $(XPSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XPOBJS) $(XPLIBS) $(XPSYSLIBS):: $(XPSUBDIRS)
+	@if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xprt,$(XPSUBDIRS),$(XPOBJS), \
+	$(LIBCWRAPPER) $(XPLIBS) $(LOADABLEEXTS),$(XPSYSLIBS))
+#endif	/* XprtServer */
+
+#if defined(XnestServer) && XnestServer
+XCOMM
+XCOMM Server with Xlib-based ddx
+XCOMM
+#ifndef Win32Architecture
+XNESTDDXDIR = hw/xnest
+#else
+XNESTDDXDIR = hw
+#endif
+#if BuildDPMS
+XNESTDPMSSTUBOBJS = $(XNESTDDXDIR)/dpmsstubs.o
+#endif
+XNESTDIRS = $(STDDIRS) $(XNESTDDXDIR) $(DEPDIRS)
+#if !defined(LynxOSArchitecture) && \
+    !defined(Win32Architecture) && \
+    !defined(QNX4Architecture)
+XNESTOBJS = hw/xnest/miinitext.o $(XNESTDPMSSTUBOBJS)
+#else
+XNESTOBJS = hw/xnest/miinitext.o dix/main.o $(XNESTDPMSSTUBOBJS)
+#endif
+XNEST = hw/xnest/LibraryTargetName(xnest)
+XNESTLIBS = PreFbLibs $(XNEST) NoMfbPostFbLibs $(XNEST)
+XNESTSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XNESTDIRS) $(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS):: $(XNESTDIRS)
+	@if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xnest,$(XNESTDIRS),$(XNESTOBJS) $(XNESTDEFFILE), \
+	$(LIBCWRAPPER) $(XNESTLIBS) $(LOADABLEEXTS),$(XNESTSYSLIBS))
+#endif /* XnestServer */
+
+
+#if defined(XnonServer) && XnonServer
+XCOMM
+XCOMM non server, just compile sources for build test
+XCOMM
+MFBSUBDIR   = mfb
+CFB8SUBDIR  = cfb
+CFB16SUBDIR = cfb16
+CFB32SUBDIR = cfb32
+#if HasParallelMake
+MakeMutex($(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS))
+#endif
+Xnon: $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS)
+#endif /* XnonServer */
+
+
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XCOMM
+XCOMM server with Virtual (malloced) framebuffer
+XCOMM
+MFBSUBDIR = mfb
+FBSUBDIR  = fb
+#if defined(Win32Architecture)
+XVFBDDXDIR = hw
+#else
+XVFBDDXDIR = hw/vfb
+#endif
+XVFBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(XVFBDDXDIR) $(DEPDIRS)
+#ifndef Win32Architecture
+#if BuildDPMS
+XVFBDPMSSTUBOBJS = $(XVFBDDXDIR)/dpmsstubs.o
+#endif
+XVFBOBJS = $(XVFBDDXDIR)/stubs.o $(XVFBDDXDIR)/miinitext.o $(XVFBDPMSSTUBOBJS)
+#else
+XVFBOBJS = dix/main.o hw/vfb/stubs.o hw/vfb/miinitext.o
+#endif
+XVFB = $(XVFBDDXDIR)/LibraryTargetName(vfb)
+XVFBLIBS = PreFbLibs $(XVFB) $(FB) PostFbLibs $(MI)
+XVFBSYSLIBS = $(FONTLIBS) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XVFBDIRS) $(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS):: $(XVFBDIRS)
+	@if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xvfb,$(XVFBDIRS),$(XVFBOBJS) $(XVFBDEFFILE), \
+	$(LIBCWRAPPER) $(XVFBLIBS) $(LOADABLEEXTS),$(XVFBSYSLIBS))
+#endif /* XVirtualFramebufferServer */
+
+#if defined(XdmxServer) && XdmxServer
+XCOMM
+XCOMM distribued multihead Server
+XCOMM
+#ifndef Win32Architecture
+XDMXDDXDIR = hw/dmx
+#else
+XDMXDDXDIR = hw
+#endif
+FBDIR = fb
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+XDMXDIRS = $(STDDIRS) $(XDMXDDXDIR) $(SHADOWDIR) $(DEPDIRS) $(FBDIR) $(MIDAMAGEDIR)
+#if BuildGlxExt
+#if BuildXinerama
+GLXPROXY_EXTRAOBJS = hw/dmx/panoramiX.o
+#endif
+GLXPROXYLIB = hw/dmx/glxProxy/LibraryTargetName(glxProxy)
+#endif
+#if !defined(LynxOSArchitecture) && \
+    !defined(Win32Architecture) && \
+    !defined(QNX4Architecture)
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS)
+#else
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS) dix/main.o
+#endif
+XDMX = hw/dmx/LibraryTargetName(dmx) \
+       hw/dmx/input/LibraryTargetName(dmxinput) \
+       hw/dmx/config/LibraryTargetName(dmxconfig) \
+       $(GLXPROXYLIB)
+XDMXLIBS = PreFbLibs $(XDMX) MiExtLibs FbPostFbLibs $(XDMX)
+#if BuildRender
+XDMXRENDERLIB = $(XRENDERLIB)
+#endif
+XDMXSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XILIB) $(XLIB) $(SYSLIBS) $(XMULIB) $(XDMXRENDERLIB)
+#if HasParallelMake
+MakeMutex($(XDMXDIRS) $(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS):: $(XDMXDIRS)
+	@if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xdmx,$(XDMXDIRS),$(XDMXOBJS), \
+       $(LIBCWRAPPER) $(XDMXLIBS) $(LOADABLEEXTS),$(XDMXSYSLIBS))
+#endif /* XdmxServer */
+
+#if defined(XWinServer) && XWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+#if BuildXWinLayer
+LAYERDIR = miext/layer
+XWINLAYERLIB = $(LAYER)
+#else
+LAYERDIR = 
+XWINLAYERLIB = 
+#endif
+#if BuildXWinMultiWindowExtWM
+ROOTLESSDIR = miext/rootless
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+	      $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+	      $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+#else
+ROOTLESSDIR = 
+ROOTLESSLIB = 
+#endif
+XWINDDXDIR = hw/xwin
+#if BuildXWinXF86Config
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+#else
+XWINPARSERDIR = 
+XWINPARSERLIB = 
+#endif
+#if defined(GlxUseWindows) && GlxUseWindows
+XWINOPENGLLIB = -lopengl32
+#else
+XWINOPENGLLIB = 
+#endif
+
+XWINLIB = $(XWINDDXDIR)/LibraryTargetName(XWin)
+XWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(XWINDDXDIR) \
+	   $(DEPDIRS) $(XWINPARSERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+XWINOBJS = $(XWINDDXDIR)/stubs.o $(XWINDDXDIR)/XWin.res
+XWINLIBS = PreFbLibs $(XWINLIB) FbPostFbLibs $(XWINLIB) $(XWINLAYERLIB) \
+           $(SHADOW) $(XWINPARSERLIB) $(ROOTLESSLIB) $(OS)
+#if BuildXWinMultiWindow || BuildXWinClipboard
+XWINX11  = $(XONLYLIB)	   
+# if defined(Win32Architecture)
+PTHREADLIB = -lpthreadGC2
+# endif
+#endif
+#if defined(Win32Architecture)
+# if defined(GlxUseWindows) && GlxUseWindows
+XWINGL32 = -lopengl32
+# endif
+XWINW32  = -lgdi32 -lwsock32 $(XWINGL32) $(PTHREADLIB) 
+#else
+XWINW32  = -lgdi32
+#endif
+XWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XWINX11) $(SYSLIBS) $(XWINW32)
+
+EXTRA_LDOPTIONS = -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(XWINDIRS) $(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS))
+#endif
+
+#if ForceServerRemake
+$(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS):: $(XWINDIRS)
+	@if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+#ifdef mingwArchitecture
+XWINSERVERNAME=Xming    
+XWINGLSERVERNAME=XmingGL    
+#else
+XWINSERVERNAME=XWin    
+XWINGLSERVERNAME=XWin_GL 
+#endif
+ServerTarget($(XWINSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+	     $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS))
+#if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows 
+ServerTarget($(XWINGLSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+	     $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS) \
+	     $(XWINOPENGLLIB)) 
+#endif
+
+#ifndef ServerToInstall
+# define ServerToInstall $(XWINSERVERNAME)
+#endif
+
+#endif /* XWinServer */
+
+
+#ifdef DarwinArchitecture
+/*
+ * To allow building even when building the client-side libraries is turned
+ * off, libraries in ProjectRoot are listed as dependencies for some targets.
+ * This causes problems unless we tell make where to find these dependencies.
+ */
+VPATH = $(BUILDLIBDIR):$(USRLIBDIR)
+#endif
+
+#if defined(XDarwinServer) && XDarwinServer
+XCOMM
+XCOMM X Darwin server for Mac OS X / Darwin
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+ROOTLESSDIR = miext/rootless
+DARWINDDXDIR = hw/darwin
+DARWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(DARWINDDXDIR) $(DEPDIRS)
+DARWINOBJS = $(DARWINDDXDIR)/miinitext.o
+DARWINLIBS = PreFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINEXTLIBS = MiExtLibs FbPostFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINSYSLIBS = $(FONTLIBS) $(SYSLIBS) -framework IOKit
+IOKITLIB = $(DARWINDDXDIR)/iokit/LibraryTargetName(iokit)
+
+/*
+ * IOKit X server
+ */
+SetUIDServerTarget(XDarwin,$(DARWINDIRS),$(DARWINOBJS), \
+	$(DARWINLIBS) $(IOKITLIB) $(DARWINEXTLIBS),$(DARWINSYSLIBS))
+
+#if DarwinQuartzSupport
+
+QUARTZDIR = $(DARWINDDXDIR)/quartz
+QUARTZLIB = $(QUARTZDIR)/LibraryTargetName(XQuartz)
+QUARTZSYSLIBS = -framework ApplicationServices -framework Cocoa \
+                -framework CoreAudio -framework Carbon -ObjC
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+              $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+              $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+XPLUGINLIB = XpluginLibrary
+
+#if NothingOutsideProjectRoot
+XDARWINAPPDIR = $(BINDIR)/XDarwin.app/Contents
+#else
+XDARWINAPPDIR = /Applications/XDarwin.app/Contents
+#endif
+
+/*
+ * Quartz X server (installed in its application bundle)
+ */
+SetUIDServerTarget(XDarwinApp,$(DARWINDIRS),$(DARWINOBJS), \
+	$(DARWINLIBS) $(QUARTZLIB) $(DARWINEXTLIBS), \
+	$(DARWINSYSLIBS) $(QUARTZSYSLIBS) -u _miDCInitialize)
+
+install::
+	$(MKDIRHIER) $(DESTDIR)$(XDARWINAPPDIR)/MacOS
+	$(MV) $(DESTDIR)$(BINDIR)/XDarwinApp \
+		$(DESTDIR)$(XDARWINAPPDIR)/MacOS/XDarwin
+	-(cd $(DESTDIR)$(BINDIR); $(RM) XDarwinQuartz; \
+		$(LN) $(XDARWINAPPDIR)/MacOS/XDarwin XDarwinQuartz)
+
+/*
+ * Display mode bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+#if HasXplugin
+XPRDIRS = $(QUARTZDIR)/xpr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+XPRLIBS = $(QUARTZDIR)/xpr/LibraryTargetName(xpr) $(ROOTLESSLIB)
+
+BundleProgramTarget(xpr,XDarwinApp,$(XPRDIRS),$(QUARTZDIR)/xpr/xprScreen.o, \
+	$(XPRLIBS),-framework ApplicationServices \
+	$(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+CRDIRS = $(QUARTZDIR)/cr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+CRLIBS = $(QUARTZDIR)/cr/LibraryTargetName(cr) $(ROOTLESSLIB)
+
+BundleProgramTarget(cr,XDarwinApp,$(CRDIRS),$(QUARTZDIR)/cr/crScreen.o, \
+	$(CRLIBS),-framework ApplicationServices -framework Cocoa \
+	-framework Carbon -ObjC,$(XDARWINAPPDIR)/Resources)
+
+FSDIRS = $(QUARTZDIR)/fullscreen $(SHADOWDIR)
+FSLIBS = $(QUARTZDIR)/fullscreen/LibraryTargetName(fullscreen) $(SHADOW)
+
+BundleProgramTarget(fullscreen,XDarwinApp,$(FSDIRS), \
+	$(QUARTZDIR)/fullscreen/fullscreen.o,$(FSLIBS), \
+	-framework ApplicationServices,$(XDARWINAPPDIR)/Resources)
+
+/*
+ * GLX bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+BundleProgramTarget(glxAGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+	GL/apple/libAGLcore.a, \
+	-framework AGL -framework OpenGL,$(XDARWINAPPDIR)/Resources)
+
+#if BuildAppleDRI
+BundleProgramTarget(glxCGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+	GL/apple/libCGLcore.a, \
+	-framework OpenGL $(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+BundleProgramTarget(glxMesa,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+	GL/mesa/GLcore/libGLcore.a,NullParameter,$(XDARWINAPPDIR)/Resources)
+
+#else /* !DarwinQuartzSupport */
+
+#define ServerToInstall XDarwin
+
+#endif /* DarwinQuartzSupport */
+
+#endif /* XDarwinServer */
+
+
+CFBSUBDIRS = $(CFB8SUBDIR) $(CFB16SUBDIR) $(CFB24SUBDIR) $(CFB32SUBDIR)
+MIEXTDIRS = $(SHADOWDIR) $(LAYERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+IPLANDIRS = $(IPLAN2P2DIR) $(IPLAN2P4DIR) $(IPLAN2P8DIR)
+DDXDIRS = $(DECWSDDXDIR) $(SUNDDXDIR) $(LYNXDDXDIR) \
+	  $(HPDDXDIR) $(XFREE86DDXDIR) $(XWINDDXDIR) $(DARWINDDXDIR) \
+	  $(XVFBDDXDIR) $(XNESTDDXDIR) $(XDMXDDXDIR)
+SUBDIRS = $(STDDIRS) $(MFBSUBDIR) $(CFBSUBDIRS) \
+	  $(IPLANDIRS) $(ILBMDIR) $(AFBSUBDIR) \
+          $(DDXDIRS) $(FBSUBDIR) $(KDRIVEDIRS) $(MIEXTDIRS)
+
+#if  defined(ServerToInstall) && !defined(OS2Architecture)
+install::
+	-(cd $(DESTDIR)$(BINDIR); $(RM) X; $(LN) ServerToInstall X)
+#endif
+
+#define IHaveSubdirs
+
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(SUBDIRS))
+LintSubdirs($(SUBDIRS))
+
+ForceSubdirs($(DEPDIRS) $(SUBDIRS))
+
+DEFAULTFONTPATH = DefaultFontPath
+EXTRAMANDEFS = -D__default_font_path__="`echo $(DEFAULTFONTPATH) | sed -e 's/,/, /g'`"
+
+InstallManPage(Xserver,$(MANDIR))
+
+#if MakeDllModules && DoLoadableServer && \
+        (defined(SunArchitecture) && defined(SVR4Architecture))
+XCOMM Hackery for building dlopen-able .so modules on Solaris
+
+AllTarget(linker-deps)
+
+LINKER_DEPS_DIRS = $(SUBDIRS) $(FONTLIBSRC)
+
+XCOMM After everything is built, run through and generate linker dependencies
+linker-deps:
+        RunPerlScript($(XF86SRC)/os-support/sunos/find_deps.pl,-R ProjectRoot $(LINKER_DEPS_DIRS))
+	for i in $(LINKER_DEPS_DIRS) ; do \
+	  echo "relinking with dependency flags in $(CURRENT_DIR)/$$i..."; \
+                MakeNamedTargetSubdir($$i,NullParameter,all) ; \
+        done
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/SunExt/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,68 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)Imakefile 1.2     05/11/08 SMI"
+XCOMM
+XCOMM Additional Sun-specific extensions
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+#define IHaveSubdirs
+SUBDIRS = modules
+#endif
+
+    INCLUDES = -I. -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) 
+
+     DEFINES = $(EXT_DEFINES) 
+
+XCOMM SolarisIA (interactive priority class) extension
+   SOLIA_SRCS = interactive.c
+   SOLIA_OBJS = interactive.o
+
+SpecialCObjectRule(interactive,NullParameter,$(CONNECTION_FLAGS) -DXSERV_t)
+
+         SRCS = $(SOLIA_SRCS)
+
+         OBJS = $(SOLIA_OBJS)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(sunext,$(OBJS))
+LintLibraryTarget(sunext,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/SunExt/interactive.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,881 @@
+/*
+ * 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.
+ */
+
+#pragma ident   "@(#)interactive.c 35.14     05/08/31 SMI"
+
+/************************************************************
+	Basic boilerplate extension.
+
+	This file also contains the code to make the priocntl on behalf
+	of the clients.
+
+	Note that ChangePriority also sets the last client with focus
+	to the normal priority.
+
+	If there are knobs to be added to the system, for say the nice
+	values for the IA class, they would be added here.
+********************************************************/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#ifdef XFree86LOADER
+# include "xf86_ansic.h"
+#else
+#include <errno.h>
+#include <sys/types.h>
+#include <stdio.h>
+#endif
+
+/* We shouldn't be including these in an XFree86LOADER module, but there's
+ * no way this extension will work without them, so we go ahead and do it.
+ */
+#include <sys/priocntl.h>
+#include <sys/iapriocntl.h>
+#ifdef XFree86LOADER
+#undef uid_t
+extern uid_t getuid(void);
+extern int setegid(gid_t);
+#else
+#include <unistd.h>
+#endif
+
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "os.h"
+#include "dixstruct.h"
+#include "windowstr.h"
+#include "inputstr.h"
+#include "extnsionst.h"
+#define _XIA_SERVER_
+#include <X11/extensions/interactive.h>
+#include <X11/Xfuncproto.h>
+#include "dix.h"
+
+#define UNSET_PRIORITY 		0
+#define SET_PRIORITY		1
+#define SET_INTERACTIVE 	2
+
+#define SERVER			0x1
+#define WMGR			0x2
+#define BOTH			0x3
+
+typedef struct _ClientProcessInfo {
+	int count;
+	ConnectionPidPtr pids;
+} ClientProcessRec, * ClientProcessPtr;
+
+static int ProcIADispatch(ClientPtr client), SProcIADispatch(ClientPtr client);
+static int ProcIASetProcessInfo(ClientPtr client), SProcIASetProcessInfo(ClientPtr client);
+static int ProcIAGetProcessInfo(ClientPtr client), SProcIAGetProcessInfo(ClientPtr client);
+static int ProcIAQueryVersion(ClientPtr client), SProcIAQueryVersion(ClientPtr client);
+static void IACloseDown(ExtensionEntry *ext);
+static void IAClientStateChange(CallbackListPtr *pcbl, pointer nulldata, pointer calldata);
+
+static int InitializeClass(void );
+static void SetIAPrivate(int*);
+static void ChangeInteractive(ClientPtr);
+static int SetPriority(int, int);
+static void UnsetLastPriority(ClientProcessPtr LastPid); 
+static void ChangePriority(register ClientPtr client);
+
+static int SetClientPrivate(ClientPtr client, ConnectionPidPtr stuff, int length);
+static void FreeProcessList(ClientPtr client);
+/* static int LocalConnection(OsCommPtr); */
+static int PidSetEqual(ClientProcessPtr, ClientProcessPtr);
+
+static int IAWrapProcVectors(void);
+static int IAUnwrapProcVectors(void);
+
+static CARD32 IAInitTimerCall(OsTimerPtr timer,CARD32 now,pointer arg);
+
+static iaclass_t 	IAClass;
+static id_t		TScid;
+static ClientProcessPtr	LastPids = NULL;
+static int 		specialIAset = 0;
+static int 		ia_nice = IA_BOOST;
+static Bool 		InteractiveOS = xTrue;
+static ClientPtr 	wmClientptr = NULL;
+static unsigned long 	IAExtensionGeneration = 0;
+static OsTimerPtr 	IAInitTimer = NULL;
+static int (* IASavedProcVector[256]) (ClientPtr client);
+
+typedef struct {
+    ClientProcessPtr    process; /* Process id information */    
+    Bool		wmgr;
+} IAClientPrivateRec, *IAClientPrivatePtr;
+
+static int	IAClientPrivateIndex;
+
+#define GetIAClient(pClient)    ((IAClientPrivatePtr) (pClient)->devPrivates[IAClientPrivateIndex].ptr)
+#define GetConnectionPids(pClient)	(GetIAClient(pClient)->process)
+
+/* Set via xorg.conf option in loadable module */
+int IADebugLevel = 0;
+
+#define IA_DEBUG(level, func)	\
+	if (IADebugLevel >= level) { func; } else (void)(0)
+
+#define IA_DEBUG_BASIC		1
+#define IA_DEBUG_PRIOCNTL	3
+
+void
+IAExtensionInit(void)
+{
+    IA_DEBUG(IA_DEBUG_BASIC, 
+      LogMessage(X_INFO, "SolarisIA: Initializing (generation %d)\n",
+	IAExtensionGeneration));
+
+    if (IAExtensionGeneration == serverGeneration)
+	return;
+
+    InteractiveOS=xFalse;
+
+    if (InitializeClass() != Success)
+	return;
+
+    if (SetPriority(P_MYID, SET_INTERACTIVE) != Success)
+	return;
+
+    if (SetPriority(P_MYID, SET_PRIORITY) != Success)
+	return;
+
+    IAClientPrivateIndex = AllocateClientPrivateIndex();
+    if (IAClientPrivateIndex < 0)
+	return;
+    if (!AllocateClientPrivate (IAClientPrivateIndex,
+				      sizeof (IAClientPrivateRec)))
+        return;
+
+    if (!AddCallback(&ClientStateCallback, IAClientStateChange, NULL))
+        return;
+
+    if (IAWrapProcVectors() != 0)
+	return;
+
+    if (!AddExtension(IANAME, IANumberEvents, IANumberErrors,
+				 ProcIADispatch, SProcIADispatch,
+				 IACloseDown, StandardMinorOpcode))
+	return;
+
+    /* InitExtensions is called before InitClientPrivates(serverClient)
+       so we set this timer to callback as soon as we hit WaitForSomething
+       to initialize the serverClient */
+    IAInitTimer = TimerSet(IAInitTimer, 0, 1, IAInitTimerCall, NULL);
+
+    specialIAset = 0;
+    InteractiveOS = xTrue;
+    IAExtensionGeneration = serverGeneration;
+
+    IA_DEBUG(IA_DEBUG_BASIC, 
+      LogMessage(X_INFO, "SolarisIA: Finished initializing (generation %d)\n",
+	IAExtensionGeneration));
+}
+
+/* Called when we first hit WaitForSomething to initialize serverClient */
+static CARD32 
+IAInitTimerCall(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+    ConnectionPidRec serverPid;
+
+    if (InteractiveOS != xTrue)
+	return 0;
+
+    GetConnectionPids(serverClient) = NULL;
+    GetIAClient(serverClient)->wmgr = FALSE;
+
+    serverPid = getpid();
+    SetClientPrivate(serverClient, &serverPid, 1);
+
+    ChangePriority(serverClient);
+    return 0;
+}
+
+/* Called when new client connects or existing client disconnects */
+static void
+IAClientStateChange(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+    NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+    ClientPtr pClient = pci->client;
+    ClientProcessPtr CurrentPids;
+
+    switch (pClient->clientState) {
+    case ClientStateGone:
+    case ClientStateRetained:
+	CurrentPids = GetConnectionPids(pClient);
+
+	if (pClient==wmClientptr) {
+	    IA_DEBUG(IA_DEBUG_BASIC,
+	      LogMessage(X_INFO, "SolarisIA: WindowManager closed (pid %d)\n",
+	      (CurrentPids && CurrentPids->pids) ? CurrentPids->pids[0] : -1));
+	    wmClientptr=NULL;
+	}
+
+	if (CurrentPids && LastPids && PidSetEqual(CurrentPids, LastPids))
+	    LastPids=NULL;
+
+	FreeProcessList(pClient);
+	GetIAClient(pClient)->wmgr = FALSE;
+	break;
+	
+    case ClientStateInitial:
+	GetConnectionPids(pClient) = NULL;
+	GetIAClient(pClient)->wmgr = FALSE;
+	break;
+
+    default:
+	break;
+    }
+} 
+
+
+static int
+ProcIADispatch (ClientPtr client)
+{
+    REQUEST(xReq);
+    switch (stuff->data)
+    {
+    case X_IAQueryVersion:
+	return ProcIAQueryVersion(client);
+    case X_IASetProcessInfo:
+	return ProcIASetProcessInfo(client);
+    case X_IAGetProcessInfo:
+	return ProcIAGetProcessInfo(client);
+    default:
+	return BadRequest;
+    }
+}
+
+static int
+ProcIAQueryVersion(ClientPtr client)
+{
+    REQUEST(xIAQueryVersionReq);
+    xIAQueryVersionReply rep;
+
+    REQUEST_SIZE_MATCH(xIAQueryVersionReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.majorVersion = IA_MAJOR_VERSION;
+    rep.minorVersion = IA_MINOR_VERSION;
+    WriteToClient(client, sizeof(xIAQueryVersionReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+static int
+ProcIASetProcessInfo(ClientPtr client)
+{
+
+    REQUEST(xIASetProcessInfoReq);
+    register int length;
+    static uid_t ServerUid = -1;
+
+    REQUEST_AT_LEAST_SIZE(xIASetProcessInfoReq);
+
+    if (ServerUid < 0)
+	ServerUid=getuid();
+
+    if ((stuff->flags & INTERACTIVE_INFO) && 
+	(stuff->uid==ServerUid || ServerUid==0 || stuff->uid==0) &&
+	LocalClient(client)) {
+	length=stuff->length-(sizeof(xIASetProcessInfoReq)>>2);
+	SetClientPrivate(client, (ConnectionPidPtr)&stuff[1], length);
+	ChangeInteractive(client);
+    }
+
+    if ((stuff->flags & INTERACTIVE_SETTING) && 
+	(stuff->uid==ServerUid || ServerUid==0) &&
+	LocalClient(client)) {
+	SetIAPrivate((int*)&stuff[1]);
+    }
+
+    return (client->noClientException);
+}
+
+static int
+ProcIAGetProcessInfo(ClientPtr client)
+{
+    ClientProcessPtr CurrentPids=GetConnectionPids(client);
+    REQUEST(xIAGetProcessInfoReq);
+    xIAGetProcessInfoReply rep;
+    register int length=0;
+    caddr_t write_back=NULL;
+
+    REQUEST_SIZE_MATCH(xIAGetProcessInfoReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    if (stuff->flags & INTERACTIVE_INFO) {
+	    if (!CurrentPids) 
+    		rep.count = 0;
+	    else {
+    		rep.count = CurrentPids->count;
+       		length = rep.count << 2;
+	        write_back=(caddr_t)CurrentPids->pids;
+	    }
+    }
+    if (stuff->flags & INTERACTIVE_SETTING) {
+	rep.count=1;
+	length=rep.count << 2;
+	write_back=(caddr_t)&ia_nice;
+    }
+
+    WriteToClient(client, sizeof(xIAGetProcessInfoReply), (char *)&rep);
+    WriteToClient(client, length, write_back);
+    return (client->noClientException);
+}
+
+static void
+IACloseDown(ExtensionEntry *ext)
+{
+    int i;
+
+    InteractiveOS=xFalse;
+
+    IAUnwrapProcVectors();
+
+    DeleteCallback(&ClientStateCallback, IAClientStateChange, NULL);
+}
+
+/* 
+   The SProc* functions are here for completeness. They should never get
+   called. But since they do the server has to eat the request and
+   return thanks for sharing.
+*/
+
+/*ARGSUSED*/
+static int
+SProcIADispatch (ClientPtr client)
+{
+    REQUEST(xReq);
+    switch (stuff->data)
+    {
+    case X_IAQueryVersion:
+	return SProcIAQueryVersion(client);
+    case X_IASetProcessInfo:
+	return SProcIASetProcessInfo(client);
+    case X_IAGetProcessInfo:
+	return SProcIAGetProcessInfo(client);
+    default:
+	return BadRequest;
+    }
+}
+
+/*ARGSUSED*/
+static int
+SProcIAQueryVersion(ClientPtr client)
+{
+    REQUEST_SIZE_MATCH(xIAQueryVersionReq);
+    return (client->noClientException);
+}
+ 
+/*ARGSUSED*/
+static int
+SProcIASetProcessInfo(ClientPtr client)
+{
+    REQUEST(xIASetProcessInfoReq);
+    REQUEST_AT_LEAST_SIZE(xIASetProcessInfoReq);
+
+    return (client->noClientException);
+}
+
+/*ARGSUSED*/
+static int
+SProcIAGetProcessInfo(ClientPtr client)
+{
+    REQUEST(xIAGetProcessInfoReq);
+    REQUEST_SIZE_MATCH(xIAGetProcessInfoReq);
+
+    return (client->noClientException);
+}
+
+static void
+ChangeInteractive(ClientPtr client)
+{
+   ClientProcessPtr CurrentPids=GetConnectionPids(client);
+   register int count;
+
+   if (InteractiveOS==xFalse)
+        return;
+
+   if (!CurrentPids || !CurrentPids->pids)
+	return;
+
+   count=CurrentPids->count;
+
+   while(count--)
+      SetPriority(CurrentPids->pids[count], SET_INTERACTIVE);
+}
+
+/*
+Loop through pids associated with client. Magically make last focus
+group go non-interactive -IA_BOOST.
+*/
+static void
+ChangePriority(register ClientPtr client)
+{
+   ClientProcessPtr CurrentPids=GetConnectionPids(client);
+   register int count;
+
+   /* If no pid info for current client make sure to unset last focus group. */
+   /* This can happen if we have a remote client with focus or if the client */
+   /* is statically linked or if it is using a down rev version of libX11.   */
+   if (!CurrentPids || !CurrentPids->pids) {
+	if (LastPids && LastPids->pids) {
+	    UnsetLastPriority(LastPids);
+	    LastPids=NULL;
+	}
+	return;
+   }
+
+   /* Make sure server or wmgr isn't unset by testing for them */
+   /* this way LastPids is never set to point to the server or */
+   /* wmgr pid.						       */
+   if ((client->index==serverClient->index || 
+     GetIAClient(client)->wmgr==xTrue)) {
+
+       if ((specialIAset < BOTH) && CurrentPids->pids) {
+
+	   if (client->index == serverClient->index) {
+	       specialIAset |= SERVER;	
+	   }
+	   else {
+	       specialIAset |= WMGR; 
+	   }
+	   SetPriority(CurrentPids->pids[0], SET_PRIORITY);
+       }
+       return;
+   }
+
+   if (LastPids && LastPids->pids) {
+	if (CurrentPids && LastPids && PidSetEqual(CurrentPids, LastPids))
+		return;				/*Shortcut. Focus changed
+						  between two windows with
+						  same pid */
+	UnsetLastPriority(LastPids);
+   }
+  
+   count=CurrentPids->count;
+   while(count--)
+      SetPriority(CurrentPids->pids[count], SET_PRIORITY);
+   LastPids=CurrentPids;
+}
+
+static void
+UnsetLastPriority(ClientProcessPtr LastPids)
+{
+    register int LastPidcount=LastPids->count;
+
+    while(LastPidcount--)
+      	SetPriority(LastPids->pids[LastPidcount], UNSET_PRIORITY);
+}
+
+static int
+InitializeClass(void)
+{
+   pcinfo_t  pcinfo;
+
+   /* Get TS class information 					*/ 
+
+   strcpy (pcinfo.pc_clname, "TS");
+   priocntl(0, 0, PC_GETCID, (caddr_t)&pcinfo); 
+   TScid=pcinfo.pc_cid;
+
+   /* Get IA class information */
+   strcpy (pcinfo.pc_clname, "IA");
+   if ((priocntl(0, 0, PC_GETCID, (caddr_t)&pcinfo)) == -1)
+        return ~Success;
+ 
+   IAClass.pc_cid=pcinfo.pc_cid;
+   ((iaparms_t*)IAClass.pc_clparms)->ia_uprilim=IA_NOCHANGE;
+   ((iaparms_t*)IAClass.pc_clparms)->ia_upri=IA_NOCHANGE;
+
+   return Success;
+}
+
+static int
+SetPriority(int pid, int cmd)
+{
+    pcparms_t pcinfo;
+    long	ret;
+    gid_t	usr_egid = getegid();
+
+    if ( setegid(0) < 0 )
+	Error("Error in setting egid to 0");
+
+
+    pcinfo.pc_cid=PC_CLNULL;
+    if ((priocntl(P_PID, pid, PC_GETPARMS, (caddr_t)&pcinfo)) < 0) {
+	if ( setegid(usr_egid) < 0 )
+	    Error("Error in resetting egid");
+
+	return ~Success; /* Scary time; punt */
+    }
+
+    /* If process is in TS or IA class we can safely set parameters */
+    if ((pcinfo.pc_cid == IAClass.pc_cid) || (pcinfo.pc_cid == TScid)) {
+
+       switch (cmd) {
+       case UNSET_PRIORITY:
+   		((iaparms_t*)IAClass.pc_clparms)->ia_mode=IA_INTERACTIVE_OFF;
+   		((iaparms_t*)IAClass.pc_clparms)->ia_nice-=ia_nice;
+		break;
+       case SET_PRIORITY:
+   		((iaparms_t*)IAClass.pc_clparms)->ia_mode=IA_SET_INTERACTIVE;
+   		((iaparms_t*)IAClass.pc_clparms)->ia_nice+=ia_nice;
+		break;
+       case SET_INTERACTIVE: 
+      /* If this returns true, the process is already in the IA class */
+      /* So just return.						   */
+		 if ( pcinfo.pc_cid == IAClass.pc_cid)
+			return Success;
+
+   		((iaparms_t*)IAClass.pc_clparms)->ia_mode=IA_INTERACTIVE_OFF;
+   		((iaparms_t*)IAClass.pc_clparms)->ia_nice=-ia_nice;
+		break;
+       }
+
+	if ( priocntl(P_PID, pid, PC_SETPARMS, (caddr_t)&IAClass) == -1 )
+	    {
+	    ret = ~Success;
+	    }
+	else
+	    {
+	    ret = Success;
+	    }
+
+
+	IA_DEBUG(IA_DEBUG_PRIOCNTL,
+	{
+	    const char *cmdmsg;
+
+	    switch (cmd) {
+	    case UNSET_PRIORITY:   cmdmsg = "UNSET_PRIORITY"; break;
+	    case SET_PRIORITY:     cmdmsg = "SET_PRIORITY"; break;
+	    case SET_INTERACTIVE:  cmdmsg = "SET_INTERACTIVE"; break;
+	    default:		   cmdmsg = "UNKNOWN_CMD!!!"; break;
+	    }
+	    LogMessage(X_INFO, "SolarisIA: SetPriority(%d, %s): %s\n", 
+	      pid, cmdmsg, (ret == Success) ? "succeeeded" : "failed");
+	});
+
+
+	if ( setegid(usr_egid) < 0 )
+	    Error("Error in resetting egid");
+
+	return ret;
+    }
+
+    return ~Success;
+}
+
+static void
+SetIAPrivate(int * value)
+{
+	ia_nice=*value;
+}
+
+/*****************************************************************************
+ * Various utility functions - in Xsun these lived in Xserver/os/process.c
+ */
+
+/* In Xsun we used the osPrivate in OsCommPtr, so this was SetOsPrivate. */
+static int
+SetClientPrivate(ClientPtr client, ConnectionPidPtr stuff, int length)
+{	
+    ClientProcessPtr	cpp;
+
+    FreeProcessList(client);
+	
+    cpp = (ClientProcessPtr)xalloc(sizeof(ClientProcessRec));
+
+    if (cpp == NULL)
+	return BadAlloc;
+
+    cpp->pids = (ConnectionPidPtr)xalloc(sizeof(ConnectionPidRec)*length);  
+
+    if (cpp->pids == NULL) {
+	xfree(cpp);
+	return BadAlloc;
+    }
+
+    GetConnectionPids(client) = cpp;
+    cpp->count = length;
+    memcpy(cpp->pids, stuff, sizeof(ConnectionPidRec)*length);
+    
+    return Success;
+}
+
+static void
+FreeProcessList(ClientPtr client)
+{
+    ClientProcessPtr	cpp = GetConnectionPids(client);
+    
+    if (cpp == NULL)
+	return;
+
+    if ( LastPids == cpp )
+	LastPids = NULL;
+
+    if (cpp->pids != NULL)
+	xfree(cpp->pids);
+
+    xfree(cpp);
+
+    GetConnectionPids(client) = NULL;
+}
+
+/*
+        Check to see that all in current (a) are in
+        last (b). And that a and b have the same number
+        of members in the set.
+*/
+int
+PidSetEqual(ClientProcessPtr a, ClientProcessPtr b)
+{
+        register int currentcount=a->count;
+        register int lastcount=b->count;
+        int retval;
+
+        if (currentcount != lastcount)  
+                return 0; /* definately NOT the same set */
+
+        while(currentcount--) {
+            retval=0;
+            while(lastcount--)
+                if (a->pids[currentcount]==b->pids[lastcount]) {
+                        retval=1;
+                        break;
+                }
+            if (retval==0)
+                return retval;
+            lastcount=b->count;
+        }
+
+        return retval;
+}
+
+
+/*****************************************************************************
+ * Wrappers for normal procs - in Xsun we modified the original procs directly
+ * in dix, but here we wrap them for a small performance loss but a large
+ * increase in maintainability and ease of porting to new releases.
+ */
+
+static int
+IAProcSetInputFocus(ClientPtr client)
+{
+    int res;
+    Window focusID;
+    register WindowPtr focusWin;
+    REQUEST(xSetInputFocusReq);
+
+    res = (*IASavedProcVector[X_SetInputFocus])(client);
+    if ((res != Success) || (InteractiveOS != xTrue))
+	return res;
+
+    focusID = stuff->focus;
+
+    if ((focusID == None) || (focusID == PointerRoot)) {
+        focusWin = (WindowPtr)focusID;
+    } else {
+	if (!(focusWin = SecurityLookupWindow(focusID, client,
+                                               SecurityReadAccess)))
+	    return BadWindow;
+    }
+
+    if ((focusWin != NullWindow) && (focusWin != PointerRootWin)) {
+	register ClientPtr requestee;
+        ClientProcessPtr wmPid=NULL;
+        ClientProcessPtr RequesteePids=NULL;
+ 
+        if (wmClientptr)
+                wmPid=GetConnectionPids(wmClientptr);
+ 
+        requestee=wClient(focusWin);
+        RequesteePids=GetConnectionPids(requestee);
+ 
+        /* if wm is not setting focus to himself */
+ 
+        if (wmPid && RequesteePids && !PidSetEqual(wmPid, RequesteePids))
+            ChangePriority(requestee);
+        else  {
+ 
+            /* If wm is setting focus to himself and Lastpids exists and
+               LastPids pids are valid Unset the priority for the LastPids
+               focus group */
+ 
+            if (wmPid && RequesteePids && PidSetEqual(wmPid, RequesteePids))
+                if (LastPids && LastPids->pids) {
+                    UnsetLastPriority(LastPids);
+                    LastPids=NULL;
+                }
+        }
+    }
+
+    return res;
+}
+
+static int
+IAProcSendEvent(ClientPtr client)
+{
+    int res;
+    REQUEST(xSendEventReq);
+
+    res = (*IASavedProcVector[X_SendEvent])(client);
+    if ((res != Success) || (InteractiveOS != xTrue))
+	return res;
+
+    if ((InteractiveOS==xTrue) &&
+        (client == wmClientptr) &&
+        (stuff->event.u.u.type == ClientMessage) &&
+        (stuff->event.u.u.detail == 32) ) {
+ 
+        register ClientPtr requestee;
+        ClientProcessPtr wmPid=NULL;
+        ClientProcessPtr RequesteePids=NULL;
+	WindowPtr pWin;
+
+	if (stuff->destination == PointerWindow)
+	    pWin = GetSpriteWindow();
+	else if (stuff->destination == InputFocus)
+	{
+	    WindowPtr inputFocus = inputInfo.keyboard->focus->win;
+
+	    if (inputFocus == NoneWin)
+		return Success;
+	    
+	 /* If the input focus is PointerRootWin, send the event to where
+	    the pointer is if possible, then perhaps propogate up to root. */
+	    if (inputFocus == PointerRootWin)
+		inputFocus = GetCurrentRootWindow();
+	    
+	    if (IsParent(inputFocus, GetSpriteWindow()))
+		pWin = GetSpriteWindow();
+	    else
+		pWin = inputFocus;
+	}
+	else
+	    pWin = SecurityLookupWindow(stuff->destination, client,
+	    				SecurityReadAccess);
+	if (!pWin)
+	    return BadWindow;
+ 
+        if (wmClientptr)
+	    wmPid=GetConnectionPids(wmClientptr);
+        requestee=wClient(pWin);
+        RequesteePids=GetConnectionPids(requestee);
+ 
+        /* if wm is not setting focus to himself */
+        if (wmPid && RequesteePids && !PidSetEqual(wmPid, RequesteePids)) {
+            ChangePriority(requestee);
+	}
+	else {
+ 
+            /* If wm is setting focus to himself and Lastpids exists and
+               LastPids pids are valid Unset the priority for the LastPids
+               focus group */
+ 
+                if (LastPids && LastPids->pids) {
+                    UnsetLastPriority(LastPids);
+                    LastPids=NULL;
+                }
+        }
+    }
+    return res;
+}
+
+static Bool
+IAProcChangeWindowAttributes(ClientPtr client)
+{
+    REQUEST(xChangeWindowAttributesReq);
+
+    if ((InteractiveOS==xTrue) && (stuff->valueMask & CWEventMask) &&
+	(GetIAClient(client)->wmgr == xFalse) ) {
+
+	register XID *pVlist = (XID *) &stuff[1];
+	register Mask tmask = stuff->valueMask;
+	register Mask index2;
+
+	while (tmask) {
+	    index2 = (Mask) lowbit (tmask);
+	    tmask &= ~index2;
+	    if (index2 == CWEventMask) {
+		break;
+	    }
+	    pVlist++;
+	}
+
+	if ((index2 == CWEventMask) && (*pVlist & SubstructureRedirectMask)) {
+	    IA_DEBUG(IA_DEBUG_BASIC,
+	    ClientProcessPtr CurrentPids=GetConnectionPids(client);
+
+	    LogMessage(X_INFO, "SolarisIA: WindowManager detected (pid %d)\n",
+	      (CurrentPids && CurrentPids->pids) ? CurrentPids->pids[0] : -1));
+
+
+	    GetIAClient(client)->wmgr=xTrue;
+	    wmClientptr = client;
+	    ChangePriority(client);
+	}
+    }
+
+    return (*IASavedProcVector[X_ChangeWindowAttributes])(client);
+}
+
+
+static int 
+IAWrapProcVectors(void)
+{
+    IASavedProcVector[X_SetInputFocus] = ProcVector[X_SetInputFocus];
+    ProcVector[X_SetInputFocus] = IAProcSetInputFocus;
+
+    IASavedProcVector[X_SendEvent] = ProcVector[X_SendEvent];
+    ProcVector[X_SendEvent] = IAProcSendEvent;
+
+    IASavedProcVector[X_ChangeWindowAttributes] 
+      = ProcVector[X_ChangeWindowAttributes];
+    ProcVector[X_ChangeWindowAttributes] = IAProcChangeWindowAttributes;
+
+    return 0;
+}
+
+static int 
+IAUnwrapProcVectors(void)
+{
+    ProcVector[X_SetInputFocus] = IASavedProcVector[X_SetInputFocus];
+    ProcVector[X_SendEvent] = IASavedProcVector[X_SendEvent];
+    ProcVector[X_ChangeWindowAttributes] = IASavedProcVector[X_ChangeWindowAttributes];
+
+    return 0;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/SunExt/modules/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,60 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)Imakefile 1.2     05/11/08 SMI"
+XCOMM
+XCOMM Additional Sun-specific extensions
+
+#define IHaveModules
+#include <Server.tmpl>
+
+     INCLUDES = -I. -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+	-I$(SERVERSRC)/Xext
+
+      DEFINES = $(EXT_DEFINES)
+
+XCOMM SolarisIA (interactive priority class) extension
+XCOMM (Yes, this breaks all the rules of XFree86/Xorg loadable modules,
+XCOMM  so should not go back to X.Org CVS in this form, but it works for now.)
+
+   SOLIA_SRCS = interactive.c iamodule.c
+   SOLIA_OBJS = interactive.o iamodule.o
+
+LinkSourceFile(interactive.c,..)
+SpecialCObjectRule(interactive,NullParameter,$(CONNECTION_FLAGS) -DXSERV_t)
+
+ModuleObjectRule()
+LibraryModuleTarget(IA,$(SOLIA_OBJS))
+InstallLibraryModule(IA,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(IA,$(DRIVERSDKMODULEDIR),extensions)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/SunExt/modules/iamodule.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* "@(#)iamodule.c	1.2	05/11/08" */
+/* $Id$ */
+
+#include "xf86_ansic.h"
+#include "xf86Module.h"
+#include "xf86Opt.h"
+#include "modinit.h"
+
+#include "interactive.h"
+
+static MODULESETUPPROTO(IASetup);
+
+extern void IAExtensionInit(INITARGS);
+
+ExtensionModule IAExt =
+{
+    IAExtensionInit,
+    IANAME,
+    NULL,
+    NULL,
+    NULL
+};
+
+static XF86ModuleVersionInfo VersRec =
+{
+        "IANAME",
+        MODULEVENDORSTRING,
+        MODINFOSTRING1,
+        MODINFOSTRING2,
+        XORG_VERSION_CURRENT,
+        1, 0, 0,
+        ABI_CLASS_EXTENSION,
+        ABI_EXTENSION_VERSION,
+        MOD_CLASS_NONE,
+        {0,0,0,0}
+};
+
+XF86ModuleData IAModuleData = { &VersRec, IASetup, NULL };
+
+static pointer
+IASetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    if (opts) {
+	pointer o = xf86FindOption(opts, "IADebugLevel");
+	if (o) {
+	    extern int IADebugLevel;
+	    IADebugLevel = xf86SetIntOption(opts, "IADebugLevel", 0);
+	}
+    }
+    LoadExtension(&IAExt, FALSE);
+
+    /* Need a non-NULL return */
+    return (pointer)1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/Xext/extmod/modinit.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,281 @@
+/* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.c,v 1.16 2002/03/06 21:12:33 mvojkovi Exp $ */
+
+/*
+ *
+ * Copyright (c) 1997 Matthieu Herrb
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Matthieu Herrb not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Matthieu Herrb makes no
+ * representations about the suitability of this software for any purpose.
+ *  It is provided "as is" without express or implied warranty.
+ *
+ * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+
+#include "xf86Module.h"
+#include "xf86Opt.h"
+
+#include <X11/Xproto.h>
+
+#include "modinit.h"
+#include "globals.h"
+
+#ifdef XEVIE
+extern void XevieExtensionInit (INITARGS);
+# define _XEVIE_SERVER_
+# include "Xevie.h"
+# include "Xeviestr.h"
+#endif
+
+static MODULESETUPPROTO(extmodSetup);
+
+/*
+ * Array describing extensions to be initialized
+ */
+ExtensionModule extensionModules[] = {
+#ifdef SHAPE
+    {
+	ShapeExtensionInit,
+	SHAPENAME,
+	&noShapeExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef MULTIBUFFER
+    {
+	MultibufferExtensionInit,
+	MULTIBUFFER_PROTOCOL_NAME,
+	&noMultibufferExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef MITMISC
+    {
+	MITMiscExtensionInit,
+	MITMISCNAME,
+	&noMITMiscExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef notyet
+    {
+	XTestExtensionInit,
+	XTestExtensionName,
+	&noTestExtensions,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef BIGREQS
+     {
+	BigReqExtensionInit,
+	XBigReqExtensionName,
+	&noBigReqExtension,
+	NULL,
+	NULL
+     },
+#endif
+#ifdef XSYNC
+    {
+	SyncExtensionInit,
+	SYNC_NAME,
+	&noSyncExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef SCREENSAVER
+    {
+	ScreenSaverExtensionInit,
+	ScreenSaverName,
+	&noScreenSaverExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef XCMISC
+    {
+	XCMiscExtensionInit,
+	XCMiscExtensionName,
+	&noXCMiscExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef XF86VIDMODE
+    {
+	XFree86VidModeExtensionInit,
+	XF86VIDMODENAME,
+	&noXFree86VidModeExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef XF86MISC
+    {
+	XFree86MiscExtensionInit,
+	XF86MISCNAME,
+	&noXFree86MiscExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef XFreeXDGA
+    {
+	XFree86DGAExtensionInit,
+	XF86DGANAME,
+	&noXFree86DGAExtension,
+	XFree86DGARegister,
+	NULL
+    },
+#endif
+#ifdef DPMSExtension
+    {
+	DPMSExtensionInit,
+	DPMSExtensionName,
+	&noDPMSExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef FONTCACHE
+    {
+	FontCacheExtensionInit,
+	FONTCACHENAME,
+	&noFontCacheExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef TOGCUP
+    {
+	XcupExtensionInit,
+	XCUPNAME,
+	&noXcupExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef EVI
+    {
+	EVIExtensionInit,
+	EVINAME,
+	&noEVIExtension,
+	NULL,
+	NULL
+    },
+#endif
+#ifdef XV
+    {
+	XvExtensionInit,
+	XvName,
+	&noXvExtension,
+	XvRegister,
+	NULL
+    },
+    {
+        XvMCExtensionInit,
+        XvMCName,
+        &noXvExtension,
+        NULL,
+        NULL
+    },
+#endif
+#ifdef RES
+    {
+        ResExtensionInit,
+        XRES_NAME, 
+        &noResExtension,
+        NULL,
+        NULL
+    },
+#endif
+#ifdef XEVIE
+    {
+       XevieExtensionInit,
+       XEVIENAME,
+       NULL,
+       NULL,
+       NULL
+    },
+#endif
+
+    {				/* DON'T delete this entry ! */
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL
+    }
+};
+
+static XF86ModuleVersionInfo VersRec =
+{
+	"extmod",
+	MODULEVENDORSTRING,
+	MODINFOSTRING1,
+	MODINFOSTRING2,
+	XORG_VERSION_CURRENT,
+	1, 0, 0,
+	ABI_CLASS_EXTENSION,
+	ABI_EXTENSION_VERSION,
+	MOD_CLASS_EXTENSION,
+	{0,0,0,0}
+};
+
+/*
+ * Data for the loader
+ */
+XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL };
+
+static pointer
+extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    int i;
+
+    /* XXX the option stuff here is largely a sample/test case */
+
+    for (i = 0; extensionModules[i].name != NULL; i++) {
+	if (opts) {
+	    char *s;
+	    s = (char *)xalloc(strlen(extensionModules[i].name) + 5);
+	    if (s) {
+		pointer o;
+		strcpy(s, "omit");
+		strcat(s, extensionModules[i].name);
+		o = xf86FindOption(opts, s);
+		xfree(s);
+		if (o) {
+		    xf86MarkOptionUsed(o);
+		    continue;
+		}
+	    }
+	}
+	LoadExtension(&extensionModules[i], FALSE);
+    }
+    /* Need a non-NULL return */
+    return (pointer)1;
+}
+
+#endif /* XFree86LOADER */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/dix/dispatch.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,4085 @@
+/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.13 2005/09/13 01:33:19 daniels Exp $ */
+/* $Xorg: dispatch.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */
+/************************************************************
+
+Copyright 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 1987, 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.
+
+********************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+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.
+
+******************************************************************/
+
+/* Copyright 2006 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.
+ */ 
+/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.32 2003/11/10 18:21:45 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef PANORAMIX_DEBUG
+#include <stdio.h>
+int ProcInitialConnection();
+#endif
+
+#include "windowstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "selection.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "opaque.h"
+#include "input.h"
+#include "servermd.h"
+#include "extnsionst.h"
+#include "dixfont.h"
+#include "dispatch.h"
+#include "swaprep.h"
+#include "swapreq.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XKB
+#define XKB_IN_SERVER
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+#define mskcnt ((MAXCLIENTS + 31) / 32)
+#define BITMASK(i) (1U << ((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))
+
+extern xConnSetupPrefix connSetupPrefix;
+extern char *ConnectionInfo;
+
+Selection *CurrentSelections;
+int NumCurrentSelections;
+CallbackListPtr SelectionCallback = NULL;
+
+static ClientPtr grabClient;
+#define GrabNone 0
+#define GrabActive 1
+#define GrabKickout 2
+static int grabState = GrabNone;
+static long grabWaiters[mskcnt];
+CallbackListPtr ServerGrabCallback = NULL;
+HWEventQueuePtr checkForInput[2];
+extern int connBlockScreenStart;
+
+static void KillAllClients(void);
+
+static void DeleteClientFromAnySelections(ClientPtr client);
+
+#ifdef TSOL
+SecurityHookPtr pSecHook = NULL;
+#endif /* TSOL */
+
+static int nextFreeClientID; /* always MIN free client ID */
+
+static int	nClients;	/* number of authorized clients */
+
+CallbackListPtr ClientStateCallback;
+
+/* dispatchException & isItTimeToYield must be declared volatile since they
+ * are modified by signal handlers - otherwise optimizer may assume it doesn't
+ * need to actually check value in memory when used and may miss changes from
+ * signal handlers.
+ */
+volatile char dispatchException = 0;
+volatile char isItTimeToYield;
+
+/* Various of the DIX function interfaces were not designed to allow
+ * the client->errorValue to be set on BadValue and other errors.
+ * Rather than changing interfaces and breaking untold code we introduce
+ * a new global that dispatch can use.
+ */
+XID clientErrorValue;   /* XXX this is a kludge */
+
+#define SAME_SCREENS(a, b) (\
+    (a.pScreen == b.pScreen))
+
+void
+SetInputCheck(HWEventQueuePtr c0, HWEventQueuePtr c1)
+{
+    checkForInput[0] = c0;
+    checkForInput[1] = c1;
+}
+
+void
+UpdateCurrentTime()
+{
+    TimeStamp systime;
+
+    /* To avoid time running backwards, we must call GetTimeInMillis before
+     * calling ProcessInputEvents.
+     */
+    systime.months = currentTime.months;
+    systime.milliseconds = GetTimeInMillis();
+    if (systime.milliseconds < currentTime.milliseconds)
+	systime.months++;
+    if (*checkForInput[0] != *checkForInput[1])
+	ProcessInputEvents();
+    if (CompareTimeStamps(systime, currentTime) == LATER)
+	currentTime = systime;
+}
+
+/* Like UpdateCurrentTime, but can't call ProcessInputEvents */
+void
+UpdateCurrentTimeIf()
+{
+    TimeStamp systime;
+
+    systime.months = currentTime.months;
+    systime.milliseconds = GetTimeInMillis();
+    if (systime.milliseconds < currentTime.milliseconds)
+	systime.months++;
+    if (*checkForInput[0] == *checkForInput[1])
+	currentTime = systime;
+}
+
+void
+InitSelections()
+{
+    if (CurrentSelections)
+	xfree(CurrentSelections);
+    CurrentSelections = (Selection *)NULL;
+    NumCurrentSelections = 0;
+}
+
+void 
+FlushClientCaches(XID id)
+{
+    int i;
+    register ClientPtr client;
+
+    client = clients[CLIENT_ID(id)];
+    if (client == NullClient)
+        return ;
+    for (i=0; i<currentMaxClients; i++)
+    {
+	client = clients[i];
+        if (client != NullClient)
+	{
+            if (client->lastDrawableID == id)
+	    {
+		client->lastDrawableID = WindowTable[0]->drawable.id;
+		client->lastDrawable = (DrawablePtr)WindowTable[0];
+	    }
+            else if (client->lastGCID == id)
+	    {
+                client->lastGCID = INVALID;
+		client->lastGC = (GCPtr)NULL;
+	    }
+	}
+    }
+}
+#ifdef SMART_SCHEDULE
+
+#undef SMART_DEBUG
+
+#define SMART_SCHEDULE_DEFAULT_INTERVAL	20	    /* ms */
+#define SMART_SCHEDULE_MAX_SLICE	200	    /* ms */
+
+Bool	    SmartScheduleDisable = FALSE;
+long	    SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
+long	    SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
+long	    SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
+long	    SmartScheduleTime;
+ClientPtr   SmartLastClient;
+int	    SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
+int         SmartScheduleClient(int *clientReady, int nready);
+
+#ifdef SMART_DEBUG
+long	    SmartLastPrint;
+#endif
+
+void        Dispatch(void);
+void        InitProcVectors(void);
+
+int
+SmartScheduleClient (int *clientReady, int nready)
+{
+    ClientPtr	pClient;
+    int		i;
+    int		client;
+    int		bestPrio, best = 0;
+    int		bestRobin, robin;
+    long	now = SmartScheduleTime;
+    long	idle;
+
+    bestPrio = -0x7fffffff;
+    bestRobin = 0;
+    idle = 2 * SmartScheduleSlice;
+    for (i = 0; i < nready; i++)
+    {
+	client = clientReady[i];
+	pClient = clients[client];
+	/* Praise clients which are idle */
+	if ((now - pClient->smart_check_tick) >= idle)
+	{
+	    if (pClient->smart_priority < 0)
+		pClient->smart_priority++;
+	}
+	pClient->smart_check_tick = now;
+	
+	/* check priority to select best client */
+	robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff;
+	if (pClient->smart_priority > bestPrio ||
+	    (pClient->smart_priority == bestPrio && robin > bestRobin))
+	{
+	    bestPrio = pClient->smart_priority;
+	    bestRobin = robin;
+	    best = client;
+	}
+#ifdef SMART_DEBUG
+	if ((now - SmartLastPrint) >= 5000)
+	    fprintf (stderr, " %2d: %3d", client, pClient->smart_priority);
+#endif
+    }
+#ifdef SMART_DEBUG
+    if ((now - SmartLastPrint) >= 5000)
+    {
+	fprintf (stderr, " use %2d\n", best);
+	SmartLastPrint = now;
+    }
+#endif
+    pClient = clients[best];
+    SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index;
+    /*
+     * Set current client pointer
+     */
+    if (SmartLastClient != pClient)
+    {
+	pClient->smart_start_tick = now;
+	SmartLastClient = pClient;
+    }
+    /*
+     * Adjust slice
+     */
+    if (nready == 1)
+    {
+	/*
+	 * If it's been a long time since another client
+	 * has run, bump the slice up to get maximal
+	 * performance from a single client
+	 */
+	if ((now - pClient->smart_start_tick) > 1000 &&
+	    SmartScheduleSlice < SmartScheduleMaxSlice)
+	{
+	    SmartScheduleSlice += SmartScheduleInterval;
+	}
+    }
+    else
+    {
+	SmartScheduleSlice = SmartScheduleInterval;
+    }
+    return best;
+}
+#endif
+
+#define MAJOROP ((xReq *)client->requestBuffer)->reqType
+
+void
+Dispatch(void)
+{
+    register int        *clientReady;     /* array of request ready clients */
+    register int	result;
+    register ClientPtr	client;
+    register int	nready;
+    register HWEventQueuePtr* icheck = checkForInput;
+#ifdef SMART_SCHEDULE
+    long			start_tick;
+#endif
+
+    nextFreeClientID = 1;
+    InitSelections();
+    nClients = 0;
+
+    clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients);
+    if (!clientReady)
+	return;
+
+    while (!dispatchException)
+    {
+        if (*icheck[0] != *icheck[1])
+	{
+	    ProcessInputEvents();
+	    FlushIfCriticalOutputPending();
+	}
+
+	nready = WaitForSomething(clientReady);
+
+#ifdef SMART_SCHEDULE
+	if (nready && !SmartScheduleDisable)
+	{
+	    clientReady[0] = SmartScheduleClient (clientReady, nready);
+	    nready = 1;
+	}
+#endif
+       /***************** 
+	*  Handle events in round robin fashion, doing input between 
+	*  each round 
+	*****************/
+
+	while (!dispatchException && (--nready >= 0))
+	{
+	    client = clients[clientReady[nready]];
+	    if (! client)
+	    {
+		/* KillClient can cause this to happen */
+		continue;
+	    }
+	    /* GrabServer activation can cause this to be true */
+	    if (grabState == GrabKickout)
+	    {
+		grabState = GrabActive;
+		break;
+	    }
+	    isItTimeToYield = FALSE;
+ 
+            requestingClient = client;
+#ifdef SMART_SCHEDULE
+	    start_tick = SmartScheduleTime;
+#endif
+	    while (!isItTimeToYield)
+	    {
+	        if (*icheck[0] != *icheck[1])
+		{
+		    ProcessInputEvents();
+		    FlushIfCriticalOutputPending();
+		}
+#ifdef SMART_SCHEDULE
+		if (!SmartScheduleDisable && 
+		    (SmartScheduleTime - start_tick) >= SmartScheduleSlice)
+		{
+		    /* Penalize clients which consume ticks */
+		    if (client->smart_priority > SMART_MIN_PRIORITY)
+			client->smart_priority--;
+		    break;
+		}
+#endif
+		/* now, finally, deal with client requests */
+
+	        result = ReadRequestFromClient(client);
+	        if (result <= 0) 
+	        {
+		    if (result < 0)
+			CloseDownClient(client);
+		    break;
+	        }
+
+		client->sequence++;
+#ifdef DEBUG
+		if (client->requestLogIndex == MAX_REQUEST_LOG)
+		    client->requestLogIndex = 0;
+		client->requestLog[client->requestLogIndex] = MAJOROP;
+		client->requestLogIndex++;
+#endif
+		if (result > (maxBigRequestSize << 2))
+		    result = BadLength;
+		else
+#ifdef TSOL
+           	{
+                    if (pSecHook)
+			(*pSecHook->AuditStart)(client);
+                    result = (* client->requestVector[MAJOROP])(client);
+                    if (pSecHook)
+			(*pSecHook->AuditEnd)(client, result);
+		}
+#else
+                    result = (* client->requestVector[MAJOROP])(client);
+#endif /* TSOL */
+
+		if (result != Success) 
+		{
+		    if (client->noClientException != Success)
+                        CloseDownClient(client);
+                    else
+		        SendErrorToClient(client, MAJOROP,
+					  MinorOpcodeOfRequest(client),
+					  client->errorValue, result);
+		    break;
+	        }
+#ifdef DAMAGEEXT
+		FlushIfCriticalOutputPending ();
+#endif
+	    }
+	    FlushAllOutput();
+#ifdef SMART_SCHEDULE
+	    client = clients[clientReady[nready]];
+	    if (client)
+		client->smart_stop_tick = SmartScheduleTime;
+#endif
+	    requestingClient = NULL;
+	}
+	dispatchException &= ~DE_PRIORITYCHANGE;
+    }
+#if defined(DDXBEFORERESET)
+    ddxBeforeReset ();
+#endif
+    KillAllClients();
+    DEALLOCATE_LOCAL(clientReady);
+    dispatchException &= ~DE_RESET;
+}
+
+#undef MAJOROP
+
+int
+ProcBadRequest(ClientPtr client)
+{
+    return (BadRequest);
+}
+
+int
+ProcCreateWindow(ClientPtr client)
+{
+    register WindowPtr pParent, pWin;
+    REQUEST(xCreateWindowReq);
+    int result;
+    int len;
+
+    REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
+    
+    LEGAL_NEW_RESOURCE(stuff->wid, client);
+    if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
+						    SecurityWriteAccess)))
+        return BadWindow;
+    len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
+    if (Ones(stuff->mask) != len)
+        return BadLength;
+    if (!stuff->width || !stuff->height)
+    {
+	client->errorValue = 0;
+        return BadValue;
+    }
+    pWin = CreateWindow(stuff->wid, pParent, stuff->x,
+			      stuff->y, stuff->width, stuff->height, 
+			      stuff->borderWidth, stuff->class,
+			      stuff->mask, (XID *) &stuff[1], 
+			      (int)stuff->depth, 
+			      client, stuff->visual, &result);
+    if (pWin)
+    {
+	Mask mask = pWin->eventMask;
+
+	pWin->eventMask = 0; /* subterfuge in case AddResource fails */
+	if (!AddResource(stuff->wid, RT_WINDOW, (pointer)pWin))
+	    return BadAlloc;
+	pWin->eventMask = mask;
+    }
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+        return(result);
+}
+
+int
+ProcChangeWindowAttributes(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xChangeWindowAttributesReq);
+    register int result;
+    int len;
+
+    REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+    len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
+    if (len != Ones(stuff->valueMask))
+        return BadLength;
+    result =  ChangeWindowAttributes(pWin, 
+				  stuff->valueMask, 
+				  (XID *) &stuff[1], 
+				  client);
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+        return(result);
+}
+
+int
+ProcGetWindowAttributes(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xResourceReq);
+    xGetWindowAttributesReply wa;
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    GetWindowAttributes(pWin, client, &wa);
+    WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
+    return(client->noClientException);
+}
+
+int
+ProcDestroyWindow(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityDestroyAccess);
+    if (!pWin)
+        return(BadWindow);
+    if (pWin->parent)
+	FreeResource(stuff->id, RT_NONE);
+    return(client->noClientException);
+}
+
+int
+ProcDestroySubwindows(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityDestroyAccess);
+    if (!pWin)
+        return(BadWindow);
+    DestroySubwindows(pWin, client);
+    return(client->noClientException);
+}
+
+int
+ProcChangeSaveSet(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xChangeSaveSetReq);
+    register int result;
+		  
+    REQUEST_SIZE_MATCH(xChangeSaveSetReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
+        return BadMatch;
+    if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
+    {
+        result = AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE);
+	if (client->noClientException != Success)
+	    return(client->noClientException);
+	else
+            return(result);
+    }
+    else
+    {
+	client->errorValue = stuff->mode;
+	return( BadValue );
+    }
+}
+
+int
+ProcReparentWindow(register ClientPtr client)
+{
+    register WindowPtr pWin, pParent;
+    REQUEST(xReparentWindowReq);
+    register int result;
+
+    REQUEST_SIZE_MATCH(xReparentWindowReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+    pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
+					      SecurityWriteAccess);
+    if (!pParent)
+        return(BadWindow);
+    if (SAME_SCREENS(pWin->drawable, pParent->drawable))
+    {
+        if ((pWin->backgroundState == ParentRelative) &&
+            (pParent->drawable.depth != pWin->drawable.depth))
+            return BadMatch;
+	if ((pWin->drawable.class != InputOnly) &&
+	    (pParent->drawable.class == InputOnly))
+	    return BadMatch;
+        result =  ReparentWindow(pWin, pParent, 
+			 (short)stuff->x, (short)stuff->y, client);
+	if (client->noClientException != Success)
+            return(client->noClientException);
+	else
+            return(result);
+    }
+    else 
+        return (BadMatch);
+}
+
+int
+ProcMapWindow(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    MapWindow(pWin, client);
+           /* update cache to say it is mapped */
+    return(client->noClientException);
+}
+
+int
+ProcMapSubwindows(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
+					    SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    MapSubwindows(pWin, client);
+           /* update cache to say it is mapped */
+    return(client->noClientException);
+}
+
+int
+ProcUnmapWindow(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
+					    SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    UnmapWindow(pWin, FALSE);
+           /* update cache to say it is mapped */
+    return(client->noClientException);
+}
+
+int
+ProcUnmapSubwindows(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
+					    SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    UnmapSubwindows(pWin);
+    return(client->noClientException);
+}
+
+int
+ProcConfigureWindow(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xConfigureWindowReq);
+    register int result;
+    int len;
+
+    REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
+    pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client,
+					    SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+    len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
+    if (Ones((Mask)stuff->mask) != len)
+        return BadLength;
+    result =  ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1], 
+			      client);
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+        return(result);
+}
+
+int
+ProcCirculateWindow(register ClientPtr client)
+{
+    register WindowPtr pWin;
+    REQUEST(xCirculateWindowReq);
+
+    REQUEST_SIZE_MATCH(xCirculateWindowReq);
+    if ((stuff->direction != RaiseLowest) &&
+	(stuff->direction != LowerHighest))
+    {
+	client->errorValue = stuff->direction;
+        return BadValue;
+    }
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+    CirculateWindow(pWin, (int)stuff->direction, client);
+    return(client->noClientException);
+}
+
+int
+GetGeometry(register ClientPtr client, xGetGeometryReply *rep)
+{
+    register DrawablePtr pDraw;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess);
+    rep->type = X_Reply;
+    rep->length = 0;
+    rep->sequenceNumber = client->sequence;
+    rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
+    rep->depth = pDraw->depth;
+    rep->width = pDraw->width;
+    rep->height = pDraw->height;
+
+    /* XXX - Because the pixmap-implementation of the multibuffer extension 
+     *       may have the buffer-id's drawable resource value be a pointer
+     *       to the buffer's window instead of the buffer itself
+     *       (this happens if the buffer is the displayed buffer),
+     *       we also have to check that the id matches before we can
+     *       truly say that it is a DRAWABLE_WINDOW.
+     */
+
+    if ((pDraw->type == UNDRAWABLE_WINDOW) ||
+        ((pDraw->type == DRAWABLE_WINDOW) && (stuff->id == pDraw->id)))
+    {
+        register WindowPtr pWin = (WindowPtr)pDraw;
+	rep->x = pWin->origin.x - wBorderWidth (pWin);
+	rep->y = pWin->origin.y - wBorderWidth (pWin);
+	rep->borderWidth = pWin->borderWidth;
+    }
+    else /* DRAWABLE_PIXMAP or DRAWABLE_BUFFER */
+    {
+	rep->x = rep->y = rep->borderWidth = 0;
+    }
+
+    return Success;
+}
+
+
+int
+ProcGetGeometry(register ClientPtr client)
+{
+    xGetGeometryReply rep;
+    int status;
+
+    if ((status = GetGeometry(client, &rep)) != Success)
+	return status;
+
+    WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
+    return(client->noClientException);
+}
+
+
+int
+ProcQueryTree(register ClientPtr client)
+{
+    xQueryTreeReply reply;
+    int numChildren = 0;
+    register WindowPtr pChild, pWin, pHead;
+    Window  *childIDs = (Window *)NULL;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    reply.type = X_Reply;
+    reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+    reply.sequenceNumber = client->sequence;
+    if (pWin->parent)
+	reply.parent = pWin->parent->drawable.id;
+    else
+        reply.parent = (Window)None;
+    pHead = RealChildHead(pWin);
+    for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+	numChildren++;
+    if (numChildren)
+    {
+	int curChild = 0;
+
+	childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
+	if (!childIDs)
+	    return BadAlloc;
+	for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+	    childIDs[curChild++] = pChild->drawable.id;
+    }
+    
+    reply.nChildren = numChildren;
+    reply.length = (numChildren * sizeof(Window)) >> 2;
+    
+    WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
+    if (numChildren)
+    {
+    	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+	WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
+	DEALLOCATE_LOCAL(childIDs);
+    }
+
+    return(client->noClientException);
+}
+
+int
+ProcInternAtom(register ClientPtr client)
+{
+    Atom atom;
+    char *tchar;
+    REQUEST(xInternAtomReq);
+
+    REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes);
+    if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse))
+    {
+	client->errorValue = stuff->onlyIfExists;
+        return(BadValue);
+    }
+    tchar = (char *) &stuff[1];
+    atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
+    if (atom != BAD_RESOURCE)
+    {
+	xInternAtomReply reply;
+	reply.type = X_Reply;
+	reply.length = 0;
+	reply.sequenceNumber = client->sequence;
+	reply.atom = atom;
+	WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
+	return(client->noClientException);
+    }
+    else
+	return (BadAlloc);
+}
+
+int
+ProcGetAtomName(register ClientPtr client)
+{
+    char *str;
+    xGetAtomNameReply reply;
+    int len;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    if ( (str = NameForAtom(stuff->id)) )
+    {
+	len = strlen(str);
+	reply.type = X_Reply;
+	reply.length = (len + 3) >> 2;
+	reply.sequenceNumber = client->sequence;
+	reply.nameLength = len;
+	WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
+	(void)WriteToClient(client, len, str);
+	return(client->noClientException);
+    }
+    else 
+    { 
+	client->errorValue = stuff->id;
+	return (BadAtom);
+    }
+}
+
+#ifdef K5AUTH
+extern int k5_bad();
+#endif
+
+int
+ProcSetSelectionOwner(register ClientPtr client)
+{
+    WindowPtr pWin;
+    TimeStamp time;
+    REQUEST(xSetSelectionOwnerReq);
+
+    REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+    UpdateCurrentTime();
+    time = ClientTimeToServerTime(stuff->time);
+
+    /* If the client's time stamp is in the future relative to the server's
+	time stamp, do not set the selection, just return success. */
+    if (CompareTimeStamps(time, currentTime) == LATER)
+    	return Success;
+    if (stuff->window != None)
+    {
+        pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					       SecurityReadAccess);
+        if (!pWin)
+            return(BadWindow);
+    }
+    else
+        pWin = (WindowPtr)None;
+    if (ValidAtom(stuff->selection))
+    {
+	int i = 0;
+
+	/*
+	 * First, see if the selection is already set... 
+	 */
+	while ((i < NumCurrentSelections) && 
+	       CurrentSelections[i].selection != stuff->selection) 
+            i++;
+        if (i < NumCurrentSelections)
+        {        
+	    xEvent event;
+
+	    /* If the timestamp in client's request is in the past relative
+		to the time stamp indicating the last time the owner of the
+		selection was set, do not set the selection, just return 
+		success. */
+            if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged)
+		== EARLIER)
+		return Success;
+	    if (CurrentSelections[i].client &&
+		(!pWin || (CurrentSelections[i].client != client)))
+	    {
+		event.u.u.type = SelectionClear;
+		event.u.selectionClear.time = time.milliseconds;
+		event.u.selectionClear.window = CurrentSelections[i].window;
+		event.u.selectionClear.atom = CurrentSelections[i].selection;
+		(void) TryClientEvents (CurrentSelections[i].client, &event, 1,
+				NoEventMask, NoEventMask /* CantBeFiltered */,
+				NullGrab);
+	    }
+	}
+	else
+	{
+	    /*
+	     * It doesn't exist, so add it...
+	     */
+	    Selection *newsels;
+
+	    if (i == 0)
+		newsels = (Selection *)xalloc(sizeof(Selection));
+	    else
+		newsels = (Selection *)xrealloc(CurrentSelections,
+			    (NumCurrentSelections + 1) * sizeof(Selection));
+	    if (!newsels)
+		return BadAlloc;
+	    NumCurrentSelections++;
+	    CurrentSelections = newsels;
+	    CurrentSelections[i].selection = stuff->selection;
+	}
+        CurrentSelections[i].lastTimeChanged = time;
+	CurrentSelections[i].window = stuff->window;
+	CurrentSelections[i].pWin = pWin;
+	CurrentSelections[i].client = (pWin ? client : NullClient);
+	if (SelectionCallback)
+	{
+	    SelectionInfoRec	info;
+
+	    info.selection = &CurrentSelections[i];
+	    info.kind= SelectionSetOwner;
+	    CallCallbacks(&SelectionCallback, &info);
+	}
+	return (client->noClientException);
+    }
+    else 
+    {
+	client->errorValue = stuff->selection;
+        return (BadAtom);
+    }
+}
+
+int
+ProcGetSelectionOwner(register ClientPtr client)
+{
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    if (ValidAtom(stuff->id))
+    {
+	int i;
+        xGetSelectionOwnerReply reply;
+
+	i = 0;
+        while ((i < NumCurrentSelections) && 
+	       CurrentSelections[i].selection != stuff->id) i++;
+        reply.type = X_Reply;
+	reply.length = 0;
+	reply.sequenceNumber = client->sequence;
+        if (i < NumCurrentSelections)
+            reply.owner = CurrentSelections[i].window;
+        else
+            reply.owner = None;
+        WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
+        return(client->noClientException);
+    }
+    else            
+    {
+	client->errorValue = stuff->id;
+        return (BadAtom); 
+    }
+}
+
+int
+ProcConvertSelection(register ClientPtr client)
+{
+    Bool paramsOkay;
+    xEvent event;
+    WindowPtr pWin;
+    REQUEST(xConvertSelectionReq);
+
+    REQUEST_SIZE_MATCH(xConvertSelectionReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+
+    paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target));
+    if (stuff->property != None)
+	paramsOkay &= ValidAtom(stuff->property);
+    if (paramsOkay)
+    {
+	int i;
+
+	i = 0;
+	while ((i < NumCurrentSelections) && 
+	       CurrentSelections[i].selection != stuff->selection) i++;
+	if ((i < NumCurrentSelections) && 
+	    (CurrentSelections[i].window != None)
+#ifdef XCSECURITY
+	    && (!client->CheckAccess ||
+		(* client->CheckAccess)(client, CurrentSelections[i].window,
+					RT_WINDOW, SecurityReadAccess,
+					CurrentSelections[i].pWin))
+#endif
+	    )
+	{        
+	    event.u.u.type = SelectionRequest;
+	    event.u.selectionRequest.time = stuff->time;
+	    event.u.selectionRequest.owner = 
+			CurrentSelections[i].window;
+	    event.u.selectionRequest.requestor = stuff->requestor;
+	    event.u.selectionRequest.selection = stuff->selection;
+	    event.u.selectionRequest.target = stuff->target;
+	    event.u.selectionRequest.property = stuff->property;
+	    if (TryClientEvents(
+		CurrentSelections[i].client, &event, 1, NoEventMask,
+		NoEventMask /* CantBeFiltered */, NullGrab))
+		return (client->noClientException);
+	}
+	event.u.u.type = SelectionNotify;
+	event.u.selectionNotify.time = stuff->time;
+	event.u.selectionNotify.requestor = stuff->requestor;
+	event.u.selectionNotify.selection = stuff->selection;
+	event.u.selectionNotify.target = stuff->target;
+	event.u.selectionNotify.property = None;
+	(void) TryClientEvents(client, &event, 1, NoEventMask,
+			       NoEventMask /* CantBeFiltered */, NullGrab);
+	return (client->noClientException);
+    }
+    else 
+    {
+	client->errorValue = stuff->property;
+        return (BadAtom);
+    }
+}
+
+int
+ProcGrabServer(register ClientPtr client)
+{
+    REQUEST_SIZE_MATCH(xReq);
+    if (grabState != GrabNone && client != grabClient)
+    {
+	ResetCurrentRequest(client);
+	client->sequence--;
+	BITSET(grabWaiters, client->index);
+	IgnoreClient(client);
+	return(client->noClientException);
+    }
+    OnlyListenToOneClient(client);
+    grabState = GrabKickout;
+    grabClient = client;
+
+    if (ServerGrabCallback)
+    {
+	ServerGrabInfoRec grabinfo;
+	grabinfo.client = client;
+	grabinfo.grabstate  = SERVER_GRABBED;
+	CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
+    }
+
+    return(client->noClientException);
+}
+
+static void
+UngrabServer(ClientPtr client)
+{
+    int i;
+
+    grabState = GrabNone;
+    ListenToAllClients();
+    for (i = mskcnt; --i >= 0 && !grabWaiters[i]; )
+	;
+    if (i >= 0)
+    {
+	i <<= 5;
+	while (!GETBIT(grabWaiters, i))
+	    i++;
+	BITCLEAR(grabWaiters, i);
+	AttendClient(clients[i]);
+    }
+
+    if (ServerGrabCallback)
+    {
+	ServerGrabInfoRec grabinfo;
+	grabinfo.client = client;
+	grabinfo.grabstate  = SERVER_UNGRABBED;
+	CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
+    }
+}
+
+int
+ProcUngrabServer(register ClientPtr client)
+{
+    REQUEST_SIZE_MATCH(xReq);
+    UngrabServer(client);
+    return(client->noClientException);
+}
+
+int
+ProcTranslateCoords(register ClientPtr client)
+{
+    REQUEST(xTranslateCoordsReq);
+
+    register WindowPtr pWin, pDst;
+    xTranslateCoordsReply rep;
+
+    REQUEST_SIZE_MATCH(xTranslateCoordsReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+    pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
+					   SecurityReadAccess);
+    if (!pDst)
+        return(BadWindow);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    if (!SAME_SCREENS(pWin->drawable, pDst->drawable))
+    {
+	rep.sameScreen = xFalse;
+        rep.child = None;
+	rep.dstX = rep.dstY = 0;
+    }
+    else
+    {
+	INT16 x, y;
+	rep.sameScreen = xTrue;
+	rep.child = None;
+	/* computing absolute coordinates -- adjust to destination later */
+	x = pWin->drawable.x + stuff->srcX;
+	y = pWin->drawable.y + stuff->srcY;
+	pWin = pDst->firstChild;
+	while (pWin)
+	{
+#ifdef SHAPE
+	    BoxRec  box;
+#endif
+	    if ((pWin->mapped) &&
+		(x >= pWin->drawable.x - wBorderWidth (pWin)) &&
+		(x < pWin->drawable.x + (int)pWin->drawable.width +
+		 wBorderWidth (pWin)) &&
+		(y >= pWin->drawable.y - wBorderWidth (pWin)) &&
+		(y < pWin->drawable.y + (int)pWin->drawable.height +
+		 wBorderWidth (pWin))
+#ifdef SHAPE
+		/* When a window is shaped, a further check
+		 * is made to see if the point is inside
+		 * borderSize
+		 */
+		&& (!wBoundingShape(pWin) ||
+		    POINT_IN_REGION(pWin->drawable.pScreen, 
+					&pWin->borderSize, x, y, &box))
+		
+		&& (!wInputShape(pWin) ||
+		    POINT_IN_REGION(pWin->drawable.pScreen,
+				    wInputShape(pWin),
+				    x - pWin->drawable.x,
+				    y - pWin->drawable.y, &box))
+#endif
+		)
+            {
+		rep.child = pWin->drawable.id;
+		pWin = (WindowPtr) NULL;
+	    }
+	    else
+		pWin = pWin->nextSib;
+	}
+	/* adjust to destination coordinates */
+	rep.dstX = x - pDst->drawable.x;
+	rep.dstY = y - pDst->drawable.y;
+    }
+    WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
+    return(client->noClientException);
+}
+
+int
+ProcOpenFont(register ClientPtr client)
+{
+    int	err;
+    REQUEST(xOpenFontReq);
+
+    REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes);
+    client->errorValue = stuff->fid;
+    LEGAL_NEW_RESOURCE(stuff->fid, client);
+    err = OpenFont(client, stuff->fid, (Mask) 0,
+		stuff->nbytes, (char *)&stuff[1]);
+    if (err == Success)
+    {
+	return(client->noClientException);
+    }
+    else
+	return err;
+}
+
+int
+ProcCloseFont(register ClientPtr client)
+{
+    FontPtr pFont;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
+					    SecurityDestroyAccess);
+    if ( pFont != (FontPtr)NULL)	/* id was valid */
+    {
+        FreeResource(stuff->id, RT_NONE);
+	return(client->noClientException);
+    }
+    else
+    {
+	client->errorValue = stuff->id;
+        return (BadFont);
+    }
+}
+
+int
+ProcQueryFont(register ClientPtr client)
+{
+    xQueryFontReply	*reply;
+    FontPtr pFont;
+    register GC *pGC;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    client->errorValue = stuff->id;		/* EITHER font or gc */
+    pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
+					    SecurityReadAccess);
+    if (!pFont)
+    {
+	  /* can't use VERIFY_GC because it might return BadGC */
+	pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
+					    SecurityReadAccess);
+        if (!pGC)
+	{
+	    client->errorValue = stuff->id;
+            return(BadFont);     /* procotol spec says only error is BadFont */
+	}
+	pFont = pGC->font;
+    }
+
+    {
+	xCharInfo	*pmax = FONTINKMAX(pFont);
+	xCharInfo	*pmin = FONTINKMIN(pFont);
+	int		nprotoxcistructs;
+	int		rlength;
+
+	nprotoxcistructs = (
+	   pmax->rightSideBearing == pmin->rightSideBearing &&
+	   pmax->leftSideBearing == pmin->leftSideBearing &&
+	   pmax->descent == pmin->descent &&
+	   pmax->ascent == pmin->ascent &&
+	   pmax->characterWidth == pmin->characterWidth) ?
+		0 : N2dChars(pFont);
+
+	rlength = sizeof(xQueryFontReply) +
+	             FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp)  +
+		     nprotoxcistructs * sizeof(xCharInfo);
+	reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength);
+	if(!reply)
+	{
+	    return(BadAlloc);
+	}
+
+	reply->type = X_Reply;
+	reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+	reply->sequenceNumber = client->sequence;
+	QueryFont( pFont, reply, nprotoxcistructs);
+
+        WriteReplyToClient(client, rlength, reply);
+	DEALLOCATE_LOCAL(reply);
+	return(client->noClientException);
+    }
+}
+
+int
+ProcQueryTextExtents(register ClientPtr client)
+{
+    REQUEST(xQueryTextExtentsReq);
+    xQueryTextExtentsReply reply;
+    FontPtr pFont;
+    GC *pGC;
+    ExtentInfoRec info;
+    unsigned long length;
+
+    REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
+        
+    pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT,
+					    SecurityReadAccess);
+    if (!pFont)
+    {
+        pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC,
+					   SecurityReadAccess);
+        if (!pGC)
+	{
+	    client->errorValue = stuff->fid;
+            return(BadFont);
+	}
+	pFont = pGC->font;
+    }
+    length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2);
+    length = length << 1;
+    if (stuff->oddLength)
+    {
+	if (length == 0)
+	    return(BadLength);
+        length--;
+    }
+    if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info))
+	return(BadAlloc);
+    reply.type = X_Reply;
+    reply.length = 0;
+    reply.sequenceNumber = client->sequence;
+    reply.drawDirection = info.drawDirection;
+    reply.fontAscent = info.fontAscent;
+    reply.fontDescent = info.fontDescent;
+    reply.overallAscent = info.overallAscent;
+    reply.overallDescent = info.overallDescent;
+    reply.overallWidth = info.overallWidth;
+    reply.overallLeft = info.overallLeft;
+    reply.overallRight = info.overallRight;
+    WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
+    return(client->noClientException);
+}
+
+int
+ProcListFonts(register ClientPtr client)
+{
+    REQUEST(xListFontsReq);
+
+    REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
+
+    return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, 
+	stuff->maxNames);
+}
+
+int
+ProcListFontsWithInfo(register ClientPtr client)
+{
+    REQUEST(xListFontsWithInfoReq);
+
+    REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes);
+
+    return StartListFontsWithInfo(client, stuff->nbytes,
+				  (unsigned char *) &stuff[1], stuff->maxNames);
+}
+
+/**
+ *
+ *  \param value must conform to DeleteType
+ */
+int
+dixDestroyPixmap(pointer value, XID pid)
+{
+    PixmapPtr pPixmap = (PixmapPtr)value;
+    return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
+}
+
+int
+ProcCreatePixmap(register ClientPtr client)
+{
+    PixmapPtr pMap;
+    register DrawablePtr pDraw;
+    REQUEST(xCreatePixmapReq);
+    DepthPtr pDepth;
+    register int i;
+
+    REQUEST_SIZE_MATCH(xCreatePixmapReq);
+    client->errorValue = stuff->pid;
+    LEGAL_NEW_RESOURCE(stuff->pid, client);
+    SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
+				 SecurityReadAccess);
+    if (!stuff->width || !stuff->height)
+    {
+	client->errorValue = 0;
+        return BadValue;
+    }
+    if (stuff->width > 32767 || stuff->height > 32767)
+    {
+	/* It is allowed to try and allocate a pixmap which is larger than
+	 * 32767 in either dimension. However, all of the framebuffer code
+	 * is buggy and does not reliably draw to such big pixmaps, basically
+	 * because the Region data structure operates with signed shorts
+	 * for the rectangles in it.
+	 *
+	 * Furthermore, several places in the X server computes the
+	 * size in bytes of the pixmap and tries to store it in an
+	 * integer. This integer can overflow and cause the allocated size
+	 * to be much smaller.
+	 *
+	 * So, such big pixmaps are rejected here with a BadAlloc
+	 */
+	return BadAlloc;
+    }
+    if (stuff->depth != 1)
+    {
+        pDepth = pDraw->pScreen->allowedDepths;
+        for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
+	   if (pDepth->depth == stuff->depth)
+               goto CreatePmap;
+	client->errorValue = stuff->depth;
+        return BadValue;
+    }
+CreatePmap:
+    pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap)
+		(pDraw->pScreen, stuff->width,
+		 stuff->height, stuff->depth);
+    if (pMap)
+    {
+	pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+	pMap->drawable.id = stuff->pid;
+	if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
+	    return(client->noClientException);
+    }
+    return (BadAlloc);
+}
+
+int
+ProcFreePixmap(register ClientPtr client)
+{
+    PixmapPtr pMap;
+
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP,
+					     SecurityDestroyAccess);
+    if (pMap) 
+    {
+	FreeResource(stuff->id, RT_NONE);
+	return(client->noClientException);
+    }
+    else 
+    {
+	client->errorValue = stuff->id;
+	return (BadPixmap);
+    }
+}
+
+int
+ProcCreateGC(register ClientPtr client)
+{
+    int error;
+    GC *pGC;
+    register DrawablePtr pDraw;
+    unsigned len;
+    REQUEST(xCreateGCReq);
+
+    REQUEST_AT_LEAST_SIZE(xCreateGCReq);
+    client->errorValue = stuff->gc;
+    LEGAL_NEW_RESOURCE(stuff->gc, client);
+    SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client,
+			      SecurityReadAccess);
+    len = client->req_len -  (sizeof(xCreateGCReq) >> 2);
+    if (len != Ones(stuff->mask))
+        return BadLength;
+    pGC = (GC *)CreateGC(pDraw, stuff->mask, 
+			 (XID *) &stuff[1], &error);
+    if (error != Success)
+        return error;
+    if (!AddResource(stuff->gc, RT_GC, (pointer)pGC))
+	return (BadAlloc);
+    return(client->noClientException);
+}
+
+int
+ProcChangeGC(register ClientPtr client)
+{
+    GC *pGC;
+    REQUEST(xChangeGCReq);
+    int result;
+    unsigned len;
+		
+    REQUEST_AT_LEAST_SIZE(xChangeGCReq);
+    SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess);
+    len = client->req_len -  (sizeof(xChangeGCReq) >> 2);
+    if (len != Ones(stuff->mask))
+        return BadLength;
+
+    result = dixChangeGC(client, pGC, stuff->mask, (CARD32 *) &stuff[1], 0);
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+    {
+	client->errorValue = clientErrorValue;
+        return(result);
+    }
+}
+
+int
+ProcCopyGC(register ClientPtr client)
+{
+    register GC *dstGC;
+    register GC *pGC;
+    int result;
+    REQUEST(xCopyGCReq);
+
+    REQUEST_SIZE_MATCH(xCopyGCReq);
+    SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess);
+    SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess);
+    if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
+        return (BadMatch);    
+    result = CopyGC(pGC, dstGC, stuff->mask);
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+    {
+	client->errorValue = clientErrorValue;
+        return(result);
+    }
+}
+
+int
+ProcSetDashes(register ClientPtr client)
+{
+    register GC *pGC;
+    int result;
+    REQUEST(xSetDashesReq);
+
+    REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
+    if (stuff->nDashes == 0)
+    {
+	 client->errorValue = 0;
+         return BadValue;
+    }
+
+    SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
+
+    result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes,
+		       (unsigned char *)&stuff[1]);
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+    {
+	client->errorValue = clientErrorValue;
+        return(result);
+    }
+}
+
+int
+ProcSetClipRectangles(register ClientPtr client)
+{
+    int	nr;
+    int result;
+    register GC *pGC;
+    REQUEST(xSetClipRectanglesReq);
+
+    REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
+    if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
+	(stuff->ordering != YXSorted) && (stuff->ordering != YXBanded))
+    {
+	client->errorValue = stuff->ordering;
+        return BadValue;
+    }
+    SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
+		 
+    nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq);
+    if (nr & 4)
+	return(BadLength);
+    nr >>= 3;
+    result = SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin,
+			  nr, (xRectangle *)&stuff[1], (int)stuff->ordering);
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+        return(result);
+}
+
+int
+ProcFreeGC(register ClientPtr client)
+{
+    register GC *pGC;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    SECURITY_VERIFY_GC(pGC, stuff->id, client, SecurityDestroyAccess);
+    FreeResource(stuff->id, RT_NONE);
+    return(client->noClientException);
+}
+
+int
+ProcClearToBackground(register ClientPtr client)
+{
+    REQUEST(xClearAreaReq);
+    register WindowPtr pWin;
+
+    REQUEST_SIZE_MATCH(xClearAreaReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+    if (pWin->drawable.class == InputOnly)
+    {
+	client->errorValue = stuff->window;
+	return (BadMatch);
+    }		    
+    if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
+    {
+	client->errorValue = stuff->exposures;
+        return(BadValue);
+    }
+    (*pWin->drawable.pScreen->ClearToBackground)(pWin, stuff->x, stuff->y,
+			       stuff->width, stuff->height,
+			       (Bool)stuff->exposures);
+    return(client->noClientException);
+}
+
+int
+ProcCopyArea(register ClientPtr client)
+{
+    register DrawablePtr pDst;
+    register DrawablePtr pSrc;
+    register GC *pGC;
+    REQUEST(xCopyAreaReq);
+    RegionPtr pRgn;
+
+    REQUEST_SIZE_MATCH(xCopyAreaReq);
+
+    VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); 
+    if (stuff->dstDrawable != stuff->srcDrawable)
+    {
+	SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client,
+				 SecurityReadAccess);
+	if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth))
+	{
+	    client->errorValue = stuff->dstDrawable;
+	    return (BadMatch);
+	}
+    }
+    else
+        pSrc = pDst;
+
+    SET_DBE_SRCBUF(pSrc, stuff->srcDrawable);
+
+    pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
+				 stuff->width, stuff->height, 
+				 stuff->dstX, stuff->dstY);
+    if (pGC->graphicsExposures)
+    {
+	(*pDst->pScreen->SendGraphicsExpose)
+ 		(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
+	if (pRgn)
+	    REGION_DESTROY(pDst->pScreen, pRgn);
+    }
+
+    return(client->noClientException);
+}
+
+int
+ProcCopyPlane(register ClientPtr client)
+{
+    register DrawablePtr psrcDraw, pdstDraw;
+    register GC *pGC;
+    REQUEST(xCopyPlaneReq);
+    RegionPtr pRgn;
+
+    REQUEST_SIZE_MATCH(xCopyPlaneReq);
+
+    VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client);
+    if (stuff->dstDrawable != stuff->srcDrawable)
+    {
+	SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client,
+				 SecurityReadAccess);
+	if (pdstDraw->pScreen != psrcDraw->pScreen)
+	{
+	    client->errorValue = stuff->dstDrawable;
+	    return (BadMatch);
+	}
+    }
+    else
+        psrcDraw = pdstDraw;
+
+    SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable);
+
+    /* Check to see if stuff->bitPlane has exactly ONE good bit set */
+    if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
+       (stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
+    {
+       client->errorValue = stuff->bitPlane;
+       return(BadValue);
+    }
+
+    pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY,
+				 stuff->width, stuff->height, 
+				 stuff->dstX, stuff->dstY, stuff->bitPlane);
+    if (pGC->graphicsExposures)
+    {
+	(*pdstDraw->pScreen->SendGraphicsExpose)
+ 		(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
+	if (pRgn)
+	    REGION_DESTROY(pdstDraw->pScreen, pRgn);
+    }
+    return(client->noClientException);
+}
+
+int
+ProcPolyPoint(register ClientPtr client)
+{
+    int npoint;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xPolyPointReq);
+
+    REQUEST_AT_LEAST_SIZE(xPolyPointReq);
+    if ((stuff->coordMode != CoordModeOrigin) && 
+	(stuff->coordMode != CoordModePrevious))
+    {
+	client->errorValue = stuff->coordMode;
+        return BadValue;
+    }
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); 
+    npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
+    if (npoint)
+        (*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
+			  (xPoint *) &stuff[1]);
+    return (client->noClientException);
+}
+
+int
+ProcPolyLine(register ClientPtr client)
+{
+    int npoint;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xPolyLineReq);
+
+    REQUEST_AT_LEAST_SIZE(xPolyLineReq);
+    if ((stuff->coordMode != CoordModeOrigin) && 
+	(stuff->coordMode != CoordModePrevious))
+    {
+	client->errorValue = stuff->coordMode;
+        return BadValue;
+    }
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
+    if (npoint > 1)
+	(*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint, 
+			      (DDXPointPtr) &stuff[1]);
+    return(client->noClientException);
+}
+
+int
+ProcPolySegment(register ClientPtr client)
+{
+    int nsegs;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xPolySegmentReq);
+
+    REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
+    if (nsegs & 4)
+	return(BadLength);
+    nsegs >>= 3;
+    if (nsegs)
+        (*pGC->ops->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]);
+    return (client->noClientException);
+}
+
+int
+ProcPolyRectangle (register ClientPtr client)
+{
+    int nrects;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xPolyRectangleReq);
+
+    REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
+    if (nrects & 4)
+	return(BadLength);
+    nrects >>= 3;
+    if (nrects)
+        (*pGC->ops->PolyRectangle)(pDraw, pGC, 
+		    nrects, (xRectangle *) &stuff[1]);
+    return(client->noClientException);
+}
+
+int
+ProcPolyArc(register ClientPtr client)
+{
+    int		narcs;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xPolyArcReq);
+
+    REQUEST_AT_LEAST_SIZE(xPolyArcReq);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
+    if (narcs % sizeof(xArc))
+	return(BadLength);
+    narcs /= sizeof(xArc);
+    if (narcs)
+        (*pGC->ops->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]);
+    return (client->noClientException);
+}
+
+int
+ProcFillPoly(register ClientPtr client)
+{
+    int          things;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xFillPolyReq);
+
+    REQUEST_AT_LEAST_SIZE(xFillPolyReq);
+    if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) &&  
+	(stuff->shape != Convex))
+    {
+	client->errorValue = stuff->shape;
+        return BadValue;
+    }
+    if ((stuff->coordMode != CoordModeOrigin) && 
+	(stuff->coordMode != CoordModePrevious))
+    {
+	client->errorValue = stuff->coordMode;
+        return BadValue;
+    }
+
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
+    if (things)
+        (*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
+			 stuff->coordMode, things,
+			 (DDXPointPtr) &stuff[1]);
+    return(client->noClientException);
+}
+
+int
+ProcPolyFillRectangle(register ClientPtr client)
+{
+    int             things;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xPolyFillRectangleReq);
+
+    REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
+    if (things & 4)
+	return(BadLength);
+    things >>= 3;
+
+    if (things)
+        (*pGC->ops->PolyFillRect) (pDraw, pGC, things,
+		      (xRectangle *) &stuff[1]);
+    return (client->noClientException);
+}
+
+int
+ProcPolyFillArc(register ClientPtr client)
+{
+    int		narcs;
+    register GC *pGC;
+    register DrawablePtr pDraw;
+    REQUEST(xPolyFillArcReq);
+
+    REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
+    if (narcs % sizeof(xArc))
+	return(BadLength);
+    narcs /= sizeof(xArc);
+    if (narcs)
+        (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
+    return (client->noClientException);
+}
+
+#ifdef MATCH_CLIENT_ENDIAN
+
+int
+ServerOrder (void)
+{
+    int	    whichbyte = 1;
+
+    if (*((char *) &whichbyte))
+	return LSBFirst;
+    return MSBFirst;
+}
+
+#define ClientOrder(client) ((client)->swapped ? !ServerOrder() : ServerOrder())
+
+void
+ReformatImage (char *base, int nbytes, int bpp, int order)
+{
+    switch (bpp) {
+    case 1:	/* yuck */
+	if (BITMAP_BIT_ORDER != order)
+	    BitOrderInvert ((unsigned char *) base, nbytes);
+#if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8
+	ReformatImage (base, nbytes, BITMAP_SCANLINE_UNIT, order);
+#endif
+	break;
+    case 4:
+	break;  /* yuck */
+    case 8:
+	break;
+    case 16:
+	if (IMAGE_BYTE_ORDER != order)
+	    TwoByteSwap ((unsigned char *) base, nbytes);
+	break;
+    case 32:
+	if (IMAGE_BYTE_ORDER != order)
+	    FourByteSwap ((unsigned char *) base, nbytes);
+	break;
+    }
+}
+#else
+#define ReformatImage(b,n,bpp,o)
+#endif
+
+/* 64-bit server notes: the protocol restricts padding of images to
+ * 8-, 16-, or 32-bits. We would like to have 64-bits for the server
+ * to use internally. Removes need for internal alignment checking.
+ * All of the PutImage functions could be changed individually, but
+ * as currently written, they call other routines which require things
+ * to be 64-bit padded on scanlines, so we changed things here.
+ * If an image would be padded differently for 64- versus 32-, then
+ * copy each scanline to a 64-bit padded scanline.
+ * Also, we need to make sure that the image is aligned on a 64-bit
+ * boundary, even if the scanlines are padded to our satisfaction.
+ */
+int
+ProcPutImage(register ClientPtr client)
+{
+    register	GC *pGC;
+    register	DrawablePtr pDraw;
+    long	length; 	/* length of scanline server padded */
+    long 	lengthProto; 	/* length of scanline protocol padded */
+    char	*tmpImage;
+    REQUEST(xPutImageReq);
+
+    REQUEST_AT_LEAST_SIZE(xPutImageReq);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+    if (stuff->format == XYBitmap)
+    {
+        if ((stuff->depth != 1) ||
+	    (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
+            return BadMatch;
+        length 	    = BitmapBytePad(stuff->width + stuff->leftPad);
+    }
+    else if (stuff->format == XYPixmap)
+    {
+        if ((pDraw->depth != stuff->depth) || 
+	    (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
+            return BadMatch;
+        length      = BitmapBytePad(stuff->width + stuff->leftPad);
+	length      *= stuff->depth;
+    }
+    else if (stuff->format == ZPixmap)
+    {
+        if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0))
+            return BadMatch;
+        length      = PixmapBytePad(stuff->width, stuff->depth);
+    }
+    else
+    {
+	client->errorValue = stuff->format;
+        return BadValue;
+    }
+
+    tmpImage = (char *)&stuff[1];
+    lengthProto = length;
+	
+    if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) + 
+	(sizeof(xPutImageReq) >> 2)) != client->req_len)
+	return BadLength;
+
+    ReformatImage (tmpImage, lengthProto * stuff->height, 
+		   stuff->format == ZPixmap ? BitsPerPixel (stuff->depth) : 1,
+		   ClientOrder(client));
+    
+    (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY,
+		  stuff->width, stuff->height, 
+		  stuff->leftPad, stuff->format, tmpImage);
+
+     return (client->noClientException);
+}
+
+
+int
+DoGetImage(register ClientPtr client, int format, Drawable drawable, 
+           int x, int y, int width, int height, 
+           Mask planemask, xGetImageReply **im_return)
+{
+    register DrawablePtr pDraw;
+    int			nlines, linesPerBuf;
+    register int	linesDone;
+    long		widthBytesLine, length;
+    Mask		plane = 0;
+    char		*pBuf;
+    xGetImageReply	xgi;
+#ifdef XCSECURITY
+    RegionPtr pVisibleRegion = NULL;
+#endif
+
+    if ((format != XYPixmap) && (format != ZPixmap))
+    {
+	client->errorValue = format;
+        return(BadValue);
+    }
+    SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess);
+    if(pDraw->type == DRAWABLE_WINDOW)
+    {
+      if( /* check for being viewable */
+	 !((WindowPtr) pDraw)->realized ||
+	  /* check for being on screen */
+         pDraw->x + x < 0 ||
+ 	 pDraw->x + x + width > pDraw->pScreen->width ||
+         pDraw->y + y < 0 ||
+         pDraw->y + y + height > pDraw->pScreen->height ||
+          /* check for being inside of border */
+         x < - wBorderWidth((WindowPtr)pDraw) ||
+         x + width > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
+         y < -wBorderWidth((WindowPtr)pDraw) ||
+         y + height > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height
+        )
+	    return(BadMatch);
+	xgi.visual = wVisual (((WindowPtr) pDraw));
+    }
+    else
+    {
+      if(x < 0 ||
+         x+width > (int)pDraw->width ||
+         y < 0 ||
+         y+height > (int)pDraw->height
+        )
+	    return(BadMatch);
+	xgi.visual = None;
+    }
+
+    SET_DBE_SRCBUF(pDraw, drawable);
+
+    xgi.type = X_Reply;
+    xgi.sequenceNumber = client->sequence;
+    xgi.depth = pDraw->depth;
+    if(format == ZPixmap)
+    {
+	widthBytesLine = PixmapBytePad(width, pDraw->depth);
+	length = widthBytesLine * height;
+
+    }
+    else 
+    {
+	widthBytesLine = BitmapBytePad(width);
+	plane = ((Mask)1) << (pDraw->depth - 1);
+	/* only planes asked for */
+	length = widthBytesLine * height *
+		 Ones(planemask & (plane | (plane - 1)));
+
+    }
+
+    xgi.length = length;
+
+    if (im_return) {
+	pBuf = (char *)xalloc(sz_xGetImageReply + length);
+	if (!pBuf)
+	    return (BadAlloc);
+	if (widthBytesLine == 0)
+	    linesPerBuf = 0;
+	else
+	    linesPerBuf = height;
+	*im_return = (xGetImageReply *)pBuf;
+	*(xGetImageReply *)pBuf = xgi;
+	pBuf += sz_xGetImageReply;
+    } else {
+	xgi.length = (xgi.length + 3) >> 2;
+	if (widthBytesLine == 0 || height == 0)
+	    linesPerBuf = 0;
+	else if (widthBytesLine >= IMAGE_BUFSIZE)
+	    linesPerBuf = 1;
+	else
+	{
+	    linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
+	    if (linesPerBuf > height)
+		linesPerBuf = height;
+	}
+	length = linesPerBuf * widthBytesLine;
+	if (linesPerBuf < height)
+	{
+	    /* we have to make sure intermediate buffers don't need padding */
+	    while ((linesPerBuf > 1) &&
+		   (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1)))
+	    {
+		linesPerBuf--;
+		length -= widthBytesLine;
+	    }
+	    while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1))
+	    {
+		linesPerBuf++;
+		length += widthBytesLine;
+	    }
+	}
+	if(!(pBuf = (char *) ALLOCATE_LOCAL(length)))
+	    return (BadAlloc);
+	WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
+    }
+
+#ifdef XCSECURITY
+    if (client->trustLevel != XSecurityClientTrusted &&
+	pDraw->type == DRAWABLE_WINDOW)
+    {
+	pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
+	if (pVisibleRegion)
+	{
+	    REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion, -pDraw->x, -pDraw->y);
+	}
+    }
+#endif
+
+    if (linesPerBuf == 0)
+    {
+	/* nothing to do */
+    }
+    else if (format == ZPixmap)
+    {
+        linesDone = 0;
+        while (height - linesDone > 0)
+        {
+	    nlines = min(linesPerBuf, height - linesDone);
+	    (*pDraw->pScreen->GetImage) (pDraw,
+	                                 x,
+				         y + linesDone,
+				         width, 
+				         nlines,
+				         format,
+				         planemask,
+				         (pointer) pBuf);
+#ifdef XCSECURITY
+	    if (pVisibleRegion)
+		SecurityCensorImage(client, pVisibleRegion, widthBytesLine,
+			pDraw, x, y + linesDone, width, 
+			nlines, format, pBuf);
+#endif
+
+	    /* Note that this is NOT a call to WriteSwappedDataToClient,
+               as we do NOT byte swap */
+	    if (!im_return)
+	    {
+		ReformatImage (pBuf, (int)(nlines * widthBytesLine),
+			       BitsPerPixel (pDraw->depth),
+			       ClientOrder(client));
+
+/* Don't split me, gcc pukes when you do */
+		(void)WriteToClient(client,
+				    (int)(nlines * widthBytesLine),
+				    pBuf);
+	    }
+	    linesDone += nlines;
+        }
+    }
+    else /* XYPixmap */
+    {
+        for (; plane; plane >>= 1)
+	{
+	    if (planemask & plane)
+	    {
+	        linesDone = 0;
+	        while (height - linesDone > 0)
+	        {
+		    nlines = min(linesPerBuf, height - linesDone);
+	            (*pDraw->pScreen->GetImage) (pDraw,
+	                                         x,
+				                 y + linesDone,
+				                 width, 
+				                 nlines,
+				                 format,
+				                 plane,
+				                 (pointer)pBuf);
+#ifdef XCSECURITY
+		    if (pVisibleRegion)
+			SecurityCensorImage(client, pVisibleRegion,
+				widthBytesLine,
+				pDraw, x, y + linesDone, width, 
+				nlines, format, pBuf);
+#endif
+
+		    /* Note: NOT a call to WriteSwappedDataToClient,
+		       as we do NOT byte swap */
+		    if (im_return) {
+			pBuf += nlines * widthBytesLine;
+		    } else {
+			ReformatImage (pBuf, 
+				       (int)(nlines * widthBytesLine), 
+				       1,
+				       ClientOrder (client));
+
+/* Don't split me, gcc pukes when you do */
+			(void)WriteToClient(client,
+					(int)(nlines * widthBytesLine),
+					pBuf);
+		    }
+		    linesDone += nlines;
+		}
+            }
+	}
+    }
+#ifdef XCSECURITY
+    if (pVisibleRegion)
+	REGION_DESTROY(pDraw->pScreen, pVisibleRegion);
+#endif
+    if (!im_return)
+	DEALLOCATE_LOCAL(pBuf);
+    return (client->noClientException);
+}
+
+int
+ProcGetImage(register ClientPtr client)
+{
+    REQUEST(xGetImageReq);
+
+    REQUEST_SIZE_MATCH(xGetImageReq);
+
+    return DoGetImage(client, stuff->format, stuff->drawable,
+		      stuff->x, stuff->y,
+		      (int)stuff->width, (int)stuff->height,
+		      stuff->planeMask, (xGetImageReply **)NULL);
+}
+
+int
+ProcPolyText(register ClientPtr client)
+{
+    int	err;
+    REQUEST(xPolyTextReq);
+    DrawablePtr pDraw;
+    GC *pGC;
+
+    REQUEST_AT_LEAST_SIZE(xPolyTextReq);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+    err = PolyText(client,
+		   pDraw,
+		   pGC,
+		   (unsigned char *)&stuff[1],
+		   ((unsigned char *) stuff) + (client->req_len << 2),
+		   stuff->x,
+		   stuff->y,
+		   stuff->reqType,
+		   stuff->drawable);
+
+    if (err == Success)
+    {
+	return(client->noClientException);
+    }
+    else
+	return err;
+}
+
+int
+ProcImageText8(register ClientPtr client)
+{
+    int	err;
+    register DrawablePtr pDraw;
+    register GC *pGC;
+
+    REQUEST(xImageTextReq);
+
+    REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+    err = ImageText(client,
+		    pDraw,
+		    pGC,
+		    stuff->nChars,
+		    (unsigned char *)&stuff[1],
+		    stuff->x,
+		    stuff->y,
+		    stuff->reqType,
+		    stuff->drawable);
+
+    if (err == Success)
+    {
+	return(client->noClientException);
+    }
+    else
+	return err;
+}
+
+int
+ProcImageText16(register ClientPtr client)
+{
+    int	err;
+    register DrawablePtr pDraw;
+    register GC *pGC;
+
+    REQUEST(xImageTextReq);
+
+    REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
+    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+    err = ImageText(client,
+		    pDraw,
+		    pGC,
+		    stuff->nChars,
+		    (unsigned char *)&stuff[1],
+		    stuff->x,
+		    stuff->y,
+		    stuff->reqType,
+		    stuff->drawable);
+
+    if (err == Success)
+    {
+	return(client->noClientException);
+    }
+    else
+	return err;
+}
+
+
+int
+ProcCreateColormap(register ClientPtr client)
+{
+    VisualPtr	pVisual;
+    ColormapPtr	pmap;
+    Colormap	mid;
+    register WindowPtr   pWin;
+    ScreenPtr pScreen;
+    REQUEST(xCreateColormapReq);
+    int i, result;
+
+    REQUEST_SIZE_MATCH(xCreateColormapReq);
+
+    if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll))
+    {
+	client->errorValue = stuff->alloc;
+        return(BadValue);
+    }
+    mid = stuff->mid;
+    LEGAL_NEW_RESOURCE(mid, client);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+
+    pScreen = pWin->drawable.pScreen;
+    for (i = 0, pVisual = pScreen->visuals;
+	 i < pScreen->numVisuals;
+	 i++, pVisual++)
+    {
+	if (pVisual->vid != stuff->visual)
+	    continue;
+	result =  CreateColormap(mid, pScreen, pVisual, &pmap,
+				 (int)stuff->alloc, client->index);
+	if (client->noClientException != Success)
+	    return(client->noClientException);
+	else
+	    return(result);
+    }
+    client->errorValue = stuff->visual;
+    return(BadValue);
+}
+
+int
+ProcFreeColormap(register ClientPtr client)
+{
+    ColormapPtr pmap;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP,
+						SecurityDestroyAccess);
+    if (pmap) 
+    {
+	/* Freeing a default colormap is a no-op */
+	if (!(pmap->flags & IsDefault))
+	    FreeResource(stuff->id, RT_NONE);
+	return (client->noClientException);
+    }
+    else 
+    {
+	client->errorValue = stuff->id;
+	return (BadColor);
+    }
+}
+
+
+int
+ProcCopyColormapAndFree(register ClientPtr client)
+{
+    Colormap	mid;
+    ColormapPtr	pSrcMap;
+    REQUEST(xCopyColormapAndFreeReq);
+    int result;
+
+    REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
+    mid = stuff->mid;
+    LEGAL_NEW_RESOURCE(mid, client);
+    if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client,	stuff->srcCmap,
+		RT_COLORMAP, SecurityReadAccess|SecurityWriteAccess)) )
+    {
+	result = CopyColormapAndFree(mid, pSrcMap, client->index);
+	if (client->noClientException != Success)
+            return(client->noClientException);
+	else
+            return(result);
+    }
+    else
+    {
+	client->errorValue = stuff->srcCmap;
+	return(BadColor);
+    }
+}
+
+int
+ProcInstallColormap(register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
+					    RT_COLORMAP, SecurityReadAccess);
+    if (pcmp)
+    {
+        (*(pcmp->pScreen->InstallColormap)) (pcmp);
+        return (client->noClientException);        
+    }
+    else
+    {
+        client->errorValue = stuff->id;
+        return (BadColor);
+    }
+}
+
+int
+ProcUninstallColormap(register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
+					RT_COLORMAP, SecurityReadAccess);
+    if (pcmp)
+    {
+	if(pcmp->mid != pcmp->pScreen->defColormap)
+            (*(pcmp->pScreen->UninstallColormap)) (pcmp);
+        return (client->noClientException);        
+    }
+    else
+    {
+        client->errorValue = stuff->id;
+        return (BadColor);
+    }
+}
+
+int
+ProcListInstalledColormaps(register ClientPtr client)
+{
+    xListInstalledColormapsReply *preply; 
+    int nummaps;
+    WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+
+    if (!pWin)
+        return(BadWindow);
+
+    preply = (xListInstalledColormapsReply *) 
+		ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
+		     pWin->drawable.pScreen->maxInstalledCmaps *
+		     sizeof(Colormap));
+    if(!preply)
+        return(BadAlloc);
+
+    preply->type = X_Reply;
+    preply->sequenceNumber = client->sequence;
+    nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
+        (pWin->drawable.pScreen, (Colormap *)&preply[1]);
+    preply->nColormaps = nummaps;
+    preply->length = nummaps;
+    WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply);
+    client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+    WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
+    DEALLOCATE_LOCAL(preply);
+    return(client->noClientException);
+}
+
+int
+ProcAllocColor (register ClientPtr client)
+{
+    ColormapPtr pmap;
+    int	retval;
+    xAllocColorReply acr;
+    REQUEST(xAllocColorReq);
+
+    REQUEST_SIZE_MATCH(xAllocColorReq);
+    pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityWriteAccess);
+    if (pmap)
+    {
+#ifdef LBX
+	/*
+	 * If the colormap is grabbed by a proxy, the server will have
+	 * to regain control over the colormap.  This AllocColor request
+	 * will be handled after the server gets back the colormap control.
+	 */
+	if (LbxCheckColorRequest (client, pmap, (xReq *) stuff))
+	    return Success;
+#endif
+	acr.type = X_Reply;
+	acr.length = 0;
+	acr.sequenceNumber = client->sequence;
+	acr.red = stuff->red;
+	acr.green = stuff->green;
+	acr.blue = stuff->blue;
+	acr.pixel = 0;
+	if( (retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
+	                       &acr.pixel, client->index)) )
+	{
+            if (client->noClientException != Success)
+                return(client->noClientException);
+	    else
+	        return (retval);
+	}
+#ifdef PANORAMIX
+	if (noPanoramiXExtension || !pmap->pScreen->myNum)
+#endif
+        WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
+	return (client->noClientException);
+
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcAllocNamedColor (register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xAllocNamedColorReq);
+
+    REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					    RT_COLORMAP, SecurityWriteAccess);
+    if (pcmp)
+    {
+	int		retval;
+
+	xAllocNamedColorReply ancr;
+
+#ifdef LBX
+	/*
+	 * If the colormap is grabbed by a proxy, the server will have
+	 * to regain control over the colormap.  This AllocNamedColor request
+	 * will be handled after the server gets back the colormap control.
+	 */
+	if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
+	    return Success;
+#endif
+	ancr.type = X_Reply;
+	ancr.length = 0;
+	ancr.sequenceNumber = client->sequence;
+
+	if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
+	                 &ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue))
+	{
+	    ancr.screenRed = ancr.exactRed;
+	    ancr.screenGreen = ancr.exactGreen;
+	    ancr.screenBlue = ancr.exactBlue;
+	    ancr.pixel = 0;
+	    if( (retval = AllocColor(pcmp,
+	                 &ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
+			 &ancr.pixel, client->index)) )
+	    {
+                if (client->noClientException != Success)
+                    return(client->noClientException);
+                else
+    	            return(retval);
+	    }
+#ifdef PANORAMIX
+	    if (noPanoramiXExtension || !pcmp->pScreen->myNum)
+#endif
+            WriteReplyToClient(client, sizeof (xAllocNamedColorReply), &ancr);
+	    return (client->noClientException);
+	}
+	else
+	    return(BadName);
+	
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcAllocColorCells (register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xAllocColorCellsReq);
+
+    REQUEST_SIZE_MATCH(xAllocColorCellsReq);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityWriteAccess);
+    if (pcmp)
+    {
+	xAllocColorCellsReply	accr;
+	int			npixels, nmasks, retval;
+	long			length;
+	Pixel			*ppixels, *pmasks;
+
+#ifdef LBX
+	/*
+	 * If the colormap is grabbed by a proxy, the server will have
+	 * to regain control over the colormap.  This AllocColorCells request
+	 * will be handled after the server gets back the colormap control.
+	 */
+	if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
+	    return Success;
+#endif
+	npixels = stuff->colors;
+	if (!npixels)
+	{
+	    client->errorValue = npixels;
+	    return (BadValue);
+	}
+	if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
+	{
+	    client->errorValue = stuff->contiguous;
+	    return (BadValue);
+	}
+	nmasks = stuff->planes;
+	length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
+	ppixels = (Pixel *)ALLOCATE_LOCAL(length);
+	if(!ppixels)
+            return(BadAlloc);
+	pmasks = ppixels + npixels;
+
+	if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks, 
+				    (Bool)stuff->contiguous, ppixels, pmasks)) )
+	{
+	    DEALLOCATE_LOCAL(ppixels);
+            if (client->noClientException != Success)
+                return(client->noClientException);
+	    else
+	        return(retval);
+	}
+#ifdef PANORAMIX
+	if (noPanoramiXExtension || !pcmp->pScreen->myNum)
+#endif
+	{
+	    accr.type = X_Reply;
+	    accr.length = length >> 2;
+	    accr.sequenceNumber = client->sequence;
+	    accr.nPixels = npixels;
+	    accr.nMasks = nmasks;
+	    WriteReplyToClient(client, sizeof (xAllocColorCellsReply), &accr);
+	    client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+	    WriteSwappedDataToClient(client, length, ppixels);
+	}
+	DEALLOCATE_LOCAL(ppixels);
+        return (client->noClientException);        
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcAllocColorPlanes(register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xAllocColorPlanesReq);
+
+    REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityWriteAccess);
+    if (pcmp)
+    {
+	xAllocColorPlanesReply	acpr;
+	int			npixels, retval;
+	long			length;
+	Pixel			*ppixels;
+
+#ifdef LBX
+	/*
+	 * If the colormap is grabbed by a proxy, the server will have
+	 * to regain control over the colormap.  This AllocColorPlanes request
+	 * will be handled after the server gets back the colormap control.
+	 */
+	if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
+	    return Success;
+#endif
+	npixels = stuff->colors;
+	if (!npixels)
+	{
+	    client->errorValue = npixels;
+	    return (BadValue);
+	}
+	if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
+	{
+	    client->errorValue = stuff->contiguous;
+	    return (BadValue);
+	}
+	acpr.type = X_Reply;
+	acpr.sequenceNumber = client->sequence;
+	acpr.nPixels = npixels;
+	length = (long)npixels * sizeof(Pixel);
+	ppixels = (Pixel *)ALLOCATE_LOCAL(length);
+	if(!ppixels)
+            return(BadAlloc);
+	if( (retval = AllocColorPlanes(client->index, pcmp, npixels,
+	    (int)stuff->red, (int)stuff->green, (int)stuff->blue,
+	    (Bool)stuff->contiguous, ppixels,
+	    &acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
+	{
+            DEALLOCATE_LOCAL(ppixels);
+            if (client->noClientException != Success)
+                return(client->noClientException);
+	    else
+	        return(retval);
+	}
+	acpr.length = length >> 2;
+#ifdef PANORAMIX
+	if (noPanoramiXExtension || !pcmp->pScreen->myNum)
+#endif
+	{
+	    WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
+	    client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+	    WriteSwappedDataToClient(client, length, ppixels);
+	}
+	DEALLOCATE_LOCAL(ppixels);
+        return (client->noClientException);        
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcFreeColors(register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xFreeColorsReq);
+
+    REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityWriteAccess);
+    if (pcmp)
+    {
+	int	count;
+        int     retval;
+
+	if(pcmp->flags & AllAllocated)
+	    return(BadAccess);
+	count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
+	retval =  FreeColors(pcmp, client->index, count,
+	    (Pixel *)&stuff[1], (Pixel)stuff->planeMask);
+        if (client->noClientException != Success)
+            return(client->noClientException);
+        else
+	{
+	    client->errorValue = clientErrorValue;
+            return(retval);
+	}
+
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcStoreColors (ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xStoreColorsReq);
+
+    REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityWriteAccess);
+    if (pcmp)
+    {
+	int	count;
+        int     retval;
+
+        count = (client->req_len << 2) - sizeof(xStoreColorsReq);
+	if (count % sizeof(xColorItem))
+	    return(BadLength);
+	count /= sizeof(xColorItem);
+	retval = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
+        if (client->noClientException != Success)
+            return(client->noClientException);
+        else
+	{
+	    client->errorValue = clientErrorValue;
+            return(retval);
+	}
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcStoreNamedColor (register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xStoreNamedColorReq);
+
+    REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityWriteAccess);
+    if (pcmp)
+    {
+	xColorItem	def;
+        int             retval;
+
+	if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1],
+	                 stuff->nbytes, &def.red, &def.green, &def.blue))
+	{
+	    def.flags = stuff->flags;
+	    def.pixel = stuff->pixel;
+	    retval = StoreColors(pcmp, 1, &def);
+            if (client->noClientException != Success)
+                return(client->noClientException);
+	    else
+		return(retval);
+	}
+        return (BadName);        
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcQueryColors(register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xQueryColorsReq);
+
+    REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityReadAccess);
+    if (pcmp)
+    {
+	int			count, retval;
+	xrgb 			*prgbs;
+	xQueryColorsReply	qcr;
+
+	count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2;
+	prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb));
+	if(!prgbs && count)
+            return(BadAlloc);
+	if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
+	{
+   	    if (prgbs) DEALLOCATE_LOCAL(prgbs);
+	    if (client->noClientException != Success)
+                return(client->noClientException);
+	    else
+	    {
+		client->errorValue = clientErrorValue;
+	        return (retval);
+	    }
+	}
+	qcr.type = X_Reply;
+	qcr.length = (count * sizeof(xrgb)) >> 2;
+	qcr.sequenceNumber = client->sequence;
+	qcr.nColors = count;
+	WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
+	if (count)
+	{
+	    client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
+	    WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
+	}
+	if (prgbs) DEALLOCATE_LOCAL(prgbs);
+	return(client->noClientException);
+	
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+} 
+
+int
+ProcLookupColor(register ClientPtr client)
+{
+    ColormapPtr pcmp;
+    REQUEST(xLookupColorReq);
+
+    REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
+    pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+					RT_COLORMAP, SecurityReadAccess);
+    if (pcmp)
+    {
+	xLookupColorReply lcr;
+
+	if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
+	                 &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue))
+	{
+	    lcr.type = X_Reply;
+	    lcr.length = 0;
+	    lcr.sequenceNumber = client->sequence;
+	    lcr.screenRed = lcr.exactRed;
+	    lcr.screenGreen = lcr.exactGreen;
+	    lcr.screenBlue = lcr.exactBlue;
+	    (*pcmp->pScreen->ResolveColor)(&lcr.screenRed,
+	                                   &lcr.screenGreen,
+					   &lcr.screenBlue,
+					   pcmp->pVisual);
+	    WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr);
+	    return(client->noClientException);
+	}
+        return (BadName);        
+    }
+    else
+    {
+        client->errorValue = stuff->cmap;
+        return (BadColor);
+    }
+}
+
+int
+ProcCreateCursor (register ClientPtr client)
+{
+    CursorPtr	pCursor;
+
+    register PixmapPtr 	src;
+    register PixmapPtr 	msk;
+    unsigned char *	srcbits;
+    unsigned char *	mskbits;
+    unsigned short	width, height;
+    long		n;
+    CursorMetricRec cm;
+
+
+    REQUEST(xCreateCursorReq);
+
+    REQUEST_SIZE_MATCH(xCreateCursorReq);
+    LEGAL_NEW_RESOURCE(stuff->cid, client);
+
+    src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source,
+					      RT_PIXMAP, SecurityReadAccess);
+    msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask,
+					      RT_PIXMAP, SecurityReadAccess);
+    if (   src == (PixmapPtr)NULL)
+    {
+	client->errorValue = stuff->source;
+	return (BadPixmap);
+    }
+    if ( msk == (PixmapPtr)NULL)
+    {
+	if (stuff->mask != None)
+	{
+	    client->errorValue = stuff->mask;
+	    return (BadPixmap);
+	}
+    }
+    else if (  src->drawable.width != msk->drawable.width
+	    || src->drawable.height != msk->drawable.height
+	    || src->drawable.depth != 1
+	    || msk->drawable.depth != 1)
+	return (BadMatch);
+
+    width = src->drawable.width;
+    height = src->drawable.height;
+
+    if ( stuff->x > width 
+      || stuff->y > height )
+	return (BadMatch);
+
+    n = BitmapBytePad(width)*height;
+    srcbits = (unsigned char *)xalloc(n);
+    if (!srcbits)
+	return (BadAlloc);
+    mskbits = (unsigned char *)xalloc(n);
+    if (!mskbits)
+    {
+	xfree(srcbits);
+	return (BadAlloc);
+    }
+
+    /* zeroing the (pad) bits helps some ddx cursor handling */
+    bzero((char *)srcbits, n);
+    (* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height,
+					 XYPixmap, 1, (pointer)srcbits);
+    if ( msk == (PixmapPtr)NULL)
+    {
+	register unsigned char *bits = mskbits;
+	while (--n >= 0)
+	    *bits++ = ~0;
+    }
+    else
+    {
+	/* zeroing the (pad) bits helps some ddx cursor handling */
+	bzero((char *)mskbits, n);
+	(* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width,
+					height, XYPixmap, 1, (pointer)mskbits);
+    }
+    cm.width = width;
+    cm.height = height;
+    cm.xhot = stuff->x;
+    cm.yhot = stuff->y;
+    pCursor = AllocCursor( srcbits, mskbits, &cm,
+	    stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
+	    stuff->backRed, stuff->backGreen, stuff->backBlue);
+
+    if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+	    return (client->noClientException);
+    return BadAlloc;
+}
+
+int
+ProcCreateGlyphCursor (register ClientPtr client)
+{
+    CursorPtr pCursor;
+    int res;
+
+    REQUEST(xCreateGlyphCursorReq);
+
+    REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
+    LEGAL_NEW_RESOURCE(stuff->cid, client);
+
+    res = AllocGlyphCursor(stuff->source, stuff->sourceChar,
+			   stuff->mask, stuff->maskChar,
+			   stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
+			   stuff->backRed, stuff->backGreen, stuff->backBlue,
+			   &pCursor, client);
+    if (res != Success)
+	return res;
+    if (AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+	return client->noClientException;
+    return BadAlloc;
+}
+
+
+int
+ProcFreeCursor (register ClientPtr client)
+{
+    CursorPtr pCursor;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id,
+					RT_CURSOR, SecurityDestroyAccess);
+    if (pCursor) 
+    {
+	FreeResource(stuff->id, RT_NONE);
+	return (client->noClientException);
+    }
+    else 
+    {
+	client->errorValue = stuff->id;
+	return (BadCursor);
+    }
+}
+
+int
+ProcQueryBestSize (register ClientPtr client)
+{
+    xQueryBestSizeReply	reply;
+    register DrawablePtr pDraw;
+    ScreenPtr pScreen;
+    REQUEST(xQueryBestSizeReq);
+
+    REQUEST_SIZE_MATCH(xQueryBestSizeReq);
+    if ((stuff->class != CursorShape) && 
+	(stuff->class != TileShape) && 
+	(stuff->class != StippleShape))
+    {
+	client->errorValue = stuff->class;
+        return(BadValue);
+    }
+    SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
+				 SecurityReadAccess);
+    if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
+	return (BadMatch);
+    pScreen = pDraw->pScreen;
+    (* pScreen->QueryBestSize)(stuff->class, &stuff->width,
+			       &stuff->height, pScreen);
+    reply.type = X_Reply;
+    reply.length = 0;
+    reply.sequenceNumber = client->sequence;
+    reply.width = stuff->width;
+    reply.height = stuff->height;
+    WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
+    return (client->noClientException);
+}
+
+
+int
+ProcSetScreenSaver (register ClientPtr client)
+{
+    int blankingOption, exposureOption;
+    REQUEST(xSetScreenSaverReq);
+
+    REQUEST_SIZE_MATCH(xSetScreenSaverReq);
+    blankingOption = stuff->preferBlank;
+    if ((blankingOption != DontPreferBlanking) &&
+        (blankingOption != PreferBlanking) &&
+        (blankingOption != DefaultBlanking))
+    {
+	client->errorValue = blankingOption;
+        return BadValue;
+    }
+    exposureOption = stuff->allowExpose;
+    if ((exposureOption != DontAllowExposures) &&
+        (exposureOption != AllowExposures) &&
+        (exposureOption != DefaultExposures))
+    {
+	client->errorValue = exposureOption;
+        return BadValue;
+    }
+    if (stuff->timeout < -1)
+    {
+	client->errorValue = stuff->timeout;
+        return BadValue;
+    }
+    if (stuff->interval < -1)
+    {
+	client->errorValue = stuff->interval;
+        return BadValue;
+    }
+
+    if (blankingOption == DefaultBlanking)
+	ScreenSaverBlanking = defaultScreenSaverBlanking;
+    else
+	ScreenSaverBlanking = blankingOption; 
+    if (exposureOption == DefaultExposures)
+	ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
+    else
+	ScreenSaverAllowExposures = exposureOption;
+
+    if (stuff->timeout >= 0)
+	ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND;
+    else 
+	ScreenSaverTime = defaultScreenSaverTime;
+    if (stuff->interval >= 0)
+	ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND;
+    else
+	ScreenSaverInterval = defaultScreenSaverInterval;
+
+    SetScreenSaverTimer();
+    return (client->noClientException);
+}
+
+int
+ProcGetScreenSaver(register ClientPtr client)
+{
+    xGetScreenSaverReply rep;
+
+    REQUEST_SIZE_MATCH(xReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.timeout = ScreenSaverTime / MILLI_PER_SECOND;
+    rep.interval = ScreenSaverInterval / MILLI_PER_SECOND;
+    rep.preferBlanking = ScreenSaverBlanking;
+    rep.allowExposures = ScreenSaverAllowExposures;
+    WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
+    return (client->noClientException);
+}
+
+int
+ProcChangeHosts(register ClientPtr client)
+{
+    REQUEST(xChangeHostsReq);
+    int result;
+
+    REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength);
+
+    if(stuff->mode == HostInsert)
+	result = AddHost(client, (int)stuff->hostFamily,
+			 stuff->hostLength, (pointer)&stuff[1]);
+    else if (stuff->mode == HostDelete)
+	result = RemoveHost(client, (int)stuff->hostFamily, 
+			    stuff->hostLength, (pointer)&stuff[1]);  
+    else
+    {
+	client->errorValue = stuff->mode;
+        return BadValue;
+    }
+    if (!result)
+	result = client->noClientException;
+    return (result);
+}
+
+int
+ProcListHosts(register ClientPtr client)
+{
+    xListHostsReply reply;
+    int	len, nHosts, result;
+    pointer	pdata;
+    /* REQUEST(xListHostsReq); */
+
+    REQUEST_SIZE_MATCH(xListHostsReq);
+#ifdef XCSECURITY
+    /* untrusted clients can't list hosts */
+    if (client->trustLevel != XSecurityClientTrusted)
+    {
+	SecurityAudit("client %d attempted to list hosts\n", client->index);
+	return BadAccess;
+    }
+#endif
+    result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
+    if (result != Success)
+	return(result);
+    reply.type = X_Reply;
+    reply.sequenceNumber = client->sequence;
+    reply.nHosts = nHosts;
+    reply.length = len >> 2;
+    WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
+    if (nHosts)
+    {
+	client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
+	WriteSwappedDataToClient(client, len, pdata);
+    }
+    xfree(pdata);
+    return (client->noClientException);
+}
+
+int
+ProcChangeAccessControl(register ClientPtr client)
+{
+    int result;
+    REQUEST(xSetAccessControlReq);
+
+    REQUEST_SIZE_MATCH(xSetAccessControlReq);
+    if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess))
+    {
+	client->errorValue = stuff->mode;
+        return BadValue;
+    }
+    result = ChangeAccessControl(client, stuff->mode == EnableAccess);
+    if (!result)
+	result = client->noClientException;
+    return (result);
+}
+
+int
+ProcKillClient(register ClientPtr client)
+{
+    REQUEST(xResourceReq);
+    ClientPtr	killclient;
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    if (stuff->id == AllTemporary)
+    {
+	CloseDownRetainedResources();
+        return (client->noClientException);
+    }
+
+    if ((killclient = LookupClient(stuff->id, client)))
+    {
+	CloseDownClient(killclient);
+	/* if an LBX proxy gets killed, isItTimeToYield will be set */
+	if (isItTimeToYield || (client == killclient))
+	{
+	    /* force yield and return Success, so that Dispatch()
+	     * doesn't try to touch client
+	     */
+	    isItTimeToYield = TRUE;
+	    return (Success);
+	}
+	return (client->noClientException);
+    }
+    else
+    {
+	client->errorValue = stuff->id;
+	return (BadValue);
+    }
+}
+
+int
+ProcSetFontPath(register ClientPtr client)
+{
+    unsigned char *ptr;
+    unsigned long nbytes, total;
+    long nfonts;
+    int n, result;
+    int error;
+    REQUEST(xSetFontPathReq);
+    
+    REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
+    
+    nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);
+    total = nbytes;
+    ptr = (unsigned char *)&stuff[1];
+    nfonts = stuff->nFonts;
+    while (--nfonts >= 0)
+    {
+	if ((total == 0) || (total < (n = (*ptr + 1))))
+	    return(BadLength);
+	total -= n;
+	ptr += n;
+    }
+    if (total >= 4)
+	return(BadLength);
+    result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
+			 &error);
+    if (!result)
+    {
+	result = client->noClientException;
+	client->errorValue = error;
+    }
+    return (result);
+}
+
+int
+ProcGetFontPath(register ClientPtr client)
+{
+    xGetFontPathReply reply;
+    int stringLens, numpaths;
+    unsigned char *bufferStart;
+    /* REQUEST (xReq); */
+
+    REQUEST_SIZE_MATCH(xReq);
+    bufferStart = GetFontPath(&numpaths, &stringLens);
+
+    reply.type = X_Reply;
+    reply.sequenceNumber = client->sequence;
+    reply.length = (stringLens + numpaths + 3) >> 2;
+    reply.nPaths = numpaths;
+
+    WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
+    if (stringLens || numpaths)
+	(void)WriteToClient(client, stringLens + numpaths, (char *)bufferStart);
+    return(client->noClientException);
+}
+
+int
+ProcChangeCloseDownMode(register ClientPtr client)
+{
+    REQUEST(xSetCloseDownModeReq);
+
+    REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
+    if ((stuff->mode == AllTemporary) ||
+	(stuff->mode == RetainPermanent) ||
+	(stuff->mode == RetainTemporary))
+    {
+	client->closeDownMode = stuff->mode;
+	return (client->noClientException);
+    }
+    else   
+    {
+	client->errorValue = stuff->mode;
+	return (BadValue);
+    }
+}
+
+int ProcForceScreenSaver(register ClientPtr client)
+{    
+    REQUEST(xForceScreenSaverReq);
+
+    REQUEST_SIZE_MATCH(xForceScreenSaverReq);
+    
+    if ((stuff->mode != ScreenSaverReset) && 
+	(stuff->mode != ScreenSaverActive))
+    {
+	client->errorValue = stuff->mode;
+        return BadValue;
+    }
+    SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode);
+    return client->noClientException;
+}
+
+int ProcNoOperation(register ClientPtr client)
+{
+    REQUEST_AT_LEAST_SIZE(xReq);
+    
+    /* noop -- don't do anything */
+    return(client->noClientException);
+}
+
+void
+InitProcVectors(void)
+{
+    int i;
+    for (i = 0; i<256; i++)
+    {
+	if(!ProcVector[i])
+	{
+            ProcVector[i] = SwappedProcVector[i] = ProcBadRequest;
+	    ReplySwapVector[i] = ReplyNotSwappd;
+	}
+#ifdef K5AUTH
+	if (!k5_Vector[i])
+	{
+	    k5_Vector[i] = k5_bad;
+	}
+#endif
+    }
+    for(i = LASTEvent; i < 128; i++)
+    {
+	EventSwapVector[i] = NotImplemented;
+    }
+    
+}
+
+/**********************
+ * CloseDownClient
+ *
+ *  Client can either mark his resources destroy or retain.  If retained and
+ *  then killed again, the client is really destroyed.
+ *********************/
+
+char dispatchExceptionAtReset = DE_RESET;
+
+void
+CloseDownClient(register ClientPtr client)
+{
+    Bool really_close_down = client->clientGone ||
+			     client->closeDownMode == DestroyAll;
+
+    if (!client->clientGone)
+    {
+	/* ungrab server if grabbing client dies */
+	if (grabState != GrabNone && grabClient == client)
+	{
+	    UngrabServer(client);
+	}
+	BITCLEAR(grabWaiters, client->index);
+#ifdef TSOL
+	if (pSecHook)
+            (*pSecHook->DeleteClientFromAnySelections)(client);
+	else
+            DeleteClientFromAnySelections(client);
+#else
+     	DeleteClientFromAnySelections(client);
+#endif /* TSOL */
+
+	DeleteClientFromAnySelections(client);
+	ReleaseActiveGrabs(client);
+	DeleteClientFontStuff(client);
+	if (!really_close_down)
+	{
+	    /*  This frees resources that should never be retained
+	     *  no matter what the close down mode is.  Actually we
+	     *  could do this unconditionally, but it's probably
+	     *  better not to traverse all the client's resources
+	     *  twice (once here, once a few lines down in
+	     *  FreeClientResources) in the common case of
+	     *  really_close_down == TRUE.
+	     */
+	    FreeClientNeverRetainResources(client);
+	    client->clientState = ClientStateRetained;
+  	    if (ClientStateCallback)
+            {
+		NewClientInfoRec clientinfo;
+
+		clientinfo.client = client; 
+		clientinfo.prefix = (xConnSetupPrefix *)NULL;  
+		clientinfo.setup = (xConnSetup *) NULL;
+		CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+            } 
+	}
+	client->clientGone = TRUE;  /* so events aren't sent to client */
+	if (ClientIsAsleep(client))
+	    ClientSignal (client);
+	ProcessWorkQueueZombies();
+#ifdef LBX
+	ProcessQTagZombies();
+#endif
+	CloseDownConnection(client);
+
+	/* If the client made it to the Running stage, nClients has
+	 * been incremented on its behalf, so we need to decrement it
+	 * now.  If it hasn't gotten to Running, nClients has *not*
+	 * been incremented, so *don't* decrement it.
+	 */
+	if (client->clientState != ClientStateInitial &&
+	    client->clientState != ClientStateAuthenticating )
+	{
+	    --nClients;
+	}
+    }
+
+    if (really_close_down)
+    {
+	if (client->clientState == ClientStateRunning && nClients == 0)
+	    dispatchException |= dispatchExceptionAtReset;
+
+	client->clientState = ClientStateGone;
+	if (ClientStateCallback)
+	{
+	    NewClientInfoRec clientinfo;
+
+	    clientinfo.client = client; 
+	    clientinfo.prefix = (xConnSetupPrefix *)NULL;  
+	    clientinfo.setup = (xConnSetup *) NULL;
+	    CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+	} 	    
+	FreeClientResources(client);
+	if (client->index < nextFreeClientID)
+	    nextFreeClientID = client->index;
+	clients[client->index] = NullClient;
+#ifdef SMART_SCHEDULE
+	SmartLastClient = NullClient;
+#endif
+	xfree(client);
+
+	while (!clients[currentMaxClients-1])
+	    currentMaxClients--;
+    }
+}
+
+static void
+KillAllClients()
+{
+    int i;
+    for (i=1; i<currentMaxClients; i++)
+        if (clients[i]) {
+            /* Make sure Retained clients are released. */
+            clients[i]->closeDownMode = DestroyAll;
+            CloseDownClient(clients[i]);     
+        }
+}
+
+/*********************
+ * CloseDownRetainedResources
+ *
+ *    Find all clients that are gone and have terminated in RetainTemporary 
+ *    and  destroy their resources.
+ *********************/
+
+void
+CloseDownRetainedResources()
+{
+    register int i;
+    register ClientPtr client;
+
+    for (i=1; i<currentMaxClients; i++)
+    {
+        client = clients[i];
+        if (client && (client->closeDownMode == RetainTemporary)
+	    && (client->clientGone))
+	    CloseDownClient(client);
+    }
+}
+
+void InitClient(ClientPtr client, int i, pointer ospriv)
+{
+    client->index = i;
+    client->sequence = 0; 
+    client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
+    client->clientGone = FALSE;
+    if (i)
+    {
+	client->closeDownMode = DestroyAll;
+	client->lastDrawable = (DrawablePtr)WindowTable[0];
+	client->lastDrawableID = WindowTable[0]->drawable.id;
+    }
+    else
+    {
+	client->closeDownMode = RetainPermanent;
+	client->lastDrawable = (DrawablePtr)NULL;
+	client->lastDrawableID = INVALID;
+    }
+    client->lastGC = (GCPtr) NULL;
+    client->lastGCID = INVALID;
+    client->numSaved = 0;
+    client->saveSet = (SaveSetElt *)NULL;
+    client->noClientException = Success;
+#ifdef DEBUG
+    client->requestLogIndex = 0;
+#endif
+    client->requestVector = InitialVector;
+    client->osPrivate = ospriv;
+    client->swapped = FALSE;
+    client->big_requests = FALSE;
+    client->priority = 0;
+    client->clientState = ClientStateInitial;
+#ifdef XKB
+    if (!noXkbExtension) {
+	client->xkbClientFlags = 0;
+	client->mapNotifyMask = 0;
+	QueryMinMaxKeyCodes(&client->minKC,&client->maxKC);
+    }
+#endif
+    client->replyBytesRemaining = 0;
+#ifdef LBX
+    client->readRequest = StandardReadRequestFromClient;
+#endif
+#ifdef XCSECURITY
+    client->trustLevel = XSecurityClientTrusted;
+    client->CheckAccess = NULL;
+    client->authId = 0;
+#endif
+#ifdef XAPPGROUP
+    client->appgroup = NULL;
+#endif
+    client->fontResFunc = NULL;
+#ifdef SMART_SCHEDULE
+    client->smart_priority = 0;
+    client->smart_start_tick = SmartScheduleTime;
+    client->smart_stop_tick = SmartScheduleTime;
+    client->smart_check_tick = SmartScheduleTime;
+#endif
+}
+
+extern int clientPrivateLen;
+extern unsigned *clientPrivateSizes;
+extern unsigned totalClientSize;
+
+int
+InitClientPrivates(ClientPtr client)
+{
+    register char *ptr;
+    DevUnion *ppriv;
+    register unsigned *sizes;
+    register unsigned size;
+    register int i;
+
+    if (totalClientSize == sizeof(ClientRec))
+	ppriv = (DevUnion *)NULL;
+    else if (client->index)
+	ppriv = (DevUnion *)(client + 1);
+    else
+    {
+	ppriv = (DevUnion *)xalloc(totalClientSize - sizeof(ClientRec));
+	if (!ppriv)
+	    return 0;
+    }
+    client->devPrivates = ppriv;
+    sizes = clientPrivateSizes;
+    ptr = (char *)(ppriv + clientPrivateLen);
+    for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++)
+    {
+	if ( (size = *sizes) )
+	{
+	    ppriv->ptr = (pointer)ptr;
+	    ptr += size;
+	}
+	else
+	    ppriv->ptr = (pointer)NULL;
+    }
+    return 1;
+}
+
+/************************
+ * int NextAvailableClient(ospriv)
+ *
+ * OS dependent portion can't assign client id's because of CloseDownModes.
+ * Returns NULL if there are no free clients.
+ *************************/
+
+ClientPtr NextAvailableClient(pointer ospriv)
+{
+    register int i;
+    register ClientPtr client;
+    xReq data;
+
+    i = nextFreeClientID;
+    if (i == MAXCLIENTS)
+	return (ClientPtr)NULL;
+    clients[i] = client = (ClientPtr)xalloc(totalClientSize);
+    if (!client)
+	return (ClientPtr)NULL;
+    InitClient(client, i, ospriv);
+    InitClientPrivates(client);
+    if (!InitClientResources(client))
+    {
+	xfree(client);
+	return (ClientPtr)NULL;
+    }
+    data.reqType = 1;
+    data.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
+    if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
+    {
+	FreeClientResources(client);
+	xfree(client);
+	return (ClientPtr)NULL;
+    }
+    if (i == currentMaxClients)
+	currentMaxClients++;
+    while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
+	nextFreeClientID++;
+    if (ClientStateCallback)
+    {
+	NewClientInfoRec clientinfo;
+
+        clientinfo.client = client; 
+        clientinfo.prefix = (xConnSetupPrefix *)NULL;  
+        clientinfo.setup = (xConnSetup *) NULL;
+	CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+    } 	
+    return(client);
+}
+
+int
+ProcInitialConnection(register ClientPtr client)
+{
+    REQUEST(xReq);
+    register xConnClientPrefix *prefix;
+    int whichbyte = 1;
+
+    prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
+    if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
+	return (client->noClientException = -1);
+    if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
+	(!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
+    {
+	client->swapped = TRUE;
+	SwapConnClientPrefix(prefix);
+    }
+    stuff->reqType = 2;
+    stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) +
+		     ((prefix->nbytesAuthString + (unsigned)3) >> 2);
+    if (client->swapped)
+    {
+	swaps(&stuff->length, whichbyte);
+    }
+    ResetCurrentRequest(client);
+    return (client->noClientException);
+}
+
+#ifdef LBX
+void
+IncrementClientCount()
+{
+    nClients++;
+}
+#endif
+
+int
+SendConnSetup(register ClientPtr client, char *reason)
+{
+    register xWindowRoot *root;
+    register int i;
+    int numScreens;
+    char* lConnectionInfo;
+    xConnSetupPrefix* lconnSetupPrefix;
+
+    if (reason)
+    {
+	xConnSetupPrefix csp;
+
+	csp.success = xFalse;
+	csp.lengthReason = strlen(reason);
+	csp.length = (csp.lengthReason + (unsigned)3) >> 2;
+	csp.majorVersion = X_PROTOCOL;
+	csp.minorVersion = X_PROTOCOL_REVISION;
+	if (client->swapped)
+	    WriteSConnSetupPrefix(client, &csp);
+	else
+	    (void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
+        (void)WriteToClient(client, (int)csp.lengthReason, reason);
+	return (client->noClientException = -1);
+    }
+
+    numScreens = screenInfo.numScreens;
+    lConnectionInfo = ConnectionInfo;
+    lconnSetupPrefix = &connSetupPrefix;
+
+    /* We're about to start speaking X protocol back to the client by
+     * sending the connection setup info.  This means the authorization
+     * step is complete, and we can count the client as an
+     * authorized one.
+     */
+    nClients++;
+
+    client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
+    client->sequence = 0;
+#ifdef XAPPGROUP
+    XagConnectionInfo (client, &lconnSetupPrefix, &lConnectionInfo, &numScreens);
+#endif
+    ((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask;
+    ((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
+#ifdef MATCH_CLIENT_ENDIAN
+    ((xConnSetup *)lConnectionInfo)->imageByteOrder = ClientOrder (client);
+    ((xConnSetup *)lConnectionInfo)->bitmapBitOrder = ClientOrder (client);
+#endif
+    /* fill in the "currentInputMask" */
+    root = (xWindowRoot *)(lConnectionInfo + connBlockScreenStart);
+#ifdef PANORAMIX
+    if (noPanoramiXExtension)
+	numScreens = screenInfo.numScreens;
+    else 
+        numScreens = ((xConnSetup *)ConnectionInfo)->numRoots;
+#endif
+
+    for (i=0; i<numScreens; i++) 
+    {
+	register unsigned int j;
+	register xDepth *pDepth;
+
+        root->currentInputMask = WindowTable[i]->eventMask |
+			         wOtherEventMasks (WindowTable[i]);
+	pDepth = (xDepth *)(root + 1);
+	for (j = 0; j < root->nDepths; j++)
+	{
+	    pDepth = (xDepth *)(((char *)(pDepth + 1)) +
+				pDepth->nVisuals * sizeof(xVisualType));
+	}
+	root = (xWindowRoot *)pDepth;
+    }
+
+    if (client->swapped)
+    {
+	WriteSConnSetupPrefix(client, lconnSetupPrefix);
+	WriteSConnectionInfo(client,
+			     (unsigned long)(lconnSetupPrefix->length << 2),
+			     lConnectionInfo);
+    }
+    else
+    {
+	(void)WriteToClient(client, sizeof(xConnSetupPrefix),
+			    (char *) lconnSetupPrefix);
+	(void)WriteToClient(client, (int)(lconnSetupPrefix->length << 2),
+			    lConnectionInfo);
+    }
+    client->clientState = ClientStateRunning;
+    if (ClientStateCallback)
+    {
+	NewClientInfoRec clientinfo;
+
+        clientinfo.client = client; 
+        clientinfo.prefix = lconnSetupPrefix;  
+        clientinfo.setup = (xConnSetup *)lConnectionInfo;
+	CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+    } 	
+    return (client->noClientException);
+}
+
+int
+ProcEstablishConnection(register ClientPtr client)
+{
+    char *reason, *auth_proto, *auth_string;
+    register xConnClientPrefix *prefix;
+    REQUEST(xReq);
+
+    prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
+    auth_proto = (char *)prefix + sz_xConnClientPrefix;
+    auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3);
+    if ((prefix->majorVersion != X_PROTOCOL) ||
+	(prefix->minorVersion != X_PROTOCOL_REVISION))
+	reason = "Protocol version mismatch";
+    else
+	reason = ClientAuthorized(client,
+				  (unsigned short)prefix->nbytesAuthProto,
+				  auth_proto,
+				  (unsigned short)prefix->nbytesAuthString,
+				  auth_string);
+    /*
+     * If Kerberos is being used for this client, the clientState
+     * will be set to ClientStateAuthenticating at this point.
+     * More messages need to be exchanged among the X server, Kerberos
+     * server, and client to figure out if everyone is authorized.
+     * So we don't want to send the connection setup info yet, since
+     * the auth step isn't really done.
+     */
+    if (client->clientState == ClientStateCheckingSecurity)
+	client->clientState = ClientStateCheckedSecurity;
+    else if (client->clientState != ClientStateAuthenticating)
+	return(SendConnSetup(client, reason));
+    return(client->noClientException);
+}
+
+void
+SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, 
+                  XID resId, int errorCode)
+{
+    xError rep;
+
+    rep.type = X_Error;
+    rep.sequenceNumber = client->sequence;
+    rep.errorCode = errorCode;
+    rep.majorCode = majorCode;
+    rep.minorCode = minorCode;
+    rep.resourceID = resId;
+
+    WriteEventsToClient (client, 1, (xEvent *)&rep);
+}
+
+void
+DeleteWindowFromAnySelections(WindowPtr pWin)
+{
+    register int i;
+
+    for (i = 0; i< NumCurrentSelections; i++)
+        if (CurrentSelections[i].pWin == pWin)
+        {
+	    if (SelectionCallback)
+	    {
+	        SelectionInfoRec    info;
+
+		info.selection = &CurrentSelections[i];
+		info.kind = SelectionWindowDestroy;
+		CallCallbacks(&SelectionCallback, &info);
+	    }
+            CurrentSelections[i].pWin = (WindowPtr)NULL;
+            CurrentSelections[i].window = None;
+	    CurrentSelections[i].client = NullClient;
+	}
+}
+
+static void
+DeleteClientFromAnySelections(ClientPtr client)
+{
+    register int i;
+
+    for (i = 0; i< NumCurrentSelections; i++)
+        if (CurrentSelections[i].client == client)
+        {
+	    if (SelectionCallback)
+	    {
+	        SelectionInfoRec    info;
+
+		info.selection = &CurrentSelections[i];
+		info.kind = SelectionWindowDestroy;
+		CallCallbacks(&SelectionCallback, &info);
+	    }
+            CurrentSelections[i].pWin = (WindowPtr)NULL;
+            CurrentSelections[i].window = None;
+	    CurrentSelections[i].client = NullClient;
+	}
+}
+
+void
+MarkClientException(ClientPtr client)
+{
+    client->noClientException = -1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/dix/events.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,4683 @@
+/* $XdotOrg: xc/programs/Xserver/dix/events.c,v 1.17 2005/08/25 22:11:04 anholt Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.51 2004/01/12 17:04:52 tsi 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.
+
+********************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+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.
+
+******************************************************************/
+
+/* Copyright 2006 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.
+ */ 
+
+/* $Xorg: events.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "resource.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+
+#include "dixstruct.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#include "globals.h"
+
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
+#endif
+
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+#ifdef XEVIE
+extern WindowPtr *WindowTable;
+extern int       xevieFlag;
+extern int       xevieClientIndex;
+extern DeviceIntPtr     xeviemouse;
+extern DeviceIntPtr     xeviekb;
+extern Mask      xevieMask;
+extern Mask      xevieFilters[128];
+extern int       xevieEventSent;
+extern int       xevieKBEventSent;
+int    xeviegrabState = 0;
+xEvent *xeviexE;
+#endif
+
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extnsionst.h"
+
+#include "dixevents.h"
+#include "dixgrabs.h"
+#include "dispatch.h"
+
+#define EXTENSION_EVENT_BASE  64
+
+#define NoSuchEvent 0x80000000	/* so doesn't match NoEventMask */
+#define StructureAndSubMask ( StructureNotifyMask | SubstructureNotifyMask )
+#define AllButtonsMask ( \
+	Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
+#define MotionMask ( \
+	PointerMotionMask | Button1MotionMask | \
+	Button2MotionMask | Button3MotionMask | Button4MotionMask | \
+	Button5MotionMask | ButtonMotionMask )
+#define PropagateMask ( \
+	KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | \
+	MotionMask )
+#define PointerGrabMask ( \
+	ButtonPressMask | ButtonReleaseMask | \
+	EnterWindowMask | LeaveWindowMask | \
+	PointerMotionHintMask | KeymapStateMask | \
+	MotionMask )
+#define AllModifiersMask ( \
+	ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
+	Mod3Mask | Mod4Mask | Mod5Mask )
+#define AllEventMasks (lastEventMask|(lastEventMask-1))
+/*
+ * The following relies on the fact that the Button<n>MotionMasks are equal
+ * to the corresponding Button<n>Masks from the current modifier/button state.
+ */
+#define Motion_Filter(class) (PointerMotionMask | \
+			      (class)->state | (class)->motionMask)
+
+
+#define WID(w) ((w) ? ((w)->drawable.id) : 0)
+
+#define XE_KBPTR (xE->u.keyButtonPointer)
+
+
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
+CallbackListPtr EventCallback;
+CallbackListPtr DeviceEventCallback;
+
+#define DNPMCOUNT 8
+
+Mask DontPropagateMasks[DNPMCOUNT];
+static int DontPropagateRefCnts[DNPMCOUNT];
+
+#ifdef DEBUG
+static debug_events = 0;
+#endif
+InputInfo inputInfo;
+
+static struct {
+    QdEventPtr		pending, *pendtail;
+    DeviceIntPtr	replayDev;	/* kludgy rock to put flag for */
+    WindowPtr		replayWin;	/*   ComputeFreezes            */
+    Bool		playingEvents;
+    TimeStamp		time;
+} syncEvents;
+
+/*
+ * The window trace information is used to avoid having to compute all the
+ * windows between the root and the current pointer window each time a button
+ * or key goes down. The grabs on each of those windows must be checked.
+ */
+static WindowPtr *spriteTrace = (WindowPtr *)NULL;
+#define ROOT spriteTrace[0]
+static int spriteTraceSize = 0;
+static int spriteTraceGood;
+
+static  struct {
+    CursorPtr	current;
+    BoxRec	hotLimits;	/* logical constraints of hot spot */
+    Bool	confined;	/* confined to screen */
+#if defined(SHAPE) || defined(PANORAMIX)
+    RegionPtr	hotShape;	/* additional logical shape constraint */
+#endif
+    BoxRec	physLimits;	/* physical constraints of hot spot */
+    WindowPtr	win;		/* window of logical position */
+    HotSpot	hot;		/* logical pointer position */
+    HotSpot	hotPhys;	/* physical pointer position */
+#ifdef PANORAMIX
+    ScreenPtr	screen;		/* all others are in Screen 0 coordinates */
+    RegionRec   Reg1;	        /* Region 1 for confining motion */
+    RegionRec   Reg2;		/* Region 2 for confining virtual motion */
+    WindowPtr   windows[MAXSCREENS];
+    WindowPtr	confineWin;	/* confine window */ 
+#endif
+} sprite;			/* info about the cursor sprite */
+
+#ifdef XEVIE
+WindowPtr xeviewin;
+HotSpot xeviehot;
+#endif
+
+static void DoEnterLeaveEvents(
+    WindowPtr fromWin,
+    WindowPtr toWin,
+    int mode
+);
+
+#ifdef TSOL
+WindowPtr XYToWindow(
+#else
+static WindowPtr XYToWindow(
+#endif /* TSOL */
+    int /*x*/,
+    int /*y*/
+);
+
+extern int lastEvent;
+
+static Mask lastEventMask;
+
+#ifdef TSOL
+extern SecurityHookPtr pSecHook;
+#endif /* TSOL */
+
+#ifdef XINPUT
+extern int DeviceMotionNotify;
+#endif
+
+#define CantBeFiltered NoEventMask
+static Mask filters[128] =
+{
+	NoSuchEvent,		       /* 0 */
+	NoSuchEvent,		       /* 1 */
+	KeyPressMask,		       /* KeyPress */
+	KeyReleaseMask,		       /* KeyRelease */
+	ButtonPressMask,	       /* ButtonPress */
+	ButtonReleaseMask,	       /* ButtonRelease */
+	PointerMotionMask,	       /* MotionNotify (initial state) */
+	EnterWindowMask,	       /* EnterNotify */
+	LeaveWindowMask,	       /* LeaveNotify */
+	FocusChangeMask,	       /* FocusIn */
+	FocusChangeMask,	       /* FocusOut */
+	KeymapStateMask,	       /* KeymapNotify */
+	ExposureMask,		       /* Expose */
+	CantBeFiltered,		       /* GraphicsExpose */
+	CantBeFiltered,		       /* NoExpose */
+	VisibilityChangeMask,	       /* VisibilityNotify */
+	SubstructureNotifyMask,	       /* CreateNotify */
+	StructureAndSubMask,	       /* DestroyNotify */
+	StructureAndSubMask,	       /* UnmapNotify */
+	StructureAndSubMask,	       /* MapNotify */
+	SubstructureRedirectMask,      /* MapRequest */
+	StructureAndSubMask,	       /* ReparentNotify */
+	StructureAndSubMask,	       /* ConfigureNotify */
+	SubstructureRedirectMask,      /* ConfigureRequest */
+	StructureAndSubMask,	       /* GravityNotify */
+	ResizeRedirectMask,	       /* ResizeRequest */
+	StructureAndSubMask,	       /* CirculateNotify */
+	SubstructureRedirectMask,      /* CirculateRequest */
+	PropertyChangeMask,	       /* PropertyNotify */
+	CantBeFiltered,		       /* SelectionClear */
+	CantBeFiltered,		       /* SelectionRequest */
+	CantBeFiltered,		       /* SelectionNotify */
+	ColormapChangeMask,	       /* ColormapNotify */
+	CantBeFiltered,		       /* ClientMessage */
+	CantBeFiltered		       /* MappingNotify */
+};
+
+static CARD8 criticalEvents[32] =
+{
+    0x7c				/* key and button events */
+};
+
+#ifdef PANORAMIX
+
+static void ConfineToShape(RegionPtr shape, int *px, int *py);
+static void SyntheticMotion(int x, int y);
+static void PostNewCursor(void);
+
+static Bool
+XineramaSetCursorPosition(
+    int x, 
+    int y, 
+    Bool generateEvent
+){
+    ScreenPtr pScreen;
+    BoxRec box;
+    int i;
+
+    /* x,y are in Screen 0 coordinates.  We need to decide what Screen
+       to send the message too and what the coordinates relative to 
+       that screen are. */
+
+    pScreen = sprite.screen;
+    x += panoramiXdataPtr[0].x;
+    y += panoramiXdataPtr[0].y;
+
+    if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+								x, y, &box)) 
+    {
+	FOR_NSCREENS(i) 
+	{
+	    if(i == pScreen->myNum) 
+		continue;
+	    if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], x, y, &box))
+	    {
+		pScreen = screenInfo.screens[i];
+		break;
+	    }
+	}
+    }
+
+    sprite.screen = pScreen;
+    sprite.hotPhys.x = x - panoramiXdataPtr[0].x;
+    sprite.hotPhys.y = y - panoramiXdataPtr[0].y;
+    x -= panoramiXdataPtr[pScreen->myNum].x;
+    y -= panoramiXdataPtr[pScreen->myNum].y;
+
+    return (*pScreen->SetCursorPosition)(pScreen, x, y, generateEvent);
+}
+
+
+static void
+XineramaConstrainCursor(void)
+{
+    ScreenPtr pScreen = sprite.screen;
+    BoxRec newBox = sprite.physLimits;
+
+    /* Translate the constraining box to the screen
+       the sprite is actually on */
+    newBox.x1 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
+    newBox.x2 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
+    newBox.y1 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+    newBox.y2 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+
+    (* pScreen->ConstrainCursor)(pScreen, &newBox);
+}
+
+static void
+XineramaCheckPhysLimits(
+    CursorPtr cursor,
+    Bool generateEvents
+){
+    HotSpot new;
+
+    if (!cursor)
+	return;
+ 
+    new = sprite.hotPhys;
+
+    /* I don't care what the DDX has to say about it */
+    sprite.physLimits = sprite.hotLimits;
+
+    /* constrain the pointer to those limits */
+    if (new.x < sprite.physLimits.x1)
+	new.x = sprite.physLimits.x1;
+    else
+	if (new.x >= sprite.physLimits.x2)
+	    new.x = sprite.physLimits.x2 - 1;
+    if (new.y < sprite.physLimits.y1)
+	new.y = sprite.physLimits.y1;
+    else
+	if (new.y >= sprite.physLimits.y2)
+	    new.y = sprite.physLimits.y2 - 1;
+
+    if (sprite.hotShape)  /* more work if the shape is a mess */
+	ConfineToShape(sprite.hotShape, &new.x, &new.y);
+
+    if((new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
+    {
+	XineramaSetCursorPosition (new.x, new.y, generateEvents);
+	if (!generateEvents)
+	    SyntheticMotion(new.x, new.y);
+    }
+
+    /* Tell DDX what the limits are */
+    XineramaConstrainCursor();
+}
+
+
+static Bool
+XineramaSetWindowPntrs(WindowPtr pWin)
+{
+    if(pWin == WindowTable[0]) {
+	    memcpy(sprite.windows, WindowTable, 
+				PanoramiXNumScreens*sizeof(WindowPtr));
+    } else {
+	PanoramiXRes *win;
+	int i;
+
+	win = (PanoramiXRes*)LookupIDByType(pWin->drawable.id, XRT_WINDOW);
+
+	if(!win)
+	    return FALSE;
+
+	for(i = 0; i < PanoramiXNumScreens; i++) {
+	   sprite.windows[i] = LookupIDByType(win->info[i].id, RT_WINDOW);
+	   if(!sprite.windows[i])  /* window is being unmapped */
+		return FALSE;
+	}
+    }
+    return TRUE;
+}
+
+static void
+XineramaCheckVirtualMotion(
+   QdEventPtr qe,
+   WindowPtr pWin
+){
+
+    if (qe)
+    {
+	sprite.hot.pScreen = qe->pScreen;  /* should always be Screen 0 */
+#ifdef XEVIE
+	xeviehot.x =
+#endif
+	sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
+#ifdef XEVIE
+	xeviehot.y =
+#endif
+	sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
+	pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
+					 NullWindow;
+    }
+    if (pWin)
+    {
+	int x, y, off_x, off_y, i;
+	BoxRec lims;
+
+	if(!XineramaSetWindowPntrs(pWin))
+	    return;
+
+	i = PanoramiXNumScreens - 1;
+	
+	REGION_COPY(sprite.screen, &sprite.Reg2, 
+					&sprite.windows[i]->borderSize); 
+	off_x = panoramiXdataPtr[i].x;
+	off_y = panoramiXdataPtr[i].y;
+
+	while(i--) {
+	    x = off_x - panoramiXdataPtr[i].x;
+	    y = off_y - panoramiXdataPtr[i].y;
+
+	    if(x || y)
+		REGION_TRANSLATE(sprite.screen, &sprite.Reg2, x, y);
+		
+	    REGION_UNION(sprite.screen, &sprite.Reg2, &sprite.Reg2, 
+					&sprite.windows[i]->borderSize);
+
+	    off_x = panoramiXdataPtr[i].x;
+	    off_y = panoramiXdataPtr[i].y;
+	}
+
+	lims = *REGION_EXTENTS(sprite.screen, &sprite.Reg2);
+
+        if (sprite.hot.x < lims.x1)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+            sprite.hot.x = lims.x1;
+        else if (sprite.hot.x >= lims.x2)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+            sprite.hot.x = lims.x2 - 1;
+        if (sprite.hot.y < lims.y1)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+            sprite.hot.y = lims.y1;
+        else if (sprite.hot.y >= lims.y2)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+            sprite.hot.y = lims.y2 - 1;
+
+	if (REGION_NUM_RECTS(&sprite.Reg2) > 1) 
+	    ConfineToShape(&sprite.Reg2, &sprite.hot.x, &sprite.hot.y);
+
+	if (qe)
+	{
+	    qe->pScreen = sprite.hot.pScreen;
+	    qe->event->u.keyButtonPointer.rootX = sprite.hot.x;
+	    qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
+	}
+    }
+}
+
+
+static Bool
+XineramaCheckMotion(xEvent *xE)
+{
+    WindowPtr prevSpriteWin = sprite.win;
+
+    if (xE && !syncEvents.playingEvents)
+    {
+	/* Motion events entering DIX get translated to Screen 0
+	   coordinates.  Replayed events have already been 
+	   translated since they've entered DIX before */
+	XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x -
+			  panoramiXdataPtr[0].x;
+	XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y -
+			  panoramiXdataPtr[0].y;
+#ifdef XEVIE
+	xeviehot.x =
+#endif
+	sprite.hot.x = XE_KBPTR.rootX;
+#ifdef XEVIE
+	xeviehot.y =
+#endif
+	sprite.hot.y = XE_KBPTR.rootY;
+	if (sprite.hot.x < sprite.physLimits.x1)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+	    sprite.hot.x = sprite.physLimits.x1;
+	else if (sprite.hot.x >= sprite.physLimits.x2)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+	    sprite.hot.x = sprite.physLimits.x2 - 1;
+	if (sprite.hot.y < sprite.physLimits.y1)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+	    sprite.hot.y = sprite.physLimits.y1;
+	else if (sprite.hot.y >= sprite.physLimits.y2)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+	    sprite.hot.y = sprite.physLimits.y2 - 1;
+
+	if (sprite.hotShape) 
+	    ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
+
+	sprite.hotPhys = sprite.hot;
+	if ((sprite.hotPhys.x != XE_KBPTR.rootX) ||
+	    (sprite.hotPhys.y != XE_KBPTR.rootY))
+	{
+	    XineramaSetCursorPosition(
+			sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
+	}
+	XE_KBPTR.rootX = sprite.hot.x;
+	XE_KBPTR.rootY = sprite.hot.y;
+    }
+
+#ifdef XEVIE
+    xeviewin =
+#endif
+    sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
+
+    if (sprite.win != prevSpriteWin)
+    {
+	if (prevSpriteWin != NullWindow) {
+	    if (!xE)
+		UpdateCurrentTimeIf();
+	    DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal);
+	}
+	PostNewCursor();
+        return FALSE;
+    }
+    return TRUE;
+}
+
+
+static void
+XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents)
+{
+
+    if (syncEvents.playingEvents)
+    {
+	XineramaCheckVirtualMotion((QdEventPtr)NULL, pWin);
+	SyntheticMotion(sprite.hot.x, sprite.hot.y);
+    }
+    else
+    {
+	int x, y, off_x, off_y, i;
+
+	if(!XineramaSetWindowPntrs(pWin))
+	    return;
+
+	i = PanoramiXNumScreens - 1;
+	
+	REGION_COPY(sprite.screen, &sprite.Reg1, 
+					&sprite.windows[i]->borderSize); 
+	off_x = panoramiXdataPtr[i].x;
+	off_y = panoramiXdataPtr[i].y;
+
+	while(i--) {
+	    x = off_x - panoramiXdataPtr[i].x;
+	    y = off_y - panoramiXdataPtr[i].y;
+
+	    if(x || y)
+		REGION_TRANSLATE(sprite.screen, &sprite.Reg1, x, y);
+		
+	    REGION_UNION(sprite.screen, &sprite.Reg1, &sprite.Reg1, 
+					&sprite.windows[i]->borderSize);
+
+	    off_x = panoramiXdataPtr[i].x;
+	    off_y = panoramiXdataPtr[i].y;
+	}
+
+	sprite.hotLimits = *REGION_EXTENTS(sprite.screen, &sprite.Reg1);
+
+	if(REGION_NUM_RECTS(&sprite.Reg1) > 1)
+	   sprite.hotShape = &sprite.Reg1;
+	else
+	   sprite.hotShape = NullRegion;
+	
+	sprite.confined = FALSE;
+	sprite.confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
+
+	XineramaCheckPhysLimits(sprite.current, generateEvents);
+    }
+}
+
+
+static void
+XineramaChangeToCursor(CursorPtr cursor)
+{
+    if (cursor != sprite.current)
+    {
+	if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
+		(sprite.current->bits->yhot != cursor->bits->yhot))
+	    XineramaCheckPhysLimits(cursor, FALSE);
+    	(*sprite.screen->DisplayCursor)(sprite.screen, cursor);
+	FreeCursor(sprite.current, (Cursor)0);
+	sprite.current = cursor;
+	sprite.current->refcnt++;
+    }
+}
+
+
+#endif  /* PANORAMIX */
+
+void
+SetMaskForEvent(Mask mask, int event)
+{
+    if ((event < LASTEvent) || (event >= 128))
+	FatalError("SetMaskForEvent: bogus event number");
+    filters[event] = mask;
+}
+
+void
+SetCriticalEvent(int event)
+{
+    if (event >= 128)
+	FatalError("SetCriticalEvent: bogus event number");
+    criticalEvents[event >> 3] |= 1 << (event & 7);
+}
+
+static void
+SyntheticMotion(int x, int y)
+{
+    xEvent xE;
+
+#ifdef PANORAMIX
+    /* Translate back to the sprite screen since processInputProc
+       will translate from sprite screen to screen 0 upon reentry
+       to the DIX layer */
+    if(!noPanoramiXExtension) {
+	x += panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x;
+	y += panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y;
+    }
+#endif
+    xE.u.keyButtonPointer.rootX = x;
+    xE.u.keyButtonPointer.rootY = y;
+    if (syncEvents.playingEvents)
+	xE.u.keyButtonPointer.time = syncEvents.time.milliseconds;
+    else
+	xE.u.keyButtonPointer.time = currentTime.milliseconds;
+    xE.u.u.type = MotionNotify;
+    (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1);
+}
+
+#ifdef SHAPE
+static void
+ConfineToShape(RegionPtr shape, int *px, int *py)
+{
+    BoxRec box;
+    int x = *px, y = *py;
+    int incx = 1, incy = 1;
+
+    if (POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box))
+	return;
+    box = *REGION_EXTENTS(sprite.hot.pScreen, shape);
+    /* this is rather crude */
+    do {
+	x += incx;
+	if (x >= box.x2)
+	{
+	    incx = -1;
+	    x = *px - 1;
+	}
+	else if (x < box.x1)
+	{
+	    incx = 1;
+	    x = *px;
+	    y += incy;
+	    if (y >= box.y2)
+	    {
+		incy = -1;
+		y = *py - 1;
+	    }
+	    else if (y < box.y1)
+		return; /* should never get here! */
+	}
+    } while (!POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box));
+    *px = x;
+    *py = y;
+}
+#endif
+
+static void
+CheckPhysLimits(
+    CursorPtr cursor,
+    Bool generateEvents,
+    Bool confineToScreen,
+    ScreenPtr pScreen)
+{
+    HotSpot new;
+
+    if (!cursor)
+	return;
+    new = sprite.hotPhys;
+    if (pScreen)
+	new.pScreen = pScreen;
+    else
+	pScreen = new.pScreen;
+    (*pScreen->CursorLimits) (pScreen, cursor, &sprite.hotLimits,
+			      &sprite.physLimits);
+    sprite.confined = confineToScreen;
+    (* pScreen->ConstrainCursor)(pScreen, &sprite.physLimits);
+    if (new.x < sprite.physLimits.x1)
+	new.x = sprite.physLimits.x1;
+    else
+	if (new.x >= sprite.physLimits.x2)
+	    new.x = sprite.physLimits.x2 - 1;
+    if (new.y < sprite.physLimits.y1)
+	new.y = sprite.physLimits.y1;
+    else
+	if (new.y >= sprite.physLimits.y2)
+	    new.y = sprite.physLimits.y2 - 1;
+#ifdef SHAPE
+    if (sprite.hotShape)
+	ConfineToShape(sprite.hotShape, &new.x, &new.y); 
+#endif
+    if ((pScreen != sprite.hotPhys.pScreen) ||
+	(new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
+    {
+	if (pScreen != sprite.hotPhys.pScreen)
+	    sprite.hotPhys = new;
+	(*pScreen->SetCursorPosition) (pScreen, new.x, new.y, generateEvents);
+	if (!generateEvents)
+	    SyntheticMotion(new.x, new.y);
+    }
+}
+
+static void
+CheckVirtualMotion(
+    register QdEventPtr qe,
+    register WindowPtr pWin)
+{
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension) {
+	XineramaCheckVirtualMotion(qe, pWin);
+	return;
+    }
+#endif
+    if (qe)
+    {
+	sprite.hot.pScreen = qe->pScreen;
+#ifdef XEVIE
+	xeviehot.x =
+#endif
+	sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
+#ifdef XEVIE
+	xeviehot.y =
+#endif
+	sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
+	pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
+					 NullWindow;
+    }
+    if (pWin)
+    {
+	BoxRec lims;
+
+	if (sprite.hot.pScreen != pWin->drawable.pScreen)
+	{
+	    sprite.hot.pScreen = pWin->drawable.pScreen;
+#ifdef XEVIE
+	    xeviehot.x = xeviehot.y = 0;
+#endif
+	    sprite.hot.x = sprite.hot.y = 0;
+	}
+	lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize);
+	if (sprite.hot.x < lims.x1)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+	    sprite.hot.x = lims.x1;
+	else if (sprite.hot.x >= lims.x2)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+	    sprite.hot.x = lims.x2 - 1;
+	if (sprite.hot.y < lims.y1)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+	    sprite.hot.y = lims.y1;
+	else if (sprite.hot.y >= lims.y2)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+	    sprite.hot.y = lims.y2 - 1;
+#ifdef SHAPE
+	if (wBoundingShape(pWin))
+	    ConfineToShape(&pWin->borderSize, &sprite.hot.x, &sprite.hot.y);
+#endif
+	if (qe)
+	{
+	    qe->pScreen = sprite.hot.pScreen;
+	    qe->event->u.keyButtonPointer.rootX = sprite.hot.x;
+	    qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
+	}
+    }
+    ROOT = WindowTable[sprite.hot.pScreen->myNum];
+}
+
+static void
+ConfineCursorToWindow(WindowPtr pWin, Bool generateEvents, Bool confineToScreen)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension) {
+	XineramaConfineCursorToWindow(pWin, generateEvents);
+	return;
+    }	
+#endif
+
+    if (syncEvents.playingEvents)
+    {
+	CheckVirtualMotion((QdEventPtr)NULL, pWin);
+	SyntheticMotion(sprite.hot.x, sprite.hot.y);
+    }
+    else
+    {
+	sprite.hotLimits = *REGION_EXTENTS( pScreen, &pWin->borderSize);
+#ifdef SHAPE
+	sprite.hotShape = wBoundingShape(pWin) ? &pWin->borderSize
+					       : NullRegion;
+#endif
+	CheckPhysLimits(sprite.current, generateEvents, confineToScreen,
+			pScreen);
+    }
+}
+
+Bool
+PointerConfinedToScreen()
+{
+    return sprite.confined;
+}
+
+static void
+ChangeToCursor(CursorPtr cursor)
+{
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension) {
+	XineramaChangeToCursor(cursor);
+	return;
+    }
+#endif
+
+    if (cursor != sprite.current)
+    {
+	if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
+		(sprite.current->bits->yhot != cursor->bits->yhot))
+	    CheckPhysLimits(cursor, FALSE, sprite.confined,
+			    (ScreenPtr)NULL);
+	(*sprite.hotPhys.pScreen->DisplayCursor) (sprite.hotPhys.pScreen,
+						  cursor);
+	FreeCursor(sprite.current, (Cursor)0);
+	sprite.current = cursor;
+	sprite.current->refcnt++;
+    }
+}
+
+/* returns true if b is a descendent of a */
+Bool
+IsParent(register WindowPtr a, register WindowPtr b)
+{
+    for (b = b->parent; b; b = b->parent)
+	if (b == a) return TRUE;
+    return FALSE;
+}
+
+static void
+PostNewCursor(void)
+{
+    register    WindowPtr win;
+    register    GrabPtr grab = inputInfo.pointer->grab;
+
+    if (syncEvents.playingEvents)
+	return;
+    if (grab)
+    {
+	if (grab->cursor)
+	{
+	    ChangeToCursor(grab->cursor);
+	    return;
+	}
+	if (IsParent(grab->window, sprite.win))
+	    win = sprite.win;
+	else
+	    win = grab->window;
+    }
+    else
+	win = sprite.win;
+    for (; win; win = win->parent)
+	if (win->optional && win->optional->cursor != NullCursor)
+	{
+	    ChangeToCursor(win->optional->cursor);
+	    return;
+	}
+}
+
+WindowPtr
+GetCurrentRootWindow()
+{
+    return ROOT;
+}
+
+WindowPtr
+GetSpriteWindow()
+{
+    return sprite.win;
+}
+
+CursorPtr
+GetSpriteCursor()
+{
+    return sprite.current;
+}
+
+void
+GetSpritePosition(int *px, int *py)
+{
+    *px = sprite.hotPhys.x;
+    *py = sprite.hotPhys.y;
+}
+
+#ifdef PANORAMIX
+int
+XineramaGetCursorScreen()
+{
+    if(!noPanoramiXExtension) {
+	return sprite.screen->myNum;
+    } else {
+	return 0;
+    }
+}
+#endif /* PANORAMIX */
+
+#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
+
+static void
+MonthChangedOrBadTime(register xEvent *xE)
+{
+    /* If the ddx/OS is careless about not processing timestamped events from
+     * different sources in sorted order, then it's possible for time to go
+     * backwards when it should not.  Here we ensure a decent time.
+     */
+    if ((currentTime.milliseconds - XE_KBPTR.time) > TIMESLOP)
+	currentTime.months++;
+    else
+	XE_KBPTR.time = currentTime.milliseconds;
+}
+
+#define NoticeTime(xE) { \
+    if ((xE)->u.keyButtonPointer.time < currentTime.milliseconds) \
+	MonthChangedOrBadTime(xE); \
+    currentTime.milliseconds = (xE)->u.keyButtonPointer.time; \
+    lastDeviceEventTime = currentTime; }
+
+void
+NoticeEventTime(register xEvent *xE)
+{
+    if (!syncEvents.playingEvents)
+	NoticeTime(xE);
+}
+
+/**************************************************************************
+ *            The following procedures deal with synchronous events       *
+ **************************************************************************/
+
+void
+EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count)
+{
+    register QdEventPtr tail = *syncEvents.pendtail;
+    register QdEventPtr qe;
+    xEvent		*qxE;
+
+    NoticeTime(xE);
+
+#ifdef XKB
+    /* Fix for key repeating bug. */
+    if (device->key != NULL && device->key->xkbInfo != NULL && 
+	xE->u.u.type == KeyRelease)
+	AccessXCancelRepeatKey(device->key->xkbInfo, xE->u.u.detail);
+#endif
+
+    if (DeviceEventCallback)
+    {
+	DeviceEventInfoRec eventinfo;
+	/*  The RECORD spec says that the root window field of motion events
+	 *  must be valid.  At this point, it hasn't been filled in yet, so
+	 *  we do it here.  The long expression below is necessary to get
+	 *  the current root window; the apparently reasonable alternative
+	 *  GetCurrentRootWindow()->drawable.id doesn't give you the right
+	 *  answer on the first motion event after a screen change because
+	 *  the data that GetCurrentRootWindow relies on hasn't been
+	 *  updated yet.
+	 */
+	if (xE->u.u.type == MotionNotify)
+	    XE_KBPTR.root =
+		WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
+	eventinfo.events = xE;
+	eventinfo.count = count;
+	CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+    }
+    if (xE->u.u.type == MotionNotify)
+    {
+#ifdef PANORAMIX
+	if(!noPanoramiXExtension) {
+	    XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x -
+			      panoramiXdataPtr[0].x;
+	    XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y -
+			      panoramiXdataPtr[0].y;
+	}
+#endif
+	sprite.hotPhys.x = XE_KBPTR.rootX;
+	sprite.hotPhys.y = XE_KBPTR.rootY;
+	/* do motion compression */
+	if (tail &&
+	    (tail->event->u.u.type == MotionNotify) &&
+	    (tail->pScreen == sprite.hotPhys.pScreen))
+	{
+	    tail->event->u.keyButtonPointer.rootX = sprite.hotPhys.x;
+	    tail->event->u.keyButtonPointer.rootY = sprite.hotPhys.y;
+	    tail->event->u.keyButtonPointer.time = XE_KBPTR.time;
+	    tail->months = currentTime.months;
+	    return;
+	}
+    }
+    qe = (QdEventPtr)xalloc(sizeof(QdEventRec) + (count * sizeof(xEvent)));
+    if (!qe)
+	return;
+    qe->next = (QdEventPtr)NULL;
+    qe->device = device;
+    qe->pScreen = sprite.hotPhys.pScreen;
+    qe->months = currentTime.months;
+    qe->event = (xEvent *)(qe + 1);
+    qe->evcount = count;
+    for (qxE = qe->event; --count >= 0; qxE++, xE++)
+	*qxE = *xE;
+    if (tail)
+	syncEvents.pendtail = &tail->next;
+    *syncEvents.pendtail = qe;
+}
+
+static void
+PlayReleasedEvents(void)
+{
+    register QdEventPtr *prev, qe;
+    register DeviceIntPtr dev;
+
+    prev = &syncEvents.pending;
+    while ( (qe = *prev) )
+    {
+	if (!qe->device->sync.frozen)
+	{
+	    *prev = qe->next;
+	    if (*syncEvents.pendtail == *prev)
+		syncEvents.pendtail = prev;
+	    if (qe->event->u.u.type == MotionNotify)
+		CheckVirtualMotion(qe, NullWindow);
+	    syncEvents.time.months = qe->months;
+	    syncEvents.time.milliseconds = qe->event->u.keyButtonPointer.time;
+#ifdef PANORAMIX
+	   /* Translate back to the sprite screen since processInputProc
+	      will translate from sprite screen to screen 0 upon reentry
+	      to the DIX layer */
+	    if(!noPanoramiXExtension) {
+		qe->event->u.keyButtonPointer.rootX += 
+			panoramiXdataPtr[0].x - 
+			panoramiXdataPtr[sprite.screen->myNum].x;
+		qe->event->u.keyButtonPointer.rootY += 
+			panoramiXdataPtr[0].y - 
+			panoramiXdataPtr[sprite.screen->myNum].y;
+	    }
+#endif
+	    (*qe->device->public.processInputProc)(qe->event, qe->device,
+						   qe->evcount);
+	    xfree(qe);
+	    for (dev = inputInfo.devices; dev && dev->sync.frozen; dev = dev->next)
+		;
+	    if (!dev)
+		break;
+	    /* Playing the event may have unfrozen another device. */
+	    /* So to play it safe, restart at the head of the queue */
+	    prev = &syncEvents.pending;
+	}
+	else
+	    prev = &qe->next;
+    } 
+}
+
+static void
+FreezeThaw(register DeviceIntPtr dev, Bool frozen)
+{
+    dev->sync.frozen = frozen;
+    if (frozen)
+	dev->public.processInputProc = dev->public.enqueueInputProc;
+    else
+	dev->public.processInputProc = dev->public.realInputProc;
+}
+
+void
+ComputeFreezes()
+{
+    register DeviceIntPtr replayDev = syncEvents.replayDev;
+    register int i;
+    WindowPtr w;
+    register xEvent *xE;
+    int count;
+    GrabPtr grab;
+    register DeviceIntPtr dev;
+
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+	FreezeThaw(dev, dev->sync.other || (dev->sync.state >= FROZEN));
+    if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending))
+	return;
+    syncEvents.playingEvents = TRUE;
+    if (replayDev)
+    {
+	xE = replayDev->sync.event;
+	count = replayDev->sync.evcount;
+	syncEvents.replayDev = (DeviceIntPtr)NULL;
+
+        w = XYToWindow( XE_KBPTR.rootX, XE_KBPTR.rootY);
+	for (i = 0; i < spriteTraceGood; i++)
+	{
+	    if (syncEvents.replayWin == spriteTrace[i])
+	    {
+		if (!CheckDeviceGrabs(replayDev, xE, i+1, count)) {
+		    if (replayDev->focus)
+			DeliverFocusedEvent(replayDev, xE, w, count);
+		    else
+			DeliverDeviceEvents(w, xE, NullGrab, NullWindow,
+					        replayDev, count);
+		}
+		goto playmore;
+	    }
+	}
+	/* must not still be in the same stack */
+	if (replayDev->focus)
+	    DeliverFocusedEvent(replayDev, xE, w, count);
+	else
+	    DeliverDeviceEvents(w, xE, NullGrab, NullWindow, replayDev, count);
+    }
+playmore:
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+    {
+	if (!dev->sync.frozen)
+	{
+	    PlayReleasedEvents();
+	    break;
+	}
+    }
+    syncEvents.playingEvents = FALSE;
+    /* the following may have been skipped during replay, so do it now */
+    if ((grab = inputInfo.pointer->grab) && grab->confineTo)
+    {
+	if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+	    sprite.hotPhys.x = sprite.hotPhys.y = 0;
+	ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+    }
+    else
+	ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+			      TRUE, FALSE);
+    PostNewCursor();
+}
+
+#ifdef RANDR
+void
+ScreenRestructured (ScreenPtr pScreen)
+{
+    GrabPtr grab;
+
+    if ((grab = inputInfo.pointer->grab) && grab->confineTo)
+    {
+	if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+	    sprite.hotPhys.x = sprite.hotPhys.y = 0;
+	ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+    }
+    else
+	ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+			      TRUE, FALSE);
+}
+#endif
+
+void
+CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
+{
+    register GrabPtr grab = thisDev->grab;
+    register DeviceIntPtr dev;
+
+    if (thisMode == GrabModeSync)
+	thisDev->sync.state = FROZEN_NO_EVENT;
+    else
+    {	/* free both if same client owns both */
+	thisDev->sync.state = THAWED;
+	if (thisDev->sync.other &&
+	    (CLIENT_BITS(thisDev->sync.other->resource) ==
+	     CLIENT_BITS(grab->resource)))
+	    thisDev->sync.other = NullGrab;
+    }
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+    {
+	if (dev != thisDev)
+	{
+	    if (otherMode == GrabModeSync)
+		dev->sync.other = grab;
+	    else
+	    {	/* free both if same client owns both */
+		if (dev->sync.other &&
+		    (CLIENT_BITS(dev->sync.other->resource) ==
+		     CLIENT_BITS(grab->resource)))
+		    dev->sync.other = NullGrab;
+	    }
+	}
+    }
+    ComputeFreezes();
+}
+
+void
+ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, 
+                    TimeStamp time, Bool autoGrab)
+{
+    WindowPtr oldWin = (mouse->grab) ? mouse->grab->window
+				     : sprite.win;
+
+    if (grab->confineTo)
+    {
+	if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+	    sprite.hotPhys.x = sprite.hotPhys.y = 0;
+	ConfineCursorToWindow(grab->confineTo, FALSE, TRUE);
+    }
+    DoEnterLeaveEvents(oldWin, grab->window, NotifyGrab);
+    mouse->valuator->motionHintWindow = NullWindow;
+    if (syncEvents.playingEvents)
+	mouse->grabTime = syncEvents.time;
+    else
+	mouse->grabTime = time;
+    if (grab->cursor)
+	grab->cursor->refcnt++;
+    mouse->activeGrab = *grab;
+    mouse->grab = &mouse->activeGrab;
+    mouse->fromPassiveGrab = autoGrab;
+    PostNewCursor();
+    CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
+}
+
+void
+DeactivatePointerGrab(register DeviceIntPtr mouse)
+{
+    register GrabPtr grab = mouse->grab;
+    register DeviceIntPtr dev;
+
+    mouse->valuator->motionHintWindow = NullWindow;
+    mouse->grab = NullGrab;
+    mouse->sync.state = NOT_GRABBED;
+    mouse->fromPassiveGrab = FALSE;
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+    {
+	if (dev->sync.other == grab)
+	    dev->sync.other = NullGrab;
+    }
+    DoEnterLeaveEvents(grab->window, sprite.win, NotifyUngrab);
+    if (grab->confineTo)
+	ConfineCursorToWindow(ROOT, FALSE, FALSE);
+    PostNewCursor();
+    if (grab->cursor)
+	FreeCursor(grab->cursor, (Cursor)0);
+    ComputeFreezes();
+}
+
+void
+ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive)
+{
+    WindowPtr oldWin;
+
+    if (keybd->grab)
+	oldWin = keybd->grab->window;
+    else if (keybd->focus)
+	oldWin = keybd->focus->win;
+    else
+	oldWin = sprite.win;
+    if (oldWin == FollowKeyboardWin)
+	oldWin = inputInfo.keyboard->focus->win;
+    if (keybd->valuator)
+	keybd->valuator->motionHintWindow = NullWindow;
+    DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);
+    if (syncEvents.playingEvents)
+	keybd->grabTime = syncEvents.time;
+    else
+	keybd->grabTime = time;
+    keybd->activeGrab = *grab;
+    keybd->grab = &keybd->activeGrab;
+    keybd->fromPassiveGrab = passive;
+    CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
+}
+
+void
+DeactivateKeyboardGrab(register DeviceIntPtr keybd)
+{
+    register GrabPtr grab = keybd->grab;
+    register DeviceIntPtr dev;
+    register WindowPtr focusWin = keybd->focus ? keybd->focus->win
+					       : sprite.win;
+
+    if (focusWin == FollowKeyboardWin)
+	focusWin = inputInfo.keyboard->focus->win;
+    if (keybd->valuator)
+	keybd->valuator->motionHintWindow = NullWindow;
+    keybd->grab = NullGrab;
+    keybd->sync.state = NOT_GRABBED;
+    keybd->fromPassiveGrab = FALSE;
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+    {
+	if (dev->sync.other == grab)
+	    dev->sync.other = NullGrab;
+    }
+    DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
+    ComputeFreezes();
+}
+
+void
+AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
+{
+    Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced;
+    TimeStamp grabTime;
+    register DeviceIntPtr dev;
+
+    thisGrabbed = thisDev->grab && SameClient(thisDev->grab, client);
+    thisSynced = FALSE;
+    otherGrabbed = FALSE;
+    othersFrozen = TRUE;
+    grabTime = thisDev->grabTime;
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+    {
+	if (dev == thisDev)
+	    continue;
+	if (dev->grab && SameClient(dev->grab, client))
+	{
+	    if (!(thisGrabbed || otherGrabbed) ||
+		(CompareTimeStamps(dev->grabTime, grabTime) == LATER))
+		grabTime = dev->grabTime;
+	    otherGrabbed = TRUE;
+	    if (thisDev->sync.other == dev->grab)
+		thisSynced = TRUE;
+	    if (dev->sync.state < FROZEN)
+		othersFrozen = FALSE;
+	}
+	else if (!dev->sync.other || !SameClient(dev->sync.other, client))
+	    othersFrozen = FALSE;
+    }
+    if (!((thisGrabbed && thisDev->sync.state >= FROZEN) || thisSynced))
+	return;
+    if ((CompareTimeStamps(time, currentTime) == LATER) ||
+	(CompareTimeStamps(time, grabTime) == EARLIER))
+	return;
+    switch (newState)
+    {
+	case THAWED:	 	       /* Async */
+	    if (thisGrabbed)
+		thisDev->sync.state = THAWED;
+	    if (thisSynced)
+		thisDev->sync.other = NullGrab;
+	    ComputeFreezes();
+	    break;
+	case FREEZE_NEXT_EVENT:		/* Sync */
+	    if (thisGrabbed)
+	    {
+		thisDev->sync.state = FREEZE_NEXT_EVENT;
+		if (thisSynced)
+		    thisDev->sync.other = NullGrab;
+		ComputeFreezes();
+	    }
+	    break;
+	case THAWED_BOTH:		/* AsyncBoth */
+	    if (othersFrozen)
+	    {
+		for (dev = inputInfo.devices; dev; dev = dev->next)
+		{
+		    if (dev->grab && SameClient(dev->grab, client))
+			dev->sync.state = THAWED;
+		    if (dev->sync.other && SameClient(dev->sync.other, client))
+			dev->sync.other = NullGrab;
+		}
+		ComputeFreezes();
+	    }
+	    break;
+	case FREEZE_BOTH_NEXT_EVENT:	/* SyncBoth */
+	    if (othersFrozen)
+	    {
+		for (dev = inputInfo.devices; dev; dev = dev->next)
+		{
+		    if (dev->grab && SameClient(dev->grab, client))
+			dev->sync.state = FREEZE_BOTH_NEXT_EVENT;
+		    if (dev->sync.other && SameClient(dev->sync.other, client))
+			dev->sync.other = NullGrab;
+		}
+		ComputeFreezes();
+	    }
+	    break;
+	case NOT_GRABBED:		/* Replay */
+	    if (thisGrabbed && thisDev->sync.state == FROZEN_WITH_EVENT)
+	    {
+		if (thisSynced)
+		    thisDev->sync.other = NullGrab;
+		syncEvents.replayDev = thisDev;
+		syncEvents.replayWin = thisDev->grab->window;
+		(*thisDev->DeactivateGrab)(thisDev);
+		syncEvents.replayDev = (DeviceIntPtr)NULL;
+	    }
+	    break;
+	case THAW_OTHERS:		/* AsyncOthers */
+	    if (othersFrozen)
+	    {
+		for (dev = inputInfo.devices; dev; dev = dev->next)
+		{
+		    if (dev == thisDev)
+			continue;
+		    if (dev->grab && SameClient(dev->grab, client))
+			dev->sync.state = THAWED;
+		    if (dev->sync.other && SameClient(dev->sync.other, client))
+			dev->sync.other = NullGrab;
+		}
+		ComputeFreezes();
+	    }
+	    break;
+    }
+}
+
+int
+ProcAllowEvents(register ClientPtr client)
+{
+    TimeStamp		time;
+    DeviceIntPtr	mouse = inputInfo.pointer;
+    DeviceIntPtr	keybd = inputInfo.keyboard;
+    REQUEST(xAllowEventsReq);
+
+    REQUEST_SIZE_MATCH(xAllowEventsReq);
+    time = ClientTimeToServerTime(stuff->time);
+    switch (stuff->mode)
+    {
+	case ReplayPointer:
+	    AllowSome(client, time, mouse, NOT_GRABBED);
+	    break;
+	case SyncPointer: 
+	    AllowSome(client, time, mouse, FREEZE_NEXT_EVENT);
+	    break;
+	case AsyncPointer: 
+	    AllowSome(client, time, mouse, THAWED);
+	    break;
+	case ReplayKeyboard: 
+	    AllowSome(client, time, keybd, NOT_GRABBED);
+	    break;
+	case SyncKeyboard: 
+	    AllowSome(client, time, keybd, FREEZE_NEXT_EVENT);
+	    break;
+	case AsyncKeyboard: 
+	    AllowSome(client, time, keybd, THAWED);
+	    break;
+	case SyncBoth:
+	    AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT);
+	    break;
+	case AsyncBoth:
+	    AllowSome(client, time, keybd, THAWED_BOTH);
+	    break;
+	default: 
+	    client->errorValue = stuff->mode;
+	    return BadValue;
+    }
+    return Success;
+}
+
+void
+ReleaseActiveGrabs(ClientPtr client)
+{
+    register DeviceIntPtr dev;
+    Bool    done;
+
+    /* XXX CloseDownClient should remove passive grabs before
+     * releasing active grabs.
+     */
+    do {
+    	done = TRUE;
+    	for (dev = inputInfo.devices; dev; dev = dev->next)
+    	{
+	    if (dev->grab && SameClient(dev->grab, client))
+	    {
+	    	(*dev->DeactivateGrab)(dev);
+	    	done = FALSE;
+	    }
+    	}
+    } while (!done);
+}
+
+/**************************************************************************
+ *            The following procedures deal with delivering events        *
+ **************************************************************************/
+
+int
+TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, 
+                 Mask filter, GrabPtr grab)
+{
+    int i;
+    int type;
+
+#ifdef DEBUG
+    if (debug_events) ErrorF(
+	"Event([%d, %d], mask=0x%x), client=%d",
+	pEvents->u.u.type, pEvents->u.u.detail, mask, client->index);
+#endif
+    if ((client) && (client != serverClient) && (!client->clientGone) &&
+	((filter == CantBeFiltered) || (mask & filter)))
+    {
+	if (grab && !SameClient(grab, client))
+	    return -1; /* don't send, but notify caller */
+	type = pEvents->u.u.type;
+	if (type == MotionNotify)
+	{
+	    if (mask & PointerMotionHintMask)
+	    {
+		if (WID(inputInfo.pointer->valuator->motionHintWindow) ==
+		    pEvents->u.keyButtonPointer.event)
+		{
+#ifdef DEBUG
+		    if (debug_events) ErrorF("\n");
+	    fprintf(stderr,"motionHintWindow == keyButtonPointer.event\n");
+#endif
+		    return 1; /* don't send, but pretend we did */
+		}
+		pEvents->u.u.detail = NotifyHint;
+	    }
+	    else
+	    {
+		pEvents->u.u.detail = NotifyNormal;
+	    }
+	}
+#ifdef XINPUT
+	else
+	{
+	    if ((type == DeviceMotionNotify) &&
+		MaybeSendDeviceMotionNotifyHint
+			((deviceKeyButtonPointer*)pEvents, mask) != 0)
+		return 1;
+	}
+#endif
+	type &= 0177;
+	if (type != KeymapNotify)
+	{
+	    /* all extension events must have a sequence number */
+	    for (i = 0; i < count; i++)
+		pEvents[i].u.u.sequenceNumber = client->sequence;
+	}
+
+	if (BitIsOn(criticalEvents, type))
+	{
+#ifdef SMART_SCHEDULE
+	    if (client->smart_priority < SMART_MAX_PRIORITY)
+		client->smart_priority++;
+#endif
+	    SetCriticalOutputPending();
+	}
+
+	WriteEventsToClient(client, count, pEvents);
+#ifdef DEBUG
+	if (debug_events) ErrorF(  " delivered\n");
+#endif
+	return 1;
+    }
+    else
+    {
+#ifdef DEBUG
+	if (debug_events) ErrorF("\n");
+#endif
+	return 0;
+    }
+}
+
+int
+DeliverEventsToWindow(register WindowPtr pWin, xEvent *pEvents, int count, 
+                      Mask filter, GrabPtr grab, int mskidx)
+{
+    int deliveries = 0, nondeliveries = 0;
+    int attempt;
+    register InputClients *other;
+    ClientPtr client = NullClient;
+    Mask deliveryMask = 0; /* If a grab occurs due to a button press, then
+		              this mask is the mask of the grab. */
+    int type = pEvents->u.u.type;
+
+    /* CantBeFiltered means only window owner gets the event */
+    if ((filter == CantBeFiltered) || !(type & EXTENSION_EVENT_BASE))
+    {
+	/* if nobody ever wants to see this event, skip some work */
+	if (filter != CantBeFiltered &&
+	    !((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
+	    return 0;
+	if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count,
+				      pWin->eventMask, filter, grab)) )
+	{
+	    if (attempt > 0)
+	    {
+		deliveries++;
+		client = wClient(pWin);
+		deliveryMask = pWin->eventMask;
+	    } else
+		nondeliveries--;
+	}
+    }
+    if (filter != CantBeFiltered)
+    {
+	if (type & EXTENSION_EVENT_BASE)
+	{
+	    OtherInputMasks *inputMasks;
+
+	    inputMasks = wOtherInputMasks(pWin);
+	    if (!inputMasks ||
+		!(inputMasks->inputEvents[mskidx] & filter))
+		return 0;
+	    other = inputMasks->inputClients;
+	}
+	else
+	    other = (InputClients *)wOtherClients(pWin);
+	for (; other; other = other->next)
+	{
+	    if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
+					  other->mask[mskidx], filter, grab)) )
+	    {
+		if (attempt > 0)
+		{
+		    deliveries++;
+		    client = rClient(other);
+		    deliveryMask = other->mask[mskidx];
+		} else
+		    nondeliveries--;
+	    }
+	}
+    }
+    if ((type == ButtonPress) && deliveries && (!grab))
+    {
+	GrabRec tempGrab;
+
+	tempGrab.device = inputInfo.pointer;
+	tempGrab.resource = client->clientAsMask;
+	tempGrab.window = pWin;
+	tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
+	tempGrab.eventMask = deliveryMask;
+	tempGrab.keyboardMode = GrabModeAsync;
+	tempGrab.pointerMode = GrabModeAsync;
+	tempGrab.confineTo = NullWindow;
+	tempGrab.cursor = NullCursor;
+	(*inputInfo.pointer->ActivateGrab)(inputInfo.pointer, &tempGrab,
+					   currentTime, TRUE);
+    }
+    else if ((type == MotionNotify) && deliveries)
+	inputInfo.pointer->valuator->motionHintWindow = pWin;
+#ifdef XINPUT
+    else
+    {
+	if (((type == DeviceMotionNotify)
+#ifdef XKB
+	     || (type == DeviceButtonPress)
+#endif
+	    ) && deliveries)
+	    CheckDeviceGrabAndHintWindow (pWin, type,
+					  (deviceKeyButtonPointer*) pEvents,
+					  grab, client, deliveryMask);
+    }
+#endif
+    if (deliveries)
+	return deliveries;
+    return nondeliveries;
+}
+
+/* If the event goes to dontClient, don't send it and return 0.  if
+   send works,  return 1 or if send didn't work, return 2.
+   Only works for core events.
+*/
+
+#ifdef PANORAMIX
+static int 
+XineramaTryClientEventsResult(
+    ClientPtr client,
+    GrabPtr grab,
+    Mask mask, 
+    Mask filter
+){
+    if ((client) && (client != serverClient) && (!client->clientGone) &&
+        ((filter == CantBeFiltered) || (mask & filter)))
+    {
+        if (grab && !SameClient(grab, client)) return -1;
+	else return 1;
+    }
+    return 0;
+}
+#endif
+
+int
+MaybeDeliverEventsToClient(register WindowPtr pWin, xEvent *pEvents, 
+                           int count, Mask filter, ClientPtr dontClient)
+{
+    register OtherClients *other;
+
+
+    if (pWin->eventMask & filter)
+    {
+        if (wClient(pWin) == dontClient)
+	    return 0;
+#ifdef PANORAMIX
+	if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) 
+	    return XineramaTryClientEventsResult(
+			wClient(pWin), NullGrab, pWin->eventMask, filter);
+#endif
+	return TryClientEvents(wClient(pWin), pEvents, count,
+			       pWin->eventMask, filter, NullGrab);
+    }
+    for (other = wOtherClients(pWin); other; other = other->next)
+    {
+	if (other->mask & filter)
+	{
+            if (SameClient(other, dontClient))
+		return 0;
+#ifdef PANORAMIX
+	    if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) 
+	      return XineramaTryClientEventsResult(
+			rClient(other), NullGrab, other->mask, filter);
+#endif
+	    return TryClientEvents(rClient(other), pEvents, count,
+				   other->mask, filter, NullGrab);
+	}
+    }
+    return 2;
+}
+
+static void
+FixUpEventFromWindow(
+    xEvent *xE,
+    WindowPtr pWin,
+    Window child,
+    Bool calcChild)
+{
+    if (calcChild)
+    {
+        WindowPtr w=spriteTrace[spriteTraceGood-1];
+	/* If the search ends up past the root should the child field be 
+	 	set to none or should the value in the argument be passed 
+		through. It probably doesn't matter since everyone calls 
+		this function with child == None anyway. */
+
+        while (w) 
+        {
+            /* If the source window is same as event window, child should be
+		none.  Don't bother going all all the way back to the root. */
+
+ 	    if (w == pWin)
+	    { 
+   		child = None;
+ 		break;
+	    }
+	    
+	    if (w->parent == pWin)
+	    {
+		child = w->drawable.id;
+		break;
+            }
+ 	    w = w->parent;
+        } 	    
+    }
+    XE_KBPTR.root = ROOT->drawable.id;
+    XE_KBPTR.event = pWin->drawable.id;
+    if (sprite.hot.pScreen == pWin->drawable.pScreen)
+    {
+	XE_KBPTR.sameScreen = xTrue;
+	XE_KBPTR.child = child;
+	XE_KBPTR.eventX =
+	XE_KBPTR.rootX - pWin->drawable.x;
+	XE_KBPTR.eventY =
+	XE_KBPTR.rootY - pWin->drawable.y;
+    }
+    else
+    {
+	XE_KBPTR.sameScreen = xFalse;
+	XE_KBPTR.child = None;
+	XE_KBPTR.eventX = 0;
+	XE_KBPTR.eventY = 0;
+    }
+}
+
+int
+DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, 
+                    register WindowPtr stopAt, DeviceIntPtr dev, int count)
+{
+    Window child = None;
+    int type = xE->u.u.type;
+    Mask filter = filters[type];
+    int deliveries = 0;
+
+    if (type & EXTENSION_EVENT_BASE)
+    {
+	register OtherInputMasks *inputMasks;
+	int mskidx = dev->id;
+
+	inputMasks = wOtherInputMasks(pWin);
+	if (inputMasks && !(filter & inputMasks->deliverableEvents[mskidx]))
+	    return 0;
+	while (pWin)
+	{
+	    if (inputMasks && (inputMasks->inputEvents[mskidx] & filter))
+	    {
+		FixUpEventFromWindow(xE, pWin, child, FALSE);
+		deliveries = DeliverEventsToWindow(pWin, xE, count, filter,
+						   grab, mskidx);
+		if (deliveries > 0)
+		    return deliveries;
+	    }
+	    if ((deliveries < 0) ||
+		(pWin == stopAt) ||
+		(inputMasks &&
+		 (filter & inputMasks->dontPropagateMask[mskidx])))
+		return 0;
+	    child = pWin->drawable.id;
+	    pWin = pWin->parent;
+	    if (pWin)
+		inputMasks = wOtherInputMasks(pWin);
+	}
+    }
+    else
+    {
+	if (!(filter & pWin->deliverableEvents))
+	    return 0;
+	while (pWin)
+	{
+	    if ((wOtherEventMasks(pWin)|pWin->eventMask) & filter)
+	    {
+		FixUpEventFromWindow(xE, pWin, child, FALSE);
+		deliveries = DeliverEventsToWindow(pWin, xE, count, filter,
+						   grab, 0);
+		if (deliveries > 0)
+		    return deliveries;
+	    }
+	    if ((deliveries < 0) ||
+		(pWin == stopAt) ||
+		(filter & wDontPropagateMask(pWin)))
+		return 0;
+	    child = pWin->drawable.id;
+	    pWin = pWin->parent;
+	}
+    }
+    return 0;
+}
+
+/* not useful for events that propagate up the tree or extension events */
+int
+DeliverEvents(register WindowPtr pWin, register xEvent *xE, int count, 
+              register WindowPtr otherParent)
+{
+    Mask filter;
+    int     deliveries;
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+	return count;
+#endif
+
+    if (!count)
+	return 0;
+    filter = filters[xE->u.u.type];
+    if ((filter & SubstructureNotifyMask) && (xE->u.u.type != CreateNotify))
+	xE->u.destroyNotify.event = pWin->drawable.id;
+    if (filter != StructureAndSubMask)
+	return DeliverEventsToWindow(pWin, xE, count, filter, NullGrab, 0);
+    deliveries = DeliverEventsToWindow(pWin, xE, count, StructureNotifyMask,
+				       NullGrab, 0);
+    if (pWin->parent)
+    {
+	xE->u.destroyNotify.event = pWin->parent->drawable.id;
+	deliveries += DeliverEventsToWindow(pWin->parent, xE, count,
+					    SubstructureNotifyMask, NullGrab,
+					    0);
+	if (xE->u.u.type == ReparentNotify)
+	{
+	    xE->u.destroyNotify.event = otherParent->drawable.id;
+	    deliveries += DeliverEventsToWindow(otherParent, xE, count,
+						SubstructureNotifyMask,
+						NullGrab, 0);
+	}
+    }
+    return deliveries;
+}
+
+
+static Bool 
+PointInBorderSize(WindowPtr pWin, int x, int y)
+{
+    BoxRec box;
+
+    if(POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box))
+	return TRUE;
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
+	int i;
+
+	for(i = 1; i < PanoramiXNumScreens; i++) {
+	   if(POINT_IN_REGION(sprite.screen, 
+			&sprite.windows[i]->borderSize, 
+			x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x, 
+			y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y, 
+			&box))
+		return TRUE;
+	}
+    }
+#endif
+    return FALSE;
+}
+
+#ifdef TSOL
+WindowPtr
+#else
+static WindowPtr
+#endif /* TSOL */
+XYToWindow(int x, int y)
+{
+    register WindowPtr  pWin;
+    BoxRec		box;
+
+    spriteTraceGood = 1;	/* root window still there */
+    pWin = ROOT->firstChild;
+    while (pWin)
+    {
+	if ((pWin->mapped) &&
+	    (x >= pWin->drawable.x - wBorderWidth (pWin)) &&
+	    (x < pWin->drawable.x + (int)pWin->drawable.width +
+	     wBorderWidth(pWin)) &&
+	    (y >= pWin->drawable.y - wBorderWidth (pWin)) &&
+	    (y < pWin->drawable.y + (int)pWin->drawable.height +
+	     wBorderWidth (pWin))
+#ifdef SHAPE
+	    /* When a window is shaped, a further check
+	     * is made to see if the point is inside
+	     * borderSize
+	     */
+	    && (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
+	    && (!wInputShape(pWin) ||
+		POINT_IN_REGION(pWin->drawable.pScreen,
+				wInputShape(pWin),
+				x - pWin->drawable.x,
+				y - pWin->drawable.y, &box))
+#endif
+	    )
+	{
+	    if (spriteTraceGood >= spriteTraceSize)
+	    {
+		spriteTraceSize += 10;
+		Must_have_memory = TRUE; /* XXX */
+		spriteTrace = (WindowPtr *)xrealloc(
+		    spriteTrace, spriteTraceSize*sizeof(WindowPtr));
+		Must_have_memory = FALSE; /* XXX */
+	    }
+	    spriteTrace[spriteTraceGood++] = pWin;
+	    pWin = pWin->firstChild;
+	}
+	else
+	    pWin = pWin->nextSib;
+    }
+    return spriteTrace[spriteTraceGood-1];
+}
+
+static Bool
+CheckMotion(xEvent *xE)
+{
+    WindowPtr prevSpriteWin = sprite.win;
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension)
+	return XineramaCheckMotion(xE);
+#endif
+
+    if (xE && !syncEvents.playingEvents)
+    {
+	if (sprite.hot.pScreen != sprite.hotPhys.pScreen)
+	{
+	    sprite.hot.pScreen = sprite.hotPhys.pScreen;
+	    ROOT = WindowTable[sprite.hot.pScreen->myNum];
+	}
+#ifdef XEVIE
+	xeviehot.x =
+#endif
+	sprite.hot.x = XE_KBPTR.rootX;
+#ifdef XEVIE
+	xeviehot.y =
+#endif
+	sprite.hot.y = XE_KBPTR.rootY;
+	if (sprite.hot.x < sprite.physLimits.x1)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+	    sprite.hot.x = sprite.physLimits.x1;
+	else if (sprite.hot.x >= sprite.physLimits.x2)
+#ifdef XEVIE
+	    xeviehot.x =
+#endif
+	    sprite.hot.x = sprite.physLimits.x2 - 1;
+	if (sprite.hot.y < sprite.physLimits.y1)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+	    sprite.hot.y = sprite.physLimits.y1;
+	else if (sprite.hot.y >= sprite.physLimits.y2)
+#ifdef XEVIE
+	    xeviehot.y =
+#endif
+	    sprite.hot.y = sprite.physLimits.y2 - 1;
+#ifdef SHAPE
+	if (sprite.hotShape)
+	    ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
+#endif
+	sprite.hotPhys = sprite.hot;
+	if ((sprite.hotPhys.x != XE_KBPTR.rootX) ||
+	    (sprite.hotPhys.y != XE_KBPTR.rootY))
+	{
+	    (*sprite.hotPhys.pScreen->SetCursorPosition)(
+		sprite.hotPhys.pScreen,
+		sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
+	}
+	XE_KBPTR.rootX = sprite.hot.x;
+	XE_KBPTR.rootY = sprite.hot.y;
+    }
+
+#ifdef XEVIE
+    xeviewin =
+#endif
+    sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
+#ifdef notyet
+    if (!(sprite.win->deliverableEvents &
+	  Motion_Filter(inputInfo.pointer->button))
+	!syncEvents.playingEvents)
+    {
+	/* XXX Do PointerNonInterestBox here */
+    }
+#endif
+    if (sprite.win != prevSpriteWin)
+    {
+	if (prevSpriteWin != NullWindow) {
+	    if (!xE)
+		UpdateCurrentTimeIf();
+	    DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal);
+	}
+	PostNewCursor();
+        return FALSE;
+    }
+    return TRUE;
+}
+
+void
+WindowsRestructured()
+{
+    (void) CheckMotion((xEvent *)NULL);
+}
+
+#ifdef PANORAMIX
+/* This was added to support reconfiguration under Xdmx.  The problem is
+ * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin
+ * other than 0,0, the information in the private sprite structure must
+ * be updated accordingly, or XYToWindow (and other routines) will not
+ * compute correctly. */
+void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
+{
+    ScreenPtr pScreen = win->drawable.pScreen;
+    GrabPtr   grab;
+
+    if (noPanoramiXExtension) return;
+    
+    sprite.hot.x        -= xoff;
+    sprite.hot.y        -= yoff;
+
+    sprite.hotPhys.x    -= xoff;
+    sprite.hotPhys.y    -= yoff;
+
+    sprite.hotLimits.x1 -= xoff; 
+    sprite.hotLimits.y1 -= yoff;
+    sprite.hotLimits.x2 -= xoff;
+    sprite.hotLimits.y2 -= yoff;
+
+    if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg1))
+        REGION_TRANSLATE(sprite.screen, &sprite.Reg1,    xoff, yoff);
+    if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg2))
+        REGION_TRANSLATE(sprite.screen, &sprite.Reg2,    xoff, yoff);
+
+    /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
+    if ((grab = inputInfo.pointer->grab) && grab->confineTo) {
+	if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+	    sprite.hotPhys.x = sprite.hotPhys.y = 0;
+	ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+    } else
+	ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+			      TRUE, FALSE);
+}
+#endif
+
+void
+DefineInitialRootWindow(register WindowPtr win)
+{
+    register ScreenPtr pScreen = win->drawable.pScreen;
+
+    sprite.hotPhys.pScreen = pScreen;
+    sprite.hotPhys.x = pScreen->width / 2;
+    sprite.hotPhys.y = pScreen->height / 2;
+    sprite.hot = sprite.hotPhys;
+    sprite.hotLimits.x2 = pScreen->width;
+    sprite.hotLimits.y2 = pScreen->height;
+#ifdef XEVIE
+    xeviewin =
+#endif
+    sprite.win = win;
+    sprite.current = wCursor (win);
+    sprite.current->refcnt++;
+    spriteTraceGood = 1;
+    ROOT = win;
+    (*pScreen->CursorLimits) (
+	pScreen, sprite.current, &sprite.hotLimits, &sprite.physLimits);
+    sprite.confined = FALSE;
+    (*pScreen->ConstrainCursor) (pScreen, &sprite.physLimits);
+    (*pScreen->SetCursorPosition) (pScreen, sprite.hot.x, sprite.hot.y, FALSE);
+    (*pScreen->DisplayCursor) (pScreen, sprite.current);
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension) {
+	sprite.hotLimits.x1 = -panoramiXdataPtr[0].x;
+	sprite.hotLimits.y1 = -panoramiXdataPtr[0].y;
+	sprite.hotLimits.x2 = PanoramiXPixWidth  - panoramiXdataPtr[0].x;
+	sprite.hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+	sprite.physLimits = sprite.hotLimits;
+	sprite.confineWin = NullWindow;
+#ifdef SHAPE
+        sprite.hotShape = NullRegion;
+#endif
+	sprite.screen = pScreen;
+	/* gotta UNINIT these someplace */
+	REGION_NULL(pScreen, &sprite.Reg1);
+	REGION_NULL(pScreen, &sprite.Reg2);
+    }
+#endif
+}
+
+/*
+ * This does not take any shortcuts, and even ignores its argument, since
+ * it does not happen very often, and one has to walk up the tree since
+ * this might be a newly instantiated cursor for an intermediate window
+ * between the one the pointer is in and the one that the last cursor was
+ * instantiated from.
+ */
+void
+WindowHasNewCursor(WindowPtr pWin)
+{
+    PostNewCursor();
+}
+
+void
+NewCurrentScreen(ScreenPtr newScreen, int x, int y)
+{
+    sprite.hotPhys.x = x;
+    sprite.hotPhys.y = y;
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension) {
+	sprite.hotPhys.x += panoramiXdataPtr[newScreen->myNum].x - 
+			    panoramiXdataPtr[0].x;
+	sprite.hotPhys.y += panoramiXdataPtr[newScreen->myNum].y - 
+			    panoramiXdataPtr[0].y;
+	if (newScreen != sprite.screen) {
+	    sprite.screen = newScreen;
+	    /* Make sure we tell the DDX to update its copy of the screen */
+	    if(sprite.confineWin)
+		XineramaConfineCursorToWindow(sprite.confineWin, TRUE);
+	    else
+		XineramaConfineCursorToWindow(WindowTable[0], TRUE);
+	    /* if the pointer wasn't confined, the DDX won't get 
+	       told of the pointer warp so we reposition it here */
+	    if(!syncEvents.playingEvents)
+		(*sprite.screen->SetCursorPosition)(sprite.screen,
+		    sprite.hotPhys.x + panoramiXdataPtr[0].x - 
+			panoramiXdataPtr[sprite.screen->myNum].x,
+		    sprite.hotPhys.y + panoramiXdataPtr[0].y - 
+			panoramiXdataPtr[sprite.screen->myNum].y, FALSE);
+	}
+    } else 
+#endif
+    if (newScreen != sprite.hotPhys.pScreen)
+	ConfineCursorToWindow(WindowTable[newScreen->myNum], TRUE, FALSE);
+}
+
+#ifdef PANORAMIX
+
+static Bool
+XineramaPointInWindowIsVisible(
+    WindowPtr pWin,
+    int x,
+    int y
+)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    BoxRec box;
+    int i, xoff, yoff;
+
+    if (!pWin->realized) return FALSE;
+
+    if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+        return TRUE;
+    
+    if(!XineramaSetWindowPntrs(pWin)) return FALSE;
+
+    xoff = x + panoramiXdataPtr[0].x;  
+    yoff = y + panoramiXdataPtr[0].y;  
+
+    for(i = 1; i < PanoramiXNumScreens; i++) {
+	pWin = sprite.windows[i];
+	pScreen = pWin->drawable.pScreen;
+	x = xoff - panoramiXdataPtr[i].x;
+	y = yoff - panoramiXdataPtr[i].y;
+
+	if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box)
+	   && (!wInputShape(pWin) ||
+	       POINT_IN_REGION(pWin->drawable.pScreen,
+			       wInputShape(pWin),
+			       x - pWin->drawable.x, 
+			       y - pWin->drawable.y, &box)))
+            return TRUE;
+
+    }
+
+    return FALSE;
+}
+
+static int
+XineramaWarpPointer(ClientPtr client)
+{
+    WindowPtr	dest = NULL;
+    int		x, y;
+
+    REQUEST(xWarpPointerReq);
+
+
+    if (stuff->dstWid != None)
+    {
+	dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
+	if (!dest)
+	    return BadWindow;
+    }
+    x = sprite.hotPhys.x;
+    y = sprite.hotPhys.y;
+
+    if (stuff->srcWid != None)
+    {
+	int     winX, winY;
+ 	XID 	winID = stuff->srcWid;
+        WindowPtr source;
+	
+	source = SecurityLookupWindow(winID, client, SecurityReadAccess);
+	if (!source) return BadWindow;
+
+	winX = source->drawable.x;
+	winY = source->drawable.y;
+	if(source == WindowTable[0]) {
+	    winX -= panoramiXdataPtr[0].x;
+	    winY -= panoramiXdataPtr[0].y;
+	}
+	if (x < winX + stuff->srcX ||
+	    y < winY + stuff->srcY ||
+	    (stuff->srcWidth != 0 &&
+	     winX + stuff->srcX + (int)stuff->srcWidth < x) ||
+	    (stuff->srcHeight != 0 &&
+	     winY + stuff->srcY + (int)stuff->srcHeight < y) ||
+	    !XineramaPointInWindowIsVisible(source, x, y))
+	    return Success;
+    }
+    if (dest) {
+	x = dest->drawable.x;
+	y = dest->drawable.y;
+	if(dest == WindowTable[0]) {
+	    x -= panoramiXdataPtr[0].x;
+	    y -= panoramiXdataPtr[0].y;
+	}
+    } 
+
+    x += stuff->dstX;
+    y += stuff->dstY;
+
+    if (x < sprite.physLimits.x1)
+	x = sprite.physLimits.x1;
+    else if (x >= sprite.physLimits.x2)
+	x = sprite.physLimits.x2 - 1;
+    if (y < sprite.physLimits.y1)
+	y = sprite.physLimits.y1;
+    else if (y >= sprite.physLimits.y2)
+	y = sprite.physLimits.y2 - 1;
+    if (sprite.hotShape)
+	ConfineToShape(sprite.hotShape, &x, &y);
+
+    XineramaSetCursorPosition(x, y, TRUE);
+
+    return Success;
+}
+
+#endif
+
+
+int
+ProcWarpPointer(ClientPtr client)
+{
+    WindowPtr	dest = NULL;
+    int		x, y;
+    ScreenPtr	newScreen;
+
+    REQUEST(xWarpPointerReq);
+
+    REQUEST_SIZE_MATCH(xWarpPointerReq);
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension)
+	return XineramaWarpPointer(client);
+#endif
+
+    if (stuff->dstWid != None)
+    {
+	dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
+	if (!dest)
+	    return BadWindow;
+    }
+    x = sprite.hotPhys.x;
+    y = sprite.hotPhys.y;
+
+    if (stuff->srcWid != None)
+    {
+	int     winX, winY;
+ 	XID 	winID = stuff->srcWid;
+        WindowPtr source;
+	
+	source = SecurityLookupWindow(winID, client, SecurityReadAccess);
+	if (!source) return BadWindow;
+
+	winX = source->drawable.x;
+	winY = source->drawable.y;
+	if (source->drawable.pScreen != sprite.hotPhys.pScreen ||
+	    x < winX + stuff->srcX ||
+	    y < winY + stuff->srcY ||
+	    (stuff->srcWidth != 0 &&
+	     winX + stuff->srcX + (int)stuff->srcWidth < x) ||
+	    (stuff->srcHeight != 0 &&
+	     winY + stuff->srcY + (int)stuff->srcHeight < y) ||
+	    !PointInWindowIsVisible(source, x, y))
+	    return Success;
+    }
+    if (dest) 
+    {
+	x = dest->drawable.x;
+	y = dest->drawable.y;
+	newScreen = dest->drawable.pScreen;
+    } else 
+	newScreen = sprite.hotPhys.pScreen;
+
+    x += stuff->dstX;
+    y += stuff->dstY;
+
+    if (x < 0)
+	x = 0;
+    else if (x >= newScreen->width)
+	x = newScreen->width - 1;
+    if (y < 0)
+	y = 0;
+    else if (y >= newScreen->height)
+	y = newScreen->height - 1;
+
+    if (newScreen == sprite.hotPhys.pScreen)
+    {
+	if (x < sprite.physLimits.x1)
+	    x = sprite.physLimits.x1;
+	else if (x >= sprite.physLimits.x2)
+	    x = sprite.physLimits.x2 - 1;
+	if (y < sprite.physLimits.y1)
+	    y = sprite.physLimits.y1;
+	else if (y >= sprite.physLimits.y2)
+	    y = sprite.physLimits.y2 - 1;
+#if defined(SHAPE)
+	if (sprite.hotShape)
+	    ConfineToShape(sprite.hotShape, &x, &y);
+#endif
+	(*newScreen->SetCursorPosition)(newScreen, x, y, TRUE);
+    }
+    else if (!PointerConfinedToScreen())
+    {
+	NewCurrentScreen(newScreen, x, y);
+    }
+    return Success;
+}
+
+static Bool 
+BorderSizeNotEmpty(WindowPtr pWin)
+{
+     if(REGION_NOTEMPTY(sprite.hotPhys.pScreen, &pWin->borderSize))
+	return TRUE;
+
+#ifdef PANORAMIX
+     if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
+	int i;
+
+	for(i = 1; i < PanoramiXNumScreens; i++) {
+	    if(REGION_NOTEMPTY(sprite.screen, &sprite.windows[i]->borderSize))
+		return TRUE;
+	}
+     }
+#endif
+     return FALSE;
+}
+
+/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
+	passive grab set on the window to be activated. */
+
+static Bool
+CheckPassiveGrabsOnWindow(
+    WindowPtr pWin,
+    register DeviceIntPtr device,
+    register xEvent *xE,
+    int count)
+{
+    register GrabPtr grab = wPassiveGrabs(pWin);
+    GrabRec tempGrab;
+    register xEvent *dxE;
+
+    if (!grab)
+	return FALSE;
+    tempGrab.window = pWin;
+    tempGrab.device = device;
+    tempGrab.type = xE->u.u.type;
+    tempGrab.detail.exact = xE->u.u.detail;
+    tempGrab.detail.pMask = NULL;
+    tempGrab.modifiersDetail.pMask = NULL;
+    for (; grab; grab = grab->next)
+    {
+#ifdef XKB
+	DeviceIntPtr	gdev;
+	XkbSrvInfoPtr	xkbi;
+
+	gdev= grab->modifierDevice;
+	xkbi= gdev->key->xkbInfo;
+#endif
+	tempGrab.modifierDevice = grab->modifierDevice;
+	if ((device == grab->modifierDevice) &&
+	    ((xE->u.u.type == KeyPress)
+#if defined(XINPUT) && defined(XKB)
+	     || (xE->u.u.type == DeviceKeyPress)
+#endif
+	     ))
+	    tempGrab.modifiersDetail.exact =
+#ifdef XKB
+		(noXkbExtension?gdev->key->prev_state:xkbi->state.grab_mods);
+#else
+		grab->modifierDevice->key->prev_state;
+#endif
+	else
+	    tempGrab.modifiersDetail.exact =
+#ifdef XKB
+		(noXkbExtension ? gdev->key->state : xkbi->state.grab_mods);
+#else
+		grab->modifierDevice->key->state;
+#endif
+	if (GrabMatchesSecond(&tempGrab, grab) &&
+	    (!grab->confineTo ||
+	     (grab->confineTo->realized && 
+				BorderSizeNotEmpty(grab->confineTo))))
+	{
+#ifdef XCSECURITY
+	    if (!SecurityCheckDeviceAccess(wClient(pWin), device, FALSE))
+		return FALSE;
+#endif
+#ifdef XKB
+	    if (!noXkbExtension) {
+		XE_KBPTR.state &= 0x1f00;
+		XE_KBPTR.state |=
+				tempGrab.modifiersDetail.exact&(~0x1f00);
+	    }
+#endif
+	    (*device->ActivateGrab)(device, grab, currentTime, TRUE);
+ 
+	    FixUpEventFromWindow(xE, grab->window, None, TRUE);
+
+	    (void) TryClientEvents(rClient(grab), xE, count,
+				   filters[xE->u.u.type],
+				   filters[xE->u.u.type],  grab);
+
+	    if (device->sync.state == FROZEN_NO_EVENT)
+	    {
+		if (device->sync.evcount < count)
+		{
+		    Must_have_memory = TRUE; /* XXX */
+		    device->sync.event = (xEvent *)xrealloc(device->sync.event,
+							    count*
+							    sizeof(xEvent));
+		    Must_have_memory = FALSE; /* XXX */
+		}
+		device->sync.evcount = count;
+		for (dxE = device->sync.event; --count >= 0; dxE++, xE++)
+		    *dxE = *xE;
+	    	device->sync.state = FROZEN_WITH_EVENT;
+            }	
+	    return TRUE;
+	}
+    }
+    return FALSE;
+}
+
+/**
+"CheckDeviceGrabs" handles both keyboard and pointer events that may cause
+a passive grab to be activated.  If the event is a keyboard event, the
+ancestors of the focus window are traced down and tried to see if they have
+any passive grabs to be activated.  If the focus window itself is reached and
+it's descendants contain they pointer, the ancestors of the window that the
+pointer is in are then traced down starting at the focus window, otherwise no
+grabs are activated.  If the event is a pointer event, the ancestors of the
+window that the pointer is in are traced down starting at the root until
+CheckPassiveGrabs causes a passive grab to activate or all the windows are
+tried. PRH
+*/
+
+Bool
+CheckDeviceGrabs(register DeviceIntPtr device, register xEvent *xE, 
+                 int checkFirst, int count)
+{
+    register int i;
+    register WindowPtr pWin = NULL;
+    register FocusClassPtr focus = device->focus;
+
+    if (((xE->u.u.type == ButtonPress)
+#if defined(XINPUT) && defined(XKB)
+	 || (xE->u.u.type == DeviceButtonPress)
+#endif
+	 ) && (device->button->buttonsDown != 1))
+	return FALSE;
+
+    i = checkFirst;
+
+    if (focus)
+    {
+	for (; i < focus->traceGood; i++)
+	{
+	    pWin = focus->trace[i];
+	    if (pWin->optional &&
+		CheckPassiveGrabsOnWindow(pWin, device, xE, count))
+		return TRUE;
+	}
+  
+	if ((focus->win == NoneWin) ||
+	    (i >= spriteTraceGood) ||
+	    ((i > checkFirst) && (pWin != spriteTrace[i-1])))
+	    return FALSE;
+    }
+
+    for (; i < spriteTraceGood; i++)
+    {
+	pWin = spriteTrace[i];
+	if (pWin->optional &&
+	    CheckPassiveGrabsOnWindow(pWin, device, xE, count))
+	    return TRUE;
+    }
+
+    return FALSE;
+}
+
+void
+DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count)
+{
+    WindowPtr focus = keybd->focus->win;
+    int mskidx = 0;
+
+    if (focus == FollowKeyboardWin)
+	focus = inputInfo.keyboard->focus->win;
+    if (!focus)
+	return;
+    if (focus == PointerRootWin)
+    {
+	DeliverDeviceEvents(window, xE, NullGrab, NullWindow, keybd, count);
+	return;
+    }
+    if ((focus == window) || IsParent(focus, window))
+    {
+	if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count))
+	    return;
+    }
+    /* just deliver it to the focus window */
+    FixUpEventFromWindow(xE, focus, None, FALSE);
+    if (xE->u.u.type & EXTENSION_EVENT_BASE)
+	mskidx = keybd->id;
+    (void)DeliverEventsToWindow(focus, xE, count, filters[xE->u.u.type],
+				NullGrab, mskidx);
+}
+
+void
+DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev, 
+                    Bool deactivateGrab, int count)
+{
+    register GrabPtr grab = thisDev->grab;
+    int deliveries = 0;
+    register DeviceIntPtr dev;
+    register xEvent *dxE;
+
+    if (grab->ownerEvents)
+    {
+	WindowPtr focus;
+
+	if (thisDev->focus)
+	{
+	    focus = thisDev->focus->win;
+	    if (focus == FollowKeyboardWin)
+		focus = inputInfo.keyboard->focus->win;
+	}
+	else
+	    focus = PointerRootWin;
+	if (focus == PointerRootWin)
+	    deliveries = DeliverDeviceEvents(sprite.win, xE, grab, NullWindow,
+					     thisDev, count);
+	else if (focus && (focus == sprite.win || IsParent(focus, sprite.win)))
+	    deliveries = DeliverDeviceEvents(sprite.win, xE, grab, focus,
+					     thisDev, count);
+	else if (focus)
+	    deliveries = DeliverDeviceEvents(focus, xE, grab, focus,
+					     thisDev, count);
+    }
+    if (!deliveries)
+    {
+	FixUpEventFromWindow(xE, grab->window, None, TRUE);
+	deliveries = TryClientEvents(rClient(grab), xE, count,
+				     (Mask)grab->eventMask,
+				     filters[xE->u.u.type], grab);
+	if (deliveries && (xE->u.u.type == MotionNotify
+#ifdef XINPUT
+			   || xE->u.u.type == DeviceMotionNotify
+#endif
+			   ))
+	    thisDev->valuator->motionHintWindow = grab->window;
+    }
+    if (deliveries && !deactivateGrab && (xE->u.u.type != MotionNotify
+#ifdef XINPUT
+					  && xE->u.u.type != DeviceMotionNotify
+#endif
+					  ))
+	switch (thisDev->sync.state)
+	{
+	case FREEZE_BOTH_NEXT_EVENT:
+	    for (dev = inputInfo.devices; dev; dev = dev->next)
+	    {
+		if (dev == thisDev)
+		    continue;
+		FreezeThaw(dev, TRUE);
+		if ((dev->sync.state == FREEZE_BOTH_NEXT_EVENT) &&
+		    (CLIENT_BITS(dev->grab->resource) ==
+		     CLIENT_BITS(thisDev->grab->resource)))
+		    dev->sync.state = FROZEN_NO_EVENT;
+		else
+		    dev->sync.other = thisDev->grab;
+	    }
+	    /* fall through */
+	case FREEZE_NEXT_EVENT:
+	    thisDev->sync.state = FROZEN_WITH_EVENT;
+	    FreezeThaw(thisDev, TRUE);
+	    if (thisDev->sync.evcount < count)
+	    {
+		Must_have_memory = TRUE; /* XXX */
+		thisDev->sync.event = (xEvent *)xrealloc(thisDev->sync.event,
+							 count*sizeof(xEvent));
+		Must_have_memory = FALSE; /* XXX */
+	    }
+	    thisDev->sync.evcount = count;
+	    for (dxE = thisDev->sync.event; --count >= 0; dxE++, xE++)
+		*dxE = *xE;
+	    break;
+	}
+}
+
+void
+#ifdef XKB
+CoreProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count)
+#else
+ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count)
+#endif
+{
+    int             key, bit;
+    register BYTE   *kptr;
+    register int    i;
+    register CARD8  modifiers;
+    register CARD16 mask;
+    GrabPtr         grab = keybd->grab;
+    Bool            deactivateGrab = FALSE;
+    register KeyClassPtr keyc = keybd->key;
+#ifdef XEVIE
+    static Window           rootWin = 0;
+
+    if(!xeviegrabState && xevieFlag && clients[xevieClientIndex] &&
+          (xevieMask & xevieFilters[xE->u.u.type])) {
+      key = xE->u.u.detail;
+      kptr = &keyc->down[key >> 3];
+      bit = 1 << (key & 7);
+      if((xE->u.u.type == KeyPress &&  (*kptr & bit)) ||
+         (xE->u.u.type == KeyRelease && !(*kptr & bit)))
+      {} else {
+#ifdef XKB
+        if(!noXkbExtension)
+	    xevieKBEventSent = 1;
+#endif
+        if(!xevieKBEventSent)
+        {
+          xeviekb = keybd;
+          if(!rootWin) {
+	      rootWin = GetCurrentRootWindow()->drawable.id;
+          }
+          xE->u.keyButtonPointer.event = xeviewin->drawable.id;
+          xE->u.keyButtonPointer.root = rootWin;
+          xE->u.keyButtonPointer.child = (xeviewin->firstChild) ? xeviewin->firstChild->
+drawable.id:0;
+          xE->u.keyButtonPointer.rootX = xeviehot.x;
+          xE->u.keyButtonPointer.rootY = xeviehot.y;
+          xE->u.keyButtonPointer.state = keyc->state;
+          WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE);
+#ifdef XKB
+          if(noXkbExtension)
+#endif
+            return;
+        } else {
+	    xevieKBEventSent = 0;
+        }
+      }
+    }
+#endif
+
+    if (!syncEvents.playingEvents)
+    {
+	NoticeTime(xE);
+	if (DeviceEventCallback)
+	{
+	    DeviceEventInfoRec eventinfo;
+	    eventinfo.events = xE;
+	    eventinfo.count = count;
+	    CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+	}
+    }
+#ifdef XEVIE
+    /* fix for bug5094030: don't change the state bit if the event is from XEvIE client */
+    if(!(!xeviegrabState && xevieFlag && clients[xevieClientIndex] &&
+	 (xevieMask & xevieFilters[xE->u.u.type]
+#ifdef XKB
+	  && !noXkbExtension
+#endif
+    )))
+#endif
+    XE_KBPTR.state = (keyc->state | inputInfo.pointer->button->state);
+    XE_KBPTR.rootX = sprite.hot.x;
+    XE_KBPTR.rootY = sprite.hot.y;
+    key = xE->u.u.detail;
+    kptr = &keyc->down[key >> 3];
+    bit = 1 << (key & 7);
+    modifiers = keyc->modifierMap[key];
+#if defined(XKB) && defined(XEVIE)
+    if(!noXkbExtension && !xeviegrabState &&
+       xevieFlag && clients[xevieClientIndex] &&
+       (xevieMask & xevieFilters[xE->u.u.type])) {
+	switch(xE->u.u.type) {
+	  case KeyPress: *kptr &= ~bit; break;
+	  case KeyRelease: *kptr |= bit; break;
+	}
+    }
+#endif
+
+#ifdef DEBUG
+    if ((xkbDebugFlags&0x4)&&
+	((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+	ErrorF("CoreProcessKbdEvent: Key %d %s\n",key,
+			(xE->u.u.type==KeyPress?"down":"up"));
+    }
+#endif
+    switch (xE->u.u.type)
+    {
+	case KeyPress: 
+	    if (*kptr & bit) /* allow ddx to generate multiple downs */
+	    {   
+		if (!modifiers)
+		{
+		    xE->u.u.type = KeyRelease;
+		    (*keybd->public.processInputProc)(xE, keybd, count);
+		    xE->u.u.type = KeyPress;
+		    /* release can have side effects, don't fall through */
+		    (*keybd->public.processInputProc)(xE, keybd, count);
+		}
+		return;
+	    }
+	    inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+	    *kptr |= bit;
+	    keyc->prev_state = keyc->state;
+	    for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+	    {
+		if (mask & modifiers)
+		{
+		    /* This key affects modifier "i" */
+		    keyc->modifierKeyCount[i]++;
+		    keyc->state |= mask;
+		    modifiers &= ~mask;
+		}
+	    }
+	    if (!grab && CheckDeviceGrabs(keybd, xE, 0, count))
+	    {
+		keybd->activatingKey = key;
+		return;
+	    }
+	    break;
+	case KeyRelease: 
+	    if (!(*kptr & bit)) /* guard against duplicates */
+		return;
+	    inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+	    *kptr &= ~bit;
+	    keyc->prev_state = keyc->state;
+	    for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+	    {
+		if (mask & modifiers) {
+		    /* This key affects modifier "i" */
+		    if (--keyc->modifierKeyCount[i] <= 0) {
+			keyc->state &= ~mask;
+			keyc->modifierKeyCount[i] = 0;
+		    }
+		    modifiers &= ~mask;
+		}
+	    }
+	    if (keybd->fromPassiveGrab && (key == keybd->activatingKey))
+		deactivateGrab = TRUE;
+	    break;
+	default: 
+	    FatalError("Impossible keyboard event");
+    }
+    if (grab)
+	DeliverGrabbedEvent(xE, keybd, deactivateGrab, count);
+    else
+	DeliverFocusedEvent(keybd, xE, sprite.win, count);
+    if (deactivateGrab)
+        (*keybd->DeactivateGrab)(keybd);
+
+#ifdef TSOL
+    if (pSecHook)
+	(*pSecHook->ProcessKeyboard)(xE, keyc);
+#endif /* TSOL */
+
+}
+
+#ifdef XKB
+/* This function is used to set the key pressed or key released state -
+   this is only used when the pressing of keys does not cause 
+   CoreProcessKeyEvent to be called, as in for example Mouse Keys.
+*/
+void
+FixKeyState (register xEvent *xE, register DeviceIntPtr keybd)
+{
+    int             key, bit;
+    register BYTE   *kptr;
+    register KeyClassPtr keyc = keybd->key;
+
+    key = xE->u.u.detail;
+    kptr = &keyc->down[key >> 3];
+    bit = 1 << (key & 7);
+#ifdef DEBUG
+    if ((xkbDebugFlags&0x4)&&
+	((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+	ErrorF("FixKeyState: Key %d %s\n",key,
+			(xE->u.u.type==KeyPress?"down":"up"));
+    }
+#endif
+    switch (xE->u.u.type)
+    {
+	case KeyPress: 
+	    *kptr |= bit;
+	    break;
+	case KeyRelease: 
+	    *kptr &= ~bit;
+	    break;
+	default: 
+	    FatalError("Impossible keyboard event");
+    }
+}
+#endif
+
+void
+#ifdef XKB
+CoreProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count)
+#else
+ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count)
+#endif
+{
+    register GrabPtr	grab = mouse->grab;
+    Bool                deactivateGrab = FALSE;
+    register ButtonClassPtr butc = mouse->button;
+#ifdef XKB
+    XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo;
+#endif
+#ifdef XEVIE
+    if(xevieFlag && clients[xevieClientIndex] && !xeviegrabState &&
+       (xevieMask & xevieFilters[xE->u.u.type])) {
+      if(xevieEventSent)
+        xevieEventSent = 0;
+      else {
+        xeviemouse = mouse;
+        WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE);
+        return;
+      }
+    }
+#endif
+
+    if (!syncEvents.playingEvents)
+	NoticeTime(xE)
+    XE_KBPTR.state = (butc->state | (
+#ifdef XKB
+			(noXkbExtension ?
+				inputInfo.keyboard->key->state :
+				xkbi->state.grab_mods)
+#else
+			inputInfo.keyboard->key->state
+#endif
+				    ));
+    {
+	NoticeTime(xE);
+	if (DeviceEventCallback)
+	{
+	    DeviceEventInfoRec eventinfo;
+	    /* see comment in EnqueueEvents regarding the next three lines */
+	    if (xE->u.u.type == MotionNotify)
+		XE_KBPTR.root =
+		    WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
+	    eventinfo.events = xE;
+	    eventinfo.count = count;
+	    CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+	}
+    }
+    if (xE->u.u.type != MotionNotify)
+    {
+	register int  key;
+	register BYTE *kptr;
+	int           bit;
+
+	XE_KBPTR.rootX = sprite.hot.x;
+	XE_KBPTR.rootY = sprite.hot.y;
+
+	key = xE->u.u.detail;
+	kptr = &butc->down[key >> 3];
+	bit = 1 << (key & 7);
+	switch (xE->u.u.type)
+	{
+	case ButtonPress: 
+	    mouse->valuator->motionHintWindow = NullWindow;
+	    if (!(*kptr & bit))
+		butc->buttonsDown++;
+	    butc->motionMask = ButtonMotionMask;
+	    *kptr |= bit;
+#if !defined(XFree86Server) || !defined(XINPUT)
+	    xE->u.u.detail = butc->map[key];
+#endif
+	    if (xE->u.u.detail == 0)
+		return;
+	    if (xE->u.u.detail <= 5)
+		butc->state |= (Button1Mask >> 1) << xE->u.u.detail;
+	    filters[MotionNotify] = Motion_Filter(butc);
+	    if (!grab)
+		if (CheckDeviceGrabs(mouse, xE, 0, count))
+		    return;
+	    break;
+	case ButtonRelease: 
+	    mouse->valuator->motionHintWindow = NullWindow;
+	    if (*kptr & bit)
+		--butc->buttonsDown;
+	    if (!butc->buttonsDown)
+		butc->motionMask = 0;
+	    *kptr &= ~bit;
+#if !defined(XFree86Server) || !defined(XINPUT)
+	    xE->u.u.detail = butc->map[key];
+#endif
+	    if (xE->u.u.detail == 0)
+		return;
+	    if (xE->u.u.detail <= 5)
+		butc->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
+	    filters[MotionNotify] = Motion_Filter(butc);
+	    if (!butc->state && mouse->fromPassiveGrab)
+		deactivateGrab = TRUE;
+	    break;
+	default: 
+	    FatalError("bogus pointer event from ddx");
+	}
+    }
+    else if (!CheckMotion(xE))
+	return;
+    if (grab)
+	DeliverGrabbedEvent(xE, mouse, deactivateGrab, count);
+    else
+	DeliverDeviceEvents(sprite.win, xE, NullGrab, NullWindow,
+			    mouse, count);
+    if (deactivateGrab)
+        (*mouse->DeactivateGrab)(mouse);
+}
+
+#define AtMostOneClient \
+	(SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask)
+
+void
+RecalculateDeliverableEvents(pWin)
+    register WindowPtr pWin;
+{
+    register OtherClients *others;
+    register WindowPtr pChild;
+
+    pChild = pWin;
+    while (1)
+    {
+	if (pChild->optional)
+	{
+	    pChild->optional->otherEventMasks = 0;
+	    for (others = wOtherClients(pChild); others; others = others->next)
+	    {
+		pChild->optional->otherEventMasks |= others->mask;
+	    }
+	}
+	pChild->deliverableEvents = pChild->eventMask|
+				    wOtherEventMasks(pChild);
+	if (pChild->parent)
+	    pChild->deliverableEvents |=
+		(pChild->parent->deliverableEvents &
+		 ~wDontPropagateMask(pChild) & PropagateMask);
+	if (pChild->firstChild)
+	{
+	    pChild = pChild->firstChild;
+	    continue;
+	}
+	while (!pChild->nextSib && (pChild != pWin))
+	    pChild = pChild->parent;
+	if (pChild == pWin)
+	    break;
+	pChild = pChild->nextSib;
+    }
+}
+
+/**
+ *
+ *  \param value must conform to DeleteType
+ */
+int
+OtherClientGone(pointer value, XID id)
+{
+    register OtherClientsPtr other, prev;
+    register WindowPtr pWin = (WindowPtr)value;
+
+    prev = 0;
+    for (other = wOtherClients(pWin); other; other = other->next)
+    {
+	if (other->resource == id)
+	{
+	    if (prev)
+		prev->next = other->next;
+	    else
+	    {
+		if (!(pWin->optional->otherClients = other->next))
+		    CheckWindowOptionalNeed (pWin);
+	    }
+	    xfree(other);
+	    RecalculateDeliverableEvents(pWin);
+	    return(Success);
+	}
+	prev = other;
+    }
+    FatalError("client not on event list");
+    /*NOTREACHED*/
+    return -1; /* make compiler happy */
+}
+
+int
+EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
+{
+    Mask check;
+    OtherClients * others;
+
+    if (mask & ~AllEventMasks)
+    {
+	client->errorValue = mask;
+	return BadValue;
+    }
+    check = (mask & AtMostOneClient);
+    if (check & (pWin->eventMask|wOtherEventMasks(pWin)))
+    {				       /* It is illegal for two different
+				          clients to select on any of the
+				          events for AtMostOneClient. However,
+				          it is OK, for some client to
+				          continue selecting on one of those
+				          events.  */
+	if ((wClient(pWin) != client) && (check & pWin->eventMask))
+	    return BadAccess;
+	for (others = wOtherClients (pWin); others; others = others->next)
+	{
+	    if (!SameClient(others, client) && (check & others->mask))
+		return BadAccess;
+	}
+    }
+    if (wClient (pWin) == client)
+    {
+	check = pWin->eventMask;
+#ifdef SGIMISC
+	pWin->eventMask =
+	    (mask & ~SGIMiscSpecialDestroyMask) | (pWin->eventMask & SGIMiscSpecialDestroyMask);
+#else
+	pWin->eventMask = mask;
+#endif
+    }
+    else
+    {
+	for (others = wOtherClients (pWin); others; others = others->next)
+	{
+	    if (SameClient(others, client))
+	    {
+		check = others->mask;
+#ifdef SGIMISC
+		mask = (mask & ~SGIMiscSpecialDestroyMask) | (others->mask & SGIMiscSpecialDestroyMask);
+#endif
+		if (mask == 0)
+		{
+		    FreeResource(others->resource, RT_NONE);
+		    return Success;
+		}
+		else
+		    others->mask = mask;
+		goto maskSet;
+	    }
+	}
+	check = 0;
+	if (!pWin->optional && !MakeWindowOptional (pWin))
+	    return BadAlloc;
+	others = (OtherClients *) xalloc(sizeof(OtherClients));
+	if (!others)
+	    return BadAlloc;
+	others->mask = mask;
+	others->resource = FakeClientID(client->index);
+	others->next = pWin->optional->otherClients;
+	pWin->optional->otherClients = others;
+	if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer)pWin))
+	    return BadAlloc;
+    }
+maskSet: 
+    if ((inputInfo.pointer->valuator->motionHintWindow == pWin) &&
+	(mask & PointerMotionHintMask) &&
+	!(check & PointerMotionHintMask) &&
+	!inputInfo.pointer->grab)
+	inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+    RecalculateDeliverableEvents(pWin);
+    return Success;
+}
+
+int
+EventSuppressForWindow(register WindowPtr pWin, register ClientPtr client, 
+                       Mask mask, Bool *checkOptional)
+{
+    register int i, free;
+
+    if ((mask & ~PropagateMask) && !permitOldBugs)
+    {
+	client->errorValue = mask;
+	return BadValue;
+    }
+    if (pWin->dontPropagate)
+	DontPropagateRefCnts[pWin->dontPropagate]--;
+    if (!mask)
+	i = 0;
+    else
+    {
+	for (i = DNPMCOUNT, free = 0; --i > 0; )
+	{
+	    if (!DontPropagateRefCnts[i])
+		free = i;
+	    else if (mask == DontPropagateMasks[i])
+		break;
+	}
+	if (!i && free)
+	{
+	    i = free;
+	    DontPropagateMasks[i] = mask;
+	}
+    }
+    if (i || !mask)
+    {
+	pWin->dontPropagate = i;
+	if (i)
+	    DontPropagateRefCnts[i]++;
+	if (pWin->optional)
+	{
+	    pWin->optional->dontPropagateMask = mask;
+	    *checkOptional = TRUE;
+	}
+    }
+    else
+    {
+	if (!pWin->optional && !MakeWindowOptional (pWin))
+	{
+	    if (pWin->dontPropagate)
+		DontPropagateRefCnts[pWin->dontPropagate]++;
+	    return BadAlloc;
+	}
+	pWin->dontPropagate = 0;
+        pWin->optional->dontPropagateMask = mask;
+    }
+    RecalculateDeliverableEvents(pWin);
+    return Success;
+}
+
+static WindowPtr 
+CommonAncestor(
+    register WindowPtr a,
+    register WindowPtr b)
+{
+    for (b = b->parent; b; b = b->parent)
+	if (IsParent(b, a)) return b;
+    return NullWindow;
+}
+
+static void
+EnterLeaveEvent(
+    int type,
+    int mode,
+    int detail,
+    register WindowPtr pWin,
+    Window child)
+{
+    xEvent		event;
+    register DeviceIntPtr keybd = inputInfo.keyboard;
+    WindowPtr		focus;
+    register DeviceIntPtr mouse = inputInfo.pointer;
+    register GrabPtr	grab = mouse->grab;
+    Mask		mask;
+
+    if ((pWin == mouse->valuator->motionHintWindow) &&
+	(detail != NotifyInferior))
+	mouse->valuator->motionHintWindow = NullWindow;
+    if (grab)
+    {
+	mask = (pWin == grab->window) ? grab->eventMask : 0;
+	if (grab->ownerEvents)
+	    mask |= EventMaskForClient(pWin, rClient(grab));
+    }
+    else
+    {
+	mask = pWin->eventMask | wOtherEventMasks(pWin);
+    }
+    if (mask & filters[type])
+    {
+	event.u.u.type = type;
+	event.u.u.detail = detail;
+	event.u.enterLeave.time = currentTime.milliseconds;
+	event.u.enterLeave.rootX = sprite.hot.x;
+	event.u.enterLeave.rootY = sprite.hot.y;
+	/* Counts on the same initial structure of crossing & button events! */
+	FixUpEventFromWindow(&event, pWin, None, FALSE);
+	/* Enter/Leave events always set child */
+	event.u.enterLeave.child = child;
+	event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ?
+					    ELFlagSameScreen : 0;
+#ifdef XKB
+	if (!noXkbExtension) {
+	    event.u.enterLeave.state = mouse->button->state & 0x1f00;
+	    event.u.enterLeave.state |= 
+			XkbGrabStateFromRec(&keybd->key->xkbInfo->state);
+	} else
+#endif
+	event.u.enterLeave.state = keybd->key->state | mouse->button->state;
+	event.u.enterLeave.mode = mode;
+	focus = keybd->focus->win;
+	if ((focus != NoneWin) &&
+	    ((pWin == focus) || (focus == PointerRootWin) ||
+	     IsParent(focus, pWin)))
+	    event.u.enterLeave.flags |= ELFlagFocus;
+	if (grab)
+	    (void)TryClientEvents(rClient(grab), &event, 1, mask,
+				  filters[type], grab);
+	else
+	    (void)DeliverEventsToWindow(pWin, &event, 1, filters[type],
+					NullGrab, 0);
+    }
+    if ((type == EnterNotify) && (mask & KeymapStateMask))
+    {
+	xKeymapEvent ke;
+
+#ifdef XCSECURITY
+	ClientPtr client = grab ? rClient(grab)
+				: clients[CLIENT_ID(pWin->drawable.id)];
+	if (!SecurityCheckDeviceAccess(client, keybd, FALSE))
+	{
+	    bzero((char *)&ke.map[0], 31);
+	}
+	else
+#endif
+	memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31);
+	ke.type = KeymapNotify;
+	if (grab)
+	    (void)TryClientEvents(rClient(grab), (xEvent *)&ke, 1, mask,
+				  KeymapStateMask, grab);
+	else
+	    (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1,
+					KeymapStateMask, NullGrab, 0);
+    }
+}
+
+static void
+EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail)
+{
+    WindowPtr	parent = child->parent;
+
+    if (ancestor == parent)
+	return;
+    EnterNotifies(ancestor, parent, mode, detail);
+    EnterLeaveEvent(EnterNotify, mode, detail, parent, child->drawable.id);
+}
+
+static void
+LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail)
+{
+    register WindowPtr  pWin;
+
+    if (ancestor == child)
+	return;
+    for (pWin = child->parent; pWin != ancestor; pWin = pWin->parent)
+    {
+	EnterLeaveEvent(LeaveNotify, mode, detail, pWin, child->drawable.id);
+	child = pWin;
+    }
+}
+
+static void
+DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode)
+{
+    if (fromWin == toWin)
+	return;
+    if (IsParent(fromWin, toWin))
+    {
+	EnterLeaveEvent(LeaveNotify, mode, NotifyInferior, fromWin, None);
+	EnterNotifies(fromWin, toWin, mode, NotifyVirtual);
+	EnterLeaveEvent(EnterNotify, mode, NotifyAncestor, toWin, None);
+    }
+    else if (IsParent(toWin, fromWin))
+    {
+	EnterLeaveEvent(LeaveNotify, mode, NotifyAncestor, fromWin, None);
+	LeaveNotifies(fromWin, toWin, mode, NotifyVirtual);
+	EnterLeaveEvent(EnterNotify, mode, NotifyInferior, toWin, None);
+    }
+    else
+    { /* neither fromWin nor toWin is descendent of the other */
+	WindowPtr common = CommonAncestor(toWin, fromWin);
+	/* common == NullWindow ==> different screens */
+	EnterLeaveEvent(LeaveNotify, mode, NotifyNonlinear, fromWin, None);
+	LeaveNotifies(fromWin, common, mode, NotifyNonlinearVirtual);
+	EnterNotifies(common, toWin, mode, NotifyNonlinearVirtual);
+	EnterLeaveEvent(EnterNotify, mode, NotifyNonlinear, toWin, None);
+    }
+}
+
+static void
+FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, register WindowPtr pWin)
+{
+    xEvent event;
+
+#ifdef XINPUT
+    if (dev != inputInfo.keyboard)
+    {
+	DeviceFocusEvent(dev, type, mode, detail, pWin);
+	return;
+    }
+#endif
+    event.u.focus.mode = mode;
+    event.u.u.type = type;
+    event.u.u.detail = detail;
+    event.u.focus.window = pWin->drawable.id;
+    (void)DeliverEventsToWindow(pWin, &event, 1, filters[type], NullGrab,
+				0);
+    if ((type == FocusIn) &&
+	((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask))
+    {
+	xKeymapEvent ke;
+#ifdef XCSECURITY
+	ClientPtr client = clients[CLIENT_ID(pWin->drawable.id)];
+	if (!SecurityCheckDeviceAccess(client, dev, FALSE))
+	{
+	    bzero((char *)&ke.map[0], 31);
+	}
+	else
+#endif
+	memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31);
+	ke.type = KeymapNotify;
+	(void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1,
+				    KeymapStateMask, NullGrab, 0);
+    }
+}
+
+ /*
+  * recursive because it is easier
+  * no-op if child not descended from ancestor
+  */
+static Bool
+FocusInEvents(
+    DeviceIntPtr dev,
+    WindowPtr ancestor, WindowPtr child, WindowPtr skipChild,
+    int mode, int detail,
+    Bool doAncestor)
+{
+    if (child == NullWindow)
+	return ancestor == NullWindow;
+    if (ancestor == child)
+    {
+	if (doAncestor)
+	    FocusEvent(dev, FocusIn, mode, detail, child);
+	return TRUE;
+    }
+    if (FocusInEvents(dev, ancestor, child->parent, skipChild, mode, detail,
+		      doAncestor))
+    {
+	if (child != skipChild)
+	    FocusEvent(dev, FocusIn, mode, detail, child);
+	return TRUE;
+    }
+    return FALSE;
+}
+
+/* dies horribly if ancestor is not an ancestor of child */
+static void
+FocusOutEvents(
+    DeviceIntPtr dev,
+    WindowPtr child, WindowPtr ancestor,
+    int mode, int detail,
+    Bool doAncestor)
+{
+    register WindowPtr  pWin;
+
+    for (pWin = child; pWin != ancestor; pWin = pWin->parent)
+	FocusEvent(dev, FocusOut, mode, detail, pWin);
+    if (doAncestor)
+	FocusEvent(dev, FocusOut, mode, detail, ancestor);
+}
+
+void
+DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode)
+{
+    int     out, in;		       /* for holding details for to/from
+				          PointerRoot/None */
+    int     i;
+
+    if (fromWin == toWin)
+	return;
+    out = (fromWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
+    in = (toWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
+ /* wrong values if neither, but then not referenced */
+
+    if ((toWin == NullWindow) || (toWin == PointerRootWin))
+    {
+	if ((fromWin == NullWindow) || (fromWin == PointerRootWin))
+   	{
+	    if (fromWin == PointerRootWin)
+		FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
+			       TRUE);
+	    /* Notify all the roots */
+#ifdef PANORAMIX
+ 	    if ( !noPanoramiXExtension )
+	        FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
+	    else 
+#endif
+	        for (i=0; i<screenInfo.numScreens; i++)
+	            FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
+	}
+	else
+	{
+	    if (IsParent(fromWin, sprite.win))
+	      FocusOutEvents(dev, sprite.win, fromWin, mode, NotifyPointer,
+			     FALSE);
+	    FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin);
+	    /* next call catches the root too, if the screen changed */
+	    FocusOutEvents(dev, fromWin->parent, NullWindow, mode,
+			   NotifyNonlinearVirtual, FALSE);
+	}
+	/* Notify all the roots */
+#ifdef PANORAMIX
+	if ( !noPanoramiXExtension )
+	    FocusEvent(dev, FocusIn, mode, in, WindowTable[0]);
+	else 
+#endif
+	    for (i=0; i<screenInfo.numScreens; i++)
+	        FocusEvent(dev, FocusIn, mode, in, WindowTable[i]);
+	if (toWin == PointerRootWin)
+	    (void)FocusInEvents(dev, ROOT, sprite.win, NullWindow, mode,
+				NotifyPointer, TRUE);
+    }
+    else
+    {
+	if ((fromWin == NullWindow) || (fromWin == PointerRootWin))
+	{
+	    if (fromWin == PointerRootWin)
+		FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
+			       TRUE);
+#ifdef PANORAMIX
+ 	    if ( !noPanoramiXExtension )
+	        FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
+	    else 
+#endif
+	        for (i=0; i<screenInfo.numScreens; i++)
+	            FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
+	    if (toWin->parent != NullWindow)
+	      (void)FocusInEvents(dev, ROOT, toWin, toWin, mode,
+				  NotifyNonlinearVirtual, TRUE);
+	    FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin);
+	    if (IsParent(toWin, sprite.win))
+    	       (void)FocusInEvents(dev, toWin, sprite.win, NullWindow, mode,
+				   NotifyPointer, FALSE);
+	}
+	else
+	{
+	    if (IsParent(toWin, fromWin))
+	    {
+		FocusEvent(dev, FocusOut, mode, NotifyAncestor, fromWin);
+		FocusOutEvents(dev, fromWin->parent, toWin, mode,
+			       NotifyVirtual, FALSE);
+		FocusEvent(dev, FocusIn, mode, NotifyInferior, toWin);
+		if ((IsParent(toWin, sprite.win)) &&
+			(sprite.win != fromWin) &&
+			(!IsParent(fromWin, sprite.win)) &&
+			(!IsParent(sprite.win, fromWin)))
+		    (void)FocusInEvents(dev, toWin, sprite.win, NullWindow,
+					mode, NotifyPointer, FALSE);
+	    }
+	    else
+		if (IsParent(fromWin, toWin))
+		{
+		    if ((IsParent(fromWin, sprite.win)) &&
+			    (sprite.win != fromWin) &&
+			    (!IsParent(toWin, sprite.win)) &&
+			    (!IsParent(sprite.win, toWin)))
+			FocusOutEvents(dev, sprite.win, fromWin, mode,
+				       NotifyPointer, FALSE);
+		    FocusEvent(dev, FocusOut, mode, NotifyInferior, fromWin);
+		    (void)FocusInEvents(dev, fromWin, toWin, toWin, mode,
+					NotifyVirtual, FALSE);
+		    FocusEvent(dev, FocusIn, mode, NotifyAncestor, toWin);
+		}
+		else
+		{
+		/* neither fromWin or toWin is child of other */
+		    WindowPtr common = CommonAncestor(toWin, fromWin);
+		/* common == NullWindow ==> different screens */
+		    if (IsParent(fromWin, sprite.win))
+			FocusOutEvents(dev, sprite.win, fromWin, mode,
+				       NotifyPointer, FALSE);
+		    FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin);
+		    if (fromWin->parent != NullWindow)
+		      FocusOutEvents(dev, fromWin->parent, common, mode,
+				     NotifyNonlinearVirtual, FALSE);
+		    if (toWin->parent != NullWindow)
+		      (void)FocusInEvents(dev, common, toWin, toWin, mode,
+					  NotifyNonlinearVirtual, FALSE);
+		    FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin);
+		    if (IsParent(toWin, sprite.win))
+			(void)FocusInEvents(dev, toWin, sprite.win, NullWindow,
+					    mode, NotifyPointer, FALSE);
+		}
+	}
+    }
+}
+
+int
+SetInputFocus(
+    ClientPtr client,
+    DeviceIntPtr dev,
+    Window focusID,
+    CARD8 revertTo,
+    Time ctime,
+    Bool followOK)
+{
+    register FocusClassPtr focus;
+    register WindowPtr focusWin;
+    int mode;
+    TimeStamp time;
+
+    UpdateCurrentTime();
+    if ((revertTo != RevertToParent) &&
+	(revertTo != RevertToPointerRoot) &&
+	(revertTo != RevertToNone) &&
+	((revertTo != RevertToFollowKeyboard) || !followOK))
+    {
+	client->errorValue = revertTo;
+	return BadValue;
+    }
+    time = ClientTimeToServerTime(ctime);
+    if ((focusID == None) || (focusID == PointerRoot))
+	focusWin = (WindowPtr)(long)focusID;
+    else if ((focusID == FollowKeyboard) && followOK)
+	focusWin = inputInfo.keyboard->focus->win;
+    else if (!(focusWin = SecurityLookupWindow(focusID, client,
+					       SecurityReadAccess)))
+	return BadWindow;
+    else
+    {
+ 	/* It is a match error to try to set the input focus to an 
+	unviewable window. */
+
+	if(!focusWin->realized)
+	    return(BadMatch);
+    }
+    focus = dev->focus;
+    if ((CompareTimeStamps(time, currentTime) == LATER) ||
+	(CompareTimeStamps(time, focus->time) == EARLIER))
+	return Success;
+    mode = (dev->grab) ? NotifyWhileGrabbed : NotifyNormal;
+    if (focus->win == FollowKeyboardWin)
+	DoFocusEvents(dev, inputInfo.keyboard->focus->win, focusWin, mode);
+    else
+	DoFocusEvents(dev, focus->win, focusWin, mode);
+    focus->time = time;
+    focus->revert = revertTo;
+    if (focusID == FollowKeyboard)
+	focus->win = FollowKeyboardWin;
+    else
+	focus->win = focusWin;
+    if ((focusWin == NoneWin) || (focusWin == PointerRootWin))
+	focus->traceGood = 0;
+    else
+    {
+        int depth = 0;
+	register WindowPtr pWin;
+
+        for (pWin = focusWin; pWin; pWin = pWin->parent) depth++;
+        if (depth > focus->traceSize)
+        {
+	    focus->traceSize = depth+1;
+	    Must_have_memory = TRUE; /* XXX */
+	    focus->trace = (WindowPtr *)xrealloc(focus->trace,
+						 focus->traceSize *
+						 sizeof(WindowPtr));
+	    Must_have_memory = FALSE; /* XXX */
+	}
+	focus->traceGood = depth;
+        for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--) 
+	    focus->trace[depth] = pWin;
+    }
+    return Success;
+}
+
+int
+ProcSetInputFocus(client)
+    ClientPtr client;
+{
+    REQUEST(xSetInputFocusReq);
+
+    REQUEST_SIZE_MATCH(xSetInputFocusReq);
+#ifdef XCSECURITY
+    if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE))
+	return Success;
+#endif
+    return SetInputFocus(client, inputInfo.keyboard, stuff->focus,
+			 stuff->revertTo, stuff->time, FALSE);
+}
+
+int
+ProcGetInputFocus(ClientPtr client)
+{
+    xGetInputFocusReply rep;
+    /* REQUEST(xReq); */
+    FocusClassPtr focus = inputInfo.keyboard->focus;
+
+    REQUEST_SIZE_MATCH(xReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    if (focus->win == NoneWin)
+	rep.focus = None;
+    else if (focus->win == PointerRootWin)
+	rep.focus = PointerRoot;
+    else rep.focus = focus->win->drawable.id;
+    rep.revertTo = focus->revert;
+    WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
+    return Success;
+}
+
+int
+ProcGrabPointer(ClientPtr client)
+{
+    xGrabPointerReply rep;
+    DeviceIntPtr device = inputInfo.pointer;
+    GrabPtr grab;
+    WindowPtr pWin, confineTo;
+    CursorPtr cursor, oldCursor;
+    REQUEST(xGrabPointerReq);
+    TimeStamp time;
+
+    REQUEST_SIZE_MATCH(xGrabPointerReq);
+    UpdateCurrentTime();
+    if ((stuff->pointerMode != GrabModeSync) &&
+	(stuff->pointerMode != GrabModeAsync))
+    {
+	client->errorValue = stuff->pointerMode;
+        return BadValue;
+    }
+    if ((stuff->keyboardMode != GrabModeSync) &&
+	(stuff->keyboardMode != GrabModeAsync))
+    {
+	client->errorValue = stuff->keyboardMode;
+        return BadValue;
+    }
+    if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue))
+    {
+	client->errorValue = stuff->ownerEvents;
+        return BadValue;
+    }
+    if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs)
+    {
+	client->errorValue = stuff->eventMask;
+        return BadValue;
+    }
+    pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+    if (stuff->confineTo == None)
+	confineTo = NullWindow;
+    else 
+    {
+	confineTo = SecurityLookupWindow(stuff->confineTo, client,
+					 SecurityReadAccess);
+	if (!confineTo)
+	    return BadWindow;
+    }
+    if (stuff->cursor == None)
+	cursor = NullCursor;
+    else
+    {
+	cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+						RT_CURSOR, SecurityReadAccess);
+	if (!cursor)
+	{
+	    client->errorValue = stuff->cursor;
+	    return BadCursor;
+	}
+    }
+	/* at this point, some sort of reply is guaranteed. */
+    time = ClientTimeToServerTime(stuff->time);
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.length = 0;
+    grab = device->grab;
+    if ((grab) && !SameClient(grab, client))
+	rep.status = AlreadyGrabbed;
+    else if ((!pWin->realized) ||
+             (confineTo &&
+                !(confineTo->realized && BorderSizeNotEmpty(confineTo))))
+	rep.status = GrabNotViewable;
+    else if (device->sync.frozen &&
+	     device->sync.other && !SameClient(device->sync.other, client))
+	rep.status = GrabFrozen;
+    else if ((CompareTimeStamps(time, currentTime) == LATER) ||
+	     (CompareTimeStamps(time, device->grabTime) == EARLIER))
+	rep.status = GrabInvalidTime;
+    else
+    {
+	GrabRec tempGrab;
+
+	oldCursor = NullCursor;
+	if (grab)
+ 	{
+	    if (grab->confineTo && !confineTo)
+		ConfineCursorToWindow(ROOT, FALSE, FALSE);
+	    oldCursor = grab->cursor;
+	}
+	tempGrab.cursor = cursor;
+	tempGrab.resource = client->clientAsMask;
+	tempGrab.ownerEvents = stuff->ownerEvents;
+	tempGrab.eventMask = stuff->eventMask;
+	tempGrab.confineTo = confineTo;
+	tempGrab.window = pWin;
+	tempGrab.keyboardMode = stuff->keyboardMode;
+	tempGrab.pointerMode = stuff->pointerMode;
+	tempGrab.device = device;
+	(*device->ActivateGrab)(device, &tempGrab, time, FALSE);
+	if (oldCursor)
+	    FreeCursor (oldCursor, (Cursor)0);
+	rep.status = GrabSuccess;
+    }
+    WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep);
+    return Success;
+}
+
+int
+ProcChangeActivePointerGrab(ClientPtr client)
+{
+    DeviceIntPtr device = inputInfo.pointer;
+    register GrabPtr grab = device->grab;
+    CursorPtr newCursor, oldCursor;
+    REQUEST(xChangeActivePointerGrabReq);
+    TimeStamp time;
+
+    REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
+    if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs)
+    {
+	client->errorValue = stuff->eventMask;
+        return BadValue;
+    }
+    if (stuff->cursor == None)
+	newCursor = NullCursor;
+    else
+    {
+	newCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+						RT_CURSOR, SecurityReadAccess);
+	if (!newCursor)
+	{
+	    client->errorValue = stuff->cursor;
+	    return BadCursor;
+	}
+    }
+    if (!grab)
+	return Success;
+    if (!SameClient(grab, client))
+	return Success;
+    time = ClientTimeToServerTime(stuff->time);
+    if ((CompareTimeStamps(time, currentTime) == LATER) ||
+	     (CompareTimeStamps(time, device->grabTime) == EARLIER))
+	return Success;
+    oldCursor = grab->cursor;
+    grab->cursor = newCursor;
+    if (newCursor)
+	newCursor->refcnt++;
+    PostNewCursor();
+    if (oldCursor)
+	FreeCursor(oldCursor, (Cursor)0);
+    grab->eventMask = stuff->eventMask;
+    return Success;
+}
+
+int
+ProcUngrabPointer(ClientPtr client)
+{
+    DeviceIntPtr device = inputInfo.pointer;
+    GrabPtr grab;
+    TimeStamp time;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    UpdateCurrentTime();
+    grab = device->grab;
+    time = ClientTimeToServerTime(stuff->id);
+    if ((CompareTimeStamps(time, currentTime) != LATER) &&
+	    (CompareTimeStamps(time, device->grabTime) != EARLIER) &&
+	    (grab) && SameClient(grab, client))
+	(*device->DeactivateGrab)(device);
+    return Success;
+}
+
+int
+GrabDevice(register ClientPtr client, register DeviceIntPtr dev, 
+           unsigned this_mode, unsigned other_mode, Window grabWindow, 
+           unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status)
+{
+    register WindowPtr pWin;
+    register GrabPtr grab;
+    TimeStamp time;
+
+    UpdateCurrentTime();
+    if ((this_mode != GrabModeSync) && (this_mode != GrabModeAsync))
+    {
+	client->errorValue = this_mode;
+        return BadValue;
+    }
+    if ((other_mode != GrabModeSync) && (other_mode != GrabModeAsync))
+    {
+	client->errorValue = other_mode;
+        return BadValue;
+    }
+    if ((ownerEvents != xFalse) && (ownerEvents != xTrue))
+    {
+	client->errorValue = ownerEvents;
+        return BadValue;
+    }
+    pWin = SecurityLookupWindow(grabWindow, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+    time = ClientTimeToServerTime(ctime);
+    grab = dev->grab;
+    if (grab && !SameClient(grab, client))
+	*status = AlreadyGrabbed;
+    else if (!pWin->realized)
+	*status = GrabNotViewable;
+    else if ((CompareTimeStamps(time, currentTime) == LATER) ||
+	     (CompareTimeStamps(time, dev->grabTime) == EARLIER))
+	*status = GrabInvalidTime;
+    else if (dev->sync.frozen &&
+	     dev->sync.other && !SameClient(dev->sync.other, client))
+	*status = GrabFrozen;
+    else
+    {
+	GrabRec tempGrab;
+
+	tempGrab.window = pWin;
+	tempGrab.resource = client->clientAsMask;
+	tempGrab.ownerEvents = ownerEvents;
+	tempGrab.keyboardMode = this_mode;
+	tempGrab.pointerMode = other_mode;
+	tempGrab.eventMask = mask;
+	tempGrab.device = dev;
+	(*dev->ActivateGrab)(dev, &tempGrab, time, FALSE);
+	*status = GrabSuccess;
+    }
+    return Success;
+}
+
+int
+ProcGrabKeyboard(ClientPtr client)
+{
+    xGrabKeyboardReply rep;
+    REQUEST(xGrabKeyboardReq);
+    int result;
+
+    REQUEST_SIZE_MATCH(xGrabKeyboardReq);
+#ifdef XCSECURITY
+    if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE))
+    {
+	result = Success;
+	rep.status = AlreadyGrabbed;
+    }
+    else
+#endif
+    result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode,
+			stuff->pointerMode, stuff->grabWindow,
+			stuff->ownerEvents, stuff->time,
+			KeyPressMask | KeyReleaseMask, &rep.status);
+    if (result != Success)
+	return result;
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.length = 0;
+    WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep);
+    return Success;
+}
+
+int
+ProcUngrabKeyboard(ClientPtr client)
+{
+    DeviceIntPtr device = inputInfo.keyboard;
+    GrabPtr grab;
+    TimeStamp time;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    UpdateCurrentTime();
+    grab = device->grab;
+    time = ClientTimeToServerTime(stuff->id);
+    if ((CompareTimeStamps(time, currentTime) != LATER) &&
+	(CompareTimeStamps(time, device->grabTime) != EARLIER) &&
+	(grab) && SameClient(grab, client))
+	(*device->DeactivateGrab)(device);
+    return Success;
+}
+
+int
+ProcQueryPointer(ClientPtr client)
+{
+    xQueryPointerReply rep;
+    WindowPtr pWin, t;
+    REQUEST(xResourceReq);
+    DeviceIntPtr mouse = inputInfo.pointer;
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+    if (mouse->valuator->motionHintWindow)
+	MaybeStopHint(mouse, client);
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.mask = mouse->button->state | inputInfo.keyboard->key->state;
+    rep.length = 0;
+    rep.root = (ROOT)->drawable.id;
+    rep.rootX = sprite.hot.x;
+    rep.rootY = sprite.hot.y;
+    rep.child = None;
+    if (sprite.hot.pScreen == pWin->drawable.pScreen)
+    {
+	rep.sameScreen = xTrue;
+	rep.winX = sprite.hot.x - pWin->drawable.x;
+	rep.winY = sprite.hot.y - pWin->drawable.y;
+	for (t = sprite.win; t; t = t->parent)
+	    if (t->parent == pWin)
+	    {
+		rep.child = t->drawable.id;
+		break;
+	    }
+    }
+    else
+    {
+	rep.sameScreen = xFalse;
+	rep.winX = 0;
+	rep.winY = 0;
+    }
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension) {
+	rep.rootX += panoramiXdataPtr[0].x;
+	rep.rootY += panoramiXdataPtr[0].y;
+	if(stuff->id == rep.root) {
+	    rep.winX += panoramiXdataPtr[0].x;
+	    rep.winY += panoramiXdataPtr[0].y;
+	}
+    }
+#endif
+
+    WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
+
+    return(Success);    
+}
+
+void
+InitEvents()
+{
+    int i;
+
+    sprite.hot.pScreen = sprite.hotPhys.pScreen = (ScreenPtr)NULL;
+    inputInfo.numDevices = 0;
+    inputInfo.devices = (DeviceIntPtr)NULL;
+    inputInfo.off_devices = (DeviceIntPtr)NULL;
+    inputInfo.keyboard = (DeviceIntPtr)NULL;
+    inputInfo.pointer = (DeviceIntPtr)NULL;
+    if (spriteTraceSize == 0)
+    {
+	spriteTraceSize = 32;
+	spriteTrace = (WindowPtr *)xalloc(32*sizeof(WindowPtr));
+	if (!spriteTrace)
+	    FatalError("failed to allocate spriteTrace");
+    }
+    spriteTraceGood = 0;
+    lastEventMask = OwnerGrabButtonMask;
+    filters[MotionNotify] = PointerMotionMask;
+#ifdef XEVIE
+    xeviewin =
+#endif
+    sprite.win = NullWindow;
+    sprite.current = NullCursor;
+    sprite.hotLimits.x1 = 0;
+    sprite.hotLimits.y1 = 0;
+    sprite.hotLimits.x2 = 0;
+    sprite.hotLimits.y2 = 0;
+    sprite.confined = FALSE;
+    syncEvents.replayDev = (DeviceIntPtr)NULL;
+    syncEvents.replayWin = NullWindow;
+    while (syncEvents.pending)
+    {
+	QdEventPtr next = syncEvents.pending->next;
+	xfree(syncEvents.pending);
+	syncEvents.pending = next;
+    }
+    syncEvents.pendtail = &syncEvents.pending;
+    syncEvents.playingEvents = FALSE;
+    syncEvents.time.months = 0;
+    syncEvents.time.milliseconds = 0;	/* hardly matters */
+    currentTime.months = 0;
+    currentTime.milliseconds = GetTimeInMillis();
+    lastDeviceEventTime = currentTime;
+    for (i = 0; i < DNPMCOUNT; i++)
+    {
+	DontPropagateMasks[i] = 0;
+	DontPropagateRefCnts[i] = 0;
+    }
+}
+
+void
+CloseDownEvents(void)
+{
+  xfree(spriteTrace);
+  spriteTrace = NULL;
+  spriteTraceSize = 0;
+}
+
+int
+ProcSendEvent(ClientPtr client)
+{
+    WindowPtr pWin;
+    WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
+    REQUEST(xSendEventReq);
+
+    REQUEST_SIZE_MATCH(xSendEventReq);
+
+    /* The client's event type must be a core event type or one defined by an
+	extension. */
+
+    if ( ! ((stuff->event.u.u.type > X_Reply &&
+	     stuff->event.u.u.type < LASTEvent) || 
+	    (stuff->event.u.u.type >= EXTENSION_EVENT_BASE &&
+	     stuff->event.u.u.type < (unsigned)lastEvent)))
+    {
+	client->errorValue = stuff->event.u.u.type;
+	return BadValue;
+    }
+    if (stuff->event.u.u.type == ClientMessage &&
+	stuff->event.u.u.detail != 8 &&
+	stuff->event.u.u.detail != 16 &&
+	stuff->event.u.u.detail != 32 &&
+	!permitOldBugs)
+    {
+	client->errorValue = stuff->event.u.u.detail;
+	return BadValue;
+    }
+    if ((stuff->eventMask & ~AllEventMasks) && !permitOldBugs)
+    {
+	client->errorValue = stuff->eventMask;
+	return BadValue;
+    }
+
+    if (stuff->destination == PointerWindow)
+	pWin = sprite.win;
+    else if (stuff->destination == InputFocus)
+    {
+	WindowPtr inputFocus = inputInfo.keyboard->focus->win;
+
+	if (inputFocus == NoneWin)
+	    return Success;
+
+	/* If the input focus is PointerRootWin, send the event to where
+	the pointer is if possible, then perhaps propogate up to root. */
+   	if (inputFocus == PointerRootWin)
+	    inputFocus = ROOT;
+
+	if (IsParent(inputFocus, sprite.win))
+	{
+	    effectiveFocus = inputFocus;
+	    pWin = sprite.win;
+	}
+	else
+	    effectiveFocus = pWin = inputFocus;
+    }
+    else
+	pWin = SecurityLookupWindow(stuff->destination, client,
+				    SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+    if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue))
+    {
+	client->errorValue = stuff->propagate;
+	return BadValue;
+    }
+    stuff->event.u.u.type |= 0x80;
+    if (stuff->propagate)
+    {
+	for (;pWin; pWin = pWin->parent)
+	{
+	    if (DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
+				      NullGrab, 0))
+		return Success;
+	    if (pWin == effectiveFocus)
+		return Success;
+	    stuff->eventMask &= ~wDontPropagateMask(pWin);
+	    if (!stuff->eventMask)
+		break;
+	}
+    }
+    else
+	(void)DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
+				    NullGrab, 0);
+    return Success;
+}
+
+int
+ProcUngrabKey(ClientPtr client)
+{
+    REQUEST(xUngrabKeyReq);
+    WindowPtr pWin;
+    GrabRec tempGrab;
+    DeviceIntPtr keybd = inputInfo.keyboard;
+
+    REQUEST_SIZE_MATCH(xUngrabKeyReq);
+    pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+
+    if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
+	 (stuff->key < keybd->key->curKeySyms.minKeyCode))
+	&& (stuff->key != AnyKey))
+    {
+	client->errorValue = stuff->key;
+        return BadValue;
+    }
+    if ((stuff->modifiers != AnyModifier) &&
+	(stuff->modifiers & ~AllModifiersMask))
+    {
+	client->errorValue = stuff->modifiers;
+	return BadValue;
+    }
+    tempGrab.resource = client->clientAsMask;
+    tempGrab.device = keybd;
+    tempGrab.window = pWin;
+    tempGrab.modifiersDetail.exact = stuff->modifiers;
+    tempGrab.modifiersDetail.pMask = NULL;
+    tempGrab.modifierDevice = inputInfo.keyboard;
+    tempGrab.type = KeyPress;
+    tempGrab.detail.exact = stuff->key;
+    tempGrab.detail.pMask = NULL;
+
+    if (!DeletePassiveGrabFromList(&tempGrab))
+	return(BadAlloc);
+    return(Success);
+}
+
+int
+ProcGrabKey(ClientPtr client)
+{
+    WindowPtr pWin;
+    REQUEST(xGrabKeyReq);
+    GrabPtr grab;
+    DeviceIntPtr keybd = inputInfo.keyboard;
+
+    REQUEST_SIZE_MATCH(xGrabKeyReq);
+    if ((stuff->ownerEvents != xTrue) && (stuff->ownerEvents != xFalse))
+    {
+	client->errorValue = stuff->ownerEvents;
+	return(BadValue);
+    }
+    if ((stuff->pointerMode != GrabModeSync) &&
+	(stuff->pointerMode != GrabModeAsync))
+    {
+	client->errorValue = stuff->pointerMode;
+        return BadValue;
+    }
+    if ((stuff->keyboardMode != GrabModeSync) &&
+	(stuff->keyboardMode != GrabModeAsync))
+    {
+	client->errorValue = stuff->keyboardMode;
+        return BadValue;
+    }
+    if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
+	 (stuff->key < keybd->key->curKeySyms.minKeyCode))
+	&& (stuff->key != AnyKey))
+    {
+	client->errorValue = stuff->key;
+        return BadValue;
+    }
+    if ((stuff->modifiers != AnyModifier) &&
+	(stuff->modifiers & ~AllModifiersMask))
+    {
+	client->errorValue = stuff->modifiers;
+	return BadValue;
+    }
+    pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+
+    grab = CreateGrab(client->index, keybd, pWin, 
+	(Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents,
+	(Bool)stuff->keyboardMode, (Bool)stuff->pointerMode,
+	keybd, stuff->modifiers, KeyPress, stuff->key, 
+	NullWindow, NullCursor);
+    if (!grab)
+	return BadAlloc;
+    return AddPassiveGrabToList(grab);
+}
+
+
+int
+ProcGrabButton(ClientPtr client)
+{
+    WindowPtr pWin, confineTo;
+    REQUEST(xGrabButtonReq);
+    CursorPtr cursor;
+    GrabPtr grab;
+
+    REQUEST_SIZE_MATCH(xGrabButtonReq);
+    if ((stuff->pointerMode != GrabModeSync) &&
+	(stuff->pointerMode != GrabModeAsync))
+    {
+	client->errorValue = stuff->pointerMode;
+        return BadValue;
+    }
+    if ((stuff->keyboardMode != GrabModeSync) &&
+	(stuff->keyboardMode != GrabModeAsync))
+    {
+	client->errorValue = stuff->keyboardMode;
+        return BadValue;
+    }
+    if ((stuff->modifiers != AnyModifier) &&
+	(stuff->modifiers & ~AllModifiersMask))
+    {
+	client->errorValue = stuff->modifiers;
+	return BadValue;
+    }
+    if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue))
+    {
+	client->errorValue = stuff->ownerEvents;
+	return BadValue;
+    }
+    if (stuff->eventMask & ~PointerGrabMask)
+    {
+	client->errorValue = stuff->eventMask;
+        return BadValue;
+    }
+    pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+    if (stuff->confineTo == None)
+       confineTo = NullWindow;
+    else {
+	confineTo = SecurityLookupWindow(stuff->confineTo, client,
+					 SecurityReadAccess);
+	if (!confineTo)
+	    return BadWindow;
+    }
+    if (stuff->cursor == None)
+	cursor = NullCursor;
+    else
+    {
+	cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+						RT_CURSOR, SecurityReadAccess);
+	if (!cursor)
+	{
+	    client->errorValue = stuff->cursor;
+	    return BadCursor;
+	}
+    }
+
+
+    grab = CreateGrab(client->index, inputInfo.pointer, pWin, 
+    permitOldBugs ? (Mask)(stuff->eventMask |
+			       ButtonPressMask | ButtonReleaseMask) :
+			(Mask)stuff->eventMask,
+	(Bool)stuff->ownerEvents, (Bool) stuff->keyboardMode,
+	(Bool)stuff->pointerMode, inputInfo.keyboard, stuff->modifiers,
+	ButtonPress, stuff->button, confineTo, cursor);
+    if (!grab)
+	return BadAlloc;
+    return AddPassiveGrabToList(grab);
+}
+
+int
+ProcUngrabButton(ClientPtr client)
+{
+    REQUEST(xUngrabButtonReq);
+    WindowPtr pWin;
+    GrabRec tempGrab;
+
+    REQUEST_SIZE_MATCH(xUngrabButtonReq);
+    if ((stuff->modifiers != AnyModifier) &&
+	(stuff->modifiers & ~AllModifiersMask))
+    {
+	client->errorValue = stuff->modifiers;
+	return BadValue;
+    }
+    pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+    tempGrab.resource = client->clientAsMask;
+    tempGrab.device = inputInfo.pointer;
+    tempGrab.window = pWin;
+    tempGrab.modifiersDetail.exact = stuff->modifiers;
+    tempGrab.modifiersDetail.pMask = NULL;
+    tempGrab.modifierDevice = inputInfo.keyboard;
+    tempGrab.type = ButtonPress;
+    tempGrab.detail.exact = stuff->button;
+    tempGrab.detail.pMask = NULL;
+
+    if (!DeletePassiveGrabFromList(&tempGrab))
+	return(BadAlloc);
+    return(Success);
+}
+
+void
+DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
+{
+    WindowPtr		parent;
+    DeviceIntPtr	mouse = inputInfo.pointer;
+    DeviceIntPtr	keybd = inputInfo.keyboard;
+    FocusClassPtr	focus = keybd->focus;
+    OtherClientsPtr	oc;
+    GrabPtr		passive;
+
+
+    /* Deactivate any grabs performed on this window, before making any
+	input focus changes. */
+
+    if (mouse->grab &&
+	((mouse->grab->window == pWin) || (mouse->grab->confineTo == pWin)))
+	(*mouse->DeactivateGrab)(mouse);
+
+    /* Deactivating a keyboard grab should cause focus events. */
+
+    if (keybd->grab && (keybd->grab->window == pWin))
+	(*keybd->DeactivateGrab)(keybd);
+
+    /* If the focus window is a root window (ie. has no parent) then don't 
+	delete the focus from it. */
+    
+    if ((pWin == focus->win) && (pWin->parent != NullWindow))
+    {
+	int focusEventMode = NotifyNormal;
+
+ 	/* If a grab is in progress, then alter the mode of focus events. */
+
+	if (keybd->grab)
+	    focusEventMode = NotifyWhileGrabbed;
+
+	switch (focus->revert)
+	{
+	case RevertToNone:
+	    DoFocusEvents(keybd, pWin, NoneWin, focusEventMode);
+	    focus->win = NoneWin;
+	    focus->traceGood = 0;
+	    break;
+	case RevertToParent:
+	    parent = pWin;
+	    do
+	    {
+		parent = parent->parent;
+		focus->traceGood--;
+	    } while (!parent->realized
+/* This would be a good protocol change -- windows being reparented
+   during SaveSet processing would cause the focus to revert to the
+   nearest enclosing window which will survive the death of the exiting
+   client, instead of ending up reverting to a dying window and thence
+   to None
+ */
+#ifdef NOTDEF
+ 	      || clients[CLIENT_ID(parent->drawable.id)]->clientGone
+#endif
+		);
+	    DoFocusEvents(keybd, pWin, parent, focusEventMode);
+	    focus->win = parent;
+	    focus->revert = RevertToNone;
+	    break;
+	case RevertToPointerRoot:
+	    DoFocusEvents(keybd, pWin, PointerRootWin, focusEventMode);
+	    focus->win = PointerRootWin;
+	    focus->traceGood = 0;
+	    break;
+	}
+    }
+
+    if (mouse->valuator->motionHintWindow == pWin)
+	mouse->valuator->motionHintWindow = NullWindow;
+
+    if (freeResources)
+    {
+	if (pWin->dontPropagate)
+	    DontPropagateRefCnts[pWin->dontPropagate]--;
+	while ( (oc = wOtherClients(pWin)) )
+	    FreeResource(oc->resource, RT_NONE);
+	while ( (passive = wPassiveGrabs(pWin)) )
+	    FreeResource(passive->resource, RT_NONE);
+     }
+#ifdef XINPUT
+    DeleteWindowFromAnyExtEvents(pWin, freeResources);
+#endif
+}
+
+/**
+ * Call this whenever some window at or below pWin has changed geometry 
+ */
+void
+CheckCursorConfinement(WindowPtr pWin)
+{
+    GrabPtr grab = inputInfo.pointer->grab;
+    WindowPtr confineTo;
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return;
+#endif
+
+    if (grab && (confineTo = grab->confineTo))
+    {
+	if (!BorderSizeNotEmpty(confineTo))
+	    (*inputInfo.pointer->DeactivateGrab)(inputInfo.pointer);
+	else if ((pWin == confineTo) || IsParent(pWin, confineTo))
+	    ConfineCursorToWindow(confineTo, TRUE, TRUE);
+    }
+}
+
+Mask
+EventMaskForClient(WindowPtr pWin, ClientPtr client)
+{
+    register OtherClientsPtr	other;
+
+    if (wClient (pWin) == client)
+	return pWin->eventMask;
+    for (other = wOtherClients(pWin); other; other = other->next)
+    {
+	if (SameClient(other, client))
+	    return other->mask;
+    }
+    return 0;
+}
+
+int
+ProcRecolorCursor(ClientPtr client)
+{
+    CursorPtr pCursor;
+    int		nscr;
+    ScreenPtr	pscr;
+    Bool 	displayed;
+    REQUEST(xRecolorCursorReq);
+
+    REQUEST_SIZE_MATCH(xRecolorCursorReq);
+    pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+					RT_CURSOR, SecurityWriteAccess);
+    if ( !pCursor) 
+    {
+	client->errorValue = stuff->cursor;
+	return (BadCursor);
+    }
+
+    pCursor->foreRed = stuff->foreRed;
+    pCursor->foreGreen = stuff->foreGreen;
+    pCursor->foreBlue = stuff->foreBlue;
+
+    pCursor->backRed = stuff->backRed;
+    pCursor->backGreen = stuff->backGreen;
+    pCursor->backBlue = stuff->backBlue;
+
+    for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
+    {
+	pscr = screenInfo.screens[nscr];
+#ifdef PANORAMIX
+	if(!noPanoramiXExtension)
+	    displayed = (pscr == sprite.screen);
+	else
+#endif
+	    displayed = (pscr == sprite.hotPhys.pScreen);
+	( *pscr->RecolorCursor)(pscr, pCursor,
+				(pCursor == sprite.current) && displayed);
+    }
+    return (Success);
+}
+
+void
+WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
+{
+#ifdef PANORAMIX
+    xEvent    eventCopy;
+#endif
+    xEvent    eventTo, *eventFrom;
+    int       i;
+
+#ifdef XKB
+    if ((!noXkbExtension)&&(!XkbFilterEvents(pClient, count, events)))
+	return;
+#endif
+
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension && 
+       (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y)) 
+    {
+	switch(events->u.u.type) {
+	case MotionNotify:
+	case ButtonPress:
+	case ButtonRelease:
+	case KeyPress:
+	case KeyRelease:
+	case EnterNotify:
+	case LeaveNotify:
+	/* 
+	   When multiple clients want the same event DeliverEventsToWindow
+	   passes the same event structure multiple times so we can't 
+	   modify the one passed to us 
+        */
+	    count = 1;  /* should always be 1 */
+	    memcpy(&eventCopy, events, sizeof(xEvent));
+	    eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x;
+	    eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y;
+	    if(eventCopy.u.keyButtonPointer.event == 
+	       eventCopy.u.keyButtonPointer.root) 
+	    {
+		eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x;
+		eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y;
+	    }
+	    events = &eventCopy;
+	    break;
+	default: break;
+	}
+    }
+#endif
+
+    if (EventCallback)
+    {
+	EventInfoRec eventinfo;
+	eventinfo.client = pClient;
+	eventinfo.events = events;
+	eventinfo.count = count;
+	CallCallbacks(&EventCallback, (pointer)&eventinfo);
+    }
+    if(pClient->swapped)
+    {
+	for(i = 0; i < count; i++)
+	{
+	    eventFrom = &events[i];
+	    /* Remember to strip off the leading bit of type in case
+	       this event was sent with "SendEvent." */
+	    (*EventSwapVector[eventFrom->u.u.type & 0177])
+		(eventFrom, &eventTo);
+	    (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo);
+	}
+    }
+    else
+    {
+	(void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/dix/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+XCOMM Default DPMS settings for Solaris
+EXTRA_DEFINES = -DDEFAULT_STANDBY_TIME=1440000 \
+		-DDEFAULT_SUSPEND_TIME=1620000 \
+		-DDEFAULT_OFF_TIME=1800000 \
+		-DDEFAULT_DPMS_ENABLED=TRUE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/dix/property.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,818 @@
+/* $XFree86: xc/programs/Xserver/dix/property.c,v 3.12 2002/02/19 11:09:22 alanh 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 2006 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.
+ */ 
+/* $Xorg: property.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "propertyst.h"
+#include "dixstruct.h"
+#include "dispatch.h"
+#include "swaprep.h"
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "lbxserve.h"
+#include "lbxtags.h"
+#endif
+
+#if defined(LBX) || defined(LBX_COMPAT)
+#if 0 /* no header in X11 environment, not used in X11 environment */
+int fWriteToClient(ClientPtr client, int len, char *buf)
+{
+    return WriteToClient(client, len, buf);
+}
+#endif
+#endif
+
+#ifdef TSOL
+#include "extnsionst.h"
+extern SecurityHookPtr pSecHook;
+#endif /* TSOL */
+
+/*****************************************************************
+ * Property Stuff
+ *
+ *    ChangeProperty, DeleteProperty, GetProperties,
+ *    ListProperties
+ *
+ *   Properties below to windows.  A allocate slots each time
+ *   a property is added.  No fancy searching done.
+ *
+ *****************************************************************/
+
+#ifdef notdef
+static void
+PrintPropertys(WindowPtr pWin)
+{
+    PropertyPtr pProp;
+    register int j;
+
+    pProp = pWin->userProps;
+    while (pProp)
+    {
+        ErrorF(  "%x %x\n", pProp->propertyName, pProp->type);
+        ErrorF("property format: %d\n", pProp->format);
+        ErrorF("property data: \n");
+        for (j=0; j<(pProp->format/8)*pProp->size; j++)
+           ErrorF("%c\n", pProp->data[j]);
+        pProp = pProp->next;
+    }
+}
+#endif
+
+int
+ProcRotateProperties(ClientPtr client)
+{
+    int     i, j, delta;
+    REQUEST(xRotatePropertiesReq);
+    WindowPtr pWin;
+    register    Atom * atoms;
+    PropertyPtr * props;               /* array of pointer */
+    PropertyPtr pProp;
+    xEvent event;
+
+    REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
+    UpdateCurrentTime();
+    pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
+					    SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+    if (!stuff->nAtoms)
+	return(Success);
+    atoms = (Atom *) & stuff[1];
+    props = (PropertyPtr *)ALLOCATE_LOCAL(stuff->nAtoms * sizeof(PropertyPtr));
+    if (!props)
+	return(BadAlloc);
+    for (i = 0; i < stuff->nAtoms; i++)
+    {
+	char action;
+
+#ifdef TSOL
+        if (pSecHook)
+            action = (*pSecHook->CheckPropertyAccess)(client, pWin, atoms[i],
+                                SecurityReadAccess|SecurityWriteAccess);
+        else
+#endif
+
+#ifdef XCSECURITY
+	action = SecurityCheckPropertyAccess(client, pWin, atoms[i],
+				SecurityReadAccess|SecurityWriteAccess);
+#endif
+        if (!ValidAtom(atoms[i])
+#ifdef XCSECURITY
+	    || (SecurityErrorOperation == action)
+#endif
+	   )
+        {
+            DEALLOCATE_LOCAL(props);
+	    client->errorValue = atoms[i];
+            return BadAtom;
+        }
+#ifdef XCSECURITY
+	if (SecurityIgnoreOperation == action)
+        {
+            DEALLOCATE_LOCAL(props);
+	    return Success;
+	}
+#endif
+        for (j = i + 1; j < stuff->nAtoms; j++)
+            if (atoms[j] == atoms[i])
+            {
+                DEALLOCATE_LOCAL(props);
+                return BadMatch;
+            }
+        pProp = wUserProps (pWin);
+        while (pProp)
+        {
+            if (pProp->propertyName == atoms[i])
+                goto found;
+	    pProp = pProp->next;
+        }
+        DEALLOCATE_LOCAL(props);
+        return BadMatch;
+found: 
+        props[i] = pProp;
+    }
+    delta = stuff->nPositions;
+
+    /* If the rotation is a complete 360 degrees, then moving the properties
+	around and generating PropertyNotify events should be skipped. */
+
+    if ( (stuff->nAtoms != 0) && (abs(delta) % stuff->nAtoms) != 0 ) 
+    {
+	while (delta < 0)                  /* faster if abs value is small */
+            delta += stuff->nAtoms;
+    	for (i = 0; i < stuff->nAtoms; i++)
+ 	{
+	    /* Generate a PropertyNotify event for each property whose value
+		is changed in the order in which they appear in the request. */
+ 
+ 	    event.u.u.type = PropertyNotify;
+            event.u.property.window = pWin->drawable.id;
+    	    event.u.property.state = PropertyNewValue;
+	    event.u.property.atom = props[i]->propertyName;	
+	    event.u.property.time = currentTime.milliseconds;
+	    DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+	
+            props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms];
+	}
+    }
+    DEALLOCATE_LOCAL(props);
+    return Success;
+}
+
+int 
+ProcChangeProperty(ClientPtr client)
+{	      
+    WindowPtr pWin;
+    char format, mode;
+    unsigned long len;
+    int sizeInBytes;
+    int totalSize;
+    int err;
+    char action;
+    REQUEST(xChangePropertyReq);
+
+    REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
+    UpdateCurrentTime();
+    format = stuff->format;
+    mode = stuff->mode;
+    if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
+	(mode != PropModePrepend))
+    {
+	client->errorValue = mode;
+	return BadValue;
+    }
+    if ((format != 8) && (format != 16) && (format != 32))
+    {
+	client->errorValue = format;
+        return BadValue;
+    }
+    len = stuff->nUnits;
+    if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
+	return BadLength;
+    sizeInBytes = format>>3;
+    totalSize = len * sizeInBytes;
+    REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize);
+
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityWriteAccess);
+    if (!pWin)
+	return(BadWindow);
+    if (!ValidAtom(stuff->property))
+    {
+	client->errorValue = stuff->property;
+	return(BadAtom);
+    }
+    if (!ValidAtom(stuff->type))
+    {
+	client->errorValue = stuff->type;
+	return(BadAtom);
+    }
+
+#ifdef TSOL
+    if (pSecHook)
+        action = (*pSecHook->CheckPropertyAccess)(client, pWin, stuff->property,
+                SecurityWriteAccess);
+        else
+#endif
+
+#ifdef XCSECURITY
+    action = (SecurityCheckPropertyAccess(client, pWin, stuff->property,
+					SecurityWriteAccess));
+    switch (action)
+    {
+	case SecurityErrorOperation:
+	    client->errorValue = stuff->property;
+	    return BadAtom;
+	case SecurityIgnoreOperation:
+	    return Success;
+    }
+#endif
+#ifdef TSOL
+    if (pSecHook)
+	err = (*pSecHook->ChangeWindowProperty)(client, pWin, stuff->property,
+            stuff->type, (int)format, (int)mode, len, (pointer)&stuff[1], TRUE);
+    else
+#endif /* TSOL */
+
+#ifdef LBX
+    err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type,
+	 (int)format, (int)mode, len, TRUE, (pointer)&stuff[1], TRUE, NULL);
+#else
+    err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format,
+			       (int)mode, len, (pointer)&stuff[1], TRUE);
+#endif
+    if (err != Success)
+	return err;
+    else
+	return client->noClientException;
+}
+
+int
+ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, 
+                     int mode, unsigned long len, pointer value, 
+                     Bool sendevent)
+{
+#ifdef LBX
+    return LbxChangeWindowProperty(NULL, pWin, property, type,
+				   format, mode, len, TRUE, value,
+				   sendevent, NULL);
+#else
+    PropertyPtr pProp;
+    xEvent event;
+    int sizeInBytes;
+    int totalSize;
+    pointer data;
+
+    sizeInBytes = format>>3;
+    totalSize = len * sizeInBytes;
+
+    /* first see if property already exists */
+
+    pProp = wUserProps (pWin);
+    while (pProp)
+    {
+	if (pProp->propertyName == property)
+	    break;
+	pProp = pProp->next;
+    }
+    if (!pProp)   /* just add to list */
+    {
+	if (!pWin->optional && !MakeWindowOptional (pWin))
+	    return(BadAlloc);
+        pProp = (PropertyPtr)xalloc(sizeof(PropertyRec));
+	if (!pProp)
+	    return(BadAlloc);
+        data = (pointer)xalloc(totalSize);
+	if (!data && len)
+	{
+	    xfree(pProp);
+	    return(BadAlloc);
+	}
+        pProp->propertyName = property;
+        pProp->type = type;
+        pProp->format = format;
+        pProp->data = data;
+	if (len)
+	    memmove((char *)data, (char *)value, totalSize);
+	pProp->size = len;
+        pProp->next = pWin->optional->userProps;
+        pWin->optional->userProps = pProp;
+#ifdef TSOL
+	pProp->secPrivate = (pointer)NULL;
+#endif /* TSOL */
+    }
+    else
+    {
+	/* To append or prepend to a property the request format and type
+		must match those of the already defined property.  The
+		existing format and type are irrelevant when using the mode
+		"PropModeReplace" since they will be written over. */
+
+        if ((format != pProp->format) && (mode != PropModeReplace))
+	    return(BadMatch);
+        if ((pProp->type != type) && (mode != PropModeReplace))
+            return(BadMatch);
+        if (mode == PropModeReplace)
+        {
+	    if (totalSize != pProp->size * (pProp->format >> 3))
+	    {
+	    	data = (pointer)xrealloc(pProp->data, totalSize);
+	    	if (!data && len)
+		    return(BadAlloc);
+            	pProp->data = data;
+	    }
+	    if (len)
+		memmove((char *)pProp->data, (char *)value, totalSize);
+	    pProp->size = len;
+    	    pProp->type = type;
+	    pProp->format = format;
+	}
+	else if (len == 0)
+	{
+	    /* do nothing */
+	}
+        else if (mode == PropModeAppend)
+        {
+	    data = (pointer)xrealloc(pProp->data,
+				     sizeInBytes * (len + pProp->size));
+	    if (!data)
+		return(BadAlloc);
+            pProp->data = data;
+	    memmove(&((char *)data)[pProp->size * sizeInBytes], 
+		    (char *)value,
+		  totalSize);
+            pProp->size += len;
+	}
+        else if (mode == PropModePrepend)
+        {
+            data = (pointer)xalloc(sizeInBytes * (len + pProp->size));
+	    if (!data)
+		return(BadAlloc);
+	    memmove(&((char *)data)[totalSize], (char *)pProp->data, 
+		  (int)(pProp->size * sizeInBytes));
+            memmove((char *)data, (char *)value, totalSize);
+	    xfree(pProp->data);
+            pProp->data = data;
+            pProp->size += len;
+	}
+    }
+    if (sendevent)
+    {
+	event.u.u.type = PropertyNotify;
+	event.u.property.window = pWin->drawable.id;
+	event.u.property.state = PropertyNewValue;
+	event.u.property.atom = pProp->propertyName;
+	event.u.property.time = currentTime.milliseconds;
+	DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+    }
+    return(Success);
+#endif
+}
+
+int
+DeleteProperty(WindowPtr pWin, Atom propName)
+{
+    PropertyPtr pProp, prevProp;
+    xEvent event;
+
+    if (!(pProp = wUserProps (pWin)))
+	return(Success);
+    prevProp = (PropertyPtr)NULL;
+    while (pProp)
+    {
+	if (pProp->propertyName == propName)
+	    break;
+        prevProp = pProp;
+	pProp = pProp->next;
+    }
+    if (pProp) 
+    {		    
+        if (prevProp == (PropertyPtr)NULL)      /* takes care of head */
+        {
+            if (!(pWin->optional->userProps = pProp->next))
+		CheckWindowOptionalNeed (pWin);
+        }
+	else
+        {
+            prevProp->next = pProp->next;
+        }
+#ifdef LBX
+	if (pProp->tag_id)
+	    TagDeleteTag(pProp->tag_id);
+#endif
+	event.u.u.type = PropertyNotify;
+	event.u.property.window = pWin->drawable.id;
+	event.u.property.state = PropertyDelete;
+        event.u.property.atom = pProp->propertyName;
+	event.u.property.time = currentTime.milliseconds;
+	DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+	xfree(pProp->data);
+#ifdef TSOL
+	xfree(pProp->secPrivate);
+#endif /* TSOL */
+        xfree(pProp);
+    }
+    return(Success);
+}
+
+void
+DeleteAllWindowProperties(WindowPtr pWin)
+{
+    PropertyPtr pProp, pNextProp;
+    xEvent event;
+
+    pProp = wUserProps (pWin);
+    while (pProp)
+    {
+#ifdef LBX
+	if (pProp->tag_id)
+	    TagDeleteTag(pProp->tag_id);
+#endif
+	event.u.u.type = PropertyNotify;
+	event.u.property.window = pWin->drawable.id;
+	event.u.property.state = PropertyDelete;
+	event.u.property.atom = pProp->propertyName;
+	event.u.property.time = currentTime.milliseconds;
+	DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+	pNextProp = pProp->next;
+        xfree(pProp->data);
+#ifdef TSOL
+	xfree(pProp->secPrivate);
+#endif /* TSOL */
+        xfree(pProp);
+	pProp = pNextProp;
+    }
+}
+
+static int
+NullPropertyReply(
+    ClientPtr client,
+    ATOM propertyType,
+    int format,
+    xGetPropertyReply *reply)
+{
+    reply->nItems = 0;
+    reply->length = 0;
+    reply->bytesAfter = 0;
+    reply->propertyType = propertyType;
+    reply->format = format;
+    WriteReplyToClient(client, sizeof(xGenericReply), reply);
+    return(client->noClientException);
+}
+
+/*****************
+ * GetProperty
+ *    If type Any is specified, returns the property from the specified
+ *    window regardless of its type.  If a type is specified, returns the
+ *    property only if its type equals the specified type.
+ *    If delete is True and a property is returned, the property is also
+ *    deleted from the window and a PropertyNotify event is generated on the
+ *    window.
+ *****************/
+
+int
+ProcGetProperty(ClientPtr client)
+{
+    PropertyPtr pProp, prevProp;
+    unsigned long n, len, ind;
+    WindowPtr pWin;
+    xGetPropertyReply reply;
+    REQUEST(xGetPropertyReq);
+
+    REQUEST_SIZE_MATCH(xGetPropertyReq);
+    if (stuff->delete)
+	UpdateCurrentTime();
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+
+    if (!ValidAtom(stuff->property))
+    {
+	client->errorValue = stuff->property;
+	return(BadAtom);
+    }
+    if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
+    {
+	client->errorValue = stuff->delete;
+	return(BadValue);
+    }
+    if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
+    {
+	client->errorValue = stuff->type;
+	return(BadAtom);
+    }
+
+    pProp = wUserProps (pWin);
+    prevProp = (PropertyPtr)NULL;
+    while (pProp)
+    {
+	if (pProp->propertyName == stuff->property) 
+	    break;
+	prevProp = pProp;
+	pProp = pProp->next;
+    }
+
+    reply.type = X_Reply;
+    reply.sequenceNumber = client->sequence;
+    if (!pProp) 
+	return NullPropertyReply(client, None, 0, &reply);
+
+#ifdef XCSECURITY
+    {
+	char action;
+	Mask access_mode = SecurityReadAccess;
+
+	if (stuff->delete)
+	    access_mode |= SecurityDestroyAccess;
+#ifdef TSOL
+         if (pSecHook)
+             action = (*pSecHook->CheckPropertyAccess)(client, pWin, stuff->property,
+                        access_mode);
+	  else
+#endif
+
+	action = (SecurityCheckPropertyAccess(client, pWin, stuff->property,
+					   access_mode));
+	switch (action)
+	{
+	    case SecurityErrorOperation:
+		client->errorValue = stuff->property;
+		return BadAtom;;
+	    case SecurityIgnoreOperation:
+		return NullPropertyReply(client, pProp->type, pProp->format,
+					 &reply);
+	}
+    }
+#endif
+    /* If the request type and actual type don't match. Return the
+    property information, but not the data. */
+
+    if (((stuff->type != pProp->type) &&
+	 (stuff->type != AnyPropertyType))
+       )
+    {
+	reply.bytesAfter = pProp->size;
+	reply.format = pProp->format;
+	reply.length = 0;
+	reply.nItems = 0;
+	reply.propertyType = pProp->type;
+	WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+	return(Success);
+    }
+#ifdef LBX
+    /* make sure we have the current value */                       
+    if (pProp->tag_id && pProp->owner_pid) {
+	LbxStallPropRequest(client, pProp);
+	return client->noClientException;
+    }                                              
+#endif
+
+/*
+ *  Return type, format, value to client
+ */
+    n = (pProp->format/8) * pProp->size; /* size (bytes) of prop */
+    ind = stuff->longOffset << 2;        
+
+   /* If longOffset is invalid such that it causes "len" to
+	    be negative, it's a value error. */
+
+    if (n < ind)
+    {
+	client->errorValue = stuff->longOffset;
+	return BadValue;
+    }
+
+    len = min(n - ind, 4 * stuff->longLength);
+
+    reply.bytesAfter = n - (ind + len);
+    reply.format = pProp->format;
+    reply.length = (len + 3) >> 2;
+    reply.nItems = len / (pProp->format / 8 );
+    reply.propertyType = pProp->type;
+
+    if (stuff->delete && (reply.bytesAfter == 0))
+    { /* send the event */
+	xEvent event;
+
+	event.u.u.type = PropertyNotify;
+	event.u.property.window = pWin->drawable.id;
+	event.u.property.state = PropertyDelete;
+	event.u.property.atom = pProp->propertyName;
+	event.u.property.time = currentTime.milliseconds;
+	DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+    }
+
+    WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+    if (len)
+    {
+	switch (reply.format) {
+	case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break;
+	case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break;
+	default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
+	}
+	WriteSwappedDataToClient(client, len,
+				 (char *)pProp->data + ind);
+    }
+
+    if (stuff->delete && (reply.bytesAfter == 0))
+    { /* delete the Property */
+#ifdef LBX
+	if (pProp->tag_id)
+	    TagDeleteTag(pProp->tag_id);
+#endif
+	if (prevProp == (PropertyPtr)NULL) /* takes care of head */
+	{
+	    if (!(pWin->optional->userProps = pProp->next))
+		CheckWindowOptionalNeed (pWin);
+	}
+	else
+	    prevProp->next = pProp->next;
+	xfree(pProp->data);
+	xfree(pProp);
+    }
+    return(client->noClientException);
+}
+
+int
+ProcListProperties(ClientPtr client)
+{
+    Atom *pAtoms = NULL, *temppAtoms;
+    xListPropertiesReply xlpr;
+    int	numProps = 0;
+    WindowPtr pWin;
+    PropertyPtr pProp;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+
+    pProp = wUserProps (pWin);
+    while (pProp)
+    {        
+        pProp = pProp->next;
+	numProps++;
+    }
+    if (numProps)
+        if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom))))
+            return(BadAlloc);
+
+    xlpr.type = X_Reply;
+    xlpr.nProperties = numProps;
+    xlpr.length = (numProps * sizeof(Atom)) >> 2;
+    xlpr.sequenceNumber = client->sequence;
+    pProp = wUserProps (pWin);
+    temppAtoms = pAtoms;
+    while (pProp)
+    {
+	*temppAtoms++ = pProp->propertyName;
+	pProp = pProp->next;
+    }
+    WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
+    if (numProps)
+    {
+        client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
+        WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
+        DEALLOCATE_LOCAL(pAtoms);
+    }
+    return(client->noClientException);
+}
+
+int 
+ProcDeleteProperty(register ClientPtr client)
+{
+    WindowPtr pWin;
+    REQUEST(xDeletePropertyReq);
+    int result;
+    char action;
+              
+    REQUEST_SIZE_MATCH(xDeletePropertyReq);
+    UpdateCurrentTime();
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+    if (!ValidAtom(stuff->property))
+    {
+	client->errorValue = stuff->property;
+	return (BadAtom);
+    }
+
+#ifdef XCSECURITY
+#ifdef TSOL
+    if (pSecHook)
+        action = (*pSecHook->CheckPropertyAccess)(client, pWin, stuff->property,
+                SecurityDestroyAccess);
+        else
+#endif
+
+    action = (SecurityCheckPropertyAccess(client, pWin, stuff->property,
+				       SecurityDestroyAccess));
+    switch (action)
+    {
+	case SecurityErrorOperation:
+	    client->errorValue = stuff->property;
+	    return BadAtom;;
+	case SecurityIgnoreOperation:
+	    return Success;
+    }
+#endif
+
+#ifdef TSOL
+    if (pSecHook)
+	result = (*pSecHook->DeleteProperty)(client, pWin, stuff->property);
+    else
+#endif /* TSOL */
+    result = DeleteProperty(pWin, stuff->property);
+    if (client->noClientException != Success)
+	return(client->noClientException);
+    else
+	return(result);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/dix/window.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,3916 @@
+/* $XdotOrg: xc/programs/Xserver/dix/window.c,v 1.12 2005/07/03 08:53:38 daniels Exp $ */
+/* $Xorg: window.c,v 1.4 2001/02/09 02:04:41 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.
+
+*/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+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.
+
+******************************************************************/
+
+/* Copyright 2006 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.
+ */ 
+
+/* $XFree86: xc/programs/Xserver/dix/window.c,v 3.36 2003/11/14 23:52:50 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#include "dixevents.h"
+#include "globals.h"
+
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+/******
+ * Window stuff for server 
+ *
+ *    CreateRootWindow, CreateWindow, ChangeWindowAttributes,
+ *    GetWindowAttributes, DeleteWindow, DestroySubWindows,
+ *    HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows,
+ *    UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow,
+ *
+ ******/
+
+static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11};
+static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88};
+
+int screenIsSaved = SCREEN_SAVER_OFF;
+
+ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
+
+#if 0
+extern void DeleteWindowFromAnyEvents();
+extern Mask EventMaskForClient();
+extern void WindowHasNewCursor();
+extern void RecalculateDeliverableEvents();
+#endif
+
+static Bool TileScreenSaver(int i, int kind);
+
+
+#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
+			      CWDontPropagate | CWOverrideRedirect | CWCursor )
+
+#define BOXES_OVERLAP(b1, b2) \
+      (!( ((b1)->x2 <= (b2)->x1)  || \
+	( ((b1)->x1 >= (b2)->x2)) || \
+	( ((b1)->y2 <= (b2)->y1)) || \
+	( ((b1)->y1 >= (b2)->y2)) ) )
+
+#define RedirectSend(pWin) \
+    ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureRedirectMask)
+
+#define SubSend(pWin) \
+    ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask)
+
+#define StrSend(pWin) \
+    ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask)
+
+#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
+
+
+int numSaveUndersViewable = 0;
+int deltaSaveUndersViewable = 0;
+
+#ifdef TSOL
+#include "extnsionst.h"
+extern SecurityHookPtr pSecHook;
+#endif /* TSOL */
+
+#ifdef DEBUG
+/******
+ * PrintWindowTree
+ *    For debugging only
+ ******/
+
+int
+PrintChildren(WindowPtr p1, int indent)
+{
+    WindowPtr p2;
+    int i;
+
+    while (p1)
+    {
+	p2 = p1->firstChild;
+	for (i=0; i<indent; i++) ErrorF( " ");
+	ErrorF( "%x\n", p1->drawable.id);
+	miPrintRegion(&p1->clipList);
+	PrintChildren(p2, indent+4);
+	p1 = p1->nextSib;
+    }
+}
+
+PrintWindowTree()
+{
+    int i;
+    WindowPtr pWin, p1;
+
+    for (i=0; i<screenInfo.numScreens; i++)
+    {
+	ErrorF( "WINDOW %d\n", i);
+	pWin = WindowTable[i];
+	miPrintRegion(&pWin->clipList);
+	p1 = pWin->firstChild;
+	PrintChildren(p1, 4);
+    }
+}
+#endif
+
+int
+TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, pointer data)
+{
+    register int result;
+    register WindowPtr pChild;
+
+    if (!(pChild = pWin))
+       return(WT_NOMATCH);
+    while (1)
+    {
+	result = (* func)(pChild, data);
+	if (result == WT_STOPWALKING)
+	    return(WT_STOPWALKING);
+	if ((result == WT_WALKCHILDREN) && pChild->firstChild)
+	{
+	    pChild = pChild->firstChild;
+	    continue;
+	}
+	while (!pChild->nextSib && (pChild != pWin))
+	    pChild = pChild->parent;
+	if (pChild == pWin)
+	    break;
+	pChild = pChild->nextSib;
+    }
+    return(WT_NOMATCH);
+}
+
+/*****
+ * WalkTree
+ *   Walk the window tree, for SCREEN, preforming FUNC(pWin, data) on
+ *   each window.  If FUNC returns WT_WALKCHILDREN, traverse the children,
+ *   if it returns WT_DONTWALKCHILDREN, dont.  If it returns WT_STOPWALKING
+ *   exit WalkTree.  Does depth-first traverse.
+ *****/
+
+int
+WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data)
+{
+    return(TraverseTree(WindowTable[pScreen->myNum], func, data));
+}
+
+/* hack for forcing backing store on all windows */
+int	defaultBackingStore = NotUseful;
+/* hack to force no backing store */
+Bool	disableBackingStore = FALSE;
+Bool	enableBackingStore = FALSE;
+/* hack to force no save unders */
+Bool	disableSaveUnders = FALSE;
+
+static void
+SetWindowToDefaults(register WindowPtr pWin)
+{
+    pWin->prevSib = NullWindow;
+    pWin->firstChild = NullWindow;
+    pWin->lastChild = NullWindow;
+
+    pWin->valdata = (ValidatePtr)NULL;
+    pWin->optional = (WindowOptPtr)NULL;
+    pWin->cursorIsNone = TRUE;
+
+    pWin->backingStore = NotUseful;
+    pWin->DIXsaveUnder = FALSE;
+    pWin->backStorage = (pointer) NULL;
+
+    pWin->mapped = FALSE;	    /* off */
+    pWin->realized = FALSE;	/* off */
+    pWin->viewable = FALSE;
+    pWin->visibility = VisibilityNotViewable;
+    pWin->overrideRedirect = FALSE;
+    pWin->saveUnder = FALSE;
+
+    pWin->bitGravity = ForgetGravity;
+    pWin->winGravity = NorthWestGravity;
+
+    pWin->eventMask = 0;
+    pWin->deliverableEvents = 0;
+    pWin->dontPropagate = 0;
+    pWin->forcedBS = FALSE;
+#ifdef NEED_DBE_BUF_BITS
+    pWin->srcBuffer = DBE_FRONT_BUFFER;
+    pWin->dstBuffer = DBE_FRONT_BUFFER;
+#endif
+#ifdef COMPOSITE
+    pWin->redirectDraw = 0;
+#endif
+}
+
+static void
+MakeRootTile(WindowPtr pWin)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    GCPtr pGC;
+    unsigned char back[128];
+    int len = BitmapBytePad(sizeof(long));
+    register unsigned char *from, *to;
+    register int i, j;
+
+    pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4,
+						    pScreen->rootDepth);
+
+    pWin->backgroundState = BackgroundPixmap;
+    pGC = GetScratchGC(pScreen->rootDepth, pScreen);
+    if (!pWin->background.pixmap || !pGC)
+	FatalError("could not create root tile");
+
+    {
+	CARD32 attributes[2];
+
+	attributes[0] = pScreen->whitePixel;
+	attributes[1] = pScreen->blackPixel;
+
+	(void)ChangeGC(pGC, GCForeground | GCBackground, attributes);
+    }
+
+   ValidateGC((DrawablePtr)pWin->background.pixmap, pGC);
+
+   from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb;
+   to = back;
+
+   for (i = 4; i > 0; i--, from++)
+	for (j = len; j > 0; j--)
+	    *to++ = *from;
+
+   if (blackRoot)
+       bzero(back, sizeof(back));
+
+   (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1,
+		    0, 0, len, 4, 0, XYBitmap, (char *)back);
+
+   FreeScratchGC(pGC);
+
+}
+
+WindowPtr
+AllocateWindow(ScreenPtr pScreen)
+{
+    WindowPtr pWin;
+    register char *ptr;
+    register DevUnion *ppriv;
+    register unsigned *sizes;
+    register unsigned size;
+    register int i;
+
+    pWin = (WindowPtr)xalloc(pScreen->totalWindowSize);
+    if (pWin)
+    {
+	ppriv = (DevUnion *)(pWin + 1);
+	pWin->devPrivates = ppriv;
+	sizes = pScreen->WindowPrivateSizes;
+	ptr = (char *)(ppriv + pScreen->WindowPrivateLen);
+	for (i = pScreen->WindowPrivateLen; --i >= 0; ppriv++, sizes++)
+	{
+	    if ( (size = *sizes) )
+	    {
+		ppriv->ptr = (pointer)ptr;
+		ptr += size;
+	    }
+	    else
+		ppriv->ptr = (pointer)NULL;
+	}
+    }
+    return pWin;
+}
+
+/*****
+ * CreateRootWindow
+ *    Makes a window at initialization time for specified screen
+ *****/
+
+Bool
+CreateRootWindow(ScreenPtr pScreen)
+{
+    WindowPtr	pWin;
+    BoxRec	box;
+    PixmapFormatRec *format;
+
+    pWin = AllocateWindow(pScreen);
+    if (!pWin)
+	return FALSE;
+
+    savedScreenInfo[pScreen->myNum].pWindow = NULL;
+    savedScreenInfo[pScreen->myNum].wid = FakeClientID(0);
+    savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+    screenIsSaved = SCREEN_SAVER_OFF;
+
+    WindowTable[pScreen->myNum] = pWin;
+
+    pWin->drawable.pScreen = pScreen;
+    pWin->drawable.type = DRAWABLE_WINDOW;
+
+    pWin->drawable.depth = pScreen->rootDepth;
+    for (format = screenInfo.formats;
+	 format->depth != pScreen->rootDepth;
+	 format++)
+	;
+    pWin->drawable.bitsPerPixel = format->bitsPerPixel;
+
+    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+    pWin->parent = NullWindow;
+    SetWindowToDefaults(pWin);
+
+    pWin->optional = (WindowOptRec *) xalloc (sizeof (WindowOptRec));
+    if (!pWin->optional)
+        return FALSE;
+
+    pWin->optional->dontPropagateMask = 0;
+    pWin->optional->otherEventMasks = 0;
+    pWin->optional->otherClients = NULL;
+    pWin->optional->passiveGrabs = NULL;
+    pWin->optional->userProps = NULL;
+    pWin->optional->backingBitPlanes = ~0L;
+    pWin->optional->backingPixel = 0;
+#ifdef SHAPE
+    pWin->optional->boundingShape = NULL;
+    pWin->optional->clipShape = NULL;
+    pWin->optional->inputShape = NULL;
+#endif
+#ifdef XINPUT
+    pWin->optional->inputMasks = NULL;
+#endif
+    pWin->optional->colormap = pScreen->defColormap;
+    pWin->optional->visual = pScreen->rootVisual;
+
+    pWin->nextSib = NullWindow;
+
+    pWin->drawable.id = FakeClientID(0);
+
+    pWin->origin.x = pWin->origin.y = 0;
+    pWin->drawable.height = pScreen->height;
+    pWin->drawable.width = pScreen->width;
+    pWin->drawable.x = pWin->drawable.y = 0;
+
+    box.x1 = 0;
+    box.y1 = 0;
+    box.x2 = pScreen->width;
+    box.y2 = pScreen->height;
+    REGION_INIT(pScreen, &pWin->clipList, &box, 1);
+    REGION_INIT(pScreen, &pWin->winSize, &box, 1);
+    REGION_INIT(pScreen, &pWin->borderSize, &box, 1);
+    REGION_INIT(pScreen, &pWin->borderClip, &box, 1);
+
+    pWin->drawable.class = InputOutput;
+    pWin->optional->visual = pScreen->rootVisual;
+
+    pWin->backgroundState = BackgroundPixel;
+    pWin->background.pixel = pScreen->whitePixel;
+
+    pWin->borderIsPixel = TRUE;
+    pWin->border.pixel = pScreen->blackPixel;
+    pWin->borderWidth = 0;
+
+    if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
+	return FALSE;
+
+    if (disableBackingStore)
+	pScreen->backingStoreSupport = NotUseful;
+    if (enableBackingStore)
+	pScreen->backingStoreSupport = Always;
+
+#ifdef DO_SAVE_UNDERS
+    if ((pScreen->backingStoreSupport != NotUseful) &&
+	(pScreen->saveUnderSupport == NotUseful))
+    {
+	/*
+	 * If the screen has backing-store but no save-unders, let the
+	 * clients know we can support save-unders using backing-store.
+	 */
+	pScreen->saveUnderSupport = USE_DIX_SAVE_UNDERS;
+    }
+#endif /* DO_SAVE_UNDERS */
+		
+    if (disableSaveUnders)
+	pScreen->saveUnderSupport = NotUseful;
+
+    return TRUE;
+}
+
+void
+InitRootWindow(WindowPtr pWin)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    if (!(*pScreen->CreateWindow)(pWin))
+	return; /* XXX */
+    (*pScreen->PositionWindow)(pWin, 0, 0);
+
+    pWin->cursorIsNone = FALSE;
+    pWin->optional->cursor = rootCursor;
+    rootCursor->refcnt++;
+    MakeRootTile(pWin);
+    pWin->backingStore = defaultBackingStore;
+    pWin->forcedBS = (defaultBackingStore != NotUseful);
+    /* We SHOULD check for an error value here XXX */
+    (*pScreen->ChangeWindowAttributes)(pWin,
+		       CWBackPixmap|CWBorderPixel|CWCursor|CWBackingStore);
+
+#ifdef TSOL
+    if (pSecHook)
+	(*pSecHook->InitWindow)(serverClient, pWin);
+#endif /* TSOL */
+
+    MapWindow(pWin, serverClient);
+}
+
+/* Set the region to the intersection of the rectangle and the
+ * window's winSize.  The window is typically the parent of the
+ * window from which the region came.
+ */
+
+void
+ClippedRegionFromBox(register WindowPtr pWin, RegionPtr Rgn,
+                     register int x, register int y,
+                     register int w, register int h)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    BoxRec box;
+
+    box = *(REGION_EXTENTS(pScreen, &pWin->winSize));
+    /* we do these calculations to avoid overflows */
+    if (x > box.x1)
+	box.x1 = x;
+    if (y > box.y1)
+	box.y1 = y;
+    x += w;
+    if (x < box.x2)
+	box.x2 = x;
+    y += h;
+    if (y < box.y2)
+	box.y2 = y;
+    if (box.x1 > box.x2)
+	box.x2 = box.x1;
+    if (box.y1 > box.y2)
+	box.y2 = box.y1;
+    REGION_RESET(pScreen, Rgn, &box);
+    REGION_INTERSECT(pScreen, Rgn, Rgn, &pWin->winSize);
+}
+
+WindowPtr
+RealChildHead(register WindowPtr pWin)
+{
+    if (!pWin->parent &&
+	(screenIsSaved == SCREEN_SAVER_ON) &&
+	(HasSaverWindow (pWin->drawable.pScreen->myNum)))
+	return (pWin->firstChild);
+    else
+	return (NullWindow);
+}
+
+/*****
+ * CreateWindow
+ *    Makes a window in response to client request 
+ *****/
+
+WindowPtr
+CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w,
+             unsigned h, unsigned bw, unsigned class, register Mask vmask, XID *vlist,
+             int depth, ClientPtr client, VisualID visual, int *error)
+{
+    register WindowPtr pWin;
+    WindowPtr pHead;
+    register ScreenPtr pScreen;
+    xEvent event;
+    int idepth, ivisual;
+    Bool fOK;
+    DepthPtr pDepth;
+    PixmapFormatRec *format;
+    register WindowOptPtr ancwopt;
+
+    if (class == CopyFromParent)
+	class = pParent->drawable.class;
+
+    if ((class != InputOutput) && (class != InputOnly))
+    {
+	*error = BadValue;
+	client->errorValue = class;
+	return NullWindow;
+    }
+
+    if ((class != InputOnly) && (pParent->drawable.class == InputOnly))
+    {
+	*error = BadMatch;
+	return NullWindow;
+    }
+
+    if ((class == InputOnly) && ((bw != 0) || (depth != 0)))
+    {
+	*error = BadMatch;
+	return NullWindow;
+    }
+
+    pScreen = pParent->drawable.pScreen;
+    if ((class == InputOutput) && (depth == 0))
+	 depth = pParent->drawable.depth;
+    ancwopt = pParent->optional;
+    if (!ancwopt)
+	ancwopt = FindWindowWithOptional(pParent)->optional;
+    if (visual == CopyFromParent) {
+#ifdef XAPPGROUP
+	VisualID ag_visual;
+
+	if (client->appgroup && !pParent->parent &&
+	    (ag_visual = XagRootVisual (client)))
+	    visual = ag_visual;
+	else
+#endif
+	visual = ancwopt->visual;
+    }
+
+    /* Find out if the depth and visual are acceptable for this Screen */
+    if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth))
+    {
+	fOK = FALSE;
+	for(idepth = 0; idepth < pScreen->numDepths; idepth++)
+	{
+	    pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
+	    if ((depth == pDepth->depth) || (depth == 0))
+	    {
+		for (ivisual = 0; ivisual < pDepth->numVids; ivisual++)
+		{
+		    if (visual == pDepth->vids[ivisual])
+		    {
+			fOK = TRUE;
+			break;
+		    }
+		}
+	    }
+	}
+	if (fOK == FALSE)
+	{
+	    *error = BadMatch;
+	    return NullWindow;
+	}
+    }
+
+    if (((vmask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
+	(class != InputOnly) &&
+	(depth != pParent->drawable.depth))
+    {
+	*error = BadMatch;
+	return NullWindow;
+    }
+
+    if (((vmask & CWColormap) == 0) &&
+	(class != InputOnly) &&
+	((visual != ancwopt->visual) || (ancwopt->colormap == None)))
+    {
+	*error = BadMatch;
+	return NullWindow;
+    }
+
+    pWin = AllocateWindow(pScreen);
+    if (!pWin)
+    {
+	*error = BadAlloc;
+	return NullWindow;
+    }
+    pWin->drawable = pParent->drawable;
+    pWin->drawable.depth = depth;
+    if (depth == pParent->drawable.depth)
+	pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
+    else
+    {
+	for (format = screenInfo.formats; format->depth != depth; format++)
+	    ;
+	pWin->drawable.bitsPerPixel = format->bitsPerPixel;
+    }
+    if (class == InputOnly)
+	pWin->drawable.type = (short) UNDRAWABLE_WINDOW;
+    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+    pWin->drawable.id = wid;
+    pWin->drawable.class = class;
+
+    pWin->parent = pParent;
+    SetWindowToDefaults(pWin);
+
+    if (visual != ancwopt->visual)
+    {
+	if (!MakeWindowOptional (pWin))
+	{
+	    xfree (pWin);
+	    *error = BadAlloc;
+	    return NullWindow;
+	}
+	pWin->optional->visual = visual;
+	pWin->optional->colormap = None;
+    }
+
+    pWin->borderWidth = bw;
+#ifdef XCSECURITY
+    /*  can't let untrusted clients have background None windows;
+     *  they make it too easy to steal window contents
+     */
+    if (client->trustLevel != XSecurityClientTrusted)
+    {
+	pWin->backgroundState = BackgroundPixel;
+	pWin->background.pixel = 0;
+    }
+    else
+#endif
+    pWin->backgroundState = None;
+
+    pWin->borderIsPixel = pParent->borderIsPixel;
+    pWin->border = pParent->border;
+    if (pWin->borderIsPixel == FALSE)
+	pWin->border.pixmap->refcnt++;
+		
+    pWin->origin.x = x + (int)bw;
+    pWin->origin.y = y + (int)bw;
+    pWin->drawable.width = w;
+    pWin->drawable.height = h;
+    pWin->drawable.x = pParent->drawable.x + x + (int)bw;
+    pWin->drawable.y = pParent->drawable.y + y + (int)bw;
+
+	/* set up clip list correctly for unobscured WindowPtr */
+    REGION_NULL(pScreen, &pWin->clipList);
+    REGION_NULL(pScreen, &pWin->borderClip);
+    REGION_NULL(pScreen, &pWin->winSize);
+    REGION_NULL(pScreen, &pWin->borderSize);
+
+#ifdef TSOL
+    if (pSecHook)
+	(*pSecHook->InitWindow)(client, pWin);
+#endif /* TSOL */
+
+    pHead = RealChildHead(pParent);
+    if (pHead)
+    {
+	pWin->nextSib = pHead->nextSib;
+	if (pHead->nextSib)
+	    pHead->nextSib->prevSib = pWin;
+	else
+	    pParent->lastChild = pWin;
+	pHead->nextSib = pWin;
+	pWin->prevSib = pHead;
+    }
+    else
+    {
+	pWin->nextSib = pParent->firstChild;
+	if (pParent->firstChild)
+	    pParent->firstChild->prevSib = pWin;
+	else
+	    pParent->lastChild = pWin;
+	pParent->firstChild = pWin;
+    }
+
+    SetWinSize (pWin);
+    SetBorderSize (pWin);
+
+    /* We SHOULD check for an error value here XXX */
+    if (!(*pScreen->CreateWindow)(pWin))
+    {
+	*error = BadAlloc;
+	DeleteWindow(pWin, None);
+	return NullWindow;
+    }
+    /* We SHOULD check for an error value here XXX */
+    (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y);
+
+    if (!(vmask & CWEventMask))
+	RecalculateDeliverableEvents(pWin);
+
+    if (vmask)
+	*error = ChangeWindowAttributes(pWin, vmask, vlist, wClient (pWin));
+    else
+	*error = Success;
+
+    if (*error != Success)
+    {
+	DeleteWindow(pWin, None);
+	return NullWindow;
+    }
+    if (!(vmask & CWBackingStore) && (defaultBackingStore != NotUseful))
+    {
+	XID value = defaultBackingStore;
+	(void)ChangeWindowAttributes(pWin, CWBackingStore, &value, wClient (pWin));
+	pWin->forcedBS = TRUE;
+    }
+
+    if (SubSend(pParent))
+    {
+	event.u.u.type = CreateNotify;
+	event.u.createNotify.window = wid;
+	event.u.createNotify.parent = pParent->drawable.id;
+	event.u.createNotify.x = x;
+	event.u.createNotify.y = y;
+	event.u.createNotify.width = w;
+	event.u.createNotify.height = h;
+	event.u.createNotify.borderWidth = bw;
+	event.u.createNotify.override = pWin->overrideRedirect;
+	DeliverEvents(pParent, &event, 1, NullWindow);		
+    }
+    return pWin;
+}
+
+static void
+FreeWindowResources(register WindowPtr pWin)
+{
+    register ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    DeleteWindowFromAnySaveSet(pWin);
+#ifdef TSOL
+    if (pSecHook)
+	(*pSecHook->DeleteWindowFromAnySelections)(pWin);
+    else
+        DeleteWindowFromAnySelections(pWin);
+#else
+    DeleteWindowFromAnySelections(pWin);
+#endif /* TSOL */
+
+    DeleteWindowFromAnyEvents(pWin, TRUE);
+    REGION_UNINIT(pScreen, &pWin->clipList);
+    REGION_UNINIT(pScreen, &pWin->winSize);
+    REGION_UNINIT(pScreen, &pWin->borderClip);
+    REGION_UNINIT(pScreen, &pWin->borderSize);
+#ifdef SHAPE
+    if (wBoundingShape (pWin))
+	REGION_DESTROY(pScreen, wBoundingShape (pWin));
+    if (wClipShape (pWin))
+	REGION_DESTROY(pScreen, wClipShape (pWin));
+    if (wInputShape (pWin))
+	REGION_DESTROY(pScreen, wInputShape (pWin));
+#endif
+    if (pWin->borderIsPixel == FALSE)
+	(*pScreen->DestroyPixmap)(pWin->border.pixmap);
+    if (pWin->backgroundState == BackgroundPixmap)
+	(*pScreen->DestroyPixmap)(pWin->background.pixmap);
+
+    DeleteAllWindowProperties(pWin);
+    /* We SHOULD check for an error value here XXX */
+    (*pScreen->DestroyWindow)(pWin);
+    DisposeWindowOptional (pWin);
+}
+
+static void
+CrushTree(WindowPtr pWin)
+{
+    register WindowPtr pChild, pSib, pParent;
+    UnrealizeWindowProcPtr UnrealizeWindow;
+    xEvent event;
+
+    if (!(pChild = pWin->firstChild))
+	return;
+    UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow;
+    while (1)
+    {
+	if (pChild->firstChild)
+	{
+	    pChild = pChild->firstChild;
+	    continue;
+	}
+	while (1)
+	{
+	    pParent = pChild->parent;
+	    if (SubStrSend(pChild, pParent))
+	    {
+		event.u.u.type = DestroyNotify;
+		event.u.destroyNotify.window = pChild->drawable.id;
+		DeliverEvents(pChild, &event, 1, NullWindow);		
+	    }
+	    FreeResource(pChild->drawable.id, RT_WINDOW);
+	    pSib = pChild->nextSib;
+#ifdef DO_SAVE_UNDERS
+	    if (pChild->saveUnder && pChild->viewable)
+		deltaSaveUndersViewable--;
+#endif
+	    pChild->viewable = FALSE;
+	    if (pChild->realized)
+	    {
+		pChild->realized = FALSE;
+		(*UnrealizeWindow)(pChild);
+	    }
+	    FreeWindowResources(pChild);
+	    xfree(pChild);
+	    if ( (pChild = pSib) )
+		break;
+	    pChild = pParent;
+	    pChild->firstChild = NullWindow;
+	    pChild->lastChild = NullWindow;
+	    if (pChild == pWin)
+		return;
+	}
+    }
+}
+	
+/*****
+ *  DeleteWindow
+ *	 Deletes child of window then window itself
+ *	 If wid is None, don't send any events
+ *****/
+
+int
+DeleteWindow(pointer value, XID wid)
+ {
+    register WindowPtr pParent;
+    register WindowPtr pWin = (WindowPtr)value;
+    xEvent event;
+
+    UnmapWindow(pWin, FALSE);
+
+    CrushTree(pWin);
+
+    pParent = pWin->parent;
+    if (wid && pParent && SubStrSend(pWin, pParent))
+    {
+	event.u.u.type = DestroyNotify;
+	event.u.destroyNotify.window = pWin->drawable.id;
+	DeliverEvents(pWin, &event, 1, NullWindow);		
+    }
+
+    FreeWindowResources(pWin);
+    if (pParent)
+    {
+	if (pParent->firstChild == pWin)
+	    pParent->firstChild = pWin->nextSib;
+	if (pParent->lastChild == pWin)
+	    pParent->lastChild = pWin->prevSib;
+	if (pWin->nextSib)
+	    pWin->nextSib->prevSib = pWin->prevSib;
+	if (pWin->prevSib)
+	    pWin->prevSib->nextSib = pWin->nextSib;
+    }
+    xfree(pWin);
+    return Success;
+}
+
+void
+DestroySubwindows(register WindowPtr pWin, ClientPtr client)
+{
+    /* XXX
+     * The protocol is quite clear that each window should be
+     * destroyed in turn, however, unmapping all of the first
+     * eliminates most of the calls to ValidateTree.  So,
+     * this implementation is incorrect in that all of the
+     * UnmapNotifies occur before all of the DestroyNotifies.
+     * If you care, simply delete the call to UnmapSubwindows.
+     */
+    UnmapSubwindows(pWin);
+    while (pWin->lastChild)
+	FreeResource(pWin->lastChild->drawable.id, RT_NONE);
+}
+
+#define DeviceEventMasks (KeyPressMask | KeyReleaseMask | ButtonPressMask | \
+    ButtonReleaseMask | PointerMotionMask)
+
+/*****
+ *  ChangeWindowAttributes
+ *   
+ *  The value-mask specifies which attributes are to be changed; the
+ *  value-list contains one value for each one bit in the mask, from least
+ *  to most significant bit in the mask.  
+ *****/
+ 
+int
+ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
+{
+    register Mask index2;
+    register XID *pVlist;
+    PixmapPtr pPixmap;
+    Pixmap pixID;
+    CursorPtr pCursor, pOldCursor;
+    Cursor cursorID;
+    WindowPtr pChild;
+    Colormap cmap;
+    ColormapPtr	pCmap;
+    xEvent xE;
+    int result;
+    register ScreenPtr pScreen;
+    Mask vmaskCopy = 0;
+    register Mask tmask;
+    unsigned int val;
+    int error;
+    Bool checkOptional = FALSE;
+    Bool borderRelative = FALSE;
+    WindowPtr pLayerWin;
+
+    if ((pWin->drawable.class == InputOnly) && (vmask & (~INPUTONLY_LEGAL_MASK)))
+	return BadMatch;
+
+    error = Success;
+    pScreen = pWin->drawable.pScreen;
+    pVlist = vlist;
+    tmask = vmask;
+    while (tmask)
+    {
+	index2 = (Mask) lowbit (tmask);
+	tmask &= ~index2;
+	switch (index2)
+	{
+	  case CWBackPixmap:
+	    pixID = (Pixmap )*pVlist;
+	    pVlist++;
+	    if (pWin->backgroundState == ParentRelative)
+		borderRelative = TRUE;
+	    if (pixID == None)
+	    {
+#ifdef XCSECURITY
+		/*  can't let untrusted clients have background None windows */
+		if (client->trustLevel == XSecurityClientTrusted)
+		{
+#endif
+		if (pWin->backgroundState == BackgroundPixmap)
+		    (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+		if (!pWin->parent)
+		    MakeRootTile(pWin);
+		else
+		    pWin->backgroundState = None;
+#ifdef XCSECURITY
+		}
+		else
+		{ /* didn't change the background to None, so don't tell ddx */
+		    index2 = 0; 
+		}
+#endif
+	    }
+	    else if (pixID == ParentRelative)
+	    {
+		if (pWin->parent &&
+		    pWin->drawable.depth != pWin->parent->drawable.depth)
+		{
+		    error = BadMatch;
+		    goto PatchUp;
+		}
+		if (pWin->backgroundState == BackgroundPixmap)
+		    (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+		if (!pWin->parent)
+		    MakeRootTile(pWin);
+		else
+		    pWin->backgroundState = ParentRelative;
+		borderRelative = TRUE;
+		/* Note that the parent's backgroundTile's refcnt is NOT
+		 * incremented. */
+	    }
+	    else
+	    {	
+		pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
+						RT_PIXMAP, SecurityReadAccess);
+		if (pPixmap != (PixmapPtr) NULL)
+		{
+		    if	((pPixmap->drawable.depth != pWin->drawable.depth) ||
+			 (pPixmap->drawable.pScreen != pScreen))
+		    {
+			error = BadMatch;
+			goto PatchUp;
+		    }
+		    if (pWin->backgroundState == BackgroundPixmap)
+			(*pScreen->DestroyPixmap)(pWin->background.pixmap);
+		    pWin->backgroundState = BackgroundPixmap;
+		    pWin->background.pixmap = pPixmap;
+		    pPixmap->refcnt++;
+		}
+		else
+		{
+		    error = BadPixmap;
+		    client->errorValue = pixID;
+		    goto PatchUp;
+		}
+	    }
+	    break;
+	  case CWBackPixel:
+	    if (pWin->backgroundState == ParentRelative)
+		borderRelative = TRUE;
+	    if (pWin->backgroundState == BackgroundPixmap)
+		(*pScreen->DestroyPixmap)(pWin->background.pixmap);
+	    pWin->backgroundState = BackgroundPixel;
+	    pWin->background.pixel = (CARD32 ) *pVlist;
+		   /* background pixel overrides background pixmap,
+		      so don't let the ddx layer see both bits */
+	    vmaskCopy &= ~CWBackPixmap;
+	    pVlist++;
+	    break;
+	  case CWBorderPixmap:
+	    pixID = (Pixmap ) *pVlist;
+	    pVlist++;
+	    if (pixID == CopyFromParent)
+	    {
+		if (!pWin->parent ||
+		    (pWin->drawable.depth != pWin->parent->drawable.depth))
+		{
+		    error = BadMatch;
+		    goto PatchUp;
+		}
+		if (pWin->borderIsPixel == FALSE)
+		    (*pScreen->DestroyPixmap)(pWin->border.pixmap);
+		pWin->border = pWin->parent->border;
+		if ((pWin->borderIsPixel = pWin->parent->borderIsPixel) == TRUE)
+		{
+		    index2 = CWBorderPixel;
+		}
+		else
+		{
+		    pWin->parent->border.pixmap->refcnt++;
+		}
+	    }
+	    else
+	    {	
+		pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
+					RT_PIXMAP, SecurityReadAccess);
+		if (pPixmap)
+		{
+		    if	((pPixmap->drawable.depth != pWin->drawable.depth) ||
+			 (pPixmap->drawable.pScreen != pScreen))
+		    {
+			error = BadMatch;
+			goto PatchUp;
+		    }
+		    if (pWin->borderIsPixel == FALSE)
+			(*pScreen->DestroyPixmap)(pWin->border.pixmap);
+		    pWin->borderIsPixel = FALSE;
+		    pWin->border.pixmap = pPixmap;
+		    pPixmap->refcnt++;
+		}
+		else
+		{
+		    error = BadPixmap;
+		    client->errorValue = pixID;
+		    goto PatchUp;
+		}
+	    }
+	    break;
+	  case CWBorderPixel:
+	    if (pWin->borderIsPixel == FALSE)
+		(*pScreen->DestroyPixmap)(pWin->border.pixmap);
+	    pWin->borderIsPixel = TRUE;
+	    pWin->border.pixel = (CARD32) *pVlist;
+		    /* border pixel overrides border pixmap,
+		       so don't let the ddx layer see both bits */
+	    vmaskCopy &= ~CWBorderPixmap;
+	    pVlist++;
+	    break;
+	  case CWBitGravity:
+	    val = (CARD8 )*pVlist;
+	    pVlist++;
+	    if (val > StaticGravity)
+	    {
+		error = BadValue;
+		client->errorValue = val;
+		goto PatchUp;
+	    }
+	    pWin->bitGravity = val;
+	    break;
+	  case CWWinGravity:
+	    val = (CARD8 )*pVlist;
+	    pVlist++;
+	    if (val > StaticGravity)
+	    {
+		error = BadValue;
+		client->errorValue = val;
+		goto PatchUp;
+	    }
+	    pWin->winGravity = val;
+	    break;
+	  case CWBackingStore:
+	    val = (CARD8 )*pVlist;
+	    pVlist++;
+	    if ((val != NotUseful) && (val != WhenMapped) && (val != Always))
+	    {
+		error = BadValue;
+		client->errorValue = val;
+		goto PatchUp;
+	    }
+	    pWin->backingStore = val;
+	    pWin->forcedBS = FALSE;
+	    break;
+	  case CWBackingPlanes:
+	    if (pWin->optional || ((CARD32)*pVlist != (CARD32)~0L)) {
+		if (!pWin->optional && !MakeWindowOptional (pWin))
+		{
+		    error = BadAlloc;
+		    goto PatchUp;
+		}
+		pWin->optional->backingBitPlanes = (CARD32) *pVlist;
+		if ((CARD32)*pVlist == (CARD32)~0L)
+		    checkOptional = TRUE;
+	    }
+	    pVlist++;
+	    break;
+	  case CWBackingPixel:
+	    if (pWin->optional || (CARD32) *pVlist) {
+		if (!pWin->optional && !MakeWindowOptional (pWin))
+		{
+		    error = BadAlloc;
+		    goto PatchUp;
+		}
+		pWin->optional->backingPixel = (CARD32) *pVlist;
+		if (!*pVlist)
+		    checkOptional = TRUE;
+	    }
+	    pVlist++;
+	    break;
+	  case CWSaveUnder:
+	    val = (BOOL) *pVlist;
+	    pVlist++;
+	    if ((val != xTrue) && (val != xFalse))
+	    {
+		error = BadValue;
+		client->errorValue = val;
+		goto PatchUp;
+	    }
+#ifdef DO_SAVE_UNDERS
+	    if (pWin->parent && (pWin->saveUnder != val) && (pWin->viewable) &&
+		DO_SAVE_UNDERS(pWin))
+	    {
+		/*
+		 * Re-check all siblings and inferiors for obscurity or
+		 * exposition (hee hee).
+		 */
+		if (pWin->saveUnder)
+		    deltaSaveUndersViewable--;
+		else
+		    deltaSaveUndersViewable++;
+		pWin->saveUnder = val;
+
+		if (pWin->firstChild)
+		{
+                    pLayerWin = (*pScreen->GetLayerWindow)(pWin);
+                   if ((*pScreen->ChangeSaveUnder)(pLayerWin->parent, pWin->nextSib))
+                       (*pScreen->PostChangeSaveUnder)(pLayerWin->parent,
+                                                       pWin->nextSib);
+               }
+               else
+               {
+                   if ((*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib))
+                       (*pScreen->PostChangeSaveUnder)(pWin,
+                                                       pWin->nextSib);
+               }                                   
+	    }
+	    else
+	    {
+		/*  If we're changing the saveUnder attribute of the root 
+		 *  window, all we do is set pWin->saveUnder so that
+		 *  GetWindowAttributes returns the right value.  We don't
+		 *  do the "normal" save-under processing (as above).
+		 *  Hope that doesn't cause any problems.
+		 */
+		pWin->saveUnder = val;
+	    }
+#else
+	    pWin->saveUnder = val;
+#endif /* DO_SAVE_UNDERS */
+	    break;
+	  case CWEventMask:
+	    result = EventSelectForWindow(pWin, client, (Mask )*pVlist);
+	    if (result)
+	    {
+		error = result;
+		goto PatchUp;
+	    }
+	    pVlist++;
+	    break;
+	  case CWDontPropagate:
+	    result = EventSuppressForWindow(pWin, client, (Mask )*pVlist,
+					    &checkOptional);
+	    if (result)
+	    {
+		error = result;
+		goto PatchUp;
+	    }
+	    pVlist++;
+	    break;
+	  case CWOverrideRedirect:
+	    val = (BOOL ) *pVlist;
+	    pVlist++;
+	    if ((val != xTrue) && (val != xFalse))
+	    {
+		error = BadValue;
+		client->errorValue = val;
+		goto PatchUp;
+	    }
+	    pWin->overrideRedirect = val;
+	    break;
+	  case CWColormap:
+	    cmap = (Colormap) *pVlist;
+	    pVlist++;
+	    if (cmap == CopyFromParent)
+	    {
+#ifdef XAPPGROUP
+		Colormap ag_colormap;
+		ClientPtr win_owner;
+
+		/*
+		 * win_owner == client for CreateWindow, other clients
+		 * can ChangeWindowAttributes
+		 */
+		win_owner = clients[CLIENT_ID(pWin->drawable.id)];
+
+		if ( win_owner && win_owner->appgroup &&
+		    !pWin->parent->parent &&
+		    (ag_colormap = XagDefaultColormap (win_owner)))
+		    cmap = ag_colormap;
+		else
+#endif
+		if (pWin->parent &&
+		    (!pWin->optional ||
+		     pWin->optional->visual == wVisual (pWin->parent)))
+		{
+		    cmap = wColormap (pWin->parent);
+		}
+		else
+		    cmap = None;
+	    }
+	    if (cmap == None)
+	    {
+		error = BadMatch;
+		goto PatchUp;
+	    }
+	    pCmap = (ColormapPtr)SecurityLookupIDByType(client, cmap,
+					      RT_COLORMAP, SecurityReadAccess);
+	    if (!pCmap)
+	    {
+		error = BadColor;
+		client->errorValue = cmap;
+		goto PatchUp;
+	    }
+	    if (pCmap->pVisual->vid != wVisual (pWin) ||
+		pCmap->pScreen != pScreen)
+	    {
+		error = BadMatch;
+		goto PatchUp;
+	    }
+	    if (cmap != wColormap (pWin))
+	    {
+		if (!pWin->optional)
+		{
+		    if (!MakeWindowOptional (pWin))
+		    {
+			error = BadAlloc;
+			goto PatchUp;
+		    }
+		}
+		else if (pWin->parent && cmap == wColormap (pWin->parent))
+		    checkOptional = TRUE;
+
+		/*
+		 * propagate the original colormap to any children
+		 * inheriting it
+		 */
+
+		for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
+		{
+		    if (!pChild->optional && !MakeWindowOptional (pChild))
+		    {
+			error = BadAlloc;
+			goto PatchUp;
+		    }
+		}
+
+		pWin->optional->colormap = cmap;
+
+		/*
+		 * check on any children now matching the new colormap
+		 */
+
+		for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
+		{
+		    if (pChild->optional->colormap == cmap)
+			CheckWindowOptionalNeed (pChild);
+		}
+	
+		xE.u.u.type = ColormapNotify;
+		xE.u.colormap.window = pWin->drawable.id;
+		xE.u.colormap.colormap = cmap;
+		xE.u.colormap.new = xTrue;
+		xE.u.colormap.state = IsMapInstalled(cmap, pWin);
+		DeliverEvents(pWin, &xE, 1, NullWindow);
+	    }
+	    break;
+	  case CWCursor:
+	    cursorID = (Cursor ) *pVlist;
+	    pVlist++;
+	    /*
+	     * install the new
+	     */
+	    if ( cursorID == None)
+	    {
+		if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
+		    pCursor = rootCursor;
+		else
+		    pCursor = (CursorPtr) None;
+	    }
+	    else
+	    {
+		pCursor = (CursorPtr)SecurityLookupIDByType(client, cursorID,
+						RT_CURSOR, SecurityReadAccess);
+		if (!pCursor)
+		{
+		    error = BadCursor;
+		    client->errorValue = cursorID;
+		    goto PatchUp;
+		}
+	    }
+
+	    if (pCursor != wCursor (pWin))
+	    {
+		/*
+		 * patch up child windows so they don't lose cursors.
+		 */
+
+		for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
+		{
+		    if (!pChild->optional && !pChild->cursorIsNone &&
+			!MakeWindowOptional (pChild))
+		    {
+			error = BadAlloc;
+			goto PatchUp;
+		    }
+		}
+
+		pOldCursor = 0;
+		if (pCursor == (CursorPtr) None)
+		{
+		    pWin->cursorIsNone = TRUE;
+		    if (pWin->optional)
+		    {
+			pOldCursor = pWin->optional->cursor;
+			pWin->optional->cursor = (CursorPtr) None;
+			checkOptional = TRUE;
+		    }
+		} else {
+		    if (!pWin->optional)
+		    {
+			if (!MakeWindowOptional (pWin))
+			{
+			    error = BadAlloc;
+			    goto PatchUp;
+			}
+		    }
+		    else if (pWin->parent && pCursor == wCursor (pWin->parent))
+			checkOptional = TRUE;
+		    pOldCursor = pWin->optional->cursor;
+		    pWin->optional->cursor = pCursor;
+		    pCursor->refcnt++;
+		    pWin->cursorIsNone = FALSE;
+		    /*
+		     * check on any children now matching the new cursor
+		     */
+
+		    for (pChild=pWin->firstChild; pChild; pChild=pChild->nextSib)
+		    {
+			if (pChild->optional &&
+			    (pChild->optional->cursor == pCursor))
+			    CheckWindowOptionalNeed (pChild);
+		    }
+		}
+
+		if (pWin->realized)
+		    WindowHasNewCursor( pWin);
+
+		/* Can't free cursor until here - old cursor
+		 * is needed in WindowHasNewCursor
+		 */
+		if (pOldCursor)
+		    FreeCursor (pOldCursor, (Cursor)0);
+	    }
+	    break;
+	 default:
+	    error = BadValue;
+	    client->errorValue = vmask;
+	    goto PatchUp;
+      }
+      vmaskCopy |= index2;
+    }
+PatchUp:
+    if (checkOptional)
+	CheckWindowOptionalNeed (pWin);
+
+	/* We SHOULD check for an error value here XXX */
+    (*pScreen->ChangeWindowAttributes)(pWin, vmaskCopy);
+
+    /* 
+	If the border contents have changed, redraw the border. 
+	Note that this has to be done AFTER pScreen->ChangeWindowAttributes
+	for the tile to be rotated, and the correct function selected.
+    */
+    if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative)
+	&& pWin->viewable && HasBorder (pWin))
+    {
+	RegionRec exposed;
+
+	REGION_NULL(pScreen, &exposed);
+	REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize);
+	(*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER);
+	REGION_UNINIT(pScreen, &exposed);
+    }
+    return error;
+}
+
+
+/*****
+ * GetWindowAttributes
+ *    Notice that this is different than ChangeWindowAttributes
+ *****/
+
+void
+GetWindowAttributes(register WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply *wa)
+{
+    wa->type = X_Reply;
+    wa->bitGravity = pWin->bitGravity;
+    wa->winGravity = pWin->winGravity;
+    if (pWin->forcedBS && pWin->backingStore != Always)
+	wa->backingStore = NotUseful;
+    else
+	wa->backingStore = pWin->backingStore;
+    wa->length = (sizeof(xGetWindowAttributesReply) -
+		 sizeof(xGenericReply)) >> 2;
+    wa->sequenceNumber = client->sequence;
+    wa->backingBitPlanes =  wBackingBitPlanes (pWin);
+    wa->backingPixel =  wBackingPixel (pWin);
+    wa->saveUnder = (BOOL)pWin->saveUnder;
+    wa->override = pWin->overrideRedirect;
+    if (!pWin->mapped)
+	wa->mapState = IsUnmapped;
+    else if (pWin->realized)
+	wa->mapState = IsViewable;
+    else
+	wa->mapState = IsUnviewable;
+
+    wa->colormap =  wColormap (pWin);
+    wa->mapInstalled = (wa->colormap == None) ? xFalse
+				: IsMapInstalled(wa->colormap, pWin);
+
+    wa->yourEventMask = EventMaskForClient(pWin, client);
+    wa->allEventMasks = pWin->eventMask | wOtherEventMasks (pWin);
+    wa->doNotPropagateMask = wDontPropagateMask (pWin);
+    wa->class = pWin->drawable.class;
+    wa->visualID = wVisual (pWin);
+}
+
+
+WindowPtr
+MoveWindowInStack(register WindowPtr pWin, register WindowPtr pNextSib)
+{
+    register WindowPtr pParent = pWin->parent;
+    WindowPtr pFirstChange = pWin; /* highest window where list changes */
+
+    if (pWin->nextSib != pNextSib)
+    {
+	WindowPtr pOldNextSib = pWin->nextSib;
+
+	if (!pNextSib)	      /* move to bottom */
+	{
+	    if (pParent->firstChild == pWin)
+		pParent->firstChild = pWin->nextSib;
+	    /* if (pWin->nextSib) */	 /* is always True: pNextSib == NULL
+					  * and pWin->nextSib != pNextSib
+					  * therefore pWin->nextSib != NULL */
+	    pFirstChange = pWin->nextSib;
+	    pWin->nextSib->prevSib = pWin->prevSib;
+	    if (pWin->prevSib)
+		pWin->prevSib->nextSib = pWin->nextSib;
+	    pParent->lastChild->nextSib = pWin;
+	    pWin->prevSib = pParent->lastChild;
+	    pWin->nextSib = NullWindow;
+	    pParent->lastChild = pWin;
+	}
+	else if (pParent->firstChild == pNextSib) /* move to top */
+	{
+	    pFirstChange = pWin;
+	    if (pParent->lastChild == pWin)
+	       pParent->lastChild = pWin->prevSib;
+	    if (pWin->nextSib)
+		pWin->nextSib->prevSib = pWin->prevSib;
+	    if (pWin->prevSib)
+		pWin->prevSib->nextSib = pWin->nextSib;
+	    pWin->nextSib = pParent->firstChild;
+	    pWin->prevSib = (WindowPtr ) NULL;
+	    pNextSib->prevSib = pWin;
+	    pParent->firstChild = pWin;
+	}
+	else			/* move in middle of list */
+	{
+	    WindowPtr pOldNext = pWin->nextSib;
+
+	    pFirstChange = NullWindow;
+	    if (pParent->firstChild == pWin)
+		pFirstChange = pParent->firstChild = pWin->nextSib;
+	    if (pParent->lastChild == pWin) {
+	       pFirstChange = pWin;
+	       pParent->lastChild = pWin->prevSib;
+	    }
+	    if (pWin->nextSib)
+		pWin->nextSib->prevSib = pWin->prevSib;
+	    if (pWin->prevSib)
+		pWin->prevSib->nextSib = pWin->nextSib;
+	    pWin->nextSib = pNextSib;
+	    pWin->prevSib = pNextSib->prevSib;
+	    if (pNextSib->prevSib)
+		pNextSib->prevSib->nextSib = pWin;
+	    pNextSib->prevSib = pWin;
+	    if (!pFirstChange) {		     /* do we know it yet? */
+		pFirstChange = pParent->firstChild;  /* no, search from top */
+		while ((pFirstChange != pWin) && (pFirstChange != pOldNext))
+		     pFirstChange = pFirstChange->nextSib;
+	    }
+	}
+	if(pWin->drawable.pScreen->RestackWindow)
+	    (*pWin->drawable.pScreen->RestackWindow)(pWin, pOldNextSib);
+    }
+
+#ifdef ROOTLESS
+    /*
+     * In rootless mode we can't optimize away window restacks.
+     * There may be non-X windows around, so even if the window
+     * is in the correct position from X's point of view,
+     * the underlying window system may want to reorder it.
+     */
+    else if (pWin->drawable.pScreen->RestackWindow)
+        (*pWin->drawable.pScreen->RestackWindow)(pWin, pWin->nextSib);
+#endif
+
+    return( pFirstChange );
+}
+
+RegionPtr
+CreateUnclippedWinSize (register WindowPtr pWin)
+{
+    RegionPtr	pRgn;
+    BoxRec	box;
+
+    box.x1 = pWin->drawable.x;
+    box.y1 = pWin->drawable.y;
+    box.x2 = pWin->drawable.x + (int) pWin->drawable.width;
+    box.y2 = pWin->drawable.y + (int) pWin->drawable.height;
+    pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
+#ifdef SHAPE
+    if (wBoundingShape (pWin) || wClipShape (pWin)) {
+	ScreenPtr pScreen = pWin->drawable.pScreen;
+
+	REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x,
+			 - pWin->drawable.y);
+	if (wBoundingShape (pWin))
+	    REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
+	if (wClipShape (pWin))
+	    REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin));
+	REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y);
+    }
+#endif
+    return pRgn;
+}
+
+void
+SetWinSize (register WindowPtr pWin)
+{
+#ifdef COMPOSITE
+    if (pWin->redirectDraw)
+    {
+	BoxRec	box;
+
+	box.x1 = pWin->drawable.x;
+	box.y1 = pWin->drawable.y;
+	box.x2 = pWin->drawable.x + pWin->drawable.width;
+	box.y2 = pWin->drawable.y + pWin->drawable.height;
+	REGION_RESET (pScreen, &pWin->winSize, &box);
+    }
+    else
+#endif
+    ClippedRegionFromBox(pWin->parent, &pWin->winSize,
+			 pWin->drawable.x, pWin->drawable.y,
+			 (int)pWin->drawable.width,
+			 (int)pWin->drawable.height);
+#ifdef SHAPE
+    if (wBoundingShape (pWin) || wClipShape (pWin)) {
+	ScreenPtr pScreen = pWin->drawable.pScreen;
+
+	REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x,
+			 - pWin->drawable.y);
+	if (wBoundingShape (pWin))
+	    REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+			     wBoundingShape (pWin));
+	if (wClipShape (pWin))
+	    REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+			     wClipShape (pWin));
+	REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x,
+			 pWin->drawable.y);
+    }
+#endif
+}
+
+void
+SetBorderSize (register WindowPtr pWin)
+{
+    int	bw;
+
+    if (HasBorder (pWin)) {
+	bw = wBorderWidth (pWin);
+#ifdef COMPOSITE
+	if (pWin->redirectDraw)
+	{
+	    BoxRec	box;
+
+	    box.x1 = pWin->drawable.x - bw;
+	    box.y1 = pWin->drawable.y - bw;
+	    box.x2 = pWin->drawable.x + pWin->drawable.width + bw;
+	    box.y2 = pWin->drawable.y + pWin->drawable.height + bw;
+	    REGION_RESET (pScreen, &pWin->borderSize, &box);
+	}
+	else
+#endif
+	ClippedRegionFromBox(pWin->parent, &pWin->borderSize,
+		pWin->drawable.x - bw, pWin->drawable.y - bw,
+		(int)(pWin->drawable.width + (bw<<1)),
+		(int)(pWin->drawable.height + (bw<<1)));
+#ifdef SHAPE
+	if (wBoundingShape (pWin)) {
+	    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+	    REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x,
+			     - pWin->drawable.y);
+	    REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize,
+			     wBoundingShape (pWin));
+	    REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x,
+			     pWin->drawable.y);
+	    REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize,
+			 &pWin->winSize);
+	}
+#endif
+    } else {
+	REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize,
+					       &pWin->winSize);
+    }
+}
+
+/**
+ *
+ *  \param x,y          new window position
+ *  \param oldx,oldy    old window position
+ *  \param destx,desty  position relative to gravity
+ */
+
+void
+GravityTranslate (register int x, register int y, int oldx, int oldy,
+                  int dw, int dh, unsigned gravity,
+                  register int *destx, register int *desty)
+{
+    switch (gravity) {
+    case NorthGravity:
+	*destx = x + dw / 2;
+	*desty = y;
+	break;
+    case NorthEastGravity:
+	*destx = x + dw;
+	*desty = y;
+	break;
+    case WestGravity:
+	*destx = x;
+	*desty = y + dh / 2;
+	break;
+    case CenterGravity:
+	*destx = x + dw / 2;
+	*desty = y + dh / 2;
+	break;
+    case EastGravity:
+	*destx = x + dw;
+	*desty = y + dh / 2;
+	break;
+    case SouthWestGravity:
+	*destx = x;
+	*desty = y + dh;
+	break;
+    case SouthGravity:
+	*destx = x + dw / 2;
+	*desty = y + dh;
+	break;
+    case SouthEastGravity:
+	*destx = x + dw;
+	*desty = y + dh;
+	break;
+    case StaticGravity:
+	*destx = oldx;
+	*desty = oldy;
+	break;
+    default:
+	*destx = x;
+	*desty = y;
+	break;
+    }
+}
+
+/* XXX need to retile border on each window with ParentRelative origin */
+void
+ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh)
+{
+    register ScreenPtr pScreen;
+    register WindowPtr pSib, pChild;
+    Bool resized = (dw || dh);
+
+    pScreen = pWin->drawable.pScreen;
+
+    for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib)
+    {
+	if (resized && (pSib->winGravity > NorthWestGravity))
+	{
+	    int cwsx, cwsy;
+
+	    cwsx = pSib->origin.x;
+	    cwsy = pSib->origin.y;
+	    GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh,
+			pSib->winGravity, &cwsx, &cwsy);
+	    if (cwsx != pSib->origin.x || cwsy != pSib->origin.y)
+	    {
+		xEvent event;
+
+		event.u.u.type = GravityNotify;
+		event.u.gravity.window = pSib->drawable.id;
+		event.u.gravity.x = cwsx - wBorderWidth (pSib);
+		event.u.gravity.y = cwsy - wBorderWidth (pSib);
+		DeliverEvents (pSib, &event, 1, NullWindow);
+		pSib->origin.x = cwsx;
+		pSib->origin.y = cwsy;
+	    }
+	}
+	pSib->drawable.x = pWin->drawable.x + pSib->origin.x;
+	pSib->drawable.y = pWin->drawable.y + pSib->origin.y;
+	SetWinSize (pSib);
+	SetBorderSize (pSib);
+	(*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y);
+
+	if ( (pChild = pSib->firstChild) )
+	{
+	    while (1)
+	    {
+		pChild->drawable.x = pChild->parent->drawable.x +
+				     pChild->origin.x;
+		pChild->drawable.y = pChild->parent->drawable.y +
+				     pChild->origin.y;
+		SetWinSize (pChild);
+		SetBorderSize (pChild);
+		(*pScreen->PositionWindow)(pChild,
+				    pChild->drawable.x, pChild->drawable.y);
+		if (pChild->firstChild)
+		{
+		    pChild = pChild->firstChild;
+		    continue;
+		}
+		while (!pChild->nextSib && (pChild != pSib))
+		    pChild = pChild->parent;
+		if (pChild == pSib)
+		    break;
+		pChild = pChild->nextSib;
+	    }
+	}
+    }
+}
+
+#define GET_INT16(m, f) \
+	if (m & mask) \
+	  { \
+	     f = (INT16) *pVlist;\
+	    pVlist++; \
+	 }
+#define GET_CARD16(m, f) \
+	if (m & mask) \
+	 { \
+	    f = (CARD16) *pVlist;\
+	    pVlist++;\
+	 }
+
+#define GET_CARD8(m, f) \
+	if (m & mask) \
+	 { \
+	    f = (CARD8) *pVlist;\
+	    pVlist++;\
+	 }
+
+#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight))
+
+#define IllegalInputOnlyConfigureMask (CWBorderWidth)
+
+/*
+ * IsSiblingAboveMe
+ *     returns Above if pSib above pMe in stack or Below otherwise 
+ */
+
+static int
+IsSiblingAboveMe(
+    register WindowPtr pMe,
+    register WindowPtr pSib)
+{
+    register WindowPtr pWin;
+
+    pWin = pMe->parent->firstChild;
+    while (pWin)
+    {
+	if (pWin == pSib)
+	    return(Above);
+	else if (pWin == pMe)
+	    return(Below);
+	pWin = pWin->nextSib;
+    }
+    return(Below);
+}
+
+#ifdef TSOL
+BoxPtr
+#else
+static BoxPtr
+#endif /* TSOL */
+WindowExtents(
+    register WindowPtr pWin,
+    register BoxPtr pBox)
+{
+    pBox->x1 = pWin->drawable.x - wBorderWidth (pWin);
+    pBox->y1 = pWin->drawable.y - wBorderWidth (pWin);
+    pBox->x2 = pWin->drawable.x + (int)pWin->drawable.width
+	       + wBorderWidth (pWin);
+    pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height
+	       + wBorderWidth (pWin);
+    return(pBox);
+}
+
+#ifdef SHAPE
+#define IS_SHAPED(pWin)	(wBoundingShape (pWin) != (RegionPtr) NULL)
+
+static RegionPtr
+MakeBoundingRegion (
+    register WindowPtr	pWin,
+    BoxPtr	pBox)
+{
+    RegionPtr	pRgn;
+    ScreenPtr   pScreen = pWin->drawable.pScreen;
+
+    pRgn = REGION_CREATE(pScreen, pBox, 1);
+    if (wBoundingShape (pWin)) {
+	    REGION_TRANSLATE(pScreen, pRgn, -pWin->origin.x,
+						  -pWin->origin.y);
+	    REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
+	    REGION_TRANSLATE(pScreen, pRgn, pWin->origin.x,
+						  pWin->origin.y);
+    }
+    return pRgn;
+}
+
+#ifdef TSOL
+Bool
+#else
+static Bool
+#endif /* TSOL */
+ShapeOverlap (
+    WindowPtr	pWin,
+    BoxPtr	pWinBox,
+    WindowPtr	pSib,
+    BoxPtr	pSibBox)
+{
+    RegionPtr	pWinRgn, pSibRgn;
+    register ScreenPtr	pScreen;
+    Bool	ret;
+
+    if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib))
+	return TRUE;
+    pScreen = pWin->drawable.pScreen;
+    pWinRgn = MakeBoundingRegion (pWin, pWinBox);
+    pSibRgn = MakeBoundingRegion (pSib, pSibBox);
+    REGION_INTERSECT(pScreen, pWinRgn, pWinRgn, pSibRgn);
+    ret = REGION_NOTEMPTY(pScreen, pWinRgn);
+    REGION_DESTROY(pScreen, pWinRgn);
+    REGION_DESTROY(pScreen, pSibRgn);
+    return ret;
+}
+#endif
+
+static Bool
+AnyWindowOverlapsMe(
+    WindowPtr pWin,
+    WindowPtr pHead,
+    register BoxPtr box)
+{
+    register WindowPtr pSib;
+    BoxRec sboxrec;
+    register BoxPtr sbox;
+
+    for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib)
+    {
+	if (pSib->mapped)
+	{
+	    sbox = WindowExtents(pSib, &sboxrec);
+	    if (BOXES_OVERLAP(sbox, box)
+#ifdef SHAPE
+	    && ShapeOverlap (pWin, box, pSib, sbox)
+#endif
+	    )
+		return(TRUE);
+	}
+    }
+    return(FALSE);
+}
+
+static Bool
+IOverlapAnyWindow(
+    WindowPtr pWin,
+    register BoxPtr box)
+{
+    register WindowPtr pSib;
+    BoxRec sboxrec;
+    register BoxPtr sbox;
+
+    for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib)
+    {
+	if (pSib->mapped)
+	{
+	    sbox = WindowExtents(pSib, &sboxrec);
+	    if (BOXES_OVERLAP(sbox, box)
+#ifdef SHAPE
+	    && ShapeOverlap (pWin, box, pSib, sbox)
+#endif
+	    )
+		return(TRUE);
+	}
+    }
+    return(FALSE);
+}
+
+/*
+ *   WhereDoIGoInTheStack() 
+ *	  Given pWin and pSib and the relationshipe smode, return
+ *	  the window that pWin should go ABOVE.
+ *	  If a pSib is specified:
+ *	      Above:  pWin is placed just above pSib
+ *	      Below:  pWin is placed just below pSib
+ *	      TopIf:  if pSib occludes pWin, then pWin is placed
+ *		      at the top of the stack
+ *	      BottomIf:	 if pWin occludes pSib, then pWin is 
+ *			 placed at the bottom of the stack
+ *	      Opposite: if pSib occludes pWin, then pWin is placed at the
+ *			top of the stack, else if pWin occludes pSib, then
+ *			pWin is placed at the bottom of the stack
+ *
+ *	  If pSib is NULL:
+ *	      Above:  pWin is placed at the top of the stack
+ *	      Below:  pWin is placed at the bottom of the stack
+ *	      TopIf:  if any sibling occludes pWin, then pWin is placed at
+ *		      the top of the stack
+ *	      BottomIf: if pWin occludes any sibline, then pWin is placed at
+ *			the bottom of the stack
+ *	      Opposite: if any sibling occludes pWin, then pWin is placed at
+ *			the top of the stack, else if pWin occludes any
+ *			sibling, then pWin is placed at the bottom of the stack
+ *
+ */
+
+static WindowPtr
+WhereDoIGoInTheStack(
+    register WindowPtr pWin,
+    register WindowPtr pSib,
+    short x,
+    short y,
+    unsigned short w,
+    unsigned short h,
+    int smode)
+{
+    BoxRec box;
+    register ScreenPtr pScreen;
+    WindowPtr pHead, pFirst;
+
+    if ((pWin == pWin->parent->firstChild) &&
+	(pWin == pWin->parent->lastChild))
+	return((WindowPtr ) NULL);
+    pHead = RealChildHead(pWin->parent);
+    pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild;
+    pScreen = pWin->drawable.pScreen;
+    box.x1 = x;
+    box.y1 = y;
+    box.x2 = x + (int)w;
+    box.y2 = y + (int)h;
+    switch (smode)
+    {
+      case Above:
+	if (pSib)
+	   return(pSib);
+	else if (pWin == pFirst)
+	    return(pWin->nextSib);
+	else
+	    return(pFirst);
+      case Below:
+	if (pSib)
+	    if (pSib->nextSib != pWin)
+		return(pSib->nextSib);
+	    else
+		return(pWin->nextSib);
+	else
+	    return NullWindow;
+      case TopIf:
+	if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
+	    return(pWin->nextSib);
+	else if (pSib)
+	{
+	    if ((IsSiblingAboveMe(pWin, pSib) == Above) &&
+		(RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
+		return(pFirst);
+	    else
+		return(pWin->nextSib);
+	}
+	else if (AnyWindowOverlapsMe(pWin, pHead, &box))
+	    return(pFirst);
+	else
+	    return(pWin->nextSib);
+      case BottomIf:
+	if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
+	    return(pWin->nextSib);
+	else if (pSib)
+	{
+	    if ((IsSiblingAboveMe(pWin, pSib) == Below) &&
+		(RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
+		return NullWindow;
+	    else
+		return(pWin->nextSib);
+	}
+	else if (IOverlapAnyWindow(pWin, &box))
+	    return NullWindow;
+	else
+	    return(pWin->nextSib);
+      case Opposite:
+	if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
+	    return(pWin->nextSib);
+	else if (pSib)
+	{
+	    if (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)
+	    {
+		if (IsSiblingAboveMe(pWin, pSib) == Above)
+		    return(pFirst);
+		else
+		    return NullWindow;
+	    }
+	    else
+		return(pWin->nextSib);
+	}
+	else if (AnyWindowOverlapsMe(pWin, pHead, &box))
+	{
+	    /* If I'm occluded, I can't possibly be the first child
+	     * if (pWin == pWin->parent->firstChild)
+	     *	  return pWin->nextSib;
+	     */
+	    return(pFirst);
+	}
+	else if (IOverlapAnyWindow(pWin, &box))
+	    return NullWindow;
+	else
+	    return pWin->nextSib;
+      default:
+      {
+	ErrorF("Internal error in ConfigureWindow, smode == %d\n",smode );
+	return pWin->nextSib;
+      }
+    }
+}
+
+#ifdef TSOL
+void
+#else
+static void
+#endif /* TSOL */
+ReflectStackChange(
+    register WindowPtr pWin,
+    register WindowPtr pSib,
+    VTKind  kind)
+{
+/* Note that pSib might be NULL */
+
+    Bool WasViewable = (Bool)pWin->viewable;
+    Bool anyMarked;
+    WindowPtr pFirstChange;
+#ifdef DO_SAVE_UNDERS
+    Bool	dosave = FALSE;
+#endif
+    WindowPtr  pLayerWin;
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    /* if this is a root window, can't be restacked */
+    if (!pWin->parent)
+	return;
+
+    pFirstChange = MoveWindowInStack(pWin, pSib);
+
+    if (WasViewable)
+    {
+	anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
+						      &pLayerWin);
+	if (pLayerWin != pWin) pFirstChange = pLayerWin;
+#ifdef DO_SAVE_UNDERS
+	if (DO_SAVE_UNDERS(pWin))
+	{
+	    dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
+	}
+#endif /* DO_SAVE_UNDERS */
+	if (anyMarked)
+	{
+	    (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind);
+	    (*pScreen->HandleExposures)(pLayerWin->parent);
+	}
+#ifdef DO_SAVE_UNDERS
+	if (dosave)
+	    (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
+#endif /* DO_SAVE_UNDERS */
+	if (anyMarked && pWin->drawable.pScreen->PostValidateTree)
+	    (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind);
+    }
+    if (pWin->realized)
+	WindowsRestructured ();
+}
+
+/*****
+ * ConfigureWindow
+ *****/
+
+int
+ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client)
+{
+#define RESTACK_WIN    0
+#define MOVE_WIN       1
+#define RESIZE_WIN     2
+#define REBORDER_WIN   3
+    register WindowPtr pSib = NullWindow;
+    register WindowPtr pParent = pWin->parent;
+    Window sibwid = 0;
+    Mask index2, tmask;
+    register XID *pVlist;
+    short x,   y, beforeX, beforeY;
+    unsigned short w = pWin->drawable.width,
+		   h = pWin->drawable.height,
+		   bw = pWin->borderWidth;
+    int action, smode = Above;
+#ifdef XAPPGROUP
+    ClientPtr win_owner;
+    ClientPtr ag_leader = NULL;
+#endif
+    xEvent event;
+
+    if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask))
+	return(BadMatch);
+
+    if ((mask & CWSibling) && !(mask & CWStackMode))
+	return(BadMatch);
+
+    pVlist = vlist;
+
+    if (pParent)
+    {
+	x = pWin->drawable.x - pParent->drawable.x - (int)bw;
+	y = pWin->drawable.y - pParent->drawable.y - (int)bw;
+    }
+    else
+    {
+	x = pWin->drawable.x;
+	y = pWin->drawable.y;
+    }
+    beforeX = x;
+    beforeY = y;
+    action = RESTACK_WIN;	
+    if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth))))
+    {
+	GET_INT16(CWX, x);
+	GET_INT16(CWY, y);
+	action = MOVE_WIN;
+    }
+	/* or should be resized */
+    else if (mask & (CWX |  CWY | CWWidth | CWHeight))
+    {
+	GET_INT16(CWX, x);
+	GET_INT16(CWY, y);
+	GET_CARD16(CWWidth, w);
+	GET_CARD16 (CWHeight, h);
+	if (!w || !h)
+	{
+	    client->errorValue = 0;
+	    return BadValue;
+	}
+	action = RESIZE_WIN;
+    }
+    tmask = mask & ~ChangeMask;
+    while (tmask)
+    {
+	index2 = (Mask)lowbit (tmask);
+	tmask &= ~index2;
+	switch (index2)
+	{
+	  case CWBorderWidth:
+	    GET_CARD16(CWBorderWidth, bw);
+	    break;
+	  case CWSibling:
+	    sibwid = (Window ) *pVlist;
+	    pVlist++;
+	    pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid,
+						RT_WINDOW, SecurityReadAccess);
+	    if (!pSib)
+	    {
+		client->errorValue = sibwid;
+		return(BadWindow);
+	    }
+	    if (pSib->parent != pParent)
+		return(BadMatch);
+	    if (pSib == pWin)
+		return(BadMatch);
+	    break;
+	  case CWStackMode:
+	    GET_CARD8(CWStackMode, smode);
+	    if ((smode != TopIf) && (smode != BottomIf) &&
+		(smode != Opposite) && (smode != Above) && (smode != Below))
+	    {
+		client->errorValue = smode;
+		return(BadValue);
+	    }
+	    break;
+	  default:
+	    client->errorValue = mask;
+	    return(BadValue);
+	}
+    }
+	/* root really can't be reconfigured, so just return */
+    if (!pParent)
+	return Success;
+
+	/* Figure out if the window should be moved.  Doesnt
+	   make the changes to the window if event sent */
+
+    if (mask & CWStackMode)
+	pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x,
+				    pParent->drawable.y + y,
+				    w + (bw << 1), h + (bw << 1), smode);
+    else
+	pSib = pWin->nextSib;
+
+#ifdef XAPPGROUP
+    win_owner = clients[CLIENT_ID(pWin->drawable.id)];
+    ag_leader = XagLeader (win_owner);
+#endif
+
+    if ((!pWin->overrideRedirect) && 
+	(RedirectSend(pParent)
+#ifdef XAPPGROUP
+	|| (win_owner->appgroup && ag_leader && 
+	    XagIsControlledRoot (client, pParent))
+#endif
+	))
+    {
+	event.u.u.type = ConfigureRequest;
+	event.u.configureRequest.window = pWin->drawable.id;
+	if (mask & CWSibling)
+	   event.u.configureRequest.sibling = sibwid;
+	else
+	    event.u.configureRequest.sibling = None;
+	if (mask & CWStackMode)
+	   event.u.u.detail = smode;
+	else
+	    event.u.u.detail = Above;
+	event.u.configureRequest.x = x;
+	event.u.configureRequest.y = y;
+#ifdef PANORAMIX
+	if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
+            event.u.configureRequest.x += panoramiXdataPtr[0].x;
+            event.u.configureRequest.y += panoramiXdataPtr[0].y;
+	}
+#endif
+	event.u.configureRequest.width = w;
+	event.u.configureRequest.height = h;
+	event.u.configureRequest.borderWidth = bw;
+	event.u.configureRequest.valueMask = mask;
+#ifdef XAPPGROUP
+	/* make sure if the ag_leader maps the window it goes to the wm */
+	if (ag_leader && ag_leader != client && 
+	    XagIsControlledRoot (client, pParent)) {
+	    event.u.configureRequest.parent = XagId (win_owner);
+	    (void) TryClientEvents (ag_leader, &event, 1,
+				    NoEventMask, NoEventMask, NullGrab);
+	    return Success;
+	}
+#endif
+	event.u.configureRequest.parent = pParent->drawable.id;
+	if (MaybeDeliverEventsToClient(pParent, &event, 1,
+		SubstructureRedirectMask, client) == 1)
+	    return(Success);
+    }
+    if (action == RESIZE_WIN)
+    {
+	Bool size_change = (w != pWin->drawable.width)
+			|| (h != pWin->drawable.height);
+	if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask))
+	{
+	    xEvent eventT;
+	    eventT.u.u.type = ResizeRequest;
+	    eventT.u.resizeRequest.window = pWin->drawable.id;
+	    eventT.u.resizeRequest.width = w;
+	    eventT.u.resizeRequest.height = h;
+	    if (MaybeDeliverEventsToClient(pWin, &eventT, 1,
+				       ResizeRedirectMask, client) == 1)
+	    {
+		/* if event is delivered, leave the actual size alone. */
+		w = pWin->drawable.width;
+		h = pWin->drawable.height;
+		size_change = FALSE;
+	    }
+	}
+	if (!size_change)
+	{
+	    if (mask & (CWX | CWY))
+		action = MOVE_WIN;
+	    else if (mask & (CWStackMode | CWBorderWidth))
+		action = RESTACK_WIN;
+	    else   /* really nothing to do */
+		return(Success) ;
+	}
+    }
+
+    if (action == RESIZE_WIN)
+	    /* we've already checked whether there's really a size change */
+	    goto ActuallyDoSomething;
+    if ((mask & CWX) && (x != beforeX))
+	    goto ActuallyDoSomething;
+    if ((mask & CWY) && (y != beforeY))
+	    goto ActuallyDoSomething;
+    if ((mask & CWBorderWidth) && (bw != wBorderWidth (pWin)))
+	    goto ActuallyDoSomething;
+    if (mask & CWStackMode)
+    {
+#ifndef ROOTLESS
+        /* See above for why we always reorder in rootless mode. */
+	if (pWin->nextSib != pSib)
+#endif
+	    goto ActuallyDoSomething;
+    }
+    return(Success);
+
+ActuallyDoSomething:
+    if (SubStrSend(pWin, pParent))
+    {
+	event.u.u.type = ConfigureNotify;
+	event.u.configureNotify.window = pWin->drawable.id;
+	if (pSib)
+	    event.u.configureNotify.aboveSibling = pSib->drawable.id;
+	else
+	    event.u.configureNotify.aboveSibling = None;
+	event.u.configureNotify.x = x;
+	event.u.configureNotify.y = y;
+#ifdef PANORAMIX
+	if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
+	    event.u.configureNotify.x += panoramiXdataPtr[0].x;
+            event.u.configureNotify.y += panoramiXdataPtr[0].y;
+	}
+#endif
+	event.u.configureNotify.width = w;
+	event.u.configureNotify.height = h;
+	event.u.configureNotify.borderWidth = bw;
+	event.u.configureNotify.override = pWin->overrideRedirect;
+	DeliverEvents(pWin, &event, 1, NullWindow);
+    }
+    if (mask & CWBorderWidth)
+    {
+	if (action == RESTACK_WIN)
+	{
+	    action = MOVE_WIN;
+	    pWin->borderWidth = bw;
+	}
+	else if ((action == MOVE_WIN) &&
+		 (beforeX + wBorderWidth (pWin) == x + (int)bw) &&
+		 (beforeY + wBorderWidth (pWin) == y + (int)bw))
+	{
+	    action = REBORDER_WIN;
+	    (*pWin->drawable.pScreen->ChangeBorderWidth)(pWin, bw);
+	}
+	else
+	    pWin->borderWidth = bw;
+    }
+    if (action == MOVE_WIN)
+	(*pWin->drawable.pScreen->MoveWindow)(pWin, x, y, pSib,
+		   (mask & CWBorderWidth) ? VTOther : VTMove);
+    else if (action == RESIZE_WIN)
+	(*pWin->drawable.pScreen->ResizeWindow)(pWin, x, y, w, h, pSib);
+    else if (mask & CWStackMode)
+	ReflectStackChange(pWin, pSib, VTOther);
+
+    if (action != RESTACK_WIN)
+	CheckCursorConfinement(pWin);
+    return(Success);
+#undef RESTACK_WIN
+#undef MOVE_WIN
+#undef RESIZE_WIN
+#undef REBORDER_WIN
+}
+
+
+/******
+ *
+ * CirculateWindow
+ *    For RaiseLowest, raises the lowest mapped child (if any) that is
+ *    obscured by another child to the top of the stack.  For LowerHighest,
+ *    lowers the highest mapped child (if any) that is obscuring another
+ *    child to the bottom of the stack.	 Exposure processing is performed 
+ *
+ ******/
+
+int
+CirculateWindow(WindowPtr pParent, int direction, ClientPtr client)
+{
+    register WindowPtr pWin, pHead, pFirst;
+    xEvent event;
+    BoxRec box;
+
+    pHead = RealChildHead(pParent);
+    pFirst = pHead ? pHead->nextSib : pParent->firstChild;
+    if (direction == RaiseLowest)
+    {
+	for (pWin = pParent->lastChild;
+	     (pWin != pHead) &&
+	     !(pWin->mapped &&
+	       AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box)));
+	     pWin = pWin->prevSib) ;
+	if (pWin == pHead)
+	    return Success;
+    }
+    else
+    {
+	for (pWin = pFirst;
+	     pWin &&
+	     !(pWin->mapped &&
+	       IOverlapAnyWindow(pWin, WindowExtents(pWin, &box)));
+	     pWin = pWin->nextSib) ;
+	if (!pWin)
+	    return Success;
+    }
+
+    event.u.circulate.window = pWin->drawable.id;
+    event.u.circulate.parent = pParent->drawable.id;
+    event.u.circulate.event = pParent->drawable.id;
+    if (direction == RaiseLowest)
+	event.u.circulate.place = PlaceOnTop;
+    else
+	event.u.circulate.place = PlaceOnBottom;
+
+    if (RedirectSend(pParent))
+    {
+	event.u.u.type = CirculateRequest;
+	if (MaybeDeliverEventsToClient(pParent, &event, 1,
+		SubstructureRedirectMask, client) == 1)
+	    return(Success);
+    }
+
+    event.u.u.type = CirculateNotify;
+    DeliverEvents(pWin, &event, 1, NullWindow);
+    ReflectStackChange(pWin,
+		       (direction == RaiseLowest) ? pFirst : NullWindow,
+		       VTStack);
+
+    return(Success);
+}
+
+static int
+CompareWIDs(
+    WindowPtr pWin,
+    pointer   value) /* must conform to VisitWindowProcPtr */
+{
+    Window *wid = (Window *)value;
+
+    if (pWin->drawable.id == *wid)
+       return(WT_STOPWALKING);
+    else
+       return(WT_WALKCHILDREN);
+}
+
+/*****
+ *  ReparentWindow
+ *****/
+
+int
+ReparentWindow(register WindowPtr pWin, register WindowPtr pParent,
+               int x, int y, ClientPtr client)
+{
+    WindowPtr pPrev, pPriorParent;
+    Bool WasMapped = (Bool)(pWin->mapped);
+    xEvent event;
+    int bw = wBorderWidth (pWin);
+    register ScreenPtr pScreen;
+
+    pScreen = pWin->drawable.pScreen;
+    if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING)
+	return(BadMatch);		
+    if (!MakeWindowOptional(pWin))
+	return(BadAlloc);
+
+    if (WasMapped)
+       UnmapWindow(pWin, FALSE);
+
+    event.u.u.type = ReparentNotify;
+    event.u.reparent.window = pWin->drawable.id;
+    event.u.reparent.parent = pParent->drawable.id;
+    event.u.reparent.x = x;
+    event.u.reparent.y = y;
+#ifdef PANORAMIX
+    if(!noPanoramiXExtension && !pParent->parent) {
+	event.u.reparent.x += panoramiXdataPtr[0].x;
+	event.u.reparent.y += panoramiXdataPtr[0].y;
+    }
+#endif
+    event.u.reparent.override = pWin->overrideRedirect;
+    DeliverEvents(pWin, &event, 1, pParent);
+
+    /* take out of sibling chain */
+
+    pPriorParent = pPrev = pWin->parent;
+    if (pPrev->firstChild == pWin)
+	pPrev->firstChild = pWin->nextSib;
+    if (pPrev->lastChild == pWin)
+	pPrev->lastChild = pWin->prevSib;
+
+    if (pWin->nextSib)
+	pWin->nextSib->prevSib = pWin->prevSib;
+    if (pWin->prevSib)
+	pWin->prevSib->nextSib = pWin->nextSib;
+
+    /* insert at begining of pParent */
+    pWin->parent = pParent;
+    pPrev = RealChildHead(pParent);
+    if (pPrev)
+    {
+	pWin->nextSib = pPrev->nextSib;
+	if (pPrev->nextSib)
+	    pPrev->nextSib->prevSib = pWin;
+	else
+	    pParent->lastChild = pWin;
+	pPrev->nextSib = pWin;
+	pWin->prevSib = pPrev;
+    }
+    else
+    {
+	pWin->nextSib = pParent->firstChild;
+	pWin->prevSib = NullWindow;
+	if (pParent->firstChild)
+	    pParent->firstChild->prevSib = pWin;
+	else
+	    pParent->lastChild = pWin;
+	pParent->firstChild = pWin;
+    }
+
+    pWin->origin.x = x + bw;
+    pWin->origin.y = y + bw;
+    pWin->drawable.x = x + bw + pParent->drawable.x;
+    pWin->drawable.y = y + bw + pParent->drawable.y;
+
+    /* clip to parent */
+    SetWinSize (pWin);
+    SetBorderSize (pWin);
+
+    if (pScreen->ReparentWindow)
+	(*pScreen->ReparentWindow)(pWin, pPriorParent);
+    (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y);
+    ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+
+    CheckWindowOptionalNeed(pWin);
+
+    if (WasMapped)
+	MapWindow(pWin, client);
+    RecalculateDeliverableEvents(pWin);
+    return(Success);
+}
+
+static void
+RealizeTree(WindowPtr pWin)
+{
+    register WindowPtr pChild;
+    RealizeWindowProcPtr Realize;
+
+    Realize = pWin->drawable.pScreen->RealizeWindow;
+    pChild = pWin;
+    while (1)
+    {
+	if (pChild->mapped)
+	{
+	    pChild->realized = TRUE;
+#ifdef DO_SAVE_UNDERS
+	    if (pChild->saveUnder)
+		deltaSaveUndersViewable++;
+#endif
+	    pChild->viewable = (pChild->drawable.class == InputOutput);
+	    (* Realize)(pChild);
+	    if (pChild->firstChild)
+	    {
+		pChild = pChild->firstChild;
+		continue;
+	    }
+	}
+	while (!pChild->nextSib && (pChild != pWin))
+	    pChild = pChild->parent;
+	if (pChild == pWin)
+	    return;
+	pChild = pChild->nextSib;
+    }
+}
+
+/*****
+ * MapWindow
+ *    If some other client has selected SubStructureReDirect on the parent
+ *    and override-redirect is xFalse, then a MapRequest event is generated,
+ *    but the window remains unmapped.	Otherwise, the window is mapped and a
+ *    MapNotify event is generated.
+ *****/
+
+int
+MapWindow(register WindowPtr pWin, ClientPtr client)
+{
+    register ScreenPtr pScreen;
+
+    register WindowPtr pParent;
+#ifdef DO_SAVE_UNDERS
+    Bool	dosave = FALSE;
+#endif
+    WindowPtr  pLayerWin;
+
+    if (pWin->mapped)
+	return(Success);
+
+#ifdef XCSECURITY
+    /*  don't let an untrusted client map a child-of-trusted-window, InputOnly
+     *  window; too easy to steal device input
+     */
+    if ( (client->trustLevel != XSecurityClientTrusted) &&
+	 (pWin->drawable.class == InputOnly) &&
+	 (wClient(pWin->parent)->trustLevel == XSecurityClientTrusted) )
+	 return Success;
+#endif	
+
+    pScreen = pWin->drawable.pScreen;
+    if ( (pParent = pWin->parent) )
+    {
+	xEvent event;
+	Bool anyMarked;
+#ifdef XAPPGROUP
+	ClientPtr win_owner = clients[CLIENT_ID(pWin->drawable.id)];
+	ClientPtr ag_leader = XagLeader (win_owner);
+#endif
+
+	if ((!pWin->overrideRedirect) && 
+	    (RedirectSend(pParent)
+#ifdef XAPPGROUP
+	    || (win_owner->appgroup && ag_leader &&
+		XagIsControlledRoot (client, pParent))
+#endif
+	))
+	{
+	    event.u.u.type = MapRequest;
+	    event.u.mapRequest.window = pWin->drawable.id;
+#ifdef XAPPGROUP
+	    /* make sure if the ag_leader maps the window it goes to the wm */
+	    if (ag_leader && ag_leader != client &&
+		XagIsControlledRoot (client, pParent)) {
+		event.u.mapRequest.parent = XagId (win_owner);
+		(void) TryClientEvents (ag_leader, &event, 1,
+					NoEventMask, NoEventMask, NullGrab);
+		return Success;
+	    }
+#endif
+	    event.u.mapRequest.parent = pParent->drawable.id;
+
+	    if (MaybeDeliverEventsToClient(pParent, &event, 1,
+		SubstructureRedirectMask, client) == 1)
+		return(Success);
+	}
+
+	pWin->mapped = TRUE;
+	if (SubStrSend(pWin, pParent))
+	{
+	    event.u.u.type = MapNotify;
+	    event.u.mapNotify.window = pWin->drawable.id;
+	    event.u.mapNotify.override = pWin->overrideRedirect;
+	    DeliverEvents(pWin, &event, 1, NullWindow);
+	}
+
+	if (!pParent->realized)
+	    return(Success);
+	RealizeTree(pWin);
+	if (pWin->viewable)
+	{
+	    anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+							  &pLayerWin);
+#ifdef DO_SAVE_UNDERS
+	    if (DO_SAVE_UNDERS(pWin))
+	    {
+		dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
+	    }
+#endif /* DO_SAVE_UNDERS */
+	    if (anyMarked)
+	    {
+		(*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
+		(*pScreen->HandleExposures)(pLayerWin->parent);
+	    }
+#ifdef DO_SAVE_UNDERS
+	    if (dosave)
+		(*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
+#endif /* DO_SAVE_UNDERS */
+	if (anyMarked && pScreen->PostValidateTree)
+	    (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
+	}
+	WindowsRestructured ();
+    }
+    else
+    {
+	RegionRec   temp;
+
+	pWin->mapped = TRUE;
+	pWin->realized = TRUE;	   /* for roots */
+	pWin->viewable = pWin->drawable.class == InputOutput;
+	/* We SHOULD check for an error value here XXX */
+	(*pScreen->RealizeWindow)(pWin);
+	if (pScreen->ClipNotify)
+	    (*pScreen->ClipNotify) (pWin, 0, 0);
+	if (pScreen->PostValidateTree)
+	    (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap);
+	REGION_NULL(pScreen, &temp);
+	REGION_COPY(pScreen, &temp, &pWin->clipList);
+	(*pScreen->WindowExposures) (pWin, &temp, NullRegion);
+	REGION_UNINIT(pScreen, &temp);
+    }
+
+    return(Success);
+}
+
+
+/*****
+ * MapSubwindows
+ *    Performs a MapWindow all unmapped children of the window, in top
+ *    to bottom stacking order.
+ *****/
+
+void
+MapSubwindows(register WindowPtr pParent, ClientPtr client)
+{
+    register WindowPtr	pWin;
+    WindowPtr		pFirstMapped = NullWindow;
+#ifdef DO_SAVE_UNDERS
+    WindowPtr		pFirstSaveUndered = NullWindow;
+#endif
+    register ScreenPtr	pScreen;
+    register Mask	parentRedirect;
+    register Mask	parentNotify;
+    xEvent		event;
+    Bool		anyMarked;
+#ifdef DO_SAVE_UNDERS
+    Bool	dosave = FALSE;
+#endif
+    WindowPtr		pLayerWin;
+
+    pScreen = pParent->drawable.pScreen;
+    parentRedirect = RedirectSend(pParent);
+    parentNotify = SubSend(pParent);
+    anyMarked = FALSE;
+    for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib)
+    {
+	if (!pWin->mapped)
+	{
+	    if (parentRedirect && !pWin->overrideRedirect)
+	    {
+		event.u.u.type = MapRequest;
+		event.u.mapRequest.window = pWin->drawable.id;
+		event.u.mapRequest.parent = pParent->drawable.id;
+    
+		if (MaybeDeliverEventsToClient(pParent, &event, 1,
+		    SubstructureRedirectMask, client) == 1)
+		    continue;
+	    }
+    
+	    pWin->mapped = TRUE;
+	    if (parentNotify || StrSend(pWin))
+	    {
+		event.u.u.type = MapNotify;
+		event.u.mapNotify.window = pWin->drawable.id;
+		event.u.mapNotify.override = pWin->overrideRedirect;
+		DeliverEvents(pWin, &event, 1, NullWindow);
+	    }
+    
+	    if (!pFirstMapped)
+		pFirstMapped = pWin;
+	    if (pParent->realized)
+	    {
+		RealizeTree(pWin);
+		if (pWin->viewable)
+		{
+		    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+							(WindowPtr *)NULL);
+#ifdef DO_SAVE_UNDERS
+		    if (DO_SAVE_UNDERS(pWin))
+		    {
+			dosave = TRUE;
+		    }
+#endif /* DO_SAVE_UNDERS */
+		}
+	    }
+	}
+    }
+
+    if (pFirstMapped)
+    {
+	pLayerWin = (*pScreen->GetLayerWindow)(pParent);
+	if (pLayerWin->parent != pParent) {
+	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pLayerWin,
+							   pLayerWin,
+							   (WindowPtr *)NULL);
+	    pFirstMapped = pLayerWin;
+	}
+        if (anyMarked)
+        {
+#ifdef DO_SAVE_UNDERS
+	    if (pLayerWin->parent != pParent)
+	    {
+		if (dosave || (DO_SAVE_UNDERS(pLayerWin)))
+		{
+		    dosave = (*pScreen->ChangeSaveUnder)(pLayerWin,
+							 pLayerWin);
+		}
+	    }
+	    else if (dosave)
+	    {
+		dosave = FALSE;
+		for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib)
+		{
+		    if (DO_SAVE_UNDERS(pWin))
+		    {
+			dosave |= (*pScreen->ChangeSaveUnder)(pWin,
+							      pWin->nextSib);
+			if (dosave && !pFirstSaveUndered)
+			    pFirstSaveUndered = pWin;
+		    }
+		}
+            }
+#endif /* DO_SAVE_UNDERS */
+	    (*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap);
+	    (*pScreen->HandleExposures)(pLayerWin->parent);
+	}
+#ifdef DO_SAVE_UNDERS
+        if (dosave)
+	    (*pScreen->PostChangeSaveUnder)(pLayerWin,
+					    pFirstSaveUndered->nextSib);
+#endif /* DO_SAVE_UNDERS */
+        if (anyMarked && pScreen->PostValidateTree)
+	    (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped,
+					 VTMap);
+        WindowsRestructured ();
+    }
+}
+
+static void
+UnrealizeTree(
+    WindowPtr pWin,
+    Bool fromConfigure)
+{
+    register WindowPtr pChild;
+    UnrealizeWindowProcPtr Unrealize;
+    MarkUnrealizedWindowProcPtr MarkUnrealizedWindow;
+
+    Unrealize = pWin->drawable.pScreen->UnrealizeWindow;
+    MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow;
+    pChild = pWin;
+    while (1)
+    {
+	if (pChild->realized)
+	{
+	    pChild->realized = FALSE;
+	    pChild->visibility = VisibilityNotViewable;
+#ifdef PANORAMIX
+	    if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) {
+		PanoramiXRes *win;
+		win = (PanoramiXRes*)LookupIDByType(pChild->drawable.id,
+							XRT_WINDOW);
+		if(win)
+		   win->u.win.visibility = VisibilityNotViewable;
+	    } 
+#endif
+	    (* Unrealize)(pChild);
+	    DeleteWindowFromAnyEvents(pChild, FALSE);
+	    if (pChild->viewable)
+	    {
+#ifdef DO_SAVE_UNDERS
+		if (pChild->saveUnder)
+		    deltaSaveUndersViewable--;
+#endif
+		pChild->viewable = FALSE;
+		if (pChild->backStorage)
+		    (*pChild->drawable.pScreen->SaveDoomedAreas)(
+					    pChild, &pChild->clipList, 0, 0);
+		(* MarkUnrealizedWindow)(pChild, pWin, fromConfigure);
+		pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+	    }
+	    if (pChild->firstChild)
+	    {
+		pChild = pChild->firstChild;
+		continue;
+	    }
+	}
+	while (!pChild->nextSib && (pChild != pWin))
+	    pChild = pChild->parent;
+	if (pChild == pWin)
+	    return;
+	pChild = pChild->nextSib;
+    }
+}
+
+/*****
+ * UnmapWindow
+ *    If the window is already unmapped, this request has no effect.
+ *    Otherwise, the window is unmapped and an UnMapNotify event is
+ *    generated.  Cannot unmap a root window.
+ *****/
+
+int
+UnmapWindow(register WindowPtr pWin, Bool fromConfigure)
+{
+    register WindowPtr pParent;
+    xEvent event;
+    Bool wasRealized = (Bool)pWin->realized;
+    Bool wasViewable = (Bool)pWin->viewable;
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    WindowPtr pLayerWin = pWin;
+
+    if ((!pWin->mapped) || (!(pParent = pWin->parent)))
+	return(Success);
+    if (SubStrSend(pWin, pParent))
+    {
+	event.u.u.type = UnmapNotify;
+	event.u.unmapNotify.window = pWin->drawable.id;
+	event.u.unmapNotify.fromConfigure = fromConfigure;
+	DeliverEvents(pWin, &event, 1, NullWindow);
+    }
+    if (wasViewable && !fromConfigure)
+    {
+	pWin->valdata = UnmapValData;
+	(*pScreen->MarkOverlappedWindows)(pWin, pWin->nextSib, &pLayerWin);
+	(*pScreen->MarkWindow)(pLayerWin->parent);
+    }
+    pWin->mapped = FALSE;
+    if (wasRealized)
+	UnrealizeTree(pWin, fromConfigure);
+    if (wasViewable)
+    {
+	if (!fromConfigure)
+	{
+	    (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap);
+	    (*pScreen->HandleExposures)(pLayerWin->parent);
+	}
+#ifdef DO_SAVE_UNDERS
+	if (DO_SAVE_UNDERS(pWin))
+	{
+	    if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib) )
+	    {
+		(*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
+	    }
+	}
+	pWin->DIXsaveUnder = FALSE;
+#endif /* DO_SAVE_UNDERS */
+	if (!fromConfigure && pScreen->PostValidateTree)
+	    (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap);
+    }
+    if (wasRealized && !fromConfigure)
+	WindowsRestructured ();
+    return(Success);
+}
+
+/*****
+ * UnmapSubwindows
+ *    Performs an UnmapWindow request with the specified mode on all mapped
+ *    children of the window, in bottom to top stacking order.
+ *****/
+
+void
+UnmapSubwindows(register WindowPtr pWin)
+{
+    register WindowPtr pChild, pHead;
+    xEvent event;
+    Bool wasRealized = (Bool)pWin->realized;
+    Bool wasViewable = (Bool)pWin->viewable;
+    Bool anyMarked = FALSE;
+    Mask parentNotify;
+    WindowPtr pLayerWin = NULL;
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    if (!pWin->firstChild)
+	return;
+    parentNotify = SubSend(pWin);
+    pHead = RealChildHead(pWin);
+
+    if (wasViewable)
+	pLayerWin = (*pScreen->GetLayerWindow)(pWin);
+
+    for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+    {
+	if (pChild->mapped)
+	{
+	    if (parentNotify || StrSend(pChild))
+	    {
+		event.u.u.type = UnmapNotify;
+		event.u.unmapNotify.window = pChild->drawable.id;
+		event.u.unmapNotify.fromConfigure = xFalse;
+		DeliverEvents(pChild, &event, 1, NullWindow);
+	    }
+	    if (pChild->viewable)
+	    {
+		pChild->valdata = UnmapValData;
+		anyMarked = TRUE;
+	    }
+	    pChild->mapped = FALSE;
+	    if (pChild->realized)
+		UnrealizeTree(pChild, FALSE);
+	    if (wasViewable)
+	    {
+#ifdef DO_SAVE_UNDERS
+		pChild->DIXsaveUnder = FALSE;
+#endif /* DO_SAVE_UNDERS */
+		if (pChild->backStorage)
+		    (*pScreen->SaveDoomedAreas)(
+					    pChild, &pChild->clipList, 0, 0);
+	    }
+	}
+    }
+    if (wasViewable)
+    {
+	if (anyMarked)
+	{
+	    if (pLayerWin->parent == pWin)
+		(*pScreen->MarkWindow)(pWin);
+	    else
+	    {
+		WindowPtr ptmp;
+                (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin,
+						  (WindowPtr *)NULL);
+		(*pScreen->MarkWindow)(pLayerWin->parent);
+		
+		/* Windows between pWin and pLayerWin may not have been marked */
+		ptmp = pWin;
+ 
+		while (ptmp != pLayerWin->parent)
+		{
+		    (*pScreen->MarkWindow)(ptmp);
+		    ptmp = ptmp->parent;
+		}
+                pHead = pWin->firstChild;
+	    }
+	    (*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap);
+	    (*pScreen->HandleExposures)(pLayerWin->parent);
+	}
+#ifdef DO_SAVE_UNDERS
+	if (DO_SAVE_UNDERS(pWin))
+	{
+	    if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin))
+		(*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
+	}
+#endif /* DO_SAVE_UNDERS */
+	if (anyMarked && pScreen->PostValidateTree)
+	    (*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap);
+    }
+    if (wasRealized)
+	WindowsRestructured ();
+}
+
+
+void
+HandleSaveSet(register ClientPtr client)
+{
+    register WindowPtr pParent, pWin;
+    register int j;
+
+    for (j=0; j<client->numSaved; j++)
+    {
+	pWin = SaveSetWindow(client->saveSet[j]);
+#ifdef XFIXES
+	if (SaveSetToRoot(client->saveSet[j]))
+	    pParent = WindowTable[pWin->drawable.pScreen->myNum];
+	else
+#endif
+	{
+	    pParent = pWin->parent;
+	    while (pParent && (wClient (pParent) == client))
+		pParent = pParent->parent;
+	}
+	if (pParent)
+	{
+	    if (pParent != pWin->parent)
+	    {
+		ReparentWindow(pWin, pParent,
+			       pWin->drawable.x - wBorderWidth (pWin) - pParent->drawable.x,
+			       pWin->drawable.y - wBorderWidth (pWin) - pParent->drawable.y,
+			       client);
+		if(!pWin->realized && pWin->mapped)
+		    pWin->mapped = FALSE;
+	    }
+#ifdef XFIXES
+	    if (SaveSetRemap (client->saveSet[j]))
+#endif
+		MapWindow(pWin, client);
+	}
+    }
+    xfree(client->saveSet);
+    client->numSaved = 0;
+    client->saveSet = (SaveSetElt *)NULL;
+}
+
+/**
+ *
+ *  \param x,y  in root
+ *  \param box  "return" value
+ */
+Bool
+VisibleBoundingBoxFromPoint(register WindowPtr pWin, int x, int y, BoxPtr box)
+{
+    if (!pWin->realized)
+	return (FALSE);
+    if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->clipList, x, y, box))
+	return(TRUE);
+    return(FALSE);
+}
+
+/**
+ *
+ * \param x,y  in root
+ */
+Bool
+PointInWindowIsVisible(register WindowPtr pWin, int x, int y)
+{
+    BoxRec box;
+
+    if (!pWin->realized)
+	return (FALSE);
+    if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderClip,
+						  x, y, &box)
+	&& (!wInputShape(pWin) ||
+	    POINT_IN_REGION(pWin->drawable.pScreen,
+			    wInputShape(pWin),
+			    x - pWin->drawable.x, 
+			    y - pWin->drawable.y, &box)))
+	return(TRUE);
+    return(FALSE);
+}
+
+
+RegionPtr
+NotClippedByChildren(register WindowPtr pWin)
+{
+    register ScreenPtr pScreen;
+    RegionPtr pReg;
+
+    pScreen = pWin->drawable.pScreen;
+    pReg = REGION_CREATE(pScreen, NullBox, 1);
+    if (pWin->parent ||
+	screenIsSaved != SCREEN_SAVER_ON ||
+	!HasSaverWindow (pWin->drawable.pScreen->myNum))
+    {
+	REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize);
+    }
+    return(pReg);
+}
+
+void
+SendVisibilityNotify(WindowPtr pWin)
+{
+    xEvent event;
+#ifndef NO_XINERAMA_PORT
+    unsigned int visibility = pWin->visibility;
+#endif
+#ifdef PANORAMIX
+    /* This is not quite correct yet, but it's close */
+    if(!noPanoramiXExtension) {
+	PanoramiXRes *win;
+	WindowPtr pWin2;
+	int i, Scrnum;
+
+	Scrnum = pWin->drawable.pScreen->myNum;
+	
+	win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, Scrnum);
+
+	if(!win || (win->u.win.visibility == visibility))
+	    return;
+
+	switch(visibility) {
+	case VisibilityUnobscured:
+	    for(i = 0; i < PanoramiXNumScreens; i++) {
+		if(i == Scrnum) continue;
+
+		pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW);
+
+		if (pWin2) {
+		    if(pWin2->visibility == VisibilityPartiallyObscured)
+		   	return;
+
+		    if(!i) pWin = pWin2;
+		}
+	    }
+	    break;
+	case VisibilityPartiallyObscured:
+	    if(Scrnum) {
+	        pWin2 = (WindowPtr)LookupIDByType(win->info[0].id, RT_WINDOW);
+		if (pWin2) pWin = pWin2;
+	    }
+	    break;
+	case VisibilityFullyObscured:
+	    for(i = 0; i < PanoramiXNumScreens; i++) {
+		if(i == Scrnum) continue;
+
+		pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW);
+		
+		if (pWin2) {
+		    if(pWin2->visibility != VisibilityFullyObscured)
+		    	return;
+
+		    if(!i) pWin = pWin2;
+		}
+	    }
+	    break;
+	}
+	
+	win->u.win.visibility = visibility;
+    }
+#endif
+
+    event.u.u.type = VisibilityNotify;
+    event.u.visibility.window = pWin->drawable.id;
+    event.u.visibility.state = visibility;
+    DeliverEvents(pWin, &event, 1, NullWindow);
+}
+
+
+#define RANDOM_WIDTH 32
+
+#ifndef NOLOGOHACK
+static void DrawLogo(
+    WindowPtr pWin
+);
+#endif
+
+void
+SaveScreens(int on, int mode)
+{
+    int i;
+    int what;
+    int type;
+
+    if (on == SCREEN_SAVER_FORCER)
+    {
+	UpdateCurrentTimeIf();
+	lastDeviceEventTime = currentTime;
+	if (mode == ScreenSaverReset)
+	    what = SCREEN_SAVER_OFF;
+	else
+	    what = SCREEN_SAVER_ON;
+	type = what;
+    }
+    else
+    {
+	what = on;
+	type = what;
+	if (what == screenIsSaved)
+	    type = SCREEN_SAVER_CYCLE;
+    }
+    for (i = 0; i < screenInfo.numScreens; i++)
+    {
+	if (on == SCREEN_SAVER_FORCER)
+	   (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on);
+	if (savedScreenInfo[i].ExternalScreenSaver)
+	{
+	    if ((*savedScreenInfo[i].ExternalScreenSaver)
+		(screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER))
+		continue;
+	}
+	if (type == screenIsSaved)
+	    continue;
+	switch (type) {
+	case SCREEN_SAVER_OFF:
+	    if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+	    {
+	       (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
+						      what);
+	    }
+	    else if (HasSaverWindow (i))
+	    {
+		savedScreenInfo[i].pWindow = NullWindow;
+		FreeResource(savedScreenInfo[i].wid, RT_NONE);
+	    }
+	    break;
+	case SCREEN_SAVER_CYCLE:
+	    if (savedScreenInfo[i].blanked == SCREEN_IS_TILED)
+	    {
+		WindowPtr pWin = savedScreenInfo[i].pWindow;
+		/* make it look like screen saver is off, so that
+		 * NotClippedByChildren will compute a clip list
+		 * for the root window, so miPaintWindow works
+		 */
+		screenIsSaved = SCREEN_SAVER_OFF;
+#ifndef NOLOGOHACK
+		if (logoScreenSaver)
+		    (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, FALSE);
+#endif
+		(*pWin->drawable.pScreen->MoveWindow)(pWin,
+			   (short)(-(rand() % RANDOM_WIDTH)),
+			   (short)(-(rand() % RANDOM_WIDTH)),
+			   pWin->nextSib, VTMove);
+#ifndef NOLOGOHACK
+		if (logoScreenSaver)
+		    DrawLogo(pWin);
+#endif
+		screenIsSaved = SCREEN_SAVER_ON;
+	    }
+	    /*
+	     * Call the DDX saver in case it wants to do something
+	     * at cycle time
+	     */
+	    else if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+	    {
+		(* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
+						       type);
+	    }
+	    break;
+	case SCREEN_SAVER_ON:
+	    if (ScreenSaverBlanking != DontPreferBlanking)
+	    {
+		if ((* screenInfo.screens[i]->SaveScreen)
+		   (screenInfo.screens[i], what))
+		{
+		   savedScreenInfo[i].blanked = SCREEN_IS_BLANKED;
+		   continue;
+		}
+		if ((ScreenSaverAllowExposures != DontAllowExposures) &&
+		    TileScreenSaver(i, SCREEN_IS_BLACK))
+		{
+		    savedScreenInfo[i].blanked = SCREEN_IS_BLACK;
+		    continue;
+		}
+	    }
+	    if ((ScreenSaverAllowExposures != DontAllowExposures) &&
+		TileScreenSaver(i, SCREEN_IS_TILED))
+	    {
+		savedScreenInfo[i].blanked = SCREEN_IS_TILED;
+	    }
+	    else
+		savedScreenInfo[i].blanked = SCREEN_ISNT_SAVED;
+	    break;
+	}
+    }
+    screenIsSaved = what;
+    if (mode == ScreenSaverReset)
+       SetScreenSaverTimer();
+}
+
+static Bool
+TileScreenSaver(int i, int kind)
+{
+    int j;
+    int result;
+    XID attributes[3];
+    Mask mask;
+    WindowPtr pWin;		
+    CursorMetricRec cm;
+    unsigned char *srcbits, *mskbits;
+    CursorPtr cursor;
+    XID	cursorID = 0;
+    int	attri;
+
+    mask = 0;
+    attri = 0;
+    switch (kind) {
+    case SCREEN_IS_TILED:
+	switch (WindowTable[i]->backgroundState) {
+	case BackgroundPixel:
+	    attributes[attri++] = WindowTable[i]->background.pixel;
+	    mask |= CWBackPixel;
+	    break;
+	case BackgroundPixmap:
+	    attributes[attri++] = None;
+	    mask |= CWBackPixmap;
+	    break;
+	default:
+	    break;
+	}
+	break;
+    case SCREEN_IS_BLACK:
+	attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel;
+	mask |= CWBackPixel;
+	break;
+    }
+    mask |= CWOverrideRedirect;
+    attributes[attri++] = xTrue;
+
+    /*
+     * create a blank cursor
+     */
+
+    cm.width=16;
+    cm.height=16;
+    cm.xhot=8;
+    cm.yhot=8;
+    srcbits = (unsigned char *)xalloc( BitmapBytePad(32)*16);
+    mskbits = (unsigned char *)xalloc( BitmapBytePad(32)*16);
+    if (!srcbits || !mskbits)
+    {
+	xfree(srcbits);
+	xfree(mskbits);
+	cursor = 0;
+    }
+    else
+    {
+	for (j=0; j<BitmapBytePad(32)*16; j++)
+	    srcbits[j] = mskbits[j] = 0x0;
+	cursor = AllocCursor(srcbits, mskbits, &cm, 0, 0, 0, 0, 0, 0);
+	if (cursor)
+	{
+	    cursorID = FakeClientID(0);
+	    if (AddResource (cursorID, RT_CURSOR, (pointer) cursor))
+	    {
+		attributes[attri] = cursorID;
+		mask |= CWCursor;
+	    }
+	    else
+		cursor = 0;
+	}
+	else
+	{
+	    xfree (srcbits);
+	    xfree (mskbits);
+	}
+    }
+
+    pWin = savedScreenInfo[i].pWindow =
+	 CreateWindow(savedScreenInfo[i].wid,
+	      WindowTable[i],
+	      -RANDOM_WIDTH, -RANDOM_WIDTH,
+	      (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH,
+	      (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH,
+	      0, InputOutput, mask, attributes, 0, serverClient,
+	      wVisual (WindowTable[i]), &result);
+
+    if (cursor)
+	FreeResource (cursorID, RT_NONE);
+
+    if (!pWin)
+	return FALSE;
+
+    if (!AddResource(pWin->drawable.id, RT_WINDOW,
+		     (pointer)savedScreenInfo[i].pWindow))
+	return FALSE;
+
+    if (mask & CWBackPixmap)
+    {
+	MakeRootTile (pWin);
+	(*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap);
+    }
+    MapWindow(pWin, serverClient);
+#ifndef NOLOGOHACK
+    if (kind == SCREEN_IS_TILED && logoScreenSaver)
+	DrawLogo(pWin);
+#endif
+    return TRUE;
+}
+
+/*
+ * FindWindowWithOptional
+ *
+ * search ancestors of the given window for an entry containing
+ * a WindowOpt structure.  Assumptions:	 some parent will
+ * contain the structure.
+ */
+
+WindowPtr
+FindWindowWithOptional (register WindowPtr w)
+{
+    do
+	w = w->parent;
+    while (!w->optional);
+    return w;
+}
+
+/*
+ * CheckWindowOptionalNeed
+ *
+ * check each optional entry in the given window to see if
+ * the value is satisfied by the default rules.	 If so,
+ * release the optional record
+ */
+
+void
+CheckWindowOptionalNeed (register WindowPtr w)
+{
+    register WindowOptPtr optional;
+    register WindowOptPtr parentOptional;
+
+    if (!w->parent)
+	return;
+    optional = w->optional;
+    if (optional->dontPropagateMask != DontPropagateMasks[w->dontPropagate])
+	return;
+    if (optional->otherEventMasks != 0)
+	return;
+    if (optional->otherClients != NULL)
+	return;
+    if (optional->passiveGrabs != NULL)
+	return;
+    if (optional->userProps != NULL)
+	return;
+    if (optional->backingBitPlanes != ~0L)
+	return;
+    if (optional->backingPixel != 0)
+	return;
+#ifdef SHAPE
+    if (optional->boundingShape != NULL)
+	return;
+    if (optional->clipShape != NULL)
+	return;
+    if (optional->inputShape != NULL)
+	return;
+#endif
+#ifdef XINPUT
+    if (optional->inputMasks != NULL)
+	return;
+#endif
+    parentOptional = FindWindowWithOptional(w)->optional;
+    if (optional->visual != parentOptional->visual)
+	return;
+    if (optional->cursor != None &&
+	(optional->cursor != parentOptional->cursor ||
+	 w->parent->cursorIsNone))
+	return;
+    if (optional->colormap != parentOptional->colormap)
+	return;
+    DisposeWindowOptional (w);
+}
+
+/*
+ * MakeWindowOptional
+ *
+ * create an optional record and initialize it with the default
+ * values.
+ */
+
+Bool
+MakeWindowOptional (register WindowPtr pWin)
+{
+    register WindowOptPtr optional;
+    register WindowOptPtr parentOptional;
+
+    if (pWin->optional)
+	return TRUE;
+    optional = (WindowOptPtr) xalloc (sizeof (WindowOptRec));
+    if (!optional)
+	return FALSE;
+    optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate];
+    optional->otherEventMasks = 0;
+    optional->otherClients = NULL;
+    optional->passiveGrabs = NULL;
+    optional->userProps = NULL;
+    optional->backingBitPlanes = ~0L;
+    optional->backingPixel = 0;
+#ifdef SHAPE
+    optional->boundingShape = NULL;
+    optional->clipShape = NULL;
+    optional->inputShape = NULL;
+#endif
+#ifdef XINPUT
+    optional->inputMasks = NULL;
+#endif
+    parentOptional = FindWindowWithOptional(pWin)->optional;
+    optional->visual = parentOptional->visual;
+    if (!pWin->cursorIsNone)
+    {
+	optional->cursor = parentOptional->cursor;
+	optional->cursor->refcnt++;
+    }
+    else
+    {
+	optional->cursor = None;
+    }
+    optional->colormap = parentOptional->colormap;
+    pWin->optional = optional;
+    return TRUE;
+}
+
+void
+DisposeWindowOptional (register WindowPtr pWin)
+{
+    if (!pWin->optional)
+	return;
+    /*
+     * everything is peachy.  Delete the optional record
+     * and clean up
+     */
+    /*
+     * TOG changed this code to:
+     *
+     *	    if (pWin->cursorIsNone == FALSE)
+     *		FreeCursor (pWin->optional->cursor, (Cursor)0);
+     *	    pWin->cursorIsNone = TRUE;
+     *
+     * This is blatently wrong; windows without optionals can have
+     * two different cursor values, either None or sharing their
+     * parents cursor.  This difference is controlled by the
+     * cursorIsNone value; when TRUE, the window has no cursor,
+     * when false, it shares its cursor with its parent; TOG
+     * made it impossible for a window to have a cursor without
+     * an optional record.
+     */
+    if (pWin->optional->cursor)
+    {
+	FreeCursor (pWin->optional->cursor, (Cursor)0);
+	pWin->cursorIsNone = FALSE;
+    }
+    else
+	pWin->cursorIsNone = TRUE;
+    xfree (pWin->optional);
+    pWin->optional = NULL;
+}
+
+#ifndef NOLOGOHACK
+static void
+DrawLogo(WindowPtr pWin)
+{
+    DrawablePtr pDraw;
+    ScreenPtr pScreen;
+    int x, y;
+    unsigned int width, height, size;
+    GC *pGC;
+    int thin, gap, d31;
+    DDXPointRec poly[4];
+    ChangeGCVal fore[2], back[2];
+    xrgb rgb[2];
+    BITS32 fmask, bmask;
+    ColormapPtr cmap;
+
+    pDraw = (DrawablePtr)pWin;
+    pScreen = pDraw->pScreen;
+    x = -pWin->origin.x;
+    y = -pWin->origin.y;
+    width = pScreen->width;
+    height = pScreen->height;
+    pGC = GetScratchGC(pScreen->rootDepth, pScreen);
+    if (!pGC)
+	return;
+
+    if ((rand() % 100) <= 17) /* make the probability for white fairly low */
+	fore[0].val = pScreen->whitePixel;
+    else
+	fore[0].val = pScreen->blackPixel;
+    if ((pWin->backgroundState == BackgroundPixel) &&
+	(cmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP))) {
+	Pixel querypixels[2];
+
+	querypixels[0] = fore[0].val;
+	querypixels[1] = pWin->background.pixel;
+	QueryColors(cmap, 2, querypixels, rgb);
+	if ((rgb[0].red == rgb[1].red) &&
+	    (rgb[0].green == rgb[1].green) &&
+	    (rgb[0].blue == rgb[1].blue)) {
+	    if (fore[0].val == pScreen->blackPixel)
+		fore[0].val = pScreen->whitePixel;
+	    else
+		fore[0].val = pScreen->blackPixel;
+	}
+    }
+    fore[1].val = FillSolid;
+    fmask = GCForeground|GCFillStyle;
+    if (pWin->backgroundState == BackgroundPixel) {
+	back[0].val = pWin->background.pixel;
+	back[1].val = FillSolid;
+	bmask = GCForeground|GCFillStyle;
+    } else {
+	back[0].val = 0;
+	back[1].val = 0;
+	dixChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin,
+		    NULL, back);
+	back[0].val = FillTiled;
+	back[1].ptr = pWin->background.pixmap;
+	bmask = GCFillStyle|GCTile;
+    }
+
+    /* should be the same as the reference function XmuDrawLogo() */
+
+    size = width;
+    if (height < width)
+	 size = height;
+    size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH);
+    size &= ~1;
+    x += rand() % (width - size);
+    y += rand() % (height - size);
+
+/*
+ * 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;
+    dixChangeGC(NullClient, pGC, fmask, NULL, fore);
+    ValidateGC(pDraw, pGC);
+    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * 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;
+    dixChangeGC(NullClient, pGC, bmask, NULL, back);
+    ValidateGC(pDraw, pGC);
+    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * 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;
+    ValidateGC(pDraw, pGC);
+    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * 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;
+    dixChangeGC(NullClient, pGC, fmask, NULL, fore);
+    ValidateGC(pDraw, pGC);
+    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * 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;
+    dixChangeGC(NullClient, pGC, bmask, NULL, back);
+    ValidateGC(pDraw, pGC);
+    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+    FreeScratchGC(pGC);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/fb/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,51 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localmacros 1.3     05/11/08 SMI"
+XCOMM
+
+#if 0 /* defined(i386Architecture) -- disable for now since it causes crashes */
+XCOMM Use gcc to build fbmmx.o since it requires gcc syntax for MMX operations
+XCOMM for faster alpha-blending (6224420)
+
+MMXOPTIONS= -mmmx -Winline --param inline-unit-growth=10000 \
+        --param large-function-growth=10000 -DUSE_GCC34_MMX
+
+fbmmx.o := MODCC = /usr/sfw/bin/gcc
+fbmmx.o := CCOPTIONS = -fpcc-struct-return -DNO_ASM -Wall -Wpointer-arith
+fbmmx.o := CDEBUGFLAGS = -O3 -march=pentium -mtune=opteron
+fbmmx.o := PICFLAGS = -fpic
+
+SpecialCObjectRule(fbmmx,fbmmx.c,$(MMXOPTIONS))
+SpecialCObjectRule(fbpict,fbpict.c,-DUSE_GCC34_MMX)
+SpecialCObjectRule(fbfill,fbfill.c,-DUSE_GCC34_MMX)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/atKeynames.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,298 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.21 2003/10/09 11:43:59 pascal Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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-2003 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ */
+
+/* $XConsortium: atKeynames.h /main/11 1996/03/09 11:17:41 kaleb $ */
+
+#ifndef _ATKEYNAMES_H
+#define _ATKEYNAMES_H
+
+#define XK_TECHNICAL
+#define	XK_KATAKANA
+#include <X11/keysym.h>
+#include <X11/XF86keysym.h>
+
+#define GLYPHS_PER_KEY	4
+#define NUM_KEYCODES	248
+#define MIN_KEYCODE     8
+#define MAX_KEYCODE     (NUM_KEYCODES + MIN_KEYCODE - 1)
+
+#define AltMask		Mod1Mask
+#define NumLockMask	Mod2Mask
+#define AltLangMask	Mod3Mask
+#define KanaMask	Mod4Mask
+#define ScrollLockMask	Mod5Mask
+
+#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
+#define ModifierDown(k) ((keyc->state & (k)) == (k))
+
+/*
+ * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
+ *       sets of scancodes. Set3 can only be generated by a MF keyboard.
+ *       Set2 sends a makecode for keypress, and the same code prefixed by a
+ *       F0 for keyrelease. This is a little bit ugly to handle. Thus we use
+ *       here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
+ *       Bit 7 ist set if the key is released. The code E0 switches to a
+ *       different meaning to add the new MF cursorkeys, while not breaking old
+ *       applications. E1 is another special prefix. Since I assume that there
+ *       will be further versions of PC/XT scancode compatible keyboards, we
+ *       may be in trouble one day.
+ *
+ * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
+ *       2) Use the keyboards native set and translate it to common keysyms.
+ */
+
+/*
+ * definition of the AT84/MF101/MF102 Keyboard:
+ * ============================================================
+ *       Defined             Key Cap Glyphs       Pressed value
+ *      Key Name            Main       Also       (hex)    (dec)
+ *      ----------------   ---------- -------    ------    ------
+ */
+
+#define KEY_Escape       /* Escape                0x01  */    1  
+#define KEY_1            /* 1           !         0x02  */    2 
+#define KEY_2            /* 2           @         0x03  */    3 
+#define KEY_3            /* 3           #         0x04  */    4 
+#define KEY_4            /* 4           $         0x05  */    5 
+#define KEY_5            /* 5           %         0x06  */    6 
+#define KEY_6            /* 6           ^         0x07  */    7 
+#define KEY_7            /* 7           &         0x08  */    8 
+#define KEY_8            /* 8           *         0x09  */    9 
+#define KEY_9            /* 9           (         0x0a  */   10 
+#define KEY_0            /* 0           )         0x0b  */   11 
+#define KEY_Minus        /* - (Minus)   _ (Under) 0x0c  */   12
+#define KEY_Equal        /* = (Equal)   +         0x0d  */   13 
+#define KEY_BackSpace    /* Back Space            0x0e  */   14 
+#define KEY_Tab          /* Tab                   0x0f  */   15
+#define KEY_Q            /* Q                     0x10  */   16
+#define KEY_W            /* W                     0x11  */   17
+#define KEY_E            /* E                     0x12  */   18
+#define KEY_R            /* R                     0x13  */   19
+#define KEY_T            /* T                     0x14  */   20
+#define KEY_Y            /* Y                     0x15  */   21
+#define KEY_U            /* U                     0x16  */   22
+#define KEY_I            /* I                     0x17  */   23
+#define KEY_O            /* O                     0x18  */   24
+#define KEY_P            /* P                     0x19  */   25
+#define KEY_LBrace       /* [           {         0x1a  */   26
+#define KEY_RBrace       /* ]           }         0x1b  */   27 
+#define KEY_Enter        /* Enter                 0x1c  */   28
+#define KEY_LCtrl        /* Ctrl(left)            0x1d  */   29
+#define KEY_A            /* A                     0x1e  */   30
+#define KEY_S            /* S                     0x1f  */   31
+#define KEY_D            /* D                     0x20  */   32 
+#define KEY_F            /* F                     0x21  */   33
+#define KEY_G            /* G                     0x22  */   34
+#define KEY_H            /* H                     0x23  */   35
+#define KEY_J            /* J                     0x24  */   36
+#define KEY_K            /* K                     0x25  */   37
+#define KEY_L            /* L                     0x26  */   38
+#define KEY_SemiColon    /* ;(SemiColon) :(Colon) 0x27  */   39
+#define KEY_Quote        /* ' (Apostr)  " (Quote) 0x28  */   40
+#define KEY_Tilde        /* ` (Accent)  ~ (Tilde) 0x29  */   41
+#define KEY_ShiftL       /* Shift(left)           0x2a  */   42
+#define KEY_BSlash       /* \(BckSlash) |(VertBar)0x2b  */   43
+#define KEY_Z            /* Z                     0x2c  */   44
+#define KEY_X            /* X                     0x2d  */   45
+#define KEY_C            /* C                     0x2e  */   46
+#define KEY_V            /* V                     0x2f  */   47
+#define KEY_B            /* B                     0x30  */   48
+#define KEY_N            /* N                     0x31  */   49
+#define KEY_M            /* M                     0x32  */   50
+#define KEY_Comma        /* , (Comma)   < (Less)  0x33  */   51
+#define KEY_Period       /* . (Period)  >(Greater)0x34  */   52
+#define KEY_Slash        /* / (Slash)   ?         0x35  */   53
+#define KEY_ShiftR       /* Shift(right)          0x36  */   54
+#define KEY_KP_Multiply  /* *                     0x37  */   55
+#define KEY_Alt          /* Alt(left)             0x38  */   56
+#define KEY_Space        /*   (SpaceBar)          0x39  */   57
+#define KEY_CapsLock     /* CapsLock              0x3a  */   58
+#define KEY_F1           /* F1                    0x3b  */   59
+#define KEY_F2           /* F2                    0x3c  */   60
+#define KEY_F3           /* F3                    0x3d  */   61
+#define KEY_F4           /* F4                    0x3e  */   62
+#define KEY_F5           /* F5                    0x3f  */   63
+#define KEY_F6           /* F6                    0x40  */   64
+#define KEY_F7           /* F7                    0x41  */   65
+#define KEY_F8           /* F8                    0x42  */   66
+#define KEY_F9           /* F9                    0x43  */   67
+#define KEY_F10          /* F10                   0x44  */   68
+#define KEY_NumLock      /* NumLock               0x45  */   69
+#define KEY_ScrollLock   /* ScrollLock            0x46  */   70
+#define KEY_KP_7         /* 7           Home      0x47  */   71 
+#define KEY_KP_8         /* 8           Up        0x48  */   72 
+#define KEY_KP_9         /* 9           PgUp      0x49  */   73 
+#define KEY_KP_Minus     /* - (Minus)             0x4a  */   74
+#define KEY_KP_4         /* 4           Left      0x4b  */   75
+#define KEY_KP_5         /* 5                     0x4c  */   76
+#define KEY_KP_6         /* 6           Right     0x4d  */   77
+#define KEY_KP_Plus      /* + (Plus)              0x4e  */   78
+#define KEY_KP_1         /* 1           End       0x4f  */   79
+#define KEY_KP_2         /* 2           Down      0x50  */   80
+#define KEY_KP_3         /* 3           PgDown    0x51  */   81
+#define KEY_KP_0         /* 0           Insert    0x52  */   82
+#define KEY_KP_Decimal   /* . (Decimal) Delete    0x53  */   83 
+#define KEY_SysReqest    /* SysReqest             0x54  */   84
+                         /* NOTUSED               0x55  */
+#define KEY_Less         /* < (Less)   >(Greater) 0x56  */   86
+#define KEY_F11          /* F11                   0x57  */   87
+#define KEY_F12          /* F12                   0x58  */   88
+
+#define KEY_Prefix0      /* special               0x60  */   96
+#define KEY_Prefix1      /* specail               0x61  */   97
+
+/*
+ * The 'scancodes' below are generated by the server, because the MF101/102
+ * keyboard sends them as sequence of other scancodes
+ */
+#define KEY_Home         /* Home                  0x59  */   89
+#define KEY_Up           /* Up                    0x5a  */   90
+#define KEY_PgUp         /* PgUp                  0x5b  */   91
+#define KEY_Left         /* Left                  0x5c  */   92
+#define KEY_Begin        /* Begin                 0x5d  */   93
+#define KEY_Right        /* Right                 0x5e  */   94
+#define KEY_End          /* End                   0x5f  */   95
+#define KEY_Down         /* Down                  0x60  */   96
+#define KEY_PgDown       /* PgDown                0x61  */   97
+#define KEY_Insert       /* Insert                0x62  */   98
+#define KEY_Delete       /* Delete                0x63  */   99
+#define KEY_KP_Enter     /* Enter                 0x64  */  100
+#define KEY_RCtrl        /* Ctrl(right)           0x65  */  101
+#define KEY_Pause        /* Pause                 0x66  */  102
+#define KEY_Print        /* Print                 0x67  */  103
+#define KEY_KP_Divide    /* Divide                0x68  */  104
+#define KEY_AltLang      /* AtlLang(right)        0x69  */  105
+#define KEY_Break        /* Break                 0x6a  */  106
+#define KEY_LMeta        /* Left Meta             0x6b  */  107
+#define KEY_RMeta        /* Right Meta            0x6c  */  108
+#define KEY_Menu         /* Menu                  0x6d  */  109
+#define KEY_F13          /* F13                   0x6e  */  110
+#define KEY_F14          /* F14                   0x6f  */  111
+#define KEY_F15          /* F15                   0x70  */  112
+#define KEY_HKTG         /* Hirugana/Katakana tog 0x70  */  200 /* was 112 */
+#define KEY_F16          /* F16                   0x71  */  113
+#define KEY_F17          /* F17                   0x72  */  114
+#define KEY_KP_DEC       /* KP_DEC                0x73  */  115
+#define KEY_BSlash2      /* \           _         0x73  */  203 /* was 115 */
+#define KEY_KP_Equal	 /* Equal (Keypad)        0x76  */  118
+#define KEY_XFER         /* Kanji Transfer        0x79  */  121
+#define KEY_NFER         /* No Kanji Transfer     0x7b  */  123
+#define KEY_Yen          /* Yen                   0x7d  */  125
+
+#define KEY_Power        /* Power Key             0x84  */  132
+#define KEY_Mute         /* Audio Mute            0x85  */  133
+#define KEY_AudioLower   /* Audio Lower           0x86  */  134
+#define KEY_AudioRaise   /* Audio Raise           0x87  */  135
+#define KEY_Help         /* Help                  0x88  */  136
+#define KEY_L1           /* Stop                  0x89  */  137
+#define KEY_L2           /* Again                 0x8a  */  138
+#define KEY_L3           /* Props                 0x8b  */  139
+#define KEY_L4           /* Undo                  0x8c  */  140
+#define KEY_L5           /* Front                 0x8d  */  141
+#define KEY_L6           /* Copy                  0x8e  */  142
+#define KEY_L7           /* Open                  0x8f  */  143
+#define KEY_L8           /* Paste                 0x90  */  144
+#define KEY_L9           /* Find                  0x91  */  145
+#define KEY_L10          /* Cut                   0x92  */  146
+
+/*
+ * Fake 'scancodes' in the following ranges are generated for 2-byte
+ * codes not handled elsewhere.  These correspond to most extended keys
+ * on so-called "Internet" keyboards:
+ *
+ *	0x79-0x93
+ *	0x96-0xa1
+ *	0xa3-0xac
+ *	0xb1-0xb4
+ *	0xba-0xbd
+ *	0xc2
+ *	0xcc-0xd2
+ *	0xd6-0xf7
+ */
+
+/*
+ * Remapped 'scancodes' are generated for single-byte codes in the range
+ * 0x59-0x5f,0x62-0x76.  These are used for some extra keys on some keyboards.
+ */
+
+#define KEY_0x59		0x95
+#define KEY_0x5A		0xA2
+#define KEY_0x5B		0xAD
+#define KEY_0x5C		KEY_KP_EQUAL
+#define KEY_0x5D		0xAE
+#define KEY_0x5E		0xAF
+#define KEY_0x5F		0xB0
+#define KEY_0x62		0xB5
+#define KEY_0x63		0xB6
+#define KEY_0x64		0xB7
+#define KEY_0x65		0xB8
+#define KEY_0x66		0xB9
+#define KEY_0x67		0xBE
+#define KEY_0x68		0xBF
+#define KEY_0x69		0xC0
+#define KEY_0x6A		0xC1
+#define KEY_0x6B		0xC3
+#define KEY_0x6C		0xC4
+#define KEY_0x6D		0xC5
+#define KEY_0x6E		0xC6
+#define KEY_0x6F		0xC7
+#define KEY_0x70		0xC8
+#define KEY_0x71		0xC9
+#define KEY_0x72		0xCA
+#define KEY_0x73		0xCB
+#define KEY_0x74		0xD3
+#define KEY_0x75		0xD4
+#define KEY_0x76		0xD5
+
+/* These are for "notused" and "unknown" entries in translation maps. */
+#define KEY_NOTUSED	  0
+#define KEY_UNKNOWN	255
+
+#endif /* _ATKEYNAMES_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,46 @@
+XCOMM #########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM #########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/03 SMI"
+XCOMM
+
+XCOMM Sun software has traditionally worked better at 24-bit depth 
+XCOMM than 16-bit depth, so we override the default used in xf86Helper.c here
+
+  EXTRA_DEFINES = -DGLOBAL_DEFAULT_DEPTH=24 -DGLOBAL_DEFAULT_FBBPP=32
+
+XCOMM Hack to add modelines useful for Sun monitors and configurations
+XCOMM into the modelines list compiled into the X server
+modedefs:= MODEDEFSRCS += ../etc/sun_extramodes
+
+XCOMM Log info about Sun's Xorg package/patch versions in Xorg.*.log
+XCOMM see os-support/sunos/sun_loginfo.c
+#define BuilderString ""); extern void sunLogInfo(void); sunLogInfo(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,409 @@
+/* $DHD: xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c,v 1.15 2003/09/24 19:39:36 dawes Exp $ */
+/* $XdotOrg: $ */
+
+/*
+ * Copyright 2003 by David H. Dawes.
+ * Copyright 2003 by X-Oz Technologies.
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ * 
+ * Author: David Dawes <[email protected]>.
+ */
+
+/* Copyright 2006 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.
+ */ 
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c,v 1.2 2003/11/03 05:11:01 tsi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Sections for the default built-in configuration.
+ */
+
+#ifdef SUNSOFT
+#define BUILTIN_MODULE_SECTION \
+	"Section \"Module\"\n" \
+	"\tLoad\t\"extmod\"\n" \
+	"\tLoad\t\"dbe\"\n" \
+	"\tLoad\t\"glx\"\n" \
+	"\tLoad\t\"bitstream\"\n" \
+	"\tLoad\t\"type1\"\n" \
+	"\tLoad\t\"IA\"\n" \
+	"\tLoad\t\"xtsol\"\n" \
+	"EndSection\n\n"
+#else
+#define BUILTIN_MODULE_SECTION \
+	"Section \"Module\"\n" \
+	"\tLoad\t\"extmod\"\n" \
+	"\tLoad\t\"dbe\"\n" \
+	"\tLoad\t\"glx\"\n" \
+	"\tLoad\t\"freetype\"\n" \
+	"EndSection\n\n"
+#endif
+
+#define BUILTIN_DEVICE_NAME \
+	"\"Builtin Default %s Device %d\""
+
+#define BUILTIN_DEVICE_SECTION_PRE \
+	"Section \"Device\"\n" \
+	"\tIdentifier\t" BUILTIN_DEVICE_NAME "\n" \
+	"\tDriver\t\"%s\"\n"
+
+#define BUILTIN_DEVICE_SECTION_POST \
+	"EndSection\n\n"
+
+#define BUILTIN_DEVICE_SECTION \
+	BUILTIN_DEVICE_SECTION_PRE \
+	BUILTIN_DEVICE_SECTION_POST
+
+#define BUILTIN_MONITOR_NAME \
+	"\"Builtin Default Monitor\""
+
+#define BUILTIN_MONITOR_SECTION \
+	"Section \"Monitor\"\n" \
+	"\tIdentifier\t" BUILTIN_MONITOR_NAME "\n" \
+	"\tOption\t\"TargetRefresh\"\t\"75.0\"\n" \
+	"EndSection\n\n"
+
+#define BUILTIN_SCREEN_NAME \
+	"\"Builtin Default %s Screen %d\""
+
+#define BUILTIN_SCREEN_SECTION \
+	"Section \"Screen\"\n" \
+	"\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \
+	"\tDevice\t" BUILTIN_DEVICE_NAME "\n" \
+	"\tMonitor\t" BUILTIN_MONITOR_NAME "\n" \
+	"EndSection\n\n"
+
+#define BUILTIN_LAYOUT_SECTION_PRE \
+	"Section \"ServerLayout\"\n" \
+	"\tIdentifier\t\"Builtin Default Layout\"\n"
+
+#define BUILTIN_LAYOUT_SCREEN_LINE \
+	"\tScreen\t" BUILTIN_SCREEN_NAME "\n"
+
+#define BUILTIN_LAYOUT_SECTION_POST \
+	"EndSection\n\n"
+
+
+#ifndef GET_CONFIG_CMD
+#define GET_CONFIG_CMD			"getconfig"
+#endif
+
+#ifndef GETCONFIG_DIR
+#define GETCONFIG_DIR			PROJECTROOT "/lib/X11/getconfig"
+#endif
+
+#define GETCONFIG_WHITESPACE		" \t\n"
+
+static const char **builtinConfig = NULL;
+static int builtinLines = 0;
+static const char *deviceList[] = {
+	"fbdev",
+	"vesa",
+	"vga",
+	NULL
+};
+
+/*
+ * A built-in config file is stored as an array of strings, with each string
+ * representing a single line.  AppendToConfig() breaks up the string "s"
+ * into lines, and appends those lines it to builtinConfig.
+ */
+
+static void
+AppendToList(const char *s, const char ***list, int *lines)
+{
+    char *str, *newstr, *p;
+
+    str = xnfstrdup(s);
+    for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
+	(*lines)++;
+	*list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
+	newstr = xnfalloc(strlen(p) + 2);
+	strcpy(newstr, p);
+	strcat(newstr, "\n");
+	(*list)[*lines - 1] = newstr;
+	(*list)[*lines] = NULL;
+    }
+    xfree(str);
+}
+
+static void
+FreeList(const char ***list, int *lines)
+{
+    int i;
+
+    for (i = 0; i < *lines; i++) {
+	if ((*list)[i])
+	    xfree((*list)[i]);
+    }
+    xfree(*list);
+    *list = NULL;
+    *lines = 0;
+}
+
+static void
+FreeConfig(void)
+{
+    FreeList(&builtinConfig, &builtinLines);
+}
+
+static void
+AppendToConfig(const char *s)
+{
+    AppendToList(s, &builtinConfig, &builtinLines);
+}
+
+Bool
+xf86AutoConfig(void)
+{
+    const char **p;
+    char buf[1024];
+    pciVideoPtr *pciptr, info = NULL;
+    char *driver = NULL;
+    FILE *gp = NULL;
+    ConfigStatus ret;
+
+    /* Find the primary device, and get some information about it. */
+    if (xf86PciVideoInfo) {
+	for (pciptr = xf86PciVideoInfo; (info = *pciptr); pciptr++) {
+	    if (xf86IsPrimaryPci(info)) {
+		break;
+	    }
+	}
+	if (!info) {
+	    ErrorF("Primary device is not PCI\n");
+	}
+    } else {
+	ErrorF("xf86PciVideoInfo is not set\n");
+    }
+
+    if (info) {
+	char *tmp;
+	char *path = NULL, *a, *b;
+	char *searchPath = NULL;
+
+	/*
+	 * Look for the getconfig program first in the xf86ModulePath
+	 * directories, then in GETCONFIG_DIR, then in BINDIR.  If it
+	 * isn't found in any of those locations, just use the normal
+	 * search path.
+	 */
+
+	if (xf86ModulePath) {
+	    a = xnfstrdup(xf86ModulePath);
+	    b = strtok(a, ",");
+	    while (b) {
+		path = xnfrealloc(path,
+				  strlen(b) + 1 + strlen(GET_CONFIG_CMD) + 1);
+		sprintf(path, "%s/%s", b, GET_CONFIG_CMD);
+		if (access(path, X_OK) == 0)
+		    break;
+		b = strtok(NULL, ",");
+	    }
+	    if (!b) {
+		xfree(path);
+		path = NULL;
+	    }
+	    xfree(a);
+	}
+
+	if (!path) {
+	    path = xnfstrdup(GETCONFIG_DIR "/" GET_CONFIG_CMD);
+	    if (access(path, X_OK) != 0) {
+		xfree(path);
+		path = NULL;
+	    }
+	}
+
+#ifdef BINDIR
+	if (!path) {
+	    path = xnfstrdup(BINDIR "/" GET_CONFIG_CMD);
+	    if (access(path, X_OK) != 0) {
+		xfree(path);
+		path = NULL;
+	    }
+	}
+#endif
+
+	if (!path)
+	    path = xnfstrdup(GET_CONFIG_CMD);
+
+	/*
+	 * Build up the config file directory search path:
+	 *
+	 * /etc/X11
+	 * PROJECTROOT/etc/X11
+	 * xf86ModulePath
+	 * PROJECTROOT/lib/X11/getconfig  (GETCONFIG_DIR)
+	 */
+
+	searchPath = xnfalloc(strlen("/etc/X11") + 1 +
+			      strlen(PROJECTROOT "/etc/X11") + 1 +
+			      (xf86ModulePath ? strlen(xf86ModulePath) : 0)
+				+ 1 +
+			      strlen(GETCONFIG_DIR) + 1);
+	strcpy(searchPath, "/etc/X11," PROJECTROOT "/etc/X11,");
+	if (xf86ModulePath && *xf86ModulePath) {
+	    strcat(searchPath, xf86ModulePath);
+	    strcat(searchPath, ",");
+	}
+	strcat(searchPath, GETCONFIG_DIR);
+
+	ErrorF("xf86AutoConfig: Primary PCI is %d:%d:%d\n",
+	       info->bus, info->device, info->func);
+
+	snprintf(buf, sizeof(buf), "%s"
+#ifdef DEBUG
+		 " -D"
+#endif
+		 " -X %d"
+		 " -I %s"
+		 " -v 0x%04x -d 0x%04x -r 0x%02x -s 0x%04x"
+		 " -b 0x%04x -c 0x%04x",
+		 path,
+		 (unsigned int)xorgGetVersion(),
+		 searchPath,
+		 info->vendor, info->chipType, info->chipRev,
+		 info->subsysVendor, info->subsysCard,
+		 info->class << 8 | info->subclass);
+	ErrorF("Running \"%s\"\n", buf);
+	gp = Popen(buf, "r");
+	if (gp) {
+	    if (fgets(buf, sizeof(buf) - 1, gp)) {
+		buf[strlen(buf) - 1] = '\0';
+		tmp = strtok(buf, GETCONFIG_WHITESPACE);
+		if (tmp)
+		    driver = xnfstrdup(tmp);
+	    }
+	}
+	xfree(path);
+	xfree(searchPath);
+    }
+
+    AppendToConfig(BUILTIN_MODULE_SECTION);
+    AppendToConfig(BUILTIN_MONITOR_SECTION);
+
+    if (driver) {
+	snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE,
+		 driver, 0, driver);
+	AppendToConfig(buf);
+	ErrorF("New driver is \"%s\"\n", driver);
+	buf[0] = '\t';
+	while (fgets(buf + 1, sizeof(buf) - 2, gp)) {
+	    AppendToConfig(buf);
+	    ErrorF("Extra line: %s", buf);
+	}
+	AppendToConfig(BUILTIN_DEVICE_SECTION_POST);
+	snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION,
+		 driver, 0, driver, 0);
+	AppendToConfig(buf);
+    }
+
+    if (gp)
+	Pclose(gp);
+
+    for (p = deviceList; *p; p++) {
+	snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p);
+	AppendToConfig(buf);
+	snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0);
+	AppendToConfig(buf);
+    }
+
+    AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE);
+    if (driver) {
+	snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, driver, 0);
+	AppendToConfig(buf);
+    }
+    for (p = deviceList; *p; p++) {
+	snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
+	AppendToConfig(buf);
+    }
+    AppendToConfig(BUILTIN_LAYOUT_SECTION_POST);
+
+#ifdef BUILTIN_EXTRA
+    AppendToConfig(BUILTIN_EXTRA);
+#endif
+
+    if (driver)
+	xfree(driver);
+
+    xf86MsgVerb(X_DEFAULT, 0,
+		"Using default built-in configuration (%d lines)\n",
+		builtinLines);
+
+    xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n");
+    for (p = builtinConfig; *p; p++)
+	xf86ErrorFVerb(3, "\t%s", *p);
+    xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
+    
+    xf86setBuiltinConfig(builtinConfig);
+    ret = xf86HandleConfigFile(TRUE);
+    FreeConfig();
+    switch(ret) {
+    case CONFIG_OK:
+	return TRUE;
+    default:
+	xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
+	return FALSE;
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Config.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2740 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 1.21 2005/12/20 22:30:50 alanc Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.276 2003/10/08 14:58:26 dawes Exp $ */
+
+
+/*
+ * Loosely based on code bearing the following copyright:
+ *
+ *   Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+
+/*
+ * Copyright 1992-2003 by The XFree86 Project, Inc.
+ * Copyright 1997 by Metro Link, 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ */
+
+/*
+ *
+ * Authors:
+ *	Dirk Hohndel <[email protected]>
+ *	David Dawes <[email protected]>
+ *      Marc La France <[email protected]>
+ *      Egbert Eich <[email protected]>
+ *      ... and others
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XF86DRI
+#include <sys/types.h>
+#include <grp.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "globals.h"
+
+#ifdef XINPUT
+#include "xf86Xinput.h"
+extern DeviceAssocRec mouse_assoc;
+#endif
+
+#ifdef XKB
+#define XKB_IN_SERVER
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+#ifdef RENDER
+#include "picture.h"
+#endif
+
+#if (defined(i386) || defined(__i386__)) && \
+    (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
+     defined(__NetBSD__) || defined(linux) || \
+     (defined(SVR4) && !defined(sun)) || defined(__GNU__))
+#define SUPPORT_PC98
+#endif
+
+/*
+ * These paths define the way the config file search is done.  The escape
+ * sequences are documented in parser/scan.c.
+ */
+#ifndef ROOT_CONFIGPATH
+#define ROOT_CONFIGPATH	"%A," "%R," \
+			"/etc/X11/%R," "%P/etc/X11/%R," \
+			"%E," "%F," \
+			"/etc/X11/%F," "%P/etc/X11/%F," \
+			"%D/%X," \
+			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X"
+#endif
+#ifndef USER_CONFIGPATH
+#define USER_CONFIGPATH	"/etc/X11/%S," "%P/etc/X11/%S," \
+			"/etc/X11/%G," "%P/etc/X11/%G," \
+			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X"
+#endif
+#ifndef PROJECTROOT
+#define PROJECTROOT	"/usr/X11R6"
+#endif
+
+static char *fontPath = NULL;
+
+/* Forward declarations */
+static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
+			 int scrnum, MessageType from);
+static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
+static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
+			 Bool active);
+static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input,
+			MessageType from);
+static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
+static Bool addDefaultModes(MonPtr monitorp);
+#ifdef XF86DRI
+static Bool configDRI(XF86ConfDRIPtr drip);
+#endif
+static Bool configExtensions(XF86ConfExtensionsPtr conf_ext);
+
+/*
+ * xf86GetPathElem --
+ *	Extract a single element from the font path string starting at
+ *	pnt.  The font path element will be returned, and pnt will be
+ *	updated to point to the start of the next element, or set to
+ *	NULL if there are no more.
+ */
+static char *
+xf86GetPathElem(char **pnt)
+{
+  char *p1;
+
+  p1 = *pnt;
+  *pnt = index(*pnt, ',');
+  if (*pnt != NULL) {
+    **pnt = '\0';
+    *pnt += 1;
+  }
+  return(p1);
+}
+
+/*
+ * xf86ValidateFontPath --
+ *	Validates the user-specified font path.  Each element that
+ *	begins with a '/' is checked to make sure the directory exists.
+ *	If the directory exists, the existence of a file named 'fonts.dir'
+ *	is checked.  If either check fails, an error is printed and the
+ *	element is removed from the font path.
+ */
+
+#define DIR_FILE "/fonts.dir"
+static char *
+xf86ValidateFontPath(char *path)
+{
+  char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
+  struct stat stat_buf;
+  int flag;
+  int dirlen;
+
+  tmp_path = xcalloc(1,strlen(path)+1);
+  out_pnt = tmp_path;
+  path_elem = NULL;
+  next = path;
+  while (next != NULL) {
+    path_elem = xf86GetPathElem(&next);
+    if (*path_elem == '/') {
+#ifndef __UNIXOS2__
+      dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
+      if ((p1 = strchr(path_elem, ':')) != 0)
+#else
+    /* OS/2 must prepend X11ROOT */
+      path_elem = (char*)__XOS2RedirRoot(path_elem);
+      dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
+      if (p1 = strchr(path_elem+2, ':'))
+#endif
+	dirlen = p1 - path_elem;
+      else
+	dirlen = strlen(path_elem);
+      strncpy(dir_elem, path_elem, dirlen);
+      dir_elem[dirlen] = '\0';
+      flag = stat(dir_elem, &stat_buf);
+      if (flag == 0)
+	if (!S_ISDIR(stat_buf.st_mode))
+	  flag = -1;
+      if (flag != 0) {
+        xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem);
+	xf86ErrorF("\tEntry deleted from font path.\n");
+	xfree(dir_elem);
+	continue;
+      }
+      else {
+	p1 = xnfalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
+	strcpy(p1, dir_elem);
+	strcat(p1, DIR_FILE);
+	flag = stat(p1, &stat_buf);
+	if (flag == 0)
+	  if (!S_ISREG(stat_buf.st_mode))
+	    flag = -1;
+#ifndef __UNIXOS2__
+	xfree(p1);
+#endif
+	if (flag != 0) {
+	  xf86Msg(X_WARNING,
+		  "`fonts.dir' not found (or not valid) in \"%s\".\n", 
+		  dir_elem);
+	  xf86ErrorF("\tEntry deleted from font path.\n");
+	  xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
+	  xfree(dir_elem);
+	  continue;
+	}
+      }
+      xfree(dir_elem);
+    }
+
+    /*
+     * Either an OK directory, or a font server name.  So add it to
+     * the path.
+     */
+    if (out_pnt != tmp_path)
+      *out_pnt++ = ',';
+    strcat(out_pnt, path_elem);
+    out_pnt += strlen(path_elem);
+  }
+  return(tmp_path);
+}
+
+
+/*
+ * use the datastructure that the parser provides and pick out the parts
+ * that we need at this point
+ */
+char **
+xf86ModulelistFromConfig(pointer **optlist)
+{
+    int count = 0;
+    char **modulearray;
+    pointer *optarray;
+    XF86LoadPtr modp;
+    
+    /*
+     * make sure the config file has been parsed and that we have a
+     * ModulePath set; if no ModulePath was given, use the default
+     * ModulePath
+     */
+    if (xf86configptr == NULL) {
+        xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+        return NULL;
+    }
+    
+    if (xf86configptr->conf_modules) {
+	/*
+	 * Walk the list of modules in the "Module" section to determine how
+	 * many we have.
+	 */
+	modp = xf86configptr->conf_modules->mod_load_lst;
+	while (modp) {
+	    count++;
+	    modp = (XF86LoadPtr) modp->list.next;
+	}
+    }
+    if (count == 0)
+	return NULL;
+
+    /*
+     * allocate the memory and walk the list again to fill in the pointers
+     */
+    modulearray = xnfalloc((count + 1) * sizeof(char*));
+    optarray = xnfalloc((count + 1) * sizeof(pointer));
+    count = 0;
+    if (xf86configptr->conf_modules) {
+	modp = xf86configptr->conf_modules->mod_load_lst;
+	while (modp) {
+	    modulearray[count] = modp->load_name;
+	    optarray[count] = modp->load_opt;
+	    count++;
+	    modp = (XF86LoadPtr) modp->list.next;
+	}
+    }
+    modulearray[count] = NULL;
+    optarray[count] = NULL;
+    if (optlist)
+	*optlist = optarray;
+    else
+	xfree(optarray);
+    return modulearray;
+}
+
+
+char **
+xf86DriverlistFromConfig()
+{
+    int count = 0;
+    int j;
+    char **modulearray;
+    screenLayoutPtr slp;
+    
+    /*
+     * make sure the config file has been parsed and that we have a
+     * ModulePath set; if no ModulePath was given, use the default
+     * ModulePath
+     */
+    if (xf86configptr == NULL) {
+        xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+        return NULL;
+    }
+    
+    /*
+     * Walk the list of driver lines in active "Device" sections to
+     * determine now many implicitly loaded modules there are.
+     *
+     */
+    if (xf86ConfigLayout.screens) {
+        slp = xf86ConfigLayout.screens;
+        while ((slp++)->screen) {
+	    count++;
+        }
+    }
+
+    /*
+     * Handle the set of inactive "Device" sections.
+     */
+    j = 0;
+    while (xf86ConfigLayout.inactives[j++].identifier)
+	count++;
+
+    if (count == 0)
+	return NULL;
+
+    /*
+     * allocate the memory and walk the list again to fill in the pointers
+     */
+    modulearray = xnfalloc((count + 1) * sizeof(char*));
+    count = 0;
+    slp = xf86ConfigLayout.screens;
+    while (slp->screen) {
+	modulearray[count] = slp->screen->device->driver;
+	count++;
+	slp++;
+    }
+
+    j = 0;
+
+    while (xf86ConfigLayout.inactives[j].identifier) 
+	modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
+
+    modulearray[count] = NULL;
+
+    /* Remove duplicates */
+    for (count = 0; modulearray[count] != NULL; count++) {
+	int i;
+
+	for (i = 0; i < count; i++)
+	    if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+		modulearray[count] = "";
+		break;
+	    }
+    }
+    return modulearray;
+}
+
+
+Bool
+xf86BuiltinInputDriver(const char *name)
+{
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+    if (xf86NameCmp(name, "keyboard") == 0)
+	return TRUE;
+    else
+#endif
+	return FALSE;
+}
+
+char **
+xf86InputDriverlistFromConfig()
+{
+    int count = 0;
+    char **modulearray;
+    IDevPtr idp;
+    
+    /*
+     * make sure the config file has been parsed and that we have a
+     * ModulePath set; if no ModulePath was given, use the default
+     * ModulePath
+     */
+    if (xf86configptr == NULL) {
+        xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+        return NULL;
+    }
+    
+    /*
+     * Walk the list of driver lines in active "InputDevice" sections to
+     * determine now many implicitly loaded modules there are.
+     */
+    if (xf86ConfigLayout.inputs) {
+        idp = xf86ConfigLayout.inputs;
+        while (idp->identifier) {
+	    if (!xf86BuiltinInputDriver(idp->driver))
+	        count++;
+	    idp++;
+        }
+    }
+
+    if (count == 0)
+	return NULL;
+
+    /*
+     * allocate the memory and walk the list again to fill in the pointers
+     */
+    modulearray = xnfalloc((count + 1) * sizeof(char*));
+    count = 0;
+    idp = xf86ConfigLayout.inputs;
+    while (idp->identifier) {
+	if (!xf86BuiltinInputDriver(idp->driver)) {
+	    modulearray[count] = idp->driver;
+	    count++;
+	}
+	idp++;
+    }
+    modulearray[count] = NULL;
+
+    /* Remove duplicates */
+    for (count = 0; modulearray[count] != NULL; count++) {
+	int i;
+
+	for (i = 0; i < count; i++)
+	    if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+		modulearray[count] = "";
+		break;
+	    }
+    }
+    return modulearray;
+}
+
+static void
+fixup_video_driver_list(char **drivers)
+{
+    static const char *fallback[5] = { "vga", "vesa", "fbdev", "wsfb", NULL };
+    char **end, **drv;
+    char *x;
+    char **ati, **atimisc;
+    int i;
+
+    /* walk to the end of the list */
+    for (end = drivers; *end && **end; end++) ;
+    end--;
+
+    /*
+     * for each of the fallback drivers, if we find it in the list,
+     * swap it with the last available non-fallback driver.
+     */
+    for (i = 0; fallback[i]; i++) {
+        for (drv = drivers; drv != end; drv++) {
+            if (strstr(*drv, fallback[i])) {
+                x = *drv; *drv = *end; *end = x;
+                end--;
+                break;
+            }
+        }
+    }
+    /*
+     * since the ati wrapper driver is gross and awful, sort ati before
+     * atimisc, which makes sure all the ati symbols are visible in xorgcfg.
+     */
+    for (drv = drivers; drv != end; drv++) {
+        if (!strcmp(*drv, "atimisc")) {
+            atimisc = drv;
+            for (drv = atimisc; drv != end; drv++) {
+                if (!strcmp(*drv, "ati")) {
+                    ati = drv;
+                    x = *ati; *ati = *atimisc; *atimisc = x;
+                    return;
+                }
+            }
+            /* if we get here, ati was already ahead of atimisc */
+	    return;
+        }
+    }
+}
+
+
+/*
+ * Generate a compiled-in list of driver names.  This is used to produce a
+ * consistent probe order.  For the loader server, we also look for vendor-
+ * provided modules, pre-pending them to our own list.
+ */
+static char **
+GenerateDriverlist(char * dirname, char * drivernames)
+{
+#ifdef XFree86LOADER
+    char **ret;
+    char *subdirs[] = { dirname, NULL };
+    static const char *patlist[] = {"(.*)_drv\\.so", "(.*)_drv\\.o", NULL};
+    ret = LoaderListDirs(subdirs, patlist);
+    
+    /* fix up the probe order for video drivers */
+    if (strstr(dirname, "drivers"))
+        fixup_video_driver_list(ret);
+
+    return ret;
+#else /* non-loadable server */
+    char *cp, **driverlist;
+    int count;
+
+    /* Count the number needed */
+    count = 0;
+    cp = drivernames;
+    while (*cp) {
+	while (*cp && isspace(*cp)) cp++;
+	if (!*cp) break;
+	count++;
+	while (*cp && !isspace(*cp)) cp++;
+    }
+
+    if (!count)
+	return NULL;
+
+    /* Now allocate the array of pointers to 0-terminated driver names */
+    driverlist = (char **)xnfalloc((count + 1) * sizeof(char *));
+    count = 0;
+    cp = drivernames;
+    while (*cp) {
+	while (*cp && isspace(*cp)) cp++;
+	if (!*cp) break;
+	driverlist[count++] = cp;
+	while (*cp && !isspace(*cp)) cp++;
+	if (!*cp) break;
+	*cp++ = 0;
+    }
+    driverlist[count] = NULL;
+
+    return driverlist;
+#endif
+}
+
+
+char **
+xf86DriverlistFromCompile(void)
+{
+    static char **driverlist = NULL;
+    static Bool generated = FALSE;
+
+    /* This string is modified in-place */
+    static char drivernames[] = DRIVERS;
+
+    if (!generated) {
+        generated = TRUE;
+        driverlist = GenerateDriverlist("drivers", drivernames);
+    }
+
+    return driverlist;
+}
+
+
+char **
+xf86InputDriverlistFromCompile(void)
+{
+    static char **driverlist = NULL;
+    static Bool generated = FALSE;
+
+    /* This string is modified in-place */
+    static char drivernames[] = IDRIVERS;
+
+    if (!generated) {
+        generated = TRUE;
+	driverlist = GenerateDriverlist("input", drivernames);
+    }
+
+    return driverlist;
+}
+
+
+/*
+ * xf86ConfigError --
+ *      Print a READABLE ErrorMessage!!!  All information that is 
+ *      available is printed.
+ */
+static void
+xf86ConfigError(char *msg, ...)
+{
+    va_list ap;
+
+    ErrorF("\nConfig Error:\n");
+    va_start(ap, msg);
+    VErrorF(msg, ap);
+    va_end(ap);
+    ErrorF("\n");
+    return;
+}
+
+static Bool
+configFiles(XF86ConfFilesPtr fileconf)
+{
+  MessageType pathFrom = X_DEFAULT;
+
+  /* FontPath */
+
+  /* Try XF86Config FontPath first */
+  if (!xf86fpFlag) {
+   if (fileconf) {
+    if (fileconf->file_fontpath) {
+      char *f = xf86ValidateFontPath(fileconf->file_fontpath);
+      pathFrom = X_CONFIG;
+      if (*f)
+        defaultFontPath = f;
+      else {
+	xf86Msg(X_WARNING,
+	    "FontPath is completely invalid.  Using compiled-in default.\n");
+        fontPath = NULL;
+        pathFrom = X_DEFAULT;
+      }
+    } 
+   } else {
+      xf86Msg(X_WARNING,
+	    "No FontPath specified.  Using compiled-in default.\n");
+      pathFrom = X_DEFAULT;
+   }
+  } else {
+    /* Use fontpath specified with '-fp' */
+    if (fontPath)
+    {
+      fontPath = NULL;
+    }
+    pathFrom = X_CMDLINE;
+  }
+  if (!fileconf) {
+      /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
+       could be static, so we make a copy. */
+    char *f = xnfalloc(strlen(defaultFontPath) + 1);
+    f[0] = '\0';
+    strcpy (f, defaultFontPath);
+    defaultFontPath = xf86ValidateFontPath(f);
+    xfree(f);
+  } else {
+   if (fileconf) {
+    if (!fileconf->file_fontpath) {
+      /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
+       could be static, so we make a copy. */
+     char *f = xnfalloc(strlen(defaultFontPath) + 1);
+     f[0] = '\0';
+     strcpy (f, defaultFontPath);
+     defaultFontPath = xf86ValidateFontPath(f);
+     xfree(f);
+    }
+   }
+  }
+
+  /* If defaultFontPath is still empty, exit here */
+
+  if (! *defaultFontPath)
+    FatalError("No valid FontPath could be found.");
+
+  xf86Msg(pathFrom, "FontPath set to \"%s\"\n", defaultFontPath);
+
+  /* RgbPath */
+
+  pathFrom = X_DEFAULT;
+
+  if (xf86coFlag)
+    pathFrom = X_CMDLINE;
+  else if (fileconf) {
+    if (fileconf->file_rgbpath) {
+      rgbPath = fileconf->file_rgbpath;
+      pathFrom = X_CONFIG;
+    }
+  }
+
+  xf86Msg(pathFrom, "RgbPath set to \"%s\"\n", rgbPath);
+
+  if (fileconf && fileconf->file_inputdevs) {
+      xf86InputDeviceList = fileconf->file_inputdevs;
+      xf86Msg(X_CONFIG, "Input device list set to \"%s\"\n",
+	  xf86InputDeviceList);
+  }
+  
+  
+#ifdef XFree86LOADER
+  /* ModulePath */
+
+  if (fileconf) {
+    if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
+      xf86ModulePath = fileconf->file_modulepath;
+      xf86ModPathFrom = X_CONFIG;
+    }
+  }
+
+  xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
+#endif
+
+#if 0
+  /* LogFile */
+  /*
+   * XXX The problem with this is that the log file is already open.
+   * One option might be to copy the exiting contents to the new location.
+   * and re-open it.  The down side is that the default location would
+   * already have been overwritten.  Another option would be to start with
+   * unique temporary location, then copy it once the correct name is known.
+   * A problem with this is what happens if the server exits before that
+   * happens.
+   */
+  if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
+    xf86LogFile = fileconf->file_logfile;
+    xf86LogFileFrom = X_CONFIG;
+  }
+#endif
+
+  return TRUE;
+}
+
+typedef enum {
+    FLAG_NOTRAPSIGNALS,
+    FLAG_DONTVTSWITCH,
+    FLAG_DONTZAP,
+    FLAG_DONTZOOM,
+    FLAG_DISABLEVIDMODE,
+    FLAG_ALLOWNONLOCAL,
+    FLAG_DISABLEMODINDEV,
+    FLAG_MODINDEVALLOWNONLOCAL,
+    FLAG_ALLOWMOUSEOPENFAIL,
+    FLAG_VTINIT,
+    FLAG_VTSYSREQ,
+    FLAG_XKBDISABLE,
+    FLAG_PCIPROBE1,
+    FLAG_PCIPROBE2,
+    FLAG_PCIFORCECONFIG1,
+    FLAG_PCIFORCECONFIG2,
+    FLAG_PCIFORCENONE,
+    FLAG_PCIOSCONFIG,
+    FLAG_SAVER_BLANKTIME,
+    FLAG_DPMS_STANDBYTIME,
+    FLAG_DPMS_SUSPENDTIME,
+    FLAG_DPMS_OFFTIME,
+    FLAG_PIXMAP,
+    FLAG_PC98,
+    FLAG_ESTIMATE_SIZES_AGGRESSIVELY,
+    FLAG_NOPM,
+    FLAG_XINERAMA,
+    FLAG_ALLOW_DEACTIVATE_GRABS,
+    FLAG_ALLOW_CLOSEDOWN_GRABS,
+    FLAG_LOG,
+    FLAG_RENDER_COLORMAP_MODE,
+    FLAG_HANDLE_SPECIAL_KEYS,
+    FLAG_RANDR
+} FlagValues;
+   
+static OptionInfoRec FlagOptions[] = {
+  { FLAG_NOTRAPSIGNALS,		"NoTrapSignals",		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_DONTVTSWITCH,		"DontVTSwitch",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_DONTZAP,		"DontZap",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_DONTZOOM,		"DontZoom",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_DISABLEVIDMODE,	"DisableVidModeExtension",	OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_ALLOWNONLOCAL,		"AllowNonLocalXvidtune",	OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_DISABLEMODINDEV,	"DisableModInDev",		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_MODINDEVALLOWNONLOCAL,	"AllowNonLocalModInDev",	OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_ALLOWMOUSEOPENFAIL,	"AllowMouseOpenFail",		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_VTINIT,		"VTInit",			OPTV_STRING,
+	{0}, FALSE },
+  { FLAG_VTSYSREQ,		"VTSysReq",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_XKBDISABLE,		"XkbDisable",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_PCIPROBE1,		"PciProbe1"		,	OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_PCIPROBE2,		"PciProbe2",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_PCIFORCECONFIG1,	"PciForceConfig1",		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_PCIFORCECONFIG2,	"PciForceConfig2",		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_PCIFORCENONE,		"PciForceNone",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_PCIOSCONFIG,	        "PciOsConfig",   		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_SAVER_BLANKTIME,	"BlankTime"		,	OPTV_INTEGER,
+	{0}, FALSE },
+  { FLAG_DPMS_STANDBYTIME,	"StandbyTime",			OPTV_INTEGER,
+	{0}, FALSE },
+  { FLAG_DPMS_SUSPENDTIME,	"SuspendTime",			OPTV_INTEGER,
+	{0}, FALSE },
+  { FLAG_DPMS_OFFTIME,		"OffTime",			OPTV_INTEGER,
+	{0}, FALSE },
+  { FLAG_PIXMAP,		"Pixmap",			OPTV_INTEGER,
+	{0}, FALSE },
+  { FLAG_PC98,			"PC98",				OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_ESTIMATE_SIZES_AGGRESSIVELY,"EstimateSizesAggressively",OPTV_INTEGER,
+	{0}, FALSE },
+  { FLAG_NOPM,			"NoPM",				OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_XINERAMA,		"Xinerama",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_ALLOW_DEACTIVATE_GRABS,"AllowDeactivateGrabs",		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_ALLOW_CLOSEDOWN_GRABS, "AllowClosedownGrabs",		OPTV_BOOLEAN,
+	{0}, FALSE },
+  { FLAG_LOG,			"Log",				OPTV_STRING,
+	{0}, FALSE },
+  { FLAG_RENDER_COLORMAP_MODE,	"RenderColormapMode",		OPTV_STRING,
+        {0}, FALSE },
+  { FLAG_HANDLE_SPECIAL_KEYS,	"HandleSpecialKeys",		OPTV_STRING,
+        {0}, FALSE },
+  { FLAG_RANDR,			"RandR",			OPTV_BOOLEAN,
+	{0}, FALSE },
+  { -1,				NULL,				OPTV_NONE,
+	{0}, FALSE },
+};
+
+#if defined(i386) || defined(__i386__)
+static Bool
+detectPC98(void)
+{
+#ifdef SUPPORT_PC98
+    unsigned char buf[2];
+
+    if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2)
+	return FALSE;
+    if ((buf[0] == 0x98) && (buf[1] == 0x21))
+	return TRUE;
+    else
+	return FALSE;
+#else
+    return FALSE;
+#endif
+}
+#endif /* __i386__ */
+
+static Bool
+configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
+{
+    XF86OptionPtr optp, tmp;
+    int i;
+    Pix24Flags pix24 = Pix24DontCare;
+    Bool value;
+    MessageType from;
+
+    /*
+     * Merge the ServerLayout and ServerFlags options.  The former have
+     * precedence over the latter.
+     */
+    optp = NULL;
+    if (flagsconf && flagsconf->flg_option_lst)
+	optp = xf86optionListDup(flagsconf->flg_option_lst);
+    if (layoutopts) {
+	tmp = xf86optionListDup(layoutopts);
+	if (optp)
+	    optp = xf86optionListMerge(optp, tmp);
+	else
+	    optp = tmp;
+    }
+
+    xf86ProcessOptions(-1, optp, FlagOptions);
+
+    xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
+    xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
+    xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
+    xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
+
+    xf86GetOptValBool(FlagOptions, FLAG_ALLOW_DEACTIVATE_GRABS,
+		      &(xf86Info.grabInfo.allowDeactivate));
+    xf86GetOptValBool(FlagOptions, FLAG_ALLOW_CLOSEDOWN_GRABS,
+		      &(xf86Info.grabInfo.allowClosedown));
+
+    /*
+     * Set things up based on the config file information.  Some of these
+     * settings may be overridden later when the command line options are
+     * checked.
+     */
+#ifdef XF86VIDMODE
+    if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
+	xf86Info.vidModeEnabled = !value;
+    if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
+	xf86Info.vidModeAllowNonLocal = value;
+#endif
+
+#ifdef XF86MISC
+    if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEMODINDEV, &value))
+	xf86Info.miscModInDevEnabled = !value;
+    if (xf86GetOptValBool(FlagOptions, FLAG_MODINDEVALLOWNONLOCAL, &value))
+	xf86Info.miscModInDevAllowNonLocal = value;
+#endif
+
+    if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
+	xf86Info.allowMouseOpenFail = value;
+
+    if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) {
+#ifdef USE_VT_SYSREQ
+	xf86Info.vtSysreq = value;
+	xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled");
+#else
+	if (value)
+	    xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n");
+#endif
+    }
+
+    if (xf86GetOptValBool(FlagOptions, FLAG_XKBDISABLE, &value)) {
+#ifdef XKB
+	noXkbExtension = value;
+	xf86Msg(X_CONFIG, "Xkb %s\n", value ? "disabled" : "enabled");
+#else
+	if (!value)
+	    xf86Msg(X_WARNING, "Xserver doesn't support XKB\n");
+#endif
+    }
+
+    xf86Info.vtinit = xf86GetOptValString(FlagOptions, FLAG_VTINIT);
+
+    if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE1))
+	xf86Info.pciFlags = PCIProbe1;
+    if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE2))
+	xf86Info.pciFlags = PCIProbe2;
+    if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG1))
+	xf86Info.pciFlags = PCIForceConfig1;
+    if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG2))
+	xf86Info.pciFlags = PCIForceConfig2;
+    if (xf86IsOptionSet(FlagOptions, FLAG_PCIOSCONFIG))
+	xf86Info.pciFlags = PCIOsConfig;
+    if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCENONE))
+	xf86Info.pciFlags = PCIForceNone;
+
+    xf86Info.pmFlag = TRUE;
+    if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value)) 
+	xf86Info.pmFlag = !value;
+    {
+	const char *s;
+	if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
+	    if (!xf86NameCmp(s,"flush")) {
+		xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
+		xf86Info.log = LogFlush;
+		LogSetParameter(XLOG_FLUSH, TRUE);
+	    } else if (!xf86NameCmp(s,"sync")) {
+		xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
+		xf86Info.log = LogSync;
+		LogSetParameter(XLOG_SYNC, TRUE);
+	    } else {
+		xf86Msg(X_WARNING,"Unknown Log option\n");
+	    }
+        }
+    }
+    
+#ifdef RENDER
+    {
+	const char *s;
+
+	if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
+	    int policy = PictureParseCmapPolicy (s);
+	    if (policy == PictureCmapPolicyInvalid)
+		xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
+	    else
+	    {
+		xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
+		PictureCmapPolicy = policy;
+	    }
+	}
+    }
+#endif
+    {
+	const char *s;
+	if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) {
+	    if (!xf86NameCmp(s,"always")) {
+		xf86Msg(X_CONFIG, "Always handling special keys in DDX\n");
+		xf86Info.ddxSpecialKeys = SKAlways;
+	    } else if (!xf86NameCmp(s,"whenneeded")) {
+		xf86Msg(X_CONFIG, "Special keys handled in DDX only if needed\n");
+		xf86Info.ddxSpecialKeys = SKWhenNeeded;
+	    } else if (!xf86NameCmp(s,"never")) {
+		xf86Msg(X_CONFIG, "Never handling special keys in DDX\n");
+		xf86Info.ddxSpecialKeys = SKNever;
+	    } else {
+		xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n");
+	    }
+        }
+    }
+#ifdef RANDR
+    xf86Info.disableRandR = FALSE;
+    xf86Info.randRFrom = X_DEFAULT;
+    if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
+	xf86Info.disableRandR = !value;
+	xf86Info.randRFrom = X_CONFIG;
+    }
+#endif
+    i = -1;
+    xf86GetOptValInteger(FlagOptions, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, &i);
+    if (i >= 0)
+	xf86Info.estimateSizesAggressively = i;
+    else
+	xf86Info.estimateSizesAggressively = 0;
+
+/* Make sure that timers don't overflow CARD32's after multiplying */
+#define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
+
+    i = -1;
+    xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
+    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+	ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
+    else if (i != -1)
+	xf86ConfigError("BlankTime value %d outside legal range of 0 - %d minutes",
+			i, MAX_TIME_IN_MIN);
+
+#ifdef DPMSExtension
+    i = -1;
+    xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
+    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+	DPMSStandbyTime = defaultDPMSStandbyTime = i * MILLI_PER_MIN;
+    else if (i != -1)
+	xf86ConfigError("StandbyTime value %d outside legal range of 0 - %d minutes",
+			i, MAX_TIME_IN_MIN);
+    i = -1;
+    xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
+    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+	DPMSSuspendTime = defaultDPMSSuspendTime = i * MILLI_PER_MIN;
+    else if (i != -1)
+	xf86ConfigError("SuspendTime value %d outside legal range of 0 - %d minutes",
+			i, MAX_TIME_IN_MIN);
+    i = -1;
+    xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
+    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+	DPMSOffTime = defaultDPMSOffTime = i * MILLI_PER_MIN;
+    else if (i != -1)
+	xf86ConfigError("OffTime value %d outside legal range of 0 - %d minutes",
+			i, MAX_TIME_IN_MIN);
+#endif
+
+    i = -1;
+    xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
+    switch (i) {
+    case 24:
+	pix24 = Pix24Use24;
+	break;
+    case 32:
+	pix24 = Pix24Use32;
+	break;
+    case -1:
+	break;
+    default:
+	xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
+	return FALSE;
+    }
+    if (xf86Pix24 != Pix24DontCare) {
+	xf86Info.pixmap24 = xf86Pix24;
+	xf86Info.pix24From = X_CMDLINE;
+    } else if (pix24 != Pix24DontCare) {
+	xf86Info.pixmap24 = pix24;
+	xf86Info.pix24From = X_CONFIG;
+    } else {
+	xf86Info.pixmap24 = Pix24DontCare;
+	xf86Info.pix24From = X_DEFAULT;
+    }
+#if defined(i386) || defined(__i386__)
+    if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
+	xf86Info.pc98 = value;
+	if (value) {
+	    xf86Msg(X_CONFIG, "Japanese PC98 architecture\n");
+	}
+    } else
+	if (detectPC98()) {
+	    xf86Info.pc98 = TRUE;
+	    xf86Msg(X_PROBED, "Japanese PC98 architecture\n");
+	}
+#endif
+
+#ifdef PANORAMIX
+    from = X_DEFAULT;
+    if (!noPanoramiXExtension)
+      from = X_CMDLINE;
+    else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
+      noPanoramiXExtension = !value;
+      from = X_CONFIG;
+    }
+    if (!noPanoramiXExtension)
+      xf86Msg(from, "Xinerama: enabled\n");
+#endif
+
+    return TRUE;
+}
+
+/*
+ * XXX This function is temporary, and will be removed when the keyboard
+ * driver is converted into a regular input driver.
+ */
+static Bool
+configInputKbd(IDevPtr inputp)
+{
+  char *s;
+  MessageType from = X_DEFAULT;
+  Bool customKeycodesDefault = FALSE;
+  int verb = 0;
+#if defined(XQUEUE)
+  char *kbdproto = "Xqueue";
+#else
+  char *kbdproto = "standard";
+#endif
+
+  /* Initialize defaults */
+  xf86Info.xleds         = 0L;
+  xf86Info.kbdDelay      = 500;
+  xf86Info.kbdRate       = 30;
+  
+  xf86Info.kbdProc       = NULL;
+  xf86Info.vtinit        = NULL;
+  xf86Info.vtSysreq      = VT_SYSREQ_DEFAULT;
+#if defined(SVR4) && defined(i386)
+  xf86Info.panix106      = FALSE;
+#endif
+  xf86Info.kbdCustomKeycodes = FALSE;
+#ifdef WSCONS_SUPPORT
+  xf86Info.kbdFd 	   = -1;
+#endif
+#ifdef XKB
+  if (!xf86IsPc98()) {
+    xf86Info.xkbrules      = __XKBDEFRULES__;
+    xf86Info.xkbmodel      = "pc105";
+    xf86Info.xkblayout     = "us";
+    xf86Info.xkbvariant    = NULL;
+    xf86Info.xkboptions    = NULL;
+  } else {
+    xf86Info.xkbrules      = "xfree98";
+    xf86Info.xkbmodel      = "pc98";
+    xf86Info.xkblayout     = "nec/jp";
+    xf86Info.xkbvariant    = NULL;
+    xf86Info.xkboptions    = NULL;
+  }
+  xf86Info.xkbcomponents_specified = FALSE;
+  /* Should discourage the use of these. */
+  xf86Info.xkbkeymap     = NULL;
+  xf86Info.xkbtypes      = NULL;
+  xf86Info.xkbcompat     = NULL;
+  xf86Info.xkbkeycodes   = NULL;
+  xf86Info.xkbsymbols    = NULL;
+  xf86Info.xkbgeometry   = NULL;
+#endif
+
+  s = xf86SetStrOption(inputp->commonOptions, "Protocol", kbdproto);
+  if (xf86NameCmp(s, "standard") == 0) {
+     xf86Info.kbdProc    = xf86KbdProc;
+     xf86Info.kbdEvents  = xf86KbdEvents;
+     xfree(s);
+  } else if (xf86NameCmp(s, "xqueue") == 0) {
+#ifdef __UNIXWARE__
+    /*
+     * To retain compatibility with older config files, on UnixWare, we
+     * accept the xqueue protocol but use the normal keyboard procs.
+     */
+     xf86Info.kbdProc    = xf86KbdProc;
+     xf86Info.kbdEvents  = xf86KbdEvents;
+#else
+#ifdef XQUEUE
+    xf86Info.kbdProc = xf86XqueKbdProc;
+    xf86Info.kbdEvents = xf86XqueEvents;
+    xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n");
+#endif
+#endif
+    xfree(s);
+#ifdef WSCONS_SUPPORT
+  } else if (xf86NameCmp(s, "wskbd") == 0) {
+     xf86Info.kbdProc    = xf86KbdProc;
+     xf86Info.kbdEvents  = xf86WSKbdEvents;
+     xfree(s);
+     s = xf86SetStrOption(inputp->commonOptions, "Device", NULL);
+     xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n");
+     if (s == NULL) {
+	 xf86ConfigError("A \"device\" option is required with"
+			 " the \"wskbd\" keyboard protocol");
+	 return FALSE;
+     }
+     xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL);
+     if (xf86Info.kbdFd == -1) {
+       xf86ConfigError("cannot open \"%s\"", s);
+       xfree(s);
+       return FALSE;
+     }
+     xfree(s);
+     /* Find out keyboard type */
+     if (ioctl(xf86Info.kbdFd, WSKBDIO_GTYPE, &xf86Info.wsKbdType) == -1) {
+	     xf86ConfigError("cannot get keyboard type");
+	     close(xf86Info.kbdFd);
+	     return FALSE;
+     }
+     switch (xf86Info.wsKbdType) {
+     case WSKBD_TYPE_PC_XT:
+	     xf86Msg(X_PROBED, "Keyboard type: XT\n");
+	     break;
+     case WSKBD_TYPE_PC_AT:
+	     xf86Msg(X_PROBED, "Keyboard type: AT\n");
+	     break;
+     case WSKBD_TYPE_USB:
+	     xf86Msg(X_PROBED, "Keyboard type: USB\n");
+	     break;
+#ifdef WSKBD_TYPE_ADB
+     case WSKBD_TYPE_ADB:
+	     xf86Msg(X_PROBED, "Keyboard type: ADB\n");
+	     break;
+#endif
+#ifdef WSKBD_TYPE_SUN
+     case WSKBD_TYPE_SUN:
+	     xf86Msg(X_PROBED, "Keyboard type: Sun\n");
+	     break;
+#endif
+#ifdef WSKBD_TYPE_SUN5
+     case WSKBD_TYPE_SUN5:
+	     xf86Msg(X_PROBED, "Keyboard type: Sun5\n");
+	     break;
+#endif
+     default:
+	     xf86ConfigError("Unsupported wskbd type \"%d\"", 
+			     xf86Info.wsKbdType);
+	     close(xf86Info.kbdFd);
+	     return FALSE;
+     }
+#endif
+  } else {
+    xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s);
+    xfree(s);
+    return FALSE;
+  }
+
+  s = xf86SetStrOption(inputp->commonOptions, "AutoRepeat", NULL);
+  if (s) {
+    if (sscanf(s, "%d %d", &xf86Info.kbdDelay, &xf86Info.kbdRate) != 2) {
+      xf86ConfigError("\"%s\" is not a valid AutoRepeat value", s);
+      xfree(s);
+      return FALSE;
+    }
+  xfree(s);
+  }
+
+  s = xf86SetStrOption(inputp->commonOptions, "XLeds", NULL);
+  if (s) {
+    char *l, *end;
+    unsigned int i;
+    l = strtok(s, " \t\n");
+    while (l) {
+      i = strtoul(l, &end, 0);
+      if (*end == '\0')
+	xf86Info.xleds |= 1L << (i - 1);
+      else {
+	xf86ConfigError("\"%s\" is not a valid XLeds value", l);
+	xfree(s);
+	return FALSE;
+      }
+      l = strtok(NULL, " \t\n");
+    }
+    xfree(s);
+  }
+
+#ifdef XKB
+  from = X_DEFAULT;
+  if (noXkbExtension)
+    from = X_CMDLINE;
+  else if (xf86FindOption(inputp->commonOptions, "XkbDisable")) {
+    xf86Msg(X_WARNING, "KEYBOARD: XKB should be disabled in the "
+	    "ServerFlags section instead\n"
+	    "\tof in the \"keyboard\" InputDevice section.\n");
+    noXkbExtension =
+	xf86SetBoolOption(inputp->commonOptions, "XkbDisable", FALSE);
+    from = X_CONFIG;
+  }
+  if (noXkbExtension)
+    xf86Msg(from, "XKB: disabled\n");
+
+#define NULL_IF_EMPTY(s) (s[0] ? s : (xfree(s), (char *)NULL))
+
+  if (!noXkbExtension && !XkbInitialMap) {
+    if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeymap", NULL))) {
+      xf86Info.xkbkeymap = NULL_IF_EMPTY(s);
+      xf86Msg(X_CONFIG, "XKB: keymap: \"%s\" "
+		"(overrides other XKB settings)\n", xf86Info.xkbkeymap);
+    } else {
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbCompat", NULL))) {
+	xf86Info.xkbcompat = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: compat: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbTypes", NULL))) {
+	xf86Info.xkbtypes = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: types: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeycodes", NULL))) {
+	xf86Info.xkbkeycodes = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: keycodes: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbGeometry", NULL))) {
+	xf86Info.xkbgeometry = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: geometry: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbSymbols", NULL))) {
+	xf86Info.xkbsymbols = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: symbols: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbRules", NULL))) {
+	xf86Info.xkbrules = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: rules: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbModel", NULL))) {
+	xf86Info.xkbmodel = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: model: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbLayout", NULL))) {
+	xf86Info.xkblayout = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: layout: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbVariant", NULL))) {
+	xf86Info.xkbvariant = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: variant: \"%s\"\n", s);
+      }
+
+      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbOptions", NULL))) {
+	xf86Info.xkboptions = NULL_IF_EMPTY(s);
+	xf86Info.xkbcomponents_specified = TRUE;
+	xf86Msg(X_CONFIG, "XKB: options: \"%s\"\n", s);
+      }
+    }
+  }
+#undef NULL_IF_EMPTY
+#endif
+#if defined(SVR4) && defined(i386)
+  if ((xf86Info.panix106 =
+	xf86SetBoolOption(inputp->commonOptions, "Panix106", FALSE))) {
+    xf86Msg(X_CONFIG, "PANIX106: enabled\n");
+  }
+#endif
+
+  /*
+   * This was once a compile time option (ASSUME_CUSTOM_KEYCODES)
+   * defaulting to 1 on Linux/PPC. It is no longer necessary, but for
+   * backwards compatibility we provide 'Option "CustomKeycodes"'
+   * and try to autoprobe on Linux/PPC.
+   */
+  from = X_DEFAULT;
+  verb = 2;
+#if defined(__linux__) && defined(__powerpc__)
+  {
+    FILE *f;
+
+    f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
+    if (f) {
+      if (fgetc(f) == '0') {
+	customKeycodesDefault = TRUE;
+	from = X_PROBED;
+	verb = 1;
+      }
+      fclose(f);
+    }
+  }
+#endif
+  if (xf86FindOption(inputp->commonOptions, "CustomKeycodes")) {
+    from = X_CONFIG;
+    verb = 1;
+  }
+  xf86Info.kbdCustomKeycodes =
+	xf86SetBoolOption(inputp->commonOptions, "CustomKeycodes",
+			  customKeycodesDefault);
+  xf86MsgVerb(from, verb, "Keyboard: CustomKeycode %s\n",
+		xf86Info.kbdCustomKeycodes ? "enabled" : "disabled");
+
+  return TRUE;
+}
+
+/*
+ * Locate the core input devices.  These can be specified/located in
+ * the following ways, in order of priority:
+ *
+ *  1. The InputDevices named by the -pointer and -keyboard command line
+ *     options.
+ *  2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
+ *     the active ServerLayout.
+ *  3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
+ *  4. The first InputDevices that use the 'mouse' and 'keyboard' or 'kbd'
+ *     drivers.
+ *  5. Default devices with an empty (default) configuration.  These defaults
+ *     will reference the 'mouse' and 'keyboard' drivers.
+ */
+
+static Bool
+checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
+{
+    IDevPtr corePointer = NULL, coreKeyboard = NULL;
+    Bool foundPointer = FALSE, foundKeyboard = FALSE;
+    const char *pointerMsg = NULL, *keyboardMsg = NULL;
+    IDevPtr indp;
+    IDevRec Pointer, Keyboard;
+    XF86ConfInputPtr confInput;
+    XF86ConfInputRec defPtr, defKbd;
+    int count = 0;
+    MessageType from = X_DEFAULT;
+
+    /*
+     * First check if a core pointer or core keyboard have been specified
+     * in the active ServerLayout.  If more than one is specified for either,
+     * remove the core attribute from the later ones.
+     */
+    for (indp = servlayoutp->inputs; indp->identifier; indp++) {
+	pointer opt1 = NULL, opt2 = NULL;
+	if (indp->commonOptions &&
+	    xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) {
+	    opt1 = indp->commonOptions;
+	}
+	if (indp->extraOptions &&
+	    xf86CheckBoolOption(indp->extraOptions, "CorePointer", FALSE)) {
+	    opt2 = indp->extraOptions;
+	}
+	if (opt1 || opt2) {
+	    if (!corePointer) {
+		corePointer = indp;
+	    } else {
+		if (opt1)
+		    xf86ReplaceBoolOption(opt1, "CorePointer", FALSE);
+		if (opt2)
+		    xf86ReplaceBoolOption(opt2, "CorePointer", FALSE);
+		xf86Msg(X_WARNING, "Duplicate core pointer devices.  "
+			"Removing core pointer attribute from \"%s\"\n",
+			indp->identifier);
+	    }
+	}
+	opt1 = opt2 = NULL;
+	if (indp->commonOptions &&
+	    xf86CheckBoolOption(indp->commonOptions, "CoreKeyboard", FALSE)) {
+	    opt1 = indp->commonOptions;
+	}
+	if (indp->extraOptions &&
+	    xf86CheckBoolOption(indp->extraOptions, "CoreKeyboard", FALSE)) {
+	    opt2 = indp->extraOptions;
+	}
+	if (opt1 || opt2) {
+	    if (!coreKeyboard) {
+		coreKeyboard = indp;
+	    } else {
+		if (opt1)
+		    xf86ReplaceBoolOption(opt1, "CoreKeyboard", FALSE);
+		if (opt2)
+		    xf86ReplaceBoolOption(opt2, "CoreKeyboard", FALSE);
+		xf86Msg(X_WARNING, "Duplicate core keyboard devices.  "
+			"Removing core keyboard attribute from \"%s\"\n",
+			indp->identifier);
+	    }
+	}
+	count++;
+    }
+
+    confInput = NULL;
+
+    /* 1. Check for the -pointer command line option. */
+    if (xf86PointerName) {
+	confInput = xf86findInput(xf86PointerName,
+				  xf86configptr->conf_input_lst);
+	if (!confInput) {
+	    xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+		    xf86PointerName);
+	    return FALSE;
+	}
+	from = X_CMDLINE;
+	/*
+	 * If one was already specified in the ServerLayout, it needs to be
+	 * removed.
+	 */
+	if (corePointer) {
+	    for (indp = servlayoutp->inputs; indp->identifier; indp++)
+		if (indp == corePointer)
+		    break;
+	    for (; indp->identifier; indp++)
+		indp[0] = indp[1];
+	    count--;
+	}
+	corePointer = NULL;
+	foundPointer = TRUE;
+    }
+
+    /* 2. ServerLayout-specified core pointer. */
+    if (corePointer) {
+	foundPointer = TRUE;
+	from = X_CONFIG;
+    }
+
+    /* 3. First core pointer device. */
+    if (!foundPointer) {
+	XF86ConfInputPtr p;
+
+	for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+	    if (p->inp_option_lst &&
+		xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) {
+		confInput = p;
+		foundPointer = TRUE;
+		from = X_DEFAULT;
+		pointerMsg = "first core pointer device";
+		break;
+	    }
+	}
+    }
+
+    /* 4. First pointer with 'mouse' as the driver. */
+    if (!foundPointer) {
+	confInput = xf86findInput(CONF_IMPLICIT_POINTER,
+				  xf86configptr->conf_input_lst);
+	if (!confInput) {
+	    confInput = xf86findInputByDriver("mouse",
+					      xf86configptr->conf_input_lst);
+	}
+	if (confInput) {
+	    foundPointer = TRUE;
+	    from = X_DEFAULT;
+	    pointerMsg = "first mouse device";
+	}
+    }
+
+    /* 5. Built-in default. */
+    if (!foundPointer) {
+	bzero(&defPtr, sizeof(defPtr));
+	defPtr.inp_identifier = "<default pointer>";
+	defPtr.inp_driver = "mouse";
+	confInput = &defPtr;
+	foundPointer = TRUE;
+	from = X_DEFAULT;
+	pointerMsg = "default mouse configuration";
+    }
+
+    /* Add the core pointer device to the layout, and set it to Core. */
+    if (foundPointer && confInput) {
+	foundPointer = configInput(&Pointer, confInput, from);
+        if (foundPointer) {
+	    count++;
+	    indp = xnfrealloc(servlayoutp->inputs,
+			      (count + 1) * sizeof(IDevRec));
+	    indp[count - 1] = Pointer;
+	    indp[count - 1].extraOptions =
+				xf86addNewOption(NULL, "CorePointer", NULL);
+	    indp[count].identifier = NULL;
+	    servlayoutp->inputs = indp;
+	}
+    }
+
+    if (!foundPointer) {
+	/* This shouldn't happen. */
+	xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
+	return FALSE;
+    }
+
+    confInput = NULL;
+
+    /* 1. Check for the -keyboard command line option. */
+    if (xf86KeyboardName) {
+	confInput = xf86findInput(xf86KeyboardName,
+				  xf86configptr->conf_input_lst);
+	if (!confInput) {
+	    xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+		    xf86KeyboardName);
+	    return FALSE;
+	}
+	from = X_CMDLINE;
+	/*
+	 * If one was already specified in the ServerLayout, it needs to be
+	 * removed.
+	 */
+	if (coreKeyboard) {
+	    for (indp = servlayoutp->inputs; indp->identifier; indp++)
+		if (indp == coreKeyboard)
+		    break;
+	    for (; indp->identifier; indp++)
+		indp[0] = indp[1];
+	    count--;
+	}
+	coreKeyboard = NULL;
+	foundKeyboard = TRUE;
+    }
+
+    /* 2. ServerLayout-specified core keyboard. */
+    if (coreKeyboard) {
+	foundKeyboard = TRUE;
+	from = X_CONFIG;
+    }
+
+    /* 3. First core keyboard device. */
+    if (!foundKeyboard) {
+	XF86ConfInputPtr p;
+
+	for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+	    if (p->inp_option_lst &&
+		xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) {
+		confInput = p;
+		foundKeyboard = TRUE;
+		from = X_DEFAULT;
+		keyboardMsg = "first core keyboard device";
+		break;
+	    }
+	}
+    }
+
+    /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
+    if (!foundKeyboard) {
+	confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
+				  xf86configptr->conf_input_lst);
+	if (!confInput) {
+	    confInput = xf86findInputByDriver("kbd",
+					      xf86configptr->conf_input_lst);
+	}
+	if (!confInput) {
+	    confInput = xf86findInputByDriver("keyboard",
+					      xf86configptr->conf_input_lst);
+	}
+	if (confInput) {
+	    foundKeyboard = TRUE;
+	    from = X_DEFAULT;
+	    keyboardMsg = "first keyboard device";
+	}
+    }
+
+    /* 5. Built-in default. */
+    if (!foundKeyboard) {
+	bzero(&defKbd, sizeof(defKbd));
+	defKbd.inp_identifier = "<default keyboard>";
+	defKbd.inp_driver = "kbd";
+	confInput = &defKbd;
+	foundKeyboard = TRUE;
+	keyboardMsg = "default keyboard configuration";
+	from = X_DEFAULT;
+    }
+
+    /* Add the core keyboard device to the layout, and set it to Core. */
+    if (foundKeyboard && confInput) {
+	foundKeyboard = configInput(&Keyboard, confInput, from);
+        if (foundKeyboard) {
+	    count++;
+	    indp = xnfrealloc(servlayoutp->inputs,
+			      (count + 1) * sizeof(IDevRec));
+	    indp[count - 1] = Keyboard;
+	    indp[count - 1].extraOptions =
+				xf86addNewOption(NULL, "CoreKeyboard", NULL);
+	    indp[count].identifier = NULL;
+	    servlayoutp->inputs = indp;
+	}
+    }
+
+    if (!foundKeyboard) {
+	/* This shouldn't happen. */
+	xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
+	return FALSE;
+    }
+
+    if (pointerMsg) {
+	xf86Msg(X_WARNING, "The core pointer device wasn't specified "
+		"explicitly in the layout.\n"
+		"\tUsing the %s.\n", pointerMsg);
+    }
+
+    if (keyboardMsg) {
+	xf86Msg(X_WARNING, "The core keyboard device wasn't specified "
+		"explicitly in the layout.\n"
+		"\tUsing the %s.\n", keyboardMsg);
+    }
+
+    return TRUE;
+}
+
+typedef enum {
+    LAYOUT_ISOLATEDEVICE,
+    LAYOUT_SINGLECARD
+} LayoutValues;
+
+static OptionInfoRec LayoutOptions[] = {
+  { LAYOUT_ISOLATEDEVICE,      "IsolateDevice",        OPTV_STRING,
+       {0}, FALSE },
+  { LAYOUT_SINGLECARD,         "SingleCard",           OPTV_BOOLEAN,
+       {0}, FALSE },
+  { -1,                                NULL,                   OPTV_NONE,
+       {0}, FALSE },
+};
+
+/*
+ * figure out which layout is active, which screens are used in that layout,
+ * which drivers and monitors are used in these screens
+ */
+static Bool
+configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+	     char *default_layout)
+{
+    XF86ConfAdjacencyPtr adjp;
+    XF86ConfInactivePtr idp;
+    XF86ConfInputrefPtr irp;
+    int count = 0;
+    int scrnum;
+    XF86ConfLayoutPtr l;
+    MessageType from;
+    screenLayoutPtr slp;
+    GDevPtr gdp;
+    IDevPtr indp;
+    int i = 0, j;
+
+    if (!servlayoutp)
+	return FALSE;
+
+    /*
+     * which layout section is the active one?
+     *
+     * If there is a -layout command line option, use that one, otherwise
+     * pick the first one.
+     */
+    from = X_DEFAULT;
+    if (xf86LayoutName != NULL)
+	from = X_CMDLINE;
+    else if (default_layout) {
+	xf86LayoutName = default_layout;
+	from = X_CONFIG;
+    }
+    if (xf86LayoutName != NULL) {
+	if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
+	    xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
+		    xf86LayoutName);
+	    return FALSE;
+	}
+	conf_layout = l;
+    }
+    xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
+    adjp = conf_layout->lay_adjacency_lst;
+
+    /*
+     * we know that each screen is referenced exactly once on the left side
+     * of a layout statement in the Layout section. So to allocate the right
+     * size for the array we do a quick walk of the list to figure out how
+     * many sections we have
+     */
+    while (adjp) {
+        count++;
+        adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+    }
+#ifdef DEBUG
+    ErrorF("Found %d screens in the layout section %s",
+           count, conf_layout->lay_identifier);
+#endif
+    slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
+    slp[count].screen = NULL;
+    /*
+     * now that we have storage, loop over the list again and fill in our
+     * data structure; at this point we do not fill in the adjacency
+     * information as it is not clear if we need it at all
+     */
+    adjp = conf_layout->lay_adjacency_lst;
+    count = 0;
+    while (adjp) {
+        slp[count].screen = xnfcalloc(1, sizeof(confScreenRec));
+	if (adjp->adj_scrnum < 0)
+	    scrnum = count;
+	else
+	    scrnum = adjp->adj_scrnum;
+	if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
+			  X_CONFIG))
+	    return FALSE;
+	slp[count].x = adjp->adj_x;
+	slp[count].y = adjp->adj_y;
+	slp[count].refname = adjp->adj_refscreen;
+	switch (adjp->adj_where) {
+	case CONF_ADJ_OBSOLETE:
+	    slp[count].where = PosObsolete;
+	    slp[count].topname = adjp->adj_top_str;
+	    slp[count].bottomname = adjp->adj_bottom_str;
+	    slp[count].leftname = adjp->adj_left_str;
+	    slp[count].rightname = adjp->adj_right_str;
+	    break;
+	case CONF_ADJ_ABSOLUTE:
+	    slp[count].where = PosAbsolute;
+	    break;
+	case CONF_ADJ_RIGHTOF:
+	    slp[count].where = PosRightOf;
+	    break;
+	case CONF_ADJ_LEFTOF:
+	    slp[count].where = PosLeftOf;
+	    break;
+	case CONF_ADJ_ABOVE:
+	    slp[count].where = PosAbove;
+	    break;
+	case CONF_ADJ_BELOW:
+	    slp[count].where = PosBelow;
+	    break;
+	case CONF_ADJ_RELATIVE:
+	    slp[count].where = PosRelative;
+	    break;
+	}
+        count++;
+        adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+    }
+
+    /* XXX Need to tie down the upper left screen. */
+
+    /* Fill in the refscreen and top/bottom/left/right values */
+    for (i = 0; i < count; i++) {
+	for (j = 0; j < count; j++) {
+	    if (slp[i].refname &&
+		strcmp(slp[i].refname, slp[j].screen->id) == 0) {
+		slp[i].refscreen = slp[j].screen;
+	    }
+	    if (slp[i].topname &&
+		strcmp(slp[i].topname, slp[j].screen->id) == 0) {
+		slp[i].top = slp[j].screen;
+	    }
+	    if (slp[i].bottomname &&
+		strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
+		slp[i].bottom = slp[j].screen;
+	    }
+	    if (slp[i].leftname &&
+		strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
+		slp[i].left = slp[j].screen;
+	    }
+	    if (slp[i].rightname &&
+		strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
+		slp[i].right = slp[j].screen;
+	    }
+	}
+	if (slp[i].where != PosObsolete
+	    && slp[i].where != PosAbsolute
+	    && !slp[i].refscreen) {
+	    xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n",
+		     slp[i].refname);
+	    slp[i].where = PosAbsolute;
+	    slp[i].x = 0;
+	    slp[i].y = 0;
+	}
+    }
+
+#ifdef LAYOUT_DEBUG
+    ErrorF("Layout \"%s\"\n", conf_layout->lay_identifier);
+    for (i = 0; i < count; i++) {
+	ErrorF("Screen: \"%s\" (%d):\n", slp[i].screen->id,
+	       slp[i].screen->screennum);
+	switch (slp[i].where) {
+	case PosObsolete:
+	    ErrorF("\tObsolete format: \"%s\" \"%s\" \"%s\" \"%s\"\n",
+		   slp[i].top, slp[i].bottom, slp[i].left, slp[i].right);
+	    break;
+	case PosAbsolute:
+	    if (slp[i].x == -1)
+		if (slp[i].screen->screennum == 0)
+		    ErrorF("\tImplicitly left-most\n");
+		else
+		    ErrorF("\tImplicitly right of screen %d\n",
+			   slp[i].screen->screennum - 1);
+	    else
+		ErrorF("\t%d %d\n", slp[i].x, slp[i].y);
+	    break;
+	case PosRightOf:
+	    ErrorF("\tRight of \"%s\"\n", slp[i].refscreen->id);
+	    break;
+	case PosLeftOf:
+	    ErrorF("\tLeft of \"%s\"\n", slp[i].refscreen->id);
+	    break;
+	case PosAbove:
+	    ErrorF("\tAbove \"%s\"\n", slp[i].refscreen->id);
+	    break;
+	case PosBelow:
+	    ErrorF("\tBelow \"%s\"\n", slp[i].refscreen->id);
+	    break;
+	case PosRelative:
+	    ErrorF("\t%d %d relative to \"%s\"\n", slp[i].x, slp[i].y,
+		   slp[i].refscreen->id);
+	    break;
+	}
+    }
+#endif
+    /*
+     * Count the number of inactive devices.
+     */
+    count = 0;
+    idp = conf_layout->lay_inactive_lst;
+    while (idp) {
+        count++;
+        idp = (XF86ConfInactivePtr)idp->list.next;
+    }
+#ifdef DEBUG
+    ErrorF("Found %d inactive devices in the layout section %s",
+           count, conf_layout->lay_identifier);
+#endif
+    gdp = xnfalloc((count + 1) * sizeof(GDevRec));
+    gdp[count].identifier = NULL;
+    idp = conf_layout->lay_inactive_lst;
+    count = 0;
+    while (idp) {
+	if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+	    return FALSE;
+        count++;
+        idp = (XF86ConfInactivePtr)idp->list.next;
+    }
+    /*
+     * Count the number of input devices.
+     */
+    count = 0;
+    irp = conf_layout->lay_input_lst;
+    while (irp) {
+        count++;
+        irp = (XF86ConfInputrefPtr)irp->list.next;
+    }
+#ifdef DEBUG
+    ErrorF("Found %d input devices in the layout section %s",
+           count, conf_layout->lay_identifier);
+#endif
+    indp = xnfalloc((count + 1) * sizeof(IDevRec));
+    indp[count].identifier = NULL;
+    irp = conf_layout->lay_input_lst;
+    count = 0;
+    while (irp) {
+	if (!configInput(&indp[count], irp->iref_inputdev, X_CONFIG))
+	    return FALSE;
+	indp[count].extraOptions = irp->iref_option_lst;
+        count++;
+        irp = (XF86ConfInputrefPtr)irp->list.next;
+    }
+    servlayoutp->id = conf_layout->lay_identifier;
+    servlayoutp->screens = slp;
+    servlayoutp->inactives = gdp;
+    servlayoutp->inputs = indp;
+    servlayoutp->options = conf_layout->lay_option_lst;
+    from = X_DEFAULT;
+
+    if (!checkCoreInputDevices(servlayoutp, FALSE))
+	return FALSE;
+    return TRUE;
+}
+
+/*
+ * No layout section, so find the first Screen section and set that up as
+ * the only active screen.
+ */
+static Bool
+configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
+{
+    MessageType from;
+    XF86ConfScreenPtr s;
+    screenLayoutPtr slp;
+    IDevPtr indp;
+
+    if (!servlayoutp)
+	return FALSE;
+
+    if (conf_screen == NULL) {
+	xf86ConfigError("No Screen sections present\n");
+	return FALSE;
+    }
+
+    /*
+     * which screen section is the active one?
+     *
+     * If there is a -screen option, use that one, otherwise use the first
+     * one.
+     */
+
+    from = X_CONFIG;
+    if (xf86ScreenName != NULL) {
+	if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
+	    xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
+		    xf86ScreenName);
+	    return FALSE;
+	}
+	conf_screen = s;
+	from = X_CMDLINE;
+    }
+
+    /* We have exactly one screen */
+
+    slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec));
+    slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
+    slp[1].screen = NULL;
+    if (!configScreen(slp[0].screen, conf_screen, 0, from))
+	return FALSE;
+    servlayoutp->id = "(implicit)";
+    servlayoutp->screens = slp;
+    servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
+    servlayoutp->options = NULL;
+    /* Set up an empty input device list, then look for some core devices. */
+    indp = xnfalloc(sizeof(IDevRec));
+    indp->identifier = NULL;
+    servlayoutp->inputs = indp;
+    if (!checkCoreInputDevices(servlayoutp, TRUE))
+	return FALSE;
+    
+    return TRUE;
+}
+
+static Bool
+configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
+{
+    int count = 0;
+    XF86ConfVideoPortPtr conf_port;
+
+    xf86Msg(X_CONFIG, "|   |-->VideoAdaptor \"%s\"\n",
+	    conf_adaptor->va_identifier);
+    adaptor->identifier = conf_adaptor->va_identifier;
+    adaptor->options = conf_adaptor->va_option_lst;
+    if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
+	xf86Msg(X_CONFIG, "|   | Unsupported device type, skipping entry\n");
+	return FALSE;
+    }
+
+    /*
+     * figure out how many videoport subsections there are and fill them in
+     */
+    conf_port = conf_adaptor->va_port_lst;
+    while(conf_port) {
+        count++;
+        conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+    }
+    adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
+    adaptor->numports = count;
+    count = 0;
+    conf_port = conf_adaptor->va_port_lst;
+    while(conf_port) {
+	adaptor->ports[count].identifier = conf_port->vp_identifier;
+	adaptor->ports[count].options = conf_port->vp_option_lst;
+        count++;
+        conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+    }
+
+    return TRUE;
+}
+
+static Bool
+configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
+	     MessageType from)
+{
+    int count = 0;
+    XF86ConfDisplayPtr dispptr;
+    XF86ConfAdaptorLinkPtr conf_adaptor;
+    Bool defaultMonitor = FALSE;
+
+    xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
+	    scrnum);
+    /*
+     * now we fill in the elements of the screen
+     */
+    screenp->id         = conf_screen->scrn_identifier;
+    screenp->screennum  = scrnum;
+    screenp->defaultdepth = conf_screen->scrn_defaultdepth;
+    screenp->defaultbpp = conf_screen->scrn_defaultbpp;
+    screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
+    screenp->monitor    = xnfcalloc(1, sizeof(MonRec));
+    /* If no monitor is specified, create a default one. */
+    if (!conf_screen->scrn_monitor) {
+	XF86ConfMonitorRec defMon;
+
+	bzero(&defMon, sizeof(defMon));
+	defMon.mon_identifier = "<default monitor>";
+	/*
+	 * TARGET_REFRESH_RATE may be defined to effectively limit the
+	 * default resolution to the largest that has a "good" refresh
+	 * rate.
+	 */
+#ifdef TARGET_REFRESH_RATE
+	defMon.mon_option_lst = xf86ReplaceRealOption(defMon.mon_option_lst,
+						      "TargetRefresh",
+						      TARGET_REFRESH_RATE);
+#endif
+	if (!configMonitor(screenp->monitor, &defMon))
+	    return FALSE;
+	defaultMonitor = TRUE;
+    } else {
+	if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor))
+	    return FALSE;
+    }
+    screenp->device     = xnfcalloc(1, sizeof(GDevRec));
+    configDevice(screenp->device,conf_screen->scrn_device, TRUE);
+    screenp->device->myScreenSection = screenp;
+    screenp->options = conf_screen->scrn_option_lst;
+    
+    /*
+     * figure out how many display subsections there are and fill them in
+     */
+    dispptr = conf_screen->scrn_display_lst;
+    while(dispptr) {
+        count++;
+        dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+    }
+    screenp->displays   = xnfalloc((count) * sizeof(DispRec));
+    screenp->numdisplays = count;
+    count = 0;
+    dispptr = conf_screen->scrn_display_lst;
+    while(dispptr) {
+        configDisplay(&(screenp->displays[count]),dispptr);
+        count++;
+        dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+    }
+
+    /*
+     * figure out how many videoadaptor references there are and fill them in
+     */
+    conf_adaptor = conf_screen->scrn_adaptor_lst;
+    while(conf_adaptor) {
+        count++;
+        conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+    }
+    screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
+    screenp->numxvadaptors = 0;
+    conf_adaptor = conf_screen->scrn_adaptor_lst;
+    while(conf_adaptor) {
+        if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
+			    conf_adaptor->al_adaptor))
+    	    screenp->numxvadaptors++;
+        conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+    }
+
+    if (defaultMonitor) {
+	xf86Msg(X_WARNING, "No monitor specified for screen \"%s\".\n"
+		"\tUsing a default monitor configuration.\n", screenp->id);
+    }
+    return TRUE;
+}
+
+static Bool
+configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
+{
+    int count;
+    DisplayModePtr mode,last = NULL;
+    XF86ConfModeLinePtr cmodep;
+    XF86ConfModesPtr modes;
+    XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
+    Gamma zeros = {0.0, 0.0, 0.0};
+    float badgamma = 0.0;
+    
+    xf86Msg(X_CONFIG, "|   |-->Monitor \"%s\"\n",
+	    conf_monitor->mon_identifier);
+    monitorp->id = conf_monitor->mon_identifier;
+    monitorp->vendor = conf_monitor->mon_vendor;
+    monitorp->model = conf_monitor->mon_modelname;
+    monitorp->Modes = NULL;
+    monitorp->Last = NULL;
+    monitorp->gamma = zeros;
+    monitorp->widthmm = conf_monitor->mon_width;
+    monitorp->heightmm = conf_monitor->mon_height;
+    monitorp->options = conf_monitor->mon_option_lst;
+
+    /*
+     * fill in the monitor structure
+     */    
+    for( count = 0 ;
+	 count < conf_monitor->mon_n_hsync && count < MAX_HSYNC;
+	 count++) {
+        monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
+        monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
+    }
+    monitorp->nHsync = count;
+    for( count = 0 ;
+	 count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH;
+	 count++) {
+        monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
+        monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
+    }
+    monitorp->nVrefresh = count;
+
+    /*
+     * first we collect the mode lines from the UseModes directive
+     */
+    while(modeslnk)
+    {
+        modes = xf86findModes (modeslnk->ml_modes_str, 
+			       xf86configptr->conf_modes_lst);
+	modeslnk->ml_modes = modes;
+	
+	    
+	/* now add the modes found in the modes
+	   section to the list of modes for this
+	   monitor unless it has been added before
+	   because we are reusing the same section 
+	   for another screen */
+	if (xf86itemNotSublist(
+			       (GenericListPtr)conf_monitor->mon_modeline_lst,
+			       (GenericListPtr)modes->mon_modeline_lst)) {
+	    conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
+	        xf86addListItem(
+				(GenericListPtr)conf_monitor->mon_modeline_lst,
+				(GenericListPtr)modes->mon_modeline_lst);
+	}
+	modeslnk = modeslnk->list.next;
+    }
+
+    /*
+     * we need to hook in the mode lines now
+     * here both data structures use lists, only our internal one
+     * is double linked
+     */
+    cmodep = conf_monitor->mon_modeline_lst;
+    while( cmodep ) {
+        mode = xnfalloc(sizeof(DisplayModeRec));
+        memset(mode,'\0',sizeof(DisplayModeRec));
+	mode->type       = M_T_USERDEF;
+        mode->Clock      = cmodep->ml_clock;
+        mode->HDisplay   = cmodep->ml_hdisplay;
+        mode->HSyncStart = cmodep->ml_hsyncstart;
+        mode->HSyncEnd   = cmodep->ml_hsyncend;
+        mode->HTotal     = cmodep->ml_htotal;
+        mode->VDisplay   = cmodep->ml_vdisplay;
+        mode->VSyncStart = cmodep->ml_vsyncstart;
+        mode->VSyncEnd   = cmodep->ml_vsyncend;
+        mode->VTotal     = cmodep->ml_vtotal;
+        mode->Flags      = cmodep->ml_flags;
+        mode->HSkew      = cmodep->ml_hskew;
+        mode->VScan      = cmodep->ml_vscan;
+        mode->name       = xnfstrdup(cmodep->ml_identifier);
+        if( last ) {
+            mode->prev = last;
+            last->next = mode;
+        }
+        else {
+            /*
+             * this is the first mode
+             */
+            monitorp->Modes = mode;
+            mode->prev = NULL;
+        }
+        last = mode;
+        cmodep = (XF86ConfModeLinePtr)cmodep->list.next;
+    }
+    if(last){
+      last->next = NULL;
+    }
+    monitorp->Last = last;
+
+    /* add the (VESA) default modes */
+    if (! addDefaultModes(monitorp) )
+	return FALSE;
+
+    if (conf_monitor->mon_gamma_red > GAMMA_ZERO)
+	monitorp->gamma.red = conf_monitor->mon_gamma_red;
+    if (conf_monitor->mon_gamma_green > GAMMA_ZERO)
+	monitorp->gamma.green = conf_monitor->mon_gamma_green;
+    if (conf_monitor->mon_gamma_blue > GAMMA_ZERO)
+	monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
+    
+    /* Check that the gamma values are within range */
+    if (monitorp->gamma.red > GAMMA_ZERO &&
+	(monitorp->gamma.red < GAMMA_MIN ||
+	 monitorp->gamma.red > GAMMA_MAX)) {
+	badgamma = monitorp->gamma.red;
+    } else if (monitorp->gamma.green > GAMMA_ZERO &&
+	(monitorp->gamma.green < GAMMA_MIN ||
+	 monitorp->gamma.green > GAMMA_MAX)) {
+	badgamma = monitorp->gamma.green;
+    } else if (monitorp->gamma.blue > GAMMA_ZERO &&
+	(monitorp->gamma.blue < GAMMA_MIN ||
+	 monitorp->gamma.blue > GAMMA_MAX)) {
+	badgamma = monitorp->gamma.blue;
+    }
+    if (badgamma > GAMMA_ZERO) {
+	xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
+			badgamma, GAMMA_MIN, GAMMA_MAX);
+	    return FALSE;
+    }
+
+    return TRUE;
+}
+
+static int
+lookupVisual(const char *visname)
+{
+    int i;
+
+    if (!visname || !*visname)
+	return -1;
+
+    for (i = 0; i <= DirectColor; i++) {
+	if (!xf86nameCompare(visname, xf86VisualNames[i]))
+	    break;
+    }
+
+    if (i <= DirectColor)
+	return i;
+
+    return -1;
+}
+
+
+static Bool
+configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
+{
+    int count = 0;
+    XF86ModePtr modep;
+    
+    displayp->frameX0           = conf_display->disp_frameX0;
+    displayp->frameY0           = conf_display->disp_frameY0;
+    displayp->virtualX          = conf_display->disp_virtualX;
+    displayp->virtualY          = conf_display->disp_virtualY;
+    displayp->depth             = conf_display->disp_depth;
+    displayp->fbbpp             = conf_display->disp_bpp;
+    displayp->weight.red        = conf_display->disp_weight.red;
+    displayp->weight.green      = conf_display->disp_weight.green;
+    displayp->weight.blue       = conf_display->disp_weight.blue;
+    displayp->blackColour.red   = conf_display->disp_black.red;
+    displayp->blackColour.green = conf_display->disp_black.green;
+    displayp->blackColour.blue  = conf_display->disp_black.blue;
+    displayp->whiteColour.red   = conf_display->disp_white.red;
+    displayp->whiteColour.green = conf_display->disp_white.green;
+    displayp->whiteColour.blue  = conf_display->disp_white.blue;
+    displayp->options           = conf_display->disp_option_lst;
+    if (conf_display->disp_visual) {
+	displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
+	if (displayp->defaultVisual == -1) {
+	    xf86ConfigError("Invalid visual name: \"%s\"",
+			    conf_display->disp_visual);
+	    return FALSE;
+	}
+    } else {
+	displayp->defaultVisual = -1;
+    }
+	
+    /*
+     * now hook in the modes
+     */
+    modep = conf_display->disp_mode_lst;
+    while(modep) {
+        count++;
+        modep = (XF86ModePtr)modep->list.next;
+    }
+    displayp->modes = xnfalloc((count+1) * sizeof(char*));
+    modep = conf_display->disp_mode_lst;
+    count = 0;
+    while(modep) {
+        displayp->modes[count] = modep->mode_name;
+        count++;
+        modep = (XF86ModePtr)modep->list.next;
+    }
+    displayp->modes[count] = NULL;
+    
+    return TRUE;
+}
+
+static Bool
+configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
+{
+    int i;
+
+    if (active)
+	xf86Msg(X_CONFIG, "|   |-->Device \"%s\"\n",
+		conf_device->dev_identifier);
+    else
+	xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
+		conf_device->dev_identifier);
+	
+    devicep->identifier = conf_device->dev_identifier;
+    devicep->vendor = conf_device->dev_vendor;
+    devicep->board = conf_device->dev_board;
+    devicep->chipset = conf_device->dev_chipset;
+    devicep->ramdac = conf_device->dev_ramdac;
+    devicep->driver = conf_device->dev_driver;
+    devicep->active = active;
+    devicep->videoRam = conf_device->dev_videoram;
+    devicep->BiosBase = conf_device->dev_bios_base;
+    devicep->MemBase = conf_device->dev_mem_base;
+    devicep->IOBase = conf_device->dev_io_base;
+    devicep->clockchip = conf_device->dev_clockchip;
+    devicep->busID = conf_device->dev_busid;
+    devicep->textClockFreq = conf_device->dev_textclockfreq;
+    devicep->chipID = conf_device->dev_chipid;
+    devicep->chipRev = conf_device->dev_chiprev;
+    devicep->options = conf_device->dev_option_lst;
+    devicep->irq = conf_device->dev_irq;
+    devicep->screen = conf_device->dev_screen;
+
+    for (i = 0; i < MAXDACSPEEDS; i++) {
+	if (i < CONF_MAXDACSPEEDS)
+            devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
+	else
+	    devicep->dacSpeeds[i] = 0;
+    }
+    devicep->numclocks = conf_device->dev_clocks;
+    if (devicep->numclocks > MAXCLOCKS)
+	devicep->numclocks = MAXCLOCKS;
+    for (i = 0; i < devicep->numclocks; i++) {
+	devicep->clock[i] = conf_device->dev_clock[i];
+    }
+    devicep->claimed = FALSE;
+
+    return TRUE;
+}
+
+#ifdef XF86DRI
+static Bool
+configDRI(XF86ConfDRIPtr drip)
+{
+    int                count = 0;
+    XF86ConfBuffersPtr bufs;
+    int                i;
+    struct group       *grp;
+
+    xf86ConfigDRI.group      = -1;
+    xf86ConfigDRI.mode       = 0;
+    xf86ConfigDRI.bufs_count = 0;
+    xf86ConfigDRI.bufs       = NULL;
+
+    if (drip) {
+	if (drip->dri_group_name) {
+	    if ((grp = getgrnam(drip->dri_group_name)))
+		xf86ConfigDRI.group = grp->gr_gid;
+	} else {
+	    if (drip->dri_group >= 0)
+		xf86ConfigDRI.group = drip->dri_group;
+	}
+	xf86ConfigDRI.mode = drip->dri_mode;
+	for (bufs = drip->dri_buffers_lst; bufs; bufs = bufs->list.next)
+	    ++count;
+	
+	xf86ConfigDRI.bufs_count = count;
+	xf86ConfigDRI.bufs = xnfalloc(count * sizeof(*xf86ConfigDRI.bufs));
+	
+	for (i = 0, bufs = drip->dri_buffers_lst;
+	     i < count;
+	     i++, bufs = bufs->list.next) {
+	    
+	    xf86ConfigDRI.bufs[i].count = bufs->buf_count;
+	    xf86ConfigDRI.bufs[i].size  = bufs->buf_size;
+				/* FIXME: Flags not implemented.  These
+                                   could be used, for example, to specify a
+                                   contiguous block and/or write-combining
+                                   cache policy. */
+	    xf86ConfigDRI.bufs[i].flags = 0;
+	}
+    }
+
+    return TRUE;
+}
+#endif
+
+static Bool
+configExtensions(XF86ConfExtensionsPtr conf_ext)
+{
+    XF86OptionPtr o;
+
+    /* Extension enable/disable in miinitext.c */
+    extern Bool EnableDisableExtension(char *name, Bool enable);
+
+    if (conf_ext && conf_ext->ext_option_lst) {
+	for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
+	    char *name   = xf86OptionName(o);
+	    char *val    = xf86OptionValue(o);
+	    char *n;
+	    Bool  enable = TRUE;
+
+	    /* Handle "No<ExtensionName>" */
+	    n = xf86NormalizeName(name);
+	    if (strncmp(n, "no", 2) == 0) {
+		name += 2;
+		enable = FALSE;
+	    }
+
+	    if (!val ||
+		xf86NameCmp(val, "enable") == 0 ||
+		xf86NameCmp(val, "enabled") == 0 ||
+		xf86NameCmp(val, "on") == 0 ||
+		xf86NameCmp(val, "1") == 0 ||
+		xf86NameCmp(val, "yes") == 0 ||
+		xf86NameCmp(val, "true") == 0) {
+		/* NOTHING NEEDED -- enabling is handled below */
+	    } else if (xf86NameCmp(val, "disable") == 0 ||
+                       xf86NameCmp(val, "disabled") == 0 ||
+		       xf86NameCmp(val, "off") == 0 ||
+		       xf86NameCmp(val, "0") == 0 ||
+		       xf86NameCmp(val, "no") == 0 ||
+		       xf86NameCmp(val, "false") == 0) {
+		enable = !enable;
+	    } else {
+		xf86Msg(X_ERROR,
+			"%s is not a valid value for the Extension option\n",
+			val);
+		return FALSE;
+	    }
+
+	    if (EnableDisableExtension(name, enable)) {
+		xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
+			name, enable ? "enabled" : "disabled");
+	    } else {
+		xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
+                        name);
+	    }
+	}
+    }
+
+    return TRUE;
+}
+
+static Bool
+configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
+{
+    xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
+    inputp->identifier = conf_input->inp_identifier;
+    inputp->driver = conf_input->inp_driver;
+    inputp->commonOptions = conf_input->inp_option_lst;
+    inputp->extraOptions = NULL;
+
+    /* XXX This is required until the keyboard driver is converted */
+    if (!xf86NameCmp(inputp->driver, "keyboard"))
+	return configInputKbd(inputp);
+
+    return TRUE;
+}
+
+static Bool
+modeIsPresent(char * modename,MonPtr monitorp)
+{
+    DisplayModePtr knownmodes = monitorp->Modes;
+
+    /* all I can think of is a linear search... */
+    while(knownmodes != NULL)
+    {
+	if(!strcmp(modename,knownmodes->name) &&
+	   !(knownmodes->type & M_T_DEFAULT))
+	    return TRUE;
+	knownmodes = knownmodes->next;
+    }
+    return FALSE;
+}
+
+static Bool
+addDefaultModes(MonPtr monitorp)
+{
+    DisplayModePtr mode;
+    DisplayModePtr last = monitorp->Last;
+    int i = 0;
+
+    while (xf86DefaultModes[i].name != NULL)
+    {
+	if ( ! modeIsPresent(xf86DefaultModes[i].name,monitorp) )
+	    do
+	    {
+		mode = xnfalloc(sizeof(DisplayModeRec));
+		memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec));
+		if (xf86DefaultModes[i].name)
+		    mode->name = xnfstrdup(xf86DefaultModes[i].name);
+		if( last ) {
+		    mode->prev = last;
+		    last->next = mode;
+		}
+		else {
+		    /* this is the first mode */
+		    monitorp->Modes = mode;
+		    mode->prev = NULL;
+		}
+		last = mode;
+		i++;
+	    }
+	    while((xf86DefaultModes[i].name != NULL) &&
+		  (!strcmp(xf86DefaultModes[i].name,xf86DefaultModes[i-1].name)));
+	else
+	    i++;
+    }
+    monitorp->Last = last;
+
+    return TRUE;
+}
+
+/*
+ * load the config file and fill the global data structure
+ */
+ConfigStatus
+xf86HandleConfigFile(Bool autoconfig)
+{
+    const char *filename;
+    char *searchpath;
+    MessageType from = X_DEFAULT;
+    char *scanptr;
+    Bool singlecard = 0;
+
+    if (!autoconfig) {
+	if (getuid() == 0)
+	    searchpath = ROOT_CONFIGPATH;
+	else
+	    searchpath = USER_CONFIGPATH;
+
+	if (xf86ConfigFile)
+	    from = X_CMDLINE;
+
+	filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT);
+	if (filename) {
+	    xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename);
+	    xf86ConfigFile = xnfstrdup(filename);
+	} else {
+	    xf86Msg(X_ERROR, "Unable to locate/open config file");
+	    if (xf86ConfigFile)
+		xf86ErrorFVerb(0, ": \"%s\"", xf86ConfigFile);
+	    xf86ErrorFVerb(0, "\n");
+	    return CONFIG_NOFILE;
+	}
+    }
+     
+    if ((xf86configptr = xf86readConfigFile ()) == NULL) {
+	xf86Msg(X_ERROR, "Problem parsing the config file\n");
+	return CONFIG_PARSE_ERROR;
+    }
+    xf86closeConfigFile ();
+
+    /* Initialise a few things. */
+
+    /*
+     * now we convert part of the information contained in the parser
+     * structures into our own structures.
+     * The important part here is to figure out which Screen Sections
+     * in the XF86Config file are active so that we can piece together
+     * the modes that we need later down the road.
+     * And while we are at it, we'll decode the rest of the stuff as well
+     */
+
+    /* First check if a layout section is present, and if it is valid. */
+
+    if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
+	if (xf86ScreenName == NULL) {
+	    xf86Msg(X_WARNING,
+		    "No Layout section.  Using the first Screen section.\n");
+	}
+	if (!configImpliedLayout(&xf86ConfigLayout,
+				 xf86configptr->conf_screen_lst)) {
+            xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+	    return CONFIG_PARSE_ERROR;
+	}
+    } else {
+	if (xf86configptr->conf_flags != NULL) {
+	  char *dfltlayout = NULL;
+ 	  pointer optlist = xf86configptr->conf_flags->flg_option_lst;
+	
+	  if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
+	    dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL);
+	  if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+			  dfltlayout)) {
+	    xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+	    return CONFIG_PARSE_ERROR;
+	  }
+	} else {
+	  if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+			  NULL)) {
+	    xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+	    return CONFIG_PARSE_ERROR;
+	  }
+	}
+    }
+
+    xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
+
+    if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
+       ; /* IsolateDevice specified; overrides SingleCard */
+    } else {
+       xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
+       if (singlecard)
+           scanptr = xf86ConfigLayout.screens->screen->device->busID;
+    }
+    if (scanptr) {
+       int bus, device, func, stroffset = 0;
+       if (strncmp(scanptr, "PCI:", 4) != 0) {
+           xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
+                              "\tIgnoring IsolateDevice option.\n");
+       } else if (sscanf(scanptr, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
+           xf86IsolateDevice.bus = bus;
+           xf86IsolateDevice.device = device;
+           xf86IsolateDevice.func = func;
+           xf86Msg(X_INFO,
+                   "Isolating PCI bus \"%d:%d:%d\"\n", bus, device, func);
+       }
+    }
+
+    /* Now process everything else */
+
+    if (!configFiles(xf86configptr->conf_files) ||
+        !configServerFlags(xf86configptr->conf_flags,
+			   xf86ConfigLayout.options) ||
+	!configExtensions(xf86configptr->conf_extensions)
+#ifdef XF86DRI
+	|| !configDRI(xf86configptr->conf_dri)
+#endif
+       ) {
+             ErrorF ("Problem when converting the config data structures\n");
+             return CONFIG_PARSE_ERROR;
+    }
+
+    /*
+     * Handle some command line options that can override some of the
+     * ServerFlags settings.
+     */
+#ifdef XF86VIDMODE
+    if (xf86VidModeDisabled)
+	xf86Info.vidModeEnabled = FALSE;
+    if (xf86VidModeAllowNonLocal)
+	xf86Info.vidModeAllowNonLocal = TRUE;
+#endif
+
+#ifdef XF86MISC
+    if (xf86MiscModInDevDisabled)
+	xf86Info.miscModInDevEnabled = FALSE;
+    if (xf86MiscModInDevAllowNonLocal)
+	xf86Info.miscModInDevAllowNonLocal = TRUE;
+#endif
+
+    if (xf86AllowMouseOpenFail)
+	xf86Info.allowMouseOpenFail = TRUE;
+
+    return CONFIG_OK;
+}
+
+
+/* These make the equivalent parser functions visible to the common layer. */
+Bool
+xf86PathIsAbsolute(const char *path)
+{
+    return (xf86pathIsAbsolute(path) != 0);
+}
+
+Bool
+xf86PathIsSafe(const char *path)
+{
+    return (xf86pathIsSafe(path) != 0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1052 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */
+/*
+ * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:  Alan Hourihane, [email protected]
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "os.h"
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#include "xf86.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xf86Priv.h"
+#include "xf86PciData.h"
+#define IN_XSERVER
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include "vbe.h"
+#include "xf86DDC.h"
+#if defined(__sparc__) && !defined(__OpenBSD__)
+#include "xf86Bus.h"
+#include "xf86Sbus.h"
+#endif
+#include "globals.h"
+
+typedef struct _DevToConfig {
+    GDevRec GDev;
+    pciVideoPtr pVideo;
+#if defined(__sparc__) && !defined(__OpenBSD__)
+    sbusDevicePtr sVideo;
+#endif
+    int iDriver;
+} DevToConfigRec, *DevToConfigPtr;
+
+static DevToConfigPtr DevToConfig = NULL;
+static int nDevToConfig = 0, CurrentDriver;
+
+xf86MonPtr ConfiguredMonitor;
+Bool xf86DoConfigurePass1 = TRUE;
+Bool foundMouse = FALSE;
+
+#if defined(__UNIXOS2__)
+#define DFLT_MOUSE_DEV "mouse$"
+#define DFLT_MOUSE_PROTO "OS2Mouse"
+#elif defined(__SCO__)
+static char *DFLT_MOUSE_PROTO = "OSMouse";
+#elif defined(__UNIXWARE__)
+static char *DFLT_MOUSE_PROTO = "Xqueue";
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+#elif defined(QNX4)
+static char *DFLT_MOUSE_PROTO = "OSMouse";
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+#elif defined(__QNXNTO__)
+static char *DFLT_MOUSE_PROTO = "OSMouse";
+static char *DFLT_MOUSE_DEV = "/dev/devi/mouse0";
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#else
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#endif
+
+/*
+ * This is called by the driver, either through xf86Match???Instances() or
+ * directly.  We allocate a GDevRec and fill it in as much as we can, letting
+ * the caller fill in the rest and/or change it as it sees fit.
+ */
+GDevPtr
+xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
+{
+    int i, j;
+    pciVideoPtr pVideo = NULL;
+    Bool isPrimary = FALSE;
+
+    if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1)
+	return NULL;
+
+    /* Check for duplicates */
+    switch (bus) {
+    case BUS_PCI:
+	pVideo = (pciVideoPtr) busData;
+	for (i = 0;  i < nDevToConfig;  i++)
+	    if (DevToConfig[i].pVideo &&
+		(DevToConfig[i].pVideo->bus == pVideo->bus) &&
+		(DevToConfig[i].pVideo->device == pVideo->device) &&
+		(DevToConfig[i].pVideo->func == pVideo->func))
+		return NULL;
+	isPrimary = xf86IsPrimaryPci(pVideo);
+	break;
+    case BUS_ISA:
+	/*
+	 * This needs to be revisited as it doesn't allow for non-PCI
+	 * multihead.
+	 */
+	if (!xf86IsPrimaryIsa())
+	    return NULL;
+	isPrimary = TRUE;
+	for (i = 0;  i < nDevToConfig;  i++)
+	    if (!DevToConfig[i].pVideo)
+		return NULL;
+	break;
+#if defined(__sparc__) && !defined(__OpenBSD__)
+    case BUS_SBUS:
+	for (i = 0;  i < nDevToConfig;  i++)
+	    if (DevToConfig[i].sVideo &&
+		DevToConfig[i].sVideo->fbNum == ((sbusDevicePtr) busData)->fbNum)
+		return NULL;
+	break;
+#endif
+    default:
+	return NULL;
+    }
+
+    /* Allocate new structure occurrence */
+    i = nDevToConfig++;
+    DevToConfig =
+	xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
+#if 1   /* Doesn't work when a driver detects more than one adapter */
+    if ((i > 0) && isPrimary) {
+        memmove(DevToConfig + 1,DevToConfig,
+		(nDevToConfig - 1) * sizeof(DevToConfigRec));
+	i = 0;
+    } 
+#endif
+    memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
+
+#   define NewDevice DevToConfig[i]
+
+    NewDevice.GDev.chipID = NewDevice.GDev.chipRev = NewDevice.GDev.irq = -1;
+
+    NewDevice.iDriver = CurrentDriver;
+
+    /* Fill in what we know, converting the driver name to lower case */
+    NewDevice.GDev.driver = xnfalloc(strlen(driver) + 1);
+    for (j = 0;  (NewDevice.GDev.driver[j] = tolower(driver[j]));  j++);
+
+    switch (bus) {
+    case BUS_PCI: {
+	const char *VendorName;
+	const char *CardName;
+	char busnum[8];
+
+	NewDevice.pVideo = pVideo;
+	xf86FindPciNamesByDevice(pVideo->vendor, pVideo->chipType,
+				 NOVENDOR, NOSUBSYS,
+				 &VendorName, &CardName, NULL, NULL);
+
+	if (!VendorName) {
+	    VendorName = xnfalloc(15);
+	    sprintf((char*)VendorName, "Unknown Vendor");
+	}
+
+	if (!CardName) {
+	    CardName = xnfalloc(14);
+	    sprintf((char*)CardName, "Unknown Board");
+	}
+
+	NewDevice.GDev.identifier =
+	    xnfalloc(strlen(VendorName) + strlen(CardName) + 2);
+	sprintf(NewDevice.GDev.identifier, "%s %s", VendorName, CardName);
+
+	NewDevice.GDev.vendor = (char *)VendorName;
+	NewDevice.GDev.board = (char *)CardName;
+
+	NewDevice.GDev.busID = xnfalloc(16);
+	xf86FormatPciBusNumber(pVideo->bus, busnum);
+	sprintf(NewDevice.GDev.busID, "PCI:%s:%d:%d",
+	    busnum, pVideo->device, pVideo->func);
+
+	NewDevice.GDev.chipID = pVideo->chipType;
+	NewDevice.GDev.chipRev = pVideo->chipRev;
+
+	if (chipset < 0)
+	    chipset = (pVideo->vendor << 16) | pVideo->chipType;
+	}
+	break;
+    case BUS_ISA:
+	NewDevice.GDev.identifier = "ISA Adapter";
+	NewDevice.GDev.busID = "ISA";
+	break;
+#if defined(__sparc__) && !defined(__OpenBSD__)
+    case BUS_SBUS: {
+	char *promPath = NULL;
+	NewDevice.sVideo = (sbusDevicePtr) busData;
+	NewDevice.GDev.identifier = NewDevice.sVideo->descr;
+	if (sparcPromInit() >= 0) {
+	    promPath = sparcPromNode2Pathname(&NewDevice.sVideo->node);
+	    sparcPromClose();
+	}
+	if (promPath) {
+	    NewDevice.GDev.busID = xnfalloc(strlen(promPath) + 6);
+	    sprintf(NewDevice.GDev.busID, "SBUS:%s", promPath);
+	    xfree(promPath);
+	} else {
+	    NewDevice.GDev.busID = xnfalloc(12);
+	    sprintf(NewDevice.GDev.busID, "SBUS:fb%d", NewDevice.sVideo->fbNum);
+	}
+	}
+	break;
+#endif
+    default:
+	break;
+    }
+
+    /* Get driver's available options */
+    if (xf86DriverList[CurrentDriver]->AvailableOptions)
+	NewDevice.GDev.options = (OptionInfoPtr)
+	    (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
+							       bus);
+
+    return &NewDevice.GDev;
+
+#   undef NewDevice
+}
+
+/*
+ * Backwards compatibility
+ */
+GDevPtr
+xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
+{
+    return xf86AddBusDeviceToConfigure(driver, pVideo ? BUS_PCI : BUS_ISA,
+				       pVideo, chipset);
+}
+
+static XF86ConfInputPtr
+configureInputSection (void)
+{
+    XF86ConfInputPtr mouse = NULL;
+    parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+    ptr->inp_identifier = "Keyboard0";
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+    ptr->inp_driver = "keyboard";
+#else
+    ptr->inp_driver = "kbd";
+#endif
+    ptr->list.next = NULL;
+
+    /* Crude mechanism to auto-detect mouse (os dependent) */
+    { 
+	int fd;
+#if 0 && defined linux
+	/* Our autodetection code can do a better job */
+	int len;
+	char path[32];
+
+	if ((len = readlink(DFLT_MOUSE_DEV, path, sizeof(path) - 1)) > 0) {
+	    path[len] = '\0';
+	    if (strstr(path, "psaux") != NULL)
+		DFLT_MOUSE_PROTO = "PS/2";
+	}
+#endif
+#ifdef WSCONS_SUPPORT
+	fd = open("/dev/wsmouse", 0);
+	if (fd > 0) {
+	    DFLT_MOUSE_DEV = "/dev/wsmouse";
+	    DFLT_MOUSE_PROTO = "wsmouse";
+	    close(fd);
+	} else {
+	    ErrorF("cannot open /dev/wsmouse\n");
+	}
+#endif
+
+#ifndef __SCO__
+	fd = open(DFLT_MOUSE_DEV, 0);
+	if (fd != -1) {
+	    foundMouse = TRUE;
+	    close(fd);
+	}
+#else
+	foundMouse = TRUE;
+#endif
+    }
+
+    mouse = xf86confmalloc(sizeof(XF86ConfInputRec));
+    memset((XF86ConfInputPtr)mouse,0,sizeof(XF86ConfInputRec));
+    mouse->inp_identifier = "Mouse0";
+    mouse->inp_driver = "mouse";
+    mouse->inp_option_lst = 
+		xf86addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO);
+#ifndef __SCO__
+    mouse->inp_option_lst = 
+		xf86addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV);
+#endif
+    mouse->inp_option_lst = 
+		xf86addNewOption(mouse->inp_option_lst, "ZAxisMapping", "4 5 6 7");
+    ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
+    return ptr;
+}
+
+static XF86ConfDRIPtr
+configureDRISection (void)
+{
+#ifdef NOTYET
+    parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec)
+
+    return ptr;
+#else
+    return NULL;
+#endif
+}
+
+static XF86ConfVendorPtr
+configureVendorSection (void)
+{
+    parsePrologue (XF86ConfVendorPtr, XF86ConfVendorRec)
+
+    return NULL;
+#if 0
+    return ptr;
+#endif
+}
+
+static XF86ConfScreenPtr
+configureScreenSection (int screennum)
+{
+    int i;
+    int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
+    parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+
+    ptr->scrn_identifier = xf86confmalloc(18);
+    sprintf(ptr->scrn_identifier, "Screen%d", screennum);
+    ptr->scrn_monitor_str = xf86confmalloc(19);
+    sprintf(ptr->scrn_monitor_str, "Monitor%d", screennum);
+    ptr->scrn_device_str = xf86confmalloc(16);
+    sprintf(ptr->scrn_device_str, "Card%d", screennum);
+
+    for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
+    {
+	XF86ConfDisplayPtr display;
+
+	display = xf86confmalloc(sizeof(XF86ConfDisplayRec));
+    	memset((XF86ConfDisplayPtr)display,0,sizeof(XF86ConfDisplayRec));
+	display->disp_depth = depths[i];
+	display->disp_black.red = display->disp_white.red = -1;
+	display->disp_black.green = display->disp_white.green = -1;
+	display->disp_black.blue = display->disp_white.blue = -1;
+	ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
+				     (glp)ptr->scrn_display_lst, (glp)display);
+    }
+
+    return ptr;
+}
+
+static const char* 
+optionTypeToSting(OptionValueType type)
+{
+    switch (type) {
+    case OPTV_NONE:
+        return "";
+    case OPTV_INTEGER:
+        return "<i>";
+    case OPTV_STRING:
+        return "<str>";
+    case OPTV_ANYSTR:
+       return "[<str>]";
+    case OPTV_REAL:
+        return "<f>";
+    case OPTV_BOOLEAN:
+        return "[<bool>]";
+    case OPTV_FREQ:
+        return "<freq>";
+    default:
+        return "";
+    }
+}
+
+static XF86ConfDevicePtr
+configureDeviceSection (int screennum)
+{
+    char identifier[16];
+    OptionInfoPtr p;
+    int i = 0;
+#ifdef DO_FBDEV_PROBE
+    Bool foundFBDEV = FALSE;
+#endif
+    parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+    /* Move device info to parser structure */
+    sprintf(identifier, "Card%d", screennum);
+    ptr->dev_identifier = strdup(identifier);
+/*    ptr->dev_identifier = DevToConfig[screennum].GDev.identifier;*/
+    ptr->dev_vendor = DevToConfig[screennum].GDev.vendor;
+    ptr->dev_board = DevToConfig[screennum].GDev.board;
+    ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
+    ptr->dev_busid = DevToConfig[screennum].GDev.busID;
+    ptr->dev_driver = DevToConfig[screennum].GDev.driver;
+    ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
+    for (i = 0;  (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS);  i++)
+        ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
+    ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
+    ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
+    ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
+    ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
+    ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
+    ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
+    for (i = 0;  (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks);  i++)
+        ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
+    ptr->dev_clocks = i;
+    ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
+    ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
+    ptr->dev_irq = DevToConfig[screennum].GDev.irq;
+
+    /* Make sure older drivers don't segv */
+    if (DevToConfig[screennum].GDev.options) {
+    	/* Fill in the available driver options for people to use */
+	const char *descrip =
+	    "        ### Available Driver options are:-\n"
+	    "        ### Values: <i>: integer, <f>: float, "
+			"<bool>: \"True\"/\"False\",\n"
+	    "        ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\"\n"
+	    "        ### [arg]: arg optional\n";
+	ptr->dev_comment = xstrdup(descrip);
+	if (ptr->dev_comment) {
+    	    for (p = DevToConfig[screennum].GDev.options;
+		 p->name != NULL; p++) {
+		char *p_e;
+		const char *prefix = "        #Option     ";
+		const char *middle = " \t# ";
+		const char *suffix = "\n";
+		const char *opttype = optionTypeToSting(p->type);
+		char *optname;
+		int len = strlen(ptr->dev_comment) + strlen(prefix) +
+			  strlen(middle) + strlen(suffix) + 1;
+		
+		optname = xalloc(strlen(p->name) + 2 + 1);
+		if (!optname)
+		    break;
+		sprintf(optname, "\"%s\"", p->name);
+
+		len += max(20, strlen(optname));
+		len += strlen(opttype);
+
+		ptr->dev_comment = xrealloc(ptr->dev_comment, len);
+		if (!ptr->dev_comment)
+		    break;
+		p_e = ptr->dev_comment + strlen(ptr->dev_comment);
+		sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
+			opttype, suffix);
+		xfree(optname);
+	    }
+    	}
+    }
+
+#ifdef DO_FBDEV_PROBE
+    /* Crude mechanism to auto-detect fbdev (os dependent) */
+    /* Skip it for now. Options list it anyway, and we can't
+     * determine which screen/driver this belongs too anyway. */
+    {
+	int fd;
+
+	fd = open("/dev/fb0", 0);
+	if (fd != -1) {
+	    foundFBDEV = TRUE;
+	    close(fd);
+	}
+    }
+
+    if (foundFBDEV) {
+	XF86OptionPtr fbdev;
+
+    	fbdev = xf86confmalloc(sizeof(XF86OptionRec));
+    	memset((XF86OptionPtr)fbdev,0,sizeof(XF86OptionRec));
+    	fbdev->opt_name = "UseFBDev";
+	fbdev->opt_val = "ON";
+	ptr->dev_option_lst = (XF86OptionPtr)xf86addListItem(
+					(glp)ptr->dev_option_lst, (glp)fbdev);
+    }
+#endif
+
+    return ptr;
+}
+
+static XF86ConfLayoutPtr
+configureLayoutSection (void)
+{
+    int scrnum = 0;
+    parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+    ptr->lay_identifier = "X.org Configured";
+
+    {
+	XF86ConfInputrefPtr iptr;
+
+	iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec));
+	iptr->list.next = NULL;
+	iptr->iref_option_lst = NULL;
+	iptr->iref_inputdev_str = "Mouse0";
+	iptr->iref_option_lst =
+		xf86addNewOption (iptr->iref_option_lst, "CorePointer", NULL);
+	ptr->lay_input_lst = (XF86ConfInputrefPtr)
+		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+    }
+
+    {
+	XF86ConfInputrefPtr iptr;
+
+	iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec));
+	iptr->list.next = NULL;
+	iptr->iref_option_lst = NULL;
+	iptr->iref_inputdev_str = "Keyboard0";
+	iptr->iref_option_lst =
+		xf86addNewOption (iptr->iref_option_lst, "CoreKeyboard", NULL);
+	ptr->lay_input_lst = (XF86ConfInputrefPtr)
+		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+    }
+
+    for (scrnum = 0;  scrnum < nDevToConfig;  scrnum++) {
+	XF86ConfAdjacencyPtr aptr;
+
+	aptr = xf86confmalloc (sizeof (XF86ConfAdjacencyRec));
+	aptr->list.next = NULL;
+	aptr->adj_x = 0;
+	aptr->adj_y = 0;
+	aptr->adj_scrnum = scrnum;
+	aptr->adj_screen_str = xnfalloc(18);
+	sprintf(aptr->adj_screen_str, "Screen%d", scrnum);
+	if (scrnum == 0) {
+	    aptr->adj_where = CONF_ADJ_ABSOLUTE;
+	    aptr->adj_refscreen = NULL;
+	}
+	else {
+	    aptr->adj_where = CONF_ADJ_RIGHTOF;
+	    aptr->adj_refscreen = xnfalloc(18);
+	    sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1);
+	}
+    	ptr->lay_adjacency_lst =
+	    (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
+					      (glp)aptr);
+    }
+
+    return ptr;
+}
+
+static XF86ConfModesPtr
+configureModesSection (void)
+{
+#ifdef NOTYET
+    parsePrologue (XF86ConfModesPtr, XF86ConfModesRec)
+
+    return ptr;
+#else
+    return NULL;
+#endif
+}
+
+static XF86ConfVideoAdaptorPtr
+configureVideoAdaptorSection (void)
+{
+    parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
+
+    return NULL;
+#if 0
+    return ptr;
+#endif
+}
+
+static XF86ConfFlagsPtr
+configureFlagsSection (void)
+{
+    parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+    return ptr;
+}
+
+static XF86ConfModulePtr
+configureModuleSection (void)
+{
+#ifdef XFree86LOADER
+    char **elist, **el;
+    /* Find the list of extension modules. */
+    const char *esubdirs[] = {
+	"extensions",
+	NULL
+    };
+    const char *fsubdirs[] = {
+	"fonts",
+	NULL
+    };
+#endif
+    parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
+
+#ifdef XFree86LOADER
+    elist = LoaderListDirs(esubdirs, NULL);
+    if (elist) {
+	for (el = elist; *el; el++) {
+	    XF86LoadPtr module;
+
+    	    module = xf86confmalloc(sizeof(XF86LoadRec));
+    	    memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec));
+    	    module->load_name = *el;
+	    /* HACK, remove GLcore, glx, loads it as a submodule */
+	    if (strcmp(*el, "GLcore"))
+	    	ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
+					(glp)ptr->mod_load_lst, (glp)module);
+    	}
+	xfree(elist);
+    }
+
+    /* Process list of font backends separately to include only required ones */
+    elist = LoaderListDirs(fsubdirs, NULL);
+    if (elist) {
+	for (el = elist; *el; el++) {
+	    XF86LoadPtr module;
+
+    	    module = xf86confmalloc(sizeof(XF86LoadRec));
+    	    memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec));
+    	    module->load_name = *el;
+
+            /* Add only those font backends which are referenced by fontpath */
+            /* 'strstr(dFP,"/dir")' is meant as 'dFP =~ m(/dir\W)' */
+    	    if (defaultFontPath && (
+#ifdef SUNSOFT
+		(strcmp(*el, "bitstream") == 0) ||
+#endif
+		(strcmp(*el, "freetype")  == 0 &&
+		 strstr(defaultFontPath, "/TTF")) ||
+    	        (strcmp(*el, "type1")  == 0 &&
+		 strstr(defaultFontPath, "/Type1")) ||
+    	        (strcmp(*el, "speedo") == 0 &&
+		 strstr(defaultFontPath, "/Speedo"))))
+	    	ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
+					(glp)ptr->mod_load_lst, (glp)module);
+    	}
+	xfree(elist);
+    }
+#endif
+
+    return ptr;
+}
+
+static XF86ConfFilesPtr
+configureFilesSection (void)
+{
+    parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
+
+#ifdef XFree86LOADER
+   if (xf86ModulePath)
+       ptr->file_modulepath = strdup(xf86ModulePath);
+#endif
+   if (defaultFontPath)
+       ptr->file_fontpath = strdup(defaultFontPath);
+   if (rgbPath)
+       ptr->file_rgbpath = strdup(rgbPath);
+   
+    return ptr;
+}
+
+static XF86ConfMonitorPtr
+configureMonitorSection (int screennum)
+{
+    parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+    ptr->mon_identifier = xf86confmalloc(19);
+    sprintf(ptr->mon_identifier, "Monitor%d", screennum);
+    ptr->mon_vendor = strdup("Monitor Vendor");
+    ptr->mon_modelname = strdup("Monitor Model");
+
+    return ptr;
+}
+
+static XF86ConfMonitorPtr
+configureDDCMonitorSection (int screennum)
+{
+    int i = 0;
+    int len, mon_width, mon_height;
+#define displaySizeMaxLen 80
+    char displaySize_string[displaySizeMaxLen];
+    int displaySizeLen;
+
+    parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+    ptr->mon_identifier = xf86confmalloc(19);
+    sprintf(ptr->mon_identifier, "Monitor%d", screennum);
+    ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
+    ptr->mon_modelname = xf86confmalloc(12);
+    sprintf(ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
+
+    /* features in centimetres, we want millimetres */
+    mon_width  = 10 * ConfiguredMonitor->features.hsize ;
+    mon_height = 10 * ConfiguredMonitor->features.vsize ;
+
+#ifdef CONFIGURE_DISPLAYSIZE
+    ptr->mon_width  = mon_width;
+    ptr->mon_height = mon_height;
+#else
+    if (mon_width && mon_height) {
+      /* when values available add DisplaySize option AS A COMMENT */
+
+      displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
+				"\t#DisplaySize\t%5d %5d\t# mm\n",
+				mon_width, mon_height);
+
+      if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
+	if (ptr->mon_comment) {
+	  len = strlen(ptr->mon_comment);
+	} else {
+	  len = 0;
+	}
+	if ((ptr->mon_comment =
+	     xf86confrealloc(ptr->mon_comment, 
+			     len+strlen(displaySize_string)))) {
+	  strcpy(ptr->mon_comment + len, displaySize_string);
+	}
+      }
+    }
+#endif /* def CONFIGURE_DISPLAYSIZE */
+
+    for (i=0;i<4;i++) {
+	switch (ConfiguredMonitor->det_mon[i].type) {
+	    case DS_NAME:
+		ptr->mon_modelname  = xf86confrealloc(ptr->mon_modelname, 
+		  strlen((char*)(ConfiguredMonitor->det_mon[i].section.name))
+		    + 1);
+		strcpy(ptr->mon_modelname,
+		       (char*)(ConfiguredMonitor->det_mon[i].section.name));
+		break;
+	    case DS_RANGES:
+		ptr->mon_hsync[ptr->mon_n_hsync].lo =
+		    ConfiguredMonitor->det_mon[i].section.ranges.min_h;
+		ptr->mon_hsync[ptr->mon_n_hsync].hi =
+		    ConfiguredMonitor->det_mon[i].section.ranges.max_h;
+		ptr->mon_n_vrefresh = 1;
+		ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
+		    ConfiguredMonitor->det_mon[i].section.ranges.min_v;
+		ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
+		    ConfiguredMonitor->det_mon[i].section.ranges.max_v;
+		ptr->mon_n_hsync++;
+	    default:
+		break;
+	}
+    }
+
+    if (ConfiguredMonitor->features.dpms) {
+      ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, "DPMS", NULL);
+    }
+
+    return ptr;
+}
+
+void
+DoConfigure()
+{
+    int i,j, screennum = -1;
+    char *home = NULL;
+    char *filename = NULL;
+    XF86ConfigPtr xf86config = NULL;
+    char **vlist, **vl;
+    int *dev2screen;
+
+    vlist = xf86DriverlistFromCompile();
+
+    if (!vlist) {
+	ErrorF("Missing output drivers.  Configuration failed.\n");
+	goto bail;
+    }
+
+    ErrorF("List of video drivers:\n");
+    for (vl = vlist; *vl; vl++)
+	ErrorF("\t%s\n", *vl);
+
+#ifdef XFree86LOADER
+    /* Load all the drivers that were found. */
+    xf86LoadModules(vlist, NULL);
+#endif /* XFree86LOADER */
+
+    xfree(vlist);
+
+    for (i = 0; i < xf86NumDrivers; i++) {
+	xorgHWFlags flags;
+	if (!xf86DriverList[i]->driverFunc
+	    || !xf86DriverList[i]->driverFunc(NULL,
+					      GET_REQUIRED_HW_INTERFACES,
+					      &flags)
+	    || NEED_IO_ENABLED(flags)) {
+	    xorgHWAccess = TRUE;
+	    break;
+	}
+    }
+    /* Enable full I/O access */
+    if (xorgHWAccess) {
+	if(!xf86EnableIO())
+	    /* oops, we have failed */
+	    xorgHWAccess = FALSE;
+    }
+
+    /* Disable PCI devices */
+    xf86ResourceBrokerInit();
+    xf86AccessInit();
+    xf86FindPrimaryDevice();
+ 
+    /* Create XF86Config file structure */
+    xf86config = malloc(sizeof(XF86ConfigRec));
+    memset ((XF86ConfigPtr)xf86config, 0, sizeof(XF86ConfigRec));
+    xf86config->conf_device_lst = NULL;
+    xf86config->conf_screen_lst = NULL;
+    xf86config->conf_monitor_lst = NULL;
+
+    /* Call all of the probe functions, reporting the results. */
+    for (CurrentDriver = 0;  CurrentDriver < xf86NumDrivers;  CurrentDriver++) {
+	xorgHWFlags flags;
+	
+	if (!xorgHWAccess) {
+	    if (!xf86DriverList[CurrentDriver]->driverFunc
+		|| !xf86DriverList[CurrentDriver]->driverFunc(NULL,
+						GET_REQUIRED_HW_INTERFACES,
+						&flags)
+		|| NEED_IO_ENABLED(flags)) 
+		continue;
+	}
+	
+	if (xf86DriverList[CurrentDriver]->Probe == NULL) continue;
+
+	if ((*xf86DriverList[CurrentDriver]->Probe)(
+	    xf86DriverList[CurrentDriver], PROBE_DETECT) &&
+	    xf86DriverList[CurrentDriver]->Identify)
+	    (*xf86DriverList[CurrentDriver]->Identify)(0);
+    }
+
+    if (nDevToConfig <= 0) {
+	ErrorF("No devices to configure.  Configuration failed.\n");
+	goto bail;
+    }
+
+    /* Add device, monitor and screen sections for detected devices */
+    for (screennum = 0;  screennum < nDevToConfig;  screennum++) {
+    	XF86ConfDevicePtr DevicePtr;
+	XF86ConfMonitorPtr MonitorPtr;
+	XF86ConfScreenPtr ScreenPtr;
+
+	DevicePtr = configureDeviceSection(screennum);
+    	xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
+			    (glp)xf86config->conf_device_lst, (glp)DevicePtr);
+	MonitorPtr = configureMonitorSection(screennum);
+    	xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+			    (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+	ScreenPtr = configureScreenSection(screennum);
+    	xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+			    (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+    }
+
+    xf86config->conf_files = configureFilesSection();
+    xf86config->conf_modules = configureModuleSection();
+    xf86config->conf_flags = configureFlagsSection();
+    xf86config->conf_videoadaptor_lst = configureVideoAdaptorSection();
+    xf86config->conf_modes_lst = configureModesSection();
+    xf86config->conf_vendor_lst = configureVendorSection();
+    xf86config->conf_dri = configureDRISection();
+    xf86config->conf_input_lst = configureInputSection();
+    xf86config->conf_layout_lst = configureLayoutSection();
+
+    if (!(home = getenv("HOME")))
+    	home = "/";
+    {
+#ifdef __UNIXOS2__
+#define PATH_MAX 2048
+#endif
+#if !defined(PATH_MAX)
+#define PATH_MAX 1024
+#endif
+        const char* configfile = XF86CONFIGFILE".new";
+    	char homebuf[PATH_MAX];
+    	/* getenv might return R/O memory, as with OS/2 */
+    	strncpy(homebuf,home,PATH_MAX-1);
+    	homebuf[PATH_MAX-1] = '\0';
+    	home = homebuf;
+    	if (!(filename =
+	     (char *)ALLOCATE_LOCAL(strlen(home) + 
+	  			 strlen(configfile) + 3)))
+
+      	if (home[0] == '/' && home[1] == '\0')
+            home[0] = '\0';
+#ifndef QNX4
+	sprintf(filename, "%s/%s", home,configfile);
+#else
+	sprintf(filename, "//%d%s/%s", getnid(),home,configfile);
+#endif
+	
+    }
+
+    xf86writeConfigFile(filename, xf86config);
+
+    xf86DoConfigurePass1 = FALSE;
+    /* Try to get DDC information filled in */
+    xf86ConfigFile = filename;
+    if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
+	goto bail;
+    }
+
+    xf86DoConfigurePass1 = FALSE;
+    
+    dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
+
+    {
+	Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
+	for (screennum = 0;  screennum < nDevToConfig;  screennum++) {
+	    int k,l,n,oldNumScreens;
+
+	    i = DevToConfig[screennum].iDriver;
+
+	    if (driverProbed[i]) continue;
+	    driverProbed[i] = TRUE;
+	    
+	    oldNumScreens = xf86NumScreens;
+
+	    (*xf86DriverList[i]->Probe)(xf86DriverList[i], 0);
+
+	    /* reorder */
+	    k = screennum > 0 ? screennum : 1;
+	    for (l = oldNumScreens; l < xf86NumScreens; l++) {
+	        /* is screen primary? */
+	        Bool primary = FALSE;
+		for (n = 0; n<xf86Screens[l]->numEntities; n++) {
+	            if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
+		        dev2screen[0] = l;
+			primary = TRUE;
+			break;
+		    }
+		}
+		if (primary) continue;
+		/* not primary: assign it to next device of same driver */
+		/* 
+		 * NOTE: we assume that devices in DevToConfig 
+		 * and xf86Screens[] have the same order except
+		 * for the primary device which always comes first.
+		 */
+		for (; k < nDevToConfig; k++) {
+		    if (DevToConfig[k].iDriver == i) {
+		        dev2screen[k++] = l;
+			break;
+		    }
+		}
+	    }
+	    xf86SetPciVideo(NULL,NONE);
+	}
+	xfree(driverProbed);
+    }
+    
+
+    if (nDevToConfig != xf86NumScreens) {
+	ErrorF("Number of created screens does not match number of detected"
+	       " devices.\n  Configuration failed.\n");
+	goto bail;
+    }
+
+    xf86PostProbe();
+    xf86EntityInit();
+
+    for (j = 0; j < xf86NumScreens; j++) {
+	xf86Screens[j]->scrnIndex = j;
+    }
+
+    xf86freeMonitorList(xf86config->conf_monitor_lst);
+    xf86config->conf_monitor_lst = NULL;
+    xf86freeScreenList(xf86config->conf_screen_lst);
+    xf86config->conf_screen_lst = NULL;
+    for (j = 0; j < xf86NumScreens; j++) {
+	XF86ConfMonitorPtr MonitorPtr;
+	XF86ConfScreenPtr ScreenPtr;
+
+	ConfiguredMonitor = NULL;
+
+	xf86EnableAccess(xf86Screens[dev2screen[j]]);
+	if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]], 
+						   PROBE_DETECT) &&
+	    ConfiguredMonitor) {
+	    MonitorPtr = configureDDCMonitorSection(j);
+	} else {
+	    MonitorPtr = configureMonitorSection(j);
+	}
+	ScreenPtr = configureScreenSection(j);
+	xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+		(glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+	xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+		(glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+    }
+
+    xf86writeConfigFile(filename, xf86config);
+
+    ErrorF("\n");
+
+#ifdef __SCO__
+    ErrorF("\n"__XSERVERNAME__
+	   " is using the kernel event driver to access the mouse.\n"
+	    "If you wish to use the internal "__XSERVERNAME__
+	   " mouse drivers, please\n"
+	    "edit the file and correct the Device.\n");
+#else /* !__SCO__ */
+    if (!foundMouse) {
+	ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
+		"Edit the file and correct the Device.\n");
+    } else {
+#ifndef __UNIXOS2__  /* OS/2 definitely has a mouse */
+	ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
+		"Please check your config if the mouse is still not\n"
+		"operational, as by default "__XSERVERNAME__
+	       " tries to autodetect\n"
+		"the protocol.\n",DFLT_MOUSE_DEV);
+#endif
+    }
+#endif /* !__SCO__ */
+
+    if (xf86NumScreens > 1) {
+	ErrorF("\n"__XSERVERNAME__
+	       " has configured a multihead system, please check your config.\n");
+    }
+
+    ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
+    ErrorF("To test the server, run 'X -config %s'\n\n", filename);
+
+bail:
+    OsCleanup(TRUE);
+    AbortDDX();
+    fflush(stderr);
+    exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,256 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Globals.c,v 1.42 2004/01/27 01:31:44 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ */
+
+/*
+ * This file contains all the XFree86 global variables.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Parser.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "xf86DDC.h"
+
+/* Globals that video drivers may access */
+
+int xf86ScreenIndex = -1;	/* Index of ScrnInfo in pScreen.devPrivates */
+int xf86CreateRootWindowIndex = -1;	/* Index into pScreen.devPrivates */
+ScrnInfoPtr *xf86Screens = NULL;	/* List of ScrnInfos */
+int xf86PixmapIndex = 0;
+const unsigned char byte_reversed[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,
+};
+
+/* Globals that input drivers may access */
+InputInfoPtr xf86InputDevs = NULL;
+
+
+/* Globals that video drivers may not access */
+
+xf86InfoRec xf86Info = {
+	NULL,		/* pKeyboard */
+	NULL,		/* kbdProc */
+	NULL,		/* kbdEvents */
+	-1,		/* consoleFd */
+	-1,		/* kbdFd */
+	-1,		/* vtno */
+	-1,		/* kbdType */
+	-1,		/* kbdRate */
+	-1, 		/* kbdDelay */
+	-1,		/* bell_pitch */
+	-1,		/* bell_duration */
+	TRUE,		/* autoRepeat */
+	0,		/* leds */
+	0,		/* xleds */
+	NULL,		/* vtinit */
+	0,		/* scanPrefix */
+	FALSE,		/* capsLock */
+	FALSE,		/* numLock */
+	FALSE,		/* scrollLock */
+	FALSE,		/* modeSwitchLock */
+	FALSE,		/* composeLock */
+	FALSE,		/* vtSysreq */
+	SKWhenNeeded,	/* ddxSpecialKeys */
+	FALSE,		/* ActionKeyBindingsSet */
+#if defined(SVR4) && defined(i386)
+	FALSE,		/* panix106 */
+#endif
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+	0,		/* wskbdType */
+#endif
+	NULL,		/* pMouse */
+#ifdef XINPUT
+	NULL,		/* mouseLocal */
+#endif
+	-1,		/* lastEventTime */
+	FALSE,		/* vtRequestsPending */
+	FALSE,		/* inputPending */
+	FALSE,		/* dontVTSwitch */
+	FALSE,		/* dontZap */
+	FALSE,		/* dontZoom */
+	FALSE,		/* notrapSignals */
+	FALSE,		/* caughtSignal */
+	FALSE,		/* sharedMonitor */
+	NULL,		/* currentScreen */
+#ifdef CSRG_BASED
+	-1,		/* screenFd */
+	-1,		/* consType */
+#endif
+#ifdef XKB
+	NULL,		/* xkbkeymap */
+	NULL,		/* xkbkeycodes */
+	NULL,		/* xkbtypes */
+	NULL,		/* xkbcompat */
+	NULL,		/* xkbsymbols */
+	NULL,		/* xkbgeometry */
+	FALSE,		/* xkbcomponents_specified */
+	NULL,		/* xkbrules */
+	NULL,		/* xkbmodel */
+	NULL,		/* xkblayout */
+	NULL,		/* xkbvariant */
+	NULL,		/* xkboptions */
+#endif
+	FALSE,		/* allowMouseOpenFail */
+	TRUE,		/* vidModeEnabled */
+	FALSE,		/* vidModeAllowNonLocal */
+	TRUE,		/* miscModInDevEnabled */
+	FALSE,		/* miscModInDevAllowNonLocal */
+	PCIOsConfig,	/* pciFlags */
+	Pix24DontCare,	/* pixmap24 */
+	X_DEFAULT,	/* pix24From */
+#if defined(i386) || defined(__i386__)
+	FALSE,		/* pc98 */
+#endif
+	TRUE,		/* pmFlag */
+	LogNone,	/* syncLog */
+	0,		/* estimateSizesAggressively */
+	FALSE,		/* kbdCustomKeycodes */
+	FALSE,		/* disableRandR */
+	X_DEFAULT	/* randRFrom */
+};
+const char *xf86ConfigFile = NULL;
+const char *xf86InputDeviceList = NULL;
+const char *xf86ModulePath = DEFAULT_MODULE_PATH;
+MessageType xf86ModPathFrom = X_DEFAULT;
+const char *xf86LogFile = DEFAULT_LOGPREFIX;
+MessageType xf86LogFileFrom = X_DEFAULT;
+Bool xf86LogFileWasOpened = FALSE;
+serverLayoutRec xf86ConfigLayout = {NULL, };
+confDRIRec xf86ConfigDRI = {0, };
+XF86ConfigPtr xf86configptr = NULL;
+Bool xf86Resetting = FALSE;
+Bool xf86Initialising = FALSE;
+Bool xf86ProbeFailed = FALSE;
+Bool xf86DoProbe = FALSE;
+Bool xf86DoConfigure = FALSE;
+#ifdef XFree86LOADER
+DriverPtr *xf86DriverList = NULL;
+int xf86NumDrivers = 0;
+InputDriverPtr *xf86InputDriverList = NULL;
+int xf86NumInputDrivers = 0;
+ModuleInfoPtr *xf86ModuleInfoList = NULL;
+int xf86NumModuleInfos = 0;
+xf86MonPtr (*xf86FallbackDDCProbe) (int entityIndex, ScrnInfoPtr scrp) = NULL;
+#endif
+int xf86NumScreens = 0;
+
+const char *xf86VisualNames[] = {
+	"StaticGray",
+	"GrayScale",
+	"StaticColor",
+	"PseudoColor",
+	"TrueColor",
+	"DirectColor"
+};
+
+/* Parameters set only from the command line */
+char *xf86ServerName = "no-name";
+Bool xf86fpFlag = FALSE;
+Bool xf86coFlag = FALSE;
+Bool xf86sFlag = FALSE;
+Bool xf86bsEnableFlag = FALSE;
+Bool xf86bsDisableFlag = FALSE;
+Bool xf86silkenMouseDisableFlag = FALSE;
+Bool xf86acpiDisableFlag = FALSE;
+char *xf86LayoutName = NULL;
+char *xf86ScreenName = NULL;
+char *xf86PointerName = NULL;
+char *xf86KeyboardName = NULL;
+Bool xf86ProbeOnly = FALSE;
+int xf86Verbose = DEFAULT_VERBOSE;
+int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
+int xf86FbBpp = -1;
+Pix24Flags xf86Pix24 = Pix24DontCare;
+int xf86Depth = -1;
+rgb xf86Weight = {0, 0, 0};
+Bool xf86FlipPixels = FALSE;
+Gamma xf86Gamma = {0.0, 0.0, 0.0};
+Bool xf86ShowUnresolved = DEFAULT_UNRESOLVED;
+Bool xf86BestRefresh = DEFAULT_BEST_REFRESH;
+Bool xf86AllowMouseOpenFail = FALSE;
+#ifdef XF86VIDMODE
+Bool xf86VidModeDisabled = FALSE;
+Bool xf86VidModeAllowNonLocal = FALSE;
+#endif
+#ifdef XF86MISC
+Bool xf86MiscModInDevDisabled = FALSE;
+Bool xf86MiscModInDevAllowNonLocal = FALSE;
+#endif
+RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
+Bool xf86inSuspend = FALSE;
+Bool xorgHWAccess = FALSE;
+PciBusId xf86IsolateDevice;
+
+#ifdef DLOPEN_HACK
+/*
+ * This stuff is a hack to allow dlopen() modules to work.  It is intended
+ * only to be used when using dlopen() modules for debugging purposes.
+ */
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Init.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2035 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.212 2004/01/27 01:31:45 dawes Exp $ */
+/* $XdotOrg: $ */
+
+/*
+ * Loosely based on code bearing the following copyright:
+ *
+ *   Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+/*
+ * Copyright (c) 1992-2003 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#undef HAS_UTSNAME
+#if !defined(WIN32) && !defined(__UNIXOS2__)
+#define HAS_UTSNAME 1
+#include <sys/utsname.h>
+#endif
+
+#define NEED_EVENTS
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include <X11/Xatom.h>
+#include "input.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "site.h"
+#include "mi.h"
+
+#include "compiler.h"
+
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#define XF86_OS_PRIVS
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xorgVersion.h"
+#include "xf86Date.h"
+#include "xf86Build.h"
+#include "mipointer.h"
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#else
+#include "inputstr.h"
+#endif
+#include "xf86DDC.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+
+#include "globals.h"
+
+#ifdef XTESTEXT1
+#include "atKeynames.h"
+extern int xtest_command_key;
+#endif /* XTESTEXT1 */
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#include "dpmsproc.h"
+#endif
+
+
+/* forward declarations */
+
+static void xf86PrintBanner(void);
+static void xf86PrintMarkers(void);
+static void xf86RunVtInit(void);
+
+#ifdef __UNIXOS2__
+extern void os2ServerVideoAccess();
+#endif
+
+#ifdef XF86PM
+void (*xf86OSPMClose)(void) = NULL;
+#endif
+
+#ifdef XFree86LOADER
+static char *baseModules[] = {
+	"bitmap",
+	"pcidata",
+	NULL
+};
+#endif
+
+/* Common pixmap formats */
+
+static PixmapFormatRec formats[MAXFORMATS] = {
+	{ 1,	1,	BITMAP_SCANLINE_PAD },
+	{ 4,	8,	BITMAP_SCANLINE_PAD },
+	{ 8,	8,	BITMAP_SCANLINE_PAD },
+	{ 15,	16,	BITMAP_SCANLINE_PAD },
+	{ 16,	16,	BITMAP_SCANLINE_PAD },
+	{ 24,	32,	BITMAP_SCANLINE_PAD },
+#ifdef RENDER
+	{ 32,	32,	BITMAP_SCANLINE_PAD },
+#endif
+};
+#ifdef RENDER
+static int numFormats = 7;
+#else
+static int numFormats = 6;
+#endif
+static Bool formatsDone = FALSE;
+
+InputDriverRec XF86KEYBOARD = {
+	1,
+	"keyboard",
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	0
+};
+
+static Bool
+xf86CreateRootWindow(WindowPtr pWin)
+{
+  int ret = TRUE;
+  int err = Success;
+  ScreenPtr pScreen = pWin->drawable.pScreen;
+  RootWinPropPtr pProp;
+  CreateWindowProcPtr CreateWindow =
+    (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr);
+
+#ifdef DEBUG
+  ErrorF("xf86CreateRootWindow(%p)\n", pWin);
+#endif
+
+  if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
+    /* Can't find hook we are hung on */
+	xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
+		  "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
+		   (void *)xf86CreateRootWindow,
+		   (void *)pScreen->CreateWindow );
+  }
+
+  /* Unhook this function ... */
+  pScreen->CreateWindow = CreateWindow;
+  pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL;
+
+  /* ... and call the previous CreateWindow fuction, if any */
+  if (NULL!=pScreen->CreateWindow) {
+    ret = (*pScreen->CreateWindow)(pWin);
+  }
+
+  /* Now do our stuff */
+  if (xf86RegisteredPropertiesTable != NULL) {
+    if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
+      for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+	   pProp != NULL && err==Success;
+	   pProp = pProp->next )
+	{
+	  Atom prop;
+
+	  prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
+	  err = ChangeWindowProperty(pWin,
+				     prop, pProp->type,
+				     pProp->format, PropModeReplace,
+				     pProp->size, pProp->data,
+				     FALSE
+				     );
+	}
+      
+      /* Look at err */
+      ret &= (err==Success);
+      
+    } else {
+      xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
+	      "non-root window %p (parent %p)\n",
+	      (void *)pWin, (void *)pWin->parent);
+      ret = FALSE;
+    }
+  }
+
+#ifdef DEBUG
+  ErrorF("xf86CreateRootWindow() returns %d\n", ret);
+#endif
+  return (ret);
+}
+
+
+/*
+ * InitOutput --
+ *	Initialize screenInfo for all actually accessible framebuffers.
+ *      That includes vt-manager setup, querying all possible devices and
+ *      collecting the pixmap formats.
+ */
+
+static void
+PostConfigInit(void)
+{
+    /*
+     * Install signal handler for unexpected signals
+     */
+    xf86Info.caughtSignal=FALSE;
+    if (!xf86Info.notrapSignals) {
+       signal(SIGSEGV,xf86SigHandler);
+       signal(SIGILL,xf86SigHandler);
+#ifdef SIGEMT
+       signal(SIGEMT,xf86SigHandler);
+#endif
+       signal(SIGFPE,xf86SigHandler);
+#ifdef SIGBUS
+       signal(SIGBUS,xf86SigHandler);
+#endif
+#ifdef SIGSYS
+       signal(SIGSYS,xf86SigHandler);
+#endif
+#ifdef SIGXCPU
+       signal(SIGXCPU,xf86SigHandler);
+#endif
+#ifdef SIGXFSZ
+       signal(SIGXFSZ,xf86SigHandler);
+#endif
+#ifdef MEMDEBUG
+       signal(SIGUSR2,xf86SigMemDebug);
+#endif
+    }
+
+#ifdef XF86PM
+    xf86OSPMClose = xf86OSPMOpen();
+#endif
+    
+    /* Run an external VT Init program if specified in the config file */
+    xf86RunVtInit();
+
+    /* Do this after XF86Config is read (it's normally in OsInit()) */
+    OsInitColors();
+}
+
+void
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+  int                    i, j, k, scr_index;
+  static unsigned long   generation = 0;
+#ifdef XFree86LOADER
+  char                   **modulelist;
+  pointer                *optionlist;
+#endif
+  screenLayoutPtr	 layout;
+  Pix24Flags		 screenpix24, pix24;
+  MessageType		 pix24From = X_DEFAULT;
+  Bool			 pix24Fail = FALSE;
+  Bool			 autoconfig = FALSE;
+  
+#ifdef __UNIXOS2__
+  os2ServerVideoAccess();  /* See if we have access to the screen before doing anything */
+#endif
+
+  xf86Initialising = TRUE;
+
+  /* Do this early? */
+  if (generation != serverGeneration) {
+      xf86ScreenIndex = AllocateScreenPrivateIndex();
+      xf86CreateRootWindowIndex = AllocateScreenPrivateIndex();
+      xf86PixmapIndex = AllocatePixmapPrivateIndex();
+      generation = serverGeneration;
+  }
+
+  if (serverGeneration == 1) {
+
+    pScreenInfo->numScreens = 0;
+
+    if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
+      xf86ServerName++;
+    else
+      xf86ServerName = argv[0];
+
+    xf86PrintBanner();
+    xf86PrintMarkers();
+    if (xf86LogFile)  {
+	time_t t;
+	const char *ct;
+	t = time(NULL);
+	ct = ctime(&t);
+	xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
+		    xf86LogFile, ct);
+    }
+
+    /* Read and parse the config file */
+    if (!xf86DoProbe && !xf86DoConfigure) {
+      switch (xf86HandleConfigFile(FALSE)) {
+      case CONFIG_OK:
+	break;
+      case CONFIG_PARSE_ERROR:
+	xf86Msg(X_ERROR, "Error parsing the config file\n");
+	return;
+      case CONFIG_NOFILE:
+	autoconfig = TRUE;
+	break;
+      }
+    }
+
+    if (!autoconfig)
+	PostConfigInit();
+
+#ifdef XFree86LOADER
+    /* Initialise the loader */
+    LoaderInit();
+
+    /* Tell the loader the default module search path */
+    LoaderSetPath(xf86ModulePath);
+
+#ifdef TESTING
+    {
+	char **list, **l;
+	const char *subdirs[] = {
+		"drivers",
+		NULL
+	};
+	const char *patlist[] = {
+		"(.*)_drv\\.so",
+		"(.*)_drv\\.o",
+		NULL
+	};
+	ErrorF("Getting module listing...\n");
+	list = LoaderListDirs(NULL, NULL);
+	if (list)
+	    for (l = list; *l; l++)
+		ErrorF("module: %s\n", *l);
+	LoaderFreeDirList(list);
+	ErrorF("Getting video driver listing...\n");
+	list = LoaderListDirs(subdirs, NULL);
+	if (list)
+	    for (l = list; *l; l++)
+		ErrorF("video driver: %s\n", *l);
+	LoaderFreeDirList(list);
+	ErrorF("Getting driver listing...\n");
+	list = LoaderListDirs(NULL, patlist);
+	if (list)
+	    for (l = list; *l; l++)
+		ErrorF("video driver: %s\n", *l);
+	LoaderFreeDirList(list);
+    }
+#endif
+	
+    /* Force load mandatory base modules */
+    if (!xf86LoadModules(baseModules, NULL))
+	FatalError("Unable to load required base modules, Exiting...\n");
+    
+#endif
+
+    xf86OpenConsole();
+
+    /* Do a general bus probe.  This will be a PCI probe for x86 platforms */
+    xf86BusProbe();
+
+    if (xf86DoProbe)
+	DoProbe();
+
+    if (xf86DoConfigure)
+	DoConfigure();
+
+    if (autoconfig) {
+	if (!xf86AutoConfig()) {
+	    xf86Msg(X_ERROR, "Auto configuration failed\n");
+	    return;
+	}
+	PostConfigInit();
+    }
+
+    /* Initialise the resource broker */
+    xf86ResourceBrokerInit();
+
+#ifdef XFree86LOADER
+    /* Load all modules specified explicitly in the config file */
+    if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
+      xf86LoadModules(modulelist, optionlist);
+      xfree(modulelist);
+      xfree(optionlist);
+    }
+
+    /* Load all driver modules specified in the config file */
+    if ((modulelist = xf86DriverlistFromConfig())) {
+      xf86LoadModules(modulelist, NULL);
+      xfree(modulelist);
+    }
+
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+    /* Setup the builtin input drivers */
+    xf86AddInputDriver(&XF86KEYBOARD, NULL, 0);
+#endif
+    /* Load all input driver modules specified in the config file. */
+    if ((modulelist = xf86InputDriverlistFromConfig())) {
+      xf86LoadModules(modulelist, NULL);
+      xfree(modulelist);
+    }
+
+    /*
+     * It is expected that xf86AddDriver()/xf86AddInputDriver will be
+     * called for each driver as it is loaded.  Those functions save the
+     * module pointers for drivers.
+     * XXX Nothing keeps track of them for other modules.
+     */
+    /* XXX What do we do if not all of these could be loaded? */
+#endif
+
+    /*
+     * At this point, xf86DriverList[] is all filled in with entries for
+     * each of the drivers to try and xf86NumDrivers has the number of
+     * drivers.  If there are none, return now.
+     */
+
+    if (xf86NumDrivers == 0) {
+      xf86Msg(X_ERROR, "No drivers available.\n");
+      return;
+    }
+
+    /*
+     * Call each of the Identify functions and call the driverFunc to check
+     * if HW access is required.  The Identify functions print out some
+     * identifying information, and anything else that might be
+     * needed at this early stage.
+     */
+
+    for (i = 0; i < xf86NumDrivers; i++) {
+	xorgHWFlags flags;
+      /* The Identify function is mandatory, but if it isn't there continue */
+	if (xf86DriverList[i]->Identify != NULL)
+	    xf86DriverList[i]->Identify(0);
+	else {
+	    xf86Msg(X_WARNING, "Driver `%s' has no Identify function\n",
+		  xf86DriverList[i]->driverName ? xf86DriverList[i]->driverName
+					     : "noname");
+	}
+	if (!xorgHWAccess
+	    && (!xf86DriverList[i]->driverFunc
+		|| !xf86DriverList[i]->driverFunc(NULL,
+						  GET_REQUIRED_HW_INTERFACES,
+						  &flags)
+		|| NEED_IO_ENABLED(flags)))
+	    xorgHWAccess = TRUE;
+    }
+
+    /* Enable full I/O access */
+    if (xorgHWAccess) {
+	if(!xf86EnableIO())
+	    /* oops, we have failed */
+	    xorgHWAccess = FALSE;
+    }
+
+    /*
+     * Locate bus slot that had register IO enabled at server startup
+     */
+
+    xf86AccessInit();
+    xf86FindPrimaryDevice();
+
+    /*
+     * Now call each of the Probe functions.  Each successful probe will
+     * result in an extra entry added to the xf86Screens[] list for each
+     * instance of the hardware found.
+     */
+
+    for (i = 0; i < xf86NumDrivers; i++) {
+	xorgHWFlags flags;
+	if (!xorgHWAccess) {
+	    if (!xf86DriverList[i]->driverFunc
+		|| !xf86DriverList[i]->driverFunc(NULL,
+						 GET_REQUIRED_HW_INTERFACES,
+						  &flags)
+		|| NEED_IO_ENABLED(flags)) 
+		continue;
+	}
+	    
+	if (xf86DriverList[i]->Probe != NULL)
+	    xf86DriverList[i]->Probe(xf86DriverList[i], PROBE_DEFAULT);
+	else {
+	    xf86MsgVerb(X_WARNING, 0,
+			"Driver `%s' has no Probe function (ignoring)\n",
+			xf86DriverList[i]->driverName
+			? xf86DriverList[i]->driverName : "noname");
+	}
+	xf86SetPciVideo(NULL,NONE);
+    }
+
+    /*
+     * If nothing was detected, return now.
+     */
+
+    if (xf86NumScreens == 0) {
+      xf86Msg(X_ERROR, "No devices detected.\n");
+      return;
+    }
+
+    /*
+     * Match up the screens found by the probes against those specified
+     * in the config file.  Remove the ones that won't be used.  Sort
+     * them in the order specified.
+     */
+
+    /*
+     * What is the best way to do this?
+     *
+     * For now, go through the screens allocated by the probes, and
+     * look for screen config entry which refers to the same device
+     * section as picked out by the probe.
+     *
+     */
+
+    for (i = 0; i < xf86NumScreens; i++) {
+      for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
+	   layout++) {
+	  Bool found = FALSE;
+	  for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+	
+	      GDevPtr dev =
+		xf86GetDevFromEntity(xf86Screens[i]->entityList[j],
+				     xf86Screens[i]->entityInstanceList[j]);
+
+	      if (dev == layout->screen->device) {
+		  /* A match has been found */
+		  xf86Screens[i]->confScreen = layout->screen;
+		  found = TRUE;
+		  break;
+	      }
+	  }
+	  if (found) break;
+      }
+      if (layout->screen == NULL) {
+	/* No match found */
+	xf86Msg(X_ERROR,
+	    "Screen %d deleted because of no matching config section.\n", i);
+        xf86DeleteScreen(i--, 0);
+      }
+    }
+
+    /*
+     * If no screens left, return now.
+     */
+
+    if (xf86NumScreens == 0) {
+      xf86Msg(X_ERROR,
+	      "Device(s) detected, but none match those in the config file.\n");
+      return;
+    }
+
+    xf86PostProbe();
+    xf86EntityInit();
+
+    /*
+     * Sort the drivers to match the requested ording.  Using a slow
+     * bubble sort.
+     */
+    for (j = 0; j < xf86NumScreens - 1; j++) {
+	for (i = 0; i < xf86NumScreens - j - 1; i++) {
+	    if (xf86Screens[i + 1]->confScreen->screennum <
+		xf86Screens[i]->confScreen->screennum) {
+		ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
+		xf86Screens[i + 1] = xf86Screens[i];
+		xf86Screens[i] = tmpScrn;
+	    }
+	}
+    }
+    /* Fix up the indexes */
+    for (i = 0; i < xf86NumScreens; i++) {
+	xf86Screens[i]->scrnIndex = i;
+    }
+
+    /*
+     * Call the driver's PreInit()'s to complete initialisation for the first
+     * generation.
+     */
+    
+    for (i = 0; i < xf86NumScreens; i++) {
+	xf86EnableAccess(xf86Screens[i]);
+	if (xf86Screens[i]->PreInit &&
+	    xf86Screens[i]->PreInit(xf86Screens[i], 0))
+	    xf86Screens[i]->configured = TRUE;
+    }
+    for (i = 0; i < xf86NumScreens; i++)
+	if (!xf86Screens[i]->configured)
+	    xf86DeleteScreen(i--, 0);
+    
+    /*
+     * If no screens left, return now.
+     */
+
+    if (xf86NumScreens == 0) {
+      xf86Msg(X_ERROR,
+	      "Screen(s) found, but none have a usable configuration.\n");
+      return;
+    }
+
+    /* This could be moved into a separate function */
+
+    /*
+     * Check that all screens have initialised the mandatory function
+     * entry points.  Delete those which have not.
+     */
+
+#define WARN_SCREEN(func) \
+    xf86Msg(X_ERROR, "Driver `%s' has no %s function, deleting.\n", \
+	   xf86Screens[i]->name, (warned++, func))
+
+    for (i = 0; i < xf86NumScreens; i++) {
+      int warned = 0;
+      if (xf86Screens[i]->name == NULL) {
+	xf86Screens[i]->name = xnfalloc(strlen("screen") + 1 + 1);
+	if (i < 10)
+	  sprintf(xf86Screens[i]->name, "screen%c", i + '0');
+	else
+	  sprintf(xf86Screens[i]->name, "screen%c", i - 10 + 'A');
+	xf86MsgVerb(X_WARNING, 0,
+		    "Screen driver %d has no name set, using `%s'.\n",
+		    i, xf86Screens[i]->name);
+      }
+      if (xf86Screens[i]->ScreenInit == NULL)
+	WARN_SCREEN("ScreenInit");
+      if (xf86Screens[i]->EnterVT == NULL)
+	WARN_SCREEN("EnterVT");
+      if (xf86Screens[i]->LeaveVT == NULL)
+	WARN_SCREEN("LeaveVT");
+      if (warned)
+	xf86DeleteScreen(i--, 0);
+    }
+
+    /*
+     * If no screens left, return now.
+     */
+
+    if (xf86NumScreens == 0) {
+      xf86Msg(X_ERROR, "Screen(s) found, but drivers were unusable.\n");
+      return;
+    }
+
+    /* XXX Should this be before or after loading dependent modules? */
+    if (xf86ProbeOnly)
+    {
+      OsCleanup(TRUE);
+      AbortDDX();
+      fflush(stderr);
+      exit(0);
+    }
+
+#ifdef XFree86LOADER
+    /* Remove (unload) drivers that are not required */
+    for (i = 0; i < xf86NumDrivers; i++)
+	if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
+	    xf86DeleteDriver(i);
+#endif
+
+    /*
+     * At this stage we know how many screens there are.
+     */
+
+    for (i = 0; i < xf86NumScreens; i++)
+      xf86InitViewport(xf86Screens[i]);
+
+    /*
+     * Collect all pixmap formats and check for conflicts at the display
+     * level.  Should we die here?  Or just delete the offending screens?
+     * Also, should this be done for -probeonly?
+     */
+    screenpix24 = Pix24DontCare;
+    for (i = 0; i < xf86NumScreens; i++) {
+	if (xf86Screens[i]->imageByteOrder !=
+	    xf86Screens[0]->imageByteOrder)
+	    FatalError("Inconsistent display bitmapBitOrder.  Exiting\n");
+	if (xf86Screens[i]->bitmapScanlinePad !=
+	    xf86Screens[0]->bitmapScanlinePad)
+	    FatalError("Inconsistent display bitmapScanlinePad.  Exiting\n");
+	if (xf86Screens[i]->bitmapScanlineUnit !=
+	    xf86Screens[0]->bitmapScanlineUnit)
+	    FatalError("Inconsistent display bitmapScanlineUnit.  Exiting\n");
+	if (xf86Screens[i]->bitmapBitOrder !=
+	    xf86Screens[0]->bitmapBitOrder)
+	    FatalError("Inconsistent display bitmapBitOrder.  Exiting\n");
+
+	/* Determine the depth 24 pixmap format the screens would like */
+	if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
+	    if (screenpix24 == Pix24DontCare)
+		screenpix24 = xf86Screens[i]->pixmap24;
+	    else if (screenpix24 != xf86Screens[i]->pixmap24)
+		FatalError("Inconsistent depth 24 pixmap format.  Exiting\n");
+	}
+    }
+    /* check if screenpix24 is consistent with the config/cmdline */
+    if (xf86Info.pixmap24 != Pix24DontCare) {
+	pix24 = xf86Info.pixmap24;
+	pix24From = xf86Info.pix24From;
+	if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
+	    pix24Fail = TRUE;
+    } else if (screenpix24 != Pix24DontCare) {
+	pix24 = screenpix24;
+	pix24From = X_PROBED;
+    } else
+	pix24 = Pix24Use32;
+
+    if (pix24Fail)
+	FatalError("Screen(s) can't use the required depth 24 pixmap format"
+		   " (%d).  Exiting\n", PIX24TOBPP(pix24));
+
+    /* Initialise the depth 24 format */
+    for (j = 0; j < numFormats && formats[j].depth != 24; j++)
+	;
+    formats[j].bitsPerPixel = PIX24TOBPP(pix24);
+
+    /* Collect additional formats */
+    for (i = 0; i < xf86NumScreens; i++) {
+	for (j = 0; j < xf86Screens[i]->numFormats; j++) {
+	    for (k = 0; ; k++) {
+		if (k >= numFormats) {
+		    if (k >= MAXFORMATS)
+			FatalError("Too many pixmap formats!  Exiting\n");
+		    formats[k] = xf86Screens[i]->formats[j];
+		    numFormats++;
+		    break;
+		}
+		if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
+		    if ((formats[k].bitsPerPixel ==
+			 xf86Screens[i]->formats[j].bitsPerPixel) &&
+		        (formats[k].scanlinePad ==
+			 xf86Screens[i]->formats[j].scanlinePad))
+			break;
+		    FatalError("Inconsistent pixmap format for depth %d."
+			       "  Exiting\n", formats[k].depth);
+		}
+	    }
+	}
+    }
+    formatsDone = TRUE;
+
+    if (xf86Info.vtno >= 0 ) {
+#define VT_ATOM_NAME         "XFree86_VT"
+      Atom VTAtom=-1;
+      CARD32  *VT = NULL;
+      int  ret;
+
+      /* This memory needs to stay available until the screen has been
+	 initialized, and we can create the property for real.
+      */
+      if ( (VT = xalloc(sizeof(CARD32)))==NULL ) {
+	FatalError("Unable to make VT property - out of memory. Exiting...\n");
+      }
+      *VT = xf86Info.vtno;
+    
+      VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME), TRUE);
+
+      for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
+	ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
+					     VTAtom, XA_INTEGER, 32, 
+					     1, VT );
+	if (ret != Success)
+	  xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
+		     "Failed to register VT property\n");
+      }
+    }
+
+    /* If a screen uses depth 24, show what the pixmap format is */
+    for (i = 0; i < xf86NumScreens; i++) {
+	if (xf86Screens[i]->depth == 24) {
+	    xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
+		    PIX24TOBPP(pix24));
+	    break;
+	}
+    }
+
+#if BITMAP_SCANLINE_UNIT == 64
+    /*
+     * cfb24 doesn't currently work on architectures with a 64 bit
+     * BITMAP_SCANLINE_UNIT, so check for 24 bit pixel size for pixmaps
+     * or framebuffers.
+     */
+    {
+	Bool usesCfb24 = FALSE;
+
+	if (PIX24TOBPP(pix24) == 24)
+	    usesCfb24 = TRUE;
+	for (i = 0; i < xf86NumScreens; i++)
+	    if (xf86Screens[i]->bitsPerPixel == 24)
+		usesCfb24 = TRUE;
+	if (usesCfb24) {
+	    FatalError("24-bit pixel size is not supported on systems with"
+			" 64-bit scanlines.\n");
+	}
+    }
+#endif
+
+#ifdef XKB
+    xf86InitXkb();
+#endif
+    /* set up the proper access funcs */
+    xf86PostPreInit();
+
+    AddCallback(&ServerGrabCallback, xf86GrabServerCallback, NULL);
+    
+  } else {
+    /*
+     * serverGeneration != 1; some OSs have to do things here, too.
+     */
+    xf86OpenConsole();
+
+#ifdef XF86PM
+    /*
+      should we reopen it here? We need to deal with an already opened
+      device. We could leave this to the OS layer. For now we simply
+      close it here
+    */
+    if (xf86OSPMClose)
+        xf86OSPMClose();
+    if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
+	xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
+#endif
+
+    /* Make sure full I/O access is enabled */
+    if (xorgHWAccess)
+	xf86EnableIO();
+  }
+
+#if 0
+  /*
+   * Install signal handler for unexpected signals
+   */
+  xf86Info.caughtSignal=FALSE;
+  if (!xf86Info.notrapSignals)
+  {
+     signal(SIGSEGV,xf86SigHandler);
+     signal(SIGILL,xf86SigHandler);
+#ifdef SIGEMT
+     signal(SIGEMT,xf86SigHandler);
+#endif
+     signal(SIGFPE,xf86SigHandler);
+#ifdef SIGBUS
+     signal(SIGBUS,xf86SigHandler);
+#endif
+#ifdef SIGSYS
+     signal(SIGSYS,xf86SigHandler);
+#endif
+#ifdef SIGXCPU
+     signal(SIGXCPU,xf86SigHandler);
+#endif
+#ifdef SIGXFSZ
+     signal(SIGXFSZ,xf86SigHandler);
+#endif
+  }
+#endif
+
+  /*
+   * Use the previously collected parts to setup pScreenInfo
+   */
+
+  pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
+  pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
+  pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
+  pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
+  pScreenInfo->numPixmapFormats = numFormats;
+  for (i = 0; i < numFormats; i++)
+    pScreenInfo->formats[i] = formats[i];
+
+  /* Make sure the server's VT is active */
+    
+  if (serverGeneration != 1) {
+    xf86Resetting = TRUE;
+    /* All screens are in the same state, so just check the first */
+    if (!xf86Screens[0]->vtSema) {
+#ifdef HAS_USL_VTS
+      ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
+#endif
+      xf86AccessEnter();
+      xf86EnterServerState(SETUP);
+    } 
+  }
+#ifdef SCO325
+  else {
+    /*
+     * Under SCO we must ack that we got the console at startup,
+     * I think this is the safest way to assure it.
+     */
+    static int once = 1;
+    if (once) {
+      once = 0;
+      if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+        xf86Msg(X_WARNING, "VT_ACKACQ failed");
+    }
+  }
+#endif /* SCO325 */
+
+  for (i = 0; i < xf86NumScreens; i++) {    
+   	xf86EnableAccess(xf86Screens[i]);
+	/*
+	 * Almost everything uses these defaults, and many of those that
+	 * don't, will wrap them.
+	 */
+	xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+	xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
+	xf86Screens[i]->DPMSSet = NULL;
+	xf86Screens[i]->LoadPalette = NULL; 
+	xf86Screens[i]->SetOverscan = NULL;
+	xf86Screens[i]->DriverFunc = NULL;
+	xf86Screens[i]->pScreen = NULL;
+	scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
+      if (scr_index == i) {
+	/*
+	 * Hook in our ScrnInfoRec, and initialise some other pScreen
+	 * fields.
+	 */
+	screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr
+	  = (pointer)xf86Screens[i];
+	xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
+	/* The driver should set this, but make sure it is set anyway */
+	xf86Screens[i]->vtSema = TRUE;
+      } else {
+	/* This shouldn't normally happen */
+	FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
+      }
+
+#ifdef DEBUG
+      ErrorF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
+	     i, xf86Screens[i]->pScreen );
+      ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+	     i, xf86Screens[i]->pScreen->CreateWindow );
+#endif
+
+      screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr
+	= (void*)(xf86Screens[i]->pScreen->CreateWindow);
+      xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
+
+#ifdef RENDER
+    if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
+    {
+	xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC); 
+	PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
+				 DDC ?
+				 (DDC->features.input_type ?
+				  SubPixelHorizontalRGB : SubPixelNone) :
+				 SubPixelUnknown);
+    }
+#endif
+#ifdef RANDR
+    if (!xf86Info.disableRandR)
+	xf86RandRInit (screenInfo.screens[scr_index]);
+    xf86Msg(xf86Info.randRFrom, "RandR %s\n",
+	    xf86Info.disableRandR ? "disabled" : "enabled");
+#endif
+#ifdef NOT_USED
+      /*
+       * Here we have to let the driver getting access of the VT. Note that
+       * this doesn't mean that the graphics board may access automatically
+       * the monitor. If the monitor is shared this is done in xf86CrossScreen!
+       */
+      if (!xf86Info.sharedMonitor) (xf86Screens[i]->EnterLeaveMonitor)(ENTER);
+#endif
+  }
+
+#ifdef XFree86LOADER
+    if ((serverGeneration == 1) && LoaderCheckUnresolved(LD_RESOLV_IFDONE)) {
+	/* For now, just a warning */
+	xf86Msg(X_WARNING, "Some symbols could not be resolved!\n");
+    }
+#endif
+
+  xf86PostScreenInit();
+
+  xf86InitOrigins();
+
+  xf86Resetting = FALSE;
+  xf86Initialising = FALSE;
+
+  RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
+				 NULL);
+}
+
+
+static InputDriverPtr
+MatchInput(IDevPtr pDev)
+{
+    int i;
+
+    for (i = 0; i < xf86NumInputDrivers; i++) {
+	if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
+	    xf86NameCmp(pDev->driver, xf86InputDriverList[i]->driverName) == 0)
+	    return xf86InputDriverList[i];
+    }
+    return NULL;
+}
+
+
+/*
+ * InitInput --
+ *      Initialize all supported input devices.
+ */
+
+void
+InitInput(argc, argv)
+     int     	  argc;
+     char    	  **argv;
+{
+    IDevPtr pDev;
+    InputDriverPtr pDrv;
+    InputInfoPtr pInfo;
+    static InputInfoPtr coreKeyboard = NULL, corePointer = NULL;
+
+    xf86Info.vtRequestsPending = FALSE;
+    xf86Info.inputPending = FALSE;
+#ifdef XTESTEXT1
+    xtest_command_key = KEY_Begin + MIN_KEYCODE;
+#endif /* XTESTEXT1 */
+
+    if (serverGeneration == 1) {
+	/* Call the PreInit function for each input device instance. */
+	for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+	    /* XXX The keyboard driver is a special case for now. */
+	    if (!xf86NameCmp(pDev->driver, "keyboard")) {
+		xf86MsgVerb(X_WARNING, 0, "*** WARNING the legacy keyboard driver \"keyboard\" is deprecated\n");
+		xf86MsgVerb(X_WARNING, 0, "*** and will be removed in the next release of the Xorg server.\n");
+		xf86MsgVerb(X_WARNING, 0, "*** Please consider using the the new \"kbd\" driver for \"%s\".\n",
+			pDev->identifier);
+
+		continue;
+	    }
+#endif
+
+	    if ((pDrv = MatchInput(pDev)) == NULL) {
+		xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
+		/* XXX For now, just continue. */
+		continue;
+	    }
+	    if (!pDrv->PreInit) {
+		xf86MsgVerb(X_WARNING, 0,
+		    "Input driver `%s' has no PreInit function (ignoring)\n",
+		    pDrv->driverName);
+		continue;
+	    }
+	    pInfo = pDrv->PreInit(pDrv, pDev, 0);
+	    if (!pInfo) {
+		xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
+			pDev->identifier);
+		continue;
+	    } else if (!(pInfo->flags & XI86_CONFIGURED)) {
+		xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
+			pDev->identifier);
+		xf86DeleteInput(pInfo, 0);
+		continue;
+	    }
+	    if (pInfo->flags & XI86_CORE_KEYBOARD) {
+		if (coreKeyboard) {
+		    xf86Msg(X_ERROR,
+		      "Attempt to register more than one core keyboard (%s)\n",
+		      pInfo->name);
+		    pInfo->flags &= ~XI86_CORE_KEYBOARD;
+		} else {
+		    if (!(pInfo->flags & XI86_KEYBOARD_CAPABLE)) {
+			/* XXX just a warning for now */
+			xf86Msg(X_WARNING,
+			    "%s: does not have core keyboard capabilities\n",
+			    pInfo->name);
+		    }
+		    coreKeyboard = pInfo;
+		}
+	    }
+	    if (pInfo->flags & XI86_CORE_POINTER) {
+		if (corePointer) {
+		    xf86Msg(X_ERROR,
+			"Attempt to register more than one core pointer (%s)\n",
+			pInfo->name);
+		    pInfo->flags &= ~XI86_CORE_POINTER;
+		} else {
+		    if (!(pInfo->flags & XI86_POINTER_CAPABLE)) {
+			/* XXX just a warning for now */
+			xf86Msg(X_WARNING,
+			    "%s: does not have core pointer capabilities\n",
+			    pInfo->name);
+		    }
+		    corePointer = pInfo;
+		}
+	    }
+	}
+	if (!corePointer) {
+	    xf86Msg(X_WARNING, "No core pointer registered\n");
+	    /* XXX register a dummy core pointer */
+	}
+#ifdef NEW_KBD
+	if (!coreKeyboard) {
+	    xf86Msg(X_WARNING, "No core keyboard registered\n");
+	    /* XXX register a dummy core keyboard */
+	}
+#endif
+    }
+
+    /* Initialise all input devices. */
+    pInfo = xf86InputDevs;
+    while (pInfo) {
+	xf86ActivateDevice(pInfo);
+	pInfo = pInfo->next;
+    }
+
+    if (coreKeyboard) {
+      xf86Info.pKeyboard = coreKeyboard->dev;
+      xf86Info.kbdEvents = NULL; /* to prevent the internal keybord driver usage*/
+    }
+    else {
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+      /* Only set this if we're allowing the old driver. */
+	if (xf86Info.kbdProc != NULL) 
+	    xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
+#endif
+    }
+    if (corePointer)
+	xf86Info.pMouse = corePointer->dev;
+    if (xf86Info.pKeyboard)
+      RegisterKeyboardDevice(xf86Info.pKeyboard); 
+
+  miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse);
+#ifdef XINPUT
+  xf86eqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
+#else
+  mieqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
+#endif
+}
+
+#ifndef SET_STDERR_NONBLOCKING
+#define SET_STDERR_NONBLOCKING 1
+#endif
+
+/*
+ * OsVendorInit --
+ *      OS/Vendor-specific initialisations.  Called from OsInit(), which
+ *      is called by dix before establishing the well known sockets.
+ */
+ 
+void
+OsVendorInit()
+{
+  static Bool beenHere = FALSE;
+
+  /* xf86WrapperInit() is called directly from OsInit() */
+#ifdef SIGCHLD
+  signal(SIGCHLD, SIG_DFL);	/* Need to wait for child processes */
+#endif
+  OsDelayInitColors = TRUE;
+#ifdef XFree86LOADER
+  loadableFonts = TRUE;
+#endif
+
+  if (!beenHere)
+    xf86LogInit();
+
+#if SET_STDERR_NONBLOCKING
+        /* Set stderr to non-blocking. */
+#ifndef O_NONBLOCK
+#if defined(FNDELAY)
+#define O_NONBLOCK FNDELAY
+#elif defined(O_NDELAY)
+#define O_NONBLOCK O_NDELAY
+#endif
+#endif
+
+#ifdef O_NONBLOCK
+  if (!beenHere) {
+#if !defined(__EMX__)
+    if (geteuid() == 0 && getuid() != geteuid())
+#endif
+    {
+      int status;
+
+      status = fcntl(fileno(stderr), F_GETFL, 0);
+      if (status != -1) {
+	fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
+      }
+    }
+  }
+#endif
+#endif
+
+  beenHere = TRUE;
+}
+
+/*
+ * ddxGiveUp --
+ *      Device dependent cleanup. Called by by dix before normal server death.
+ *      For SYSV386 we must switch the terminal back to normal mode. No error-
+ *      checking here, since there should be restored as much as possible.
+ */
+
+void
+ddxGiveUp()
+{
+    int i;
+
+#ifdef XF86PM
+    if (xf86OSPMClose)
+	xf86OSPMClose();
+    xf86OSPMClose = NULL;
+#endif
+
+    xf86AccessLeaveState();
+
+    for (i = 0; i < xf86NumScreens; i++) {
+	/*
+	 * zero all access functions to
+	 * trap calls when switched away.
+	 */
+	xf86Screens[i]->vtSema = FALSE;
+	xf86Screens[i]->access = NULL;
+	xf86Screens[i]->busAccess = NULL;
+    }
+
+#ifdef USE_XF86_SERVERLOCK
+    xf86UnlockServer();
+#endif
+#ifdef XFreeXDGA
+    DGAShutdown();
+#endif
+
+    xf86CloseConsole();
+
+    xf86CloseLog();
+
+    /* If an unexpected signal was caught, dump a core for debugging */
+    if (xf86Info.caughtSignal)
+	abort();
+}
+
+
+
+/*
+ * AbortDDX --
+ *      DDX - specific abort routine.  Called by AbortServer(). The attempt is
+ *      made to restore all original setting of the displays. Also all devices
+ *      are closed.
+ */
+
+void
+AbortDDX()
+{
+  int i;
+
+  /*
+   * try to deinitialize all input devices
+   */
+  if (xf86Info.kbdProc && xf86Info.pKeyboard)
+    (xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE);
+
+  /*
+   * try to restore the original video state
+   */
+#ifdef HAS_USL_VTS
+  /* Need the sleep when starting X from within another X session */
+  sleep(1);
+#endif
+#ifdef DPMSExtension /* Turn screens back on */
+  if (DPMSPowerLevel != DPMSModeOn)
+      DPMSSet(DPMSModeOn);
+#endif
+  if (xf86Screens) {
+      if (xf86Screens[0]->vtSema)
+	  xf86EnterServerState(SETUP);
+      for (i = 0; i < xf86NumScreens; i++)
+	  if (xf86Screens[i]->vtSema) {
+	      /*
+	       * if we are aborting before ScreenInit() has finished
+	       * we might not have been wrapped yet. Therefore enable
+	       * screen explicitely.
+	       */
+	      xf86EnableAccess(xf86Screens[i]);
+	      (xf86Screens[i]->LeaveVT)(i, 0);
+	  }
+  }
+  
+  xf86AccessLeave();
+  
+  /*
+   * This is needed for an abnormal server exit, since the normal exit stuff
+   * MUST also be performed (i.e. the vt must be left in a defined state)
+   */
+  ddxGiveUp();
+}
+
+void
+OsVendorFatalError()
+{
+#ifdef VENDORSUPPORT
+    ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
+	   "at %s for support on this crash.\n",VENDORSUPPORT);
+#else
+    ErrorF("\nPlease consult the "XVENDORNAME" support \n"
+	   "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
+#endif
+    if (xf86LogFile && xf86LogFileWasOpened)
+	ErrorF("Please also check the log file at \"%s\" for additional "
+              "information.\n", xf86LogFile);
+    ErrorF("\n");
+}
+
+int
+xf86SetVerbosity(int verb)
+{
+    int save = xf86Verbose;
+
+    xf86Verbose = verb;
+    LogSetParameter(XLOG_VERBOSITY, verb);
+    return save;
+}
+
+int
+xf86SetLogVerbosity(int verb)
+{
+    int save = xf86LogVerbose;
+
+    xf86LogVerbose = verb;
+    LogSetParameter(XLOG_FILE_VERBOSITY, verb);
+    return save;
+}
+
+/*
+ * ddxProcessArgument --
+ *	Process device-dependent command line args. Returns 0 if argument is
+ *      not device dependent, otherwise Count of number of elements of argv
+ *      that are part of a device dependent commandline option.
+ *
+ */
+
+
+
+/* ARGSUSED */
+int
+ddxProcessArgument(int argc, char **argv, int i)
+{
+  /*
+   * Note: can't use xalloc/xfree here because OsInit() hasn't been called
+   * yet.  Use malloc/free instead.
+   */
+
+#define CHECK_FOR_REQUIRED_ARGUMENT() \
+    if (((i + 1) >= argc) || (!argv[i + 1])) { 				\
+      ErrorF("Required argument to %s not specified\n", argv[i]); 	\
+      UseMsg(); 							\
+      FatalError("Required argument to %s not specified\n", argv[i]);	\
+    }
+  
+  /* First the options that are only allowed for root */
+  if (getuid() == 0 || geteuid() != 0)
+  {
+    if (!strcmp(argv[i], "-modulepath"))
+    {
+      char *mp;
+      CHECK_FOR_REQUIRED_ARGUMENT();
+      mp = malloc(strlen(argv[i + 1]) + 1);
+      if (!mp)
+	FatalError("Can't allocate memory for ModulePath\n");
+      strcpy(mp, argv[i + 1]);
+      xf86ModulePath = mp;
+      xf86ModPathFrom = X_CMDLINE;
+      return 2;
+    }
+    else if (!strcmp(argv[i], "-logfile"))
+    {
+      char *lf;
+      CHECK_FOR_REQUIRED_ARGUMENT();
+      lf = malloc(strlen(argv[i + 1]) + 1);
+      if (!lf)
+	FatalError("Can't allocate memory for LogFile\n");
+      strcpy(lf, argv[i + 1]);
+      xf86LogFile = lf;
+      xf86LogFileFrom = X_CMDLINE;
+      return 2;
+    }
+  } else if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
+    FatalError("The '%s' option can only be used by root.\n", argv[i]);
+  }
+  if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
+  {
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+      FatalError("\nInvalid argument for %s\n"
+	  "\tFor non-root users, the file specified with %s must be\n"
+	  "\ta relative path and must not contain any \"..\" elements.\n"
+	  "\tUsing default "__XCONFIGFILE__" search path.\n\n",
+	  argv[i], argv[i]);
+    }
+    xf86ConfigFile = argv[i + 1];
+    return 2;
+  }
+  if (!strcmp(argv[i],"-showunresolved"))
+  {
+    xf86ShowUnresolved = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i],"-probeonly"))
+  {
+    xf86ProbeOnly = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i],"-flipPixels"))
+  {
+    xf86FlipPixels = TRUE;
+    return 1;
+  }
+#ifdef XF86VIDMODE
+  if (!strcmp(argv[i],"-disableVidMode"))
+  {
+    xf86VidModeDisabled = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
+  {
+    xf86VidModeAllowNonLocal = TRUE;
+    return 1;
+  }
+#endif
+#ifdef XF86MISC
+  if (!strcmp(argv[i],"-disableModInDev"))
+  {
+    xf86MiscModInDevDisabled = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i],"-allowNonLocalModInDev"))
+  {
+    xf86MiscModInDevAllowNonLocal = TRUE;
+    return 1;
+  }
+#endif
+  if (!strcmp(argv[i],"-allowMouseOpenFail"))
+  {
+    xf86AllowMouseOpenFail = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i],"-bestRefresh"))
+  {
+    xf86BestRefresh = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i],"-ignoreABI"))
+  {
+#ifdef XFree86LOADER
+    LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+#endif
+    return 1;
+  }
+  if (!strcmp(argv[i],"-verbose"))
+  {
+    if (++i < argc && argv[i])
+    {
+      char *end;
+      long val;
+      val = strtol(argv[i], &end, 0);
+      if (*end == '\0')
+      {
+	xf86SetVerbosity(val);
+	return 2;
+      }
+    }
+    xf86SetVerbosity(++xf86Verbose);
+    return 1;
+  }
+  if (!strcmp(argv[i],"-logverbose"))
+  {
+    if (++i < argc && argv[i])
+    {
+      char *end;
+      long val;
+      val = strtol(argv[i], &end, 0);
+      if (*end == '\0')
+      {
+	xf86SetLogVerbosity(val);
+	return 2;
+      }
+    }
+    xf86SetLogVerbosity(++xf86LogVerbose);
+    return 1;
+  }
+  if (!strcmp(argv[i],"-quiet"))
+  {
+    xf86SetVerbosity(0);
+    return 1;
+  }
+  if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
+  {
+    xf86PrintBanner();
+    exit(0);
+  }
+  /* Notice the -fp flag, but allow it to pass to the dix layer */
+  if (!strcmp(argv[i], "-fp"))
+  {
+    xf86fpFlag = TRUE;
+    return 0;
+  }
+  /* Notice the -co flag, but allow it to pass to the dix layer */
+  if (!strcmp(argv[i], "-co"))
+  {
+    xf86coFlag = TRUE;
+    return 0;
+  }
+  /* Notice the -bs flag, but allow it to pass to the dix layer */
+  if (!strcmp(argv[i], "-bs"))
+  {
+    xf86bsDisableFlag = TRUE;
+    return 0;
+  }
+  /* Notice the +bs flag, but allow it to pass to the dix layer */
+  if (!strcmp(argv[i], "+bs"))
+  {
+    xf86bsEnableFlag = TRUE;
+    return 0;
+  }
+  /* Notice the -s flag, but allow it to pass to the dix layer */
+  if (!strcmp(argv[i], "-s"))
+  {
+    xf86sFlag = TRUE;
+    return 0;
+  }
+  if (!strcmp(argv[i], "-bpp"))
+  {
+    ErrorF("The -bpp option is no longer supported.\n"
+	"\tUse -depth to set the color depth, and use -fbbpp if you really\n"
+	"\tneed to force a non-default framebuffer (hardware) pixel format.\n");
+    if (++i >= argc)
+      return 1;
+    return 2;
+  }
+  if (!strcmp(argv[i], "-pixmap24"))
+  {
+    xf86Pix24 = Pix24Use24;
+    return 1;
+  }
+  if (!strcmp(argv[i], "-pixmap32"))
+  {
+    xf86Pix24 = Pix24Use32;
+    return 1;
+  }
+  if (!strcmp(argv[i], "-fbbpp"))
+  {
+    int bpp;
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    if (sscanf(argv[++i], "%d", &bpp) == 1)
+    {
+      xf86FbBpp = bpp;
+      return 2;
+    }
+    else
+    {
+      ErrorF("Invalid fbbpp\n");
+      return 0;
+    }
+  }
+  if (!strcmp(argv[i], "-depth"))
+  {
+    int depth;
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    if (sscanf(argv[++i], "%d", &depth) == 1)
+    {
+      xf86Depth = depth;
+      return 2;
+    }
+    else
+    {
+      ErrorF("Invalid depth\n");
+      return 0;
+    }
+  }
+  if (!strcmp(argv[i], "-weight"))
+  {
+    int red, green, blue;
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
+    {
+      xf86Weight.red = red;
+      xf86Weight.green = green;
+      xf86Weight.blue = blue;
+      return 2;
+    }
+    else
+    {
+      ErrorF("Invalid weighting\n");
+      return 0;
+    }
+  }
+  if (!strcmp(argv[i], "-gamma")  || !strcmp(argv[i], "-rgamma") || 
+      !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
+  {
+    double gamma;
+    CHECK_FOR_REQUIRED_ARGUMENT();    
+    if (sscanf(argv[++i], "%lf", &gamma) == 1) {
+       if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
+	  ErrorF("gamma out of range, only  %.2f <= gamma_value <= %.1f"
+		 " is valid\n", GAMMA_MIN, GAMMA_MAX);
+	  return 0;
+       }
+       if (!strcmp(argv[i-1], "-gamma"))
+	  xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
+       else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
+       else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
+       else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
+       return 2;
+    }
+  }
+  if (!strcmp(argv[i], "-layout"))
+  {
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    xf86LayoutName = argv[++i];
+    return 2;
+  }
+  if (!strcmp(argv[i], "-screen"))
+  {
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    xf86ScreenName = argv[++i];
+    return 2;
+  }
+  if (!strcmp(argv[i], "-pointer"))
+  {
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    xf86PointerName = argv[++i];
+    return 2;
+  }
+  if (!strcmp(argv[i], "-keyboard"))
+  {
+    CHECK_FOR_REQUIRED_ARGUMENT();    
+    xf86KeyboardName = argv[++i];
+    return 2;
+  }
+  if (!strcmp(argv[i], "-nosilk"))
+  {
+    xf86silkenMouseDisableFlag = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i], "-noacpi"))
+  {
+    xf86acpiDisableFlag = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i], "-scanpci"))
+  {
+    DoScanPci(argc, argv, i);
+  }
+  if (!strcmp(argv[i], "-probe"))
+  {
+    xf86DoProbe = TRUE;
+#if 0
+    DoProbe(argc, argv, i);
+#endif
+    return 1;
+  }
+  if (!strcmp(argv[i], "-configure"))
+  {
+    if (getuid() != 0 && geteuid() == 0) {
+	ErrorF("The '-configure' option can only be used by root.\n");
+	exit(1);
+    }
+    xf86DoConfigure = TRUE;
+    xf86AllowMouseOpenFail = TRUE;
+    return 1;
+  }
+  if (!strcmp(argv[i], "-isolateDevice"))
+  {
+    int bus, device, func;
+    CHECK_FOR_REQUIRED_ARGUMENT();
+    if (strncmp(argv[++i], "PCI:", 4)) {
+       FatalError("Bus types other than PCI not yet isolable\n");
+    }
+    if (sscanf(argv[i], "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
+       xf86IsolateDevice.bus = bus;
+       xf86IsolateDevice.device = device;
+       xf86IsolateDevice.func = func;
+       return 2;
+    } else {
+       FatalError("Invalid isolated device specification\n");
+    }
+  }
+  /* OS-specific processing */
+  return xf86ProcessArgument(argc, argv, i);
+}
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+/*
+ * ddxUseMsg --
+ *	Print out correct use of device dependent commandline options.
+ *      Maybe the user now knows what really to do ...
+ */
+
+void
+ddxUseMsg()
+{
+  ErrorF("\n");
+  ErrorF("\n");
+  ErrorF("Device Dependent Usage\n");
+  if (getuid() == 0 || geteuid() != 0)
+  {
+    ErrorF("-modulepath paths      specify the module search path\n");
+    ErrorF("-logfile file          specify a log file name\n");
+    ErrorF("-configure             probe for devices and write an "__XCONFIGFILE__"\n");
+  }
+  ErrorF("-config file           specify a configuration file, relative to the\n");
+  ErrorF("                       "__XCONFIGFILE__" search path, only root can use absolute\n");
+  ErrorF("-probeonly             probe for devices, then exit\n");
+  ErrorF("-scanpci               execute the scanpci module and exit\n");
+  ErrorF("-verbose [n]           verbose startup messages\n");
+  ErrorF("-logverbose [n]        verbose log messages\n");
+  ErrorF("-quiet                 minimal startup messages\n");
+  ErrorF("-pixmap24              use 24bpp pixmaps for depth 24\n");
+  ErrorF("-pixmap32              use 32bpp pixmaps for depth 24\n");
+  ErrorF("-fbbpp n               set bpp for the framebuffer. Default: 8\n");
+  ErrorF("-depth n               set colour depth. Default: 8\n");
+  ErrorF("-gamma f               set gamma value (0.1 < f < 10.0) Default: 1.0\n");
+  ErrorF("-rgamma f              set gamma value for red phase\n");
+  ErrorF("-ggamma f              set gamma value for green phase\n");
+  ErrorF("-bgamma f              set gamma value for blue phase\n");
+  ErrorF("-weight nnn            set RGB weighting at 16 bpp.  Default: 565\n");
+  ErrorF("-layout name           specify the ServerLayout section name\n");
+  ErrorF("-screen name           specify the Screen section name\n");
+  ErrorF("-keyboard name         specify the core keyboard InputDevice name\n");
+  ErrorF("-pointer name          specify the core pointer InputDevice name\n");
+  ErrorF("-nosilk                disable Silken Mouse\n");
+  ErrorF("-flipPixels            swap default black/white Pixel values\n");
+#ifdef XF86VIDMODE
+  ErrorF("-disableVidMode        disable mode adjustments with xvidtune\n");
+  ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
+#endif
+#ifdef XF86MISC
+  ErrorF("-disableModInDev       disable dynamic modification of input device settings\n");
+  ErrorF("-allowNonLocalModInDev allow changes to keyboard and mouse settings\n");
+  ErrorF("                       from non-local clients\n");
+  ErrorF("-allowMouseOpenFail    start server even if the mouse can't be initialized\n");
+#endif
+  ErrorF("-bestRefresh           choose modes with the best refresh rate\n");
+  ErrorF("-ignoreABI             make module ABI mismatches non-fatal\n");
+  ErrorF("-isolateDevice bus_id  restrict device resets to bus_id (PCI only)\n");
+  ErrorF("-version               show the server version\n");
+  /* OS-specific usage */
+  xf86UseMsg();
+  ErrorF("\n");
+}
+
+
+#ifndef OSNAME
+#define OSNAME " unknown"
+#endif
+#ifndef OSVENDOR
+#define OSVENDOR ""
+#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE XORG_VERSION_SNAP
+#endif
+
+static void
+xf86PrintBanner()
+{
+#if PRE_RELEASE
+  ErrorF("\n"
+    "This is a pre-release version of the X server from " XVENDORNAME ".\n"
+    "It is not supported in any way.\n"
+#ifdef SUNSOFT
+	 );
+#else	 
+    "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
+    "Select the \"xorg\" product for bugs you find in this release.\n"
+    "Before reporting bugs in pre-release versions please check the\n"
+    "latest version in the X.Org Foundation CVS repository.\n"
+    "See http://wiki.x.org/wiki/CvsPage for CVS access instructions.\n");
+#endif
+#endif
+  ErrorF("\nX Window System Version %d.%d.%d",
+	 XORG_VERSION_MAJOR,
+	 XORG_VERSION_MINOR,
+	 XORG_VERSION_PATCH);
+#if XORG_VERSION_SNAP > 0
+  ErrorF(".%d", XORG_VERSION_SNAP);
+#endif
+
+#if XORG_VERSION_SNAP >= 900
+  /* When the minor number is 99, that signifies that the we are making
+   * a release candidate for a major version.  (X.0.0)
+   * When the patch number is 99, that signifies that the we are making
+   * a release candidate for a minor version.  (X.Y.0)
+   * When the patch number is < 99, then we are making a release
+   * candidate for the next point release.  (X.Y.Z)
+   */
+#if XORG_VERSION_MINOR >= 99
+  ErrorF(" (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1, XORG_VERSION_SNAP - 900);
+#elif XORG_VERSION_PATCH == 99
+  ErrorF(" (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR + 1,
+				XORG_VERSION_SNAP - 900);
+#else
+  ErrorF(" (%d.%d.%d RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR,
+ 			 XORG_VERSION_PATCH + 1, XORG_VERSION_SNAP - 900);
+#endif
+#endif
+
+#ifdef XORG_CUSTOM_VERSION
+  ErrorF(" (%s)", XORG_CUSTOM_VERSION);
+#endif
+#ifndef XORG_DATE
+#define XORG_DATE XF86_DATE
+#endif
+  ErrorF("\nRelease Date: %s\n", XORG_DATE);
+  ErrorF("X Protocol Version %d, Revision %d, %s\n",
+         X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
+  ErrorF("Build Operating System:%s%s\n", OSNAME, OSVENDOR);
+#ifdef HAS_UTSNAME
+  {
+    struct utsname name;
+
+    /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
+       and Irix) and Single Unix Spec 3 just say that non-negative is success.
+       All agree that failure is represented by a negative number.
+     */
+    if (uname(&name) >= 0) {
+      ErrorF("Current Operating System: %s %s %s %s %s\n",
+	name.sysname, name.nodename, name.release, name.version, name.machine);
+    }
+  }
+#endif
+#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
+  {
+    struct tm t;
+    char buf[100];
+
+    bzero(&t, sizeof(t));
+    bzero(buf, sizeof(buf));
+    t.tm_mday = BUILD_DATE % 100;
+    t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
+    t.tm_year = BUILD_DATE / 10000 - 1900;
+    if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+       ErrorF("Build Date: %s\n", buf);
+  }
+#endif
+#if defined(CLOG_DATE) && (CLOG_DATE > 19000000)
+  {
+    struct tm t;
+    char buf[100];
+
+    bzero(&t, sizeof(t));
+    bzero(buf, sizeof(buf));
+    t.tm_mday = CLOG_DATE % 100;
+    t.tm_mon = (CLOG_DATE / 100) % 100 - 1;
+    t.tm_year = CLOG_DATE / 10000 - 1900;
+    if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+       ErrorF("Changelog Date: %s\n", buf);
+  }
+#endif
+#if defined(BUILDERSTRING)
+  ErrorF("%s \n",BUILDERSTRING);
+#endif
+  ErrorF("\tBefore reporting problems, check "__VENDORDWEBSUPPORT__"\n"
+	 "\tto make sure that you have the latest version.\n");
+#ifdef XFree86LOADER
+  ErrorF("Module Loader present\n");
+#endif
+}
+
+static void
+xf86PrintMarkers()
+{
+  LogPrintMarkers();
+}
+
+static void
+xf86RunVtInit(void)
+{
+    int i;
+
+    /*
+     * If VTInit was set, run that program with consoleFd as stdin and stdout
+     */
+
+    if (xf86Info.vtinit) {
+      switch(fork()) {
+      case -1:
+          FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno));
+          break;
+      case 0:  /* child */
+          setuid(getuid());
+          /* set stdin, stdout to the consoleFd */
+          for (i = 0; i < 2; i++) {
+            if (xf86Info.consoleFd != i) {
+              close(i);
+              dup(xf86Info.consoleFd);
+            }
+          }
+          execl("/bin/sh", "sh", "-c", xf86Info.vtinit, (void *)NULL);
+          xf86Msg(X_WARNING, "exec of /bin/sh failed for VTInit (%s)\n",
+                 strerror(errno));
+          exit(255);
+          break;
+      default:  /* parent */
+          wait(NULL);
+      }
+    }
+}
+
+#ifdef XFree86LOADER
+/*
+ * xf86LoadModules iterates over a list that is being passed in.
+ */             
+Bool
+xf86LoadModules(char **list, pointer *optlist)
+{
+    int errmaj, errmin;
+    pointer opt;
+    int i;
+    char *name;
+    Bool failed = FALSE;
+
+    if (!list)
+	return TRUE;
+
+    for (i = 0; list[i] != NULL; i++) {
+
+#ifndef NORMALISE_MODULE_NAME
+	name = xstrdup(list[i]);
+#else
+	/* Normalise the module name */
+	name = xf86NormalizeName(list[i]);
+#endif
+
+	/* Skip empty names */
+	if (name == NULL || *name == '\0')
+	    continue;
+
+	if (optlist)
+	    opt = optlist[i];
+	else
+	    opt = NULL;
+
+        if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
+	    LoaderErrorMsg(NULL, name, errmaj, errmin);
+	    failed = TRUE;
+	}
+	xfree(name);
+    }
+    return !failed;
+}
+
+#endif
+
+/* Pixmap format stuff */
+
+PixmapFormatPtr
+xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
+{
+    int i;
+    static PixmapFormatRec format;	/* XXX not reentrant */
+
+    /*
+     * When the formats[] list initialisation isn't complete, check the
+     * depth 24 pixmap config/cmdline options and screen-specified formats.
+     */
+
+    if (!formatsDone) {
+	if (depth == 24) {
+	    Pix24Flags pix24 = Pix24DontCare;
+
+	    format.depth = 24;
+	    format.scanlinePad = BITMAP_SCANLINE_PAD;
+	    if (xf86Info.pixmap24 != Pix24DontCare)
+		pix24 = xf86Info.pixmap24;
+	    else if (pScrn->pixmap24 != Pix24DontCare)
+		pix24 = pScrn->pixmap24;
+	    if (pix24 == Pix24Use24)
+		format.bitsPerPixel = 24;
+	    else
+		format.bitsPerPixel = 32;
+	    return &format;
+	}
+    }
+	
+    for (i = 0; i < numFormats; i++)
+	if (formats[i].depth == depth)
+	   break;
+    if (i != numFormats)
+	return &formats[i];
+    else if (!formatsDone) {
+	/* Check for screen-specified formats */
+	for (i = 0; i < pScrn->numFormats; i++)
+	    if (pScrn->formats[i].depth == depth)
+		break;
+	if (i != pScrn->numFormats)
+	    return &pScrn->formats[i];
+    }
+    return NULL;
+}
+
+int
+xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
+{
+    PixmapFormatPtr format;
+
+   
+    format = xf86GetPixFormat(pScrn, depth);
+    if (format)
+	return format->bitsPerPixel;
+    else
+	return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2485 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.4 2005/05/18 10:31:53 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.69 2003/10/08 14:58:28 dawes Exp $ */
+/*
+ * Copyright (c) 1997-2003 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ */
+
+/*
+ * Authors: Dirk Hohndel <[email protected]>
+ *          David Dawes <[email protected]>
+ *          Marc La France <[email protected]>
+ *          ... and others
+ *
+ * This file includes helper functions for mode related things.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "servermd.h"
+#include "mibank.h"
+#include "globals.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86DDC.h"
+
+
+static void PrintModeline(int scrnIndex,DisplayModePtr mode);
+
+/*
+ * xf86GetNearestClock --
+ *	Find closest clock to given frequency (in kHz).  This assumes the
+ *	number of clocks is greater than zero.
+ */
+int
+xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+    int DivFactor, int MulFactor, int *divider)
+{
+    int nearestClock = 0, nearestDiv = 1;
+    int minimumGap = abs(freq - scrp->clock[0]);
+    int i, j, k, gap;
+
+    if (allowDiv2)
+	k = 2;
+    else
+	k = 1;
+
+    /* Must set this here in case the best match is scrp->clock[0] */
+    if (divider != NULL)
+	*divider = 0;
+    
+    for (i = 0;  i < scrp->numClocks;  i++) {
+	for (j = 1; j <= k; j++) {
+	    gap = abs((freq * j) - ((scrp->clock[i] * DivFactor) / MulFactor));
+	    if ((gap < minimumGap) ||
+		((gap == minimumGap) && (j < nearestDiv))) {
+		minimumGap = gap;
+		nearestClock = i;
+		nearestDiv = j;
+		if (divider != NULL)
+		    *divider = (j - 1) * V_CLKDIV2;
+	    }
+	}
+    }
+    return nearestClock;
+}
+
+/*
+ * xf86ModeStatusToString
+ *
+ * Convert a ModeStatus value to a printable message
+ */
+
+const char *
+xf86ModeStatusToString(ModeStatus status)
+{
+    switch (status) {
+    case MODE_OK:
+	return "Mode OK";
+    case MODE_HSYNC:
+	return "hsync out of range";
+    case MODE_VSYNC:
+	return "vrefresh out of range";
+    case MODE_H_ILLEGAL:
+	return "illegal horizontal timings";
+    case MODE_V_ILLEGAL:
+	return "illegal vertical timings";
+    case MODE_BAD_WIDTH:
+	return "width requires unsupported line pitch";
+    case MODE_NOMODE:
+	return "no mode is found";
+    case MODE_NO_INTERLACE:
+	return "interlace mode not supported";
+    case MODE_NO_DBLESCAN:
+	return "doublescan mode not supported";
+    case MODE_NO_VSCAN:
+	return "multiscan mode not supported";
+    case MODE_MEM:
+	return "insufficient memory for mode";
+    case MODE_VIRTUAL_X:
+	return "width too large for virtual size";
+    case MODE_VIRTUAL_Y:
+	return "height too large for virtual size";
+    case MODE_MEM_VIRT:
+	return "insufficient memory given virtual size";
+    case MODE_NOCLOCK:
+	return "no clock available for mode";
+    case MODE_CLOCK_HIGH:
+	return "mode clock too high";
+    case MODE_CLOCK_LOW:
+	return "mode clock too low";
+    case MODE_CLOCK_RANGE:
+	return "bad mode clock/interlace/doublescan";
+    case MODE_BAD_HVALUE:
+	return "horizontal timing out of range";
+    case MODE_BAD_VVALUE:
+	return "vertical timing out of range";
+    case MODE_BAD_VSCAN:
+	return "VScan value out of range";
+    case MODE_HSYNC_NARROW:
+	return "horizontal sync too narrow";
+    case MODE_HSYNC_WIDE:
+	return "horizontal sync too wide";
+    case MODE_HBLANK_NARROW:
+	return "horizontal blanking too narrow";
+    case MODE_HBLANK_WIDE:
+	return "horizontal blanking too wide";
+    case MODE_VSYNC_NARROW:
+	return "vertical sync too narrow";
+    case MODE_VSYNC_WIDE:
+	return "vertical sync too wide";
+    case MODE_VBLANK_NARROW:
+	return "vertical blanking too narrow";
+    case MODE_VBLANK_WIDE:
+	return "vertical blanking too wide";
+    case MODE_PANEL:
+	return "exceeds panel dimensions";
+    case MODE_INTERLACE_WIDTH:
+	return "width too large for interlaced mode";
+    case MODE_ONE_WIDTH:
+        return "all modes must have the same width";
+    case MODE_ONE_HEIGHT:
+        return "all modes must have the same height";
+    case MODE_ONE_SIZE:
+        return "all modes must have the same resolution";
+    case MODE_BAD:
+	return "unknown reason";
+    case MODE_ERROR:
+	return "internal error";
+    default:
+	return "unknown";
+    }
+}
+
+/*
+ * xf86ShowClockRanges() -- Print the clock ranges allowed
+ * and the clock values scaled by ClockMulFactor and ClockDivFactor
+ */
+void
+xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges)
+{
+    ClockRangePtr cp;
+    int MulFactor = 1;
+    int DivFactor = 1;
+    int i, j;
+    int scaledClock;
+
+    for (cp = clockRanges; cp != NULL; cp = cp->next) {
+	DivFactor = max(1, cp->ClockDivFactor);
+	MulFactor = max(1, cp->ClockMulFactor);
+	if (scrp->progClock) {
+	    if (cp->minClock) {
+		if (cp->maxClock) {
+		    xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			"Clock range: %6.2f to %6.2f MHz\n",
+			(double)cp->minClock / 1000.0,
+			(double)cp->maxClock / 1000.0);
+		} else {
+		    xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			"Minimum clock: %6.2f MHz\n",
+			(double)cp->minClock / 1000.0);
+		}
+	    } else {
+		if (cp->maxClock) {
+		    xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			"Maximum clock: %6.2f MHz\n",
+			(double)cp->maxClock / 1000.0);
+		}
+	    }
+	} else if (DivFactor > 1 || MulFactor > 1) {
+	    j = 0;
+	    for (i = 0; i < scrp->numClocks; i++) {
+		scaledClock = (scrp->clock[i] * DivFactor) / MulFactor;
+		if (scaledClock >= cp->minClock && scaledClock <= cp->maxClock) {
+		    if ((j % 8) == 0) {
+			if (j > 0)
+			    xf86ErrorF("\n");
+			xf86DrvMsg(scrp->scrnIndex, X_INFO, "scaled clocks:");
+		    }
+		    xf86ErrorF(" %6.2f", (double)scaledClock / 1000.0);
+		    j++;
+		}
+	    }
+	    xf86ErrorF("\n");
+	}
+    }
+}
+
+
+/*
+ * xf86FindClockRangeForMode()    [... like the name says ...]
+ */
+static ClockRangePtr
+xf86FindClockRangeForMode(ClockRangePtr clockRanges, DisplayModePtr p)
+{
+    ClockRangePtr cp;
+
+    for (cp = clockRanges; ; cp = cp->next)
+	if (!cp ||
+	    ((p->Clock >= cp->minClock) &&
+	     (p->Clock <= cp->maxClock) &&
+	     (cp->interlaceAllowed || !(p->Flags & V_INTERLACE)) &&
+	     (cp->doubleScanAllowed ||
+	      ((p->VScan <= 1) && !(p->Flags & V_DBLSCAN)))))
+	    return cp;
+}
+
+
+/*
+ * xf86HandleBuiltinMode() - handles built-in modes
+ */
+static ModeStatus
+xf86HandleBuiltinMode(ScrnInfoPtr scrp,
+		      DisplayModePtr p,
+		      DisplayModePtr modep,
+		      ClockRangePtr clockRanges,
+		      Bool allowDiv2)
+{
+    ClockRangePtr cp;
+    int extraFlags = 0;
+    int MulFactor = 1;
+    int DivFactor = 1;
+    int clockIndex;
+    
+    /* Reject previously rejected modes */
+    if (p->status != MODE_OK)
+	return p->status;
+
+    /* Reject previously considered modes */
+    if ((p->prev) && (p->type == M_T_BUILTIN))
+        return MODE_NOMODE;
+
+    if ((p->type & M_T_CLOCK_C) == M_T_CLOCK_C) {
+	/* Check clock is in range */
+	cp = xf86FindClockRangeForMode(clockRanges, p);
+	if (cp == NULL){
+	    modep->type = p->type;
+	    p->status = MODE_CLOCK_RANGE;
+	    return MODE_CLOCK_RANGE;
+	}
+	DivFactor = cp->ClockDivFactor;
+	MulFactor = cp->ClockMulFactor;
+	if (!scrp->progClock) {
+	    clockIndex = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
+					     cp->ClockDivFactor,
+					     cp->ClockMulFactor, &extraFlags);
+	    modep->Clock = (scrp->clock[clockIndex] * DivFactor)
+		/ MulFactor;
+	    modep->ClockIndex	= clockIndex;
+	    modep->SynthClock	= scrp->clock[clockIndex];
+	    if (extraFlags & V_CLKDIV2) {
+		modep->Clock /= 2;
+		modep->SynthClock /= 2;
+	    }
+	} else {
+	    modep->Clock = p->Clock;
+	    modep->ClockIndex = -1;
+	    modep->SynthClock = (modep->Clock * MulFactor)
+		/ DivFactor;
+	}
+	modep->PrivFlags = cp->PrivFlags;
+    } else {
+	if(!scrp->progClock) {
+            modep->Clock = p->Clock;
+	    modep->ClockIndex = p->ClockIndex;
+	    modep->SynthClock = p->SynthClock;
+	} else {
+	    modep->Clock = p->Clock;
+	    modep->ClockIndex = -1;
+	    modep->SynthClock = p->SynthClock;
+	}
+	modep->PrivFlags = p->PrivFlags;
+    }
+    modep->type            = p->type;
+    modep->HDisplay        = p->HDisplay;
+    modep->HSyncStart      = p->HSyncStart;
+    modep->HSyncEnd        = p->HSyncEnd;
+    modep->HTotal          = p->HTotal;
+    modep->HSkew           = p->HSkew;
+    modep->VDisplay        = p->VDisplay;
+    modep->VSyncStart      = p->VSyncStart;
+    modep->VSyncEnd        = p->VSyncEnd;
+    modep->VTotal          = p->VTotal;
+    modep->VScan           = p->VScan;
+    modep->Flags           = p->Flags | extraFlags;
+    modep->CrtcHDisplay    = p->CrtcHDisplay;
+    modep->CrtcHBlankStart = p->CrtcHBlankStart;
+    modep->CrtcHSyncStart  = p->CrtcHSyncStart;
+    modep->CrtcHSyncEnd    = p->CrtcHSyncEnd;
+    modep->CrtcHBlankEnd   = p->CrtcHBlankEnd;
+    modep->CrtcHTotal      = p->CrtcHTotal;
+    modep->CrtcHSkew       = p->CrtcHSkew;
+    modep->CrtcVDisplay    = p->CrtcVDisplay;
+    modep->CrtcVBlankStart = p->CrtcVBlankStart;
+    modep->CrtcVSyncStart  = p->CrtcVSyncStart;
+    modep->CrtcVSyncEnd    = p->CrtcVSyncEnd;
+    modep->CrtcVBlankEnd   = p->CrtcVBlankEnd;
+    modep->CrtcVTotal      = p->CrtcVTotal;
+    modep->CrtcHAdjusted   = p->CrtcHAdjusted;
+    modep->CrtcVAdjusted   = p->CrtcVAdjusted;
+    modep->HSync           = p->HSync;
+    modep->VRefresh        = p->VRefresh;
+    modep->Private         = p->Private;
+    modep->PrivSize        = p->PrivSize;
+
+    p->prev = modep;
+    
+    return MODE_OK;
+}
+
+static double
+ModeHSync(DisplayModePtr mode)
+{
+    double hsync = 0.0;
+    
+    if (mode->HSync > 0.0)
+	    hsync = mode->HSync;
+    else if (mode->HTotal > 0)
+	    hsync = (float)mode->Clock / (float)mode->HTotal;
+
+    return hsync;
+}
+
+static double
+ModeVRefresh(DisplayModePtr mode)
+{
+    double refresh = 0.0;
+
+    if (mode->VRefresh > 0.0)
+	refresh = mode->VRefresh;
+    else if (mode->HTotal > 0 && mode->VTotal > 0) {
+	refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal;
+	if (mode->Flags & V_INTERLACE)
+	    refresh *= 2.0;
+	if (mode->Flags & V_DBLSCAN)
+	    refresh /= 2.0;
+	if (mode->VScan > 1)
+	    refresh /= (float)(mode->VScan);
+    }
+    return refresh;
+}
+
+/*
+ * xf86LookupMode
+ *
+ * This function returns a mode from the given list which matches the
+ * given name.  When multiple modes with the same name are available,
+ * the method of picking the matching mode is determined by the
+ * strategy selected.
+ *
+ * This function takes the following parameters:
+ *    scrp         ScrnInfoPtr
+ *    modep        pointer to the returned mode, which must have the name
+ *                 field filled in.
+ *    clockRanges  a list of clock ranges.   This is optional when all the
+ *                 modes are built-in modes.
+ *    strategy     how to decide which mode to use from multiple modes with
+ *                 the same name
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ *    modePool     the list of monitor modes compatible with the driver
+ *    clocks       a list of discrete clocks
+ *    numClocks    number of discrete clocks
+ *    progClock    clock is programmable
+ *
+ * If a mode was found, its values are filled in to the area pointed to
+ * by modep,  If a mode was not found the return value indicates the
+ * reason.
+ */
+
+ModeStatus
+xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+	       ClockRangePtr clockRanges, LookupModeFlags strategy)
+{
+    DisplayModePtr p, bestMode = NULL;
+    ClockRangePtr cp;
+    int i, k, gap, minimumGap = CLOCK_TOLERANCE + 1;
+    double refresh, bestRefresh = 0.0;
+    Bool found = FALSE;
+    int extraFlags = 0;
+    int clockIndex = -1;
+    int MulFactor = 1;
+    int DivFactor = 1;
+    int ModePrivFlags = 0;
+    ModeStatus status = MODE_NOMODE;
+    Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
+    Bool haveBuiltin, haveEdid;
+
+    strategy &= ~(LOOKUP_CLKDIV2 | LOOKUP_OPTIONAL_TOLERANCES);
+
+    /* Some sanity checking */
+    if (scrp == NULL || scrp->modePool == NULL ||
+	(!scrp->progClock && scrp->numClocks == 0)) {
+	ErrorF("xf86LookupMode: called with invalid scrnInfoRec\n");
+	return MODE_ERROR;
+    }
+    if (modep == NULL || modep->name == NULL) {
+	ErrorF("xf86LookupMode: called with invalid modep\n");
+	return MODE_ERROR;
+    }
+    for (cp = clockRanges; cp != NULL; cp = cp->next) {
+	/* DivFactor and MulFactor must be > 0 */
+	cp->ClockDivFactor = max(1, cp->ClockDivFactor);
+	cp->ClockMulFactor = max(1, cp->ClockMulFactor);
+    }
+
+    haveBuiltin = FALSE;
+    haveEdid = FALSE;
+    /* Scan the mode pool for matching names */
+    for (p = scrp->modePool; p != NULL; p = p->next) {
+	if (strcmp(p->name, modep->name) == 0) {
+	    /*
+	     * Requested mode is a built-in mode. Don't let the user
+	     * override it.
+	     * Since built-in modes always come before user specified
+	     * modes it will always be found first.  
+	     */
+	    if (p->type & M_T_BUILTIN) {
+		haveBuiltin = TRUE;
+	    }
+
+	    if (p->type & M_T_EDID) {
+		haveEdid = TRUE;
+	    }
+
+	    if ((haveBuiltin && !(p->type & M_T_BUILTIN)) || 
+		(haveEdid && !(p->type & M_T_EDID) && (modep->type & M_T_EDID)))
+		continue;
+
+	    /* Skip over previously rejected modes */
+	    if (p->status != MODE_OK) {
+		if (!found)
+		    status = p->status;
+		continue;
+	    }
+		
+	    /* Skip over previously considered modes */
+	    if (p->prev)
+		continue;
+
+	    if (p->type & (M_T_BUILTIN) ||
+	 	((p->type & M_T_EDID) && (modep->type & M_T_EDID)))
+		return  xf86HandleBuiltinMode(scrp, p,modep, clockRanges,
+					     allowDiv2);
+
+	    /* Check clock is in range */
+	    cp = xf86FindClockRangeForMode(clockRanges, p);
+	    if (cp == NULL) {
+		/*
+		 * XXX Could do more here to provide a more detailed
+		 * reason for not finding a mode.
+		 */
+		p->status = MODE_CLOCK_RANGE;
+		if (!found)
+		    status = MODE_CLOCK_RANGE;
+		continue;
+	    }
+
+	    /*
+	     * If programmable clock and strategy is not LOOKUP_BEST_REFRESH,
+	     * the required mode has been found, otherwise record the refresh
+	     * and continue looking.
+	     */
+	    if (scrp->progClock) {
+		found = TRUE;
+		if (strategy != LOOKUP_BEST_REFRESH) {
+		    bestMode = p;
+		    DivFactor = cp->ClockDivFactor;
+		    MulFactor = cp->ClockMulFactor;
+		    ModePrivFlags = cp->PrivFlags;
+		    break;
+		}
+		refresh = ModeVRefresh(p);
+		if (p->Flags & V_INTERLACE)
+		    refresh /= INTERLACE_REFRESH_WEIGHT;
+		if (refresh > bestRefresh) {
+		    bestMode = p;
+		    DivFactor = cp->ClockDivFactor;
+		    MulFactor = cp->ClockMulFactor;
+		    ModePrivFlags = cp->PrivFlags;
+		    bestRefresh = refresh;
+		}
+		continue;
+	    }
+
+	    /*
+	     * Clock is in range, so if it is not a programmable clock, find
+	     * a matching clock.
+	     */
+
+	    i = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
+		cp->ClockDivFactor, cp->ClockMulFactor, &k);
+	    /*
+	     * If the clock is too far from the requested clock, this
+	     * mode is no good.
+	     */
+	    if (k & V_CLKDIV2)
+		gap = abs((p->Clock * 2) -
+		    ((scrp->clock[i] * cp->ClockDivFactor) / cp->ClockMulFactor));
+	    else
+		gap = abs(p->Clock -
+		    ((scrp->clock[i] * cp->ClockDivFactor) / cp->ClockMulFactor));
+	    if (gap > minimumGap) {
+		p->status = MODE_NOCLOCK;
+		if (!found)
+		    status = MODE_NOCLOCK;
+		continue;
+	    }
+	    found = TRUE;
+
+	    if (strategy == LOOKUP_BEST_REFRESH) {
+		refresh = ModeVRefresh(p);
+		if (p->Flags & V_INTERLACE)
+		    refresh /= INTERLACE_REFRESH_WEIGHT;
+		if (refresh > bestRefresh) {
+		    bestMode = p;
+		    DivFactor = cp->ClockDivFactor;
+		    MulFactor = cp->ClockMulFactor;
+		    ModePrivFlags = cp->PrivFlags;
+		    extraFlags = k;
+		    clockIndex = i;
+		    bestRefresh = refresh;
+		}
+		continue;
+	    }
+	    if (strategy == LOOKUP_CLOSEST_CLOCK) {
+		if (gap < minimumGap) {
+		    bestMode = p;
+		    DivFactor = cp->ClockDivFactor;
+		    MulFactor = cp->ClockMulFactor;
+		    ModePrivFlags = cp->PrivFlags;
+		    extraFlags = k;
+		    clockIndex = i;
+		    minimumGap = gap;
+		}
+		continue;
+	    }
+	    /*
+	     * If strategy is neither LOOKUP_BEST_REFRESH or
+	     * LOOKUP_CLOSEST_CLOCK the required mode has been found.
+	     */
+	    bestMode = p;
+	    DivFactor = cp->ClockDivFactor;
+	    MulFactor = cp->ClockMulFactor;
+	    ModePrivFlags = cp->PrivFlags;
+	    extraFlags = k;
+	    clockIndex = i;
+	    break;
+	}
+    }
+    if (!found || bestMode == NULL)
+	return status;
+
+    /* Fill in the mode parameters */
+    if (scrp->progClock) {
+        modep->Clock		= bestMode->Clock;
+	modep->ClockIndex	= -1;
+	modep->SynthClock	= (modep->Clock * MulFactor) / DivFactor;
+    } else {
+	modep->Clock		= (scrp->clock[clockIndex] * DivFactor) / MulFactor;
+	modep->ClockIndex	= clockIndex;
+	modep->SynthClock	= scrp->clock[clockIndex];
+	if (extraFlags & V_CLKDIV2) {
+	    modep->Clock /= 2;
+	    modep->SynthClock /= 2;
+	}
+    }
+    modep->type                 = bestMode->type;
+    modep->PrivFlags		= ModePrivFlags;
+    modep->HDisplay		= bestMode->HDisplay;
+    modep->HSyncStart		= bestMode->HSyncStart;
+    modep->HSyncEnd		= bestMode->HSyncEnd;
+    modep->HTotal		= bestMode->HTotal;
+    modep->HSkew		= bestMode->HSkew;
+    modep->VDisplay		= bestMode->VDisplay;
+    modep->VSyncStart		= bestMode->VSyncStart;
+    modep->VSyncEnd		= bestMode->VSyncEnd;
+    modep->VTotal		= bestMode->VTotal;
+    modep->VScan		= bestMode->VScan;
+    modep->Flags		= bestMode->Flags | extraFlags;
+    modep->CrtcHDisplay		= bestMode->CrtcHDisplay;
+    modep->CrtcHBlankStart	= bestMode->CrtcHBlankStart;
+    modep->CrtcHSyncStart	= bestMode->CrtcHSyncStart;
+    modep->CrtcHSyncEnd		= bestMode->CrtcHSyncEnd;
+    modep->CrtcHBlankEnd	= bestMode->CrtcHBlankEnd;
+    modep->CrtcHTotal		= bestMode->CrtcHTotal;
+    modep->CrtcHSkew		= bestMode->CrtcHSkew;
+    modep->CrtcVDisplay		= bestMode->CrtcVDisplay;
+    modep->CrtcVBlankStart	= bestMode->CrtcVBlankStart;
+    modep->CrtcVSyncStart	= bestMode->CrtcVSyncStart;
+    modep->CrtcVSyncEnd		= bestMode->CrtcVSyncEnd;
+    modep->CrtcVBlankEnd	= bestMode->CrtcVBlankEnd;
+    modep->CrtcVTotal		= bestMode->CrtcVTotal;
+    modep->CrtcHAdjusted	= bestMode->CrtcHAdjusted;
+    modep->CrtcVAdjusted	= bestMode->CrtcVAdjusted;
+    modep->HSync		= bestMode->HSync;
+    modep->VRefresh		= bestMode->VRefresh;
+    modep->Private		= bestMode->Private;
+    modep->PrivSize		= bestMode->PrivSize;
+
+    bestMode->prev = modep;
+
+    return MODE_OK;
+}
+
+
+/*
+ * xf86SetModeCrtc
+ *
+ * Initialises the Crtc parameters for a mode.  The initialisation includes
+ * adjustments for interlaced and double scan modes.
+ */
+static void
+xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
+{
+    if ((p == NULL) || (((p->type & M_T_CRTC_C) == M_T_BUILTIN) && (p->HSync)))
+	return;
+
+    p->CrtcHDisplay             = p->HDisplay;
+    p->CrtcHSyncStart           = p->HSyncStart;
+    p->CrtcHSyncEnd             = p->HSyncEnd;
+    p->CrtcHTotal               = p->HTotal;
+    p->CrtcHSkew                = p->HSkew;
+    p->CrtcVDisplay             = p->VDisplay;
+    p->CrtcVSyncStart           = p->VSyncStart;
+    p->CrtcVSyncEnd             = p->VSyncEnd;
+    p->CrtcVTotal               = p->VTotal;
+    if (p->Flags & V_INTERLACE) {
+	if (adjustFlags & INTERLACE_HALVE_V) {
+	    p->CrtcVDisplay         /= 2;
+	    p->CrtcVSyncStart       /= 2;
+	    p->CrtcVSyncEnd         /= 2;
+	    p->CrtcVTotal           /= 2;
+	}
+	/* Force interlaced modes to have an odd VTotal */
+	/* maybe we should only do this when INTERLACE_HALVE_V is set? */
+	p->CrtcVTotal |= 1;
+    }
+
+    if (p->Flags & V_DBLSCAN) {
+        p->CrtcVDisplay         *= 2;
+        p->CrtcVSyncStart       *= 2;
+        p->CrtcVSyncEnd         *= 2;
+        p->CrtcVTotal           *= 2;
+    }
+    if (p->VScan > 1) {
+        p->CrtcVDisplay         *= p->VScan;
+        p->CrtcVSyncStart       *= p->VScan;
+        p->CrtcVSyncEnd         *= p->VScan;
+        p->CrtcVTotal           *= p->VScan;
+    }
+    p->CrtcHAdjusted = FALSE;
+    p->CrtcVAdjusted = FALSE;
+
+    /*
+     * XXX
+     *
+     * The following is taken from VGA, but applies to other cores as well.
+     */
+    p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay);
+    p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal);
+    if ((p->CrtcVBlankEnd - p->CrtcVBlankStart) >= 127) {
+        /* 
+         * V Blanking size must be < 127.
+         * Moving blank start forward is safer than moving blank end
+         * back, since monitors clamp just AFTER the sync pulse (or in
+         * the sync pulse), but never before.
+         */
+        p->CrtcVBlankStart = p->CrtcVBlankEnd - 127;
+	/*
+	 * If VBlankStart is now > VSyncStart move VBlankStart
+	 * to VSyncStart using the maximum width that fits into
+	 * VTotal.
+	 */
+	if (p->CrtcVBlankStart > p->CrtcVSyncStart) {
+	    p->CrtcVBlankStart = p->CrtcVSyncStart;
+	    p->CrtcVBlankEnd = min(p->CrtcHBlankStart + 127, p->CrtcVTotal);
+	}
+    }
+    p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay);
+    p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal);
+
+    if ((p->CrtcHBlankEnd - p->CrtcHBlankStart) >= 63 * 8) {
+        /*
+         * H Blanking size must be < 63*8. Same remark as above.
+         */
+        p->CrtcHBlankStart = p->CrtcHBlankEnd - 63 * 8;
+	if (p->CrtcHBlankStart > p->CrtcHSyncStart) {
+	    p->CrtcHBlankStart = p->CrtcHSyncStart;
+	    p->CrtcHBlankEnd = min(p->CrtcHBlankStart + 63 * 8, p->CrtcHTotal);
+	}
+    }
+}
+
+/*
+ * xf86CheckModeForMonitor
+ *
+ * This function takes a mode and monitor description, and determines
+ * if the mode is valid for the monitor.
+ */
+ModeStatus
+xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
+{
+    int i;
+
+    /* Sanity checks */
+    if (mode == NULL || monitor == NULL) {
+	ErrorF("xf86CheckModeForMonitor: called with invalid parameters\n");
+	return MODE_ERROR;
+    }
+
+#ifdef DEBUG
+    ErrorF("xf86CheckModeForMonitor(%p %s, %p %s)\n",
+	   mode, mode->name, monitor, monitor->id);
+#endif
+
+    if (monitor->DDC) {
+	xf86MonPtr DDC = (xf86MonPtr)(monitor->DDC);
+	struct detailed_monitor_section* detMon;
+	struct monitor_ranges *mon_range;
+	int i;
+
+	mon_range = NULL;
+	for (i = 0; i < 4; i++) {
+	    detMon = &DDC->det_mon[i];
+	    if(detMon->type == DS_RANGES) {
+		mon_range = &detMon->section.ranges;
+	    }
+	}
+	if (mon_range) {
+	    /* mode->Clock in kHz, DDC in MHz */
+	    if (mon_range->max_clock < 2550 &&
+		 mode->Clock / 1000.0 > mon_range->max_clock) {
+		xf86Msg(X_WARNING,
+		   "(%s,%s) mode clock %gMHz exceeds DDC maximum %dMHz\n",
+		   mode->name, monitor->id,
+		   mode->Clock/1000.0, mon_range->max_clock);
+	    }
+	}
+    }
+
+    /* Some basic mode validity checks */
+    if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart ||
+	mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
+	return MODE_H_ILLEGAL;
+
+    if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart ||
+	mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
+	return MODE_V_ILLEGAL;
+
+    if (monitor->nHsync > 0) {
+	/* Check hsync against the allowed ranges */
+	float hsync = ModeHSync(mode);
+	for (i = 0; i < monitor->nHsync; i++) 
+	    if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+		(hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
+		break;
+	
+	/* Now see whether we ran out of sync ranges without finding a match */
+	if (i == monitor->nHsync) 
+	    return MODE_HSYNC;
+    }
+
+    if (monitor->nVrefresh > 0) {
+	/* Check vrefresh against the allowed ranges */
+	float vrefrsh = ModeVRefresh(mode);
+	for (i = 0; i < monitor->nVrefresh; i++)
+	    if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+		(vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
+		break;
+
+	/* Now see whether we ran out of refresh ranges without finding a match */
+	if (i == monitor->nVrefresh)
+	    return MODE_VSYNC;
+    }
+
+    /* Force interlaced modes to have an odd VTotal */
+    if (mode->Flags & V_INTERLACE)
+	mode->CrtcVTotal = mode->VTotal |= 1;
+
+    return MODE_OK;
+}
+
+/*
+ * xf86CheckModeSize
+ *
+ * An internal routine to check if a mode fits in video memory.  This tries to
+ * avoid overflows that would otherwise occur when video memory size is greater
+ * than 256MB.
+ */
+static Bool
+xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y)
+{
+    int bpp = scrp->fbFormat.bitsPerPixel,
+	pad = scrp->fbFormat.scanlinePad;
+    int lineWidth, lastWidth;
+
+    if (scrp->depth == 4)
+	pad *= 4;		/* 4 planes */
+
+    /* Sanity check */
+    if ((w < 0) || (x < 0) || (y <= 0))
+	return FALSE;
+
+    lineWidth = (((w * bpp) + pad - 1) / pad) * pad;
+    lastWidth = x * bpp;
+
+    /*
+     * At this point, we need to compare
+     *
+     *	(lineWidth * (y - 1)) + lastWidth
+     *
+     * against
+     *
+     *	scrp->videoRam * (1024 * 8)
+     *
+     * These are bit quantities.  To avoid overflows, do the comparison in
+     * terms of BITMAP_SCANLINE_PAD units.  This assumes BITMAP_SCANLINE_PAD
+     * is a power of 2.  We currently use 32, which limits us to a video
+     * memory size of 8GB.
+     */
+
+    lineWidth = (lineWidth + (BITMAP_SCANLINE_PAD - 1)) / BITMAP_SCANLINE_PAD;
+    lastWidth = (lastWidth + (BITMAP_SCANLINE_PAD - 1)) / BITMAP_SCANLINE_PAD;
+
+    if ((lineWidth * (y - 1) + lastWidth) >
+	(scrp->videoRam * ((1024 * 8) / BITMAP_SCANLINE_PAD)))
+	return FALSE;
+
+    return TRUE;
+}
+
+/*
+ * xf86InitialCheckModeForDriver
+ *
+ * This function checks if a mode satisfies a driver's initial requirements:
+ *   -  mode size fits within the available pixel area (memory)
+ *   -  width lies within the range of supported line pitches
+ *   -  mode size fits within virtual size (if fixed)
+ *   -  horizontal timings are in range
+ *
+ * This function takes the following parameters:
+ *    scrp         ScrnInfoPtr
+ *    mode         mode to check
+ *    maxPitch     (optional) maximum line pitch
+ *    virtualX     (optional) virtual width requested
+ *    virtualY     (optional) virtual height requested
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ *    monitor      pointer to structure for monitor section
+ *    fbFormat     pixel format for the framebuffer
+ *    videoRam     video memory size (in kB)
+ *    maxHValue    maximum horizontal timing value
+ *    maxVValue    maximum vertical timing value
+ */
+
+ModeStatus
+xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+			      ClockRangePtr clockRanges,
+			      LookupModeFlags strategy,
+			      int maxPitch, int virtualX, int virtualY)
+{
+    ClockRangePtr cp;
+    ModeStatus status;
+    Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
+    int i, needDiv2;
+    
+    /* Sanity checks */
+    if (!scrp || !mode || !clockRanges) {
+	ErrorF("xf86InitialCheckModeForDriver: "
+		"called with invalid parameters\n");
+	return MODE_ERROR;
+    }
+
+#ifdef DEBUG
+    ErrorF("xf86InitialCheckModeForDriver(%p, %p %s, %p, 0x%x, %d, %d, %d)\n",
+	   scrp, mode, mode->name , clockRanges, strategy, maxPitch,  virtualX, virtualY);
+#endif
+
+    /* Some basic mode validity checks */
+    if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart ||
+	mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
+	return MODE_H_ILLEGAL;
+
+    if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart ||
+	mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
+	return MODE_V_ILLEGAL;
+
+    if (!xf86CheckModeSize(scrp, mode->HDisplay, mode->HDisplay,
+				 mode->VDisplay))
+        return MODE_MEM;
+
+    if (maxPitch > 0 && mode->HDisplay > maxPitch)
+	return MODE_BAD_WIDTH;
+
+    if (virtualX > 0 && mode->HDisplay > virtualX)
+	return MODE_VIRTUAL_X;
+
+    if (virtualY > 0 && mode->VDisplay > virtualY)
+	return MODE_VIRTUAL_Y;
+
+    if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue)
+	return MODE_BAD_HVALUE;
+
+    if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
+	return MODE_BAD_VVALUE;
+
+    /*
+     * The use of the DisplayModeRec's Crtc* and SynthClock elements below is
+     * provisional, in that they are later reused by the driver at mode-set
+     * time.  Here, they are temporarily enlisted to contain the mode timings
+     * as seen by the CRT or panel (rather than the CRTC).  The driver's
+     * ValidMode() is allowed to modify these so it can deal with such things
+     * as mode stretching and/or centering.  The driver should >NOT< modify the
+     * user-supplied values as these are reported back when mode validation is
+     * said and done.
+     */
+    /*
+     * NOTE: We (ab)use the mode->Crtc* values here to store timing
+     * information for the calculation of Hsync and Vrefresh. Before
+     * these values are calculated the driver is given the opportunity
+     * to either set these HSync and VRefresh itself or modify the timing
+     * values.
+     * The difference to the final calculation is small but imortand:
+     * here we pass the flag INTERLACE_HALVE_V regardless if the driver
+     * sets it or not. This way our calculation of VRefresh has the same
+     * effect as if we do if (flags & V_INTERLACE) refresh *= 2.0
+     * This dual use of the mode->Crtc* values will certainly create
+     * confusion and is bad software design. However since it's part of
+     * the driver API it's hard to change.
+     */
+     
+    if (scrp->ValidMode) {
+	
+	xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
+
+	cp = xf86FindClockRangeForMode(clockRanges, mode);
+	if (!cp)
+	    return MODE_CLOCK_RANGE;
+
+	if (cp->ClockMulFactor < 1)
+	    cp->ClockMulFactor = 1;
+	if (cp->ClockDivFactor < 1)
+	    cp->ClockDivFactor = 1;
+	
+	/*
+	 * XXX  The effect of clock dividers and multipliers on the monitor's
+	 *      pixel clock needs to be verified.
+	 */
+	if (scrp->progClock) {
+	    mode->SynthClock = mode->Clock;
+	} else {
+	    i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
+				    cp->ClockDivFactor, cp->ClockMulFactor,
+				    &needDiv2);
+	    mode->SynthClock = (scrp->clock[i] * cp->ClockDivFactor) /
+		cp->ClockMulFactor;
+	    if (needDiv2 & V_CLKDIV2)
+		mode->SynthClock /= 2;
+	}
+
+	status = (*scrp->ValidMode)(scrp->scrnIndex, mode, FALSE,
+				    MODECHECK_INITIAL);
+	if (status != MODE_OK)
+	    return status;
+
+	if (mode->HSync <= 0.0)
+	    mode->HSync = (float)mode->SynthClock / (float)mode->CrtcHTotal;
+	if (mode->VRefresh <= 0.0)
+	    mode->VRefresh = (mode->SynthClock * 1000.0)
+		/ (mode->CrtcHTotal * mode->CrtcVTotal);
+    }
+    
+    mode->HSync = ModeHSync(mode);
+    mode->VRefresh = ModeVRefresh(mode);
+
+    /* Assume it is OK */
+    return MODE_OK;
+}
+
+/*
+ * xf86CheckModeForDriver
+ *
+ * This function is for checking modes while the server is running (for
+ * use mainly by the VidMode extension).
+ *
+ * This function checks if a mode satisfies a driver's requirements:
+ *   -  width lies within the line pitch
+ *   -  mode size fits within virtual size
+ *   -  horizontal/vertical timings are in range
+ *
+ * This function takes the following parameters:
+ *    scrp         ScrnInfoPtr
+ *    mode         mode to check
+ *    flags        not (currently) used
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ *    maxHValue    maximum horizontal timing value
+ *    maxVValue    maximum vertical timing value
+ *    virtualX     virtual width
+ *    virtualY     virtual height
+ *    clockRanges  allowable clock ranges
+ */
+
+ModeStatus
+xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags)
+{
+    ClockRangesPtr cp;
+    int i, k, gap, minimumGap = CLOCK_TOLERANCE + 1;
+    int extraFlags = 0;
+    int clockIndex = -1;
+    int MulFactor = 1;
+    int DivFactor = 1;
+    int ModePrivFlags = 0;
+    Bool allowDiv2;
+    ModeStatus status = MODE_NOMODE;
+
+    /* Some sanity checking */
+    if (scrp == NULL ||	(!scrp->progClock && scrp->numClocks == 0)) {
+	ErrorF("xf86CheckModeForDriver: called with invalid scrnInfoRec\n");
+	return MODE_ERROR;
+    }
+    if (mode == NULL) {
+	ErrorF("xf86CheckModeForDriver: called with invalid modep\n");
+	return MODE_ERROR;
+    }
+
+    /* Check the mode size */
+    if (mode->HDisplay > scrp->virtualX)
+	return MODE_VIRTUAL_X;
+
+    if (mode->VDisplay > scrp->virtualY)
+	return MODE_VIRTUAL_Y;
+
+    if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue)
+	return MODE_BAD_HVALUE;
+
+    if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
+	return MODE_BAD_VVALUE;
+
+    for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+	/* DivFactor and MulFactor must be > 0 */
+	cp->ClockDivFactor = max(1, cp->ClockDivFactor);
+	cp->ClockMulFactor = max(1, cp->ClockMulFactor);
+    }
+
+    if (scrp->progClock) {
+	/* Check clock is in range */
+	for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+	    if ((cp->minClock <= mode->Clock) &&
+		(cp->maxClock >= mode->Clock) &&
+		(cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) &&
+		(cp->doubleScanAllowed ||
+		 ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1))))
+	        break;
+	}
+	if (cp == NULL) {
+	    return MODE_CLOCK_RANGE;
+	}
+	/*
+	 * If programmable clock the required mode has been found
+	 */
+    	DivFactor = cp->ClockDivFactor;
+	MulFactor = cp->ClockMulFactor;
+	ModePrivFlags = cp->PrivFlags;
+    } else {
+	 status = MODE_CLOCK_RANGE;
+	/* Check clock is in range */
+	for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+	    if ((cp->minClock <= mode->Clock) &&
+		(cp->maxClock >= mode->Clock) &&
+		(cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) &&
+		(cp->doubleScanAllowed ||
+		 ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1)))) {
+
+		/*
+	 	 * Clock is in range, so if it is not a programmable clock,
+		 * find a matching clock.
+		 */
+    
+		allowDiv2 = (cp->strategy & LOOKUP_CLKDIV2) != 0;
+		i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
+			   cp->ClockDivFactor, cp->ClockMulFactor, &k);
+		/*
+		 * If the clock is too far from the requested clock, this
+		 * mode is no good.
+		 */
+		if (k & V_CLKDIV2)
+		    gap = abs((mode->Clock * 2) -
+			      ((scrp->clock[i] * cp->ClockDivFactor) /
+			       cp->ClockMulFactor));
+		else
+		    gap = abs(mode->Clock -
+			      ((scrp->clock[i] * cp->ClockDivFactor) /
+			       cp->ClockMulFactor));
+		if (gap > minimumGap) {
+		    status = MODE_NOCLOCK;
+		    continue;
+		}
+		
+		DivFactor = cp->ClockDivFactor;
+		MulFactor = cp->ClockMulFactor;
+		ModePrivFlags = cp->PrivFlags;
+		extraFlags = k;
+		clockIndex = i;
+		break;
+	    }
+	}
+	if (cp == NULL)
+	    return status;
+    }
+
+    /* Fill in the mode parameters */
+    if (scrp->progClock) {
+	mode->ClockIndex	= -1;
+	mode->SynthClock	= (mode->Clock * MulFactor) / DivFactor;
+    } else {
+	mode->Clock		= (scrp->clock[clockIndex] * DivFactor) / MulFactor;
+	mode->ClockIndex	= clockIndex;
+	mode->SynthClock	= scrp->clock[clockIndex];
+	if (extraFlags & V_CLKDIV2) {
+	    mode->Clock /= 2;
+	    mode->SynthClock /= 2;
+	}
+    }
+    mode->PrivFlags		= ModePrivFlags;
+
+    return MODE_OK;
+}
+
+static int
+modestrcmp(const char **p1, const char **p2) 
+{
+    char str1[16], str2[16], *q1, *q2;
+    int len1 = strlen(*p1); 
+    int len2 = strlen(*p2);
+
+    if ((len1 > 15) || (len2 > 15))
+	return 0;
+    strncpy(str1, *p1, len1); strncpy(str2, *p2, len2);
+    str1[len1] = str2[len2] = 0;
+    q1 = strchr(str1, 'x'); q2 = strchr(str2, 'x');
+    if (q1 && q2)
+    	*q1 = *q2 = 0;
+    else
+	return 0;
+    if (!str1 || !(q1+1) || !str2 || !(q2+1))
+	return 0;
+    if ((atoi(str1) * atoi(q1+1)) < (atoi(str2) * atoi(q2+1)))
+	return 1;
+    else if ((atoi(str1) * atoi(q1+1)) > (atoi(str2) * atoi(q2+1)))
+	return -1;
+
+    return 0;
+}
+
+/*
+ * xf86ValidateModes
+ *
+ * This function takes a set of mode names, modes and limiting conditions,
+ * and selects a set of modes and parameters based on those conditions.
+ *
+ * This function takes the following parameters:
+ *    scrp         ScrnInfoPtr
+ *    availModes   the list of modes available for the monitor
+ *    modeNames    (optional) list of mode names that the screen is requesting
+ *    clockRanges  a list of clock ranges
+ *    linePitches  (optional) a list of line pitches
+ *    minPitch     (optional) minimum line pitch (in pixels)
+ *    maxPitch     (optional) maximum line pitch (in pixels)
+ *    pitchInc     (mandatory) pitch increment (in bits)
+ *    minHeight    (optional) minimum virtual height (in pixels)
+ *    maxHeight    (optional) maximum virtual height (in pixels)
+ *    virtualX     (optional) virtual width requested (in pixels)
+ *    virtualY     (optional) virtual height requested (in pixels)
+ *    apertureSize size of video aperture (in bytes)
+ *    strategy     how to decide which mode to use from multiple modes with
+ *                 the same name
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ *    clocks       a list of discrete clocks
+ *    numClocks    number of discrete clocks
+ *    progClock    clock is programmable
+ *    monitor      pointer to structure for monitor section
+ *    fbFormat     format of the framebuffer
+ *    videoRam     video memory size
+ *    maxHValue    maximum horizontal timing value
+ *    maxVValue    maximum vertical timing value
+ *    xInc         horizontal timing increment (defaults to 8 pixels)
+ *
+ * The function fills in the following ScrnInfoRec fields:
+ *    modePool     A subset of the modes available to the monitor which
+ *		   are compatible with the driver.
+ *    modes        one mode entry for each of the requested modes, with the
+ *                 status field filled in to indicate if the mode has been
+ *                 accepted or not.
+ *    virtualX     the resulting virtual width
+ *    virtualY     the resulting virtual height
+ *    displayWidth the resulting line pitch
+ *
+ * The function's return value is the number of matching modes found, or -1
+ * if an unrecoverable error was encountered.
+ */
+
+int
+xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+		  char **modeNames, ClockRangePtr clockRanges,
+		  int *linePitches, int minPitch, int maxPitch, int pitchInc,
+		  int minHeight, int maxHeight, int virtualX, int virtualY,
+		  int apertureSize, LookupModeFlags strategy)
+{
+    DisplayModePtr p, q, r, new, last, *endp;
+    int i, numModes = 0;
+    ModeStatus status;
+    int linePitch = -1, virtX = 0, virtY = 0;
+    int newLinePitch, newVirtX, newVirtY;
+    int modeSize;					/* in pixels */
+    Bool validateAllDefaultModes = FALSE;
+    Bool userModes = TRUE;
+    Bool fallbackMode = FALSE;
+    int saveType;
+    PixmapFormatRec *BankFormat;
+    ClockRangePtr cp;
+    ClockRangesPtr storeClockRanges;
+    struct monitor_ranges *mon_range = NULL;
+    double targetRefresh = 0.0;
+    int numTimings = 0;
+    range hsync[MAX_HSYNC];
+    range vrefresh[MAX_VREFRESH];
+    DisplayModeRec dt_modes[DET_TIMINGS];
+    char *dt_mode_names[DET_TIMINGS+1];
+    char *std_mode_names[DET_TIMINGS*5+1], *std2_mode_names[STD_TIMINGS+1];
+    char *fallback_mode[] = {"1024x768", NULL};
+    int numEdidModes;
+    int numDtModes = 0;
+    int numStdModes = 0;
+    int numStd2Modes = 0;
+    char **rmodeNames;
+
+#ifdef DEBUG
+    ErrorF("xf86ValidateModes(%p, %p, %p, %p,\n\t\t  %p, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x)\n",
+	   scrp, availModes, modeNames, clockRanges,
+	   linePitches, minPitch, maxPitch, pitchInc,
+	   minHeight, maxHeight, virtualX, virtualY,
+	   apertureSize, strategy
+	   );
+#endif
+
+    /* Some sanity checking */
+    if (scrp == NULL || scrp->name == NULL || !scrp->monitor ||
+	(!scrp->progClock && scrp->numClocks == 0)) {
+	ErrorF("xf86ValidateModes: called with invalid scrnInfoRec\n");
+	return -1;
+    }
+    if (linePitches != NULL && linePitches[0] <= 0) {
+	ErrorF("xf86ValidateModes: called with invalid linePitches\n");
+	return -1;
+    }
+    if (pitchInc <= 0) {
+	ErrorF("xf86ValidateModes: called with invalid pitchInc\n");
+	return -1;
+    }
+    if ((virtualX > 0) != (virtualY > 0)) {
+	ErrorF("xf86ValidateModes: called with invalid virtual resolution\n");
+	return -1;
+    }
+
+    /*
+     * If DDC is empty, try VBE DDC probing, since xf86DoEDID_DDC2
+     * probing, which at least nv and ati drivers count on, sometimes
+     * fails for some CRT monitors
+     */
+#ifdef sun
+#ifdef improve_for_nvidia_driver
+    /* 
+     * With nvidia driver, EDID modes are added to availModes with type 0, 
+     * reconstruct them.
+     */
+    if (!strcmp (scrp->driverName, "nvidia")) {
+	for (p = availModes; p != NULL; p = p->next)
+	    if (p->type == 0) {
+		dt_modes[numDtModes] = *p;
+		dt_modes[numDtModes].type = M_T_EDID;
+		dt_mode_names[numDtModes++] = xnfstrdup(p->name);
+		dt_mode_names[numDtModes] = NULL;
+	    }
+	/* 
+         * If monitor probing failed with nvidia driver, try the results from
+	 * VBE probing 
+	 */
+    }
+    if ((!scrp->monitor->DDC) && (strcmp (scrp->driverName, "nvidia") || 
+	(!numDtModes))) {
+#else
+    if ((!scrp->monitor->DDC) && strcmp (scrp->driverName, "nvidia")) {
+#endif
+#else
+    if (!scrp->monitor->DDC) {
+#endif
+	int entityIndex = scrp->entityList[0];
+
+	if ((xf86LoadSubModule(scrp, "vbe")) && xf86FallbackDDCProbe)
+	    	scrp->monitor->DDC = xf86FallbackDDCProbe (entityIndex, scrp);
+    }
+
+    /*
+     * Probe monitor so that we can enforce/warn about its limits.
+     * If one or more DS_RANGES descriptions are present, use the parameters
+     * that they provide.  Otherwise, deduce limits based on the modes that
+     * are shown as supported via standard and detailed timings.
+     *
+     * XXX The full potential of the DDC/EDID data still isn't being tapped.
+     */
+    if (scrp->monitor->DDC) {
+	MonPtr monitor = scrp->monitor;
+	xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
+	int i, j;
+	float hmin = 1e6, hmax = 0.0, vmin = 1e6, vmax = 0.0;
+	float h;
+	struct std_timings *t;
+	struct detailed_timings *dt;
+	char name[20];
+
+	numTimings = 0;
+	for (i = 0; i < DET_TIMINGS; i++) {
+	    switch (DDC->det_mon[i].type) {
+	    case DS_RANGES:
+		mon_range = &DDC->det_mon[i].section.ranges;
+		hsync[numTimings].lo = mon_range->min_h;
+		hsync[numTimings].hi = mon_range->max_h;
+		vrefresh[numTimings].lo = mon_range->min_v;
+		vrefresh[numTimings].hi = mon_range->max_v;
+		numTimings++;
+		break;
+
+	    case DS_STD_TIMINGS:
+		t = DDC->det_mon[i].section.std_t;
+		for (j = 0; j < 5; j++) {
+		    if (t[j].hsize > 256) { /* sanity check */
+			if (t[j].refresh < vmin)
+			    vmin = t[i].refresh;
+			if (t[j].refresh > vmax)
+			    vmax = t[i].refresh;
+			/*
+			 * For typical modes this is a reasonable estimate
+			 * of the horizontal sync rate.
+			 */
+			h = t[j].refresh * 1.07 * t[j].vsize / 1000.0;
+			if (h < hmin)
+			    hmin = h;
+			if (h > hmax)
+			    hmax = h;
+			sprintf(name, "%dx%d", t[j].hsize, t[j].vsize);
+			std_mode_names[numStdModes++]	= xnfstrdup(name);
+			std_mode_names[numStdModes] = NULL;
+		    }
+		}
+		break;
+
+	    case DT:
+		dt = &DDC->det_mon[i].section.d_timings;
+		if (dt->clock > 15000000) { /* sanity check */
+		    float v;
+		    h = (float)dt->clock / (dt->h_active + dt->h_blanking);
+		    v = h / (dt->v_active + dt->v_blanking);
+		    h /= 1000.0;
+		    if (dt->interlaced) 
+			v /= 2.0;
+
+		    if (v < vmin)
+			vmin = v;
+		    if (v > vmax)
+			vmax = v;
+		    if (h < hmin)
+			hmin = h;
+		    if (h > hmax)
+			hmax = h;
+		    memset(&dt_modes[numDtModes], '\0', sizeof(DisplayModeRec));
+		    dt_modes[numDtModes].HSync	= 0.0;
+		    dt_modes[numDtModes].type       = M_T_EDID;
+		    dt_modes[numDtModes].Clock      = dt->clock/1000.0;
+		    dt_modes[numDtModes].HDisplay   = dt->h_active;
+		    dt_modes[numDtModes].HSyncStart = dt->h_sync_off + dt->h_active;
+		    dt_modes[numDtModes].HSyncEnd   = dt->h_sync_off + 
+			dt->h_sync_width + dt->h_active;
+		    dt_modes[numDtModes].HTotal     = dt->h_active + dt->h_blanking;
+		    dt_modes[numDtModes].VDisplay   = dt->v_active;
+		    dt_modes[numDtModes].VSyncStart = dt->v_sync_off + dt->v_active;
+		    dt_modes[numDtModes].VSyncEnd   = dt->v_sync_off + 
+			dt->v_sync_width + dt->v_active;
+		    dt_modes[numDtModes].VTotal     = dt->v_active + dt->v_blanking;
+		    if (dt->sync == 0x03)  {
+		    	if (dt->misc & 0x02)
+		    	    dt_modes[numDtModes].Flags |= V_PVSYNC;
+		    	else 
+		    	    dt_modes[numDtModes].Flags |= V_NVSYNC;
+		    	if (dt->misc & 0x01)
+		    	    dt_modes[numDtModes].Flags |= V_PHSYNC;
+		    	else 
+		    	    dt_modes[numDtModes].Flags |= V_NHSYNC;
+		    }
+		    if (dt->sync == 0x02) {
+		    	dt_modes[numDtModes].Flags |= V_NHSYNC;
+		        if (dt->misc & 0x01)
+		    	    dt_modes[numDtModes].Flags |= V_PCSYNC;
+		    	else 
+		    	    dt_modes[numDtModes].Flags |= V_NCSYNC;
+		    }
+		    if (dt->interlaced)
+		    	 dt_modes[numDtModes].Flags |= V_INTERLACE;
+		    sprintf(name, "%dx%d", dt->h_active, dt->v_active);
+		    dt_modes[numDtModes].name       = xnfstrdup(name);
+		    dt_mode_names[numDtModes++]	= xnfstrdup(name);
+		    dt_mode_names[numDtModes] = NULL;
+		}
+		break;
+	    }
+
+	    if (numTimings > MAX_HSYNC)
+		break;
+	}
+
+	for (i = 0; i < STD_TIMINGS; i++) {
+	    t = &DDC->timings2[i];
+	    if (t->hsize > 256) { /* sanity check */
+		if (t->refresh < vmin)
+		    vmin = t->refresh;
+		if (t->refresh > vmax)
+		    vmax = t->refresh;
+		/*
+		 * For typical modes this is a reasonable estimate
+		 * of the horizontal sync rate.
+		 */
+		h = t->refresh * 1.07 * t->vsize / 1000.0;
+		if (h < hmin)
+		    hmin = h;
+		if (h > hmax)
+		    hmax = h;
+		sprintf(name, "%dx%d", t->hsize, t->vsize);
+		std2_mode_names[numStd2Modes++]	= xnfstrdup(name);
+		std2_mode_names[numStd2Modes] = NULL;
+	    }
+	}
+
+	if (numTimings == 0) {
+	    t = DDC->timings2;
+	    for (i = 0; i < STD_TIMINGS; i++) {
+		if (t[i].hsize > 256) { /* sanity check */
+		    if (t[i].refresh < vmin)
+			vmin = t[i].refresh;
+		    if (t[i].refresh > vmax)
+			vmax = t[i].refresh;
+		    /*
+		     * For typical modes this is a reasonable estimate
+		     * of the horizontal sync rate.
+		     */
+		    h = t[i].refresh * 1.07 * t[i].vsize / 1000.0;
+		    if (h < hmin)
+			hmin = h;
+		    if (h > hmax)
+			hmax = h;
+		}
+	    }
+
+	    if (hmax > 0.0) {
+		hsync[numTimings].lo = hmin;
+		hsync[numTimings].hi = hmax;
+		vrefresh[numTimings].lo = vmin;
+		vrefresh[numTimings].hi = vmax;
+		numTimings++;
+	    }
+	}
+
+	if (numTimings > 0) {
+
+#ifdef DEBUG
+	    for (i = 0; i < numTimings; i++) {
+		ErrorF("DDC - Hsync %.1f-%.1f kHz - Vrefresh %.1f-%.1f Hz\n",
+		       hsync[i].lo, hsync[i].hi,
+		       vrefresh[i].lo, vrefresh[i].hi);
+	    }
+#endif
+
+#define DDC_SYNC_TOLERANCE SYNC_TOLERANCE
+	    if (monitor->nHsync > 0) {
+		for (i = 0; i < monitor->nHsync; i++) {
+		    Bool good = FALSE;
+		    for (j = 0; j < numTimings; j++) {
+			if ((1.0 - DDC_SYNC_TOLERANCE) * hsync[j].lo <=
+				monitor->hsync[i].lo &&
+			    (1.0 + DDC_SYNC_TOLERANCE) * hsync[j].hi >=
+				monitor->hsync[i].hi) {
+			    good = TRUE;
+			    break;
+			}
+		    }
+		    if (!good) {
+			xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+			  "config file hsync range %g-%gkHz not within DDC "
+			  "hsync ranges.\n",
+			  monitor->hsync[i].lo, monitor->hsync[i].hi);
+		    }
+		}
+	    }
+
+	    if (monitor->nVrefresh > 0) {
+		for (i = 0; i < monitor->nVrefresh; i++) {
+		    Bool good = FALSE;
+		    for (j = 0; j < numTimings; j++) {
+			if ((1.0 - DDC_SYNC_TOLERANCE) * vrefresh[j].lo <=
+				monitor->vrefresh[0].lo &&
+			    (1.0 + DDC_SYNC_TOLERANCE) * vrefresh[j].hi >=
+				monitor->vrefresh[0].hi) {
+			    good = TRUE;
+			    break;
+			}
+		    }
+		    if (!good) {
+			xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+			  "config file vrefresh range %g-%gHz not within DDC "
+			  "vrefresh ranges.\n",
+			  monitor->vrefresh[i].lo, monitor->vrefresh[i].hi);
+		    }
+		}
+	    }
+        }
+    }
+
+    /*
+     * If requested by the driver, allow missing hsync and/or vrefresh ranges
+     * in the monitor section.
+     */
+    if (strategy & LOOKUP_OPTIONAL_TOLERANCES) {
+	strategy &= ~LOOKUP_OPTIONAL_TOLERANCES;
+    } else {
+	const char *type = "";
+
+	if (scrp->monitor->nHsync <= 0) {
+	    if (numTimings > 0) {
+		scrp->monitor->nHsync = numTimings;
+		for (i = 0; i < numTimings; i++) {
+		    scrp->monitor->hsync[i].lo = hsync[i].lo;
+		    scrp->monitor->hsync[i].hi = hsync[i].hi;
+		}
+	    } else {
+		scrp->monitor->hsync[0].lo = 28;
+		scrp->monitor->hsync[0].hi = 60;
+		scrp->monitor->nHsync = 1;
+	    }
+	    type = "default ";
+	}
+	for (i = 0; i < scrp->monitor->nHsync; i++) {
+	    if (scrp->monitor->hsync[i].lo == scrp->monitor->hsync[i].hi)
+	      xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			 "%s: Using %shsync value of %.2f kHz\n",
+			 scrp->monitor->id, type,
+			 scrp->monitor->hsync[i].lo);
+	    else
+	      xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			 "%s: Using %shsync range of %.2f-%.2f kHz\n",
+			 scrp->monitor->id, type,
+			 scrp->monitor->hsync[i].lo,
+			 scrp->monitor->hsync[i].hi);
+	}
+
+	type = "";
+	if (scrp->monitor->nVrefresh <= 0) {
+	    if (numTimings > 0) {
+		scrp->monitor->nVrefresh = numTimings;
+		for (i = 0; i < numTimings; i++) {
+		    scrp->monitor->vrefresh[i].lo = vrefresh[i].lo;
+		    scrp->monitor->vrefresh[i].hi = vrefresh[i].hi;
+		}
+	    } else {
+		scrp->monitor->vrefresh[0].lo = 43;
+		scrp->monitor->vrefresh[0].hi = 72;
+		scrp->monitor->nVrefresh = 1;
+	    }
+	    type = "default ";
+	}
+	for (i = 0; i < scrp->monitor->nVrefresh; i++) {
+	    if (scrp->monitor->vrefresh[i].lo == scrp->monitor->vrefresh[i].hi)
+	      xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			 "%s: Using %svrefresh value of %.2f Hz\n",
+			 scrp->monitor->id, type,
+			 scrp->monitor->vrefresh[i].lo);
+	    else
+	      xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			 "%s: Using %svrefresh range of %.2f-%.2f Hz\n",
+			 scrp->monitor->id, type,
+			 scrp->monitor->vrefresh[i].lo,
+			 scrp->monitor->vrefresh[i].hi);
+	}
+    }
+
+    /*
+     * Store the clockRanges for later use by the VidMode extension. Must
+     * also store the strategy, since ClockDiv2 flag is stored there.
+     */
+    storeClockRanges = scrp->clockRanges;
+    while (storeClockRanges != NULL) {
+	storeClockRanges = storeClockRanges->next;
+    }
+    for (cp = clockRanges; cp != NULL; cp = cp->next,
+	   	storeClockRanges = storeClockRanges->next) {
+	storeClockRanges = xnfalloc(sizeof(ClockRanges));
+	if (scrp->clockRanges == NULL)
+	    scrp->clockRanges = storeClockRanges;
+	memcpy(storeClockRanges, cp, sizeof(ClockRange));
+	storeClockRanges->strategy = strategy;
+    }
+
+    /* Determine which pixmap format to pass to miScanLineWidth() */
+    if (scrp->depth > 4)
+	BankFormat = &scrp->fbFormat;
+    else
+	BankFormat = xf86GetPixFormat(scrp, 1);	/* >not< scrp->depth! */
+
+    if (scrp->xInc <= 0)
+        scrp->xInc = 8;		/* Suitable for VGA and others */
+
+#define _VIRTUALX(x) ((((x) + scrp->xInc - 1) / scrp->xInc) * scrp->xInc)
+
+    /*
+     * Determine maxPitch if it wasn't given explicitly.  Note linePitches
+     * always takes precedence if is non-NULL.  In that case the minPitch and
+     * maxPitch values passed are ignored.
+     */
+    if (linePitches) {
+	minPitch = maxPitch = linePitches[0];
+	for (i = 1; linePitches[i] > 0; i++) {
+	    if (linePitches[i] > maxPitch)
+		maxPitch = linePitches[i];
+	    if (linePitches[i] < minPitch)
+		minPitch = linePitches[i];
+	}
+    }
+
+    /* Initial check of virtual size against other constraints */
+    scrp->virtualFrom = X_PROBED;
+    /*
+     * Initialise virtX and virtY if the values are fixed.
+     */
+    if (virtualY > 0) {
+	if (maxHeight > 0 && virtualY > maxHeight) {
+	    xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+		       "Virtual height (%d) is too large for the hardware "
+		       "(max %d)\n", virtualY, maxHeight);
+	    return -1;
+	}
+
+	if (minHeight > 0 && virtualY < minHeight) {
+	    xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+		       "Virtual height (%d) is too small for the hardware "
+		       "(min %d)\n", virtualY, minHeight);
+	    return -1;
+	}
+
+	virtualX = _VIRTUALX(virtualX);
+	if (linePitches != NULL) {
+	    for (i = 0; linePitches[i] != 0; i++) {
+		if ((linePitches[i] >= virtualX) &&
+		    (linePitches[i] ==
+		     miScanLineWidth(virtualX, virtualY, linePitches[i],
+				     apertureSize, BankFormat, pitchInc))) {
+		    linePitch = linePitches[i];
+		    break;
+		}
+	    }
+	} else {
+	    linePitch = miScanLineWidth(virtualX, virtualY, minPitch,
+					apertureSize, BankFormat, pitchInc);
+	}
+
+	if ((linePitch < minPitch) || (linePitch > maxPitch)) {
+	    xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+		       "Virtual width (%d) is too large for the hardware "
+		       "(max %d)\n", virtualX, maxPitch);
+	    return -1;
+	}
+
+	if (!xf86CheckModeSize(scrp, linePitch, virtualX, virtualY)) {
+	    xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+		      "Virtual size (%dx%d) (pitch %d) exceeds video memory\n",
+		      virtualX, virtualY, linePitch);
+	    return -1;
+	}
+
+	virtX = virtualX;
+	virtY = virtualY;
+	scrp->virtualFrom = X_CONFIG;
+    }
+
+    /* Print clock ranges and scaled clocks */
+    xf86ShowClockRanges(scrp, clockRanges);
+
+    /*
+     * If scrp->modePool hasn't been setup yet, set it up now.  This allows the
+     * modes that the driver definitely can't use to be weeded out early.  Note
+     * that a modePool mode's prev field is used to hold a pointer to the
+     * member of the scrp->modes list for which a match was considered.
+     */
+    if (scrp->modePool == NULL) {
+	r = availModes;
+	q = NULL;
+	for (i = 0;  ;  ) {
+	    if (i < numDtModes) {
+    		DisplayModePtr  s;
+
+	    	p = &dt_modes[i];
+		for (s = availModes; s != NULL; s = s->next) {
+		   /* 
+		    * Don't prepend EDID mode if there exits a user-defined or 
+		    * built-in mode having the same name.
+		    */
+		   if (((s->type & M_T_USERDEF) || (s->type & M_T_BUILTIN)) && 
+			(!strcmp(p->name, s->name)))
+			break;
+		}
+		if (s) {
+		    xf86DrvMsg(scrp->scrnIndex, X_INFO, "EDID Modeline \"%s\" %.1fMHz not prepended to Modeline database:\n", 
+		    	p->name, p->Clock/1000.0);
+		    xf86DrvMsg(scrp->scrnIndex, X_INFO, " -- overridden by %s Modeline \"%s\" %.1fMHz.\n", 
+		   	(s->type|M_T_USERDEF) ? "user" : "builtin", s->name, s->Clock/1000.0);
+		    i++;
+		    continue;
+		}
+		xf86DrvMsg(scrp->scrnIndex, X_INFO, "Prepend EDID Modeline \"%s\" %.1fMHz to Modeline database\n",
+		    p->name, p->Clock/1000.0);	
+	    }
+	    else {
+	    	if ((p = r) == NULL)
+		    break;
+		else {
+#ifdef sun
+#ifdef improve_for_nvidia_driver
+		   /*
+		    * Type 0 modes are EDID modes added by nvidia driver, ignore 
+                    * them because they were converted to type EDID in dt_modes[] 
+                    * and have been prepended.
+		    */
+	            if (p->type == 0) {
+			r = r->next;
+			continue;
+		    }
+#endif
+#endif
+		}
+	    }
+	    
+	    status = xf86InitialCheckModeForDriver(scrp, p, clockRanges,
+						   strategy, maxPitch,
+						   virtualX, virtualY);
+
+	    if (status == MODE_OK) {
+		status = xf86CheckModeForMonitor(p, scrp->monitor);
+	    }
+	    
+	    if (status == MODE_OK) {
+		new = xnfalloc(sizeof(DisplayModeRec));
+		*new = *p;
+		new->next = NULL;
+		if (!q) {
+		    scrp->modePool = new;
+		} else {
+		    q->next = new;
+		}
+		new->prev = NULL;
+		q = new;
+		q->name = xnfstrdup(p->name);
+	        q->status = MODE_OK;
+	    } else {
+		char *typestring;
+
+		switch (p->type) {
+		case M_T_BUILTIN:	
+		    typestring = xnfstrdup("builtin");
+		    break;
+		case M_T_USERDEF:	
+		    typestring = xnfstrdup("user");
+		    break;
+		case M_T_EDID:	
+		    typestring = xnfstrdup("EDID");
+		    break;
+		case M_T_DEFAULT:	
+		    typestring = xnfstrdup("default");
+		    break;
+		default:	
+		    typestring = xnfstrdup("");
+		    break;
+		}
+		xf86DrvMsg(scrp->scrnIndex, X_INFO,
+		    "Not including %s \"%s\" %.1fMHz (%s) in pool\n", typestring,
+		    p->name, p->Clock/1000.0, xf86ModeStatusToString(status));
+	    }
+	    if (i < numDtModes)
+		i++;
+	    else
+		r = r->next;
+	}
+
+	if (scrp->modePool == NULL) {
+	    xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode pool is empty\n");
+	    return 0;
+	}
+    } else {
+	for (p = scrp->modePool; p != NULL; p = p->next) {
+	    p->prev = NULL;
+	    p->status = MODE_OK;
+	}
+    }
+
+    /*
+     * Go through the mode pool and see if any modes match the target
+     * refresh rate, (if specified).  If no modes match, abandon the target.
+     */
+    targetRefresh = xf86SetRealOption(scrp->options,
+				      "TargetRefresh", 0.0);
+    if (targetRefresh > 0.0) {
+	for (p = scrp->modePool; p != NULL; p = p->next) {
+	    if (ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
+		break;
+	}
+	if (!p)
+	    targetRefresh = 0.0;
+    }
+
+    if (targetRefresh > 0.0) {
+	xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+		   "Target refresh rate is %.1f Hz\n", targetRefresh);
+    }
+
+    /*
+     * Allocate one entry in scrp->modes for each named mode.
+     */
+    while (scrp->modes)
+	xf86DeleteMode(&scrp->modes, scrp->modes);
+
+    if (((rmodeNames = modeNames) == NULL) || (rmodeNames[0] == NULL)) {
+         /* Use EDID modes */
+	userModes = FALSE;
+	if (numDtModes) {
+	    rmodeNames = dt_mode_names;
+	    numEdidModes = numDtModes;
+	}
+	else if (numStdModes) {
+	    rmodeNames = std_mode_names;
+	    numEdidModes = numStdModes;
+	}
+	else if (numStd2Modes) {
+	    rmodeNames = std2_mode_names;
+	    numEdidModes = numStd2Modes;
+	} else {
+	    fallbackMode = TRUE;
+	    rmodeNames = fallback_mode;
+	    numEdidModes = 1;
+	}
+
+    	if ((rmodeNames) && (rmodeNames != modeNames))
+	    /* Sort and make them unique */
+	    qsort((void *) rmodeNames, numEdidModes, sizeof (char *),
+	    	(int (*) (const void *, const void *)) modestrcmp);
+	    for (i=0; i< numEdidModes; ) {
+ 	    	int j;
+
+	    	if (!rmodeNames[i] || !rmodeNames[i+1]) {
+		    break;
+		}
+	    	if (!strcmp(rmodeNames[i], rmodeNames[i+1])) {
+		    for (j = i+1; j < numEdidModes; j++) {
+			if (rmodeNames[j+1])
+				rmodeNames[j] = 
+					xnfstrdup (rmodeNames[j+1]); 
+			else
+				rmodeNames[j] = NULL;
+		    }	
+	    	} else
+			i++;
+	    }
+    }
+
+    endp = &scrp->modes;
+    last = NULL;
+    if (rmodeNames != NULL) {
+	for (i = 0; rmodeNames[i] != NULL; i++) {
+	    if (fallbackMode)
+	    	xf86DrvMsg(scrp->scrnIndex, X_INFO, 
+		    "Prepend Fallback mode name \"%s\" to validation list\n", 
+		    rmodeNames[i]);
+	    else {
+	    	if (userModes)
+	    	    xf86DrvMsg(scrp->scrnIndex, X_INFO, 
+		    	"Prepend User mode name \"%s\" to validation list\n", 
+		    	rmodeNames[i]);
+		else
+	    	    xf86DrvMsg(scrp->scrnIndex, X_INFO, 
+		    	"Prepend EDID mode name \"%s\" to validation list\n", rmodeNames[i]);
+	    }
+	    new = xnfcalloc(1, sizeof(DisplayModeRec));
+	    new->prev = last;
+	    if (userModes)
+	    	new->type = M_T_USERDEF;
+	    else {
+		if (fallbackMode)
+	    	    new->type = M_T_DEFAULT;
+		else
+	    	    new->type = M_T_EDID;
+	    }
+	    new->name = xnfalloc(strlen(rmodeNames[i]) + 1);
+	    strcpy(new->name, rmodeNames[i]);
+	    if (new->prev)
+		new->prev->next = new;
+	    *endp = last = new;
+	    endp = &new->next;
+	}
+    }
+
+    /* Lookup each mode */
+#ifdef RANDR
+    if (!xf86Info.disableRandR	
+#ifdef PANORAMIX
+	&& noPanoramiXExtension
+#endif
+	)
+	validateAllDefaultModes = TRUE;
+#endif
+
+    for (p = scrp->modes; ; p = p->next) {
+	Bool repeat;
+
+	/*
+	 * If the supplied mode names don't produce a valid mode, scan through
+	 * unconsidered modePool members until one survives validation.  This
+	 * is done in decreasing order by mode pixel area.
+	 */
+
+	if (p == NULL) {
+	    if ((numModes > 0) && !validateAllDefaultModes)
+		break;
+
+	    validateAllDefaultModes = TRUE;
+	    r = NULL;
+	    modeSize = 0;
+	    for (q = scrp->modePool;  q != NULL;  q = q->next) {
+		/* EDID modes are already in validation list (scrp->modes) */
+		if (!userModes && (q->type == M_T_EDID))
+		    continue;
+		if ((q->prev == NULL) && (q->status == MODE_OK)) {
+		    for (p = scrp->modes; p != NULL; p = p->next) {
+			/* Unique timing for each mode */
+			if (!strcmp(p->name, q->name)) 
+			/* Multiple timing for each mode */
+			/*
+			if (!strcmp(p->name, q->name) && (p->status != MODE_OK))
+			*/
+			    break;
+		    }
+
+		    /* Skip already previously considered (in scrp->modes) */
+		    if (p != NULL) 
+			q->prev = p;
+		    else {
+			/*
+			 * A quick check to not allow default modes with
+			 * horizontal timing parameters that CRTs may have
+			 * problems with.
+			 */
+			if ((q->type & M_T_DEFAULT) &&
+			    ((double)q->HTotal / (double)q->HDisplay) < 1.15)
+			    continue;
+
+			/*
+			 * If there is a target refresh rate, skip modes that
+			 * don't match up.
+			 */
+			if (ModeVRefresh(q) <
+			    (1.0 - SYNC_TOLERANCE) * targetRefresh)
+			    continue;
+
+			if (modeSize < (q->HDisplay * q->VDisplay)) {
+			    r = q;
+			    modeSize = q->HDisplay * q->VDisplay;
+			}
+		    }
+		}
+	    }
+
+	    if (r == NULL)
+		break;
+	    p = xnfcalloc(1, sizeof(DisplayModeRec));
+	    p->prev = last;
+	    p->name = xnfalloc(strlen(r->name) + 1);
+	    p->type = r->type;
+	    strcpy(p->name, r->name);
+	    if (p->prev)
+		p->prev->next = p;
+	    *endp = last = p;
+	    endp = &p->next;
+	}
+
+	repeat = FALSE;
+    lookupNext:
+	if (repeat && ((status = p->status) != MODE_OK)) {
+	    char *typestring;
+
+	    switch (p->type) {
+	    	case M_T_BUILTIN:	
+	    	    typestring = xnfstrdup("builtin");
+		    break;
+	    	case M_T_USERDEF:	
+	    	    typestring = xnfstrdup("user");
+		    break;
+	    	case M_T_EDID:	
+	    	    typestring = xnfstrdup("EDID");
+		    break;
+	    	case M_T_DEFAULT:	
+		    typestring = xnfstrdup("default");
+		    break;
+	    	default:	
+	    	    typestring = xnfstrdup("");
+		    break;
+	    }
+	    xf86DrvMsg(scrp->scrnIndex, X_INFO,
+	  	"Not using %s \"%s\" %.1f MHz (%s)\n", typestring,
+		p->name, p->Clock/1000.0, xf86ModeStatusToString(status));
+	}
+	saveType = p->type;
+	status = xf86LookupMode(scrp, p, clockRanges, strategy);
+	if (repeat && status == MODE_NOMODE) {
+	    continue;
+	}
+	if (status != MODE_OK) {
+	    char *typestring;
+
+	    switch (p->type) {
+	    	case M_T_BUILTIN:	
+	    	    typestring = xnfstrdup("builtin");
+		    break;
+	    	case M_T_USERDEF:	
+	    	    typestring = xnfstrdup("user");
+		    break;
+	    	case M_T_EDID:	
+	    	    typestring = xnfstrdup("EDID");
+		    break;
+	    	case M_T_DEFAULT:	
+		    typestring = xnfstrdup("default");
+		    break;
+	    	default:	
+	    	    typestring = xnfstrdup("");
+		    break;
+	    }
+	    xf86DrvMsg(scrp->scrnIndex, X_INFO,
+	  	"Not using %s \"%s\" %.1f MHz (%s)\n", typestring,
+		p->name, p->Clock/1000.0, xf86ModeStatusToString(status));
+	}
+	if (status == MODE_ERROR) {
+	    ErrorF("xf86ValidateModes: "
+		   "unexpected result from xf86LookupMode()\n");
+	    return -1;
+	}
+	if (status != MODE_OK) {
+	    if (p->status == MODE_OK)
+		p->status = status;
+	    continue;
+	}
+	p->type |= saveType;
+	repeat = TRUE;
+
+	newLinePitch = linePitch;
+	newVirtX = virtX;
+	newVirtY = virtY;
+
+	/*
+	 * Don't let non-user defined modes increase the virtual size
+	 */
+	if (!(p->type & M_T_USERDEF) && (numModes > 0)) {
+	    if (p->HDisplay > virtX) {
+		p->status = MODE_VIRTUAL_X;
+		goto lookupNext;
+	    }
+	    if (p->VDisplay > virtY) {
+		p->status = MODE_VIRTUAL_Y;
+		goto lookupNext;
+	    }
+	}
+	/*
+	 * Adjust virtual width and height if the mode is too large for the
+	 * current values and if they are not fixed.
+	 */
+	if (virtualX <= 0 && p->HDisplay > newVirtX)
+	    newVirtX = _VIRTUALX(p->HDisplay);
+	if (virtualY <= 0 && p->VDisplay > newVirtY) {
+	    if (maxHeight > 0 && p->VDisplay > maxHeight) {
+		p->status = MODE_VIRTUAL_Y;	/* ? */
+		goto lookupNext;
+	    }
+	    newVirtY = p->VDisplay;
+	}
+
+	/*
+	 * If virtual resolution is to be increased, revalidate it.
+	 */
+	if ((virtX != newVirtX) || (virtY != newVirtY)) {
+	    if (linePitches != NULL) {
+		newLinePitch = -1;
+		for (i = 0; linePitches[i] != 0; i++) {
+		    if ((linePitches[i] >= newVirtX) &&
+			(linePitches[i] >= linePitch) &&
+			(linePitches[i] ==
+			 miScanLineWidth(newVirtX, newVirtY, linePitches[i],
+					 apertureSize, BankFormat, pitchInc))) {
+			newLinePitch = linePitches[i];
+			break;
+		    }
+		}
+	    } else {
+		if (linePitch < minPitch)
+		    linePitch = minPitch;
+		newLinePitch = miScanLineWidth(newVirtX, newVirtY, linePitch,
+					       apertureSize, BankFormat,
+					       pitchInc);
+	    }
+	    if ((newLinePitch < minPitch) || (newLinePitch > maxPitch)) {
+		p->status = MODE_BAD_WIDTH;
+		goto lookupNext;
+	    }
+
+	    /*
+	     * Check that the pixel area required by the new virtual height
+	     * and line pitch isn't too large.
+	     */
+	    if (!xf86CheckModeSize(scrp, newLinePitch, newVirtX, newVirtY)) {
+		p->status = MODE_MEM_VIRT;
+		goto lookupNext;
+	    }
+	}
+
+	if (scrp->ValidMode) {
+	    /*
+	     * Give the driver a final say, passing it the proposed virtual
+	     * geometry.
+	     */
+	    scrp->virtualX = newVirtX;
+	    scrp->virtualY = newVirtY;
+	    scrp->displayWidth = newLinePitch;
+	    p->status = (scrp->ValidMode)(scrp->scrnIndex, p, FALSE,
+					  MODECHECK_FINAL);
+
+	    if (p->status != MODE_OK) {
+	        goto lookupNext;
+	    }
+	}
+
+	/* Mode has passed all the tests */
+	virtX = newVirtX;
+	virtY = newVirtY;
+	linePitch = newLinePitch;
+	p->status = MODE_OK;
+	numModes++;
+    }
+
+#undef _VIRTUALX
+
+    /* Update the ScrnInfoRec parameters */
+    
+    scrp->virtualX = virtX;
+    scrp->virtualY = virtY;
+    scrp->displayWidth = linePitch;
+
+    if (numModes <= 0)
+	return 0;
+  
+    for (p = scrp->modes; p != NULL; p = p->next)
+        if (p->status == MODE_OK) 
+	    break;
+    if (p) {
+	xf86DrvMsg(scrp->scrnIndex, X_INFO,
+	    "Valid mode on top of list : \"%s\" %.1f MHz %.1f kHz, %.1f Hz with --\n", 
+	    p->name, p->Clock/1000.0, ModeHSync(p), ModeVRefresh(p));
+	PrintModeline(scrp->scrnIndex, p);
+    }
+
+    /* Make the mode list into a circular list by joining up the ends */
+    p = scrp->modes;
+    while (p->next != NULL)
+	p = p->next;
+    /* p is now the last mode on the list */
+    p->next = scrp->modes;
+    scrp->modes->prev = p;
+    if (minHeight > 0 && virtY < minHeight) {
+	xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+		   "Virtual height (%d) is too small for the hardware "
+		   "(min %d)\n", virtY, minHeight);
+	return -1;
+    }
+
+    return numModes;
+}
+
+/*
+ * xf86DeleteMode
+ *
+ * This function removes a mode from a list of modes.
+ *
+ * There are different types of mode lists:
+ *
+ *  - singly linked linear lists, ending in NULL
+ *  - doubly linked linear lists, starting and ending in NULL
+ *  - doubly linked circular lists
+ *
+ */
+ 
+void
+xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode)
+{
+    /* Catch the easy/insane cases */
+    if (modeList == NULL || *modeList == NULL || mode == NULL)
+	return;
+
+    /* If the mode is at the start of the list, move the start of the list */
+    if (*modeList == mode)
+	*modeList = mode->next;
+
+    /* If mode is the only one on the list, set the list to NULL */
+    if ((mode == mode->prev) && (mode == mode->next)) {
+	*modeList = NULL;
+    } else {
+	if ((mode->prev != NULL) && (mode->prev->next == mode))
+	    mode->prev->next = mode->next;
+	if ((mode->next != NULL) && (mode->next->prev == mode))
+	    mode->next->prev = mode->prev;
+    }
+
+    xfree(mode->name);
+    xfree(mode);
+}
+
+/*
+ * xf86PruneDriverModes
+ *
+ * Remove modes from the driver's mode list which have been marked as
+ * invalid.
+ */
+
+void
+xf86PruneDriverModes(ScrnInfoPtr scrp)
+{
+    DisplayModePtr first, p, n;
+
+    p = scrp->modes;
+    if (p == NULL)
+	return;
+
+    do {
+	if (!(first = scrp->modes))
+	    return;
+	n = p->next;
+	if (p->status != MODE_OK) {
+#if 0
+	    if (p->type & M_T_BUILTIN)
+		xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			   "Not using built-in mode \"%s\" (%s)\n", p->name,
+			   xf86ModeStatusToString(p->status));
+	    else if (p->type & M_T_DEFAULT)
+		xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			   "Not using default mode \"%s\" (%s)\n", p->name,
+			   xf86ModeStatusToString(p->status));
+	    else
+	        xf86DrvMsg(scrp->scrnIndex, X_INFO,
+			   "Not using mode \"%s\" (%s)\n", p->name,
+			   xf86ModeStatusToString(p->status));
+#endif
+	    xf86DeleteMode(&(scrp->modes), p);
+	}
+	p = n;
+    } while (p != NULL && p != first);
+
+    /* modePool is no longer needed, turf it */
+    while (scrp->modePool) {
+	/*
+	 * A modePool mode's prev field is used to hold a pointer to the
+	 * member of the scrp->modes list for which a match was considered.
+	 * Clear that pointer first, otherwise xf86DeleteMode might get 
+	 * confused 
+	 */
+	scrp->modePool->prev = NULL;
+	xf86DeleteMode(&scrp->modePool, scrp->modePool);
+    }
+}
+
+
+/*
+ * xf86SetCrtcForModes
+ *
+ * Goes through the screen's mode list, and initialises the Crtc
+ * parameters for each mode.  The initialisation includes adjustments
+ * for interlaced and double scan modes.
+ */
+void
+xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags)
+{
+    DisplayModePtr p;
+
+    /*
+     * Store adjustFlags for use with the VidMode extension. There is an
+     * implicit assumption here that SetCrtcForModes is called once.
+     */
+    scrp->adjustFlags = adjustFlags;
+
+    p = scrp->modes;
+    if (p == NULL)
+	return;
+
+    do {
+	xf86SetModeCrtc(p, adjustFlags);
+#ifdef DEBUG
+	ErrorF("%sMode %s: %d (%d) %d %d (%d) %d %d (%d) %d %d (%d) %d\n",
+	       (p->type & M_T_DEFAULT) ? "Default " : "",
+	       p->name, p->CrtcHDisplay, p->CrtcHBlankStart,
+	       p->CrtcHSyncStart, p->CrtcHSyncEnd, p->CrtcHBlankEnd,
+	       p->CrtcHTotal, p->CrtcVDisplay, p->CrtcVBlankStart,
+	       p->CrtcVSyncStart, p->CrtcVSyncEnd, p->CrtcVBlankEnd,
+	       p->CrtcVTotal);
+#endif
+	p = p->next;
+    } while (p != NULL && p != scrp->modes);
+}
+
+
+static void
+add(char **p, char *new)
+{
+    *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2);
+    strcat(*p, " ");
+    strcat(*p, new);
+}
+
+static void
+PrintModeline(int scrnIndex,DisplayModePtr mode)
+{
+    char tmp[256];
+    char *flags = xnfcalloc(1, 1);
+
+    if (mode->HSkew) { 
+	snprintf(tmp, 256, "hskew %i", mode->HSkew); 
+	add(&flags, tmp);
+    }
+    if (mode->VScan) { 
+	snprintf(tmp, 256, "vscan %i", mode->VScan); 
+	add(&flags, tmp);
+    }
+    if (mode->Flags & V_INTERLACE) add(&flags, "interlace");
+    if (mode->Flags & V_CSYNC) add(&flags, "composite");
+    if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan");
+    if (mode->Flags & V_BCAST) add(&flags, "bcast");
+    if (mode->Flags & V_PHSYNC) add(&flags, "+hsync");
+    if (mode->Flags & V_NHSYNC) add(&flags, "-hsync");
+    if (mode->Flags & V_PVSYNC) add(&flags, "+vsync");
+    if (mode->Flags & V_NVSYNC) add(&flags, "-vsync");
+    if (mode->Flags & V_PCSYNC) add(&flags, "+csync");
+    if (mode->Flags & V_NCSYNC) add(&flags, "-csync");
+#if 0
+    if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2");
+#endif
+    xf86DrvMsgVerb(scrnIndex, X_INFO, 3,
+		   "Modeline \"%s\"  %6.2f  %i %i %i %i  %i %i %i %i%s\n",
+		   mode->name, mode->Clock/1000., mode->HDisplay,
+		   mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
+		   mode->VDisplay, mode->VSyncStart, mode->VSyncEnd,
+		   mode->VTotal, flags);
+    xfree(flags);
+}
+
+void
+xf86PrintModes(ScrnInfoPtr scrp)
+{
+    DisplayModePtr p;
+    float hsync, refresh = 0;
+    char *desc, *desc2, *prefix, *uprefix;
+
+    if (scrp == NULL)
+	return;
+
+    xf86DrvMsg(scrp->scrnIndex, scrp->virtualFrom, "Virtual size is %dx%d "
+	       "(pitch %d)\n", scrp->virtualX, scrp->virtualY,
+	       scrp->displayWidth);
+    
+    p = scrp->modes;
+    if (p == NULL)
+	return;
+
+    do {
+	desc = desc2 = "";
+	hsync = ModeHSync(p);
+	refresh = ModeVRefresh(p);
+	if (p->Flags & V_INTERLACE) {
+	    desc = " (I)";
+	}
+	if (p->Flags & V_DBLSCAN) {
+	    desc = " (D)";
+	}
+	if (p->VScan > 1) {
+	    desc2 = " (VScan)";
+	}
+	if (!(p->type) || (p->type & M_T_EDID))
+            prefix = "EDID mode";
+	else if (p->type & M_T_USERDEF)
+	    prefix = "User mode";
+	else if (p->type & M_T_BUILTIN)
+	    prefix = "Builtin mode";
+	else if (p->type & M_T_DEFAULT)
+	    prefix = "Default mode";
+	else
+	    prefix = "Mode";
+	uprefix = "";
+	if (hsync == 0 || refresh == 0) {
+	    if (p->name)
+		xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+			   "%s%s \"%s\"\n", uprefix, prefix, p->name);
+	    else
+		xf86DrvMsg(scrp->scrnIndex, X_PROBED,
+			   "%s%s %dx%d (unnamed)\n",
+			   uprefix, prefix, p->HDisplay, p->VDisplay);
+	} else if (p->Clock == p->SynthClock) {
+	    xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+			"%s%s \"%s\": %.1f MHz, %.1f kHz, %.1f Hz%s%s\n",
+			uprefix, prefix, p->name, p->Clock / 1000.0,
+			hsync, refresh, desc, desc2);
+	} else {
+	    xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+			"%s%s \"%s\": %.1f MHz (scaled from %.1f MHz), "
+			"%.1f kHz, %.1f Hz%s%s\n",
+			uprefix, prefix, p->name, p->Clock / 1000.0,
+			p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
+	}
+	if (hsync != 0 && refresh != 0)
+	    PrintModeline(scrp->scrnIndex,p);
+	p = p->next;
+    } while (p != NULL && p != scrp->modes);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,730 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.156 2003/10/30 15:26:33 tsi Exp $ */
+
+/*
+ * Copyright (c) 1995-2003 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ */
+
+/*
+ * This file contains macros for the PCI Vendor and Device IDs for video
+ * cards plus a few other things that are needed in drivers or elsewhere.
+ * This information is used in several ways:
+ *   1. It is used by drivers and/or other code.
+ *   2. It is used by the pciid2c.pl script to determine what vendor data to
+ *      include in the pcidata module that the X server loads.
+ *   3. A side-effect of 2. affects how config-generation works for
+ *      otherwise "unknown" cards.
+ *
+ * Don't add entries here for vendors that don't make video cards,
+ * or for non-video devices unless they're needed by a driver or elsewhere.
+ * A comprehensive set of PCI vendor, device and subsystem data is
+ * auto-generated from the ../etc/pci.ids file using the pciids2c.pl script,
+ * and is used in both the scanpci module and the scanpci utility.  Don't
+ * modify the pci.ids file.  If new/corrected entries are required, add them
+ * to ../etc/extrapci.ids.
+ */
+
+#ifndef _XF86_PCIINFO_H
+#define _XF86_PCIINFO_H
+
+/* PCI Pseudo Vendor */
+#define PCI_VENDOR_GENERIC		0x00FF
+
+#define PCI_VENDOR_REAL3D		0x003D
+#define PCI_VENDOR_COMPAQ		0x0E11
+#define PCI_VENDOR_ATI			0x1002
+#define PCI_VENDOR_AVANCE		0x1005
+#define PCI_VENDOR_TSENG		0x100C
+#define PCI_VENDOR_NS			0x100B
+#define PCI_VENDOR_WEITEK		0x100E
+#define PCI_VENDOR_VIDEOLOGIC		0x1010
+#define PCI_VENDOR_DIGITAL		0x1011
+#define PCI_VENDOR_CIRRUS		0x1013
+#define PCI_VENDOR_AMD			0x1022
+#define PCI_VENDOR_TRIDENT		0x1023
+#define PCI_VENDOR_ALI			0x1025
+#define PCI_VENDOR_DELL			0x1028
+#define PCI_VENDOR_MATROX		0x102B
+#define PCI_VENDOR_CHIPSTECH		0x102C
+#define PCI_VENDOR_MIRO			0x1031
+#define PCI_VENDOR_NEC			0x1033
+#define PCI_VENDOR_SIS			0x1039
+#define PCI_VENDOR_HP			0x103C
+#define PCI_VENDOR_SGS			0x104A
+#define PCI_VENDOR_TI			0x104C
+#define PCI_VENDOR_SONY			0x104D
+#define PCI_VENDOR_OAK			0x104E
+#define PCI_VENDOR_MOTOROLA		0x1057
+#define PCI_VENDOR_NUMNINE		0x105D
+#define PCI_VENDOR_CYRIX		0x1078
+#define PCI_VENDOR_SUN			0x108E
+#define PCI_VENDOR_DIAMOND		0x1092
+#define PCI_VENDOR_BROOKTREE		0x109E
+#define PCI_VENDOR_NEOMAGIC		0x10C8
+#define PCI_VENDOR_NVIDIA		0x10DE
+#define PCI_VENDOR_IMS			0x10E0
+#define PCI_VENDOR_INTEGRAPHICS 	0x10EA
+#define PCI_VENDOR_ALLIANCE		0x1142
+#define PCI_VENDOR_RENDITION		0x1163
+#define PCI_VENDOR_3DFX			0x121A
+#define PCI_VENDOR_SMI			0x126F
+#define PCI_VENDOR_TRITECH		0x1292
+#define PCI_VENDOR_NVIDIA_SGS		0x12D2
+#define PCI_VENDOR_VMWARE		0x15AD
+#define PCI_VENDOR_AST			0x1A03
+#define PCI_VENDOR_3DLABS		0x3D3D
+#define PCI_VENDOR_AVANCE_2		0x4005
+#define PCI_VENDOR_HERCULES		0x4843
+#define PCI_VENDOR_S3			0x5333
+#define PCI_VENDOR_INTEL		0x8086
+#define PCI_VENDOR_ARK			0xEDD8
+
+
+/* Generic */
+#define PCI_CHIP_VGA			0x0000
+#define PCI_CHIP_8514			0x0001
+
+/* Real 3D */
+#define PCI_CHIP_I740_PCI		0x00D1
+
+/* Compaq */
+#define PCI_CHIP_QV1280			0x3033
+
+/* ATI */
+#define PCI_CHIP_RV380_3150             0x3150
+#define PCI_CHIP_RV380_3151             0x3151
+#define PCI_CHIP_RV380_3152             0x3152
+#define PCI_CHIP_RV380_3153             0x3153
+#define PCI_CHIP_RV380_3154             0x3154
+#define PCI_CHIP_RV380_3156             0x3156
+#define PCI_CHIP_RV380_3E50             0x3E50
+#define PCI_CHIP_RV380_3E51             0x3E51
+#define PCI_CHIP_RV380_3E52             0x3E52
+#define PCI_CHIP_RV380_3E53             0x3E53
+#define PCI_CHIP_RV380_3E54             0x3E54
+#define PCI_CHIP_RV380_3E56             0x3E56
+#define PCI_CHIP_RS100_4136		0x4136
+#define PCI_CHIP_RS200_4137		0x4137
+#define PCI_CHIP_R300_AD		0x4144
+#define PCI_CHIP_R300_AE		0x4145
+#define PCI_CHIP_R300_AF		0x4146
+#define PCI_CHIP_R300_AG		0x4147
+#define PCI_CHIP_R350_AH                0x4148
+#define PCI_CHIP_R350_AI                0x4149
+#define PCI_CHIP_R350_AJ                0x414A
+#define PCI_CHIP_R350_AK                0x414B
+#define PCI_CHIP_RV350_AP               0x4150
+#define PCI_CHIP_RV350_AQ               0x4151
+#define PCI_CHIP_RV360_AR               0x4152
+#define PCI_CHIP_RV350_AS               0x4153
+#define PCI_CHIP_RV350_AT               0x4154
+#define PCI_CHIP_RV350_4155             0x4155
+#define PCI_CHIP_RV350_AV               0x4156
+#define PCI_CHIP_MACH32			0x4158
+#define PCI_CHIP_RS250_4237		0x4237
+#define PCI_CHIP_R200_BB		0x4242
+#define PCI_CHIP_R200_BC		0x4243
+#define PCI_CHIP_RS100_4336		0x4336
+#define PCI_CHIP_RS200_4337		0x4337
+#define PCI_CHIP_MACH64CT		0x4354
+#define PCI_CHIP_MACH64CX		0x4358
+#define PCI_CHIP_RS250_4437		0x4437
+#define PCI_CHIP_MACH64ET		0x4554
+#define PCI_CHIP_MACH64GB		0x4742
+#define PCI_CHIP_MACH64GD		0x4744
+#define PCI_CHIP_MACH64GI		0x4749
+#define PCI_CHIP_MACH64GL		0x474C
+#define PCI_CHIP_MACH64GM		0x474D
+#define PCI_CHIP_MACH64GN		0x474E
+#define PCI_CHIP_MACH64GO		0x474F
+#define PCI_CHIP_MACH64GP		0x4750
+#define PCI_CHIP_MACH64GQ		0x4751
+#define PCI_CHIP_MACH64GR		0x4752
+#define PCI_CHIP_MACH64GS		0x4753
+#define PCI_CHIP_MACH64GT		0x4754
+#define PCI_CHIP_MACH64GU		0x4755
+#define PCI_CHIP_MACH64GV		0x4756
+#define PCI_CHIP_MACH64GW		0x4757
+#define PCI_CHIP_MACH64GX		0x4758
+#define PCI_CHIP_MACH64GY		0x4759
+#define PCI_CHIP_MACH64GZ		0x475A
+#define PCI_CHIP_RV250_Id		0x4964
+#define PCI_CHIP_RV250_Ie		0x4965
+#define PCI_CHIP_RV250_If		0x4966
+#define PCI_CHIP_RV250_Ig		0x4967
+#define PCI_CHIP_R420_JH                0x4A48
+#define PCI_CHIP_R420_JI                0x4A49
+#define PCI_CHIP_R420_JJ                0x4A4A
+#define PCI_CHIP_R420_JK                0x4A4B
+#define PCI_CHIP_R420_JL                0x4A4C
+#define PCI_CHIP_R420_JM                0x4A4D
+#define PCI_CHIP_R420_JN                0x4A4E
+#define PCI_CHIP_R420_4A4F              0x4A4F
+#define PCI_CHIP_R420_JP                0x4A50
+#define PCI_CHIP_R481_4B49              0x4B49
+#define PCI_CHIP_R481_4B4A              0x4B4A
+#define PCI_CHIP_R481_4B4B              0x4B4B
+#define PCI_CHIP_R481_4B4C              0x4B4C
+#define PCI_CHIP_MACH64LB		0x4C42
+#define PCI_CHIP_MACH64LD		0x4C44
+#define PCI_CHIP_RAGE128LE		0x4C45
+#define PCI_CHIP_RAGE128LF		0x4C46
+#define PCI_CHIP_MACH64LG		0x4C47
+#define PCI_CHIP_MACH64LI		0x4C49
+#define PCI_CHIP_MACH64LM		0x4C4D
+#define PCI_CHIP_MACH64LN		0x4C4E
+#define PCI_CHIP_MACH64LP		0x4C50
+#define PCI_CHIP_MACH64LQ		0x4C51
+#define PCI_CHIP_MACH64LR		0x4C52
+#define PCI_CHIP_MACH64LS		0x4C53
+#define PCI_CHIP_RADEON_LW		0x4C57
+#define PCI_CHIP_RADEON_LX		0x4C58
+#define PCI_CHIP_RADEON_LY		0x4C59
+#define PCI_CHIP_RADEON_LZ		0x4C5A
+#define PCI_CHIP_RV250_Ld		0x4C64
+#define PCI_CHIP_RV250_Le		0x4C65
+#define PCI_CHIP_RV250_Lf		0x4C66
+#define PCI_CHIP_RV250_Lg		0x4C67
+#define PCI_CHIP_RV250_Ln		0x4C6E
+#define PCI_CHIP_RAGE128MF		0x4D46
+#define PCI_CHIP_RAGE128ML		0x4D4C
+#define PCI_CHIP_R300_ND		0x4E44
+#define PCI_CHIP_R300_NE		0x4E45
+#define PCI_CHIP_R300_NF		0x4E46
+#define PCI_CHIP_R300_NG		0x4E47
+#define PCI_CHIP_R350_NH                0x4E48  
+#define PCI_CHIP_R350_NI                0x4E49  
+#define PCI_CHIP_R360_NJ                0x4E4A  
+#define PCI_CHIP_R350_NK                0x4E4B  
+#define PCI_CHIP_RV350_NP               0x4E50
+#define PCI_CHIP_RV350_NQ               0x4E51
+#define PCI_CHIP_RV350_NR               0x4E52
+#define PCI_CHIP_RV350_NS               0x4E53
+#define PCI_CHIP_RV350_NT               0x4E54
+#define PCI_CHIP_RV350_NV               0x4E56
+#define PCI_CHIP_RAGE128PA		0x5041
+#define PCI_CHIP_RAGE128PB		0x5042
+#define PCI_CHIP_RAGE128PC		0x5043
+#define PCI_CHIP_RAGE128PD		0x5044
+#define PCI_CHIP_RAGE128PE		0x5045
+#define PCI_CHIP_RAGE128PF		0x5046
+#define PCI_CHIP_RAGE128PG		0x5047
+#define PCI_CHIP_RAGE128PH		0x5048
+#define PCI_CHIP_RAGE128PI		0x5049
+#define PCI_CHIP_RAGE128PJ		0x504A
+#define PCI_CHIP_RAGE128PK		0x504B
+#define PCI_CHIP_RAGE128PL		0x504C
+#define PCI_CHIP_RAGE128PM		0x504D
+#define PCI_CHIP_RAGE128PN		0x504E
+#define PCI_CHIP_RAGE128PO		0x504F
+#define PCI_CHIP_RAGE128PP		0x5050
+#define PCI_CHIP_RAGE128PQ		0x5051
+#define PCI_CHIP_RAGE128PR		0x5052
+#define PCI_CHIP_RAGE128PS		0x5053
+#define PCI_CHIP_RAGE128PT		0x5054
+#define PCI_CHIP_RAGE128PU		0x5055
+#define PCI_CHIP_RAGE128PV		0x5056
+#define PCI_CHIP_RAGE128PW		0x5057
+#define PCI_CHIP_RAGE128PX		0x5058
+#define PCI_CHIP_RADEON_QD		0x5144
+#define PCI_CHIP_RADEON_QE		0x5145
+#define PCI_CHIP_RADEON_QF		0x5146
+#define PCI_CHIP_RADEON_QG		0x5147
+#define PCI_CHIP_R200_QH		0x5148
+#define PCI_CHIP_R200_QI		0x5149
+#define PCI_CHIP_R200_QJ		0x514A
+#define PCI_CHIP_R200_QK		0x514B
+#define PCI_CHIP_R200_QL		0x514C
+#define PCI_CHIP_R200_QM		0x514D
+#define PCI_CHIP_R200_QN		0x514E
+#define PCI_CHIP_R200_QO		0x514F
+#define PCI_CHIP_RV200_QW		0x5157
+#define PCI_CHIP_RV200_QX		0x5158
+#define PCI_CHIP_RV100_QY		0x5159
+#define PCI_CHIP_RV100_QZ		0x515A
+#define PCI_CHIP_RN50_515E		0x515E
+#define PCI_CHIP_RAGE128RE		0x5245
+#define PCI_CHIP_RAGE128RF		0x5246
+#define PCI_CHIP_RAGE128RG		0x5247
+#define PCI_CHIP_RAGE128RK		0x524B
+#define PCI_CHIP_RAGE128RL		0x524C
+#define PCI_CHIP_RAGE128SE		0x5345
+#define PCI_CHIP_RAGE128SF		0x5346
+#define PCI_CHIP_RAGE128SG		0x5347
+#define PCI_CHIP_RAGE128SH		0x5348
+#define PCI_CHIP_RAGE128SK		0x534B
+#define PCI_CHIP_RAGE128SL		0x534C
+#define PCI_CHIP_RAGE128SM		0x534D
+#define PCI_CHIP_RAGE128SN		0x534E
+#define PCI_CHIP_RAGE128TF		0x5446
+#define PCI_CHIP_RAGE128TL		0x544C
+#define PCI_CHIP_RAGE128TR		0x5452
+#define PCI_CHIP_RAGE128TS		0x5453
+#define PCI_CHIP_RAGE128TT		0x5454
+#define PCI_CHIP_RAGE128TU		0x5455
+#define PCI_CHIP_RV370_5460             0x5460
+#define PCI_CHIP_RV370_5461             0x5461
+#define PCI_CHIP_RV370_5462             0x5462
+#define PCI_CHIP_RV370_5463             0x5463
+#define PCI_CHIP_RV370_5464             0x5464
+#define PCI_CHIP_RV370_5465             0x5465
+#define PCI_CHIP_RV370_5466             0x5466
+#define PCI_CHIP_RV370_5467             0x5467
+#define PCI_CHIP_R423_UH                0x5548
+#define PCI_CHIP_R423_UI                0x5549
+#define PCI_CHIP_R423_UJ                0x554A
+#define PCI_CHIP_R423_UK                0x554B
+#define PCI_CHIP_R430_554C              0x554C
+#define PCI_CHIP_R430_554D              0x554D
+#define PCI_CHIP_R430_554E              0x554E
+#define PCI_CHIP_R430_554F              0x554F
+#define PCI_CHIP_R423_5550              0x5550
+#define PCI_CHIP_R423_UQ                0x5551
+#define PCI_CHIP_R423_UR                0x5552
+#define PCI_CHIP_R423_UT                0x5554
+#define PCI_CHIP_RV410_564A             0x564A
+#define PCI_CHIP_RV410_564B             0x564B
+#define PCI_CHIP_RV410_5652             0x5652
+#define PCI_CHIP_RV410_5653             0x5653
+#define PCI_CHIP_MACH64VT		0x5654
+#define PCI_CHIP_MACH64VU		0x5655
+#define PCI_CHIP_MACH64VV		0x5656
+#define PCI_CHIP_RS300_5834		0x5834
+#define PCI_CHIP_RS300_5835		0x5835
+#define PCI_CHIP_RS300_5836		0x5836
+#define PCI_CHIP_RS300_5837		0x5837
+#define PCI_CHIP_RS480_5954             0x5954
+#define PCI_CHIP_RS480_5955             0x5955
+#define PCI_CHIP_RV280_5960		0x5960
+#define PCI_CHIP_RV280_5961		0x5961
+#define PCI_CHIP_RV280_5962		0x5962
+#define PCI_CHIP_RV280_5964		0x5964
+#define PCI_CHIP_RV280_5965 		0x5965
+#define PCI_CHIP_RN50_5969		0x5969
+#define PCI_CHIP_RS482_5974             0x5974
+#define PCI_CHIP_RS482_5975             0x5975
+#define PCI_CHIP_RS400_5A41             0x5A41
+#define PCI_CHIP_RS400_5A42             0x5A42
+#define PCI_CHIP_RC410_5A61             0x5A61
+#define PCI_CHIP_RC410_5A62             0x5A62
+#define PCI_CHIP_RV370_5B60             0x5B60
+#define PCI_CHIP_RV370_5B61             0x5B61
+#define PCI_CHIP_RV370_5B62             0x5B62
+#define PCI_CHIP_RV370_5B63             0x5B63
+#define PCI_CHIP_RV370_5B64             0x5B64
+#define PCI_CHIP_RV370_5B65             0x5B65
+#define PCI_CHIP_RV370_5B66             0x5B66
+#define PCI_CHIP_RV370_5B67             0x5B67
+#define PCI_CHIP_RV280_5C61		0x5C61
+#define PCI_CHIP_RV280_5C63		0x5C63
+#define PCI_CHIP_R430_5D48              0x5D48
+#define PCI_CHIP_R430_5D49              0x5D49
+#define PCI_CHIP_R430_5D4A              0x5D4A
+#define PCI_CHIP_R480_5D4C              0x5D4C
+#define PCI_CHIP_R480_5D4D              0x5D4D
+#define PCI_CHIP_R480_5D4E              0x5D4E
+#define PCI_CHIP_R480_5D4F              0x5D4F
+#define PCI_CHIP_R480_5D50              0x5D50
+#define PCI_CHIP_R480_5D52              0x5D52
+#define PCI_CHIP_R423_5D57              0x5D57
+#define PCI_CHIP_RV410_5E48             0x5E48
+#define PCI_CHIP_RV410_5E4A             0x5E4A
+#define PCI_CHIP_RV410_5E4B             0x5E4B
+#define PCI_CHIP_RV410_5E4C             0x5E4C
+#define PCI_CHIP_RV410_5E4D             0x5E4D
+#define PCI_CHIP_RV410_5E4F             0x5E4F
+#define PCI_CHIP_RS350_7834             0x7834
+#define PCI_CHIP_RS350_7835             0x7835
+
+/* AST */
+#define PCI_CHIP_AST2000		0x2000
+
+/* Avance Logic */
+#define PCI_CHIP_ALG2064		0x2064
+#define PCI_CHIP_ALG2301		0x2301
+#define PCI_CHIP_ALG2501		0x2501
+
+/* Tseng */
+#define PCI_CHIP_ET4000_W32P_A		0x3202
+#define PCI_CHIP_ET4000_W32P_B		0x3205
+#define PCI_CHIP_ET4000_W32P_D		0x3206
+#define PCI_CHIP_ET4000_W32P_C		0x3207
+#define PCI_CHIP_ET6000			0x3208
+#define PCI_CHIP_ET6300			0x4702
+
+/* Weitek */
+#define PCI_CHIP_P9000			0x9001
+#define PCI_CHIP_P9100			0x9100
+
+/* Digital */
+#define PCI_CHIP_DC21050		0x0001
+#define PCI_CHIP_DEC21030		0x0004
+#define PCI_CHIP_TGA2			0x000D
+
+/* Cirrus Logic */
+#define PCI_CHIP_GD7548			0x0038
+#define PCI_CHIP_GD7555			0x0040
+#define PCI_CHIP_GD5430			0x00A0
+#define PCI_CHIP_GD5434_4		0x00A4
+#define PCI_CHIP_GD5434_8		0x00A8
+#define PCI_CHIP_GD5436			0x00AC
+#define PCI_CHIP_GD5446			0x00B8
+#define PCI_CHIP_GD5480			0x00BC
+#define PCI_CHIP_GD5462			0x00D0
+#define PCI_CHIP_GD5464			0x00D4
+#define PCI_CHIP_GD5464BD		0x00D5
+#define PCI_CHIP_GD5465			0x00D6
+#define PCI_CHIP_6729			0x1100
+#define PCI_CHIP_6832			0x1110
+#define PCI_CHIP_GD7542			0x1200
+#define PCI_CHIP_GD7543			0x1202
+#define PCI_CHIP_GD7541			0x1204
+
+/* AMD */
+#define PCI_CHIP_AMD761			0x700E
+
+/* Trident */
+#define PCI_CHIP_2100			0x2100
+#define PCI_CHIP_8400			0x8400
+#define PCI_CHIP_8420			0x8420
+#define PCI_CHIP_8500			0x8500
+#define PCI_CHIP_8520			0x8520
+#define PCI_CHIP_8600			0x8600
+#define PCI_CHIP_8620			0x8620
+#define PCI_CHIP_8820			0x8820
+#define PCI_CHIP_9320			0x9320
+#define PCI_CHIP_9388			0x9388
+#define PCI_CHIP_9397			0x9397
+#define PCI_CHIP_939A			0x939A
+#define PCI_CHIP_9420			0x9420
+#define PCI_CHIP_9440			0x9440
+#define PCI_CHIP_9520			0x9520
+#define PCI_CHIP_9525			0x9525
+#define PCI_CHIP_9540			0x9540
+#define PCI_CHIP_9660			0x9660
+#define PCI_CHIP_9750			0x9750
+#define PCI_CHIP_9850			0x9850
+#define PCI_CHIP_9880			0x9880
+#define PCI_CHIP_9910			0x9910
+
+/* ALI */
+#define PCI_CHIP_M1435			0x1435
+
+/* Matrox */
+#define PCI_CHIP_MGA2085		0x0518
+#define PCI_CHIP_MGA2064		0x0519
+#define PCI_CHIP_MGA1064		0x051A
+#define PCI_CHIP_MGA2164		0x051B
+#define PCI_CHIP_MGA2164_AGP		0x051F
+#define PCI_CHIP_MGAG200_PCI		0x0520
+#define PCI_CHIP_MGAG200		0x0521
+#define PCI_CHIP_MGAG400		0x0525
+#define PCI_CHIP_MGAG550		0x2527
+#define PCI_CHIP_IMPRESSION		0x0D10
+#define PCI_CHIP_MGAG100_PCI		0x1000
+#define PCI_CHIP_MGAG100		0x1001
+
+#define PCI_CARD_G400_TH		0x2179
+#define PCI_CARD_MILL_G200_SD		0xFF00
+#define PCI_CARD_PROD_G100_SD		0xFF01
+#define PCI_CARD_MYST_G200_SD		0xFF02
+#define PCI_CARD_MILL_G200_SG		0xFF03
+#define PCI_CARD_MARV_G200_SD		0xFF04
+
+/* Chips & Tech */
+#define PCI_CHIP_65545			0x00D8
+#define PCI_CHIP_65548			0x00DC
+#define PCI_CHIP_65550			0x00E0
+#define PCI_CHIP_65554			0x00E4
+#define PCI_CHIP_65555			0x00E5
+#define PCI_CHIP_68554			0x00F4
+#define PCI_CHIP_69000			0x00C0
+#define PCI_CHIP_69030			0x0C30
+
+/* Miro */
+#define PCI_CHIP_ZR36050		0x5601
+
+/* NEC */
+#define PCI_CHIP_POWER_VR		0x0046
+
+/* SiS */
+#define PCI_CHIP_SG86C201		0x0001
+#define PCI_CHIP_SG86C202		0x0002
+#define PCI_CHIP_SG85C503		0x0008
+#define PCI_CHIP_SIS5597		0x0200
+/* Agregado por Carlos Duclos & Manuel Jander */
+#define PCI_CHIP_SIS82C204		0x0204
+#define PCI_CHIP_SG86C205		0x0205
+#define PCI_CHIP_SG86C215		0x0215
+#define PCI_CHIP_SG86C225		0x0225
+#define PCI_CHIP_85C501			0x0406
+#define PCI_CHIP_85C496			0x0496
+#define PCI_CHIP_85C601			0x0601
+#define PCI_CHIP_85C5107		0x5107
+#define PCI_CHIP_85C5511		0x5511
+#define PCI_CHIP_85C5513		0x5513
+#define PCI_CHIP_SIS5571		0x5571
+#define PCI_CHIP_SIS5597_2		0x5597
+#define PCI_CHIP_SIS530			0x6306
+#define PCI_CHIP_SIS6326		0x6326
+#define PCI_CHIP_SIS7001		0x7001
+#define PCI_CHIP_SIS300			0x0300
+#define PCI_CHIP_SIS315H		0x0310
+#define PCI_CHIP_SIS315PRO		0x0325
+#define PCI_CHIP_SIS330			0x0330
+#define PCI_CHIP_SIS630			0x6300
+#define PCI_CHIP_SIS540			0x5300
+#define PCI_CHIP_SIS550			0x5315 
+#define PCI_CHIP_SIS650			0x6325 
+#define PCI_CHIP_SIS730			0x7300
+
+/* Hewlett-Packard */
+#define PCI_CHIP_ELROY			0x1054
+#define PCI_CHIP_ZX1_SBA		0x1229
+#define PCI_CHIP_ZX1_IOC		0x122A
+#define PCI_CHIP_ZX1_LBA		0x122E	/* a.k.a. Mercury */
+#define PCI_CHIP_ZX1_AGP8		0x12B4	/* a.k.a. QuickSilver */
+#define PCI_CHIP_ZX2_LBA		0x12EE
+#define PCI_CHIP_ZX2_SBA		0x4030
+#define PCI_CHIP_ZX2_IOC		0x4031
+
+/* SGS */
+#define PCI_CHIP_STG2000		0x0008
+#define PCI_CHIP_STG1764		0x0009
+#define PCI_CHIP_KYROII			0x0010
+
+/* Texas Instruments */
+#define PCI_CHIP_TI_PERMEDIA		0x3D04
+#define PCI_CHIP_TI_PERMEDIA2		0x3D07
+
+/* Oak */
+#define PCI_CHIP_OTI107			0x0107
+
+/* Number Nine */
+#define PCI_CHIP_I128			0x2309
+#define PCI_CHIP_I128_2			0x2339
+#define PCI_CHIP_I128_T2R		0x493D
+#define PCI_CHIP_I128_T2R4		0x5348
+
+/* Sun */
+#define PCI_CHIP_EBUS			0x1000
+#define PCI_CHIP_HAPPY_MEAL		0x1001
+#define PCI_CHIP_SIMBA			0x5000
+#define PCI_CHIP_PSYCHO			0x8000
+#define PCI_CHIP_SCHIZO			0x8001
+#define PCI_CHIP_SABRE			0xA000
+#define PCI_CHIP_HUMMINGBIRD		0xA001
+
+/* BrookTree */
+#define PCI_CHIP_BT848			0x0350
+#define PCI_CHIP_BT849			0x0351
+
+/* NVIDIA */
+#define PCI_CHIP_NV1			0x0008
+#define PCI_CHIP_DAC64			0x0009
+#define PCI_CHIP_TNT			0x0020
+#define PCI_CHIP_TNT2			0x0028
+#define PCI_CHIP_UTNT2			0x0029
+#define PCI_CHIP_VTNT2			0x002C
+#define PCI_CHIP_UVTNT2			0x002D
+#define PCI_CHIP_ITNT2			0x00A0
+#define PCI_CHIP_GEFORCE_256		0x0100
+#define PCI_CHIP_GEFORCE_DDR		0x0101
+#define PCI_CHIP_QUADRO			0x0103
+#define PCI_CHIP_GEFORCE2_MX		0x0110
+#define PCI_CHIP_GEFORCE2_MX_100	0x0111
+#define PCI_CHIP_GEFORCE2_GO		0x0112
+#define PCI_CHIP_QUADRO2_MXR		0x0113
+#define PCI_CHIP_GEFORCE2_GTS		0x0150
+#define PCI_CHIP_GEFORCE2_TI		0x0151
+#define PCI_CHIP_GEFORCE2_ULTRA		0x0152
+#define PCI_CHIP_QUADRO2_PRO		0x0153
+#define PCI_CHIP_GEFORCE4_MX_460	0x0170
+#define PCI_CHIP_GEFORCE4_MX_440	0x0171
+#define PCI_CHIP_GEFORCE4_MX_420	0x0172
+#define PCI_CHIP_GEFORCE4_440_GO	0x0174
+#define PCI_CHIP_GEFORCE4_420_GO	0x0175
+#define PCI_CHIP_GEFORCE4_420_GO_M32	0x0176
+#define PCI_CHIP_QUADRO4_500XGL		0x0178
+#define PCI_CHIP_GEFORCE4_440_GO_M64	0x0179
+#define PCI_CHIP_QUADRO4_200		0x017A
+#define PCI_CHIP_QUADRO4_550XGL		0x017B
+#define PCI_CHIP_QUADRO4_500_GOGL	0x017C
+#define PCI_CHIP_IGEFORCE2		0x01A0
+#define PCI_CHIP_GEFORCE3		0x0200
+#define PCI_CHIP_GEFORCE3_TI_200	0x0201
+#define PCI_CHIP_GEFORCE3_TI_500	0x0202
+#define PCI_CHIP_QUADRO_DCC		0x0203
+#define PCI_CHIP_GEFORCE4_TI_4600	0x0250
+#define PCI_CHIP_GEFORCE4_TI_4400	0x0251
+#define PCI_CHIP_GEFORCE4_TI_4200	0x0253
+#define PCI_CHIP_QUADRO4_900XGL		0x0258
+#define PCI_CHIP_QUADRO4_750XGL		0x0259
+#define PCI_CHIP_QUADRO4_700XGL		0x025B
+
+/* NVIDIA & SGS */
+#define PCI_CHIP_RIVA128		0x0018
+
+/* IMS */
+#define PCI_CHIP_IMSTT128		0x9128
+#define PCI_CHIP_IMSTT3D		0x9135
+
+/* Alliance Semiconductor */
+#define PCI_CHIP_AP6410			0x3210
+#define PCI_CHIP_AP6422			0x6422
+#define PCI_CHIP_AT24			0x6424
+#define PCI_CHIP_AT3D			0x643D
+
+/* 3dfx Interactive */
+#define PCI_CHIP_VOODOO_GRAPHICS	0x0001
+#define PCI_CHIP_VOODOO2		0x0002
+#define PCI_CHIP_BANSHEE		0x0003
+#define PCI_CHIP_VOODOO3		0x0005
+#define PCI_CHIP_VOODOO5		0x0009
+
+#define PCI_CARD_VOODOO3_2000		0x0036
+#define PCI_CARD_VOODOO3_3000		0x003A
+
+/* Rendition */
+#define PCI_CHIP_V1000			0x0001
+#define PCI_CHIP_V2x00			0x2000
+
+/* 3Dlabs */
+#define PCI_CHIP_300SX			0x0001
+#define PCI_CHIP_500TX			0x0002
+#define PCI_CHIP_DELTA			0x0003
+#define PCI_CHIP_PERMEDIA		0x0004
+#define PCI_CHIP_MX			0x0006
+#define PCI_CHIP_PERMEDIA2		0x0007
+#define PCI_CHIP_GAMMA			0x0008
+#define PCI_CHIP_PERMEDIA2V		0x0009
+#define PCI_CHIP_PERMEDIA3		0x000A
+#define PCI_CHIP_PERMEDIA4		0x000C
+#define PCI_CHIP_R4			0x000D
+#define PCI_CHIP_GAMMA2			0x000E
+#define PCI_CHIP_R4ALT			0x0011
+
+/* S3 */
+#define PCI_CHIP_PLATO			0x0551
+#define PCI_CHIP_VIRGE			0x5631
+#define PCI_CHIP_TRIO			0x8811
+#define PCI_CHIP_AURORA64VP		0x8812
+#define PCI_CHIP_TRIO64UVP		0x8814
+#define PCI_CHIP_VIRGE_VX		0x883D
+#define PCI_CHIP_868			0x8880
+#define PCI_CHIP_928			0x88B0
+#define PCI_CHIP_864_0			0x88C0
+#define PCI_CHIP_864_1			0x88C1
+#define PCI_CHIP_964_0			0x88D0
+#define PCI_CHIP_964_1			0x88D1
+#define PCI_CHIP_968			0x88F0
+#define PCI_CHIP_TRIO64V2_DXGX		0x8901
+#define PCI_CHIP_PLATO_PX		0x8902
+#define PCI_CHIP_Trio3D			0x8904
+#define PCI_CHIP_VIRGE_DXGX		0x8A01
+#define PCI_CHIP_VIRGE_GX2		0x8A10
+#define PCI_CHIP_Trio3D_2X		0x8A13
+#define PCI_CHIP_SAVAGE3D		0x8A20
+#define PCI_CHIP_SAVAGE3D_MV		0x8A21
+#define PCI_CHIP_SAVAGE4		0x8A22
+#define PCI_CHIP_PROSAVAGE_PM		0x8A25
+#define PCI_CHIP_PROSAVAGE_KM		0x8A26
+#define PCI_CHIP_VIRGE_MX		0x8C01
+#define PCI_CHIP_VIRGE_MXPLUS		0x8C02
+#define PCI_CHIP_VIRGE_MXP		0x8C03
+#define PCI_CHIP_SAVAGE_MX_MV		0x8C10
+#define PCI_CHIP_SAVAGE_MX		0x8C11
+#define PCI_CHIP_SAVAGE_IX_MV		0x8C12
+#define PCI_CHIP_SAVAGE_IX		0x8C13
+#define PCI_CHIP_SUPSAV_MX128		0x8C22
+#define PCI_CHIP_SUPSAV_MX64		0x8C24
+#define PCI_CHIP_SUPSAV_MX64C		0x8C26
+#define PCI_CHIP_SUPSAV_IX128SDR	0x8C2A
+#define PCI_CHIP_SUPSAV_IX128DDR	0x8C2B
+#define PCI_CHIP_SUPSAV_IX64SDR		0x8C2C
+#define PCI_CHIP_SUPSAV_IX64DDR		0x8C2D
+#define PCI_CHIP_SUPSAV_IXCSDR		0x8C2E
+#define PCI_CHIP_SUPSAV_IXCDDR		0x8C2F
+#define PCI_CHIP_S3TWISTER_P		0x8D01
+#define PCI_CHIP_S3TWISTER_K		0x8D02
+#define PCI_CHIP_PROSAVAGE_DDR		0x8D03
+#define PCI_CHIP_PROSAVAGE_DDRK		0x8D04
+#define PCI_CHIP_SAVAGE2000		0x9102
+
+/* ARK Logic */
+#define PCI_CHIP_1000PV			0xA091
+#define PCI_CHIP_2000PV			0xA099
+#define PCI_CHIP_2000MT			0xA0A1
+#define PCI_CHIP_2000MI			0xA0A9
+
+/* Tritech Microelectronics */
+#define PCI_CHIP_TR25202		0xFC02
+
+/* Neomagic */
+#define PCI_CHIP_NM2070			0x0001
+#define PCI_CHIP_NM2090			0x0002
+#define PCI_CHIP_NM2093			0x0003
+#define PCI_CHIP_NM2097			0x0083
+#define PCI_CHIP_NM2160			0x0004
+#define PCI_CHIP_NM2200			0x0005
+#define PCI_CHIP_NM2230			0x0025
+#define PCI_CHIP_NM2360			0x0006
+#define PCI_CHIP_NM2380			0x0016
+
+/* Intel */
+#define PCI_CHIP_I815_BRIDGE		0x1130
+#define PCI_CHIP_I815			0x1132
+#define PCI_CHIP_82801_P2P		0x244E
+#define PCI_CHIP_845_G_BRIDGE		0x2560
+#define PCI_CHIP_845_G			0x2562
+#define PCI_CHIP_I830_M_BRIDGE		0x3575
+#define PCI_CHIP_I830_M			0x3577
+#define PCI_CHIP_I810_BRIDGE		0x7120
+#define PCI_CHIP_I810			0x7121
+#define PCI_CHIP_I810_DC100_BRIDGE	0x7122
+#define PCI_CHIP_I810_DC100		0x7123
+#define PCI_CHIP_I810_E_BRIDGE		0x7124
+#define PCI_CHIP_I810_E			0x7125
+#define PCI_CHIP_I740_AGP		0x7800
+#define PCI_CHIP_460GX_PXB		0x84CB
+#define PCI_CHIP_460GX_SAC		0x84E0
+#define PCI_CHIP_460GX_GXB_2		0x84E2	/* PCI function 2 */
+#define PCI_CHIP_460GX_WXB		0x84E6
+#define PCI_CHIP_460GX_GXB_1		0x84EA	/* PCI function 1 */
+
+/* Silicon Motion Inc. */
+#define PCI_CHIP_SMI910			0x0910
+#define PCI_CHIP_SMI810			0x0810
+#define PCI_CHIP_SMI820			0x0820
+#define PCI_CHIP_SMI710			0x0710
+#define PCI_CHIP_SMI712			0x0712
+#define PCI_CHIP_SMI720			0x0720
+#define PCI_CHIP_SMI731			0x0730
+
+/* VMware */
+#define PCI_CHIP_VMWARE0405		0x0405
+#define PCI_CHIP_VMWARE0710		0x0710
+
+#endif /* _XF86_PCIINFO_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86str.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1141 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.97 2003/10/30 17:36:56 tsi Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall 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 holder(s) and author(s).
+ */
+
+/*
+ * This file contains definitions of the public XFree86 data structures/types.
+ * Any data structures that video drivers need to access should go here.
+ */
+
+#ifndef _XF86STR_H
+#define _XF86STR_H
+
+#include "misc.h"
+#include "input.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "xf86Module.h"
+#include "xf86Opt.h"
+#include "xf86Pci.h"
+
+/*
+ * memType is of the size of the addressable memory (machine size)
+ * usually unsigned long.
+ */
+typedef unsigned long memType;
+
+/* Video mode flags */
+
+typedef enum {
+    V_PHSYNC	= 0x0001,
+    V_NHSYNC	= 0x0002,
+    V_PVSYNC	= 0x0004,
+    V_NVSYNC	= 0x0008,
+    V_INTERLACE	= 0x0010,
+    V_DBLSCAN	= 0x0020,
+    V_CSYNC	= 0x0040,
+    V_PCSYNC	= 0x0080,
+    V_NCSYNC	= 0x0100,
+    V_HSKEW	= 0x0200,	/* hskew provided */
+    V_BCAST	= 0x0400,
+    V_PIXMUX	= 0x1000,
+    V_DBLCLK	= 0x2000,
+    V_CLKDIV2	= 0x4000
+} ModeFlags;
+
+typedef enum {
+    INTERLACE_HALVE_V	= 0x0001	/* Halve V values for interlacing */
+} CrtcAdjustFlags;
+
+/* Flags passed to ChipValidMode() */
+typedef enum {
+    MODECHECK_INITIAL = 0,
+    MODECHECK_FINAL   = 1
+} ModeCheckFlags;
+
+/* These are possible return values for xf86CheckMode() and ValidMode() */
+typedef enum {
+    MODE_OK	= 0,	/* Mode OK */
+    MODE_HSYNC,		/* hsync out of range */
+    MODE_VSYNC,		/* vsync out of range */
+    MODE_H_ILLEGAL,	/* mode has illegal horizontal timings */
+    MODE_V_ILLEGAL,	/* mode has illegal horizontal timings */
+    MODE_BAD_WIDTH,	/* requires an unsupported linepitch */
+    MODE_NOMODE,	/* no mode with a maching name */
+    MODE_NO_INTERLACE,	/* interlaced mode not supported */
+    MODE_NO_DBLESCAN,	/* doublescan mode not supported */
+    MODE_NO_VSCAN,	/* multiscan mode not supported */
+    MODE_MEM,		/* insufficient video memory */
+    MODE_VIRTUAL_X,	/* mode width too large for specified virtual size */
+    MODE_VIRTUAL_Y,	/* mode height too large for specified virtual size */
+    MODE_MEM_VIRT,	/* insufficient video memory given virtual size */
+    MODE_NOCLOCK,	/* no fixed clock available */
+    MODE_CLOCK_HIGH,	/* clock required is too high */
+    MODE_CLOCK_LOW,	/* clock required is too low */
+    MODE_CLOCK_RANGE,	/* clock/mode isn't in a ClockRange */
+    MODE_BAD_HVALUE,	/* horizontal timing was out of range */
+    MODE_BAD_VVALUE,	/* vertical timing was out of range */
+    MODE_BAD_VSCAN,	/* VScan value out of range */
+    MODE_HSYNC_NARROW,	/* horizontal sync too narrow */
+    MODE_HSYNC_WIDE,	/* horizontal sync too wide */
+    MODE_HBLANK_NARROW,	/* horizontal blanking too narrow */
+    MODE_HBLANK_WIDE,	/* horizontal blanking too wide */
+    MODE_VSYNC_NARROW,	/* vertical sync too narrow */
+    MODE_VSYNC_WIDE,	/* vertical sync too wide */
+    MODE_VBLANK_NARROW,	/* vertical blanking too narrow */
+    MODE_VBLANK_WIDE,	/* vertical blanking too wide */
+    MODE_PANEL,         /* exceeds panel dimensions */
+    MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
+    MODE_ONE_WIDTH,     /* only one width is supported */
+    MODE_ONE_HEIGHT,    /* only one height is supported */
+    MODE_ONE_SIZE,      /* only one resolution is supported */
+    MODE_BAD = -2,	/* unspecified reason */
+    MODE_ERROR	= -1	/* error condition */
+} ModeStatus;
+
+# define M_T_BUILTIN 0x01        /* built-in mode */
+# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
+# define M_T_CRTC_C  (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC  */
+# define M_T_CLOCK_CRTC_C  (M_T_CLOCK_C | M_T_CRTC_C)
+                               /* built-in mode - configure CRTC and clock */
+# define M_T_DEFAULT 0x10	/* (VESA) default modes */
+# define M_T_USERDEF 0x20	/* One of the modes from the config file */
+# define M_T_EDID    0x40       /* Mode from probed EDID data section */
+
+/* Video mode */
+typedef struct _DisplayModeRec {
+    struct _DisplayModeRec *	prev;
+    struct _DisplayModeRec *	next;
+    char *			name;		/* identifier for the mode */
+    ModeStatus			status;
+    int				type;
+
+    /* These are the values that the user sees/provides */
+    int				Clock;		/* pixel clock freq (kHz) */
+    int				HDisplay;	/* horizontal timing */
+    int				HSyncStart;
+    int				HSyncEnd;
+    int				HTotal;
+    int				HSkew;
+    int				VDisplay;	/* vertical timing */
+    int				VSyncStart;
+    int				VSyncEnd;
+    int				VTotal;
+    int				VScan;
+    int				Flags;
+
+  /* These are the values the hardware uses */
+    int				ClockIndex;
+    int				SynthClock;	/* Actual clock freq to
+					  	 * be programmed  (kHz) */
+    int				CrtcHDisplay;
+    int				CrtcHBlankStart;
+    int				CrtcHSyncStart;
+    int				CrtcHSyncEnd;
+    int				CrtcHBlankEnd;
+    int				CrtcHTotal;
+    int				CrtcHSkew;
+    int				CrtcVDisplay;
+    int				CrtcVBlankStart;
+    int				CrtcVSyncStart;
+    int				CrtcVSyncEnd;
+    int				CrtcVBlankEnd;
+    int				CrtcVTotal;
+    Bool			CrtcHAdjusted;
+    Bool			CrtcVAdjusted;
+    int				PrivSize;
+    INT32 *			Private;
+    int				PrivFlags;
+
+    float			HSync, VRefresh;
+} DisplayModeRec, *DisplayModePtr;
+
+/* The monitor description */
+
+#define MAX_HSYNC 8
+#define MAX_VREFRESH 8
+
+typedef struct { float hi, lo; } range;
+
+typedef struct { CARD32 red, green, blue; } rgb;
+
+typedef struct { float red, green, blue; } Gamma;
+
+/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
+#define GAMMA_MAX	10.0
+#define GAMMA_MIN	(1.0 / GAMMA_MAX)
+#define GAMMA_ZERO	(GAMMA_MIN / 100.0)
+
+typedef struct {
+    char *		id;
+    char *		vendor;
+    char *		model;
+    int			nHsync;
+    range		hsync[MAX_HSYNC];
+    int			nVrefresh;
+    range		vrefresh[MAX_VREFRESH];
+    DisplayModePtr	Modes;		/* Start of the monitor's mode list */
+    DisplayModePtr	Last;		/* End of the monitor's mode list */
+    Gamma		gamma;		/* Gamma of the monitor */
+    int			widthmm;
+    int			heightmm;
+    pointer		options;
+    pointer		DDC;
+} MonRec, *MonPtr;
+
+/* the list of clock ranges */
+typedef struct x_ClockRange {
+    struct x_ClockRange *next;
+    int			minClock;	/* (kHz) */
+    int			maxClock;	/* (kHz) */
+    int			clockIndex;	/* -1 for programmable clocks */
+    Bool		interlaceAllowed;
+    Bool		doubleScanAllowed;
+    int			ClockMulFactor;
+    int			ClockDivFactor;
+    int			PrivFlags;
+} ClockRange, *ClockRangePtr;
+
+/* Need to store the strategy with clockRange for VidMode extension */
+typedef struct x_ClockRanges {
+    struct x_ClockRanges *next;
+    int			minClock;
+    int			maxClock;
+    int			clockIndex;	/* -1 for programmable clocks */
+    Bool		interlaceAllowed;
+    Bool		doubleScanAllowed;
+    int			ClockMulFactor;
+    int			ClockDivFactor;
+    int			PrivFlags;
+    int			strategy;
+} ClockRanges, *ClockRangesPtr;
+
+/*
+ * The driverFunc. xorgDriverFuncOp specifies the action driver should
+ * perform. If requested option is not supported function should return
+ * FALSE. pointer can be used to pass arguments to the function or
+ * to return data to the caller.
+ */
+typedef struct _ScrnInfoRec *ScrnInfoPtr;
+
+/* do not change order */
+typedef enum {
+    RR_GET_INFO,
+    RR_SET_CONFIG,
+    RR_GET_MODE_MM,
+    GET_REQUIRED_HW_INTERFACES = 10
+} xorgDriverFuncOp;
+
+typedef Bool xorgDriverFuncProc		  (ScrnInfoPtr, xorgDriverFuncOp,
+					   pointer);
+
+/* RR_GET_INFO, RR_SET_CONFIG */
+typedef struct {
+    int rotation;
+    int rate;
+    int width;
+    int height;
+} xorgRRConfig;
+
+typedef union {
+    short RRRotations;
+    xorgRRConfig RRConfig;
+} xorgRRRotation, *xorgRRRotationPtr;
+
+/* RR_GET_MODE_MM */
+typedef struct {
+    DisplayModePtr mode;
+    int virtX;
+    int virtY;
+    int mmWidth;
+    int mmHeight;
+} xorgRRModeMM, *xorgRRModeMMPtr;
+
+/* GET_REQUIRED_HW_INTERFACES */
+#define HW_IO 1
+#define HW_MMIO 2
+#define NEED_IO_ENABLED(x) (x & HW_IO)
+
+typedef CARD32 xorgHWFlags;
+
+/*
+ * The driver list struct.  This contains the information required for each
+ * driver before a ScrnInfoRec has been allocated.
+ */
+struct _DriverRec;
+
+typedef struct {
+    int			driverVersion;
+    char *		driverName;
+    void		(*Identify)(int flags);
+    Bool		(*Probe)(struct _DriverRec *drv, int flags);
+    const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
+    pointer		module;
+    int			refCount;
+} DriverRec1;
+
+typedef struct _DriverRec {
+    int			driverVersion;
+    char *		driverName;
+    void		(*Identify)(int flags);
+    Bool		(*Probe)(struct _DriverRec *drv, int flags);
+    const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
+    pointer		module;
+    int			refCount;
+    xorgDriverFuncProc  *driverFunc;
+} DriverRec, *DriverPtr;
+
+/*
+ *  AddDriver flags
+ */
+#define HaveDriverFuncs 1
+
+
+#ifdef XFree86LOADER
+/*
+ * The optional module list struct. This allows modules exporting helping
+ * functions to configuration tools, the Xserver, or any other
+ * application/module interested in such information.
+ */
+typedef struct _ModuleInfoRec {
+    int			moduleVersion;
+    char *		moduleName;
+    pointer		module;
+    int			refCount;
+    const OptionInfoRec * (*AvailableOptions)(void *unused);
+    pointer		unused[8];	/* leave some space for more fields */
+} ModuleInfoRec, *ModuleInfoPtr;
+#endif
+
+/*
+ * These are the private bus types.  New types can be added here.  Types
+ * required for the public interface should be added to xf86str.h, with
+ * function prototypes added to xf86.h.
+ */
+
+/* Tolerate prior #include <linux/input.h> */
+#if defined(linux) && defined(_INPUT_H)
+#undef BUS_NONE
+#undef BUS_ISA
+#undef BUS_PCI
+#undef BUS_SBUS
+#undef BUS_last
+#endif
+
+typedef enum {
+    BUS_NONE,
+    BUS_ISA,
+    BUS_PCI,
+    BUS_SBUS,
+    BUS_last    /* Keep last */
+} BusType;
+
+typedef struct {
+    int		bus;
+    int		device;
+    int		func;
+} PciBusId;
+
+typedef struct {
+    unsigned int dummy;
+} IsaBusId;
+
+typedef struct {
+    int		fbNum;
+} SbusBusId;
+
+typedef struct _bus {
+    BusType type;
+    union {
+	IsaBusId isa;
+	PciBusId pci;
+	SbusBusId sbus;
+    } id;
+} BusRec, *BusPtr;
+
+#define MAXCLOCKS   128
+typedef enum {
+    DAC_BPP8 = 0,
+    DAC_BPP16,
+    DAC_BPP24,
+    DAC_BPP32,
+    MAXDACSPEEDS
+} DacSpeedIndex;
+
+typedef struct {
+   char *			identifier;
+   char *			vendor;
+   char *			board;
+   char *			chipset;
+   char *			ramdac;
+   char *			driver;
+   struct _confscreenrec *	myScreenSection;
+   Bool				claimed;
+   int				dacSpeeds[MAXDACSPEEDS];
+   int				numclocks;
+   int				clock[MAXCLOCKS];
+   char *			clockchip;
+   char *			busID;
+   Bool				active;
+   Bool				inUse;
+   int				videoRam;
+   int				textClockFreq;
+   unsigned long		BiosBase;	/* Base address of video BIOS */
+   unsigned long		MemBase;	/* Frame buffer base address */
+   unsigned long		IOBase;
+   int				chipID;
+   int				chipRev;
+   pointer			options;
+   int                          irq;
+   int                          screen;         /* For multi-CRTC cards */
+} GDevRec, *GDevPtr;
+
+typedef int (*FindIsaDevProc)(GDevPtr dev);
+
+typedef struct {
+   char *			identifier;
+   char *			driver;
+   pointer		 	commonOptions;
+   pointer			extraOptions;
+} IDevRec, *IDevPtr;
+
+typedef struct {
+    int			vendor;
+    int			chipType;
+    int			chipRev;
+    int			subsysVendor;
+    int			subsysCard;
+    int			bus;
+    int			device;
+    int			func;
+    int			class;
+    int			subclass;
+    int			interface;
+    memType  	        memBase[6];
+    memType  	        ioBase[6];
+    int			size[6];
+    unsigned char	type[6];
+    memType   	        biosBase;
+    int			biosSize;
+    pointer		thisCard;
+    Bool                validSize;
+    Bool                validate;
+    CARD32              listed_class;
+} pciVideoRec, *pciVideoPtr;
+
+typedef struct {
+    int			frameX0;
+    int			frameY0;
+    int			virtualX;
+    int			virtualY;
+    int			depth;
+    int			fbbpp;
+    rgb			weight;
+    rgb			blackColour;
+    rgb			whiteColour;
+    int			defaultVisual;
+    char **		modes;
+    pointer		options;
+} DispRec, *DispPtr;
+
+typedef struct _confxvportrec {
+    char *		identifier;
+    pointer		options;
+} confXvPortRec, *confXvPortPtr;
+
+typedef struct _confxvadaptrec {
+    char *		identifier;
+    int			numports;
+    confXvPortPtr	ports;
+    pointer		options;
+} confXvAdaptorRec, *confXvAdaptorPtr;
+
+typedef struct _confscreenrec {
+    char *		id;
+    int			screennum;
+    int			defaultdepth;
+    int			defaultbpp;
+    int			defaultfbbpp;
+    MonPtr		monitor;
+    GDevPtr		device;
+    int			numdisplays;
+    DispPtr		displays;
+    int			numxvadaptors;
+    confXvAdaptorPtr	xvadaptors;
+    pointer		options;
+} confScreenRec, *confScreenPtr;
+
+typedef enum {
+    PosObsolete = -1,
+    PosAbsolute = 0,
+    PosRightOf,
+    PosLeftOf,
+    PosAbove,
+    PosBelow,
+    PosRelative
+} PositionType;
+
+typedef struct _screenlayoutrec {
+    confScreenPtr	screen;
+    char *		topname;
+    confScreenPtr	top;
+    char *		bottomname;
+    confScreenPtr	bottom;
+    char *		leftname;
+    confScreenPtr	left;
+    char *		rightname;
+    confScreenPtr	right;
+    PositionType	where;
+    int			x;
+    int			y;
+    char *		refname;
+    confScreenPtr	refscreen;
+} screenLayoutRec, *screenLayoutPtr;
+
+typedef struct _serverlayoutrec {
+    char *		id;
+    screenLayoutPtr	screens;
+    GDevPtr		inactives;
+    IDevPtr		inputs;
+    pointer		options;
+} serverLayoutRec, *serverLayoutPtr;
+
+typedef struct _confdribufferrec {
+    int                 count;
+    int                 size;
+    enum {
+	XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
+    }                   flags;
+} confDRIBufferRec, *confDRIBufferPtr;
+
+typedef struct _confdrirec {
+    int                 group;
+    int                 mode;
+    int                 bufs_count;
+    confDRIBufferRec    *bufs;
+} confDRIRec, *confDRIPtr;
+
+/* These values should be adjusted when new fields are added to ScrnInfoRec */
+#define NUM_RESERVED_INTS		16
+#define NUM_RESERVED_POINTERS		15
+#define NUM_RESERVED_FUNCS		11
+
+typedef pointer (*funcPointer)(void);
+
+/* flags for depth 24 pixmap options */
+typedef enum {
+    Pix24DontCare = 0,
+    Pix24Use24,
+    Pix24Use32
+} Pix24Flags;
+
+/* Power management events: so far we only support APM */
+
+typedef enum {
+    XF86_APM_UNKNOWN = -1,
+    XF86_APM_SYS_STANDBY,
+    XF86_APM_SYS_SUSPEND,
+    XF86_APM_CRITICAL_SUSPEND,
+    XF86_APM_USER_STANDBY,
+    XF86_APM_USER_SUSPEND,
+    XF86_APM_STANDBY_RESUME,
+    XF86_APM_NORMAL_RESUME,
+    XF86_APM_CRITICAL_RESUME,
+    XF86_APM_LOW_BATTERY,
+    XF86_APM_POWER_STATUS_CHANGE,
+    XF86_APM_UPDATE_TIME,
+    XF86_APM_CAPABILITY_CHANGED,
+    XF86_APM_STANDBY_FAILED,
+    XF86_APM_SUSPEND_FAILED
+} pmEvent;
+
+typedef enum {
+    PM_WAIT,
+    PM_CONTINUE,
+    PM_FAILED,
+    PM_NONE
+} pmWait;
+
+/*
+ * The IO access enabler struct. This contains the address for
+ * the IOEnable/IODisable funcs for their specific bus along
+ * with a pointer to data needed by them
+ */
+typedef struct _AccessRec {
+    void (*AccessDisable)(void *arg);
+    void (*AccessEnable)(void *arg);
+    void *arg;
+} xf86AccessRec, *xf86AccessPtr;
+
+typedef struct {
+    xf86AccessPtr mem;
+    xf86AccessPtr io;
+    xf86AccessPtr io_mem;
+} xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
+
+/*  bus-access-related types */
+typedef enum {
+    NONE,
+    IO,
+    MEM_IO,
+    MEM
+} resType;
+
+typedef struct _EntityAccessRec {
+    xf86AccessPtr fallback;
+    xf86AccessPtr pAccess;
+    resType rt;
+    pointer  busAcc;
+    struct _EntityAccessRec *next;
+} EntityAccessRec, *EntityAccessPtr;
+
+typedef struct _CurrAccRec {
+    EntityAccessPtr pMemAccess;
+    EntityAccessPtr pIoAccess;
+} xf86CurrentAccessRec, *xf86CurrentAccessPtr;
+
+/* new RAC */
+
+/* Resource Type values */
+#define ResNone		((unsigned long)(-1))
+
+#define ResMem		0x0001
+#define ResIo		0x0002
+#define ResIrq		0x0003
+#define ResDma		0x0004
+#define ResPciCfg	0x000e	/* PCI Configuration space */
+#define ResPhysMask	0x000F
+
+#define ResExclusive	0x0010
+#define ResShared	0x0020
+#define ResAny		0x0040
+#define ResAccMask	0x0070
+#define ResUnused	0x0080
+
+#define ResUnusedOpr	0x0100
+#define ResDisableOpr	0x0200
+#define ResOprMask	0x0300
+
+#define ResBlock	0x0400
+#define ResSparse	0x0800
+#define ResExtMask	0x0C00
+
+#define ResEstimated	0x001000
+#define ResInit 	0x002000
+#define ResBios		0x004000
+#define ResMiscMask	0x00F000
+
+#define ResBus		0x010000
+#define ResOverlap	0x020000
+
+#if defined(__alpha__) && defined(linux)
+# define ResDomain	0x1ff000000ul
+#else
+# define ResDomain	0xff000000ul
+#endif
+#define ResTypeMask	(ResPhysMask | ResDomain)	/* For conflict check */
+
+#define ResEnd		ResNone
+
+#define ResExcMemBlock		(ResMem | ResExclusive | ResBlock)
+#define ResExcIoBlock		(ResIo | ResExclusive | ResBlock)
+#define ResShrMemBlock		(ResMem | ResShared | ResBlock)
+#define ResShrIoBlock		(ResIo | ResShared | ResBlock)
+#define ResExcUusdMemBlock	(ResMem | ResExclusive | ResUnused | ResBlock)
+#define ResExcUusdIoBlock	(ResIo | ResExclusive | ResUnused | ResBlock)
+#define ResShrUusdMemBlock	(ResMem | ResShared | ResUnused | ResBlock)
+#define ResShrUusdIoBlock	(ResIo | ResShared | ResUnused | ResBlock)
+#define ResExcUusdMemSparse	(ResMem | ResExclusive | ResUnused | ResSparse)
+#define ResExcUusdIoSparse	(ResIo | ResExclusive | ResUnused | ResSparse)
+#define ResShrUusdMemSparse	(ResMem | ResShared | ResUnused | ResSparse)
+#define ResShrUusdIoSparse	(ResIo | ResShared | ResUnused | ResSparse)
+
+#define ResExcMemSparse		(ResMem | ResExclusive | ResSparse)
+#define ResExcIoSparse		(ResIo | ResExclusive | ResSparse)
+#define ResShrMemSparse		(ResMem | ResShared | ResSparse)
+#define ResShrIoSparse		(ResIo | ResShared | ResSparse)
+#define ResUusdMemSparse	(ResMem | ResUnused | ResSparse)
+#define ResUusdIoSparse		(ResIo | ResUnused | ResSparse)
+
+#define ResIsMem(r)		(((r)->type & ResPhysMask) == ResMem)
+#define ResIsIo(r)		(((r)->type & ResPhysMask) == ResIo)
+#define ResIsExclusive(r)	(((r)->type & ResAccMask) == ResExclusive)
+#define ResIsShared(r)		(((r)->type & ResAccMask) == ResShared)
+#define ResIsUnused(r)		(((r)->type & ResAccMask) == ResUnused)
+#define ResIsBlock(r)		(((r)->type & ResExtMask) == ResBlock)
+#define ResIsSparse(r)		(((r)->type & ResExtMask) == ResSparse)
+#define ResIsEstimated(r)	(((r)->type & ResMiscMask) == ResEstimated)
+#define ResCanOverlap(r)	(ResIsEstimated(r) || ((r)->type & ResOverlap))
+
+typedef struct {
+    unsigned long type;     /* shared, exclusive, unused etc. */
+    memType a;
+    memType b;
+} resRange, *resList;
+
+#define RANGE_TYPE(type, domain) \
+               (((unsigned long)(domain) << 24) | ((type) & ~ResBus))
+#define RANGE(r,u,v,t) {\
+                       (r).a = (u);\
+                       (r).b = (v);\
+                       (r).type = (t);\
+                       }
+
+#define rBase a
+#define rMask b
+#define rBegin a
+#define rEnd b
+
+/* resource record */
+typedef struct _resRec *resPtr;
+typedef struct _resRec {
+    resRange    val;
+    int		entityIndex;	/* who owns the resource */
+    resPtr	next;
+} resRec;
+
+#define sparse_base	val.rBase
+#define sparse_mask	val.rMask
+#define block_begin	val.rBegin
+#define block_end	val.rEnd
+#define res_type	val.type
+
+typedef struct {
+    int numChipset;
+    resRange *resList;
+} IsaChipsets;
+
+typedef struct {
+    int numChipset;
+    int PCIid;
+    resRange *resList;
+} PciChipsets;
+
+/* Entity properties */
+typedef void (*EntityProc)(int entityIndex,pointer private);
+
+typedef struct _entityInfo {
+    int index;
+    BusRec location;
+    int chipset;
+    Bool active;
+    resPtr resources;
+    GDevPtr device;
+    DriverPtr driver;
+} EntityInfoRec, *EntityInfoPtr;
+
+/* server states */
+
+typedef enum {
+    SETUP,
+    OPERATING
+} xf86State;
+
+typedef enum {
+    NOTIFY_SETUP_TRANSITION,
+    NOTIFY_SETUP,
+    NOTIFY_OPERATING,
+    NOTIFY_OPERATING_TRANSITION,
+    NOTIFY_ENABLE,
+    NOTIFY_ENTER,
+    NOTIFY_LEAVE
+} xf86NotifyState;
+
+typedef void (*xf86StateChangeNotificationCallbackFunc)(xf86NotifyState state,pointer);
+
+/* DGA */
+
+typedef struct {
+   int num;		/* A unique identifier for the mode (num > 0) */
+   DisplayModePtr mode;
+   int flags;		/* DGA_CONCURRENT_ACCESS, etc... */
+   int imageWidth;	/* linear accessible portion (pixels) */
+   int imageHeight;
+   int pixmapWidth;	/* Xlib accessible portion (pixels) */
+   int pixmapHeight;	/* both fields ignored if no concurrent access */
+   int bytesPerScanline;
+   int byteOrder;	/* MSBFirst, LSBFirst */
+   int depth;
+   int bitsPerPixel;
+   unsigned long red_mask;
+   unsigned long green_mask;
+   unsigned long blue_mask;
+   short visualClass;
+   int viewportWidth;
+   int viewportHeight;
+   int xViewportStep;	/* viewport position granularity */
+   int yViewportStep;
+   int maxViewportX;	/* max viewport origin */
+   int maxViewportY;
+   int viewportFlags;	/* types of page flipping possible */
+   int offset;		/* offset into physical memory */
+   unsigned char *address;	/* server's mapped framebuffer */
+   int reserved1;
+   int reserved2;
+} DGAModeRec, *DGAModePtr;
+
+typedef struct {
+   DGAModePtr mode;
+   PixmapPtr pPix;
+} DGADeviceRec, *DGADevicePtr;
+
+/*
+ * Flags for driver Probe() functions.
+ */
+#define PROBE_DEFAULT	  0x00
+#define PROBE_DETECT	  0x01
+#define PROBE_TRYHARD	  0x02
+
+/*
+ * Driver entry point types
+ */
+
+typedef Bool xf86ProbeProc                (DriverPtr, int);
+typedef Bool xf86PreInitProc              (ScrnInfoPtr, int);
+typedef Bool xf86ScreenInitProc           (int, ScreenPtr, int, char**);
+typedef Bool xf86SwitchModeProc           (int, DisplayModePtr, int);
+typedef void xf86AdjustFrameProc          (int, int, int, int);
+typedef Bool xf86EnterVTProc              (int, int);
+typedef void xf86LeaveVTProc              (int, int);
+typedef void xf86FreeScreenProc           (int, int);
+typedef ModeStatus xf86ValidModeProc      (int, DisplayModePtr, Bool, int);
+typedef void xf86EnableDisableFBAccessProc(int, Bool);
+typedef int  xf86SetDGAModeProc           (int, int, DGADevicePtr);
+typedef int  xf86ChangeGammaProc          (int, Gamma);
+typedef void xf86PointerMovedProc         (int, int, int);
+typedef Bool xf86PMEventProc              (int, pmEvent, Bool);
+typedef int  xf86HandleMessageProc     (int, const char*, const char*, char**);
+typedef void xf86DPMSSetProc		  (ScrnInfoPtr, int, int);
+typedef void xf86LoadPaletteProc   (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
+typedef void xf86SetOverscanProc          (ScrnInfoPtr, int);
+
+
+/*
+ * ScrnInfoRec
+ *
+ * There is one of these for each screen, and it holds all the screen-specific
+ * information.
+ *
+ * Note: the size and layout must be kept the same across versions.  New
+ * fields are to be added in place of the "reserved*" fields.  No fields
+ * are to be dependent on compile-time defines.
+ */
+
+
+typedef struct _ScrnInfoRec {
+    int			driverVersion;
+    char *		driverName;		/* canonical name used in */
+						/* the config file */
+    ScreenPtr		pScreen;		/* Pointer to the ScreenRec */
+    int			scrnIndex;		/* Number of this screen */
+    Bool		configured;		/* Is this screen valid */
+    int			origIndex;		/* initial number assigned to
+						 * this screen before
+						 * finalising the number of
+						 * available screens */
+
+    /* Display-wide screenInfo values needed by this screen */
+    int			imageByteOrder;
+    int			bitmapScanlineUnit;
+    int			bitmapScanlinePad;
+    int			bitmapBitOrder;
+    int			numFormats;
+    PixmapFormatRec	formats[MAXFORMATS];
+    PixmapFormatRec	fbFormat;
+
+    int			bitsPerPixel;		/* fb bpp */
+    Pix24Flags		pixmap24;		/* pixmap pref for depth 24 */
+    int			depth;			/* depth of default visual */
+    MessageType		depthFrom;		/* set from config? */
+    MessageType		bitsPerPixelFrom;	/* set from config? */
+    rgb			weight;			/* r/g/b weights */
+    rgb			mask;			/* rgb masks */
+    rgb			offset;			/* rgb offsets */
+    int			rgbBits;		/* Number of bits in r/g/b */
+    Gamma		gamma;			/* Gamma of the monitor */
+    int			defaultVisual;		/* default visual class */
+    int			maxHValue;		/* max horizontal timing */
+    int			maxVValue;		/* max vertical timing value */
+    int			virtualX;		/* Virtual width */
+    int			virtualY; 		/* Virtual height */
+    int			xInc;			/* Horizontal timing increment */
+    MessageType		virtualFrom;		/* set from config? */
+    int			displayWidth;		/* memory pitch */
+    int			frameX0;		/* viewport position */
+    int			frameY0;
+    int			frameX1;
+    int			frameY1;
+    int			zoomLocked;		/* Disallow mode changes */
+    DisplayModePtr	modePool;		/* list of compatible modes */
+    DisplayModePtr	modes;			/* list of actual modes */
+    DisplayModePtr	currentMode;		/* current mode
+						 * This was previously
+						 * overloaded with the modes
+						 * field, which is a pointer
+						 * into a circular list */
+    confScreenPtr	confScreen;		/* Screen config info */
+    MonPtr		monitor;		/* Monitor information */
+    DispPtr		display;		/* Display information */
+    int *		entityList;		/* List of device entities */
+    int			numEntities;
+    int			widthmm;		/* physical display dimensions
+						 * in mm */
+    int			heightmm;
+    int			xDpi;			/* width DPI */
+    int			yDpi;			/* height DPI */
+    char *		name;			/* Name to prefix messages */
+    pointer		driverPrivate;		/* Driver private area */
+    DevUnion *		privates;		/* Other privates can hook in
+						 * here */
+    DriverPtr		drv;			/* xf86DriverList[] entry */
+    pointer		module;			/* Pointer to module head */
+    int			colorKey;
+    int			overlayFlags;
+
+    /* Some of these may be moved out of here into the driver private area */
+
+    char *		chipset;		/* chipset name */
+    char *		ramdac;			/* ramdac name */
+    char *		clockchip;		/* clock name */
+    Bool		progClock;		/* clock is programmable */
+    int			numClocks;		/* number of clocks */
+    int			clock[MAXCLOCKS];	/* list of clock frequencies */
+    int			videoRam;		/* amount of video ram (kb) */
+    unsigned long	biosBase;		/* Base address of video BIOS */
+    unsigned long	memPhysBase;		/* Physical address of FB */
+    unsigned long 	fbOffset;		/* Offset of FB in the above */
+    IOADDRESS    	domainIOBase;		/* Domain I/O base address */
+    int			memClk;			/* memory clock */
+    int			textClockFreq;		/* clock of text mode */
+    Bool		flipPixels;		/* swap default black/white */
+    pointer		options;
+
+    int			chipID;
+    int			chipRev;
+    int			racMemFlags;
+    int			racIoFlags;
+    pointer		access;
+    xf86CurrentAccessPtr CurrentAccess;
+    resType		resourceType;
+    pointer		busAccess;
+
+    /* Allow screens to be enabled/disabled individually */
+    Bool		vtSema;
+    DevUnion		pixmapPrivate;		/* saved devPrivate from pixmap */
+
+    /* hw cursor moves at SIGIO time */
+    Bool		silkenMouse;
+
+    /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
+    ClockRangesPtr	clockRanges;
+    int			adjustFlags;
+
+    /*
+     * These can be used when the minor ABI version is incremented.
+     * The NUM_* parameters must be reduced appropriately to keep the
+     * structure size and alignment unchanged.
+     */
+    int			reservedInt[NUM_RESERVED_INTS];
+
+    int *		entityInstanceList;
+    pointer		reservedPtr[NUM_RESERVED_POINTERS];
+
+    /*
+     * Driver entry points.
+     *
+     */
+
+    xf86ProbeProc			*Probe;
+    xf86PreInitProc			*PreInit;
+    xf86ScreenInitProc			*ScreenInit;
+    xf86SwitchModeProc			*SwitchMode;
+    xf86AdjustFrameProc			*AdjustFrame;
+    xf86EnterVTProc			*EnterVT;
+    xf86LeaveVTProc			*LeaveVT;
+    xf86FreeScreenProc			*FreeScreen;
+    xf86ValidModeProc			*ValidMode;
+    xf86EnableDisableFBAccessProc	*EnableDisableFBAccess;
+    xf86SetDGAModeProc			*SetDGAMode;
+    xf86ChangeGammaProc			*ChangeGamma;
+    xf86PointerMovedProc		*PointerMoved;
+    xf86PMEventProc			*PMEvent;
+    xf86HandleMessageProc		*HandleMessage;
+    xf86DPMSSetProc			*DPMSSet;
+    xf86LoadPaletteProc			*LoadPalette;
+    xf86SetOverscanProc			*SetOverscan;
+    xorgDriverFuncProc			*DriverFunc;
+
+    /*
+     * This can be used when the minor ABI version is incremented.
+     * The NUM_* parameter must be reduced appropriately to keep the
+     * structure size and alignment unchanged.
+     */
+    funcPointer		reservedFuncs[NUM_RESERVED_FUNCS];
+
+} ScrnInfoRec;
+
+
+typedef struct {
+   Bool (*OpenFramebuffer)(
+	ScrnInfoPtr pScrn,
+	char **name,
+	unsigned char **mem,
+	int *size,
+	int *offset,
+        int *extra
+   );
+   void	(*CloseFramebuffer)(ScrnInfoPtr pScrn);
+   Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
+   void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
+   int  (*GetViewport)(ScrnInfoPtr pScrn);
+   void (*Sync)(ScrnInfoPtr);
+   void (*FillRect)(
+	ScrnInfoPtr pScrn,
+	int x, int y, int w, int h,
+	unsigned long color
+   );
+   void (*BlitRect)(
+	ScrnInfoPtr pScrn,
+	int srcx, int srcy,
+	int w, int h,
+	int dstx, int dsty
+   );
+   void (*BlitTransRect)(
+	ScrnInfoPtr pScrn,
+	int srcx, int srcy,
+	int w, int h,
+	int dstx, int dsty,
+	unsigned long color
+   );
+} DGAFunctionRec, *DGAFunctionPtr;
+
+typedef struct {
+    int			token;		/* id of the token */
+    const char *	name;		/* token name */
+} SymTabRec, *SymTabPtr;
+
+/* flags for xf86LookupMode */
+typedef enum {
+    LOOKUP_DEFAULT		= 0,	/* Use default mode lookup method */
+    LOOKUP_BEST_REFRESH,		/* Pick modes with best refresh */
+    LOOKUP_CLOSEST_CLOCK,		/* Pick modes with the closest clock */
+    LOOKUP_LIST_ORDER,			/* Pick first useful mode in list */
+    LOOKUP_CLKDIV2		= 0x0100, /* Allow half clocks */
+    LOOKUP_OPTIONAL_TOLERANCES	= 0x0200  /* Allow missing hsync/vrefresh */
+} LookupModeFlags;
+
+#define NoDepth24Support	0x00
+#define Support24bppFb		0x01	/* 24bpp framebuffer supported */
+#define Support32bppFb		0x02	/* 32bpp framebuffer supported */
+#define SupportConvert24to32	0x04	/* Can convert 24bpp pixmap to 32bpp */
+#define SupportConvert32to24	0x08	/* Can convert 32bpp pixmap to 24bpp */
+#define PreferConvert24to32	0x10	/* prefer 24bpp pixmap to 32bpp conv */
+#define PreferConvert32to24	0x20	/* prefer 32bpp pixmap to 24bpp conv */
+
+
+/* For DPMS */
+typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
+
+/* Input handler proc */
+typedef void (*InputHandlerProc)(int fd, pointer data);
+
+/* These are used by xf86GetClocks */
+#define CLK_REG_SAVE		-1
+#define CLK_REG_RESTORE		-2
+
+/* xf86Debug.c */
+#ifdef BUILDDEBUG
+typedef struct {
+    long sec;
+    long usec;
+} xf86TsRec, *xf86TsPtr;
+#endif
+
+/*
+ * misc constants
+ */
+#define INTERLACE_REFRESH_WEIGHT	1.5
+#define SYNC_TOLERANCE		0.01	/* 1 percent */
+#define CLOCK_TOLERANCE		2000	/* Clock matching tolerance (2MHz) */
+
+
+#define OVERLAY_8_32_DUALFB	0x00000001
+#define OVERLAY_8_24_DUALFB	0x00000002
+#define OVERLAY_8_16_DUALFB	0x00000004
+#define OVERLAY_8_32_PLANAR	0x00000008
+
+#if 0
+#define LD_RESOLV_IFDONE		0	/* only check if no more
+						   delays pending */
+#define LD_RESOLV_NOW			1	/* finish one delay step */
+#define LD_RESOLV_FORCE			2	/* force checking... */
+#endif
+
+/* Values of xf86Info.mouseFlags */
+#define MF_CLEAR_DTR       1
+#define MF_CLEAR_RTS       2
+
+/* Action Events */
+typedef enum {
+    ACTION_TERMINATE		= 0,	/* Terminate Server */
+    ACTION_NEXT_MODE		= 10,	/* Switch to next video mode */
+    ACTION_PREV_MODE,
+    ACTION_DISABLEGRAB		= 20,	/* Cancel server/pointer/kbd grabs */
+    ACTION_CLOSECLIENT,			/* Kill client holding grab */
+    ACTION_SWITCHSCREEN		= 100,	/* VT switch */
+    ACTION_SWITCHSCREEN_NEXT,
+    ACTION_SWITCHSCREEN_PREV,
+    ACTION_MESSAGE		= 9999  /* Generic message passing */
+} ActionEvent;
+
+/* xf86Versions.c */
+/*
+ * Never change existing values, and always assign values explicitly.
+ * NUM_BUILTIN_IFS must always be the last entry.
+ */
+typedef enum {
+    BUILTIN_IF_OSMOUSE = 0,
+    BUILTIN_IF_OSKBD = 1,
+    NUM_BUILTIN_IFS
+} BuiltinInterface;
+
+/*
+ * These are intentionally the same as the module version macros.
+ * It is possible to register a module as providing a specific interface,
+ * in which case the module's version is used.  This feature isn't
+ * really ready for use yet though.
+ */
+
+#define BUILTIN_INTERFACE_VERSION_NUMERIC(maj, min, patch) \
+	((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
+#define GET_BUILTIN_INTERFACE_MAJOR_VERSION(vers)	(((vers) >> 24) & 0xFF)
+#define GET_BUILTIN_INTERFACE_MINOR_VERSION(vers)	(((vers) >> 16) & 0xFF)
+#define GET_BUILTIN_INTERFACE_PATCH_VERSION(vers)	((vers) & 0xFFFF)
+
+#endif /* _XF86STR_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/ddc/edid.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,463 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.h,v 1.6 2000/04/17 16:29:55 eich Exp $ */
+
+/* edid.h: defines to parse an EDID block 
+ *
+ * This file contains all information to interpret a standard EDIC block 
+ * transmitted by a display device via DDC (Display Data Channel). So far 
+ * there is no information to deal with optional EDID blocks.  
+ * DDC is a Trademark of VESA (Video Electronics Standard Association).
+ *
+ * Copyright 1998 by Egbert Eich <[email protected]>
+ */
+
+#ifndef _EDID_H_
+#define _EDID_H_ 
+
+#include "vdif.h"
+
+/* read complete EDID record */
+#define EDID1_LEN 128
+#define BITS_PER_BYTE 9
+#define NUM BITS_PER_BYTE*EDID1_LEN
+#define HEADER 6
+
+#define STD_TIMINGS 8
+#define DET_TIMINGS 4
+
+#ifdef _PARSE_EDID_
+
+/* header: 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00  */
+#define HEADER_SECTION 0
+#define HEADER_LENGTH 8
+
+/* vendor section */
+#define VENDOR_SECTION (HEADER_SECTION + HEADER_LENGTH)
+#define V_MANUFACTURER 0
+#define V_PROD_ID (V_MANUFACTURER + 2)
+#define V_SERIAL (V_PROD_ID + 2)
+#define V_WEEK (V_SERIAL + 4)
+#define V_YEAR (V_WEEK + 1)
+#define VENDOR_LENGTH (V_YEAR + 1)
+
+/* EDID version */
+#define VERSION_SECTION (VENDOR_SECTION + VENDOR_LENGTH)
+#define V_VERSION 0
+#define V_REVISION (V_VERSION + 1)
+#define VERSION_LENGTH (V_REVISION + 1)
+
+/* display information */
+#define DISPLAY_SECTION (VERSION_SECTION + VERSION_LENGTH)
+#define D_INPUT 0
+#define D_HSIZE (D_INPUT + 1)
+#define D_VSIZE (D_HSIZE + 1)
+#define D_GAMMA (D_VSIZE + 1)
+#define FEAT_S (D_GAMMA + 1)
+#define D_RG_LOW (FEAT_S + 1)
+#define D_BW_LOW (D_RG_LOW + 1)
+#define D_REDX (D_BW_LOW + 1)
+#define D_REDY (D_REDX + 1)
+#define D_GREENX (D_REDY + 1)
+#define D_GREENY (D_GREENX + 1)
+#define D_BLUEX (D_GREENY + 1)
+#define D_BLUEY (D_BLUEX + 1)
+#define D_WHITEX (D_BLUEY + 1)
+#define D_WHITEY (D_WHITEX + 1)
+#define DISPLAY_LENGTH (D_WHITEY + 1)
+
+/* supported VESA and other standard timings */
+#define ESTABLISHED_TIMING_SECTION (DISPLAY_SECTION + DISPLAY_LENGTH)
+#define E_T1 0
+#define E_T2 (E_T1 + 1)
+#define E_TMANU (E_T2 + 1)
+#define E_TIMING_LENGTH (E_TMANU + 1) 
+
+/* non predefined standard timings supported by display */
+#define STD_TIMING_SECTION (ESTABLISHED_TIMING_SECTION + E_TIMING_LENGTH)
+#define STD_TIMING_INFO_LEN 2
+#define STD_TIMING_INFO_NUM STD_TIMINGS
+#define STD_TIMING_LENGTH (STD_TIMING_INFO_LEN * STD_TIMING_INFO_NUM)
+
+/* detailed timing info of non standard timings */
+#define DET_TIMING_SECTION (STD_TIMING_SECTION + STD_TIMING_LENGTH)
+#define DET_TIMING_INFO_LEN 18
+#define MONITOR_DESC_LEN DET_TIMING_INFO_LEN
+#define DET_TIMING_INFO_NUM DET_TIMINGS
+#define DET_TIMING_LENGTH (DET_TIMING_INFO_LEN * DET_TIMING_INFO_NUM)
+
+/* number of EDID sections to follow */
+#define NO_EDID (DET_TIMING_SECTION + DET_TIMING_LENGTH)
+/* one byte checksum */
+#define CHECKSUM (NO_EDID + 1)  
+
+#if (CHECKSUM != (EDID1_LEN - 1))
+# error "EDID1 length != 128!" 
+#endif
+
+
+#define SECTION(x,y) (Uchar *)(x + y)
+#define GET_ARRAY(y) ((Uchar *)(c + y))
+#define GET(y) *(Uchar *)(c + y)
+
+/* extract information from vendor section */
+#define _PROD_ID(x) x[0] + (x[1] << 8);
+#define PROD_ID _PROD_ID(GET_ARRAY(V_PROD_ID))
+#define _SERIAL_NO(x) x[0] + (x[1] << 8) + (x[2] << 16) + (x[3] << 24)
+#define SERIAL_NO _SERIAL_NO(GET_ARRAY(V_SERIAL))
+#define _YEAR(x) (x & 0xFF) + 1990
+#define YEAR _YEAR(GET(V_YEAR))
+#define WEEK GET(V_WEEK) & 0xFF
+#define _L1(x) ((x[0] & 0x7C) >> 2) + '@'
+#define _L2(x) ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'
+#define _L3(x) (x[1] & 0x1F) + '@';
+#define L1 _L1(GET_ARRAY(V_MANUFACTURER))
+#define L2 _L2(GET_ARRAY(V_MANUFACTURER))
+#define L3 _L3(GET_ARRAY(V_MANUFACTURER))
+
+/* extract information from version section */
+#define VERSION GET(V_VERSION)
+#define REVISION GET(V_REVISION)
+
+/* extract information from display section */
+#define _INPUT_TYPE(x) ((x & 0x80) >> 7)
+#define INPUT_TYPE _INPUT_TYPE(GET(D_INPUT))
+#define _INPUT_VOLTAGE(x) ((x & 0x60) >> 5)
+#define INPUT_VOLTAGE _INPUT_VOLTAGE(GET(D_INPUT))
+#define _SETUP(x) ((x & 0x10) >> 4)
+#define SETUP _SETUP(GET(D_INPUT))
+#define _SYNC(x) (x  & 0x0F)
+#define SYNC _SYNC(GET(D_INPUT))
+#define _DFP(x) (x & 0x01)
+#define DFP _DFP(GET(D_INPUT))
+#define _GAMMA(x) (x == 0xff ? 1.0 : ((x + 100.0)/100.0))
+#define GAMMA _GAMMA(GET(D_GAMMA))
+#define HSIZE_MAX GET(D_HSIZE)
+#define VSIZE_MAX GET(D_VSIZE)
+#define _DPMS(x) ((x & 0xE0) >> 5)
+#define DPMS _DPMS(GET(FEAT_S))
+#define _DISPLAY_TYPE(x) ((x & 0x18) >> 3)
+#define DISPLAY_TYPE _DISPLAY_TYPE(GET(FEAT_S))
+#define _MSC(x) (x & 0x7)
+#define MSC _MSC(GET(FEAT_S))
+
+
+/* color characteristics */
+#define CC_L(x,y) ((x & (0x03 << y)) >> y)
+#define CC_H(x) (x << 2)
+#define I_CC(x,y,z) CC_H(y) | CC_L(x,z)
+#define F_CC(x) ((x)/1024.0)
+#define REDX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDX)),6))
+#define REDY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDY)),4))
+#define GREENX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENX)),2))
+#define GREENY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENY)),0))
+#define BLUEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEX)),6))
+#define BLUEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEY)),4))
+#define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2))
+#define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0))
+
+/* extract information from standard timing section */
+#define T1 GET(E_T1)
+#define T2 GET(E_T2)
+#define T_MANU GET(E_TMANU)
+
+/* extract information from estabished timing section */
+#define _VALID_TIMING(x) !(((x[0] == 0x01) && (x[1] == 0x01)) \
+                        || ((x[0] == 0x00) && (x[1] == 0x00)) \
+                        || ((x[0] == 0x20) && (x[1] == 0x20)) )
+#define VALID_TIMING _VALID_TIMING(c)
+#define _HSIZE1(x) ((x[0] + 31) * 8)
+#define HSIZE1 _HSIZE1(c)
+#define RATIO(x) ((x[1] & 0xC0) >> 6)
+#define RATIO1_1 0
+/* EDID Ver. 1.3 redefined this */
+#define RATIO16_10 RATIO1_1
+#define RATIO4_3 1
+#define RATIO5_4 2
+#define RATIO16_9 3
+#define _VSIZE1(x,y,r) switch(RATIO(x)){ \
+  case RATIO1_1: y =  ((v->version > 1 || v->revision > 2) \
+		       ? (_HSIZE1(x) * 10) / 16 : _HSIZE1(x)); break; \
+  case RATIO4_3: y = _HSIZE1(x) * 3 / 4; break; \
+  case RATIO5_4: y = _HSIZE1(x) * 4 / 5; break; \
+  case RATIO16_9: y = _HSIZE1(x) * 9 / 16; break; \
+  }
+#define VSIZE1(x) _VSIZE1(c,x,v)
+#define _REFRESH_R(x) (x[1] & 0x3F) + 60
+#define REFRESH_R  _REFRESH_R(c)
+#define _ID_LOW(x) x[0]
+#define ID_LOW _ID_LOW(c)
+#define _ID_HIGH(x) (x[1] << 8)
+#define ID_HIGH _ID_HIGH(c)
+#define STD_TIMING_ID (ID_LOW | ID_HIGH)
+#define _NEXT_STD_TIMING(x)  (x = (x + STD_TIMING_INFO_LEN))
+#define NEXT_STD_TIMING _NEXT_STD_TIMING(c)
+
+
+/* EDID Ver. >= 1.2 */
+#define _IS_MONITOR_DESC(x) (x[0] == 0 && x[1] == 0 && x[2] == 0 && x[4] == 0)
+#define IS_MONITOR_DESC _IS_MONITOR_DESC(c)
+#define _PIXEL_CLOCK(x) (x[0] + (x[1] << 8)) * 10000
+#define PIXEL_CLOCK _PIXEL_CLOCK(c)
+#define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4))
+#define H_ACTIVE _H_ACTIVE(c)
+#define _H_BLANK(x) (x[3] + ((x[4] & 0x0F) << 8))
+#define H_BLANK _H_BLANK(c)
+#define _V_ACTIVE(x) (x[5] + ((x[7] & 0xF0) << 4))
+#define V_ACTIVE _V_ACTIVE(c)
+#define _V_BLANK(x) (x[6] + ((x[7] & 0x0F) << 8))
+#define V_BLANK _V_BLANK(c)
+#define _H_SYNC_OFF(x) (x[8] + ((x[11] & 0xC0) << 2))
+#define H_SYNC_OFF _H_SYNC_OFF(c)
+#define _H_SYNC_WIDTH(x) (x[9] + ((x[11] & 0x30) << 4))
+#define H_SYNC_WIDTH _H_SYNC_WIDTH(c)
+#define _V_SYNC_OFF(x) ((x[10] >> 4) + ((x[11] & 0x0C) << 2))
+#define V_SYNC_OFF _V_SYNC_OFF(c)
+#define _V_SYNC_WIDTH(x) ((x[10] & 0x0F) + ((x[11] & 0x03) << 4))
+#define V_SYNC_WIDTH _V_SYNC_WIDTH(c)
+#define _H_SIZE(x) (x[12] + ((x[14] & 0xF0) << 4))
+#define H_SIZE _H_SIZE(c)
+#define _V_SIZE(x) (x[13] + ((x[14] & 0x0F) << 8))
+#define V_SIZE _V_SIZE(c)
+#define _H_BORDER(x) (x[15])
+#define H_BORDER _H_BORDER(c)
+#define _V_BORDER(x) (x[16])
+#define V_BORDER _V_BORDER(c)
+#define _INTERLACED(x) ((x[17] & 0x80) >> 7)
+#define INTERLACED _INTERLACED(c)
+#define _STEREO(x) ((x[17] & 0x60) >> 5)
+#define STEREO _STEREO(c)
+#define _STEREO1(x) (x[17] & 0x1)
+#define STEREO1 _STEREO(c)
+#define _SYNC_T(x) ((x[17] & 0x18) >> 3)
+#define SYNC_T _SYNC_T(c)
+#define _MISC(x) ((x[17] & 0x06) >> 1)
+#define MISC _MISC(c)
+
+#define _MONITOR_DESC_TYPE(x) x[3]
+#define MONITOR_DESC_TYPE _MONITOR_DESC_TYPE(c)
+#define SERIAL_NUMBER 0xFF
+#define ASCII_STR 0xFE
+#define MONITOR_RANGES 0xFD
+#define _MIN_V(x) x[5]
+#define MIN_V _MIN_V(c) 
+#define _MAX_V(x) x[6]
+#define MAX_V _MAX_V(c) 
+#define _MIN_H(x) x[7]
+#define MIN_H _MIN_H(c) 
+#define _MAX_H(x) x[8]
+#define MAX_H _MAX_H(c) 
+#define _MAX_CLOCK(x) x[9]
+#define MAX_CLOCK _MAX_CLOCK(c) 
+#define _HAVE_2ND_GTF(x) (x[10] == 0x02)
+#define HAVE_2ND_GTF _HAVE_2ND_GTF(c)
+#define _F_2ND_GTF(x) (x[12] * 2)
+#define F_2ND_GTF _F_2ND_GTF(c)
+#define _C_2ND_GTF(x) (x[13] / 2)
+#define C_2ND_GTF _C_2ND_GTF(c)
+#define _M_2ND_GTF(x) (x[14] + (x[15] << 8))
+#define M_2ND_GTF _M_2ND_GTF(c)
+#define _K_2ND_GTF(x) (x[16])
+#define K_2ND_GTF _K_2ND_GTF(c)
+#define _J_2ND_GTF(x) (x[17] / 2)
+#define J_2ND_GTF _J_2ND_GTF(c)
+#define MONITOR_NAME 0xFC
+#define ADD_COLOR_POINT 0xFB
+#define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2))
+#define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0))
+#define _WHITEX_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 1)),2))
+#define _WHITEY_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 2)),0))
+#define _WHITE_INDEX1(x) x[5]
+#define WHITE_INDEX1 _WHITE_INDEX1(c)
+#define _WHITE_INDEX2(x) x[10]
+#define WHITE_INDEX2 _WHITE_INDEX2(c)
+#define WHITEX1 _WHITEX_ADD(c,6)
+#define WHITEY1 _WHITEY_ADD(c,6)
+#define WHITEX2 _WHITEX_ADD(c,12)
+#define WHITEY2 _WHITEY_ADD(c,12)
+#define _WHITE_GAMMA1(x) _GAMMA(x[9])
+#define WHITE_GAMMA1 _WHITE_GAMMA1(c) 
+#define _WHITE_GAMMA2(x) _GAMMA(x[14])
+#define WHITE_GAMMA2 _WHITE_GAMMA2(c)
+#define ADD_STD_TIMINGS 0xFA
+#define ADD_DUMMY 0x10
+
+#define _NEXT_DT_MD_SECTION(x) (x = (x + DET_TIMING_INFO_LEN))
+#define NEXT_DT_MD_SECTION _NEXT_DT_MD_SECTION(c)
+
+#endif /* _PARSE_EDID_ */
+
+/* input type */
+#define DIGITAL(x) x
+
+/* DFP */
+#define DFP1(x) x
+
+/* input voltage level */
+#define V070 0  /* 0.700V/0.300V */
+#define V071 1  /* 0.714V/0.286V */
+#define V100 2  /* 1.000V/0.400V */
+#define V007 3 /* 0.700V/0.000V */
+
+/* Signal level setup */
+#define SIG_SETUP(x) (x)
+
+/* sync characteristics */
+#define SEP_SYNC(x) (x & 0x08)
+#define COMP_SYNC(x) (x & 0x04)
+#define SYNC_O_GREEN(x) (x & 0x02)
+#define SYNC_SERR(x) (x & 0x01)
+
+/* DPMS features */
+#define DPMS_STANDBY(x) (x & 0x04)
+#define DPMS_SUSPEND(x) (x & 0x02)
+#define DPMS_OFF(x) (x & 0x01)
+
+/* display type */
+#define DISP_MONO 0
+#define DISP_RGB 1
+#define DISP_MULTCOLOR 2
+
+/* Msc stuff EDID Ver > 1.1 */
+#define STD_COLOR_SPACE(x) (x & 0x4)
+#define PREFERRED_TIMING_MODE(x) (x & 0x2)
+#define GFT_SUPPORTED(x) (x & 0x1)
+
+/* detailed timing misc */
+#define IS_INTERLACED(x)  (x) 
+#define IS_STEREO(x)  (x) 
+#define IS_RIGHT_STEREO(x) (x & 0x01)
+#define IS_LEFT_STEREO(x) (x & 0x02)
+#define IS_4WAY_STEREO(x) (x & 0x03)
+#define IS_RIGHT_ON_SYNC(x) IS_RIGHT_STEREO(x)
+#define IS_LEFT_ON_SYNC(x) IS_LEFT_STEREO(x)
+
+
+typedef unsigned int Uint;
+typedef unsigned char Uchar;
+
+struct vendor {
+  char name[4];
+  int prod_id;
+  Uint serial;
+  int week;
+  int year;
+};
+
+struct edid_version {
+  int version;
+  int revision;
+};
+
+struct disp_features {
+  unsigned int input_type:1;
+  unsigned int input_voltage:2;
+  unsigned int input_setup:1;
+  unsigned int input_sync:5;
+  unsigned int input_dfp:1;
+  int hsize;
+  int vsize;
+  float gamma;
+  unsigned int dpms:3;
+  unsigned int display_type:2;
+  unsigned int msc:3;
+  float redx;
+  float redy;
+  float greenx;
+  float greeny;
+  float bluex;
+  float bluey;
+  float whitex;
+  float whitey;
+};
+
+struct established_timings {
+  Uchar t1;
+  Uchar t2;
+  Uchar t_manu;
+};
+
+struct std_timings {
+  int hsize;
+  int vsize;
+  int refresh;
+  CARD16 id;
+};
+
+struct detailed_timings {
+  int clock;
+  int h_active;
+  int h_blanking;
+  int v_active;
+  int v_blanking;
+  int h_sync_off;
+  int h_sync_width;
+  int v_sync_off;
+  int v_sync_width;
+  int h_size;
+  int v_size;
+  int h_border;
+  int v_border;
+  unsigned int interlaced:1;
+  unsigned int stereo:2;
+  unsigned int sync:2;
+  unsigned int misc:2;
+  unsigned int stereo_1:1;
+};
+
+#define DT 0
+#define DS_SERIAL 0xFF
+#define DS_ASCII_STR 0xFE
+#define DS_NAME 0xFC
+#define DS_RANGES 0xFD
+#define DS_WHITE_P 0xFB
+#define DS_STD_TIMINGS 0xFA
+#define DS_DUMMY 0x10
+
+struct monitor_ranges {
+  int min_v;
+  int max_v;
+  int min_h;
+  int max_h;
+  int max_clock;
+  int gtf_2nd_f;
+  int gtf_2nd_c;
+  int gtf_2nd_m;
+  int gtf_2nd_k;
+  int gtf_2nd_j;
+};
+
+struct whitePoints{
+  int   index;
+  float white_x;
+  float white_y;
+  float white_gamma;
+};
+
+struct detailed_monitor_section {
+  int type;
+  union {
+    struct detailed_timings d_timings;
+    Uchar serial[13];
+    Uchar ascii_data[13];
+    Uchar name[13];
+    struct monitor_ranges ranges;
+    struct std_timings std_t[5];
+    struct whitePoints wp[2];
+  } section;
+};
+
+typedef struct {
+  int scrnIndex;
+  struct vendor vendor;
+  struct edid_version ver;
+  struct disp_features features;
+  struct established_timings timings1;
+  struct std_timings timings2[8];
+  struct detailed_monitor_section det_mon[4];
+  xf86vdifPtr vdif;
+  int no_sections;
+  Uchar *rawData;
+} xf86Monitor, *xf86MonPtr;
+
+extern xf86MonPtr ConfiguredMonitor;
+
+#endif /* _EDID_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,67 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h,v 1.10 2000/06/07 22:03:09 tsi Exp $ */
+
+/* xf86DDC.h
+ *
+ * This file contains all information to interpret a standard EDIC block 
+ * transmitted by a display device via DDC (Display Data Channel). So far 
+ * there is no information to deal with optional EDID blocks.  
+ * DDC is a Trademark of VESA (Video Electronics Standard Association).
+ *
+ * Copyright 1998 by Egbert Eich <[email protected]>
+ */
+
+#ifndef XF86_DDC_H
+# define XF86_DDC_H
+
+#include "edid.h"
+#include "xf86i2c.h"
+#include "xf86str.h"
+
+/* speed up / slow down */
+typedef enum {
+  DDC_SLOW,
+  DDC_FAST
+} xf86ddcSpeed;
+
+typedef void (* DDC1SetSpeedProc)(ScrnInfoPtr, xf86ddcSpeed);
+
+extern xf86MonPtr xf86DoEDID_DDC1(
+    int scrnIndex, 
+    DDC1SetSpeedProc DDC1SetSpeed,
+    unsigned int (*DDC1Read)(ScrnInfoPtr)
+);
+
+extern xf86MonPtr xf86DoEDID_DDC2(
+   int scrnIndex,
+   I2CBusPtr pBus
+);
+
+extern xf86MonPtr xf86PrintEDID(
+    xf86MonPtr monPtr
+);
+
+extern xf86MonPtr xf86InterpretEDID(
+    int screenIndex, Uchar *block
+);
+
+extern xf86vdifPtr xf86InterpretVdif(
+    CARD8 *c
+);
+
+extern Bool xf86SetDDCproperties(
+    ScrnInfoPtr pScreen,
+    xf86MonPtr DDC
+);
+
+extern void xf86print_vdif(
+    xf86vdifPtr v
+);
+
+extern xf86MonPtr (*xf86FallbackDDCProbe)(
+    int entityIndex, 
+    ScrnInfoPtr scrp
+);
+
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,72 @@
+XCOMM Copyright (c) 2005 ASPEED Technology Inc.
+XCOMM 
+XCOMM Permission to use, copy, modify, distribute, and sell this software and its
+XCOMM documentation for any purpose is hereby granted without fee, provided that
+XCOMM the above copyright notice appear in all copies and that both that
+XCOMM copyright notice and this permission notice appear in supporting
+XCOMM documentation, and that the name of the authors not be used in
+XCOMM advertising or publicity pertaining to distribution of the software without
+XCOMM specific, written prior permission.  The authors makes no representations
+XCOMM about the suitability of this software for any purpose.  It is provided
+XCOMM "as is" without express or implied warranty.
+XCOMM 
+XCOMM THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+XCOMM INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+XCOMM EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+XCOMM CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+XCOMM DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+XCOMM TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+XCOMM PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = ast_driver.c ast_mode.c ast_accel.c ast_tool.c ast_vgatool.c ast_2dtool.c ast_cursor.c
+OBJS = ast_driver.o ast_mode.o ast_accel.o ast_tool.o ast_vgatool.o ast_2dtool.o ast_cursor.o
+
+DEFINES =
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC)				\
+           -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi				\
+	   -I$(XF86SRC)/xaa -I$(XF86SRC)/rac				\
+	   -I$(SERVERSRC)/miext/shadow					\
+           -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac	\
+	   -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c		\
+	   -I$(XF86SRC)/vbe -I$(XF86SRC)/int10			\
+	   -I$(XF86SRC)/shadowfb                                \
+	   -I$(SERVERSRC)/Xext 						\
+           -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC)	\
+	   -I$(EXTINCSRC) -I$(SERVERSRC)/render
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(ast,$(OBJS))
+
+InstallObjectModule(ast,$(MODULEDIR),drivers)
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast.h,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_driver.c,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_mode.h,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_mode.c,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_accel.c,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_tool.h,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_tool.c,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_vgatool.h,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_vgatool.c,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_2dtool.h,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_2dtool.c,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_cursor.h,$(DRIVERSDKDIR)/drivers/ast)
+InstallDriverSDKNonExecFile(ast_cursor.c,$(DRIVERSDKDIR)/drivers/ast)
+
+InstallDriverSDKObjectModule(ast,$(DRIVERSDKMODULEDIR),drivers)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Compiler Options */
+#define	Accel_2D
+/* #define MMIO_2D */
+#define HWC
+
+/* Vendor & Device Info */
+#ifndef PCI_VENDOR_AST
+#define PCI_VENDOR_AST			0x1A03	
+#endif	
+
+#ifndef	PCI_CHIP_AST2000
+#define PCI_CHIP_AST2000		0x2000		
+#endif
+
+/* AST REC Info */
+#define AST_NAME 			"AST"
+#define AST_DRIVER_NAME 		"ast"
+#define AST_MAJOR_VERSION 		0
+#define AST_MINOR_VERSION 		80
+#define AST_PATCH_VERSION		0
+#define AST_VERSION	\
+        ((AST_MAJOR_VERSION << 20) | (AST_MINOR_VERSION << 10) | AST_PATCH_VERSION)
+
+/* Customized Info */
+#define DEFAULT_VIDEOMEM_SIZE		0x00800000
+#define DEFAULT_MMIO_SIZE		0x00020000
+#define DEFAULT_CMDQ_SIZE		0x00100000
+#define MIN_CMDQ_SIZE			0x00040000
+#define CMD_QUEUE_GUARD_BAND    	0x00000020
+#define DEFAULT_HWC_NUM			0x00000002
+
+/* Data Type Definition */
+typedef INT32  		LONG;
+typedef CARD8   	UCHAR;
+typedef CARD16  	USHORT;
+typedef CARD32  	ULONG;
+
+/* Data Structure Definition */
+typedef struct _ASTRegRec {
+    UCHAR 	ExtCRTC[0x50];
+    
+} ASTRegRec, *ASTRegPtr;
+
+typedef struct _VIDEOMODE {
+
+    int			ScreenWidth;
+    int			ScreenHeight;
+    int			bitsPerPixel;
+    int			ScreenPitch;
+    	
+} VIDEOMODE, *PVIDEOMODE;
+
+typedef struct {
+
+    ULONG		ulCMDQSize;
+    ULONG		ulCMDQType;
+    
+    ULONG		ulCMDQOffsetAddr;
+    UCHAR       	*pjCMDQVirtualAddr;
+    
+    UCHAR       	*pjCmdQBasePort;
+    UCHAR       	*pjWritePort;    
+    UCHAR       	*pjReadPort;     
+    UCHAR       	*pjEngStatePort;
+          
+    ULONG		ulCMDQMask;
+    ULONG		ulCurCMDQueueLen;
+                
+    ULONG		ulWritePointer;
+    ULONG		ulReadPointer;
+    
+    ULONG		ulReadPointer_OK;		/* for Eng_DBGChk */
+    
+} CMDQINFO, *PCMDQINFO;
+
+typedef struct {
+
+    int			HWC_NUM;
+    int			HWC_NUM_Next;
+
+    ULONG		ulHWCOffsetAddr;
+    UCHAR       	*pjHWCVirtualAddr;
+    
+    USHORT		cursortype;
+    USHORT		width;
+    USHORT   		height;   
+    USHORT		offset_x;
+    USHORT   		offset_y;
+    ULONG		fg;
+    ULONG		bg;
+    
+        
+} HWCINFO, *PHWCINFO;
+
+typedef struct _ASTRec {
+	
+    EntityInfoPtr 	pEnt;
+    pciVideoPtr 	PciInfo;
+    PCITAG 		PciTag;
+
+    OptionInfoPtr 	Options;
+    DisplayModePtr      ModePtr;		    
+    FBLinearPtr 	pCMDQPtr;    
+    XAAInfoRecPtr	AccelInfoPtr;
+    xf86CursorInfoPtr   HWCInfoPtr;
+    FBLinearPtr 	pHWCPtr;    
+
+    CloseScreenProcPtr CloseScreen;
+    ScreenBlockHandlerProcPtr BlockHandler;
+             
+    Bool 		noAccel;
+    Bool 		noHWC;
+    Bool 		MMIO2D;
+    int			ENGCaps;
+    int			DBGSelect;
+              	
+    ULONG     		FBPhysAddr;		/* Frame buffer physical address     */
+    ULONG     		MMIOPhysAddr;     	/* MMIO region physical address      */
+    ULONG     		BIOSPhysAddr;     	/* BIOS physical address             */
+    
+    UCHAR     		*FBVirtualAddr;   	/* Map of frame buffer               */
+    UCHAR     		*MMIOVirtualAddr; 	/* Map of MMIO region                */
+
+    unsigned long	FbMapSize;
+    unsigned long	MMIOMapSize;
+       
+    IOADDRESS		IODBase;        	/* Base of PIO memory area */
+    IOADDRESS		PIOOffset;
+    IOADDRESS		RelocateIO;
+    
+    VIDEOMODE 		VideoModeInfo;
+    ASTRegRec           SavedReg;
+    CMDQINFO		CMDQInfo;
+    HWCINFO    		HWCInfo;
+    ULONG		ulCMDReg;   
+    Bool		EnableClip;
+   		
+} ASTRec, *ASTRecPtr;
+	
+#define ASTPTR(p) ((ASTRecPtr)((p)->driverPrivate))
+
+/* Include Files */
+#include "ast_mode.h"
+#include "ast_vgatool.h"
+#include "ast_2dtool.h"
+#include "ast_cursor.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_2dtool.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,414 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+#ifdef	Accel_2D
+
+/* Prototype type declaration */
+Bool bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+Bool bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+Bool bEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+void vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+void vWaitEngIdle(ScrnInfoPtr pScrn, ASTRecPtr pAST);    
+UCHAR *pjRequestCMDQ(ASTRecPtr pAST, ULONG   ulDataLen);
+Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam);
+
+Bool
+bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST)
+{
+
+    ScreenPtr pScreen;
+
+    pAST->CMDQInfo.pjCmdQBasePort    = pAST->MMIOVirtualAddr+ 0x8044; 
+    pAST->CMDQInfo.pjWritePort       = pAST->MMIOVirtualAddr+ 0x8048;
+    pAST->CMDQInfo.pjReadPort        = pAST->MMIOVirtualAddr+ 0x804C;
+    pAST->CMDQInfo.pjEngStatePort    = pAST->MMIOVirtualAddr+ 0x804C;
+
+    /* CMDQ mode Init */
+    if (!pAST->MMIO2D) {
+        pAST->CMDQInfo.ulCMDQType = VM_CMD_QUEUE;	
+       
+        pScreen = screenInfo.screens[pScrn->scrnIndex];
+      
+        do {
+            pAST->pCMDQPtr = xf86AllocateOffscreenLinear (pScreen, pAST->CMDQInfo.ulCMDQSize, 8, NULL, NULL, NULL);
+            
+            if (pAST->pCMDQPtr) break;
+            
+            pAST->CMDQInfo.ulCMDQSize >>= 1;
+            
+        } while (pAST->CMDQInfo.ulCMDQSize >= MIN_CMDQ_SIZE);
+        
+        if (pAST->pCMDQPtr)
+        {
+           xf86DrvMsg(pScrn->scrnIndex, X_INFO,"Allocate CMDQ size is %ld kbyte \n", (unsigned long) (pAST->CMDQInfo.ulCMDQSize/1024));
+        	
+           pAST->CMDQInfo.ulCMDQOffsetAddr  = pAST->pCMDQPtr->offset*((pScrn->bitsPerPixel + 1) / 8);
+           pAST->CMDQInfo.pjCMDQVirtualAddr = pAST->FBVirtualAddr + pAST->CMDQInfo.ulCMDQOffsetAddr;
+           						 
+           pAST->CMDQInfo.ulCurCMDQueueLen = pAST->CMDQInfo.ulCMDQSize - CMD_QUEUE_GUARD_BAND;
+           pAST->CMDQInfo.ulCMDQMask = pAST->CMDQInfo.ulCMDQSize - 1 ; 
+        	
+        }	
+        else
+        {   		  
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Allocate CMDQ failed \n");
+           pAST->MMIO2D = TRUE;		/* set to MMIO mode if CMDQ allocate failed */
+        }	
+        						  
+    }
+    
+    /* MMIO mode init */  
+    if (pAST->MMIO2D) {    	
+        pAST->CMDQInfo.ulCMDQType = VM_CMD_MMIO;    	
+    }
+       
+    return (TRUE);	
+}
+
+Bool
+bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST)
+{
+    ULONG ulVMCmdQBasePort = 0;
+
+    vWaitEngIdle(pScrn, pAST);  
+
+    /* set DBG Select Info */
+    if (pAST->DBGSelect)
+    {
+        *(ULONG *) (pAST->MMIOVirtualAddr + 0x804C) = (ULONG) (pAST->DBGSelect);             	
+    }
+    
+    /* set CMDQ base */
+    switch (pAST->CMDQInfo.ulCMDQType)
+    {
+    case VM_CMD_QUEUE:
+        ulVMCmdQBasePort  = (pAST->CMDQInfo.ulCMDQOffsetAddr - 0) >> 3;
+ 
+        /* set CMDQ Threshold */
+        ulVMCmdQBasePort |= 0xF0000000;			   
+
+        /* set CMDQ Size */
+        switch (pAST->CMDQInfo.ulCMDQSize)
+        {
+        case CMD_QUEUE_SIZE_256K:
+            ulVMCmdQBasePort |= 0x00000000;   
+            break;
+        	
+        case CMD_QUEUE_SIZE_512K:
+            ulVMCmdQBasePort |= 0x04000000;   
+            break;
+      
+        case CMD_QUEUE_SIZE_1M:
+            ulVMCmdQBasePort |= 0x08000000;       
+            break;
+            
+        case CMD_QUEUE_SIZE_2M:
+            ulVMCmdQBasePort |= 0x0C000000;       
+            break;        
+            
+        default:
+            return(FALSE);
+            break;
+        }     
+                                 
+        *(ULONG *) (pAST->CMDQInfo.pjCmdQBasePort) = ulVMCmdQBasePort;         
+        pAST->CMDQInfo.ulWritePointer = *(ULONG *) (pAST->CMDQInfo.pjWritePort);                 
+        break;
+        
+    case VM_CMD_MMIO:
+        /* set CMDQ Threshold */
+        ulVMCmdQBasePort |= 0xF0000000;			   
+    
+        ulVMCmdQBasePort |= 0x02000000;			/* MMIO mode */
+        *(ULONG *) (pAST->CMDQInfo.pjCmdQBasePort) = ulVMCmdQBasePort;                 		       
+        break;
+        
+    default:
+        return (FALSE);
+        break;
+    }
+
+    return (TRUE);	
+}
+
+Bool
+bEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST)
+{
+    SetIndexRegMask(CRTC_PORT, 0xA4, 0xFE, 0x01);		/* enable 2D */  
+   
+    if (!bInitCMDQInfo(pScrn, pAST))
+    {
+        vDisable2D(pScrn, pAST);  	
+    	return (FALSE);
+    }
+        
+    if (!bEnableCMDQ(pScrn, pAST))
+    {
+        vDisable2D(pScrn, pAST);  	
+    	return (FALSE);
+    }
+            
+    return (TRUE);	
+}
+
+void
+vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST)
+{
+	
+    vWaitEngIdle(pScrn, pAST);
+    vWaitEngIdle(pScrn, pAST);
+
+    SetIndexRegMask(CRTC_PORT, 0xA4, 0xFE, 0x00);		  
+	
+}
+
+
+void
+vWaitEngIdle(ScrnInfoPtr pScrn, ASTRecPtr pAST)
+{
+    ULONG ulEngState, ulEngState2;
+    UCHAR jReg;
+    ULONG ulEngCheckSetting; 
+    
+    if (pAST->MMIO2D)     
+        ulEngCheckSetting = 0x10000000;
+    else
+        ulEngCheckSetting = 0x80000000;
+    
+    /* 2D disable if 0xA4 D[0] = 1 */
+    GetIndexRegMask(CRTC_PORT, 0xA4, 0x01, jReg);  
+    if (!jReg) goto Exit_vWaitEngIdle;
+    
+    /* 2D not work if in std. mode */
+    GetIndexRegMask(CRTC_PORT, 0xA3, 0x0F, jReg);  
+    if (!jReg) goto Exit_vWaitEngIdle;
+
+    do  
+    {
+        ulEngState = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000;
+        ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000;
+        ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000;
+        ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000;
+        ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000;
+        ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000;
+                      
+    } while ((ulEngState & ulEngCheckSetting) || (ulEngState != ulEngState2));
+    
+Exit_vWaitEngIdle:
+    ;   	
+}    
+
+/* ULONG ulGetCMDQLength() */
+__inline ULONG ulGetCMDQLength(ASTRecPtr pAST, ULONG ulWritePointer, ULONG ulCMDQMask)
+{
+    ULONG ulReadPointer, ulReadPointer2;
+    
+    do {
+        ulReadPointer  = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF;    	
+        ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF;
+        ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF;
+        ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF;
+        ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF;
+        ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF;        
+     } while (ulReadPointer != ulReadPointer2);
+
+    return ((ulReadPointer << 3) - ulWritePointer - CMD_QUEUE_GUARD_BAND) & ulCMDQMask;
+}
+
+UCHAR *pjRequestCMDQ(
+ASTRecPtr pAST, ULONG   ulDataLen)
+{
+    UCHAR   *pjBuffer;
+    ULONG   i, ulWritePointer, ulCMDQMask, ulCurCMDQLen, ulContinueCMDQLen;
+
+    ulWritePointer = pAST->CMDQInfo.ulWritePointer;
+    ulContinueCMDQLen = pAST->CMDQInfo.ulCMDQSize - ulWritePointer;
+    ulCMDQMask = pAST->CMDQInfo.ulCMDQMask;        
+    
+    if (ulContinueCMDQLen >= ulDataLen)
+    {
+        /* Get CMDQ Buffer */            	
+        if (pAST->CMDQInfo.ulCurCMDQueueLen >= ulDataLen)
+        {
+        	;
+        }
+        else
+        {
+           
+            do
+            {
+                ulCurCMDQLen = ulGetCMDQLength(pAST, ulWritePointer, ulCMDQMask);
+            } while (ulCurCMDQLen < ulDataLen);
+            
+            pAST->CMDQInfo.ulCurCMDQueueLen = ulCurCMDQLen;
+
+        }
+        
+        pjBuffer = pAST->CMDQInfo.pjCMDQVirtualAddr + ulWritePointer;
+        pAST->CMDQInfo.ulCurCMDQueueLen -= ulDataLen;            
+        pAST->CMDQInfo.ulWritePointer = (ulWritePointer + ulDataLen) & ulCMDQMask;
+        return pjBuffer;            
+    }
+    else
+    {   
+
+        /* Fill NULL CMD to the last of the CMDQ */
+        if (pAST->CMDQInfo.ulCurCMDQueueLen >= ulContinueCMDQLen)
+        {
+        	;
+        }
+        else
+        {
+           
+            do
+            {
+                ulCurCMDQLen = ulGetCMDQLength(pAST, ulWritePointer, ulCMDQMask);
+            } while (ulCurCMDQLen < ulContinueCMDQLen);
+            
+            pAST->CMDQInfo.ulCurCMDQueueLen = ulCurCMDQLen;
+
+        }
+    
+        pjBuffer = pAST->CMDQInfo.pjCMDQVirtualAddr + ulWritePointer;
+        for (i = 0; i<ulContinueCMDQLen/8; i++, pjBuffer+=8)
+        {
+            *(ULONG *)pjBuffer = (ULONG) PKT_NULL_CMD;
+            *(ULONG *) (pjBuffer+4) = 0;
+            
+        }
+        pAST->CMDQInfo.ulCurCMDQueueLen -= ulContinueCMDQLen;
+        pAST->CMDQInfo.ulWritePointer = ulWritePointer = 0;
+            
+        /* Get CMDQ Buffer */    
+        if (pAST->CMDQInfo.ulCurCMDQueueLen >= ulDataLen)
+        {
+	        ;	
+        }
+        else
+        {
+           
+            do
+            {
+                ulCurCMDQLen = ulGetCMDQLength(pAST, ulWritePointer, ulCMDQMask);
+            } while (ulCurCMDQLen < ulDataLen);
+            
+            pAST->CMDQInfo.ulCurCMDQueueLen = ulCurCMDQLen;
+
+        }
+        
+        pAST->CMDQInfo.ulCurCMDQueueLen -= ulDataLen;
+        pjBuffer = pAST->CMDQInfo.pjCMDQVirtualAddr + ulWritePointer;
+        pAST->CMDQInfo.ulWritePointer = (ulWritePointer + ulDataLen) & ulCMDQMask;
+        return pjBuffer;            
+        
+    }
+   
+} /* end of pjRequestCmdQ() */
+
+Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam)
+{
+    LONG GAbsX, GAbsY, GXInc, GYInc, GXMajor;
+    LONG MM, mm, Error0, K1, K2;
+            	
+    /* Init */
+#ifdef LONG64    
+    GAbsX = abs (LineInfo->X1 - LineInfo->X2);
+    GAbsY = abs (LineInfo->Y1 - LineInfo->Y2);
+#else
+    GAbsX = labs (LineInfo->X1 - LineInfo->X2);
+    GAbsY = labs (LineInfo->Y1 - LineInfo->Y2);
+#endif    
+
+    GXInc = (LineInfo->X1 < LineInfo->X2) ? 1:0;
+    GYInc = (LineInfo->Y1 < LineInfo->Y2) ? 1:0;
+    GXMajor = (GAbsX >= GAbsY) ? 1:0;
+   
+    /* Calculate */
+    if (GXMajor)
+    {
+        MM = GAbsX;
+        mm = GAbsY;	        	
+    }
+    else
+    {
+        MM = GAbsY;
+        mm = GAbsX;	        	    	
+    }
+
+    Error0 = (signed) (2*mm - MM);
+    	
+    K1 = 2* mm;
+    K2 = (signed) (2*mm - 2*MM);
+    
+    /*save the Param to dsLineParam */
+    dsLineParam->dsLineX = (USHORT) LineInfo->X1;
+    dsLineParam->dsLineY = (USHORT) LineInfo->Y1;
+    dsLineParam->dsLineWidth = (USHORT) MM;
+    dsLineParam->dwErrorTerm = (ULONG) Error0;
+    dsLineParam->dwK1Term = K1;
+    dsLineParam->dwK2Term = K2;
+
+    dsLineParam->dwLineAttributes = 0;
+    if (GXMajor) dsLineParam->dwLineAttributes |= LINEPARAM_XM;
+    if (!GXInc) dsLineParam->dwLineAttributes |= LINEPARAM_X_DEC;
+    if (!GYInc) dsLineParam->dwLineAttributes |= LINEPARAM_Y_DEC;
+    
+    return(TRUE);
+    
+}
+#endif	/* end of Accel_2D */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_2dtool.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,479 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Eng Capability Definition */
+#define	ENG_CAP_Sync				0x0001
+#define	ENG_CAP_ScreenToScreenCopy		0x0002
+#define	ENG_CAP_SolidFill			0x0004
+#define	ENG_CAP_SolidLine			0x0008
+#define	ENG_CAP_DashedLine			0x0010
+#define	ENG_CAP_Mono8x8PatternFill		0x0020
+#define	ENG_CAP_Color8x8PatternFill		0x0040
+#define	ENG_CAP_CPUToScreenColorExpand		0x0080
+#define	ENG_CAP_ScreenToScreenColorExpand	0x0100
+#define	ENG_CAP_Clipping			0x0200	
+#define ENG_CAP_ALL	(ENG_CAP_Sync | ENG_CAP_ScreenToScreenCopy | ENG_CAP_SolidFill	|	\
+                         ENG_CAP_SolidLine | ENG_CAP_DashedLine |				\
+                         ENG_CAP_Mono8x8PatternFill | ENG_CAP_Color8x8PatternFill |		\
+                         ENG_CAP_Clipping);
+
+/* CMDQ Definition */
+#define    AGP_CMD_QUEUE                   	1
+#define    VM_CMD_QUEUE                    	0
+#define    VM_CMD_MMIO                     	2
+
+#define    CMD_QUEUE_SIZE_256K             	0x00040000
+#define    CMD_QUEUE_SIZE_512K             	0x00080000
+#define    CMD_QUEUE_SIZE_1M               	0x00100000
+#define    CMD_QUEUE_SIZE_2M               	0x00200000
+#define    CMD_QUEUE_SIZE_4M               	0x00400000
+
+/* CMD Type Info */
+#define    PKT_NULL_CMD             		0x00009561
+
+#define    PKT_SINGLE_LENGTH        		8
+#define    PKT_SINGLE_CMD_HEADER    		0x00009562
+
+typedef struct  _PKT_SC
+{
+    ULONG    PKT_SC_dwHeader;
+    ULONG    PKT_SC_dwData[1];
+    
+} PKT_SC, *PPKT_SC;
+
+/* Eng Reg. Limitation */
+#define	MAX_SRC_PITCH				0x1FFF
+#define	MAX_DST_PITCH				0x1FFF
+#define	MAX_DST_HEIGHT				0x7FF
+#define	MAX_SRC_X				0x7FF
+#define	MAX_SRC_Y				0x7FF
+#define	MAX_DST_X				0x7FF
+#define	MAX_DST_Y				0x7FF
+#define	MAX_RECT_WIDTH				0x7FF
+#define	MAX_RECT_HEIGHT				0x7FF
+#define MAX_CLIP				0xFFF
+
+#define MAX_LINE_X        			0x7FF   
+#define MAX_LINE_Y           			0x7FF
+#define MAX_LINE_ERR   				0x3FFFFF        
+#define MAX_LINE_WIDTH   			0x7FF        
+#define MAX_LINE_K1				0x3FFFFF           
+#define MAX_LINE_K2				0x3FFFFF
+
+#define MAX_PATReg_Size				256
+
+/* Eng Reg. Definition */  
+/* MMIO Reg */
+#define MMIOREG_SRC_BASE	(pAST->MMIOVirtualAddr + 0x8000)                
+#define MMIOREG_SRC_PITCH	(pAST->MMIOVirtualAddr + 0x8004)
+#define MMIOREG_DST_BASE	(pAST->MMIOVirtualAddr + 0x8008)
+#define MMIOREG_DST_PITCH	(pAST->MMIOVirtualAddr + 0x800C)
+#define MMIOREG_DST_XY		(pAST->MMIOVirtualAddr + 0x8010)
+#define MMIOREG_SRC_XY		(pAST->MMIOVirtualAddr + 0x8014)
+#define MMIOREG_RECT_XY		(pAST->MMIOVirtualAddr + 0x8018)
+#define MMIOREG_FG		(pAST->MMIOVirtualAddr + 0x801C)
+#define MMIOREG_BG		(pAST->MMIOVirtualAddr + 0x8020)
+#define MMIOREG_FG_SRC		(pAST->MMIOVirtualAddr + 0x8024)
+#define MMIOREG_BG_SRC		(pAST->MMIOVirtualAddr + 0x8028)
+#define MMIOREG_MONO1		(pAST->MMIOVirtualAddr + 0x802C)
+#define MMIOREG_MONO2		(pAST->MMIOVirtualAddr + 0x8030)
+#define MMIOREG_CLIP1		(pAST->MMIOVirtualAddr + 0x8034)
+#define MMIOREG_CLIP2		(pAST->MMIOVirtualAddr + 0x8038)
+#define MMIOREG_CMD		(pAST->MMIOVirtualAddr + 0x803C)    
+#define MMIOREG_PAT		(pAST->MMIOVirtualAddr + 0x8100)    
+
+#define MMIOREG_LINE_XY         (pAST->MMIOVirtualAddr + 0x8010)  
+#define MMIOREG_LINE_Err        (pAST->MMIOVirtualAddr + 0x8014)  
+#define MMIOREG_LINE_WIDTH      (pAST->MMIOVirtualAddr + 0x8018)  
+#define MMIOREG_LINE_K1         (pAST->MMIOVirtualAddr + 0x8024)  
+#define MMIOREG_LINE_K2         (pAST->MMIOVirtualAddr + 0x8028)  
+#define MMIOREG_LINE_STYLE1     (pAST->MMIOVirtualAddr + 0x802C)  
+#define MMIOREG_LINE_STYLE2     (pAST->MMIOVirtualAddr + 0x8030)  
+
+/* CMDQ Reg */
+#define CMDQREG_SRC_BASE	(0x00 << 24)                       
+#define CMDQREG_SRC_PITCH	(0x01 << 24)
+#define CMDQREG_DST_BASE	(0x02 << 24)
+#define CMDQREG_DST_PITCH	(0x03 << 24)
+#define CMDQREG_DST_XY		(0x04 << 24)
+#define CMDQREG_SRC_XY		(0x05 << 24)
+#define CMDQREG_RECT_XY		(0x06 << 24)
+#define CMDQREG_FG		(0x07 << 24)
+#define CMDQREG_BG		(0x08 << 24)
+#define CMDQREG_FG_SRC		(0x09 << 24)
+#define CMDQREG_BG_SRC		(0x0A << 24)
+#define CMDQREG_MONO1		(0x0B << 24)
+#define CMDQREG_MONO2		(0x0C << 24)
+#define CMDQREG_CLIP1		(0x0D << 24)
+#define CMDQREG_CLIP2		(0x0E << 24)
+#define CMDQREG_CMD		(0x0F << 24)
+#define CMDQREG_PAT		(0x40 << 24)
+
+#define CMDQREG_LINE_XY         (0x04 << 24) 
+#define CMDQREG_LINE_Err        (0x05 << 24)  
+#define CMDQREG_LINE_WIDTH      (0x06 << 24)    
+#define CMDQREG_LINE_K1         (0x09 << 24) 
+#define CMDQREG_LINE_K2         (0x0A << 24)
+#define CMDQREG_LINE_STYLE1     (0x0B << 24) 
+#define CMDQREG_LINE_STYLE2     (0x0C << 24)
+
+/* CMD Reg. Definition */
+#define   CMD_BITBLT                 		0x00000000
+#define   CMD_LINEDRAW               		0x00000001
+#define   CMD_COLOREXP               		0x00000002
+#define   CMD_ENHCOLOREXP            		0x00000003
+#define   CMD_MASK            	        	0x00000007
+					
+#define   CMD_DISABLE_CLIP           		0x00000000   
+#define   CMD_ENABLE_CLIP            		0x00000008
+
+#define   CMD_COLOR_08               		0x00000000
+#define   CMD_COLOR_16               		0x00000010
+#define   CMD_COLOR_32               		0x00000020
+
+#define   CMD_SRC_SIQ                		0x00000040
+
+#define   CMD_TRANSPARENT               	0x00000080
+
+#define   CMD_PAT_FGCOLOR            		0x00000000
+#define   CMD_PAT_MONOMASK           		0x00010000
+#define   CMD_PAT_PATREG             		0x00020000
+
+#define   CMD_OPAQUE                 		0x00000000
+#define   CMD_FONT_TRANSPARENT          	0x00040000
+
+#define   CMD_X_INC				0x00000000	
+#define   CMD_X_DEC				0x00200000
+
+#define   CMD_Y_INC				0x00000000	
+#define   CMD_Y_DEC				0x00100000
+
+#define   CMD_DRAW_LAST_PIXEL           	0x00000000
+#define   CMD_NOT_DRAW_LAST_PIXEL       	0x00800000
+
+#define   CMD_DISABLE_LINE_STYLE     		0x00000000
+#define   CMD_ENABLE_LINE_STYLE      		0x40000000
+
+#define   CMD_RESET_STYLE_COUNTER       	0x80000000
+#define   CMD_NOT_RESET_STYLE_COUNTER   	0x00000000
+
+#define   BURST_FORCE_CMD            		0x80000000
+
+/* Line */
+#define	LINEPARAM_XM				0x00000001
+#define	LINEPARAM_X_DEC				0x00000002
+#define	LINEPARAM_Y_DEC				0x00000004
+
+typedef struct _LINEPARAM {
+    USHORT	dsLineX;
+    USHORT	dsLineY;
+    USHORT	dsLineWidth;
+    ULONG	dwErrorTerm;
+    ULONG	dwK1Term;
+    ULONG	dwK2Term;
+    ULONG	dwLineAttributes;	
+} LINEPARAM, *PLINEPARAM;
+
+typedef struct {
+	
+    ULONG X1;
+    ULONG Y1;
+    ULONG X2;
+    ULONG Y2;	
+    
+} _LINEInfo;
+
+/* Macro */
+/* MMIO 2D Macro */
+#define ASTSetupSRCBase_MMIO(base) \
+      { \
+        do { \
+           *(ULONG *)(MMIOREG_SRC_BASE) = (ULONG) (base); \
+        } while (*(ULONG *)(MMIOREG_SRC_BASE) != (ULONG) (base)); \
+      }
+#define ASTSetupSRCPitch_MMIO(pitch) \
+      { \
+        do { \
+           *(ULONG *)(MMIOREG_SRC_PITCH) = (ULONG)(pitch << 16); \
+        } while (*(ULONG *)(MMIOREG_SRC_PITCH) != (ULONG)(pitch << 16)); \
+      }
+#define ASTSetupDSTBase_MMIO(base) \
+      { \
+        do { \
+           *(ULONG *)(MMIOREG_DST_BASE) = (ULONG)(base); \
+        } while (*(ULONG *)(MMIOREG_DST_BASE) != (ULONG)(base)); \
+      }      
+#define ASTSetupDSTPitchHeight_MMIO(pitch, height) \
+      { \
+        ULONG dstpitch; \
+        dstpitch = (ULONG)((pitch << 16) + ((height) & MAX_DST_HEIGHT)); \
+        do { \
+           *(ULONG *)(MMIOREG_DST_PITCH) = dstpitch; \
+        } while (*(ULONG *)(MMIOREG_DST_PITCH) != dstpitch); \
+      }      
+#define ASTSetupDSTXY_MMIO(x, y) \
+      { \
+        ULONG dstxy; \
+        dstxy = (ULONG)(((x & MAX_DST_X) << 16) + (y & MAX_DST_Y)); \
+        do { \
+           *(ULONG *)(MMIOREG_DST_XY) = dstxy; \
+        } while (*(ULONG *)(MMIOREG_DST_XY) != dstxy); \
+      }           
+#define ASTSetupSRCXY_MMIO(x, y) \
+      { \
+        ULONG srcxy; \
+        srcxy = (ULONG)(((x & MAX_SRC_X) << 16) + (y & MAX_SRC_Y)); \
+        do { \
+           *(ULONG *)(MMIOREG_SRC_XY) = srcxy; \
+        } while (*(ULONG *)(MMIOREG_SRC_XY) != srcxy); \
+      }             
+#define ASTSetupRECTXY_MMIO(x, y) \
+      { \
+        ULONG rectxy; \
+        rectxy = (ULONG)(((x & MAX_RECT_WIDTH) << 16) + (y & MAX_RECT_WIDTH)); \
+        do { \
+           *(ULONG *)(MMIOREG_RECT_XY) = rectxy; \
+        } while (*(ULONG *)(MMIOREG_RECT_XY) != rectxy); \
+      }  
+#define ASTSetupFG_MMIO(color) \
+      { \
+        do { \
+           *(ULONG *)(MMIOREG_FG) = (ULONG)(color); \
+        } while (*(ULONG *)(MMIOREG_FG) != (ULONG)(color)); \
+      } 
+#define ASTSetupBG_MMIO(color) \
+      { \
+        do { \
+           *(ULONG *)(MMIOREG_BG) = (ULONG)(color); \
+        } while (*(ULONG *)(MMIOREG_BG) != (ULONG)(color)); \
+      }
+#define ASTSetupMONO1_MMIO(pat) \
+      { \
+        do { \
+          *(ULONG *)(MMIOREG_MONO1) = (ULONG)(pat); \
+        } while (*(ULONG *)(MMIOREG_MONO1) != (ULONG)(pat)); \
+      } 
+#define ASTSetupMONO2_MMIO(pat) \
+      { \
+        do { \
+          *(ULONG *)(MMIOREG_MONO2) = (ULONG)(pat); \
+        } while (*(ULONG *)(MMIOREG_MONO2) != (ULONG)(pat)); \
+      }
+#define ASTSetupCLIP1_MMIO(left, top) \
+      { \
+       ULONG clip1; \
+       clip1 = (ULONG)(((left & MAX_CLIP) << 16) + (top & MAX_CLIP)); \
+       do { \
+          *(ULONG *)(MMIOREG_CLIP1) = clip1; \
+       } while (*(ULONG *)(MMIOREG_CLIP1) != clip1); \
+      } 
+#define ASTSetupCLIP2_MMIO(right, bottom) \
+      { \
+       ULONG clip2; \
+       clip2 = (ULONG)(((right & MAX_CLIP) << 16) + (bottom & MAX_CLIP)); \
+       do { \
+          *(ULONG *)(MMIOREG_CLIP2) = clip2; \
+       } while (*(ULONG *)(MMIOREG_CLIP2) != clip2); \
+      }                                                                                               
+#define ASTSetupCMDReg_MMIO(reg) \
+      { \
+        *(ULONG *)(MMIOREG_CMD) = (ULONG)(reg);	\
+      }
+#define ASTSetupPatReg_MMIO(patreg, pat) \
+      { \
+       do { \
+          *(ULONG *)(MMIOREG_PAT + patreg*4) = (ULONG)(pat); \
+       } while (*(ULONG *)(MMIOREG_PAT + patreg*4) != (ULONG)(pat)); \
+      }      
+                                
+/* Line CMD */
+#define ASTSetupLineXY_MMIO(x, y) \
+      { \
+        ULONG linexy; \
+        linexy = (ULONG)(((x & MAX_LINE_X) << 16) + (y & MAX_LINE_Y)); \
+        do { \
+           *(ULONG *)(MMIOREG_LINE_XY) = linexy; \
+        } while (*(ULONG *)(MMIOREG_LINE_XY) != linexy); \
+      }
+#define ASTSetupLineXMErrTerm_MMIO(xm, err) \
+      { \
+        ULONG lineerr; \
+        lineerr = (ULONG)((xm << 24) + (err & MAX_LINE_ERR)); \
+        do { \
+           *(ULONG *)(MMIOREG_LINE_Err) = lineerr; \
+        } while (*(ULONG *)(MMIOREG_LINE_Err) != lineerr); \
+      }      
+#define ASTSetupLineWidth_MMIO(width) \
+      { \
+        ULONG linewidth; \
+        linewidth = (ULONG)((width & MAX_LINE_WIDTH) << 16); \
+        do { \
+          *(ULONG *)(MMIOREG_LINE_WIDTH) = linewidth; \
+        } while (*(ULONG *)(MMIOREG_LINE_WIDTH) != linewidth); \
+      }
+#define ASTSetupLineK1Term_MMIO(err) \
+      { \
+        do { \
+          *(ULONG *)(MMIOREG_LINE_K1) = (ULONG)(err & MAX_LINE_K1); \
+        } while (*(ULONG *)(MMIOREG_LINE_K1) != (ULONG)(err & MAX_LINE_K1)); \
+      }            
+#define ASTSetupLineK2Term_MMIO(err) \
+      { \
+        do { \
+           *(ULONG *)(MMIOREG_LINE_K2) = (ULONG)(err & MAX_LINE_K2); \
+        } while (*(ULONG *)(MMIOREG_LINE_K2) != (ULONG)(err & MAX_LINE_K2)); \
+      }
+#define ASTSetupLineStyle1_MMIO(pat) \
+      { \
+        do { \
+           *(ULONG *)(MMIOREG_LINE_STYLE1) = (ULONG)(pat); \
+        } while (*(ULONG *)(MMIOREG_LINE_STYLE1) != (ULONG)(pat)); \
+      } 
+#define ASTSetupLineStyle2_MMIO(pat) \
+      { \
+        do { \
+          *(ULONG *)(MMIOREG_LINE_STYLE2) = (ULONG)(pat); \
+        } while (*(ULONG *)(MMIOREG_LINE_STYLE2) != (ULONG)(pat)); \
+      }     
+                                
+/* CMDQ Mode Macro */ 
+#define mUpdateWritePointer *(ULONG *) (pAST->CMDQInfo.pjWritePort) = (pAST->CMDQInfo.ulWritePointer >>3)
+
+/* General CMD */
+#define ASTSetupSRCBase(addr, base) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_BASE); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(base);					\
+      }
+#define ASTSetupSRCPitch(addr, pitch) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_PITCH); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(pitch << 16);					\
+      }
+#define ASTSetupDSTBase(addr, base) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_BASE); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(base);					\
+      }      
+#define ASTSetupDSTPitchHeight(addr, pitch, height) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_PITCH); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)((pitch << 16) + ((height) & MAX_DST_HEIGHT));					\
+      }      
+#define ASTSetupDSTXY(addr, x, y) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_XY); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_DST_X) << 16) + (y & MAX_DST_Y));					\
+      }           
+#define ASTSetupSRCXY(addr, x, y) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_XY); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_SRC_X) << 16) + (y & MAX_SRC_Y));					\
+      }             
+#define ASTSetupRECTXY(addr, x, y) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_RECT_XY); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_RECT_WIDTH) << 16) + (y & MAX_RECT_WIDTH));					\
+      }  
+#define ASTSetupFG(addr, color) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_FG); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(color);					\
+      }
+#define ASTSetupBG(addr, color) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_BG); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(color);					\
+      }
+#define ASTSetupMONO1(addr, pat) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_MONO1); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(pat);				\
+      }            
+#define ASTSetupMONO2(addr, pat) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_MONO2); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(pat);				\
+      }     
+#define ASTSetupCLIP1(addr, left, top) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CLIP1); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(((left & MAX_CLIP) << 16) + (top & MAX_CLIP));	\
+      }            
+#define ASTSetupCLIP2(addr, right, bottom) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CLIP2); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(((right & MAX_CLIP) << 16) + (bottom & MAX_CLIP));	\
+      }                                                                                                    
+#define ASTSetupCMDReg(addr, reg) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CMD); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(reg);					\
+      }
+#define ASTSetupPatReg(addr, patreg, pat) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + (CMDQREG_PAT + (patreg << 24))); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(pat);				\
+      }    
+
+/* Line CMD */
+#define ASTSetupLineXY(addr, x, y) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_XY); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_LINE_X) << 16) + (y & MAX_LINE_Y));					\
+      }
+#define ASTSetupLineXMErrTerm(addr, xm, err) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_Err); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)((xm << 24) + (err & MAX_LINE_ERR));					\
+      }      
+#define ASTSetupLineWidth(addr, width) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_WIDTH); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)((width & MAX_LINE_WIDTH) << 16);				\
+      }            
+#define ASTSetupLineK1Term(addr, err) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_K1); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(err & MAX_LINE_K1);				\
+      }            
+#define ASTSetupLineK2Term(addr, err) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_K2); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(err & MAX_LINE_K2);				\
+      }     
+#define ASTSetupLineStyle1(addr, pat) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_STYLE1); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(pat);				\
+      }            
+#define ASTSetupLineStyle2(addr, pat) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_STYLE2); 	\
+        addr->PKT_SC_dwData[0] = (ULONG)(pat);				\
+      }     
+
+#define ASTSetupNULLCMD(addr) \
+      { \
+        addr->PKT_SC_dwHeader  = (ULONG) (PKT_NULL_CMD); 			\
+        addr->PKT_SC_dwData[0] = (ULONG) 0;					\
+      }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_accel.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1397 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+#ifdef	Accel_2D
+/* ROP Translation Table */
+int ASTXAACopyROP[16] =
+{
+   ROP_0,               /* GXclear */
+   ROP_DSa,             /* GXand */
+   ROP_SDna,            /* GXandReverse */
+   ROP_S,               /* GXcopy */
+   ROP_DSna,            /* GXandInverted */
+   ROP_D,               /* GXnoop */
+   ROP_DSx,             /* GXxor */
+   ROP_DSo,             /* GXor */
+   ROP_DSon,            /* GXnor */
+   ROP_DSxn,            /* GXequiv */
+   ROP_Dn,              /* GXinvert*/
+   ROP_SDno,            /* GXorReverse */
+   ROP_Sn,              /* GXcopyInverted */
+   ROP_DSno,            /* GXorInverted */
+   ROP_DSan,            /* GXnand */
+   ROP_1                /* GXset */
+};
+
+int ASTXAAPatternROP[16]=
+{
+   ROP_0,
+   ROP_DPa,
+   ROP_PDna,
+   ROP_P,
+   ROP_DPna,
+   ROP_D,
+   ROP_DPx,
+   ROP_DPo,
+   ROP_DPon,
+   ROP_PDxn,
+   ROP_Dn,
+   ROP_PDno,
+   ROP_Pn,
+   ROP_DPno,
+   ROP_DPan,
+   ROP_1
+};
+
+/* extern function */
+extern void vWaitEngIdle(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+extern UCHAR *pjRequestCMDQ(ASTRecPtr pAST, ULONG ulDataLen);
+extern Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam);
+
+/* Prototype type declaration */
+Bool ASTAccelInit(ScreenPtr pScreen);
+static void ASTSync(ScrnInfoPtr pScrn);
+static void ASTSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, 
+                                          int xdir, int ydir, int rop,
+                                          unsigned int planemask, int trans_color);
+static void ASTSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2,
+                                            int y2, int w, int h);                                
+static void ASTSetupForSolidFill(ScrnInfoPtr pScrn,
+                                 int color, int rop, unsigned int planemask);
+static void ASTSubsequentSolidFillRect(ScrnInfoPtr pScrn,
+                                       int dst_x, int dst_y, int width, int height);  
+static void ASTSetupForSolidLine(ScrnInfoPtr pScrn,
+                                 int color, int rop, unsigned int planemask);
+static void ASTSubsequentSolidHorVertLine(ScrnInfoPtr pScrn,
+                                          int x, int y, int len, int dir);
+static void ASTSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
+                                           int x1, int y1, int x2, int y2, int flags);                                       
+static void ASTSetupForDashedLine(ScrnInfoPtr pScrn,
+                                  int fg, int bg, int rop, unsigned int planemask,
+                                  int length, UCHAR *pattern);
+static void ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn,
+                                            int x1, int y1, int x2, int y2,
+                                            int flags, int phase);                                              
+static void ASTSetupForMonoPatternFill(ScrnInfoPtr pScrn,
+                                       int patx, int paty, int fg, int bg,
+                                       int rop, unsigned int planemask);
+static void ASTSubsequentMonoPatternFill(ScrnInfoPtr pScrn,
+                                         int patx, int paty,
+                                         int x, int y, int w, int h);
+static void ASTSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
+			                   int rop, unsigned int planemask, int trans_col);
+static void ASTSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty,
+                                                 int x, int y, int w, int h);
+static void ASTSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                                  int fg, int bg,
+                                                  int rop, unsigned int planemask);
+static void ASTSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                                    int x, int y,
+                                                    int width, int height, int skipleft);
+static void ASTSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                                     int fg, int bg,
+                                                     int rop, unsigned int planemask);
+static void ASTSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                                       int x, int y, int width, int height,
+                                                       int src_x, int src_y, int offset);
+static void ASTSetClippingRectangle(ScrnInfoPtr pScrn,
+                                    int left, int top, int right, int bottom);
+static void ASTDisableClipping(ScrnInfoPtr pScrn); 
+
+Bool
+ASTAccelInit(ScreenPtr pScreen)
+{
+    XAAInfoRecPtr  infoPtr;
+    ScrnInfoPtr    pScrn = xf86Screens[pScreen->myNum];
+    ASTRecPtr      pAST = ASTPTR(pScrn);
+
+    pAST->AccelInfoPtr = infoPtr = XAACreateInfoRec();
+    if (!infoPtr)  return FALSE;
+
+    infoPtr->Flags = LINEAR_FRAMEBUFFER |
+  		     OFFSCREEN_PIXMAPS |
+  		     PIXMAP_CACHE;
+
+    /* Sync */
+    if (pAST->ENGCaps & ENG_CAP_Sync)
+        infoPtr->Sync = ASTSync;
+
+    /* Screen To Screen copy */
+    if (pAST->ENGCaps & ENG_CAP_ScreenToScreenCopy)
+    {    
+        infoPtr->SetupForScreenToScreenCopy =  ASTSetupForScreenToScreenCopy;
+        infoPtr->SubsequentScreenToScreenCopy = ASTSubsequentScreenToScreenCopy;
+        infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | NO_PLANEMASK;
+    }
+
+    /* Solid fill */
+    if (pAST->ENGCaps & ENG_CAP_SolidFill)
+    {    
+        infoPtr->SetupForSolidFill = ASTSetupForSolidFill;
+        infoPtr->SubsequentSolidFillRect = ASTSubsequentSolidFillRect;
+        infoPtr->SolidFillFlags = NO_PLANEMASK;
+    } 
+        
+    /* Solid Lines */
+    if (pAST->ENGCaps & ENG_CAP_SolidLine)
+    {    
+        infoPtr->SetupForSolidLine = ASTSetupForSolidLine;
+        infoPtr->SubsequentSolidHorVertLine = ASTSubsequentSolidHorVertLine;    
+        infoPtr->SubsequentSolidTwoPointLine = ASTSubsequentSolidTwoPointLine;
+        infoPtr->SolidLineFlags = NO_PLANEMASK;
+    }
+
+    /* Dashed Lines */
+    if (pAST->ENGCaps & ENG_CAP_DashedLine)
+    {        
+        infoPtr->SetupForDashedLine = ASTSetupForDashedLine;
+        infoPtr->SubsequentDashedTwoPointLine = ASTSubsequentDashedTwoPointLine;
+        infoPtr->DashPatternMaxLength = 64;
+        infoPtr->DashedLineFlags = NO_PLANEMASK |
+			           LINE_PATTERN_MSBFIRST_LSBJUSTIFIED;
+    }			           			           
+
+    /* 8x8 mono pattern fill */
+    if (pAST->ENGCaps & ENG_CAP_Mono8x8PatternFill)
+    {    
+        infoPtr->SetupForMono8x8PatternFill = ASTSetupForMonoPatternFill;
+        infoPtr->SubsequentMono8x8PatternFillRect = ASTSubsequentMonoPatternFill;
+        infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK |
+                                           NO_TRANSPARENCY |
+				           HARDWARE_PATTERN_SCREEN_ORIGIN |
+				           HARDWARE_PATTERN_PROGRAMMED_BITS |
+				           BIT_ORDER_IN_BYTE_MSBFIRST;
+    }				           
+				           
+    /* 8x8 color pattern fill */
+    if (pAST->ENGCaps & ENG_CAP_Color8x8PatternFill)
+    {    
+        infoPtr->SetupForColor8x8PatternFill = ASTSetupForColor8x8PatternFill;
+        infoPtr->SubsequentColor8x8PatternFillRect = ASTSubsequentColor8x8PatternFillRect;
+        infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK |
+					    NO_TRANSPARENCY |    
+	 				    HARDWARE_PATTERN_SCREEN_ORIGIN;
+    }	 				    
+	 				
+    /* CPU To Screen Color Expand */
+    if (pAST->ENGCaps & ENG_CAP_CPUToScreenColorExpand)
+    {    
+        infoPtr->SetupForCPUToScreenColorExpandFill = ASTSetupForCPUToScreenColorExpandFill;
+        infoPtr->SubsequentCPUToScreenColorExpandFill = ASTSubsequentCPUToScreenColorExpandFill;
+        infoPtr->ColorExpandRange = MAX_PATReg_Size;
+        infoPtr->ColorExpandBase = MMIOREG_PAT;
+        infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK |
+	   				           BIT_ORDER_IN_BYTE_MSBFIRST;
+    }	   				           
+
+    /* Screen To Screen Color Expand */
+    if (pAST->ENGCaps & ENG_CAP_ScreenToScreenColorExpand)
+    {    
+        infoPtr->SetupForScreenToScreenColorExpandFill = ASTSetupForScreenToScreenColorExpandFill;
+        infoPtr->SubsequentScreenToScreenColorExpandFill = ASTSubsequentScreenToScreenColorExpandFill;
+        infoPtr->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK |
+	                                              BIT_ORDER_IN_BYTE_MSBFIRST;
+    }	                                              
+                                              
+    /* Clipping */
+    if (pAST->ENGCaps & ENG_CAP_Clipping)
+    {    
+        infoPtr->SetClippingRectangle = ASTSetClippingRectangle;
+        infoPtr->DisableClipping = ASTDisableClipping;
+        infoPtr->ClippingFlags = HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY 	|
+                		 HARDWARE_CLIP_MONO_8x8_FILL		|
+                		 HARDWARE_CLIP_COLOR_8x8_FILL	 	|
+                		 HARDWARE_CLIP_SOLID_FILL		|     
+                		 HARDWARE_CLIP_SOLID_LINE 		| 
+                		 HARDWARE_CLIP_DASHED_LINE 		| 
+                		 HARDWARE_CLIP_SOLID_LINE; 
+    }                		 
+
+    return(XAAInit(pScreen, infoPtr));
+    
+} /* end of ASTAccelInit */
+
+
+static void
+ASTSync(ScrnInfoPtr pScrn)
+{
+    ASTRecPtr pAST = ASTPTR(pScrn);
+
+    /* wait engle idle */
+    vWaitEngIdle(pScrn, pAST);
+
+} /* end of ASTSync */
+
+
+static void ASTSetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
+                                          int xdir, int ydir, int rop,
+                                          unsigned int planemask, int trans_color)
+{
+	
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG  cmdreg;
+    
+/*
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForScreenToScreenCopy\n");
+*/    
+    /* Modify Reg. Value */
+    cmdreg = CMD_BITBLT;
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAACopyROP[rop] << 8);
+    pAST->ulCMDReg = cmdreg;
+     
+    if (!pAST->MMIO2D)
+    {   
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*2);
+                
+        ASTSetupSRCPitch(pSingleCMD, pAST->VideoModeInfo.ScreenPitch);  
+        pSingleCMD++;
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+    }
+    else
+    {
+        /* Write to MMIO */                
+        ASTSetupSRCPitch_MMIO(pAST->VideoModeInfo.ScreenPitch);  
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);    
+    }
+                             
+} /* end of ASTSetupForScreenToScreenCopy */
+
+static void
+ASTSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2,
+                                int y2, int width, int height)
+{
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    int src_x, src_y, dst_x, dst_y;
+    ULONG srcbase, dstbase, cmdreg;
+/*
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentScreenToScreenCopy\n");
+*/
+
+    /* Modify Reg. Value */
+    cmdreg = pAST->ulCMDReg;
+    if (pAST->EnableClip)
+        cmdreg |= CMD_ENABLE_CLIP;
+    srcbase = dstbase = 0;
+
+    if (y1 >= MAX_SRC_Y)
+    {       
+        srcbase=pAST->VideoModeInfo.ScreenPitch*y1;
+        y1=0;
+    }       
+    
+    if (y2 >= pScrn->virtualY) 
+    {   
+        dstbase=pAST->VideoModeInfo.ScreenPitch*y2;
+        y2=0;
+    }
+          
+    if (x1 < x2)
+    {
+    	src_x = x1 + width - 1;
+    	dst_x = x2 + width - 1;
+    	cmdreg |= CMD_X_DEC;     	
+    }
+    else
+    {
+        src_x = x1;
+        dst_x = x2;	
+    }
+ 
+    if (y1 < y2)
+    {
+    	src_y = y1 + height - 1;
+    	dst_y = y2 + height - 1;
+    	cmdreg |= CMD_Y_DEC;     	
+    }
+    else
+    {
+        src_y = y1;
+        dst_y = y2;	
+    }
+        
+    if (!pAST->MMIO2D)        
+    {
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*6);
+      
+        ASTSetupSRCBase(pSingleCMD, srcbase);
+        pSingleCMD++;       
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);    
+        pSingleCMD++;    
+        ASTSetupSRCXY(pSingleCMD, src_x, src_y);    
+        pSingleCMD++;    
+        ASTSetupRECTXY(pSingleCMD, width, height);    
+        pSingleCMD++;    
+        ASTSetupCMDReg(pSingleCMD, cmdreg);       
+                                  
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+    
+    }
+    else
+    {
+        ASTSetupSRCBase_MMIO(srcbase);
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupDSTXY_MMIO(dst_x, dst_y);    
+        ASTSetupSRCXY_MMIO(src_x, src_y);    
+        ASTSetupRECTXY_MMIO(width, height);    
+        ASTSetupCMDReg_MMIO(cmdreg);       
+            	
+        vWaitEngIdle(pScrn, pAST);
+    }
+
+} /* end of ASTSubsequentScreenToScreenCopy */
+
+static void
+ASTSetupForSolidFill(ScrnInfoPtr pScrn,
+                     int color, int rop, unsigned int planemask)
+{
+	
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG cmdreg;
+
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForSolidFill\n");
+*/            
+    /* Modify Reg. Value */
+    cmdreg = CMD_BITBLT | CMD_PAT_FGCOLOR;
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAAPatternROP[rop] << 8);
+    pAST->ulCMDReg = cmdreg;
+            
+    if (!pAST->MMIO2D)                    
+    {
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*2);
+
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+        pSingleCMD++;
+        ASTSetupFG(pSingleCMD, color);        
+    }
+    else
+    {
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+        ASTSetupFG_MMIO(color);            	
+    }
+           
+} /* end of ASTSetupForSolidFill */
+
+
+static void
+ASTSubsequentSolidFillRect(ScrnInfoPtr pScrn,
+                           int dst_x, int dst_y, int width, int height)
+{
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG dstbase, cmdreg;        
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidFillRect\n");
+*/
+
+    /* Modify Reg. Value */
+    cmdreg = pAST->ulCMDReg;
+    if (pAST->EnableClip)
+        cmdreg |= CMD_ENABLE_CLIP;    
+    dstbase = 0;
+
+    if (dst_y >= pScrn->virtualY) 
+    {   
+        dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+        dst_y=0;
+    }
+                  
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+        pSingleCMD++;    
+        ASTSetupRECTXY(pSingleCMD, width, height);
+        pSingleCMD++;    
+        ASTSetupCMDReg(pSingleCMD, cmdreg);        
+      
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+                
+    }
+    else
+    {                  
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupDSTXY_MMIO(dst_x, dst_y);
+        ASTSetupRECTXY_MMIO(width, height);
+        ASTSetupCMDReg_MMIO(cmdreg);        
+ 
+        vWaitEngIdle(pScrn, pAST);
+      
+    }
+
+
+} /* end of ASTSubsequentSolidFillRect */
+
+/* Line */
+static void ASTSetupForSolidLine(ScrnInfoPtr pScrn, 
+                                 int color, int rop, unsigned int planemask)
+{
+
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG  cmdreg;
+/*
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForSolidLine\n");
+*/  
+    /* Modify Reg. Value */
+    cmdreg = CMD_BITBLT;
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAAPatternROP[rop] << 8);  
+    pAST->ulCMDReg = cmdreg;
+     
+    if (!pAST->MMIO2D)
+    {   
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*3);
+
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+        pSingleCMD++;
+        ASTSetupFG(pSingleCMD, color);  
+        pSingleCMD++;
+        ASTSetupBG(pSingleCMD, 0);
+        
+    }
+    else
+    {
+        /* Write to MMIO */   
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);                     
+        ASTSetupFG_MMIO(color);  
+        ASTSetupBG_MMIO(0);            
+    }
+                                 
+} /* end of ASTSetupForSolidLine */
+
+
+static void ASTSubsequentSolidHorVertLine(ScrnInfoPtr pScrn,
+                                          int x, int y, int len, int dir)
+{
+
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG dstbase, cmdreg;   
+    int width, height;
+/*                    
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidHorVertLine\n");
+*/
+            
+    /* Modify Reg. Value */
+    cmdreg = (pAST->ulCMDReg & (~CMD_MASK)) | CMD_BITBLT;
+    if (pAST->EnableClip)
+        cmdreg |= CMD_ENABLE_CLIP;    
+    dstbase = 0;
+    
+    if(dir == DEGREES_0) {			/* horizontal */
+        width  = len;
+        height = 1;	
+    } else {					/* vertical */
+        width  = 1;
+        height = len;	    	
+    }
+              
+    if ((y + height) >= pScrn->virtualY) 
+    {   
+        dstbase=pAST->VideoModeInfo.ScreenPitch*y;
+        y=0;
+    }
+              
+    
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupDSTXY(pSingleCMD, x, y);
+        pSingleCMD++;    
+        ASTSetupRECTXY(pSingleCMD, width, height);
+        pSingleCMD++;    
+        ASTSetupCMDReg(pSingleCMD, cmdreg);        
+      
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+               
+    }
+    else
+    {                  
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupDSTXY_MMIO(x, y);
+        ASTSetupRECTXY_MMIO(width, height);
+        ASTSetupCMDReg_MMIO(cmdreg);        
+ 
+        vWaitEngIdle(pScrn, pAST);
+      
+    }
+
+            
+} /* end of ASTSubsequentSolidHorVertLine */
+
+static void ASTSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
+                                           int x1, int y1, int x2, int y2, int flags)
+{
+ 
+    ASTRecPtr 	pAST = ASTPTR(pScrn);
+    PKT_SC 	*pSingleCMD;
+    LINEPARAM   dsLineParam;
+    _LINEInfo   LineInfo; 
+    ULONG 	dstbase, ulCommand;
+    ULONG	miny, maxy;         
+    USHORT      usXM;
+/*
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidTwoPointLine\n");
+*/    
+
+    /* Modify Reg. Value */
+    ulCommand = (pAST->ulCMDReg & (~CMD_MASK)) | CMD_LINEDRAW;
+    if(flags & OMIT_LAST)
+        ulCommand |= CMD_NOT_DRAW_LAST_PIXEL;
+    else
+        ulCommand &= ~CMD_NOT_DRAW_LAST_PIXEL;
+    if (pAST->EnableClip)
+        ulCommand |= CMD_ENABLE_CLIP;
+    dstbase = 0;
+    miny = (y1 > y2) ? y2 : y1;
+    maxy = (y1 > y2) ? y1 : y2;
+    if(maxy >= pScrn->virtualY) {
+        dstbase = pAST->VideoModeInfo.ScreenPitch * miny;
+        y1 -= miny;
+        y2 -= miny;
+    }
+    
+    LineInfo.X1 = x1;
+    LineInfo.Y1 = y1;
+    LineInfo.X2 = x2;
+    LineInfo.Y2 = y2;
+          
+    bGetLineTerm(&LineInfo, &dsLineParam);		/* Get Line Parameter */
+    
+    if (dsLineParam.dwLineAttributes & LINEPARAM_X_DEC) 
+        ulCommand |= CMD_X_DEC; 
+    if (dsLineParam.dwLineAttributes & LINEPARAM_Y_DEC) 
+        ulCommand |= CMD_Y_DEC;             
+        
+    usXM = (dsLineParam.dwLineAttributes & LINEPARAM_XM) ? 1:0;    
+       
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*7);
+
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupLineXY(pSingleCMD, dsLineParam.dsLineX, dsLineParam.dsLineY);
+        pSingleCMD++;    
+        ASTSetupLineXMErrTerm(pSingleCMD, usXM , dsLineParam.dwErrorTerm);
+        pSingleCMD++; 
+        ASTSetupLineWidth(pSingleCMD, dsLineParam.dsLineWidth);
+        pSingleCMD++; 
+        ASTSetupLineK1Term(pSingleCMD, dsLineParam.dwK1Term);
+        pSingleCMD++; 
+        ASTSetupLineK2Term(pSingleCMD, dsLineParam.dwK2Term);
+        pSingleCMD++;                     
+        ASTSetupCMDReg(pSingleCMD, ulCommand);        
+              
+        /* Update Write Pointer */
+        mUpdateWritePointer;                
+        
+    }
+    else
+    {                  
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupLineXY_MMIO(dsLineParam.dsLineX, dsLineParam.dsLineY);
+        ASTSetupLineXMErrTerm_MMIO( usXM , dsLineParam.dwErrorTerm);
+        ASTSetupLineWidth_MMIO(dsLineParam.dsLineWidth);
+        ASTSetupLineK1Term_MMIO(dsLineParam.dwK1Term);
+        ASTSetupLineK2Term_MMIO(dsLineParam.dwK2Term);
+        ASTSetupCMDReg_MMIO(ulCommand);        
+             
+        vWaitEngIdle(pScrn, pAST);
+      
+    }
+
+                
+} /* end of ASTSubsequentSolidTwoPointLine */
+
+/* Dash Line */
+static void
+ASTSetupForDashedLine(ScrnInfoPtr pScrn,
+                      int fg, int bg, int rop, unsigned int planemask,
+                      int length, UCHAR *pattern)
+{
+
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG  cmdreg;
+/*
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForDashedLine\n");
+*/  
+    /* Modify Reg. Value */
+    cmdreg = CMD_LINEDRAW | CMD_RESET_STYLE_COUNTER | CMD_ENABLE_LINE_STYLE;
+    
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAAPatternROP[rop] << 8);  
+    if(bg == -1) {
+        cmdreg |= CMD_TRANSPARENT;    
+        bg = 0;
+    }
+    cmdreg |= (((length-1) & 0x3F) << 24);		/* line period */
+    pAST->ulCMDReg = cmdreg;
+     
+    if (!pAST->MMIO2D)
+    {   
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*5);
+
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+        pSingleCMD++;
+        ASTSetupFG(pSingleCMD, fg);  
+        pSingleCMD++;
+        ASTSetupBG(pSingleCMD, bg); 
+        pSingleCMD++;
+        ASTSetupLineStyle1(pSingleCMD, *pattern);
+        pSingleCMD++;
+        ASTSetupLineStyle2(pSingleCMD, *(pattern+4));                   
+                       
+    }
+    else
+    {
+        /* Write to MMIO */   
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+        ASTSetupFG_MMIO(fg);  
+        ASTSetupBG_MMIO(bg); 
+        ASTSetupLineStyle1_MMIO(*pattern);
+        ASTSetupLineStyle2_MMIO(*(pattern+4));                
+
+    }
+                                 	
+}
+
+static void
+ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn,
+                                int x1, int y1, int x2, int y2,
+                                int flags, int phase)
+{
+ 
+    ASTRecPtr 	pAST = ASTPTR(pScrn);
+    PKT_SC 	*pSingleCMD;
+    LINEPARAM   dsLineParam;
+    _LINEInfo   LineInfo; 
+    ULONG 	dstbase, ulCommand; 
+    ULONG	miny, maxy;  
+    USHORT      usXM;
+/*
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentDashedTwoPointLine\n");
+*/   
+
+    /* Modify Reg. Value */
+    ulCommand = pAST->ulCMDReg;
+    if(flags & OMIT_LAST)
+        ulCommand |= CMD_NOT_DRAW_LAST_PIXEL;
+    else
+        ulCommand &= ~CMD_NOT_DRAW_LAST_PIXEL;
+    if (pAST->EnableClip)
+        ulCommand |= CMD_ENABLE_CLIP;
+    dstbase = 0;        
+    miny = (y1 > y2) ? y2 : y1;
+    maxy = (y1 > y2) ? y1 : y2;
+    if(maxy >= pScrn->virtualY) {
+        dstbase = pAST->VideoModeInfo.ScreenPitch * miny;
+        y1 -= miny;
+        y2 -= miny;
+    }
+
+    LineInfo.X1 = x1;
+    LineInfo.Y1 = y1;
+    LineInfo.X2 = x2;
+    LineInfo.Y2 = y2;
+               
+    bGetLineTerm(&LineInfo, &dsLineParam);		/* Get Line Parameter */
+    
+    if (dsLineParam.dwLineAttributes & LINEPARAM_X_DEC) 
+        ulCommand |= CMD_X_DEC; 
+    if (dsLineParam.dwLineAttributes & LINEPARAM_Y_DEC) 
+        ulCommand |= CMD_Y_DEC;             
+        
+    usXM = (dsLineParam.dwLineAttributes & LINEPARAM_XM) ? 1:0;    
+       
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*7);
+
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupLineXY(pSingleCMD, dsLineParam.dsLineX, dsLineParam.dsLineY);
+        pSingleCMD++;    
+        ASTSetupLineXMErrTerm(pSingleCMD, usXM , dsLineParam.dwErrorTerm);
+        pSingleCMD++; 
+        ASTSetupLineWidth(pSingleCMD, dsLineParam.dsLineWidth);
+        pSingleCMD++; 
+        ASTSetupLineK1Term(pSingleCMD, dsLineParam.dwK1Term);
+        pSingleCMD++; 
+        ASTSetupLineK2Term(pSingleCMD, dsLineParam.dwK2Term);
+        pSingleCMD++;                     
+        ASTSetupCMDReg(pSingleCMD, ulCommand);         
+              
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+              
+    }
+    else
+    {                  
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupLineXY_MMIO(dsLineParam.dsLineX, dsLineParam.dsLineY);
+        ASTSetupLineXMErrTerm_MMIO( usXM , dsLineParam.dwErrorTerm);
+        ASTSetupLineWidth_MMIO(dsLineParam.dsLineWidth);
+        ASTSetupLineK1Term_MMIO(dsLineParam.dwK1Term);
+        ASTSetupLineK2Term_MMIO(dsLineParam.dwK2Term);
+        ASTSetupCMDReg_MMIO(ulCommand);        
+       
+        vWaitEngIdle(pScrn, pAST);
+      
+    }
+                	
+}
+
+/* Mono Pattern Fill */
+static void
+ASTSetupForMonoPatternFill(ScrnInfoPtr pScrn,
+                           int patx, int paty, int fg, int bg,
+                           int rop, unsigned int planemask)
+{
+	
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG cmdreg;
+
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForMonoPatternFill\n");
+*/            
+    /* Modify Reg. Value */
+    cmdreg = CMD_BITBLT | CMD_PAT_MONOMASK;
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAAPatternROP[rop] << 8);
+    pAST->ulCMDReg = cmdreg;
+            
+    if (!pAST->MMIO2D)                    
+    {
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*5);
+
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+        pSingleCMD++;
+        ASTSetupFG(pSingleCMD, fg);  
+        pSingleCMD++;
+        ASTSetupBG(pSingleCMD, bg);
+        pSingleCMD++;
+        ASTSetupMONO1(pSingleCMD, patx);  
+        pSingleCMD++;
+        ASTSetupMONO2(pSingleCMD, paty);                           
+    }
+    else
+    {
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+        ASTSetupFG_MMIO(fg);   
+        ASTSetupBG_MMIO(bg);
+        ASTSetupMONO1_MMIO(patx);  
+        ASTSetupMONO2_MMIO(paty);                     	
+    }
+           	
+} /* end of ASTSetupForMonoPatternFill */
+
+                      
+static void
+ASTSubsequentMonoPatternFill(ScrnInfoPtr pScrn,
+                             int patx, int paty,
+                             int dst_x, int dst_y, int width, int height)
+{
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG dstbase, cmdreg;        
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentMonoPatternFill\n");
+*/    
+            
+    /* Modify Reg. Value */
+    cmdreg = pAST->ulCMDReg;
+    if (pAST->EnableClip)
+        cmdreg |= CMD_ENABLE_CLIP;    
+    dstbase = 0;
+
+    if (dst_y >= pScrn->virtualY) 
+    {   
+        dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+        dst_y=0;
+    }
+                  
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+        pSingleCMD++;    
+        ASTSetupRECTXY(pSingleCMD, width, height);
+        pSingleCMD++;    
+        ASTSetupCMDReg(pSingleCMD, cmdreg);        
+      
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+              
+    }
+    else
+    {                  
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupDSTXY_MMIO(dst_x, dst_y);
+        ASTSetupRECTXY_MMIO(width, height);
+        ASTSetupCMDReg_MMIO(cmdreg);        
+ 
+        vWaitEngIdle(pScrn, pAST);      
+    }	
+
+} /* end of ASTSubsequentMonoPatternFill */
+
+static void
+ASTSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
+			       int rop, unsigned int planemask, int trans_col)
+{
+	
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG cmdreg;
+    CARD32 *pataddr;
+    ULONG ulPatSize;
+    int i, j, cpp;
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForColor8x8PatternFill\n");
+*/            
+    /* Modify Reg. Value */
+    cmdreg = CMD_BITBLT | CMD_PAT_PATREG;
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAAPatternROP[rop] << 8);
+    pAST->ulCMDReg = cmdreg;
+    cpp = (pScrn->bitsPerPixel + 1) / 8;
+    pataddr = (CARD32 *)(pAST->FBVirtualAddr +
+                        (paty * pAST->VideoModeInfo.ScreenWidth) + (patx * cpp));   
+    ulPatSize = 8*8*cpp;
+                
+    if (!pAST->MMIO2D)                    
+    {
+        /* Write to CMDQ */        
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*(1 + ulPatSize/4));
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+        pSingleCMD++;
+        for (i=0; i<8; i++)
+        {
+            for (j=0; j<8*cpp/4; j++)
+            {
+                ASTSetupPatReg(pSingleCMD, (i*j + j) , (*(CARD32 *) (pataddr++)));
+                pSingleCMD++;                	
+            }	
+        }                
+    }
+    else
+    {    	
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+        for (i=0; i<8; i++)
+        {
+            for (j=0; j<8*cpp/4; j++)
+            {
+                ASTSetupPatReg_MMIO((i*j + j) , (*(CARD32 *) (pataddr++)));
+            }	
+        }                
+             	
+    }
+
+} /* end of ASTSetupForColor8x8PatternFill */
+		       
+static void
+ASTSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty,
+                                     int dst_x, int dst_y, int width, int height)
+{
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG dstbase, cmdreg;        
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentColor8x8PatternFillRect\n");
+*/
+            
+    /* Modify Reg. Value */
+    cmdreg = pAST->ulCMDReg;
+    if (pAST->EnableClip)
+        cmdreg |= CMD_ENABLE_CLIP;    
+    dstbase = 0;
+
+    if (dst_y >= pScrn->virtualY) 
+    {   
+        dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+        dst_y=0;
+    }
+                  
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+        pSingleCMD++;    
+        ASTSetupRECTXY(pSingleCMD, width, height);
+        pSingleCMD++;    
+        ASTSetupCMDReg(pSingleCMD, cmdreg);        
+      
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+                
+    }
+    else
+    {                  
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupDSTXY_MMIO(dst_x, dst_y);
+        ASTSetupRECTXY_MMIO(width, height);
+        ASTSetupCMDReg_MMIO(cmdreg);        
+ 
+        vWaitEngIdle(pScrn, pAST);      
+    }	
+	
+} /* ASTSubsequentColor8x8PatternFillRect */
+
+/* CPU to Screen Expand */
+static void
+ASTSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                      int fg, int bg,
+                                      int rop, unsigned int planemask)
+{
+
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG cmdreg;
+
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForCPUToScreenColorExpandFill\n");
+*/           
+    /* Modify Reg. Value */
+    cmdreg = CMD_COLOREXP;
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAAPatternROP[rop] << 8);
+    if(bg == -1) {
+        cmdreg |= CMD_FONT_TRANSPARENT;    
+        bg = 0;
+    }    
+    pAST->ulCMDReg = cmdreg;
+            
+    if (!pAST->MMIO2D)                    
+    {
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*3);
+
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+        pSingleCMD++;
+        ASTSetupFG(pSingleCMD, fg);  
+        pSingleCMD++;
+        ASTSetupBG(pSingleCMD, bg); 
+       
+    }
+    else
+    {
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+        ASTSetupFG_MMIO(fg); 
+        ASTSetupBG_MMIO(bg); 
+                   	
+    }
+           	
+}
+                               
+static void
+ASTSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                        int dst_x, int dst_y,
+                                        int width, int height, int offset)
+{
+
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG dstbase, cmdreg;
+
+/*           
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentCPUToScreenColorExpandFill\n");
+*/
+            
+    /* Modify Reg. Value */
+    cmdreg = pAST->ulCMDReg;
+    if (pAST->EnableClip)
+        cmdreg |= CMD_ENABLE_CLIP;    
+    dstbase = 0;
+
+    if (dst_y >= pScrn->virtualY) 
+    {   
+        dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+        dst_y=0;
+    }
+                  
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*5);
+
+        ASTSetupSRCPitch(pSingleCMD, ((width+7)/8));  
+        pSingleCMD++;    
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+        pSingleCMD++;    
+        ASTSetupRECTXY(pSingleCMD, width, height);
+        pSingleCMD++;    
+        ASTSetupCMDReg(pSingleCMD, cmdreg);        
+      
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+               
+    }
+    else
+    {  
+        ASTSetupSRCPitch_MMIO((width+7)/8);      	                
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupDSTXY_MMIO(dst_x, dst_y);
+        ASTSetupSRCXY_MMIO(0, 0);
+        
+        ASTSetupRECTXY_MMIO(width, height);
+        ASTSetupCMDReg_MMIO(cmdreg);        
+ 
+        vWaitEngIdle(pScrn, pAST);
+      
+    }
+    	
+}
+
+
+/* Screen to Screen Color Expand */
+static void
+ASTSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                         int fg, int bg,
+                                         int rop, unsigned int planemask)
+{
+
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG cmdreg;
+
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForScreenToScreenColorExpandFill\n");
+*/
+           
+    /* Modify Reg. Value */
+    cmdreg = CMD_ENHCOLOREXP;
+    switch (pAST->VideoModeInfo.bitsPerPixel)
+    {
+    case 8:
+        cmdreg |= CMD_COLOR_08;
+        break;
+    case 15:
+    case 16:
+        cmdreg |= CMD_COLOR_16;
+        break;    
+    case 24:
+    case 32:
+        cmdreg |= CMD_COLOR_32;
+        break;    	
+    }
+    cmdreg |= (ASTXAAPatternROP[rop] << 8);
+    if(bg == -1) {
+        cmdreg |= CMD_FONT_TRANSPARENT;    
+        bg = 0;
+    }    
+    pAST->ulCMDReg = cmdreg;
+            
+    if (!pAST->MMIO2D)                    
+    {
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*3);
+
+        ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+        pSingleCMD++;
+        ASTSetupFG(pSingleCMD, fg);  
+        pSingleCMD++;
+        ASTSetupBG(pSingleCMD, bg); 
+       
+    }
+    else
+    {
+        ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+        ASTSetupFG_MMIO(fg); 
+        ASTSetupBG_MMIO(bg); 
+                   	
+    }
+           	
+}
+
+
+
+static void
+ASTSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+                                           int dst_x, int dst_y, int width, int height,
+                                           int src_x, int src_y, int offset)
+{
+   ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+    ULONG srcbase, dstbase, cmdreg;
+    USHORT srcpitch;
+
+/*           
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentScreenToScreenColorExpandFill\n");
+*/
+            
+    /* Modify Reg. Value */
+    cmdreg = pAST->ulCMDReg;
+    if (pAST->EnableClip)
+        cmdreg |= CMD_ENABLE_CLIP;    
+    dstbase = 0;
+    if (dst_y >= pScrn->virtualY) 
+    {   
+        dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+        dst_y=0;
+    }
+    srcbase = pAST->VideoModeInfo.ScreenPitch*src_y + ((pScrn->bitsPerPixel+1)/8)*src_x;            
+    srcpitch = (pScrn->displayWidth+7)/8;
+    
+    if (!pAST->MMIO2D)                    
+    {                  
+        /* Write to CMDQ */    
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*6);
+
+        ASTSetupSRCBase(pSingleCMD, srcbase);
+        pSingleCMD++;  
+        ASTSetupSRCPitch(pSingleCMD,srcpitch);  
+        pSingleCMD++;    
+        ASTSetupDSTBase(pSingleCMD, dstbase);
+        pSingleCMD++;    
+        ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+        pSingleCMD++;    
+        ASTSetupRECTXY(pSingleCMD, width, height);
+        pSingleCMD++;    
+        ASTSetupCMDReg(pSingleCMD, cmdreg);        
+      
+        /* Update Write Pointer */
+        mUpdateWritePointer;
+       
+    }
+    else
+    { 
+        ASTSetupSRCBase_MMIO(srcbase);    	 
+        ASTSetupSRCPitch_MMIO(srcpitch);      	                
+        ASTSetupDSTBase_MMIO(dstbase);
+        ASTSetupDSTXY_MMIO(dst_x, dst_y);
+        ASTSetupRECTXY_MMIO(width, height);
+        ASTSetupCMDReg_MMIO(cmdreg);        
+ 
+        vWaitEngIdle(pScrn, pAST);
+      
+    }
+		
+}
+
+	  
+/* Clipping */
+static void
+ASTSetClippingRectangle(ScrnInfoPtr pScrn,
+                        int left, int top, int right, int bottom)
+{
+	
+    ASTRecPtr pAST = ASTPTR(pScrn);
+    PKT_SC *pSingleCMD;
+/*            
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetClippingRectangle\n");
+*/            
+    pAST->EnableClip = TRUE;
+            
+    if (!pAST->MMIO2D)                    
+    {
+        /* Write to CMDQ */
+        pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*2);
+
+        ASTSetupCLIP1(pSingleCMD, left, top);
+        pSingleCMD++;
+        ASTSetupCLIP2(pSingleCMD, right, bottom);                 
+    }
+    else
+    {
+        ASTSetupCLIP1_MMIO(left, top);
+        ASTSetupCLIP2_MMIO(right, bottom);                   	
+    }
+    
+}
+
+static void
+ASTDisableClipping(ScrnInfoPtr pScrn)
+{
+    ASTRecPtr pAST = ASTPTR(pScrn);
+/*    
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTDisableClipping\n");
+*/    
+    pAST->EnableClip = FALSE;
+}
+
+                                         
+#endif	/* end of Accel_2D */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_cursor.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+#include "cursorstr.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+#ifdef	HWC
+/* Prototype type declaration */
+Bool ASTCursorInit(ScreenPtr pScreen);
+Bool bInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+static void ASTShowCursor(ScrnInfoPtr pScrn); 
+static void ASTHideCursor(ScrnInfoPtr pScrn);
+static void ASTSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static void ASTSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+static void ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src);
+static Bool ASTUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs);
+static void ASTLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs);
+static Bool ASTUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs);
+
+static void ASTFireCursor(ScrnInfoPtr pScrn); 
+
+Bool
+ASTCursorInit(ScreenPtr pScreen)
+{
+    ScrnInfoPtr	pScrn = xf86Screens[pScreen->myNum];
+    ASTRecPtr 	pAST = ASTPTR(pScrn);
+    xf86CursorInfoPtr infoPtr;
+
+    infoPtr = xf86CreateCursorInfoRec();
+    if(!infoPtr) return FALSE;
+
+    pAST->HWCInfoPtr = infoPtr;
+
+    infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+                     HARDWARE_CURSOR_INVERT_MASK |        
+                     HARDWARE_CURSOR_BIT_ORDER_MSBFIRST;
+
+    infoPtr->MaxWidth  = MAX_HWC_WIDTH;
+    infoPtr->MaxHeight = MAX_HWC_HEIGHT;
+    infoPtr->ShowCursor = ASTShowCursor;
+    infoPtr->HideCursor = ASTHideCursor;
+    infoPtr->SetCursorPosition = ASTSetCursorPosition;
+    infoPtr->SetCursorColors = ASTSetCursorColors;
+    infoPtr->LoadCursorImage = ASTLoadCursorImage;
+    infoPtr->UseHWCursor = ASTUseHWCursor;
+#ifdef ARGB_CURSOR
+    infoPtr->UseHWCursorARGB = ASTUseHWCursorARGB;
+    infoPtr->LoadCursorARGB = ASTLoadCursorARGB;
+#endif
+
+    return(xf86InitCursor(pScreen, infoPtr));
+    
+}
+
+Bool bInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST)
+{
+    ScreenPtr	pScreen;
+
+    /* init cursor cache info */
+    /* Set HWC_NUM in Options instead */ 
+    /* pAST->HWCInfo.HWC_NUM = DEFAULT_HWC_NUM; */
+    pAST->HWCInfo.HWC_NUM_Next = 0;    
+      	
+    /* allocate HWC cache */  
+    if (!pAST->pHWCPtr) {   	    		       
+        pScreen = screenInfo.screens[pScrn->scrnIndex];
+        pAST->pHWCPtr = xf86AllocateOffscreenLinear (pScreen, (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM, HWC_ALIGN, NULL, NULL, NULL);
+
+        if (!pAST->pHWCPtr) {   		  
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Allocate HWC Cache failed \n");
+           return (FALSE);
+        }
+        
+        pAST->HWCInfo.ulHWCOffsetAddr  = pAST->pHWCPtr->offset*((pScrn->bitsPerPixel + 1) / 8);
+        pAST->HWCInfo.pjHWCVirtualAddr = pAST->FBVirtualAddr + pAST->HWCInfo.ulHWCOffsetAddr;                
+    }
+
+    return (TRUE);	
+}
+
+
+static void
+ASTShowCursor(ScrnInfoPtr pScrn)
+{
+    ASTRecPtr   pAST = ASTPTR(pScrn);    
+    UCHAR 	jReg;
+
+    jReg= 0x02;
+    if (pAST->HWCInfo.cursortype ==HWC_COLOR)
+        jReg |= 0x01;
+               
+    SetIndexRegMask(CRTC_PORT, 0xCB, 0xFC, jReg);	/* enable mono */ 	
+    
+}
+
+static void
+ASTHideCursor(ScrnInfoPtr pScrn)
+{
+    ASTRecPtr  pAST = ASTPTR(pScrn);
+        
+    SetIndexRegMask(CRTC_PORT, 0xCB, 0xFC, 0x00);	/* disable HWC */ 	
+        
+}
+
+static void
+ASTSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+    ASTRecPtr	pAST = ASTPTR(pScrn);
+    DisplayModePtr mode = pAST->ModePtr;    
+    int		x_offset, y_offset;
+    UCHAR 	*pjSignature;    
+       
+    /* Set cursor info to Offscreen */    
+    pjSignature = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE;   
+    *((ULONG *) (pjSignature + HWC_SIGNATURE_X)) = x;
+    *((ULONG *) (pjSignature + HWC_SIGNATURE_Y)) = y;
+               
+    x_offset = pAST->HWCInfo.offset_x;
+    y_offset = pAST->HWCInfo.offset_y;
+    
+    if(x < 0) {
+       x_offset = (-x) + pAST->HWCInfo.offset_x;
+       x = 0;
+    }
+
+    if(y < 0) {
+       y_offset = (-y) + pAST->HWCInfo.offset_y;
+       y = 0;
+    }
+
+    if(mode->Flags & V_DBLSCAN)  y *= 2;
+ 
+    /* Set to Reg. */
+    SetIndexReg(CRTC_PORT, 0xC2, (UCHAR) (x_offset)); 	
+    SetIndexReg(CRTC_PORT, 0xC3, (UCHAR) (y_offset)); 	
+    SetIndexReg(CRTC_PORT, 0xC4, (UCHAR) (x & 0xFF)); 	
+    SetIndexReg(CRTC_PORT, 0xC5, (UCHAR) ((x >> 8) & 0x0F)); 	
+    SetIndexReg(CRTC_PORT, 0xC6, (UCHAR) (y & 0xFF)); 	
+    SetIndexReg(CRTC_PORT, 0xC7, (UCHAR) ((y >> 8) & 0x07)); 	
+    
+    /* Fire HWC */
+    ASTFireCursor(pScrn);
+        
+}  
+
+static void
+ASTSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+    ASTRecPtr 	pAST = ASTPTR(pScrn);
+    
+    pAST->HWCInfo.fg = (fg & 0x0F) | (((fg>>8) & 0x0F) << 4) | (((fg>>16) & 0x0F) << 8);
+    pAST->HWCInfo.bg = (bg & 0x0F) | (((bg>>8) & 0x0F) << 4) | (((bg>>16) & 0x0F) << 8);    
+}
+
+static void
+ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src)
+{
+    ASTRecPtr	pAST = ASTPTR(pScrn);   
+    int 	i, j, k;
+    UCHAR 	*pjSrcAnd, *pjSrcXor, *pjDstData;
+    ULONG   	ulTempDstAnd32[2], ulTempDstXor32[2], ulTempDstData32[2];
+    UCHAR    	jTempSrcAnd32, jTempSrcXor32;
+    ULONG	ulCheckSum = 0;  		               
+    ULONG 	ulPatternAddr;    
+       
+    /* init cursor info. */
+    pAST->HWCInfo.cursortype = HWC_MONO;
+    pAST->HWCInfo.width  = (USHORT) MAX_HWC_WIDTH;
+    pAST->HWCInfo.height = (USHORT) MAX_HWC_HEIGHT;
+    pAST->HWCInfo.offset_x = MAX_HWC_WIDTH - pAST->HWCInfo.width;
+    pAST->HWCInfo.offset_y = MAX_HWC_HEIGHT - pAST->HWCInfo.height;
+
+    /* copy cursor image to cache */
+    pjSrcXor = src;
+    pjSrcAnd = src + (MAX_HWC_WIDTH*MAX_HWC_HEIGHT/8);
+    pjDstData =  pAST->HWCInfo.pjHWCVirtualAddr+(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next;
+      
+    for (j = 0; j < MAX_HWC_HEIGHT; j++)
+    {
+       for (i = 0; i < (MAX_HWC_WIDTH/8); i++ )
+       {
+       	    for (k=7; k>0; k-=2)
+       	    {
+                jTempSrcAnd32 = *((UCHAR *) pjSrcAnd);
+                jTempSrcXor32 = *((UCHAR *) pjSrcXor);   
+                ulTempDstAnd32[0] = ((jTempSrcAnd32 >> k) & 0x01) ? 0x00008000L:0x00L;   
+                ulTempDstXor32[0] = ((jTempSrcXor32 >> k) & 0x01) ? 0x00004000L:0x00L;                   	                                  	                 
+                ulTempDstData32[0] = ((jTempSrcXor32 >> k) & 0x01) ? pAST->HWCInfo.fg:pAST->HWCInfo.bg;                   	                                  	                                                   
+                ulTempDstAnd32[1] = ((jTempSrcAnd32 >> (k-1)) & 0x01) ? 0x80000000L:0x00L;   
+                ulTempDstXor32[1] = ((jTempSrcXor32 >> (k-1)) & 0x01) ? 0x40000000L:0x00L;                   	                                  	  
+                ulTempDstData32[1] = ((jTempSrcXor32 >> (k-1)) & 0x01) ? (pAST->HWCInfo.fg << 16):(pAST->HWCInfo.bg << 16);
+                *((ULONG *) pjDstData) = ulTempDstAnd32[0] | ulTempDstXor32[0] | ulTempDstData32[0] | ulTempDstAnd32[1] | ulTempDstXor32[1] | ulTempDstData32[1];
+                ulCheckSum += *((ULONG *) pjDstData);                               
+                pjDstData += 4;
+
+            }
+            pjSrcAnd ++;
+            pjSrcXor ++;
+             
+       }        
+        
+    }        		    
+
+    /* Write Checksum as signature */
+    pjDstData = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE;   
+    *((ULONG *) pjDstData) = ulCheckSum;
+    *((ULONG *) (pjDstData + HWC_SIGNATURE_SizeX)) = pAST->HWCInfo.width;
+    *((ULONG *) (pjDstData + HWC_SIGNATURE_SizeY)) = pAST->HWCInfo.height;
+    *((ULONG *) (pjDstData + HWC_SIGNATURE_HOTSPOTX)) = 0;
+    *((ULONG *) (pjDstData + HWC_SIGNATURE_HOTSPOTY)) = 0;
+    
+    /* set pattern offset */
+    ulPatternAddr = ((pAST->HWCInfo.ulHWCOffsetAddr+(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next) >> 3);
+    SetIndexReg(CRTC_PORT, 0xC8, (UCHAR) (ulPatternAddr & 0xFF)); 	
+    SetIndexReg(CRTC_PORT, 0xC9, (UCHAR) ((ulPatternAddr >> 8) & 0xFF)); 	
+    SetIndexReg(CRTC_PORT, 0xCA, (UCHAR) ((ulPatternAddr >> 16) & 0xFF)); 
+    
+    /* update HWC_NUM_Next */
+    pAST->HWCInfo.HWC_NUM_Next = (pAST->HWCInfo.HWC_NUM_Next+1) % pAST->HWCInfo.HWC_NUM;
+        	    
+}
+
+static Bool 
+ASTUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
+{
+    return TRUE;
+}
+
+static void
+ASTLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs)
+{
+    ASTRecPtr 	pAST = ASTPTR(pScrn);   
+
+    UCHAR	*pjDstXor, *pjSrcXor;
+    ULONG       i, j, ulSrcWidth, ulSrcHeight;
+    ULONG	ulPerPixelCopy, ulTwoPixelCopy;    
+    LONG        lAlphaDstDelta, lLastAlphaDstDelta;
+    union
+    {
+        ULONG   ul;
+        UCHAR   b[4];
+    } ulSrcData32[2], ulData32;    
+    union
+    {
+        USHORT  us;
+        UCHAR   b[2];
+    } usData16;
+    ULONG	ulCheckSum = 0;  		           
+    ULONG 	ulPatternAddr;
+ 
+    /* init cursor info. */
+    pAST->HWCInfo.cursortype = HWC_COLOR;
+    pAST->HWCInfo.width  = pCurs->bits->width;
+    pAST->HWCInfo.height = pCurs->bits->height;
+    pAST->HWCInfo.offset_x = MAX_HWC_WIDTH - pAST->HWCInfo.width;
+    pAST->HWCInfo.offset_y = MAX_HWC_HEIGHT - pAST->HWCInfo.height;
+    
+    /* copy cursor image to cache */
+    ulSrcWidth  =  pAST->HWCInfo.width;  
+    ulSrcHeight =  pAST->HWCInfo.height;  
+        
+    lAlphaDstDelta = MAX_HWC_WIDTH << 1;
+    lLastAlphaDstDelta = lAlphaDstDelta - (ulSrcWidth << 1);
+
+    pjSrcXor  = (UCHAR *) pCurs->bits->argb;;
+    pjDstXor  = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next
+                        + lLastAlphaDstDelta + (MAX_HWC_HEIGHT - ulSrcHeight) * lAlphaDstDelta;
+    
+    ulPerPixelCopy =  ulSrcWidth & 1;
+    ulTwoPixelCopy =  ulSrcWidth >> 1;
+                   
+    for (j = 0; j < ulSrcHeight; j++)
+    {
+
+        for (i = 0; i < ulTwoPixelCopy; i++ )
+        {
+            ulSrcData32[0].ul = *((ULONG *) pjSrcXor) & 0xF0F0F0F0;
+            ulSrcData32[1].ul = *((ULONG *) (pjSrcXor+4)) & 0xF0F0F0F0;
+            ulData32.b[0] = ulSrcData32[0].b[1] | (ulSrcData32[0].b[0] >> 4);
+            ulData32.b[1] = ulSrcData32[0].b[3] | (ulSrcData32[0].b[2] >> 4);
+            ulData32.b[2] = ulSrcData32[1].b[1] | (ulSrcData32[1].b[0] >> 4);
+            ulData32.b[3] = ulSrcData32[1].b[3] | (ulSrcData32[1].b[2] >> 4);                     
+            *((ULONG *) pjDstXor) = ulData32.ul;
+            ulCheckSum += (ULONG) ulData32.ul;                                     
+            pjDstXor += 4;
+            pjSrcXor += 8;
+        } 
+        
+        for (i = 0; i < ulPerPixelCopy; i++ )
+        {
+            ulSrcData32[0].ul = *((ULONG *) pjSrcXor) & 0xF0F0F0F0;
+            usData16.b[0] = ulSrcData32[0].b[1] | (ulSrcData32[0].b[0] >> 4);
+            usData16.b[1] = ulSrcData32[0].b[3] | (ulSrcData32[0].b[2] >> 4);
+            *((USHORT *) pjDstXor) = usData16.us;
+            ulCheckSum += (ULONG) usData16.us;                                                 
+            pjDstXor += 2;
+            pjSrcXor += 4;
+        } 
+
+        /* Point to next source and dest scans */
+        pjDstXor += lLastAlphaDstDelta;
+        
+    } /* end of for-loop */
+
+    /* Write Checksum as signature */
+    pjDstXor = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE;   
+    *((ULONG *) pjDstXor) = ulCheckSum;
+    *((ULONG *) (pjDstXor + HWC_SIGNATURE_SizeX)) = pAST->HWCInfo.width;
+    *((ULONG *) (pjDstXor + HWC_SIGNATURE_SizeY)) = pAST->HWCInfo.height;
+    *((ULONG *) (pjDstXor + HWC_SIGNATURE_HOTSPOTX)) = 0;
+    *((ULONG *) (pjDstXor + HWC_SIGNATURE_HOTSPOTY)) = 0;
+           
+    /* set pattern offset */
+    ulPatternAddr = ((pAST->HWCInfo.ulHWCOffsetAddr +(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next) >> 3);
+    SetIndexReg(CRTC_PORT, 0xC8, (UCHAR) (ulPatternAddr & 0xFF)); 	
+    SetIndexReg(CRTC_PORT, 0xC9, (UCHAR) ((ulPatternAddr >> 8) & 0xFF)); 	
+    SetIndexReg(CRTC_PORT, 0xCA, (UCHAR) ((ulPatternAddr >> 16) & 0xFF)); 
+    
+    /* update HWC_NUM_Next */
+    pAST->HWCInfo.HWC_NUM_Next = (pAST->HWCInfo.HWC_NUM_Next+1) % pAST->HWCInfo.HWC_NUM;
+    
+}
+
+static Bool 
+ASTUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
+{
+    return TRUE;
+}
+
+static void
+ASTFireCursor(ScrnInfoPtr pScrn)
+{
+    ASTRecPtr  pAST = ASTPTR(pScrn);
+    
+    SetIndexRegMask(CRTC_PORT, 0xCB, 0xFF, 0x00);	/* dummp write to fire HWC */ 	
+    
+}
+
+#endif	/* End of HWC */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_cursor.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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	MAX_HWC_WIDTH		64
+#define	MAX_HWC_HEIGHT		64
+#define HWC_SIZE		(MAX_HWC_WIDTH*MAX_HWC_HEIGHT*2)
+#define	HWC_SIGNATURE_SIZE	32
+#define	HWC_ALIGN		32
+
+#define HWC_MONO		0
+#define HWC_COLOR		1
+
+/* define for signature structure */
+#define HWC_SIGNATURE_CHECKSUM	0x00
+#define HWC_SIGNATURE_SizeX     0x04
+#define HWC_SIGNATURE_SizeY     0x08
+#define HWC_SIGNATURE_X         0x0C
+#define HWC_SIGNATURE_Y         0x10
+#define HWC_SIGNATURE_HOTSPOTX  0x14
+#define HWC_SIGNATURE_HOTSPOTY  0x18
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_driver.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1221 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+/* external reference fucntion */
+extern Bool ASTMapMem(ScrnInfoPtr pScrn);
+extern Bool ASTUnmapMem(ScrnInfoPtr pScrn);
+extern Bool ASTMapMMIO(ScrnInfoPtr pScrn);
+extern void ASTUnmapMMIO(ScrnInfoPtr pScrn);
+
+extern void vASTOpenKey(ScrnInfoPtr pScrn);
+extern Bool bASTRegInit(ScrnInfoPtr pScrn);
+extern ULONG GetVRAMInfo(ScrnInfoPtr pScrn);
+extern ULONG GetMaxDCLK(ScrnInfoPtr pScrn);
+extern void vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual);
+extern void ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
+extern void vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base);
+extern Bool ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
+
+extern Bool bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+extern Bool bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+extern void vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+
+extern Bool ASTAccelInit(ScreenPtr pScreen);
+
+extern Bool ASTCursorInit(ScreenPtr pScreen);
+
+/* Mandatory functions */
+static void ASTIdentify(int flags);
+const OptionInfoRec *ASTAvailableOptions(int chipid, int busid);
+static Bool ASTProbe(DriverPtr drv, int flags);
+static Bool ASTPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool ASTScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv);
+Bool ASTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+void ASTAdjustFrame(int scrnIndex, int x, int y, int flags);
+static Bool ASTEnterVT(int scrnIndex, int flags);
+static void ASTLeaveVT(int scrnIndex, int flags);
+static void ASTFreeScreen(int scrnIndex, int flags);
+static ModeStatus ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags);
+
+/* Internally used functions */
+static Bool ASTGetRec(ScrnInfoPtr pScrn);
+static void ASTFreeRec(ScrnInfoPtr pScrn);
+static Bool ASTSaveScreen(ScreenPtr pScreen, Bool unblack);
+static Bool ASTCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static void ASTSave(ScrnInfoPtr pScrn);
+static void ASTRestore(ScrnInfoPtr pScrn);
+static void ASTProbeDDC(ScrnInfoPtr pScrn, int index);
+static xf86MonPtr ASTDoDDC(ScrnInfoPtr pScrn, int index);
+static void vFillASTModeInfo (ScrnInfoPtr pScrn);
+static Bool ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+
+/*
+ * This is intentionally screen-independent.  It indicates the binding
+ * choice made in the first PreInit.
+ */
+DriverRec AST = {
+   AST_VERSION,
+   AST_DRIVER_NAME,
+   ASTIdentify,
+   ASTProbe,
+   ASTAvailableOptions,
+   NULL,
+   0
+};
+
+/* Chipsets */
+static SymTabRec ASTChipsets[] = {
+   {PCI_CHIP_AST2000,	"AST2000"},
+   {-1,			NULL}
+};
+
+static PciChipsets ASTPciChipsets[] = {
+   {PCI_CHIP_AST2000,		PCI_CHIP_AST2000,	RES_SHARED_VGA},
+   {-1,				-1, 			RES_UNDEFINED }
+};
+
+typedef enum {
+   OPTION_NOACCEL,
+   OPTION_MMIO2D,   
+   OPTION_SW_CURSOR,
+   OPTION_HWC_NUM,
+   OPTION_ENG_CAPS,   
+   OPTION_DBG_SELECT,
+   OPTION_NO_DDC
+} ASTOpts;
+
+static const OptionInfoRec ASTOptions[] = {
+   {OPTION_NOACCEL,	"NoAccel",	OPTV_BOOLEAN,	{0},	FALSE},
+   {OPTION_MMIO2D,	"MMIO2D",	OPTV_BOOLEAN,	{0},	FALSE},   
+   {OPTION_SW_CURSOR,	"SWCursor",	OPTV_BOOLEAN,	{0},	FALSE},	
+   {OPTION_HWC_NUM,	"HWCNumber",	OPTV_INTEGER,	{0},	FALSE},
+   {OPTION_ENG_CAPS,	"ENGCaps",	OPTV_INTEGER,	{0},	FALSE},	          	  
+   {OPTION_DBG_SELECT,	"DBGSelect",	OPTV_INTEGER,	{0},	FALSE},	       
+   {OPTION_NO_DDC,	"NoDDC",	OPTV_BOOLEAN,	{0}, 	FALSE},   
+   {-1,			NULL,		OPTV_NONE,	{0}, 	FALSE}
+};
+
+const char *vgahwSymbols[] = {
+   "vgaHWFreeHWRec",
+   "vgaHWGetHWRec",
+   "vgaHWGetIOBase",
+   "vgaHWGetIndex",
+   "vgaHWInit",
+   "vgaHWLock",
+   "vgaHWMapMem",
+   "vgaHWProtect",
+   "vgaHWRestore",
+   "vgaHWSave",
+   "vgaHWSaveScreen",
+   "vgaHWSetMmioFuncs",
+   "vgaHWUnlock",
+   "vgaHWUnmapMem",
+   NULL
+};
+
+const char *fbSymbols[] = {
+   "fbPictureInit",
+   "fbScreenInit",
+   NULL
+};
+
+const char *vbeSymbols[] = {
+   "VBEInit",
+   "VBEFreeModeInfo",
+   "VBEFreeVBEInfo",
+   "VBEGetModeInfo",
+   "VBEGetModePool",
+   "VBEGetVBEInfo",
+   "VBEGetVBEMode",
+   "VBEPrintModes",
+   "VBESaveRestore",
+   "VBESetDisplayStart",
+   "VBESetGetDACPaletteFormat",
+   "VBESetGetLogicalScanlineLength",
+   "VBESetGetPaletteData",
+   "VBESetModeNames",
+   "VBESetModeParameters",
+   "VBESetVBEMode",
+   "VBEValidateModes",
+   "vbeDoEDID",
+   "vbeFree",
+   NULL
+};
+
+#ifdef XFree86LOADER
+static const char *vbeOptionalSymbols[] = {
+   "VBEDPMSSet",
+   "VBEGetPixelClock",
+   NULL
+};
+#endif
+
+const char *ddcSymbols[] = {
+   "xf86PrintEDID",
+   "xf86SetDDCproperties",
+   NULL
+};
+
+const char *int10Symbols[] = {
+   "xf86ExecX86int10",
+   "xf86InitInt10",
+   "xf86Int10AllocPages",
+   "xf86int10Addr",
+   NULL
+};
+
+const char *xaaSymbols[] = {
+   "XAACreateInfoRec",
+   "XAADestroyInfoRec",
+   "XAAInit",
+   "XAACopyROP",
+   "XAAPatternROP",
+   NULL
+};
+
+const char *ramdacSymbols[] = {
+   "xf86CreateCursorInfoRec",
+   "xf86DestroyCursorInfoRec",
+   "xf86InitCursor",
+   NULL
+};
+
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(astSetup);
+
+static XF86ModuleVersionInfo astVersRec = {
+   AST_DRIVER_NAME,
+   MODULEVENDORSTRING,
+   MODINFOSTRING1,
+   MODINFOSTRING2,
+   XORG_VERSION_CURRENT,
+   AST_MAJOR_VERSION, AST_MINOR_VERSION, AST_PATCH_VERSION,
+   ABI_CLASS_VIDEODRV,
+   ABI_VIDEODRV_VERSION,
+   MOD_CLASS_VIDEODRV,
+   {0, 0, 0, 0}
+};
+
+XF86ModuleData astModuleData = { &astVersRec, astSetup, NULL };
+
+static pointer
+astSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+   static Bool setupDone = FALSE;
+
+   /* This module should be loaded only once, but check to be sure.
+    */
+   if (!setupDone) {
+      setupDone = TRUE;
+      xf86AddDriver(&AST, module, 0);
+
+      /*
+       * Tell the loader about symbols from other modules that this module
+       * might refer to.
+       */
+      LoaderRefSymLists(vgahwSymbols,
+			fbSymbols, xaaSymbols, ramdacSymbols,
+			vbeSymbols, vbeOptionalSymbols,
+			ddcSymbols, int10Symbols, NULL);
+
+      /*
+       * The return value must be non-NULL on success even though there
+       * is no TearDownProc.
+       */
+      return (pointer) TRUE;
+   } else {
+      if (errmaj)
+	 *errmaj = LDR_ONCEONLY;
+      return NULL;
+   }
+}
+
+#endif	/* XFree86LOADER */
+
+/*
+ * ASTIdentify --
+ *
+ * Returns the string name for the driver based on the chipset. In this
+ * case it will always be an AST, so we can return a static string.
+ *
+ */
+static void
+ASTIdentify(int flags)
+{
+   xf86PrintChipsets(AST_NAME, "Driver for ASPEED Graphics Chipsets",
+		     ASTChipsets);
+}
+
+const OptionInfoRec *
+ASTAvailableOptions(int chipid, int busid)
+{
+	
+   return ASTOptions;
+
+}
+
+/*
+ * ASTProbe --
+ *
+ * Look through the PCI bus to find cards that are AST boards.
+ * Setup the dispatch table for the rest of the driver functions.
+ *
+ */
+static Bool
+ASTProbe(DriverPtr drv, int flags)
+{
+    int i, numUsed, numDevSections, *usedChips;
+    Bool foundScreen = FALSE;
+    GDevPtr *devSections;   
+
+   /*
+    * Find the config file Device sections that match this
+    * driver, and return if there are none.
+    */
+    if ((numDevSections =
+	xf86MatchDevice(AST_DRIVER_NAME, &devSections)) <= 0) {
+      return FALSE;
+    }
+
+   /*
+    * This probing is just checking the PCI data the server already
+    * collected.
+    */
+    if (xf86GetPciVideoInfo() == NULL) {
+	return FALSE;
+    }
+
+    numUsed = xf86MatchPciInstances(AST_NAME, PCI_VENDOR_AST,
+				   ASTChipsets, ASTPciChipsets,
+				   devSections, numDevSections,
+				   drv, &usedChips);
+
+    xfree(devSections);
+
+    if (flags & PROBE_DETECT) {
+        if (numUsed > 0)
+	    foundScreen = TRUE;
+    } else {
+        for (i = 0; i < numUsed; i++) {
+	    ScrnInfoPtr pScrn = NULL;
+
+	    /* Allocate new ScrnInfoRec and claim the slot */
+	    if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+					     ASTPciChipsets, 0, 0, 0, 0, 0)))
+            {
+	        EntityInfoPtr pEnt;
+
+	        pEnt = xf86GetEntityInfo(usedChips[i]);
+
+	        pScrn->driverVersion = AST_VERSION;
+	        pScrn->driverName = AST_DRIVER_NAME;
+	        pScrn->name = AST_NAME;
+	    
+	        pScrn->Probe = ASTProbe;
+	        pScrn->PreInit = ASTPreInit;
+	        pScrn->ScreenInit = ASTScreenInit;
+	        pScrn->SwitchMode = ASTSwitchMode;
+	        pScrn->AdjustFrame = ASTAdjustFrame;   
+	        pScrn->EnterVT = ASTEnterVT;
+	        pScrn->LeaveVT = ASTLeaveVT;
+	        pScrn->FreeScreen = ASTFreeScreen;
+	        pScrn->ValidMode = ASTValidMode;
+	    
+	        foundScreen = TRUE;	    
+
+	    } /* end of if */
+        }  /* end of for-loop */
+    } /* end of if flags */	   
+
+    xfree(usedChips);
+
+    return foundScreen;
+}
+
+/*
+ * ASTPreInit --
+ *
+ * Do initial setup of the board before we know what resolution we will
+ * be running at.
+ *
+ */
+static Bool
+ASTPreInit(ScrnInfoPtr pScrn, int flags)
+{
+   EntityInfoPtr pEnt;
+   vgaHWPtr hwp;
+   int flags24;
+   rgb defaultWeight = { 0, 0, 0 };
+      
+   ASTRecPtr pAST;
+   
+   ClockRangePtr clockRanges;
+   int i;
+   MessageType from;
+
+   /* Suport one adapter only now */
+   if (pScrn->numEntities != 1)
+       return FALSE;
+
+   pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+
+   if (flags & PROBE_DETECT) {
+       ASTProbeDDC(pScrn, pEnt->index);
+       return TRUE;
+   }
+
+   if (pEnt->location.type != BUS_PCI)
+       return FALSE;
+
+   if (xf86RegisterResources(pEnt->index, 0, ResExclusive))
+       return FALSE;
+
+   /* The vgahw module should be loaded here when needed */
+   if (!xf86LoadSubModule(pScrn, "vgahw"))
+      return FALSE;
+   xf86LoaderReqSymLists(vgahwSymbols, NULL);
+
+   /* The fb module should be loaded here when needed */
+   if (!xf86LoadSubModule(pScrn, "fb"))
+      return FALSE;
+   xf86LoaderReqSymLists(fbSymbols, NULL);      
+   	
+   /* Allocate a vgaHWRec */
+   if (!vgaHWGetHWRec(pScrn))
+       return FALSE;
+   hwp = VGAHWPTR(pScrn);
+
+   /* Color Depth Check */
+   flags24 = Support32bppFb;
+   if (!xf86SetDepthBpp(pScrn, 0, 0, 0, flags24)) {
+      return FALSE;
+   } else {
+      switch (pScrn->depth) {
+      case 8:
+      case 16:
+      case 24:
+	 break;
+      default:
+	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		    "Given depth (%d) is not supported by ast driver\n",
+		    pScrn->depth);
+	 return FALSE;
+      }
+   }
+   xf86PrintDepthBpp(pScrn);
+
+   switch (pScrn->bitsPerPixel) {
+   case 8:
+   case 16:
+   case 32:
+      break;
+   default:
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		 "Given bpp (%d) is not supported by ast driver\n",
+		 pScrn->bitsPerPixel);
+      return FALSE;
+   }
+   
+   /* fill pScrn misc. */
+   pScrn->progClock = TRUE;
+   pScrn->rgbBits = 6;
+   pScrn->monitor = pScrn->confScreen->monitor; /* should be initialized before set gamma */
+   pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
+   pScrn->racIoFlags = RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;   
+      
+   /*
+    * If the driver can do gamma correction, it should call xf86SetGamma()
+    * here.
+    */
+   {
+      Gamma zeros = { 0.0, 0.0, 0.0 };
+
+      if (!xf86SetGamma(pScrn, zeros)) {
+         xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "call xf86SetGamma failed \n");      	
+	 return FALSE;
+      }
+   }
+
+
+   if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) {
+       return FALSE;
+   }    
+
+   if (!xf86SetDefaultVisual(pScrn, -1)) {
+       return FALSE;
+   }      
+
+   /* Allocate driverPrivate */
+   if (!ASTGetRec(pScrn)) {
+       xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "call ASTGetRec failed \n");   	
+       return FALSE;
+   }    
+
+   /* Fill AST Info */
+   pAST = ASTPTR(pScrn);
+   pAST->pEnt    = xf86GetEntityInfo(pScrn->entityList[0]);
+   pAST->PciInfo = xf86GetPciInfoForEntity(pAST->pEnt->index);
+   pAST->PciTag  = pciTag(pAST->PciInfo->bus, pAST->PciInfo->device,
+			  pAST->PciInfo->func);
+
+   /* Process the options
+    * pScrn->confScreen, pScrn->display, pScrn->monitor, pScrn->numEntities, 
+    * and pScrn->entityList should be initialized before
+    */
+   xf86CollectOptions(pScrn, NULL);   
+   if (!(pAST->Options = xalloc(sizeof(ASTOptions))))
+   {  	
+      ASTFreeRec(pScrn);   	
+      return FALSE;
+   }      
+   memcpy(pAST->Options, ASTOptions, sizeof(ASTOptions));
+   xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pAST->Options);
+    
+   /*
+    * Set the Chipset and ChipRev, allowing config file entries to
+    * override.
+    */
+   if (pAST->pEnt->device->chipset && *pAST->pEnt->device->chipset) {
+      pScrn->chipset = pAST->pEnt->device->chipset;
+      from = X_CONFIG;
+   } else if (pAST->pEnt->device->chipID >= 0) {
+      pScrn->chipset = (char *)xf86TokenToString(ASTChipsets,
+						 pAST->pEnt->device->chipID);
+      from = X_CONFIG;
+      xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
+		 pAST->pEnt->device->chipID);
+   } else {
+      from = X_PROBED;
+      pScrn->chipset = (char *)xf86TokenToString(ASTChipsets,
+						 pAST->PciInfo->chipType);
+   }
+   if (pAST->pEnt->device->chipRev >= 0) {
+      xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
+		 pAST->pEnt->device->chipRev);
+   }
+
+   xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n",
+	      (pScrn->chipset != NULL) ? pScrn->chipset : "Unknown ast");
+
+   /* Resource Allocation */
+#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0)
+    pAST->IODBase = 0;
+#else
+    pAST->IODBase = pScrn->domainIOBase;  
+#endif
+    /* "Patch" the PIOOffset inside vgaHW in order to force
+     * the vgaHW module to use our relocated i/o ports.
+     */
+    VGAHWPTR(pScrn)->PIOOffset = pAST->PIOOffset = pAST->IODBase + pAST->PciInfo->ioBase[2] - 0x380;
+	
+    pAST->RelocateIO = (IOADDRESS)(pAST->PciInfo->ioBase[2] + pAST->IODBase);
+	
+   if (pAST->pEnt->device->MemBase != 0) {
+      pAST->FBPhysAddr = pAST->pEnt->device->MemBase;
+      from = X_CONFIG;
+   } else {
+      if (pAST->PciInfo->memBase[0] != 0) {
+	 pAST->FBPhysAddr = pAST->PciInfo->memBase[0] & 0xFFF00000;
+	 from = X_PROBED;
+      } else {
+	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		    "No valid FB address in PCI config space\n");
+	 ASTFreeRec(pScrn);
+	 return FALSE;
+      }
+   }
+   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Linear framebuffer at 0x%lX\n",
+	      (unsigned long) pAST->FBPhysAddr);
+
+   if (pAST->pEnt->device->IOBase != 0) {
+      pAST->MMIOPhysAddr = pAST->pEnt->device->IOBase;
+      from = X_CONFIG;
+   } else {
+      if (pAST->PciInfo->memBase[1]) {
+	 pAST->MMIOPhysAddr = pAST->PciInfo->memBase[1] & 0xFFFF0000;
+	 from = X_PROBED;
+      } else {
+	 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+		    "No valid MMIO address in PCI config space\n");
+	 ASTFreeRec(pScrn);
+	 return FALSE;
+      }
+   }
+   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "IO registers at addr 0x%lX\n",
+	      (unsigned long) pAST->MMIOPhysAddr);
+	      
+   pScrn->videoRam = GetVRAMInfo(pScrn) / 1024;
+   from = X_DEFAULT;
+
+
+   if (pAST->pEnt->device->videoRam) {
+      pScrn->videoRam = pAST->pEnt->device->videoRam;
+      from = X_CONFIG;
+   }
+
+   pAST->FbMapSize = pScrn->videoRam * 1024;
+   pAST->MMIOMapSize = DEFAULT_MMIO_SIZE;
+
+   /* Map resource */
+   if (!ASTMapMem(pScrn)) {
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map FB Memory Failed \n");      	
+      return FALSE;
+   }
+   
+   if (!ASTMapMMIO(pScrn)) {
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map Memory Map IO Failed \n");      	
+      return FALSE;
+   }
+
+   pScrn->memPhysBase = (ULONG)pAST->FBPhysAddr;
+   pScrn->fbOffset = 0;
+
+   /* Do DDC 
+    * should be done after xf86CollectOptions
+    */
+   pScrn->monitor->DDC = ASTDoDDC(pScrn, pAST->pEnt->index);    
+
+   /* Mode Valid */
+   clockRanges = xnfcalloc(sizeof(ClockRange), 1);
+   clockRanges->next = NULL;
+   clockRanges->minClock = 9500;
+   clockRanges->maxClock = GetMaxDCLK(pScrn) * 1000;   
+   clockRanges->clockIndex = -1;
+   clockRanges->interlaceAllowed = FALSE;
+   clockRanges->doubleScanAllowed = FALSE;
+   
+   i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
+			 pScrn->display->modes, clockRanges,
+			 0, 320, 1600, 8 * pScrn->bitsPerPixel,
+			 200, 1200,
+			 pScrn->display->virtualX, pScrn->display->virtualY,
+			 pAST->FbMapSize, LOOKUP_BEST_REFRESH);
+
+   if (i == -1) {
+      ASTFreeRec(pScrn);
+      return FALSE;
+   }
+
+   xf86PruneDriverModes(pScrn);
+
+   if (!i || !pScrn->modes) {
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
+      ASTFreeRec(pScrn);
+      return FALSE;
+   }
+
+   xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
+
+   pScrn->currentMode = pScrn->modes;
+
+   xf86PrintModes(pScrn);
+
+   xf86SetDpi(pScrn, 0, 0);
+
+   /* Accelaration Check */
+   pAST->noAccel = TRUE;
+   pAST->AccelInfoPtr = NULL; 
+   pAST->pCMDQPtr = NULL;   
+   pAST->CMDQInfo.ulCMDQSize = 0;      
+#ifdef	Accel_2D
+   if (!xf86ReturnOptValBool(pAST->Options, OPTION_NOACCEL, FALSE))
+   {
+       if (!xf86LoadSubModule(pScrn, "xaa")) {
+	   ASTFreeRec(pScrn);
+	   return FALSE;
+       }       
+       xf86LoaderReqSymLists(xaaSymbols, NULL);
+       
+       pAST->noAccel = FALSE; 
+       
+       pAST->MMIO2D = TRUE;
+#ifndef	MMIO_2D                   
+       if (!xf86ReturnOptValBool(pAST->Options, OPTION_MMIO2D, FALSE)) {
+           pAST->CMDQInfo.ulCMDQSize = DEFAULT_CMDQ_SIZE;       
+           pAST->MMIO2D = FALSE;    	
+       }	
+#endif
+
+       pAST->ENGCaps = ENG_CAP_ALL;
+       if (!xf86GetOptValInteger(pAST->Options, OPTION_ENG_CAPS, &pAST->ENGCaps)) {
+           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No ENG Capability options found\n");      	
+       }
+       
+       pAST->DBGSelect = 0;
+       if (!xf86GetOptValInteger(pAST->Options, OPTION_DBG_SELECT, &pAST->DBGSelect)) {
+           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No DBG Seleclt options found\n");      	
+       }	       
+   }
+#endif   
+
+   /* HW Cursor Check */
+   pAST->noHWC = TRUE; 
+   pAST->HWCInfoPtr = NULL;
+   pAST->pHWCPtr = NULL;    
+#ifdef	HWC   
+   if (!xf86ReturnOptValBool(pAST->Options, OPTION_SW_CURSOR, FALSE)) {
+      if (!xf86LoadSubModule(pScrn, "ramdac")) {
+	 ASTFreeRec(pScrn);
+	 return FALSE;
+      }
+      xf86LoaderReqSymLists(ramdacSymbols, NULL);
+      
+      pAST->noHWC = FALSE;  
+      pAST->HWCInfo.HWC_NUM = DEFAULT_HWC_NUM;
+      if (!xf86GetOptValInteger(pAST->Options, OPTION_HWC_NUM, &pAST->HWCInfo.HWC_NUM)) {
+          xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No HWC_NUM options found\n");      	
+      }	
+             
+   }    
+#endif
+
+   /*  We won't be using the VGA access after the probe */
+   xf86SetOperatingState(resVgaIo, pAST->pEnt->index, ResUnusedOpr);
+   xf86SetOperatingState(resVgaMem, pAST->pEnt->index, ResDisableOpr);
+
+   return TRUE;
+}
+
+
+static Bool
+ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+   ScrnInfoPtr pScrn;
+   ASTRecPtr pAST;
+   vgaHWPtr hwp;   
+   VisualPtr visual;
+ 
+   /* for FB Manager */
+   BoxRec FBMemBox;   
+   int    AvailFBSize;     
+
+   pScrn = xf86Screens[pScreen->myNum];
+   pAST = ASTPTR(pScrn);
+   hwp = VGAHWPTR(pScrn);
+      
+/*   if (!pAST->noAccel) */
+   {
+       /* AvailFBSize = pAST->FbMapSize - pAST->CMDQInfo.ulCMDQSize; */
+       AvailFBSize = pAST->FbMapSize;
+   
+       FBMemBox.x1 = 0;
+       FBMemBox.y1 = 0;
+       FBMemBox.x2 = pScrn->displayWidth;
+       FBMemBox.y2 = (AvailFBSize / (pScrn->displayWidth * ((pScrn->bitsPerPixel+1)/8))) - 1;
+
+       if (!xf86InitFBManager(pScreen, &FBMemBox)) {
+          xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to init memory manager\n");
+          return FALSE;
+       }      
+
+   }
+       
+   vgaHWGetIOBase(hwp);
+
+   vFillASTModeInfo (pScrn);      
+
+   ASTSave(pScrn);     
+   if (!ASTModeInit(pScrn, pScrn->currentMode)) {
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Mode Init Failed \n");      	  	
+      return FALSE;
+   }   
+
+   ASTSaveScreen(pScreen, FALSE);
+   ASTAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+   miClearVisualTypes();
+
+   /* Re-implemented Direct Color support, -jens */
+   if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
+			 pScrn->rgbBits, pScrn->defaultVisual))
+      return FALSE;
+
+   if (!miSetPixmapDepths())
+   {
+       ASTSaveScreen(pScreen, SCREEN_SAVER_OFF);
+       return FALSE;
+   }    
+
+   switch(pScrn->bitsPerPixel) {
+       case 8:
+       case 16:
+       case 32:
+           if (!fbScreenInit(pScreen, pAST->FBVirtualAddr + pScrn->fbOffset,
+  	                     pScrn->virtualX, pScrn->virtualY,
+		             pScrn->xDpi, pScrn->yDpi,
+		             pScrn->displayWidth, pScrn->bitsPerPixel))
+               return FALSE;
+           break;
+       default:
+           return FALSE;    
+              
+   }
+
+   if (pScrn->bitsPerPixel > 8) {
+      /* Fixup RGB ordering */
+      visual = pScreen->visuals + pScreen->numVisuals;
+      while (--visual >= pScreen->visuals) {
+	 if ((visual->class | DynamicClass) == DirectColor) {
+	    visual->offsetRed = pScrn->offset.red;
+	    visual->offsetGreen = pScrn->offset.green;
+	    visual->offsetBlue = pScrn->offset.blue;
+	    visual->redMask = pScrn->mask.red;
+	    visual->greenMask = pScrn->mask.green;
+	    visual->blueMask = pScrn->mask.blue;
+	 }
+      }
+   }
+     
+   fbPictureInit(pScreen, 0, 0);
+
+   xf86SetBlackWhitePixels(pScreen);
+
+#ifdef Accel_2D
+   if (!pAST->noAccel)
+   {
+       if (!ASTAccelInit(pScreen)) {
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Hardware acceleration initialization failed\n");
+           pAST->noAccel = TRUE;           
+       }
+   }
+#endif /* end of Accel_2D */
+     
+   miInitializeBackingStore(pScreen);
+   xf86SetBackingStore(pScreen);
+   xf86SetSilkenMouse(pScreen);
+
+   miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+   if (!pAST->noHWC)
+   {
+       if (!ASTCursorInit(pScreen)) {
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Hardware cursor initialization failed\n");
+           pAST->noHWC = TRUE;                      
+       }
+   }
+   
+   if (!miCreateDefColormap(pScreen))
+      return FALSE;
+
+   if(!xf86HandleColormaps(pScreen, 256, (pScrn->depth == 8) ? 8 : pScrn->rgbBits,
+                    vASTLoadPalette, NULL,
+                    CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) {
+       return FALSE;
+   }
+   
+   xf86DPMSInit(pScreen, ASTDisplayPowerManagementSet, 0);
+   
+   pScreen->SaveScreen = ASTSaveScreen;
+   pAST->CloseScreen = pScreen->CloseScreen;
+   pScreen->CloseScreen = ASTCloseScreen;
+
+   if (serverGeneration == 1)
+      xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+
+   return TRUE;
+   	
+} /* ASTScreenInit */
+
+
+Bool
+ASTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+   ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+#ifdef	HWC
+   if (pAST->pHWCPtr) {
+       xf86FreeOffscreenLinear(pAST->pHWCPtr);		/* free HWC Cache */
+       pAST->pHWCPtr = NULL;      
+   }    
+#endif
+
+#ifdef Accel_2D 
+   if (pAST->pCMDQPtr) {
+       xf86FreeOffscreenLinear(pAST->pCMDQPtr);		/* free CMDQ */
+       pAST->pCMDQPtr = NULL;             
+   } 
+   vDisable2D(pScrn, pAST);
+#endif
+   
+   ASTRestore(pScrn);
+   
+   return ASTModeInit(pScrn, mode);
+
+}
+
+void
+ASTAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+   ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+   ASTRecPtr   pAST  = ASTPTR(pScrn);
+   ULONG base;
+      
+   base = y * pAST->VideoModeInfo.ScreenWidth + x * ((pAST->VideoModeInfo.bitsPerPixel + 1) / 8);
+   base = base >> 2;				/* DW unit */
+
+   vSetStartAddressCRT1(pAST, base);
+
+}
+
+/* enter into X Server */		
+static Bool
+ASTEnterVT(int scrnIndex, int flags)
+{
+   ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+   if (!ASTModeInit(pScrn, pScrn->currentMode))
+      return FALSE;
+   ASTAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+   
+   return TRUE;
+   	
+}
+
+/* leave X server */
+static void
+ASTLeaveVT(int scrnIndex, int flags)
+{
+	
+   ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+   vgaHWPtr hwp = VGAHWPTR(pScrn);
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+#ifdef	HWC
+   if (pAST->pHWCPtr) {
+       xf86FreeOffscreenLinear(pAST->pHWCPtr);		/* free HWC Cache */
+       pAST->pHWCPtr = NULL;      
+   }    
+#endif
+
+#ifdef Accel_2D  
+   if (pAST->pCMDQPtr) {
+       xf86FreeOffscreenLinear(pAST->pCMDQPtr);		/* free CMDQ */
+       pAST->pCMDQPtr = NULL;             
+   }    
+   vDisable2D(pScrn, pAST);
+#endif
+      
+   ASTRestore(pScrn);  
+   vgaHWLock(hwp);	
+
+}
+
+static void
+ASTFreeScreen(int scrnIndex, int flags)
+{
+   ASTFreeRec(xf86Screens[scrnIndex]);
+   if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
+      vgaHWFreeHWRec(xf86Screens[scrnIndex]);   
+}
+
+
+static ModeStatus
+ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+
+   Bool Flags = MODE_NOMODE;
+   	
+   if (mode->Flags & V_INTERLACE) {
+      if (verbose) {
+	 xf86DrvMsg(scrnIndex, X_PROBED,
+		    "Removing interlaced mode \"%s\"\n", mode->name);
+      }
+      return MODE_NO_INTERLACE;
+   }
+
+   if ((mode->CrtcHDisplay > MAX_HResolution) || (mode->CrtcVDisplay > MAX_VResolution)) {
+      if (verbose) {
+	 xf86DrvMsg(scrnIndex, X_PROBED,
+		    "Removing the mode \"%s\"\n", mode->name);
+      }   	
+      return Flags;   	
+   }
+   
+   switch (mode->CrtcHDisplay)
+   {
+   case 640:
+       if (mode->CrtcVDisplay == 480) Flags=MODE_OK;
+       break;        
+   case 800:
+       if (mode->CrtcVDisplay == 600) Flags=MODE_OK;
+       break;   
+   case 1024:
+       if (mode->CrtcVDisplay == 768) Flags=MODE_OK;
+       break;   
+   case 1280:
+       if (mode->CrtcVDisplay == 1024) Flags=MODE_OK;
+       break;
+   case 1600:
+       if (mode->CrtcVDisplay == 1200) Flags=MODE_OK;
+       break;   
+   default:
+       return Flags;   	   	
+   }
+   
+   return Flags;
+   
+}			
+
+
+/* Internal used modules */
+/*
+ * ASTGetRec and ASTFreeRec --
+ *
+ * Private data for the driver is stored in the screen structure.
+ * These two functions create and destroy that private data.
+ *
+ */
+static Bool
+ASTGetRec(ScrnInfoPtr pScrn)
+{
+   if (pScrn->driverPrivate)
+      return TRUE;
+
+   pScrn->driverPrivate = xnfcalloc(sizeof(ASTRec), 1);
+   return TRUE;
+}
+
+static void
+ASTFreeRec(ScrnInfoPtr pScrn)
+{
+   if (!pScrn)
+      return;
+   if (!pScrn->driverPrivate)
+      return;
+   xfree(pScrn->driverPrivate);
+   pScrn->driverPrivate = 0;
+}
+
+static Bool
+ASTSaveScreen(ScreenPtr pScreen, Bool unblack)
+{
+   /* more ref. SiS */	
+   return vgaHWSaveScreen(pScreen, unblack);
+}
+
+static Bool
+ASTCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+   ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+   vgaHWPtr hwp = VGAHWPTR(pScrn);
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+   if (pScrn->vtSema == TRUE)
+   {  
+#ifdef	HWC
+   if (pAST->pHWCPtr) {
+       xf86FreeOffscreenLinear(pAST->pHWCPtr);		/* free HWC Cache */
+       pAST->pHWCPtr = NULL;      
+   }    
+#endif
+   	   
+#ifdef Accel_2D  
+   if (pAST->pCMDQPtr) {
+       xf86FreeOffscreenLinear(pAST->pCMDQPtr);		/* free CMDQ */
+       pAST->pCMDQPtr = NULL;      
+   }
+   vDisable2D(pScrn, pAST);
+#endif
+         
+      ASTRestore(pScrn);
+      vgaHWLock(hwp);
+   }
+
+   ASTUnmapMem(pScrn);
+   vgaHWUnmapMem(pScrn);
+
+   if(pAST->AccelInfoPtr) {
+       XAADestroyInfoRec(pAST->AccelInfoPtr);
+       pAST->AccelInfoPtr = NULL;
+   }
+
+   if(pAST->HWCInfoPtr) {
+       xf86DestroyCursorInfoRec(pAST->HWCInfoPtr);
+       pAST->HWCInfoPtr = NULL;
+   }
+
+   pScrn->vtSema = FALSE;
+   pScreen->CloseScreen = pAST->CloseScreen;
+   return (*pScreen->CloseScreen) (scrnIndex, pScreen);
+}
+
+static void
+ASTSave(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST;
+   vgaRegPtr vgaReg;
+   ASTRegPtr astReg;   
+   int i;
+
+   pAST = ASTPTR(pScrn);
+   vgaReg = &VGAHWPTR(pScrn)->SavedReg;
+   astReg = &pAST->SavedReg;
+    
+   /* do save */    
+   vgaHWSave(pScrn, vgaReg, VGA_SR_ALL);
+   
+   /* Ext. Save */
+   vASTOpenKey(pScrn);
+   
+   for (i=0; i<0x50; i++)
+       GetIndexReg(CRTC_PORT, (UCHAR) (i+0x80), astReg->ExtCRTC[i]);   	
+   
+}
+
+static void
+ASTRestore(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST;
+   vgaRegPtr vgaReg;
+   ASTRegPtr astReg;   
+   int i;
+
+   pAST = ASTPTR(pScrn);
+   vgaReg = &VGAHWPTR(pScrn)->SavedReg;
+   astReg = &pAST->SavedReg;
+    
+   /* do restore */    
+   vgaHWProtect(pScrn, TRUE);   
+   vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL);	      
+   vgaHWProtect(pScrn, FALSE);   
+   
+   /* Ext. restore */
+   vASTOpenKey(pScrn);
+   
+   for (i=0; i<0x50; i++)
+       SetIndexReg(CRTC_PORT, (UCHAR) (i+0x80), astReg->ExtCRTC[i]);   	
+   
+}
+
+static void
+ASTProbeDDC(ScrnInfoPtr pScrn, int index)
+{
+   vbeInfoPtr pVbe;
+
+   if (xf86LoadSubModule(pScrn, "vbe")) {
+      pVbe = VBEInit(NULL, index);
+      ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+      vbeFree(pVbe);
+   }
+}
+
+static xf86MonPtr
+ASTDoDDC(ScrnInfoPtr pScrn, int index)
+{
+   vbeInfoPtr pVbe;
+   xf86MonPtr MonInfo = NULL;
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+   /* Honour Option "noDDC" */
+   if (xf86ReturnOptValBool(pAST->Options, OPTION_NO_DDC, FALSE)) {
+      return MonInfo;
+   }
+
+   if (xf86LoadSubModule(pScrn, "vbe") && (pVbe = VBEInit(NULL, index))) {
+      xf86LoaderReqSymLists(vbeSymbols, NULL);
+      MonInfo = vbeDoEDID(pVbe, NULL);
+      xf86PrintEDID(MonInfo);
+      xf86SetDDCproperties(pScrn, MonInfo);
+      vbeFree(pVbe);
+   } else {
+      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+		 "this driver cannot do DDC without VBE\n");
+   }
+
+   return MonInfo;
+}
+
+static void
+vFillASTModeInfo (ScrnInfoPtr pScrn)
+{
+    ASTRecPtr pAST;
+    
+    pAST = ASTPTR(pScrn);
+    
+    pAST->VideoModeInfo.ScreenWidth = pScrn->virtualX;   
+    pAST->VideoModeInfo.ScreenHeight = pScrn->virtualY;   
+    pAST->VideoModeInfo.bitsPerPixel = pScrn->bitsPerPixel;   
+    pAST->VideoModeInfo.ScreenPitch = pScrn->virtualX * ((pScrn->bitsPerPixel + 1) / 8) ;       
+
+}
+
+static Bool
+ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+    vgaHWPtr hwp;
+    ASTRecPtr pAST;
+
+    hwp = VGAHWPTR(pScrn);
+    pAST = ASTPTR(pScrn);
+
+    vgaHWUnlock(hwp);
+
+    if (!vgaHWInit(pScrn, mode))
+      return FALSE;
+
+    pScrn->vtSema = TRUE;
+    pAST->ModePtr = mode;
+
+    if (!ASTSetMode(pScrn, mode))
+      return FALSE;
+    
+    vgaHWProtect(pScrn, FALSE);
+
+    return TRUE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_mode.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,712 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+VBIOS_STDTABLE_STRUCT StdTable[] = {
+    /* MD_2_3_400 */
+    {
+        0x67,						
+        {0x00,0x03,0x00,0x02},				
+        {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,	
+         0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
+         0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
+         0xff},
+        {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,	
+         0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+         0x0c,0x00,0x0f,0x08},
+        {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,	
+         0xff}
+    },   
+    /* Mode12/ExtEGATable */
+    {
+        0xe3, 						
+        {0x01,0x0f,0x00,0x06},				
+        {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,       
+         0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,       
+         0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3,       
+         0xff},                                         
+        {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,       
+         0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,       
+         0x01,0x00,0x0f,0x00},                          
+        {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,       
+         0xff}                                          
+    },
+    /* ExtVGATable */
+    {
+        0x2f,						
+        {0x01,0x0f,0x00,0x0e},                          
+        {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,       
+         0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,       
+         0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,       
+         0xff},                                         
+        {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,       
+         0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,       
+         0x01,0x00,0x00,0x00},                          
+        {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,       
+         0xff}
+    },
+    /* ExtHiCTable */
+    {
+        0x2f,						
+        {0x01,0x0f,0x00,0x0e},                          
+        {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,       
+         0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,       
+         0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,       
+         0xff},                                         
+        {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,       
+         0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,       
+         0x01,0x00,0x00,0x00},                          
+        {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,       
+         0xff}
+    },     
+    /* ExtTrueCTable */
+    {
+        0x2f,						
+        {0x01,0x0f,0x00,0x0e},                          
+        {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,       
+         0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,       
+         0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,       
+         0xff},                                         
+        {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,       
+         0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,       
+         0x01,0x00,0x00,0x00},                          
+        {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,       
+         0xff}
+    },  
+};
+
+VBIOS_ENHTABLE_STRUCT  Res640x480Table[] = {
+    { 800, 640, 8, 96, 525, 480, 2, 2, VCLK28_322,	/* 60Hz */
+      (SyncNN | HBorder | VBorder | Charx8Dot), 60, 1, 0x2E },
+    { 832, 640, 16, 40, 520, 480, 1, 3, VCLK31_5,	/* 72Hz */
+      (SyncNN | HBorder | VBorder | Charx8Dot), 72, 2, 0x2E  },
+    { 840, 640, 16, 64, 500, 480, 1, 3, VCLK31_5,	/* 75Hz */
+      (SyncNN | Charx8Dot) , 75, 3, 0x2E },      
+    { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36,		/* 85Hz */
+      (SyncNN | Charx8Dot) , 85, 4, 0x2E },
+    { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36,		/* end */
+      (SyncNN | Charx8Dot) , 0xFF, 4, 0x2E },              	      			
+};
+
+
+VBIOS_ENHTABLE_STRUCT  Res800x600Table[] = {
+    {1024, 800, 24, 72, 625, 600, 1, 2, VCLK36,		/* 56Hz */
+      (SyncPP | Charx8Dot), 56, 1, 0x30 },	      
+    {1056, 800, 40, 128, 628, 600, 1, 4, VCLK40,	/* 60Hz */ 
+      (SyncPP | Charx8Dot), 60, 2, 0x30 },
+    {1040, 800, 56, 120, 666, 600, 37, 6, VCLK50,	/* 72Hz */ 
+      (SyncPP | Charx8Dot), 72, 3, 0x30 },            
+    {1056, 800, 16, 80, 625, 600, 1, 3, VCLK49_5,	/* 75Hz */ 
+      (SyncPP | Charx8Dot), 75, 4, 0x30 },  	  			
+    {1048, 800, 32, 64, 631, 600, 1, 3, VCLK56_25,	/* 85Hz */ 
+      (SyncPP | Charx8Dot), 85, 5, 0x30 },  
+    {1048, 800, 32, 64, 631, 600, 1, 3, VCLK56_25,	/* end */ 
+      (SyncPP | Charx8Dot), 0xFF, 5, 0x30 },           
+};
+
+
+VBIOS_ENHTABLE_STRUCT  Res1024x768Table[] = {	
+    {1344, 1024, 24, 136, 806, 768, 3, 6, VCLK65,	/* 60Hz */ 
+      (SyncNN | Charx8Dot), 60, 1, 0x31 },	
+    {1328, 1024, 24, 136, 806, 768, 3, 6, VCLK75,	/* 70Hz */ 
+      (SyncNN | Charx8Dot), 70, 2, 0x31 },
+    {1312, 1024, 16, 96, 800, 768, 1, 3, VCLK78_75,	/* 75Hz */ 
+      (SyncPP | Charx8Dot), 75, 3, 0x31 },      
+    {1376, 1024, 48, 96, 808, 768, 1, 3, VCLK94_5,	/* 85Hz */ 
+      (SyncPP | Charx8Dot), 85, 4, 0x31 },  
+    {1376, 1024, 48, 96, 808, 768, 1, 3, VCLK94_5,	/* end */ 
+      (SyncPP | Charx8Dot), 0xFF, 4, 0x31 },             
+};
+
+VBIOS_ENHTABLE_STRUCT  Res1280x1024Table[] = {	
+    {1688, 1280, 48, 112, 1066, 1024, 1, 3, VCLK108,	/* 60Hz */ 
+      (SyncPP | Charx8Dot), 60, 1, 0x32 }, 
+    {1688, 1280, 16, 144, 1066, 1024, 1, 3, VCLK135,	/* 75Hz */ 
+      (SyncPP | Charx8Dot), 75, 2, 0x32 },  
+    {1728, 1280, 64, 160, 1072, 1024, 1, 3, VCLK157_5,	/* 85Hz */ 
+      (SyncPP | Charx8Dot), 85, 3, 0x32 },    
+    {1728, 1280, 64, 160, 1072, 1024, 1, 3, VCLK157_5,	/* end */ 
+      (SyncPP | Charx8Dot), 0xFF, 3, 0x32 },                        
+};
+
+VBIOS_ENHTABLE_STRUCT  Res1600x1200Table[] = {	
+    {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162,	/* 60Hz */ 
+      (SyncPP | Charx8Dot), 60, 1, 0x33 }, 
+    {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162,	/* end */ 
+      (SyncPP | Charx8Dot), 60, 1, 0x33 },         
+};
+
+VBIOS_DCLK_INFO DCLKTable [] = {
+    {0x2C, 0xE7, 0x03},					/* 00: VCLK25_175	*/		
+    {0x95, 0x62, 0x03},				        /* 01: VCLK28_322	*/
+    {0x67, 0x63, 0x01},				        /* 02: VCLK31_5         */
+    {0x76, 0x63, 0x01},				        /* 03: VCLK36         	*/
+    {0xEE, 0x67, 0x01},				        /* 04: VCLK40          	*/
+    {0x82, 0x62, 0x01}, 			        /* 05: VCLK49_5        	*/
+    {0xC6, 0x64, 0x01},                        	        /* 06: VCLK50          	*/
+    {0x94, 0x62, 0x01},                        	        /* 07: VCLK56_25       	*/
+    {0x80, 0x64, 0x00},                        	        /* 08: VCLK65		*/
+    {0x7B, 0x63, 0x00},                        	        /* 09: VCLK75	        */
+    {0x67, 0x62, 0x00},				        /* 0A: VCLK78_75       	*/
+    {0x7C, 0x62, 0x00},                        	        /* 0B: VCLK94_5        	*/
+    {0x8E, 0x62, 0x00},                        	        /* 0C: VCLK108         	*/
+    {0x85, 0x24, 0x00},                        	        /* 0D: VCLK135         	*/
+    {0x67, 0x22, 0x00},                        	        /* 0E: VCLK157_5       	*/
+    {0x6A, 0x22, 0x00},				        /* 0F: VCLK162         	*/
+};
+
+VBIOS_DAC_INFO DAC_TEXT[] = {
+ { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x2a },  { 0x00, 0x2a, 0x00 },  { 0x00, 0x2a, 0x2a }, 
+ { 0x2a, 0x00, 0x00 },  { 0x2a, 0x00, 0x2a },  { 0x2a, 0x2a, 0x00 },  { 0x2a, 0x2a, 0x2a }, 
+ { 0x00, 0x00, 0x15 },  { 0x00, 0x00, 0x3f },  { 0x00, 0x2a, 0x15 },  { 0x00, 0x2a, 0x3f }, 
+ { 0x2a, 0x00, 0x15 },  { 0x2a, 0x00, 0x3f },  { 0x2a, 0x2a, 0x15 },  { 0x2a, 0x2a, 0x3f }, 
+ { 0x00, 0x15, 0x00 },  { 0x00, 0x15, 0x2a },  { 0x00, 0x3f, 0x00 },  { 0x00, 0x3f, 0x2a }, 
+ { 0x2a, 0x15, 0x00 },  { 0x2a, 0x15, 0x2a },  { 0x2a, 0x3f, 0x00 },  { 0x2a, 0x3f, 0x2a }, 
+ { 0x00, 0x15, 0x15 },  { 0x00, 0x15, 0x3f },  { 0x00, 0x3f, 0x15 },  { 0x00, 0x3f, 0x3f }, 
+ { 0x2a, 0x15, 0x15 },  { 0x2a, 0x15, 0x3f },  { 0x2a, 0x3f, 0x15 },  { 0x2a, 0x3f, 0x3f }, 
+ { 0x15, 0x00, 0x00 },  { 0x15, 0x00, 0x2a },  { 0x15, 0x2a, 0x00 },  { 0x15, 0x2a, 0x2a }, 
+ { 0x3f, 0x00, 0x00 },  { 0x3f, 0x00, 0x2a },  { 0x3f, 0x2a, 0x00 },  { 0x3f, 0x2a, 0x2a }, 
+ { 0x15, 0x00, 0x15 },  { 0x15, 0x00, 0x3f },  { 0x15, 0x2a, 0x15 },  { 0x15, 0x2a, 0x3f }, 
+ { 0x3f, 0x00, 0x15 },  { 0x3f, 0x00, 0x3f },  { 0x3f, 0x2a, 0x15 },  { 0x3f, 0x2a, 0x3f }, 
+ { 0x15, 0x15, 0x00 },  { 0x15, 0x15, 0x2a },  { 0x15, 0x3f, 0x00 },  { 0x15, 0x3f, 0x2a }, 
+ { 0x3f, 0x15, 0x00 },  { 0x3f, 0x15, 0x2a },  { 0x3f, 0x3f, 0x00 },  { 0x3f, 0x3f, 0x2a }, 
+ { 0x15, 0x15, 0x15 },  { 0x15, 0x15, 0x3f },  { 0x15, 0x3f, 0x15 },  { 0x15, 0x3f, 0x3f }, 
+ { 0x3f, 0x15, 0x15 },  { 0x3f, 0x15, 0x3f },  { 0x3f, 0x3f, 0x15 },  { 0x3f, 0x3f, 0x3f }, 	
+};
+
+VBIOS_DAC_INFO DAC_EGA[] = {
+ { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x2a },  { 0x00, 0x2a, 0x00 },  { 0x00, 0x2a, 0x2a }, 
+ { 0x2a, 0x00, 0x00 },  { 0x2a, 0x00, 0x2a },  { 0x2a, 0x2a, 0x00 },  { 0x2a, 0x2a, 0x2a }, 
+ { 0x00, 0x00, 0x15 },  { 0x00, 0x00, 0x3f },  { 0x00, 0x2a, 0x15 },  { 0x00, 0x2a, 0x3f }, 
+ { 0x2a, 0x00, 0x15 },  { 0x2a, 0x00, 0x3f },  { 0x2a, 0x2a, 0x15 },  { 0x2a, 0x2a, 0x3f }, 
+ { 0x00, 0x15, 0x00 },  { 0x00, 0x15, 0x2a },  { 0x00, 0x3f, 0x00 },  { 0x00, 0x3f, 0x2a }, 
+ { 0x2a, 0x15, 0x00 },  { 0x2a, 0x15, 0x2a },  { 0x2a, 0x3f, 0x00 },  { 0x2a, 0x3f, 0x2a }, 
+ { 0x00, 0x15, 0x15 },  { 0x00, 0x15, 0x3f },  { 0x00, 0x3f, 0x15 },  { 0x00, 0x3f, 0x3f }, 
+ { 0x2a, 0x15, 0x15 },  { 0x2a, 0x15, 0x3f },  { 0x2a, 0x3f, 0x15 },  { 0x2a, 0x3f, 0x3f }, 
+ { 0x15, 0x00, 0x00 },  { 0x15, 0x00, 0x2a },  { 0x15, 0x2a, 0x00 },  { 0x15, 0x2a, 0x2a }, 
+ { 0x3f, 0x00, 0x00 },  { 0x3f, 0x00, 0x2a },  { 0x3f, 0x2a, 0x00 },  { 0x3f, 0x2a, 0x2a }, 
+ { 0x15, 0x00, 0x15 },  { 0x15, 0x00, 0x3f },  { 0x15, 0x2a, 0x15 },  { 0x15, 0x2a, 0x3f }, 
+ { 0x3f, 0x00, 0x15 },  { 0x3f, 0x00, 0x3f },  { 0x3f, 0x2a, 0x15 },  { 0x3f, 0x2a, 0x3f }, 
+ { 0x15, 0x15, 0x00 },  { 0x15, 0x15, 0x2a },  { 0x15, 0x3f, 0x00 },  { 0x15, 0x3f, 0x2a }, 
+ { 0x3f, 0x15, 0x00 },  { 0x3f, 0x15, 0x2a },  { 0x3f, 0x3f, 0x00 },  { 0x3f, 0x3f, 0x2a }, 
+ { 0x15, 0x15, 0x15 },  { 0x15, 0x15, 0x3f },  { 0x15, 0x3f, 0x15 },  { 0x15, 0x3f, 0x3f }, 
+ { 0x3f, 0x15, 0x15 },  { 0x3f, 0x15, 0x3f },  { 0x3f, 0x3f, 0x15 },  { 0x3f, 0x3f, 0x3f }, 	
+};
+
+VBIOS_DAC_INFO DAC_VGA[] = {
+ { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x2a },  { 0x00, 0x2a, 0x00 },  { 0x00, 0x2a, 0x2a }, 
+ { 0x2a, 0x00, 0x00 },  { 0x2a, 0x00, 0x2a },  { 0x2a, 0x15, 0x00 },  { 0x2a, 0x2a, 0x2a }, 
+ { 0x15, 0x15, 0x15 },  { 0x15, 0x15, 0x3f },  { 0x15, 0x3f, 0x15 },  { 0x15, 0x3f, 0x3f }, 
+ { 0x3f, 0x15, 0x15 },  { 0x3f, 0x15, 0x3f },  { 0x3f, 0x3f, 0x15 },  { 0x3f, 0x3f, 0x3f }, 
+ { 0x00, 0x00, 0x00 },  { 0x05, 0x05, 0x05 },  { 0x08, 0x08, 0x08 },  { 0x0b, 0x0b, 0x0b }, 
+ { 0x0e, 0x0e, 0x0e },  { 0x11, 0x11, 0x11 },  { 0x14, 0x14, 0x14 },  { 0x18, 0x18, 0x18 }, 
+ { 0x1c, 0x1c, 0x1c },  { 0x20, 0x20, 0x20 },  { 0x24, 0x24, 0x24 },  { 0x28, 0x28, 0x28 }, 
+ { 0x2d, 0x2d, 0x2d },  { 0x32, 0x32, 0x32 },  { 0x38, 0x38, 0x38 },  { 0x3f, 0x3f, 0x3f }, 
+ { 0x00, 0x00, 0x3f },  { 0x10, 0x00, 0x3f },  { 0x1f, 0x00, 0x3f },  { 0x2f, 0x00, 0x3f }, 
+ { 0x3f, 0x00, 0x3f },  { 0x3f, 0x00, 0x2f },  { 0x3f, 0x00, 0x1f },  { 0x3f, 0x00, 0x10 }, 
+ { 0x3f, 0x00, 0x00 },  { 0x3f, 0x10, 0x00 },  { 0x3f, 0x1f, 0x00 },  { 0x3f, 0x2f, 0x00 }, 
+ { 0x3f, 0x3f, 0x00 },  { 0x2f, 0x3f, 0x00 },  { 0x1f, 0x3f, 0x00 },  { 0x10, 0x3f, 0x00 }, 
+ { 0x00, 0x3f, 0x00 },  { 0x00, 0x3f, 0x10 },  { 0x00, 0x3f, 0x1f },  { 0x00, 0x3f, 0x2f }, 
+ { 0x00, 0x3f, 0x3f },  { 0x00, 0x2f, 0x3f },  { 0x00, 0x1f, 0x3f },  { 0x00, 0x10, 0x3f }, 
+ { 0x1f, 0x1f, 0x3f },  { 0x27, 0x1f, 0x3f },  { 0x2f, 0x1f, 0x3f },  { 0x37, 0x1f, 0x3f }, 
+ { 0x3f, 0x1f, 0x3f },  { 0x3f, 0x1f, 0x37 },  { 0x3f, 0x1f, 0x2f },  { 0x3f, 0x1f, 0x27 }, 
+ { 0x3f, 0x1f, 0x1f },  { 0x3f, 0x27, 0x1f },  { 0x3f, 0x2f, 0x1f },  { 0x3f, 0x37, 0x1f }, 
+ { 0x3f, 0x3f, 0x1f },  { 0x37, 0x3f, 0x1f },  { 0x2f, 0x3f, 0x1f },  { 0x27, 0x3f, 0x1f }, 
+ { 0x1f, 0x3f, 0x1f },  { 0x1f, 0x3f, 0x27 },  { 0x1f, 0x3f, 0x2f },  { 0x1f, 0x3f, 0x37 }, 
+ { 0x1f, 0x3f, 0x3f },  { 0x1f, 0x37, 0x3f },  { 0x1f, 0x2f, 0x3f },  { 0x1f, 0x27, 0x3f }, 
+ { 0x2d, 0x2d, 0x3f },  { 0x31, 0x2d, 0x3f },  { 0x36, 0x2d, 0x3f },  { 0x3a, 0x2d, 0x3f }, 
+ { 0x3f, 0x2d, 0x3f },  { 0x3f, 0x2d, 0x3a },  { 0x3f, 0x2d, 0x36 },  { 0x3f, 0x2d, 0x31 }, 
+ { 0x3f, 0x2d, 0x2d },  { 0x3f, 0x31, 0x2d },  { 0x3f, 0x36, 0x2d },  { 0x3f, 0x3a, 0x2d }, 
+ { 0x3f, 0x3f, 0x2d },  { 0x3a, 0x3f, 0x2d },  { 0x36, 0x3f, 0x2d },  { 0x31, 0x3f, 0x2d }, 
+ { 0x2d, 0x3f, 0x2d },  { 0x2d, 0x3f, 0x31 },  { 0x2d, 0x3f, 0x36 },  { 0x2d, 0x3f, 0x3a }, 
+ { 0x2d, 0x3f, 0x3f },  { 0x2d, 0x3a, 0x3f },  { 0x2d, 0x36, 0x3f },  { 0x2d, 0x31, 0x3f }, 
+ { 0x00, 0x00, 0x1c },  { 0x07, 0x00, 0x1c },  { 0x0e, 0x00, 0x1c },  { 0x15, 0x00, 0x1c }, 
+ { 0x1c, 0x00, 0x1c },  { 0x1c, 0x00, 0x15 },  { 0x1c, 0x00, 0x0e },  { 0x1c, 0x00, 0x07 }, 
+ { 0x1c, 0x00, 0x00 },  { 0x1c, 0x07, 0x00 },  { 0x1c, 0x0e, 0x00 },  { 0x1c, 0x15, 0x00 }, 
+ { 0x1c, 0x1c, 0x00 },  { 0x15, 0x1c, 0x00 },  { 0x0e, 0x1c, 0x00 },  { 0x07, 0x1c, 0x00 }, 
+ { 0x00, 0x1c, 0x00 },  { 0x00, 0x1c, 0x07 },  { 0x00, 0x1c, 0x0e },  { 0x00, 0x1c, 0x15 }, 
+ { 0x00, 0x1c, 0x1c },  { 0x00, 0x15, 0x1c },  { 0x00, 0x0e, 0x1c },  { 0x00, 0x07, 0x1c }, 
+ { 0x0e, 0x0e, 0x1c },  { 0x11, 0x0e, 0x1c },  { 0x15, 0x0e, 0x1c },  { 0x18, 0x0e, 0x1c }, 
+ { 0x1c, 0x0e, 0x1c },  { 0x1c, 0x0e, 0x18 },  { 0x1c, 0x0e, 0x15 },  { 0x1c, 0x0e, 0x11 }, 
+ { 0x1c, 0x0e, 0x0e },  { 0x1c, 0x11, 0x0e },  { 0x1c, 0x15, 0x0e },  { 0x1c, 0x18, 0x0e }, 
+ { 0x1c, 0x1c, 0x0e },  { 0x18, 0x1c, 0x0e },  { 0x15, 0x1c, 0x0e },  { 0x11, 0x1c, 0x0e }, 
+ { 0x0e, 0x1c, 0x0e },  { 0x0e, 0x1c, 0x11 },  { 0x0e, 0x1c, 0x15 },  { 0x0e, 0x1c, 0x18 }, 
+ { 0x0e, 0x1c, 0x1c },  { 0x0e, 0x18, 0x1c },  { 0x0e, 0x15, 0x1c },  { 0x0e, 0x11, 0x1c }, 
+ { 0x14, 0x14, 0x1c },  { 0x16, 0x14, 0x1c },  { 0x18, 0x14, 0x1c },  { 0x1a, 0x14, 0x1c }, 
+ { 0x1c, 0x14, 0x1c },  { 0x1c, 0x14, 0x1a },  { 0x1c, 0x14, 0x18 },  { 0x1c, 0x14, 0x16 }, 
+ { 0x1c, 0x14, 0x14 },  { 0x1c, 0x16, 0x14 },  { 0x1c, 0x18, 0x14 },  { 0x1c, 0x1a, 0x14 }, 
+ { 0x1c, 0x1c, 0x14 },  { 0x1a, 0x1c, 0x14 },  { 0x18, 0x1c, 0x14 },  { 0x16, 0x1c, 0x14 }, 
+ { 0x14, 0x1c, 0x14 },  { 0x14, 0x1c, 0x16 },  { 0x14, 0x1c, 0x18 },  { 0x14, 0x1c, 0x1a }, 
+ { 0x14, 0x1c, 0x1c },  { 0x14, 0x1a, 0x1c },  { 0x14, 0x18, 0x1c },  { 0x14, 0x16, 0x1c }, 
+ { 0x00, 0x00, 0x10 },  { 0x04, 0x00, 0x10 },  { 0x08, 0x00, 0x10 },  { 0x0c, 0x00, 0x10 }, 
+ { 0x10, 0x00, 0x10 },  { 0x10, 0x00, 0x0c },  { 0x10, 0x00, 0x08 },  { 0x10, 0x00, 0x04 }, 
+ { 0x10, 0x00, 0x00 },  { 0x10, 0x04, 0x00 },  { 0x10, 0x08, 0x00 },  { 0x10, 0x0c, 0x00 }, 
+ { 0x10, 0x10, 0x00 },  { 0x0c, 0x10, 0x00 },  { 0x08, 0x10, 0x00 },  { 0x04, 0x10, 0x00 }, 
+ { 0x00, 0x10, 0x00 },  { 0x00, 0x10, 0x04 },  { 0x00, 0x10, 0x08 },  { 0x00, 0x10, 0x0c }, 
+ { 0x00, 0x10, 0x10 },  { 0x00, 0x0c, 0x10 },  { 0x00, 0x08, 0x10 },  { 0x00, 0x04, 0x10 }, 
+ { 0x08, 0x08, 0x10 },  { 0x0a, 0x08, 0x10 },  { 0x0c, 0x08, 0x10 },  { 0x0e, 0x08, 0x10 }, 
+ { 0x10, 0x08, 0x10 },  { 0x10, 0x08, 0x0e },  { 0x10, 0x08, 0x0c },  { 0x10, 0x08, 0x0a }, 
+ { 0x10, 0x08, 0x08 },  { 0x10, 0x0a, 0x08 },  { 0x10, 0x0c, 0x08 },  { 0x10, 0x0e, 0x08 }, 
+ { 0x10, 0x10, 0x08 },  { 0x0e, 0x10, 0x08 },  { 0x0c, 0x10, 0x08 },  { 0x0a, 0x10, 0x08 }, 
+ { 0x08, 0x10, 0x08 },  { 0x08, 0x10, 0x0a },  { 0x08, 0x10, 0x0c },  { 0x08, 0x10, 0x0e }, 
+ { 0x08, 0x10, 0x10 },  { 0x08, 0x0e, 0x10 },  { 0x08, 0x0c, 0x10 },  { 0x08, 0x0a, 0x10 }, 
+ { 0x0b, 0x0b, 0x10 },  { 0x0c, 0x0b, 0x10 },  { 0x0d, 0x0b, 0x10 },  { 0x0f, 0x0b, 0x10 }, 
+ { 0x10, 0x0b, 0x10 },  { 0x10, 0x0b, 0x0f },  { 0x10, 0x0b, 0x0d },  { 0x10, 0x0b, 0x0c }, 
+ { 0x10, 0x0b, 0x0b },  { 0x10, 0x0c, 0x0b },  { 0x10, 0x0d, 0x0b },  { 0x10, 0x0f, 0x0b }, 
+ { 0x10, 0x10, 0x0b },  { 0x0f, 0x10, 0x0b },  { 0x0d, 0x10, 0x0b },  { 0x0c, 0x10, 0x0b }, 
+ { 0x0b, 0x10, 0x0b },  { 0x0b, 0x10, 0x0c },  { 0x0b, 0x10, 0x0d },  { 0x0b, 0x10, 0x0f }, 
+ { 0x0b, 0x10, 0x10 },  { 0x0b, 0x0f, 0x10 },  { 0x0b, 0x0d, 0x10 },  { 0x0b, 0x0c, 0x10 }, 
+ { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x00 }, 
+ { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x00 },  { 0x00, 0x00, 0x00 }, 	
+};
+
+/* extern. function */
+extern void vASTOpenKey(ScrnInfoPtr pScrn);
+extern Bool bASTRegInit(ScrnInfoPtr pScrn);
+extern void vAST1000DisplayOn(ASTRecPtr pAST);
+extern void vAST1000DisplayOff(ASTRecPtr pAST);
+
+extern Bool bEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+extern void vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+
+extern Bool bInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST);
+
+/* Prototype type declaration*/
+Bool ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
+Bool bGetAST1000VGAModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo);
+void vSetStdReg(ScrnInfoPtr pScrn,  DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo);
+void vSetCRTCReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo);
+void vSetOffsetReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo);
+void vSetDCLKReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo);
+void vSetExtReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo);
+Bool bSetDACReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo);
+
+Bool
+ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+    ASTRecPtr pAST;
+    VBIOS_MODE_INFO vgamodeinfo; 
+		
+    pAST = ASTPTR(pScrn);
+
+    vASTOpenKey(pScrn);
+    bASTRegInit(pScrn);
+    
+    /* pre set mode */        		
+    bGetAST1000VGAModeInfo(pScrn, mode, &vgamodeinfo);  
+      
+    /* set mode */
+    vSetStdReg(pScrn, mode, &vgamodeinfo);      
+    vSetCRTCReg(pScrn, mode, &vgamodeinfo);
+    vSetOffsetReg(pScrn, mode, &vgamodeinfo);    
+    vSetDCLKReg(pScrn, mode, &vgamodeinfo);
+    vSetExtReg(pScrn, mode, &vgamodeinfo);
+    bSetDACReg(pScrn, mode, &vgamodeinfo);       
+    
+    /* post set mode */
+#ifdef	Accel_2D
+   if (!pAST->noAccel) {
+       if (!bEnable2D(pScrn, pAST)) {
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Enable 2D failed\n");  
+           pAST->noAccel = TRUE;                    	
+       }	   	
+   }
+#endif 
+#ifdef	HWC
+   if (!pAST->noHWC) {
+       if (!bInitHWC(pScrn, pAST)) {
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Init HWC failed\n"); 
+           pAST->noHWC = TRUE;                     	
+       }	   	
+   }
+#endif       
+    vAST1000DisplayOn(pAST);
+    
+    return (TRUE);	
+}
+
+
+Bool bGetAST1000VGAModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo)
+{
+    ASTRecPtr pAST;	
+    ULONG ulModeID, ulColorIndex, ulRefreshRate, ulRefreshRateIndex = 0;
+    ULONG ulHBorder, ulVBorder;
+        
+    pAST = ASTPTR(pScrn);
+    
+    switch (pScrn->bitsPerPixel)
+    {
+    case 8:
+         pVGAModeInfo->pStdTableEntry = (PVBIOS_STDTABLE_STRUCT) &StdTable[VGAModeIndex]; 
+	 ulColorIndex = VGAModeIndex-1;       
+         break;   
+    case 16:
+         pVGAModeInfo->pStdTableEntry = (PVBIOS_STDTABLE_STRUCT) &StdTable[HiCModeIndex];
+	 ulColorIndex = HiCModeIndex-1;                
+         break;
+    case 24:         
+    case 32:
+         pVGAModeInfo->pStdTableEntry = (PVBIOS_STDTABLE_STRUCT) &StdTable[TrueCModeIndex]; 
+	 ulColorIndex = TrueCModeIndex-1;                
+	 break;    
+    default:
+         return (FALSE);
+    }
+
+    switch (mode->CrtcHDisplay)
+    {
+    case 640:
+         pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res640x480Table[ulRefreshRateIndex];
+         break;
+    case 800:
+         pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res800x600Table[ulRefreshRateIndex];
+         break;         
+    case 1024:
+         pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res1024x768Table[ulRefreshRateIndex];
+         break;
+    case 1280:
+         pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res1280x1024Table[ulRefreshRateIndex];
+         break;
+    case 1600:
+         pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res1600x1200Table[ulRefreshRateIndex];
+         break;                  
+    default:
+         return (FALSE);     
+    }
+
+    /* Get Proper Mode Index */
+    ulRefreshRate = (mode->Clock * 1000) / (mode->HTotal * mode->VTotal);    
+    
+    while (pVGAModeInfo->pEnhTableEntry->ulRefreshRate < ulRefreshRate)
+    {
+        pVGAModeInfo->pEnhTableEntry++;
+        if ((pVGAModeInfo->pEnhTableEntry->ulRefreshRate > ulRefreshRate) || 
+            (pVGAModeInfo->pEnhTableEntry->ulRefreshRate == 0xFF)) 
+        {
+            pVGAModeInfo->pEnhTableEntry--;
+            break; 	
+        }    
+    }
+
+    /* Update mode CRTC info */
+    ulHBorder = (pVGAModeInfo->pEnhTableEntry->Flags & HBorder) ? 1:0;    
+    ulVBorder = (pVGAModeInfo->pEnhTableEntry->Flags & VBorder) ? 1:0;    
+    
+    mode->CrtcHTotal      = (int) pVGAModeInfo->pEnhTableEntry->HT;
+    mode->CrtcHBlankStart = (int) (pVGAModeInfo->pEnhTableEntry->HDE + ulHBorder);
+    mode->CrtcHBlankEnd   = (int) (pVGAModeInfo->pEnhTableEntry->HT - ulHBorder); 
+    mode->CrtcHSyncStart  = (int) (pVGAModeInfo->pEnhTableEntry->HDE + ulHBorder
+                                   + pVGAModeInfo->pEnhTableEntry->HFP);
+    mode->CrtcHSyncEnd    = (int) (pVGAModeInfo->pEnhTableEntry->HDE + ulHBorder
+                                   + pVGAModeInfo->pEnhTableEntry->HFP
+                                   + pVGAModeInfo->pEnhTableEntry->HSYNC);
+
+    mode->CrtcVTotal      = (int) pVGAModeInfo->pEnhTableEntry->VT;
+    mode->CrtcVBlankStart = (int) (pVGAModeInfo->pEnhTableEntry->VDE + ulVBorder);
+    mode->CrtcVBlankEnd   = (int) (pVGAModeInfo->pEnhTableEntry->VT - ulVBorder); 
+    mode->CrtcVSyncStart  = (int) (pVGAModeInfo->pEnhTableEntry->VDE + ulVBorder
+                                   + pVGAModeInfo->pEnhTableEntry->VFP);
+    mode->CrtcVSyncEnd    = (int) (pVGAModeInfo->pEnhTableEntry->VDE + ulVBorder
+                                   + pVGAModeInfo->pEnhTableEntry->VFP
+                                   + pVGAModeInfo->pEnhTableEntry->VSYNC);
+                      
+    /* Write mode info to scratch */
+    ulRefreshRateIndex = pVGAModeInfo->pEnhTableEntry->ulRefreshRateIndex;
+    ulModeID = pVGAModeInfo->pEnhTableEntry->ulModeID;
+
+    SetIndexReg(CRTC_PORT, 0x8C, (UCHAR) ((ulColorIndex & 0x0F) << 4));         	    
+    SetIndexReg(CRTC_PORT, 0x8D, (UCHAR) (ulRefreshRateIndex & 0xFF));         	    
+    SetIndexReg(CRTC_PORT, 0x8E, (UCHAR) (ulModeID & 0xFF));         	
+    
+    return (TRUE);
+}
+	
+void vSetStdReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo)
+{
+	
+    PVBIOS_STDTABLE_STRUCT pStdModePtr;
+    ASTRecPtr pAST;		    
+    ULONG i;
+    UCHAR jReg;    
+        
+    pStdModePtr = pVGAModeInfo->pStdTableEntry;
+    pAST = ASTPTR(pScrn);        
+    
+    /* Set Misc */
+    jReg = pStdModePtr->MISC;
+    SetReg(MISC_PORT_WRITE,jReg);
+
+    /* Set Seq */
+    SetIndexReg(SEQ_PORT,0x00, 0x03);
+    for (i=0; i<4; i++)
+    {
+        jReg = pStdModePtr->SEQ[i];
+    	if (!i) (jReg |= 0x20);			/* display off */
+        SetIndexReg(SEQ_PORT,(UCHAR) (i+1), jReg);    	
+    }
+    
+    /* Set CRTC */
+    SetIndexRegMask(CRTC_PORT,0x11, 0x7F, 0x00);
+    for (i=0; i<25; i++)
+    {
+        jReg = pStdModePtr->CRTC[i];
+        SetIndexReg(CRTC_PORT,(UCHAR) i, jReg);        
+    }
+
+    /* Set AR */
+    jReg = GetReg(INPUT_STATUS1_READ);
+    for (i=0; i<20; i++)
+    {
+        jReg = pStdModePtr->AR[i];
+        SetReg(AR_PORT_WRITE, (UCHAR) i);         
+        SetReg(AR_PORT_WRITE, jReg);        
+    }    
+    SetReg(AR_PORT_WRITE, 0x14);         
+    SetReg(AR_PORT_WRITE, 0x00);  
+    
+    jReg = GetReg(INPUT_STATUS1_READ);
+    SetReg (AR_PORT_WRITE, 0x20);		/* set POS */
+                         
+    /* Set GR */
+    for (i=0; i<9; i++)
+    {
+        SetIndexReg(GR_PORT,(UCHAR) i, jReg);        
+          	    	
+    }    
+            
+    	
+}
+
+void
+vSetCRTCReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo)
+{
+    ASTRecPtr pAST;	
+    USHORT usTemp;	
+    UCHAR jReg05, jReg07, jReg09, jRegAC, jRegAD, jRegAE;
+
+    pAST = ASTPTR(pScrn);
+    jReg05 = jReg07 = jReg09 = jRegAC = jRegAD = jRegAE = 0;
+    
+    /* unlock CRTC */
+    SetIndexRegMask(CRTC_PORT,0x11, 0x7F, 0x00);                                    
+    
+    /* Horizontal Timing Programming */
+    usTemp = (mode->CrtcHTotal >> 3) - 5;
+    if (usTemp & 0x100) jRegAC |= 0x01;			/* HT D[8] */
+    SetIndexRegMask(CRTC_PORT,0x00, 0x00, (UCHAR) usTemp);
+    usTemp = (mode->CrtcHDisplay >> 3) - 1;
+    if (usTemp & 0x100) jRegAC |= 0x04;			/* HDE D[8] */
+    SetIndexRegMask(CRTC_PORT,0x01, 0x00, (UCHAR) usTemp);    
+    usTemp = (mode->CrtcHBlankStart >> 3) - 1;
+    if (usTemp & 0x100) jRegAC |= 0x10;			/* HBS D[8] */
+    SetIndexRegMask(CRTC_PORT,0x02, 0x00, (UCHAR) usTemp);        	
+    usTemp = ((mode->CrtcHBlankEnd >> 3) - 1) & 0x7F;
+    if (usTemp & 0x20) jReg05 |= 0x80;			/* HBE D[5] */
+    if (usTemp & 0x40) jRegAD |= 0x01;			/* HBE D[6] */    
+    SetIndexRegMask(CRTC_PORT,0x03, 0xE0, (UCHAR) (usTemp & 0x1F));
+    usTemp = (mode->CrtcHSyncStart >> 3 );
+    if (usTemp & 0x100) jRegAC |= 0x40;			/* HRS D[5] */    
+    SetIndexRegMask(CRTC_PORT,0x04, 0x00, (UCHAR) (usTemp)); 
+    usTemp = (mode->CrtcHSyncEnd >> 3 ) & 0x3F;
+    if (usTemp & 0x20) jRegAD |= 0x04;			/* HRE D[5] */    
+    SetIndexRegMask(CRTC_PORT,0x05, 0x60, (UCHAR) ((usTemp & 0x1F) | jReg05));
+ 
+    SetIndexRegMask(CRTC_PORT,0xAC, 0x00, (UCHAR) jRegAC);        	
+    SetIndexRegMask(CRTC_PORT,0xAD, 0x00, (UCHAR) jRegAD); 
+    
+    /* Vetical Timing Programming */
+    usTemp = (mode->CrtcVTotal) - 2;
+    if (usTemp & 0x100) jReg07 |= 0x01;			/* VT D[8] */
+    if (usTemp & 0x200) jReg07 |= 0x20;			
+    if (usTemp & 0x400) jRegAE |= 0x01;			/* VT D[10] */    
+    SetIndexRegMask(CRTC_PORT,0x06, 0x00, (UCHAR) usTemp);  
+    usTemp = (mode->CrtcVSyncStart) - 1;
+    if (usTemp & 0x100) jReg07 |= 0x04;			/* VRS D[8] */
+    if (usTemp & 0x200) jReg07 |= 0x80;			/* VRS D[9] */
+    if (usTemp & 0x400) jRegAE |= 0x08;			/* VRS D[10] */    
+    SetIndexRegMask(CRTC_PORT,0x10, 0x00, (UCHAR) usTemp); 
+    usTemp = ((mode->CrtcVSyncEnd) - 1) & 0x3F;
+    if (usTemp & 0x10) jRegAE |= 0x20;			/* VRE D[4] */
+    if (usTemp & 0x20) jRegAE |= 0x40;			/* VRE D[5] */
+    SetIndexRegMask(CRTC_PORT,0x11, 0x70, (UCHAR) (usTemp & 0x0F)); 
+    usTemp = (mode->CrtcVDisplay) - 1;
+    if (usTemp & 0x100) jReg07 |= 0x02;			/* VDE D[8] */
+    if (usTemp & 0x200) jReg07 |= 0x40;			/* VDE D[9] */
+    if (usTemp & 0x400) jRegAE |= 0x02;			/* VDE D[10] */  
+    SetIndexRegMask(CRTC_PORT,0x12, 0x00, (UCHAR) usTemp); 
+    usTemp = (mode->CrtcVBlankStart) - 1;
+    if (usTemp & 0x100) jReg07 |= 0x08;			/* VBS D[8] */
+    if (usTemp & 0x200) jReg09 |= 0x20;			/* VBS D[9] */
+    if (usTemp & 0x400) jRegAE |= 0x04;			/* VBS D[10] */  
+    SetIndexRegMask(CRTC_PORT,0x15, 0x00, (UCHAR) usTemp);     
+    usTemp = (mode->CrtcVBlankEnd) - 1 ;
+    if (usTemp & 0x100) jRegAE |= 0x10;			/* VBE D[8] */
+    SetIndexRegMask(CRTC_PORT,0x16, 0x00, (UCHAR) usTemp);                                
+
+    SetIndexRegMask(CRTC_PORT,0x07, 0x00, (UCHAR) jReg07);                                
+    SetIndexRegMask(CRTC_PORT,0x09, 0xDF, (UCHAR) jReg09);                                
+    SetIndexRegMask(CRTC_PORT,0xAE, 0x00, (UCHAR) (jRegAE | 0x80));	/* disable line compare */
+    
+    /* lock CRTC */
+    SetIndexRegMask(CRTC_PORT,0x11, 0x7F, 0x80);                                    
+                   	
+}
+
+void vSetOffsetReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo)
+{
+    ASTRecPtr pAST;	
+    USHORT usOffset;	
+
+    pAST = ASTPTR(pScrn);
+
+    usOffset = 	pAST->VideoModeInfo.ScreenPitch >> 3;		/* Unit: char */
+        
+    SetIndexReg(CRTC_PORT,0x13, (UCHAR) (usOffset & 0xFF));         	
+    SetIndexReg(CRTC_PORT,0xB0, (UCHAR) ((usOffset >> 8) & 0x3F));         	
+    
+}
+
+void vSetDCLKReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo)
+{
+    PVBIOS_ENHTABLE_STRUCT pEnhModePtr;
+    PVBIOS_DCLK_INFO pDCLKPtr;
+    ASTRecPtr pAST;	
+        
+    pAST = ASTPTR(pScrn);
+
+    pEnhModePtr = pVGAModeInfo->pEnhTableEntry;
+    pDCLKPtr = &DCLKTable[pEnhModePtr->DCLKIndex];
+
+    SetIndexRegMask(CRTC_PORT,0xC0, 0x00,  pDCLKPtr->Param1); 
+    SetIndexRegMask(CRTC_PORT,0xC1, 0x00,  pDCLKPtr->Param2);    
+    SetIndexRegMask(CRTC_PORT,0xBB, 0xCF,  ((pDCLKPtr->Param3 & 0x03) << 4));                                                                                                       
+    	
+}
+
+
+void vSetExtReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo)
+{
+	
+    ASTRecPtr pAST;
+    UCHAR jRegA0, jRegA3, jRegA8;
+    	
+    pAST = ASTPTR(pScrn);
+
+    jRegA0=jRegA3=jRegA8=0;	
+    /* Mode Type Setting */	
+    switch (pScrn->bitsPerPixel) {
+    case 8:
+        jRegA0 = 0x70;
+        jRegA3 = 0x01;
+        jRegA8 = 0x00;        
+        break;
+    case 15:        
+    case 16:
+        jRegA0 = 0x70; 
+        jRegA3 = 0x04;
+        jRegA8 = 0x02;                   
+        break;    
+    case 32:
+        jRegA0 = 0x70; 
+        jRegA3 = 0x08;
+        jRegA8 = 0x02;                   
+        break;
+    }	
+    SetIndexRegMask(CRTC_PORT,0xA0, 0x8F, (UCHAR) jRegA0);                                
+    SetIndexRegMask(CRTC_PORT,0xA3, 0xF0, (UCHAR) jRegA3);                                
+    SetIndexRegMask(CRTC_PORT,0xA8, 0xFD, (UCHAR) jRegA8);                                
+
+    /* Set Threshold */
+    SetIndexReg(CRTC_PORT,0xA7, 0x2F);                                
+    SetIndexReg(CRTC_PORT,0xA6, 0x1F);                                
+   	
+}
+
+
+Bool bSetDACReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo)
+{
+    PVBIOS_DAC_INFO pDACPtr;
+    ASTRecPtr pAST;  	
+    ULONG i, ulDACNumber;
+    UCHAR DACR, DACG, DACB;
+
+    pAST = ASTPTR(pScrn);    
+
+    switch (pScrn->bitsPerPixel)
+    {
+    case 8:
+         ulDACNumber = DAC_NUM_VGA;
+         pDACPtr = (PVBIOS_DAC_INFO) &DAC_VGA[0];
+         break;
+    default:
+         return (FALSE);
+    }
+
+    for (i=0; i<ulDACNumber; i++)
+    {
+    	DACR = pDACPtr->DACR;
+    	DACG = pDACPtr->DACG;
+    	DACB = pDACPtr->DACB;
+
+        VGA_LOAD_PALETTE_INDEX (i, DACR, DACG, DACB);
+        
+        pDACPtr++;
+    }
+
+    return (TRUE);
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_mode.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Mode Limitation */
+#define MAX_HResolution		1600
+#define MAX_VResolution		1200
+ 
+/* Std. Table Index Definition */
+#define TextModeIndex 		0
+#define EGAModeIndex 		1
+#define VGAModeIndex 		2
+#define HiCModeIndex 		3
+#define TrueCModeIndex 		4
+
+/* DCLK Index */
+#define VCLK25_175     		0x00
+#define VCLK28_322     		0x01
+#define VCLK31_5       		0x02
+#define VCLK36         		0x03
+#define VCLK40         		0x04
+#define VCLK49_5       		0x05
+#define VCLK50         		0x06
+#define VCLK56_25      		0x07
+#define VCLK65		 	0x08
+#define VCLK75	        	0x09
+#define VCLK78_75      		0x0A
+#define VCLK94_5       		0x0B
+#define VCLK108        		0x0C
+#define VCLK135        		0x0D
+#define VCLK157_5      		0x0E
+#define VCLK162        		0x0F
+
+/* Flags Definition */
+#define Charx8Dot               0x00000001
+#define HalfDCLK                0x00000002
+#define DoubleScanMode          0x00000004
+#define LineCompareOff          0x00000008
+#define SyncPP                  0x00000000
+#define SyncPN                  0x00000040
+#define SyncNP                  0x00000080
+#define SyncNN                  0x000000C0
+#define HBorder                 0x00000020
+#define VBorder                 0x00000010
+
+/* DAC Definition */
+#define DAC_NUM_TEXT		64
+#define DAC_NUM_EGA		64
+#define DAC_NUM_VGA		256
+
+/* Data Structure decalration for internal use */
+typedef struct {
+	
+    UCHAR MISC;	
+    UCHAR SEQ[4];
+    UCHAR CRTC[25];
+    UCHAR AR[20];	    
+    UCHAR GR[9];
+    
+} VBIOS_STDTABLE_STRUCT, *PVBIOS_STDTABLE_STRUCT;
+
+typedef struct {
+	
+    ULONG HT;
+    ULONG HDE;
+    ULONG HFP;
+    ULONG HSYNC;
+    ULONG VT;
+    ULONG VDE;
+    ULONG VFP;
+    ULONG VSYNC;
+    ULONG DCLKIndex;        
+    ULONG Flags;
+
+    ULONG ulRefreshRate;
+    ULONG ulRefreshRateIndex;
+    ULONG ulModeID;
+        
+} VBIOS_ENHTABLE_STRUCT, *PVBIOS_ENHTABLE_STRUCT;
+
+typedef struct {
+    UCHAR Param1;
+    UCHAR Param2;
+    UCHAR Param3;	
+} VBIOS_DCLK_INFO, *PVBIOS_DCLK_INFO;
+
+typedef struct {
+    UCHAR DACR;
+    UCHAR DACG;
+    UCHAR DACB;	
+} VBIOS_DAC_INFO, *PVBIOS_DAC_INFO;
+
+typedef struct {
+    PVBIOS_STDTABLE_STRUCT pStdTableEntry;
+    PVBIOS_ENHTABLE_STRUCT pEnhTableEntry;
+    	
+} VBIOS_MODE_INFO, *PVBIOS_MODE_INFO;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_tool.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+/* Prototype type declaration*/
+Bool ASTMapMem(ScrnInfoPtr pScrn);
+Bool ASTUnmapMem(ScrnInfoPtr pScrn);
+Bool ASTMapMMIO(ScrnInfoPtr pScrn);
+void ASTUnmapMMIO(ScrnInfoPtr pScrn);
+
+Bool
+ASTMapMem(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+
+   pAST->FBVirtualAddr = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
+				 pAST->PciTag,
+				 pAST->FBPhysAddr, pAST->FbMapSize);
+				 
+   if (!pAST->FBVirtualAddr)
+      return FALSE;
+
+   return TRUE;
+}
+
+Bool
+ASTUnmapMem(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST = ASTPTR(pScrn);
+ 
+   xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pAST->FBVirtualAddr,
+		   pAST->FbMapSize);
+		   
+   pAST->FBVirtualAddr = 0;
+   
+   return TRUE;
+}
+
+Bool
+ASTMapMMIO(ScrnInfoPtr pScrn)
+{
+   int mmioFlags;
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+#if !defined(__alpha__)
+   mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT;
+#else
+   mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT | VIDMEM_SPARSE;
+#endif
+
+   pAST->MMIOVirtualAddr = xf86MapPciMem(pScrn->scrnIndex, mmioFlags,
+				         pAST->PciTag,
+				         pAST->MMIOPhysAddr, pAST->MMIOMapSize);
+   if (!pAST->MMIOVirtualAddr)
+      return FALSE;
+
+   return TRUE;
+}
+
+void
+ASTUnmapMMIO(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+   xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pAST->MMIOVirtualAddr,
+		   pAST->MMIOMapSize);
+   pAST->MMIOVirtualAddr = 0;
+   
+}
+ 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_vgatool.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+/* Prototype type declaration*/
+void vASTOpenKey(ScrnInfoPtr pScrn);
+Bool bASTRegInit(ScrnInfoPtr pScrn);
+ULONG GetVRAMInfo(ScrnInfoPtr pScrn);
+ULONG GetMaxDCLK(ScrnInfoPtr pScrn);
+void vAST1000DisplayOn(ASTRecPtr pAST);
+void vAST1000DisplayOff(ASTRecPtr pAST);
+void vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base);
+void vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual);
+void ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
+
+void
+vASTOpenKey(ScrnInfoPtr pScrn)
+{   	
+   ASTRecPtr pAST = ASTPTR(pScrn);
+   
+   SetIndexReg(CRTC_PORT,0x80, 0xA8);     
+   
+}
+
+Bool
+bASTRegInit(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST = ASTPTR(pScrn);
+
+   /* Enable MMIO */
+   SetIndexRegMask(CRTC_PORT,0xA1, 0xFF, 0x04);
+
+   return (TRUE);
+   	
+}
+
+ULONG
+GetVRAMInfo(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST = ASTPTR(pScrn);
+   UCHAR jReg;
+
+   vASTOpenKey(pScrn);
+
+   GetIndexRegMask(CRTC_PORT, 0xAA, 0xFF, jReg);  
+
+   switch (jReg & 0x03)
+   {
+   case 0x00:
+       return (VIDEOMEM_SIZE_08M);           
+   case 0x01:
+       return (VIDEOMEM_SIZE_16M);                  
+   case 0x02:
+       return (VIDEOMEM_SIZE_32M);                 
+   case 0x03:	
+       return (VIDEOMEM_SIZE_64M); 
+   }                     
+ 
+   return (DEFAULT_VIDEOMEM_SIZE);
+   	
+}
+
+ULONG
+GetMaxDCLK(ScrnInfoPtr pScrn)
+{
+   ASTRecPtr pAST = ASTPTR(pScrn);
+   UCHAR jReg;
+   ULONG ulData, ulData2;
+   ULONG ulRefPLL, ulDeNumerator, ulNumerator, ulDivider;
+   ULONG ulDRAMBusWidth, ulMCLK, ulDRAMBandwidth, ActualDRAMBandwidth, DRAMEfficiency = 500;
+   ULONG ulDCLK;
+	
+   vASTOpenKey(pScrn);
+
+   *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000;
+   *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x00000001;
+   
+   /* Get BusWidth */
+   ulData = *(ULONG * ) (pAST->MMIOVirtualAddr + 0x10004);       
+   if (ulData & 0x40)
+      ulDRAMBusWidth = 16;
+   else    
+      ulDRAMBusWidth = 32;
+          
+   /* Get MCLK */
+   {
+       *(ULONG *) (pAST->MMIOVirtualAddr + 0x10100) = 0x000000A8;
+   	
+       ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10120);       
+       ulData2 = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10170);       
+       if (ulData2 & 0x2000)
+           ulRefPLL = 14318;
+       else
+           ulRefPLL = 12000;
+           
+       ulDeNumerator = ulData & 0x1F;
+       ulNumerator = (ulData & 0x3FE0) >> 5;
+               
+       ulData = (ulData & 0xC000) >> 14;        
+       switch (ulData)
+       {
+       case 0x03:
+           ulDivider = 0x04;
+           break;
+       case 0x02:
+       case 0x01:        
+           ulDivider = 0x02;
+           break;
+       default:
+           ulDivider = 0x01;                         
+       }    
+       
+       ulMCLK = ulRefPLL * (ulNumerator + 2) / ((ulDeNumerator + 2) * ulDivider * 1000);          
+       
+   }  
+   
+   /* Get Bandwidth */  
+   ulDRAMBandwidth = ulMCLK * ulDRAMBusWidth * 2 / 8;
+   ActualDRAMBandwidth = ulDRAMBandwidth * DRAMEfficiency / 1000;
+   
+   /* Get Max DCLK */    
+   GetIndexRegMask(CRTC_PORT, 0xD0, 0xFF, jReg);  
+   if (jReg & 0x08)                      
+       ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1+16) / 8);	
+   else    
+       ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1) / 8);	   
+
+   if (ulDCLK > 165) ulDCLK = 165;
+   
+   return(ulDCLK);
+   
+}
+
+void
+vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base)
+{
+    SetIndexReg(CRTC_PORT,0x0D, (UCHAR) (base & 0xFF));
+    SetIndexReg(CRTC_PORT,0x0C, (UCHAR) ((base >> 8) & 0xFF));
+    SetIndexReg(CRTC_PORT,0xAF, (UCHAR) ((base >> 16) & 0xFF));
+    	
+}
+
+void
+vAST1000DisplayOff(ASTRecPtr pAST)
+{
+    SetIndexRegMask(SEQ_PORT,0x01, 0xDF, 0x20);
+	    
+}
+
+
+void
+vAST1000DisplayOn(ASTRecPtr pAST)
+{
+	
+    SetIndexRegMask(SEQ_PORT,0x01, 0xDF, 0x00);	
+    
+}	
+
+
+void
+vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
+               VisualPtr pVisual)
+{
+	
+    ASTRecPtr  pAST = ASTPTR(pScrn);
+    int     i, j, index;
+    UCHAR DACIndex, DACR, DACG, DACB;
+  
+    switch (pScrn->bitsPerPixel) {
+    case 15:
+        for(i=0; i<numColors; i++) {
+            index = indices[i];
+	    for(j=0; j<8; j++) {
+                DACIndex = (index * 8) + j;
+                DACR = colors[index].red << (8- pScrn->rgbBits);
+                DACG = colors[index].green << (8- pScrn->rgbBits);
+                DACB = colors[index].blue << (8- pScrn->rgbBits);
+                         
+                VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);                         
+	    }
+        }
+        break;
+        
+    case 16:
+        for(i=0; i<numColors; i++) {
+            index = indices[i];
+	    for(j=0; j<4; j++) {
+                DACIndex = (index * 4) + j;
+                DACR = colors[index/2].red << (8- pScrn->rgbBits);
+                DACG = colors[index].green << (8- pScrn->rgbBits);
+                DACB = colors[index/2].blue << (8- pScrn->rgbBits);
+                         
+                VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);                         
+	    }
+        }
+        break;
+        
+    case 24:
+        for(i=0; i<numColors; i++) {
+            index = indices[i];
+            DACIndex = index;
+            DACR = colors[index].red;
+            DACG = colors[index].green;
+            DACB = colors[index].blue;
+                         
+            VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);                         
+        }    
+        break;
+        
+    default:
+        for(i=0; i<numColors; i++) {
+            index = indices[i];
+            DACIndex = index;
+            DACR = colors[index].red >> (8 - pScrn->rgbBits);
+            DACG = colors[index].green >> (8 - pScrn->rgbBits);
+            DACB = colors[index].blue >> (8 - pScrn->rgbBits);
+                         
+            VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);                         
+        }    
+
+    } /* end of switch */
+    
+} /* end of vASTLoadPalette */
+
+void
+ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
+{
+   ASTRecPtr pAST;
+   UCHAR SEQ01, CRB6;
+
+   pAST = ASTPTR(pScrn);
+   SEQ01=CRB6=0;
+   
+   vASTOpenKey(pScrn);
+   
+   switch (PowerManagementMode) {
+   case DPMSModeOn:
+      /* Screen: On; HSync: On, VSync: On */
+      SEQ01 = 0x00;
+      CRB6 = 0x00;
+      break;
+   case DPMSModeStandby:
+      /* Screen: Off; HSync: Off, VSync: On */
+      SEQ01 = 0x20;
+      CRB6  = 0x01;     
+      break;
+   case DPMSModeSuspend:
+      /* Screen: Off; HSync: On, VSync: Off */
+      SEQ01 = 0x20;
+      CRB6  = 0x02;           
+      break;
+   case DPMSModeOff:
+      /* Screen: Off; HSync: Off, VSync: Off */
+      SEQ01 = 0x20;
+      CRB6  = 0x03;           
+      break;
+   }
+
+   SetIndexRegMask(SEQ_PORT,0x01, 0xDF, SEQ01);
+   SetIndexRegMask(CRTC_PORT,0xB6, 0xFC, CRB6);
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ast/ast_vgatool.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2005 ASPEED Technology 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 the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* VRAM Size Definition */
+#define VIDEOMEM_SIZE_08M	0x00800000
+#define VIDEOMEM_SIZE_16M	0x01000000
+#define VIDEOMEM_SIZE_32M	0x02000000
+#define VIDEOMEM_SIZE_64M	0x04000000
+
+#define AR_PORT_WRITE		(pAST->RelocateIO + 0x40)
+#define MISC_PORT_WRITE		(pAST->RelocateIO + 0x42)
+#define SEQ_PORT 		(pAST->RelocateIO + 0x44)
+#define DAC_INDEX_WRITE		(pAST->RelocateIO + 0x48)
+#define DAC_DATA		(pAST->RelocateIO + 0x49)
+#define GR_PORT			(pAST->RelocateIO + 0x4E)
+#define CRTC_PORT 		(pAST->RelocateIO + 0x54)
+#define INPUT_STATUS1_READ	(pAST->RelocateIO + 0x5A)
+
+#define GetReg(base)				inb(base)
+#define SetReg(base,val)			outb(base,val)
+#define GetIndexReg(base,index,val)			do {			\
+                      				outb(base,index);	\
+                      				val = inb(base+1);		\
+                    				} while (0)
+#define SetIndexReg(base,index, val)		do { \
+                      				outb(base,index);	\
+                      				outb(base+1,val);   	\
+                    				} while (0)
+#define GetIndexRegMask(base,index, and, val)	do {			\
+                      				outb(base,index);	\
+                      				val = (inb(base+1) & and);		\
+                    				} while (0)                    			
+#define SetIndexRegMask(base,index, and, val)  	do { \
+                      				UCHAR __Temp; 	\
+                      				outb(base,index);   	\
+                      				__Temp = (inb((base)+1)&(and))|(val); 	\
+                      				SetIndexReg(base,index,__Temp); 	\
+                    				} while (0)
+
+#define VGA_LOAD_PALETTE_INDEX(index, red, green, blue) \
+{ \
+   UCHAR __junk;				\
+   SetReg(DAC_INDEX_WRITE,(UCHAR)(index));	\
+   __junk = GetReg(SEQ_PORT);			\
+   SetReg(DAC_DATA,(UCHAR)(red));		\
+   __junk = GetReg(SEQ_PORT);			\
+   SetReg(DAC_DATA,(UCHAR)(green));		\
+   __junk = GetReg(SEQ_PORT);			\
+   SetReg(DAC_DATA,(UCHAR)(blue));		\
+   __junk = GetReg(SEQ_PORT);      		\
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,352 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c,v 1.15tsi Exp $*/
+/*
+ * Copyright 2000 through 2004 by Marc Aurele La France (TSI @ UQV), [email protected]
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of Marc Aurele La France not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Marc Aurele La France makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
+ * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * DRI support by:
+ *    Leif Delgass <[email protected]>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ati.h"
+#include "atiadapter.h"
+#include "atichip.h"
+#include "aticonfig.h"
+#include "aticursor.h"
+#include "atioption.h"
+#include "atistruct.h"
+
+#include "mach64_common.h"
+
+/*
+ * Non-publicised XF86Config options.
+ */
+typedef enum
+{
+    ATI_OPTION_BIOS_DISPLAY,    /* Allow BIOS interference */
+    ATI_OPTION_CRT_SCREEN,      /* Legacy negation of "PanelDisplay" */
+    ATI_OPTION_DEVEL,           /* Intentionally undocumented */
+    ATI_OPTION_BLEND,           /* Force horizontal blending of small modes */
+    ATI_OPTION_LCDSYNC,         /* Use XF86Config panel mode porches */
+    ATI_OPTION_OFFSCRN_PIXMAP   /* Enable offscreen pixmap */
+} ATIPrivateOptionType;
+
+/*
+ * ATIProcessOptions --
+ *
+ * This function extracts options from what was parsed out of the XF86Config
+ * file.
+ */
+void
+ATIProcessOptions
+(
+    ScrnInfoPtr pScreenInfo,
+    ATIPtr      pATI
+)
+{
+    OptionInfoPtr PublicOption = xnfalloc(ATIPublicOptionSize);
+    OptionInfoRec PrivateOption[] =
+    {
+        {                       /* ON:  Let BIOS change display(s) */
+            ATI_OPTION_BIOS_DISPLAY,    /* OFF:  Don't */
+            "biosdisplay",
+            OPTV_BOOLEAN,
+            {0, },
+            FALSE
+        },
+        {                       /* Negation of "PanelDisplay" public option */
+            ATI_OPTION_CRT_SCREEN,
+            "crtscreen",
+            OPTV_BOOLEAN,
+            {0, },
+            FALSE
+        },
+        {                       /* ON:   Ease exploration of loose ends */
+            ATI_OPTION_DEVEL,   /* OFF:  Fit for public consumption */
+            "tsi",
+            OPTV_BOOLEAN,
+            {0, },
+            FALSE
+        },
+        {                       /* ON:   Horizontally blend most modes */
+            ATI_OPTION_BLEND,   /* OFF:  Use pixel replication more often */
+            "lcdblend",
+            OPTV_BOOLEAN,
+            {0, },
+            FALSE
+        },
+        {                       /* ON:   Use XF86Config porch timings */
+            ATI_OPTION_LCDSYNC, /* OFF:  Use porches from mode on entry */
+            "lcdsync",
+            OPTV_BOOLEAN,
+            {0, },
+            FALSE
+        },
+	{
+	    ATI_OPTION_OFFSCRN_PIXMAP, /* ON: disable offscreen  pixmap */
+	    "offscreenpixmap",             /* OFF: enable offscreen pixmap */
+	    OPTV_BOOLEAN,
+	    {0, },
+	    FALSE
+	},
+        {
+            -1,
+            NULL,
+            OPTV_NONE,
+            {0, },
+            FALSE
+        }
+    };
+
+    (void)memcpy(PublicOption, ATIPublicOptions, ATIPublicOptionSize);
+
+#   define Accel         PublicOption[ATI_OPTION_ACCEL].value.bool
+#   define BIOSDisplay   PrivateOption[ATI_OPTION_BIOS_DISPLAY].value.bool
+#   define Blend         PrivateOption[ATI_OPTION_BLEND].value.bool
+#   define CRTDisplay    PublicOption[ATI_OPTION_CRT_DISPLAY].value.bool
+#   define CRTScreen     PrivateOption[ATI_OPTION_CRT_SCREEN].value.bool
+#   define CSync         PublicOption[ATI_OPTION_CSYNC].value.bool
+#   define Devel         PrivateOption[ATI_OPTION_DEVEL].value.bool
+#   define HWCursor      PublicOption[ATI_OPTION_HWCURSOR].value.bool
+
+#ifndef AVOID_CPIO
+
+#   define Linear        PublicOption[ATI_OPTION_LINEAR].value.bool
+
+#endif /* AVOID_CPIO */
+
+#ifdef XF86DRI_DEVEL
+
+#   define IsPCI       PublicOption[ATI_OPTION_IS_PCI].value.bool
+#   define DMAMode     PublicOption[ATI_OPTION_DMA_MODE].value.str
+#   define AGPMode     PublicOption[ATI_OPTION_AGP_MODE].value.num
+#   define AGPSize     PublicOption[ATI_OPTION_AGP_SIZE].value.num
+#   define LocalTex    PublicOption[ATI_OPTION_LOCAL_TEXTURES].value.bool
+#   define BufferSize  PublicOption[ATI_OPTION_BUFFER_SIZE].value.num
+
+#endif /* XF86DRI_DEVEL */
+
+#ifdef TV_OUT
+
+#   define TvOut        PublicOption[ATI_OPTION_TV_OUT].value.bool
+#   define TvStd        PublicOption[ATI_OPTION_TV_STD].value.str
+
+#endif /* TV_OUT */
+
+#   define CacheMMIO     PublicOption[ATI_OPTION_MMIO_CACHE].value.bool
+#   define TestCacheMMIO PublicOption[ATI_OPTION_TEST_MMIO_CACHE].value.bool
+#   define PanelDisplay  PublicOption[ATI_OPTION_PANEL_DISPLAY].value.bool
+#   define ProbeClocks   PublicOption[ATI_OPTION_PROBE_CLOCKS].value.bool
+#   define ShadowFB      PublicOption[ATI_OPTION_SHADOW_FB].value.bool
+#   define SWCursor      PublicOption[ATI_OPTION_SWCURSOR].value.bool
+#   define LCDSync       PrivateOption[ATI_OPTION_LCDSYNC].value.bool
+#   define OffScrnPixmap PrivateOption[ATI_OPTION_OFFSCRN_PIXMAP].value.bool
+
+#   define ReferenceClock \
+        PublicOption[ATI_OPTION_REFERENCE_CLOCK].value.freq.freq
+
+    /* Pick up XF86Config options */
+    xf86CollectOptions(pScreenInfo, NULL);
+
+    /* Set non-zero defaults */
+
+#ifndef AVOID_CPIO
+
+    if (pATI->Adapter >= ATI_ADAPTER_MACH64)
+
+#endif /* AVOID_CPIO */
+
+    {
+        Accel = CacheMMIO = HWCursor = TRUE;
+
+#ifndef AVOID_CPIO
+
+        Linear = TRUE;
+
+#endif /* AVOID_CPIO */
+
+#ifdef TV_OUT
+
+	TvStd = "None";  /* No tv standard change requested */
+
+#endif
+    }
+
+    ReferenceClock = ((double)157500000.0) / ((double)11.0);
+
+#ifndef AVOID_CPIO
+
+    if (pATI->PCIInfo)
+
+#endif /* AVOID_CPIO */
+
+    {
+        ShadowFB = TRUE;
+    }
+
+    Blend = PanelDisplay = TRUE;
+#ifdef XF86DRI_DEVEL
+    DMAMode = "mmio";
+#endif
+
+    xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
+        PublicOption);
+    xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
+        PrivateOption);
+
+#ifndef AVOID_CPIO
+
+    /* Disable linear apertures if the OS doesn't support them */
+    if (!xf86LinearVidMem() && Linear)
+    {
+        if (PublicOption[ATI_OPTION_LINEAR].found)
+            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+                "OS does not support linear apertures.\n");
+        Linear = FALSE;
+    }
+
+#endif /* AVOID_CPIO */
+
+    /* Move option values into driver private structure */
+    pATI->OptionAccel = Accel;
+    pATI->OptionBIOSDisplay = BIOSDisplay;
+    pATI->OptionBlend = Blend;
+    pATI->OptionCRTDisplay = CRTDisplay;
+    pATI->OptionCSync = CSync;
+    pATI->OptionDevel = Devel;
+
+#ifndef AVOID_CPIO
+
+    pATI->OptionLinear = Linear;
+
+#endif /* AVOID_CPIO */
+
+#ifdef TV_OUT
+
+    if (TvOut && pATI->Chip < ATI_CHIP_264GT) {
+       /* Only allow this for 3D Rage (I) or greater chip ID
+	* AFAIK, no chips before this supported TV-Out
+	* mach64VT has support for TV tuner, but no TV-Out
+	*/
+	xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+                "TV Out not supported for this chip.\n");
+    } else {
+	ATITVStandard std;
+	pATI->OptionTvOut = TvOut;
+	pATI->OptionTvStd = ATI_TV_STD_INVALID;
+	for (std = 0; std < ATI_TV_STDS_MAX_VALID; std++) {
+	    if (std != ATI_TV_STD_RESERVED1 && std != ATI_TV_STD_RESERVED2) {
+		if (strncasecmp(TvStd, ATITVStandardNames[std], ATI_TV_STDS_NAME_MAXLEN)==0) {
+		    pATI->OptionTvStd = std;
+		    break;
+		}
+	    }
+	}
+    }
+
+#endif /* TV_OUT */
+
+    pATI->OptionMMIOCache = CacheMMIO;
+    pATI->OptionTestMMIOCache = TestCacheMMIO;
+    pATI->OptionProbeClocks = ProbeClocks;
+    pATI->OptionShadowFB = ShadowFB;
+    pATI->OptionLCDSync = LCDSync;
+    pATI->OptionOffScrnPixmap = OffScrnPixmap;
+
+    /* "CRTScreen" is now "NoPanelDisplay" */
+    if ((PanelDisplay != CRTScreen) ||
+        PublicOption[ATI_OPTION_PANEL_DISPLAY].found)
+        pATI->OptionPanelDisplay = PanelDisplay;
+    else
+        pATI->OptionPanelDisplay = !CRTScreen;
+
+#ifdef XF86DRI_DEVEL
+
+    pATI->OptionIsPCI = IsPCI;
+    pATI->OptionAGPMode = AGPMode;
+    pATI->OptionAGPSize = AGPSize;
+    pATI->OptionLocalTextures = LocalTex;
+    pATI->OptionBufferSize = BufferSize;
+
+    if (strcasecmp(DMAMode, "async")==0)
+        pATI->OptionDMAMode = MACH64_MODE_DMA_ASYNC;
+    else if (strcasecmp(DMAMode, "sync")==0)
+        pATI->OptionDMAMode = MACH64_MODE_DMA_SYNC;
+    else if (strcasecmp(DMAMode, "mmio")==0 )
+        pATI->OptionDMAMode = MACH64_MODE_MMIO;
+    else {
+        xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+		   "Unkown dma_mode: '%s'\n", DMAMode);
+	xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+		   "Valid dma_mode options are: 'async','sync','mmio'\n");
+        xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+		   "Defaulting to async DMA mode\n");
+	pATI->OptionDMAMode = MACH64_MODE_DMA_ASYNC;
+    }
+
+#endif /* XF86DRI_DEVEL */
+
+    /* Validate and set cursor options */
+    pATI->Cursor = ATI_CURSOR_SOFTWARE;
+    if (SWCursor || !HWCursor)
+    {
+        if (HWCursor && PublicOption[ATI_OPTION_HWCURSOR].found)
+            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+                "Option \"sw_cursor\" overrides Option \"hw_cursor\".\n");
+    }
+    else if (pATI->Chip < ATI_CHIP_264CT)
+    {
+        if (HWCursor && PublicOption[ATI_OPTION_HWCURSOR].found)
+            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+                "Option \"hw_cursor\" not supported in this configuration.\n");
+    }
+    else
+    {
+        pATI->Cursor = ATI_CURSOR_HARDWARE;
+    }
+
+    /* Only set the reference clock if it hasn't already been determined */
+    if (!pATI->ReferenceNumerator || !pATI->ReferenceDenominator)
+    {
+        switch ((int)(ReferenceClock / ((double)100000.0)))
+        {
+            case 143:
+                pATI->ReferenceNumerator = 157500;
+                pATI->ReferenceDenominator = 11;
+                break;
+
+            case 286:
+                pATI->ReferenceNumerator = 315000;
+                pATI->ReferenceDenominator = 11;
+                break;
+
+            default:
+                pATI->ReferenceNumerator =
+                    (int)(ReferenceClock / ((double)1000.0));
+                pATI->ReferenceDenominator = 1;
+                break;
+        }
+    }
+
+    xfree(PublicOption);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,885 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.22 2003/11/13 18:42:47 tsi Exp $ */
+/*
+ * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), [email protected]
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of Marc Aurele La France not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Marc Aurele La France makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
+ * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * DRI support by:
+ *    Manuel Teira
+ *    Leif Delgass <[email protected]>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ati.h"
+#include "atiadapter.h"
+#include "aticonsole.h"
+#include "aticrtc.h"
+#include "atii2c.h"
+#include "atilock.h"
+#include "atimach64.h"
+#include "atimach64io.h"
+#include "atimode.h"
+#include "atistruct.h"
+#include "ativga.h"
+#include "atividmem.h"
+
+#ifdef XF86DRI_DEVEL
+#include "mach64_common.h"
+#include "atidri.h"
+#endif
+
+#include "mach64_common.h"
+
+
+
+#include "xf86.h"
+
+#ifdef TV_OUT
+
+#include "atichip.h"
+#include "atiprint.h"
+#include "atioption.h"
+#include "vbe.h"
+
+static const char *vbeSymbols[] = {
+    "VBEGetVBEMode",
+    NULL
+};
+
+#endif /* TV_OUT */
+
+/*
+ * ATISaveScreen --
+ *
+ * This function is a screen saver hook for DIX.
+ */
+Bool
+ATISaveScreen
+(
+    ScreenPtr pScreen,
+    int       Mode
+)
+{
+    ScrnInfoPtr pScreenInfo;
+    ATIPtr      pATI;
+
+    if ((Mode != SCREEN_SAVER_ON) && (Mode != SCREEN_SAVER_CYCLE))
+        SetTimeSinceLastInputEvent();
+
+    if (!pScreen)
+        return TRUE;
+
+    pScreenInfo = xf86Screens[pScreen->myNum];
+    if (!pScreenInfo->vtSema)
+        return TRUE;
+
+    pATI = ATIPTR(pScreenInfo);
+    switch (pATI->NewHW.crtc)
+    {
+
+#ifndef AVOID_CPIO
+
+        case ATI_CRTC_VGA:
+            ATIVGASaveScreen(pATI, Mode);
+            break;
+
+#endif /* AVOID_CPIO */
+
+        case ATI_CRTC_MACH64:
+            ATIMach64SaveScreen(pATI, Mode);
+            break;
+
+        default:
+            break;
+    }
+
+    return TRUE;
+}
+
+/*
+ * ATISetDPMSMode --
+ *
+ * This function sets the adapter's VESA Display Power Management Signaling
+ * mode.
+ */
+void
+ATISetDPMSMode
+(
+    ScrnInfoPtr pScreenInfo,
+    int         DPMSMode,
+    int         flags
+)
+{
+    ATIPtr pATI;
+
+    if (!pScreenInfo || !pScreenInfo->vtSema)
+        return;
+
+    pATI = ATIPTR(pScreenInfo);
+
+    switch (pATI->Adapter)
+    {
+        case ATI_ADAPTER_MACH64:
+            ATIMach64SetDPMSMode(pScreenInfo, pATI, DPMSMode);
+            break;
+
+        default:
+
+#ifndef AVOID_CPIO
+
+            /* Assume EGA/VGA */
+            ATIVGASetDPMSMode(pATI, DPMSMode);
+            break;
+
+        case ATI_ADAPTER_NONE:
+        case ATI_ADAPTER_8514A:
+        case ATI_ADAPTER_MACH8:
+
+#endif /* AVOID_CPIO */
+
+            break;
+    }
+}
+
+#ifdef TV_OUT
+
+static void
+ATIProbeAndSetActiveDisplays
+(
+    ScrnInfoPtr pScreenInfo,
+    ATIPtr      pATI
+)
+{
+    vbeInfoPtr pVbe;
+    Bool tv_attached, crt_attached, lcd_attached;
+    int disp_request;
+    ATITVStandard tv_std, tv_std_request;
+
+    xf86LoaderRefSymLists(vbeSymbols, NULL);
+
+    if (xf86GetVerbosity() > 3) {
+	xf86ErrorFVerb(4, "\n Before TV-Out queries\n\n",
+		       pScreenInfo->currentMode->name);
+	ATIPrintRegisters(pATI);
+    }
+
+    pATI->tvActive = FALSE;
+    pVbe = pATI->pVBE;
+    if (pVbe) {
+	/* LT Pro, XL, Mobility specific BIOS functions */
+	if (pATI->Chip == ATI_CHIP_264LTPRO ||
+	    pATI->Chip == ATI_CHIP_264XL || 
+	    pATI->Chip == ATI_CHIP_MOBILITY) {
+    
+	    /* Get attached display(s) - LTPro, XL, Mobility */
+	    pVbe->pInt10->num = 0x10;
+	    pVbe->pInt10->ax = 0xa083;
+	    pVbe->pInt10->cx = 0x0700; /* ch=0x07 - probe all, 0x01 CRT, 0x02 TV, 0x04 LCD */
+	    xf86ExecX86int10(pVbe->pInt10);
+
+	    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+		       "Attached displays: ax=0x%04x, cx=0x%04x\n",
+		       pVbe->pInt10->ax, pVbe->pInt10->cx);
+
+	    tv_attached = crt_attached = lcd_attached = FALSE;
+	    if (pVbe->pInt10->ax & 0xff00) {
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			   "Failed to detect attached displays\n");
+	    } else {
+			
+		if (pVbe->pInt10->cx & 0x3)
+		{
+			xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+				   "   CRT attached\n");
+			crt_attached = TRUE;
+		}
+		else
+		    crt_attached = FALSE;
+
+		if ((pVbe->pInt10->cx >> 2) & 0x3)
+		{
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "   DFP/LCD attached\n");
+		    lcd_attached = TRUE;
+		}
+		else
+		    lcd_attached = FALSE;
+
+		switch ((pVbe->pInt10->cx >> 4) & 0x3) {
+		case 0:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "   No TV attached\n");
+		    break;
+		case 1:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "   TV attached (composite connector)\n");
+		    tv_attached = TRUE;
+		    break;
+		case 2:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "   TV attached (S-video connector)\n");
+		    tv_attached = TRUE;
+		    break;
+		case 3:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "   TV attached (S-video/composite connectors)\n");
+		    tv_attached = TRUE;
+		    break;
+		default:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			       "Unrecognized return code: 0x%04x\n", 
+			       pVbe->pInt10->cx);
+		}
+
+	    }
+
+	    /* Get active display  - LTPro, XL, Mobility */
+	    pVbe->pInt10->num = 0x10;
+	    pVbe->pInt10->ax = 0xa084;
+	    pVbe->pInt10->bx = 0x0000; /* bh=0x00 get active, bh=0x01 set active */
+	    xf86ExecX86int10(pVbe->pInt10);
+
+	    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+		       "Active displays: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
+		       pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
+
+	    if (pVbe->pInt10->ax & 0xff00) {
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			   "Failed to detect active display\n");
+	    } else {
+		if (pVbe->pInt10->bx & 0x1) 
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 		       
+			       "   DFP/LCD is active\n");
+
+		if (pVbe->pInt10->bx & 0x2) 
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "   CRT is active\n");
+
+		if (pVbe->pInt10->bx & 0x4) {
+		    
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "   TV is active\n");
+
+		    if (!tv_attached) {
+			/* tv not connected - disable tv */
+			disp_request = 0x00;
+			if (crt_attached)
+			    disp_request |= 0x02; /* enable CRT */
+			if (lcd_attached && pATI->OptionPanelDisplay)
+			    disp_request |= 0x01; /* enable DFP/LCD */
+
+			pVbe->pInt10->num = 0x10;
+			pVbe->pInt10->ax = 0xa084;
+			pVbe->pInt10->bx = 0x0100; /* bh=0x01 set active */
+			pVbe->pInt10->cx = disp_request; 
+			xf86ExecX86int10(pVbe->pInt10);
+
+			xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+				   "TV not present, disabling: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
+				   pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
+			if (pVbe->pInt10->ax & 0xff00) {
+			    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+				       "Disabling TV failed\n");
+			}
+		    } else {
+			pATI->tvActive = TRUE;
+		    }
+
+		} else if (tv_attached && (pVbe->pInt10->bx & 0x0400)) {
+		    /* tv connected and available - enable TV */
+		    disp_request = 0x04;          /* enable TV */
+
+#if 0
+		    /* This works, but CRT image is vertically compressed */
+		    if (crt_attached)
+			    disp_request |= 0x02; /* enable CRT */
+		    /* NOTE: For me, LCD+TV does NOT work */
+		    /*if (lcd_attached && pATI->OptionPanelDisplay)
+			    disp_request |= 0x01; * enable DFP/LCD */
+#endif
+
+		    pVbe->pInt10->num = 0x10;
+		    pVbe->pInt10->ax = 0xa084;
+		    pVbe->pInt10->bx = 0x0100; /* bh=0x01 set active */
+		    pVbe->pInt10->cx = disp_request; /* try to activate TV */
+		    xf86ExecX86int10(pVbe->pInt10);
+		    
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "Setting TV active: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
+			       pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
+		    if (pVbe->pInt10->ax & 0xff00) {
+			xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+				   "Setting TV active failed\n");
+		    } else {
+			pATI->tvActive = TRUE;
+		    }
+		}
+	    }
+
+	} else { /* pATI->Chip < ATI_CHIP_264LTPRO */
+	    /* TVOut Hooks - Check for TVOut BIOS/hardware */
+	    pVbe->pInt10->num = 0x10;
+	    pVbe->pInt10->ax = 0xa019;
+	    pVbe->pInt10->cx = 0x0000; /* TVOut BIOS query */
+	    xf86ExecX86int10(pVbe->pInt10);
+
+	    tv_attached = FALSE;
+
+	    if (pVbe->pInt10->ax & 0xff00) {
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			   "Failed to detect TV-Out BIOS\n");
+	    } else {
+		switch (pVbe->pInt10->ax & 0x0003) {
+		case 3:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "TV-Out BIOS detected and active\n");
+
+		    /* TV attached query */
+		    pVbe->pInt10->num = 0x10;
+		    pVbe->pInt10->ax = 0xa070;
+		    pVbe->pInt10->bx = 0x0002; /* Sub-function: return tv attached info */
+		    xf86ExecX86int10(pVbe->pInt10);
+
+		    if (pVbe->pInt10->ax & 0xff00) {
+			xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+				   "Failed to detect if TV is attached\n");
+		    } else {
+			switch (pVbe->pInt10->cx & 0x0003) {
+			case 3:
+			    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+				       "TV attached to composite and S-video connectors\n");
+			    tv_attached = TRUE;
+			    break;
+			case 2:
+			    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+				       "TV attached to S-video connector\n");
+			    tv_attached = TRUE;
+			    break;
+			case 1:
+			    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+				       "TV attached to composite connector\n");
+			    tv_attached = TRUE;
+			    break;
+			default:
+			    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+				       "TV is not attached\n");
+			}
+		    }
+		    break;
+		case 1:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "TV-Out BIOS service is not available due to" 
+			       "a system BIOS error or TV-Out hardware not being installed\n");
+		    break;
+		default:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "No TV-Out BIOS or hardware detected\n");
+		}
+	    }
+	}
+
+	/* Return TV-Out configuration 
+	 * see Programmer's Guide under "TV Out Specific Functions"
+	 * It's not clear exactly which adapters support these
+	 */
+	pVbe->pInt10->num = 0x10;
+	pVbe->pInt10->ax = 0xa070;
+	pVbe->pInt10->bx = 0x00;
+	xf86ExecX86int10(pVbe->pInt10);
+
+	xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+		   "TV-Out query: ax=0x%04x, bx=0x%04x, cx=0x%04x, dx=0x%04x\n",
+		   pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx, pVbe->pInt10->dx);
+
+	if (pVbe->pInt10->ax & 0xff00) {
+
+	    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+		       "Failed to detect TV-Out configuration.\n");
+
+	} else if (pVbe->pInt10->bx == 0) {
+	    if (pVbe->pInt10->dx == 0) {
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			   "TV-Out is not detected.\n");
+	    } else {
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			   "TV-Out is detected but not supported.\n");
+	    }
+
+	} else if ((pVbe->pInt10->cx & 0xff) == 0) {
+
+	    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+		       "TV-Out is currently disabled.\n");
+	    if (tv_attached && pATI->Chip < ATI_CHIP_264LTPRO) {
+		/* Try to enable TV-Out */
+		pVbe->pInt10->num = 0x10;
+		pVbe->pInt10->ax = 0xa070;
+		pVbe->pInt10->bx = 0x0001; /* Sub-function: Select TV Out */
+		/* cl=0x001 enable, cl=0x000 disable, 
+		 * cl=0x080 disable with feature connector bit preserved 
+		 */
+		pVbe->pInt10->cx = 0x0001;
+			
+		xf86ExecX86int10(pVbe->pInt10);
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			   "Setting TV active: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
+			   pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
+
+		if (pVbe->pInt10->ax & 0xff00) {
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			       "Setting TV active failed\n");
+		} else {
+		    pATI->tvActive = TRUE;
+		}
+	    }
+
+	} else {
+	    pATI->tvActive = TRUE;
+
+	    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+		       "TV-Out is currently enabled (TV-Out revision code: %d).\n",
+		       (pVbe->pInt10->dx >> 8) & 0xff);
+
+	    switch ((pVbe->pInt10->cx >> 8) & 0xff) {
+	    case 0:
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 29.49892\n");
+		break;
+	    case 1:
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 28.63636\n");
+		break;
+	    case 2:
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 14.31818\n");
+		break;
+	    case 3:
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 27.00000\n");
+		break;
+	    default:
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			   "Unknown reference frequency cx=0x%04x\n", pVbe->pInt10->cx);
+		    
+	    }
+
+	    /* Return TV standard
+	     * see Programmer's Guide under "TV Out Specific Functions"
+	     * It's not clear exactly which adapters support these
+	     */
+	    pVbe->pInt10->num = 0x10;
+	    pVbe->pInt10->ax = 0xa071;
+	    pVbe->pInt10->bx = 0x00;
+	    xf86ExecX86int10(pVbe->pInt10);
+
+	    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+		       "TV standard query result: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
+		       pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
+
+	    if (pVbe->pInt10->ax & 0xff00) {
+
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			   "Failed to return TV standard.\n");
+	    } else {
+		tv_std = pVbe->pInt10->cx & 0x00ff;
+		switch (tv_std) {
+		case ATI_TV_STD_NTSC:
+		case ATI_TV_STD_PAL:
+		case ATI_TV_STD_PALM:
+		case ATI_TV_STD_PAL60:
+		case ATI_TV_STD_NTSCJ:
+		case ATI_TV_STD_PALCN:
+		case ATI_TV_STD_PALN:
+		case ATI_TV_STD_SCARTPAL:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
+			       "Current TV standard: %s\n", ATITVStandardNames[tv_std]);
+		    break;
+		default:
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			       "Unrecognized TV standard return code cx=0x%04x\n", 
+			       pVbe->pInt10->cx);
+		}
+
+		tv_std_request = pATI->OptionTvStd;
+		if (tv_std_request < 0 || 
+		    tv_std_request > ATI_TV_STD_NONE || 
+		    tv_std_request == ATI_TV_STD_RESERVED1 || 
+		    tv_std_request == ATI_TV_STD_RESERVED2) {
+		    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+			       "Invalid TV standard requested, please check configuration file\n");
+		} else if (tv_std_request != ATI_TV_STD_NONE) {
+		    /* Set TV standard if requested (LT Pro not supported) */
+		    if (pATI->Chip != ATI_CHIP_264LTPRO &&
+			tv_std_request != tv_std) {
+				
+			pVbe->pInt10->num = 0x10;
+			pVbe->pInt10->ax = 0xa070;
+			pVbe->pInt10->bx = 0x0003; /* sub-function: set TV standard */
+			pVbe->pInt10->cx = tv_std_request;
+			xf86ExecX86int10(pVbe->pInt10);
+			if (pVbe->pInt10->ax & 0xff00)
+			    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+				       "Failed to set TV standard\n");
+			else
+			    xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 
+				       "Set TV standard to %s\n", ATITVStandardNames[tv_std_request]);
+		    } else {
+			xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
+				   "Setting TV standard not supported on ATI Rage LT Pro\n");
+		    }
+		}
+	    }
+	    
+	}
+    } else {
+	xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "VBE module not loaded\n");
+    }
+}
+
+#endif /* TV_OUT */
+
+/*
+ * ATIEnterGraphics --
+ *
+ * This function sets the hardware to a graphics video state.
+ */
+Bool
+ATIEnterGraphics
+(
+    ScreenPtr   pScreen,
+    ScrnInfoPtr pScreenInfo,
+    ATIPtr      pATI
+)
+{
+unsigned int PciReg;
+pciConfigPtr           pPCI;
+pciVideoPtr            pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo();
+
+	pVideo = xf86PciVideoInfo[pScreenInfo->scrnIndex];
+	pPCI = pVideo->thisCard;
+/*
+* Possibly fix block I/O indicator in PCI configuration space.
+*/
+	PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG);
+	if (!(PciReg & 0x00000004U))
+		pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, PciReg | 
+				0x00000004U);
+
+    /* Map apertures */
+    if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI))
+        return FALSE;
+
+    /* Unlock device */
+    ATIUnlock(pATI);
+
+    /* Calculate hardware data */
+    if (pScreen &&
+        !ATIModeCalculate(pScreenInfo->scrnIndex, pATI, &pATI->NewHW,
+            pScreenInfo->currentMode))
+        return FALSE;
+
+    pScreenInfo->vtSema = TRUE;
+
+#ifdef TV_OUT
+    if (pATI->OptionTvOut) {
+
+	xf86LoaderRefSymLists(vbeSymbols, NULL);
+
+	if (pATI->pVBE) {
+	    if (VBEGetVBEMode(pATI->pVBE, &pATI->vbemode)) {
+		xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Saving VESA mode: 0x%x\n", 
+			   pATI->vbemode);
+	    }
+	}
+    }
+#endif /* TV_OUT */
+
+    /* Save current state */
+    ATIModeSave(pScreenInfo, pATI, &pATI->OldHW);
+
+#ifdef TV_OUT
+    if (pATI->OptionTvOut) 
+	ATIProbeAndSetActiveDisplays(pScreenInfo, pATI);
+#endif /* TV_OUT */
+
+    /* Set graphics state */
+    ATIModeSet(pScreenInfo, pATI, &pATI->NewHW);
+
+    /* Possibly blank the screen */
+    if (pScreen)
+       (void)ATISaveScreen(pScreen, SCREEN_SAVER_ON);
+
+    /* Position the screen */
+    (*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex,
+        pScreenInfo->frameX0, pScreenInfo->frameY0, 0);
+
+    SetTimeSinceLastInputEvent();
+
+    return TRUE;
+}
+
+/*
+ * ATILeaveGraphics --
+ *
+ * This function restores the hardware to its previous state.
+ */
+void
+ATILeaveGraphics
+(
+    ScrnInfoPtr pScreenInfo,
+    ATIPtr      pATI
+)
+{
+    if (pScreenInfo->vtSema)
+    {
+        /* If not exiting, save graphics video state */
+        if (!xf86ServerIsExiting())
+            ATIModeSave(pScreenInfo, pATI, &pATI->NewHW);
+
+#ifdef TV_OUT
+	if (pATI->OptionTvOut) 
+	    ATIProbeAndSetActiveDisplays(pScreenInfo, pATI);
+#endif /* TV_OUT */
+
+        /* Restore mode in effect on server entry */
+        ATIModeSet(pScreenInfo, pATI, &pATI->OldHW);
+
+        pScreenInfo->vtSema = FALSE;
+    }
+
+    /* Lock device */
+    ATILock(pATI);
+
+    /* Unmap apertures */
+
+#ifdef AVOID_DGA
+
+    if (!pATI->Closeable)
+
+#else /* AVOID_DGA */
+
+    if (!pATI->Closeable || !pATI->nDGAMode)
+
+#endif /* AVOID_DGA */
+
+        ATIUnmapApertures(pScreenInfo->scrnIndex, pATI);
+
+    SetTimeSinceLastInputEvent();
+}
+
+/*
+ * ATISwitchMode --
+ *
+ * This function switches to another graphics video state.
+ */
+_X_EXPORT Bool
+ATISwitchMode
+(
+    int            iScreen,
+    DisplayModePtr pMode,
+    int            flags
+)
+{
+    ScrnInfoPtr pScreenInfo = xf86Screens[iScreen];
+    ATIPtr      pATI        = ATIPTR(pScreenInfo);
+
+    /* Calculate new hardware data */
+    if (!ATIModeCalculate(iScreen, pATI, &pATI->NewHW, pMode))
+        return FALSE;
+
+    /* Set new hardware state */
+    if (pScreenInfo->vtSema)
+    {
+        pScreenInfo->currentMode = pMode;
+
+#ifdef XF86DRI_DEVEL
+
+        if (pATI->directRenderingEnabled) 
+        {
+            DRILock(pScreenInfo->pScreen,0);
+	    ATIDRIWaitForIdle(pATI);
+        }
+
+#endif /* XF86DRI_DEVEL */
+
+        ATIModeSet(pScreenInfo, pATI, &pATI->NewHW);
+
+#ifdef XF86DRI_DEVEL
+
+        if (pATI->directRenderingEnabled) 
+        {
+            DRIUnlock(pScreenInfo->pScreen);
+        }
+
+#endif /* XF86DRI_DEVEL */
+
+    }
+
+    SetTimeSinceLastInputEvent();
+
+    return TRUE;
+}
+
+/*
+ * ATIEnterVT --
+ *
+ * This function sets the server's virtual console to a graphics video state.
+ */
+_X_EXPORT Bool
+ATIEnterVT
+(
+    int iScreen,
+    int flags
+)
+{
+    ScrnInfoPtr pScreenInfo = xf86Screens[iScreen];
+    ScreenPtr   pScreen     = pScreenInfo->pScreen;
+    ATIPtr      pATI        = ATIPTR(pScreenInfo);
+    PixmapPtr   pScreenPixmap;
+    DevUnion    PixmapPrivate;
+    Bool        Entered;
+
+    if (!ATIEnterGraphics(NULL, pScreenInfo, pATI))
+        return FALSE;
+
+    /* The rest of this isn't needed for shadowfb */
+    if (pATI->OptionShadowFB)
+    {
+
+#ifdef XF86DRI_DEVEL
+
+        if (pATI->directRenderingEnabled) 
+        {
+            /* get the Mach64 back into shape after resume */
+            ATIDRIResume(pScreen);
+            DRIUnlock(pScreen);
+        }
+
+#endif /* XF86DRI_DEVEL */
+
+        return TRUE;
+    }
+
+#ifndef AVOID_CPIO
+
+    /* If used, modify banking interface */
+    if (!miModifyBanking(pScreen, &pATI->BankInfo))
+        return FALSE;
+
+#endif /* AVOID_CPIO */
+
+    pScreenPixmap = (*pScreen->GetScreenPixmap)(pScreen);
+    PixmapPrivate = pScreenPixmap->devPrivate;
+    if (!PixmapPrivate.ptr)
+        pScreenPixmap->devPrivate = pScreenInfo->pixmapPrivate;
+
+    /* Tell framebuffer about remapped aperture */
+    Entered = (*pScreen->ModifyPixmapHeader)(pScreenPixmap,
+        -1, -1, -1, -1, -1, pATI->pMemory);
+
+    if (!PixmapPrivate.ptr)
+    {
+        pScreenInfo->pixmapPrivate = pScreenPixmap->devPrivate;
+        pScreenPixmap->devPrivate.ptr = NULL;
+    }
+
+#ifdef XF86DRI_DEVEL
+
+    if (pATI->directRenderingEnabled) 
+    {
+        /* get the Mach64 back into shape after resume */
+        ATIDRIResume(pScreen);
+        DRIUnlock(pScreen);
+    }
+
+#endif /* XF86DRI_DEVEL */
+
+    return Entered;
+}
+
+/*
+ * ATILeaveVT --
+ *
+ * This function restores the server's virtual console to its state on server
+ * entry.
+ */
+_X_EXPORT void
+ATILeaveVT
+(
+    int iScreen,
+    int flags
+)
+{
+    ScrnInfoPtr pScreenInfo = xf86Screens[iScreen];
+    ScreenPtr   pScreen     = pScreenInfo->pScreen;
+    ATIPtr      pATI        = ATIPTR(pScreenInfo);
+
+#ifdef XF86DRI_DEVEL
+
+    if (pATI->directRenderingEnabled) 
+    {
+        DRILock(pScreen,0);
+        ATIDRIWaitForIdle(pATI);
+    }
+
+#endif /* XF86DRI_DEVEL */
+
+    ATILeaveGraphics(pScreenInfo, ATIPTR(pScreenInfo));
+}
+
+/*
+ * ATIFreeScreen --
+ *
+ * This function frees all driver data related to a screen.
+ */
+_X_EXPORT void
+ATIFreeScreen
+(
+    int iScreen,
+    int flags
+)
+{
+    ScreenPtr   pScreen     = screenInfo.screens[iScreen];
+    ScrnInfoPtr pScreenInfo = xf86Screens[iScreen];
+    ATIPtr      pATI        = ATIPTR(pScreenInfo);
+
+    if (pATI->Closeable || (serverGeneration > 1))
+        ATII2CFreeScreen(iScreen);
+
+    if (pATI->Closeable)
+        (void)(*pScreen->CloseScreen)(iScreen, pScreen);
+
+    ATILeaveGraphics(pScreenInfo, pATI);
+
+#ifndef AVOID_CPIO
+
+    xfree(pATI->OldHW.frame_buffer);
+    xfree(pATI->NewHW.frame_buffer);
+
+#endif /* AVOID_CPIO */
+
+    xfree(pATI->pShadow);
+
+#ifndef AVOID_DGA
+
+    xfree(pATI->pDGAMode);
+
+#endif /* AVOID_DGA */
+
+    xfree(pATI);
+    pScreenInfo->driverPrivate = NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64accel.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1040 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64accel.c,v 1.1 2003/04/23 21:51:28 tsi Exp $ */
+/*
+ * Copyright 2003 through 2004 by Marc Aurele La France (TSI @ UQV), [email protected]
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of Marc Aurele La France not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Marc Aurele La France makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
+ * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 1999-2000 Precision Insight, Inc., Cedar Park, Texas.
+ * 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 (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.
+ */
+/* 
+ * DRI support by:
+ *    Manuel Teira
+ *    Leif Delgass <[email protected]>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ati.h"
+#include "atichip.h"
+#include "atimach64accel.h"
+#include "atimach64io.h"
+#include "atipriv.h"
+#include "atiregs.h"
+
+#ifdef XF86DRI_DEVEL
+#include "mach64_common.h"
+#endif
+
+#include "miline.h"
+
+/* Used to test MMIO cache integrity in ATIMach64Sync() */
+#define TestRegisterCaching(_Register)                   \
+    if (RegisterIsCached(_Register) &&                   \
+        (CacheSlot(_Register) != inm(_Register)))        \
+    {                                                    \
+        UncacheRegister(_Register);                      \
+        xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,    \
+            #_Register " MMIO write cache disabled!\n"); \
+    }
+
+/*
+ * X-to-Mach64 mix translation table.
+ */
+static CARD8 ATIMach64ALU[16] =
+{
+    MIX_0,                       /* GXclear */
+    MIX_AND,                     /* GXand */
+    MIX_SRC_AND_NOT_DST,         /* GXandReverse */
+    MIX_SRC,                     /* GXcopy */
+    MIX_NOT_SRC_AND_DST,         /* GXandInverted */
+    MIX_DST,                     /* GXnoop */
+    MIX_XOR,                     /* GXxor */
+    MIX_OR,                      /* GXor */
+    MIX_NOR,                     /* GXnor */
+    MIX_XNOR,                    /* GXequiv */
+    MIX_NOT_DST,                 /* GXinvert */
+    MIX_SRC_OR_NOT_DST,          /* GXorReverse */
+    MIX_NOT_SRC,                 /* GXcopyInverted */
+    MIX_NOT_SRC_OR_DST,          /* GXorInverted */
+    MIX_NAND,                    /* GXnand */
+    MIX_1                        /* GXset */
+};
+
+/*
+ * ATIMach64ValidateClip --
+ *
+ * This function ensures the current scissor settings do not interfere with
+ * the current draw request.
+ */
+static void
+ATIMach64ValidateClip
+(
+    ATIPtr pATI,
+    int    sc_left,
+    int    sc_right,
+    int    sc_top,
+    int    sc_bottom
+)
+{
+    if ((sc_left < (int)pATI->sc_left) || (sc_right > (int)pATI->sc_right))
+    {
+        outf(SC_LEFT_RIGHT, pATI->sc_left_right);
+        pATI->sc_left = pATI->NewHW.sc_left;
+        pATI->sc_right = pATI->NewHW.sc_right;
+    }
+
+    if ((sc_top < (int)pATI->sc_top) || (sc_bottom > (int)pATI->sc_bottom))
+    {
+        outf(SC_TOP_BOTTOM, pATI->sc_top_bottom);
+        pATI->sc_top = pATI->NewHW.sc_top;
+        pATI->sc_bottom = pATI->NewHW.sc_bottom;
+    }
+}
+
+/*
+ * ATIMach64Sync --
+ *
+ * This is called to wait for the draw engine to become idle.
+ */
+void
+ATIMach64Sync
+(
+    ScrnInfoPtr pScreenInfo
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+#ifdef XF86DRI_DEVEL
+
+    if ( pATI->directRenderingEnabled && pATI->NeedDRISync )
+    {
+	ATIHWPtr pATIHW = &pATI->NewHW;
+
+	if (pATI->OptionMMIOCache) {
+	    /* "Invalidate" the MMIO cache so the cache slots get updated */
+	    UncacheRegister(SRC_CNTL);
+	    UncacheRegister(HOST_CNTL);
+	    UncacheRegister(PAT_CNTL);
+	    UncacheRegister(SC_LEFT_RIGHT);
+	    UncacheRegister(SC_TOP_BOTTOM);
+	    UncacheRegister(DP_BKGD_CLR);
+	    UncacheRegister(DP_FRGD_CLR);
+	    UncacheRegister(DP_WRITE_MASK);
+	    UncacheRegister(DP_MIX);
+	    UncacheRegister(CLR_CMP_CNTL);
+	}
+
+	ATIDRIWaitForIdle(pATI);
+
+	outr( BUS_CNTL, pATIHW->bus_cntl );
+
+	/* DRI uses GUI_TRAJ_CNTL, which is a composite of 
+	 * src_cntl, dst_cntl, pat_cntl, and host_cntl
+	 */
+	outf( SRC_CNTL, pATIHW->src_cntl );
+	outf( DST_CNTL, pATIHW->dst_cntl );
+	outf( PAT_CNTL, pATIHW->pat_cntl );
+	outf( HOST_CNTL, pATIHW->host_cntl );
+
+	outf( DST_OFF_PITCH, pATIHW->dst_off_pitch );
+	outf( SRC_OFF_PITCH, pATIHW->src_off_pitch );
+	outf( DP_SRC, pATIHW->dp_src );
+	outf( DP_MIX, pATIHW->dp_mix );
+	outf( DP_FRGD_CLR,  pATIHW->dp_frgd_clr );
+	outf( DP_WRITE_MASK, pATIHW->dp_write_mask );
+	
+	outf( DP_PIX_WIDTH, pATIHW->dp_pix_width );
+	outf( CLR_CMP_CNTL, pATIHW->clr_cmp_cntl );
+	outf( ALPHA_TST_CNTL, 0 );
+	outf( Z_CNTL, 0 );
+	outf( SCALE_3D_CNTL, 0 );
+
+	ATIMach64WaitForFIFO(pATI, 2);
+	outf( SC_LEFT_RIGHT,
+	      SetWord(pATIHW->sc_right, 1) | SetWord(pATIHW->sc_left, 0) );
+	outf( SC_TOP_BOTTOM,
+	      SetWord(pATIHW->sc_bottom, 1) | SetWord(pATIHW->sc_top, 0) );
+
+	if (pATI->OptionMMIOCache) {
+	    /* Now that the cache slots reflect the register state, re-enable MMIO cache */
+	    CacheRegister(SRC_CNTL);
+	    CacheRegister(HOST_CNTL);
+	    CacheRegister(PAT_CNTL);
+	    CacheRegister(SC_LEFT_RIGHT);
+	    CacheRegister(SC_TOP_BOTTOM);
+	    CacheRegister(DP_BKGD_CLR);
+	    CacheRegister(DP_FRGD_CLR);
+	    CacheRegister(DP_WRITE_MASK);
+	    CacheRegister(DP_MIX);
+	    CacheRegister(CLR_CMP_CNTL);
+	}
+
+	ATIMach64WaitForIdle(pATI);
+
+	if (pATI->OptionMMIOCache && pATI->OptionTestMMIOCache) {
+	  
+	    /* Only check registers we didn't restore */
+	    TestRegisterCaching(PAT_REG0);
+            TestRegisterCaching(PAT_REG1);
+
+            TestRegisterCaching(CLR_CMP_CLR);
+            TestRegisterCaching(CLR_CMP_MSK);
+
+	    if (pATI->Block1Base)
+            {
+                TestRegisterCaching(OVERLAY_Y_X_START);
+                TestRegisterCaching(OVERLAY_Y_X_END);
+
+                TestRegisterCaching(OVERLAY_GRAPHICS_KEY_CLR);
+                TestRegisterCaching(OVERLAY_GRAPHICS_KEY_MSK);
+
+                TestRegisterCaching(OVERLAY_KEY_CNTL);
+
+                TestRegisterCaching(OVERLAY_SCALE_INC);
+                TestRegisterCaching(OVERLAY_SCALE_CNTL);
+
+                TestRegisterCaching(SCALER_HEIGHT_WIDTH);
+
+                TestRegisterCaching(SCALER_TEST);
+
+                TestRegisterCaching(VIDEO_FORMAT);
+   
+                if (pATI->Chip < ATI_CHIP_264VTB)
+                {
+                    TestRegisterCaching(BUF0_OFFSET);
+                    TestRegisterCaching(BUF0_PITCH);
+                    TestRegisterCaching(BUF1_OFFSET);
+                    TestRegisterCaching(BUF1_PITCH);
+                }
+                else
+                {
+                    TestRegisterCaching(SCALER_BUF0_OFFSET);
+                    TestRegisterCaching(SCALER_BUF1_OFFSET);
+                    TestRegisterCaching(SCALER_BUF_PITCH);
+
+                    TestRegisterCaching(OVERLAY_EXCLUSIVE_HORZ);
+                    TestRegisterCaching(OVERLAY_EXCLUSIVE_VERT);
+  
+                    if (pATI->Chip >= ATI_CHIP_264GTPRO)
+                    {
+                        TestRegisterCaching(SCALER_COLOUR_CNTL);
+  
+                        TestRegisterCaching(SCALER_H_COEFF0);
+                        TestRegisterCaching(SCALER_H_COEFF1);
+                        TestRegisterCaching(SCALER_H_COEFF2);
+                        TestRegisterCaching(SCALER_H_COEFF3);
+                        TestRegisterCaching(SCALER_H_COEFF4);
+
+                        TestRegisterCaching(SCALER_BUF0_OFFSET_U);
+                        TestRegisterCaching(SCALER_BUF0_OFFSET_V);
+                        TestRegisterCaching(SCALER_BUF1_OFFSET_U);
+                        TestRegisterCaching(SCALER_BUF1_OFFSET_V);
+                    }
+                }
+    	    }
+         }
+	pATI->NeedDRISync = FALSE;
+
+    }
+    else
+
+#endif /* XF86DRI_DEVEL */
+    {
+      ATIMach64WaitForIdle(pATI);
+      
+      if (pATI->OptionMMIOCache && pATI->OptionTestMMIOCache)
+      {
+        /*
+         * For debugging purposes, attempt to verify that each cached register
+         * should actually be cached.
+         */
+        TestRegisterCaching(SRC_CNTL);
+
+        TestRegisterCaching(HOST_CNTL);
+
+        TestRegisterCaching(PAT_REG0);
+        TestRegisterCaching(PAT_REG1);
+        TestRegisterCaching(PAT_CNTL);
+
+        if (RegisterIsCached(SC_LEFT_RIGHT) &&  /* Special case */
+            (CacheSlot(SC_LEFT_RIGHT) !=
+             (SetWord(inm(SC_RIGHT), 1) | SetWord(inm(SC_LEFT), 0))))
+        {
+            UncacheRegister(SC_LEFT_RIGHT);
+            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+                "SC_LEFT_RIGHT write cache disabled!\n");
+        }
+
+        if (RegisterIsCached(SC_TOP_BOTTOM) &&  /* Special case */
+            (CacheSlot(SC_TOP_BOTTOM) !=
+             (SetWord(inm(SC_BOTTOM), 1) | SetWord(inm(SC_TOP), 0))))
+        {
+            UncacheRegister(SC_TOP_BOTTOM);
+            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+                "SC_TOP_BOTTOM write cache disabled!\n");
+        }
+
+        TestRegisterCaching(DP_BKGD_CLR);
+        TestRegisterCaching(DP_FRGD_CLR);
+        TestRegisterCaching(DP_WRITE_MASK);
+        TestRegisterCaching(DP_MIX);
+
+        TestRegisterCaching(CLR_CMP_CLR);
+        TestRegisterCaching(CLR_CMP_MSK);
+        TestRegisterCaching(CLR_CMP_CNTL);
+
+        if (pATI->Block1Base)
+        {
+            TestRegisterCaching(OVERLAY_Y_X_START);
+            TestRegisterCaching(OVERLAY_Y_X_END);
+
+            TestRegisterCaching(OVERLAY_GRAPHICS_KEY_CLR);
+            TestRegisterCaching(OVERLAY_GRAPHICS_KEY_MSK);
+
+            TestRegisterCaching(OVERLAY_KEY_CNTL);
+
+            TestRegisterCaching(OVERLAY_SCALE_INC);
+            TestRegisterCaching(OVERLAY_SCALE_CNTL);
+
+            TestRegisterCaching(SCALER_HEIGHT_WIDTH);
+
+            TestRegisterCaching(SCALER_TEST);
+
+            TestRegisterCaching(VIDEO_FORMAT);
+
+            if (pATI->Chip < ATI_CHIP_264VTB)
+            {
+                TestRegisterCaching(BUF0_OFFSET);
+                TestRegisterCaching(BUF0_PITCH);
+                TestRegisterCaching(BUF1_OFFSET);
+                TestRegisterCaching(BUF1_PITCH);
+            }
+            else
+            {
+                TestRegisterCaching(SCALER_BUF0_OFFSET);
+                TestRegisterCaching(SCALER_BUF1_OFFSET);
+                TestRegisterCaching(SCALER_BUF_PITCH);
+
+                TestRegisterCaching(OVERLAY_EXCLUSIVE_HORZ);
+                TestRegisterCaching(OVERLAY_EXCLUSIVE_VERT);
+
+                if (pATI->Chip >= ATI_CHIP_264GTPRO)
+                {
+                    TestRegisterCaching(SCALER_COLOUR_CNTL);
+
+                    TestRegisterCaching(SCALER_H_COEFF0);
+                    TestRegisterCaching(SCALER_H_COEFF1);
+                    TestRegisterCaching(SCALER_H_COEFF2);
+                    TestRegisterCaching(SCALER_H_COEFF3);
+                    TestRegisterCaching(SCALER_H_COEFF4);
+
+                    TestRegisterCaching(SCALER_BUF0_OFFSET_U);
+                    TestRegisterCaching(SCALER_BUF0_OFFSET_V);
+                    TestRegisterCaching(SCALER_BUF1_OFFSET_U);
+                    TestRegisterCaching(SCALER_BUF1_OFFSET_V);
+                }
+            }
+        }
+      }
+    }
+
+    /*
+     * For VTB's and later, the first CPU read of the framebuffer will return
+     * zeroes, so do it here.  This appears to be due to some kind of engine
+     * caching of framebuffer data I haven't found any way of disabling, or
+     * otherwise circumventing.  Thanks to Mark Vojkovich for the suggestion.
+     */
+    if (pATI->pXAAInfo)
+      pATI->pXAAInfo->NeedToSync = FALSE;
+
+    pATI = *(volatile ATIPtr *)pATI->pMemory;
+}
+
+/*
+ * ATIMach64SetupForScreenToScreenCopy --
+ *
+ * This function sets up the draw engine for a series of screen-to-screen copy
+ * operations.
+ */
+static void
+ATIMach64SetupForScreenToScreenCopy
+(
+    ScrnInfoPtr  pScreenInfo,
+    int          xdir,
+    int          ydir,
+    int          rop,
+    unsigned int planemask,
+    int          TransparencyColour
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    ATIMach64WaitForFIFO(pATI, 3);
+    outf(DP_WRITE_MASK, planemask);
+    outf(DP_SRC, DP_MONO_SRC_ALLONES |
+        SetBits(SRC_BLIT, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+    outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX));
+
+#ifdef AVOID_DGA
+
+    if (TransparencyColour == -1)
+
+#else /* AVOID_DGA */
+
+    if (!pATI->XAAForceTransBlit && (TransparencyColour == -1))
+
+#endif /* AVOID_DGA */
+
+    {
+        outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE);
+    }
+    else
+    {
+        ATIMach64WaitForFIFO(pATI, 2);
+        outf(CLR_CMP_CLR, TransparencyColour);
+        outf(CLR_CMP_CNTL, CLR_CMP_FN_EQUAL | CLR_CMP_SRC_2D);
+    }
+
+    pATI->dst_cntl = 0;
+
+    if (ydir > 0)
+        pATI->dst_cntl |= DST_Y_DIR;
+    if (xdir > 0)
+        pATI->dst_cntl |= DST_X_DIR;
+
+    if (pATI->XModifier == 1)
+        outf(DST_CNTL, pATI->dst_cntl);
+    else
+        pATI->dst_cntl |= DST_24_ROT_EN;
+}
+
+/*
+ * ATIMach64SubsequentScreenToScreenCopy --
+ *
+ * This function performs a screen-to-screen copy operation.
+ */
+static void
+ATIMach64SubsequentScreenToScreenCopy
+(
+    ScrnInfoPtr pScreenInfo,
+    int         xSrc,
+    int         ySrc,
+    int         xDst,
+    int         yDst,
+    int         w,
+    int         h
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    xSrc *= pATI->XModifier;
+    xDst *= pATI->XModifier;
+    w    *= pATI->XModifier;
+
+    ATIDRISync(pScreenInfo);
+
+    /* Disable clipping if it gets in the way */
+    ATIMach64ValidateClip(pATI, xDst, xDst + w - 1, yDst, yDst + h - 1);
+
+    if (!(pATI->dst_cntl & DST_X_DIR))
+    {
+        xSrc += w - 1;
+        xDst += w - 1;
+    }
+
+    if (!(pATI->dst_cntl & DST_Y_DIR))
+    {
+        ySrc += h - 1;
+        yDst += h - 1;
+    }
+
+    if (pATI->XModifier != 1)
+        outf(DST_CNTL, pATI->dst_cntl | SetBits((xDst / 4) % 6, DST_24_ROT));
+
+    ATIMach64WaitForFIFO(pATI, 4);
+    outf(SRC_Y_X, SetWord(xSrc, 1) | SetWord(ySrc, 0));
+    outf(SRC_WIDTH1, w);
+    outf(DST_Y_X, SetWord(xDst, 1) | SetWord(yDst, 0));
+    outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0));
+}
+
+/*
+ * ATIMach64SetupForSolidFill --
+ *
+ * This function sets up the draw engine for a series of solid fills.
+ */
+static void
+ATIMach64SetupForSolidFill
+(
+    ScrnInfoPtr  pScreenInfo,
+    int          colour,
+    int          rop,
+    unsigned int planemask
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    ATIMach64WaitForFIFO(pATI, 5);
+    outf(DP_WRITE_MASK, planemask);
+    outf(DP_SRC, DP_MONO_SRC_ALLONES |
+        SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+    outf(DP_FRGD_CLR, colour);
+    outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX));
+
+    outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE);
+
+    if (pATI->XModifier == 1)
+        outf(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+}
+
+/*
+ * ATIMach64SubsequentSolidFillRect --
+ *
+ * This function performs a solid rectangle fill.
+ */
+static void
+ATIMach64SubsequentSolidFillRect
+(
+    ScrnInfoPtr pScreenInfo,
+    int         x,
+    int         y,
+    int         w,
+    int         h
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    if (pATI->XModifier != 1)
+    {
+        x *= pATI->XModifier;
+        w *= pATI->XModifier;
+
+        outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) |
+            (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN));
+    }
+
+    /* Disable clipping if it gets in the way */
+    ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1);
+
+    ATIMach64WaitForFIFO(pATI, 2);
+    outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+    outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0));
+}
+
+/*
+ * ATIMach64SetupForSolidLine --
+ *
+ * This function sets up the draw engine for a series of solid lines.  It is
+ * not used for 24bpp because the engine doesn't support it.
+ */
+static void
+ATIMach64SetupForSolidLine
+(
+    ScrnInfoPtr  pScreenInfo,
+    int          colour,
+    int          rop,
+    unsigned int planemask
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    ATIMach64WaitForFIFO(pATI, 5);
+    outf(DP_WRITE_MASK, planemask);
+    outf(DP_SRC, DP_MONO_SRC_ALLONES |
+        SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+    outf(DP_FRGD_CLR, colour);
+    outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX));
+
+    outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE);
+
+    ATIMach64ValidateClip(pATI, pATI->NewHW.sc_left, pATI->NewHW.sc_right,
+        pATI->NewHW.sc_top, pATI->NewHW.sc_bottom);
+}
+
+/*
+ * ATIMach64SubsequentSolidHorVertLine --
+ *
+ * This is called to draw a solid horizontal or vertical line.  This does a
+ * one-pixel wide solid fill.
+ */
+static void
+ATIMach64SubsequentSolidHorVertLine
+(
+    ScrnInfoPtr pScreenInfo,
+    int         x,
+    int         y,
+    int         len,
+    int         dir
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    ATIMach64WaitForFIFO(pATI, 3);
+    outf(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+    outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+
+    if (dir == DEGREES_0)
+        outf(DST_HEIGHT_WIDTH, SetWord(len, 1) | SetWord(1, 0));
+    else /* if (dir == DEGREES_270) */
+        outf(DST_HEIGHT_WIDTH, SetWord(1, 1) | SetWord(len, 0));
+}
+
+/*
+ * ATIMach64SubsequentSolidBresenhamLine --
+ *
+ * This function draws a line using the Bresenham line engine.
+ */
+static void
+ATIMach64SubsequentSolidBresenhamLine
+(
+    ScrnInfoPtr pScreenInfo,
+    int         x,
+    int         y,
+    int         major,
+    int         minor,
+    int         err,
+    int         len,
+    int         octant
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+    CARD32 dst_cntl = DST_LAST_PEL;
+
+    if (octant & YMAJOR)
+        dst_cntl |= DST_Y_MAJOR;
+
+    if (!(octant & XDECREASING))
+        dst_cntl |= DST_X_DIR;
+
+    if (!(octant & YDECREASING))
+        dst_cntl |= DST_Y_DIR;
+
+    ATIDRISync(pScreenInfo);
+
+    ATIMach64WaitForFIFO(pATI, 6);
+    outf(DST_CNTL, dst_cntl);
+    outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+    outf(DST_BRES_ERR, minor + err);
+    outf(DST_BRES_INC, minor);
+    outf(DST_BRES_DEC, minor - major);
+    outf(DST_BRES_LNTH, len);
+}
+
+/*
+ * ATIMach64SetupForMono8x8PatternFill --
+ *
+ * This function sets up the draw engine for a series of 8x8 1bpp pattern
+ * fills.
+ */
+static void
+ATIMach64SetupForMono8x8PatternFill
+(
+    ScrnInfoPtr  pScreenInfo,
+    int          patx,
+    int          paty,
+    int          fg,
+    int          bg,
+    int          rop,
+    unsigned int planemask
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    ATIMach64WaitForFIFO(pATI, 3);
+    outf(DP_WRITE_MASK, planemask);
+    outf(DP_SRC, DP_MONO_SRC_PATTERN |
+        SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+    outf(DP_FRGD_CLR, fg);
+
+    if (bg == -1)
+    {
+        outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+            SetBits(MIX_DST, DP_BKGD_MIX));
+    }
+    else
+    {
+        ATIMach64WaitForFIFO(pATI, 2);
+        outf(DP_BKGD_CLR, bg);
+        outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+            SetBits(ATIMach64ALU[rop], DP_BKGD_MIX));
+    }
+
+    ATIMach64WaitForFIFO(pATI, 4);
+    outf(PAT_REG0, patx);
+    outf(PAT_REG1, paty);
+    outf(PAT_CNTL, PAT_MONO_EN);
+
+    outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE);
+
+    if (pATI->XModifier == 1)
+        outf(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+}
+
+/*
+ * ATIMach64SubsequentMono8x8PatternFillRect --
+ *
+ * This function performs an 8x8 1bpp pattern fill.
+ */
+static void
+ATIMach64SubsequentMono8x8PatternFillRect
+(
+    ScrnInfoPtr pScreenInfo,
+    int         patx,
+    int         paty,
+    int         x,
+    int         y,
+    int         w,
+    int         h
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    if (pATI->XModifier != 1)
+    {
+        x *= pATI->XModifier;
+        w *= pATI->XModifier;
+
+        outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) |
+            (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN));
+    }
+
+    /* Disable clipping if it gets in the way */
+    ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1);
+
+    ATIMach64WaitForFIFO(pATI, 2);
+    outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+    outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0));
+}
+
+/*
+ * ATIMach64SetupForScanlineCPUToScreenColorExpandFill --
+ *
+ * This function sets up the engine for a series of colour expansion fills.
+ */
+static void
+ATIMach64SetupForScanlineCPUToScreenColorExpandFill
+(
+    ScrnInfoPtr  pScreenInfo,
+    int          fg,
+    int          bg,
+    int          rop,
+    unsigned int planemask
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    ATIMach64WaitForFIFO(pATI, 3);
+    outf(DP_WRITE_MASK, planemask);
+    outf(DP_SRC, DP_MONO_SRC_HOST |
+        SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+    outf(DP_FRGD_CLR, fg);
+
+    if (bg == -1)
+    {
+        outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+            SetBits(MIX_DST, DP_BKGD_MIX));
+    }
+    else
+    {
+        ATIMach64WaitForFIFO(pATI, 2);
+        outf(DP_BKGD_CLR, bg);
+        outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+            SetBits(ATIMach64ALU[rop], DP_BKGD_MIX));
+    }
+
+    outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE);
+
+    if (pATI->XModifier == 1)
+        outf(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+}
+
+/*
+ * ATIMach64SubsequentScanlineCPUToScreenColorExpandFill --
+ *
+ * This function sets up the engine for a single colour expansion fill.
+ */
+static void
+ATIMach64SubsequentScanlineCPUToScreenColorExpandFill
+(
+    ScrnInfoPtr pScreenInfo,
+    int         x,
+    int         y,
+    int         w,
+    int         h,
+    int         skipleft
+)
+{
+    ATIPtr pATI = ATIPTR(pScreenInfo);
+
+    ATIDRISync(pScreenInfo);
+
+    if (pATI->XModifier != 1)
+    {
+        x *= pATI->XModifier;
+        w *= pATI->XModifier;
+        skipleft *= pATI->XModifier;
+
+        outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) |
+            (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN));
+    }
+
+    pATI->ExpansionBitmapWidth = (w + 31) / 32;
+
+    ATIMach64WaitForFIFO(pATI, 3);
+    pATI->sc_left = x + skipleft;
+    pATI->sc_right = x + w - 1;
+    outf(SC_LEFT_RIGHT,
+        SetWord(pATI->sc_right, 1) | SetWord(pATI->sc_left, 0));
+    outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+    outf(DST_HEIGHT_WIDTH,
+        SetWord(pATI->ExpansionBitmapWidth * 32, 1) | SetWord(h, 0));
+}
+
+/*
+ * ATIMach64SubsequentColorExpandScanline --
+ *
+ * This function feeds a bitmap scanline to the engine for a colour expansion
+ * fill.  This is written to do burst transfers for those platforms that can do
+ * them, and to improve CPU/engine concurrency.
+ */
+static void
+ATIMach64SubsequentColorExpandScanline
+(
+    ScrnInfoPtr pScreenInfo,
+    int         iBuffer
+)
+{
+    ATIPtr          pATI         = ATIPTR(pScreenInfo);
+    CARD32          *pBitmapData = pATI->ExpansionBitmapScanlinePtr[iBuffer];
+    int             w            = pATI->ExpansionBitmapWidth;
+    int             nDWord;
+
+    ATIDRISync(pScreenInfo);
+
+    while (w > 0)
+    {
+        /*
+         * Transfers are done in chunks of up to 64 bytes in length (32 on
+         * earlier controllers).
+         */
+        nDWord = w;
+        if (nDWord > pATI->nHostFIFOEntries)
+            nDWord = pATI->nHostFIFOEntries;
+
+        /* Make enough FIFO slots available */
+        ATIMach64WaitForFIFO(pATI, nDWord);
+
+        /*
+         * Always start transfers on a chuck-sized boundary.  Note that
+         * HOST_DATA_0 is actually on a 512-byte boundary, but *pBitmapData can
+         * only be guaranteed to be on a chunk-sized boundary.
+         *
+         * Transfer current chunk.  With any luck, the compiler won't mangle
+         * this too badly...
+         */
+
+#       if defined(ATIMove32)
+
+        {
+            ATIMove32(pATI->pHOST_DATA, pBitmapData, nDWord);
+        }
+
+#       else
+
+        {
+            volatile CARD32 *pDst;
+            CARD32          *pSrc;
+            unsigned int    iDWord;
+
+            iDWord = 16 - nDWord;
+            pDst = (volatile CARD32 *)pATI->pHOST_DATA - iDWord;
+            pSrc = pBitmapData - iDWord;
+
+            switch (iDWord)
+            {
+                case  0:  MMIO_MOVE32(pDst +  0, 0, *(pSrc +  0));
+                case  1:  MMIO_MOVE32(pDst +  1, 0, *(pSrc +  1));
+                case  2:  MMIO_MOVE32(pDst +  2, 0, *(pSrc +  2));
+                case  3:  MMIO_MOVE32(pDst +  3, 0, *(pSrc +  3));
+                case  4:  MMIO_MOVE32(pDst +  4, 0, *(pSrc +  4));
+                case  5:  MMIO_MOVE32(pDst +  5, 0, *(pSrc +  5));
+                case  6:  MMIO_MOVE32(pDst +  6, 0, *(pSrc +  6));
+                case  7:  MMIO_MOVE32(pDst +  7, 0, *(pSrc +  7));
+                case  8:  MMIO_MOVE32(pDst +  8, 0, *(pSrc +  8));
+                case  9:  MMIO_MOVE32(pDst +  9, 0, *(pSrc +  9));
+                case 10:  MMIO_MOVE32(pDst + 10, 0, *(pSrc + 10));
+                case 11:  MMIO_MOVE32(pDst + 11, 0, *(pSrc + 11));
+                case 12:  MMIO_MOVE32(pDst + 12, 0, *(pSrc + 12));
+                case 13:  MMIO_MOVE32(pDst + 13, 0, *(pSrc + 13));
+                case 14:  MMIO_MOVE32(pDst + 14, 0, *(pSrc + 14));
+                case 15:  MMIO_MOVE32(pDst + 15, 0, *(pSrc + 15));
+
+                default:    /* Muffle compiler */
+                    break;
+            }
+        }
+
+#       endif
+
+        /* Step to next chunk */
+        pBitmapData += nDWord;
+        w -= nDWord;
+        pATI->nAvailableFIFOEntries -= nDWord;
+    }
+
+    pATI->EngineIsBusy = TRUE;
+}
+
+/*
+ * ATIMach64AccelInit --
+ *
+ * This function fills in structure fields needed for acceleration on Mach64
+ * variants.
+ */
+int
+ATIMach64AccelInit
+(
+    ATIPtr        pATI,
+    XAAInfoRecPtr pXAAInfo
+)
+{
+    /* This doesn't seem quite right... */
+    if (pATI->XModifier == 1)
+    {
+	if (pATI->OptionOffScrnPixmap)
+            pXAAInfo->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS;
+	else
+	    pXAAInfo->Flags = PIXMAP_CACHE;
+
+#ifndef AVOID_CPIO
+
+        if (!pATI->BankInfo.BankSize)
+
+#endif /* AVOID_CPIO */
+
+        {
+            pXAAInfo->Flags |= LINEAR_FRAMEBUFFER;
+        }
+    }
+
+    /* Sync */
+    pXAAInfo->Sync = ATIMach64Sync;
+
+    /* Screen-to-screen copy */
+    pXAAInfo->SetupForScreenToScreenCopy = ATIMach64SetupForScreenToScreenCopy;
+    pXAAInfo->SubsequentScreenToScreenCopy =
+        ATIMach64SubsequentScreenToScreenCopy;
+
+    /* Solid fills */
+    pXAAInfo->SetupForSolidFill = ATIMach64SetupForSolidFill;
+    pXAAInfo->SubsequentSolidFillRect = ATIMach64SubsequentSolidFillRect;
+
+    /* 8x8 mono pattern fills */
+    pXAAInfo->Mono8x8PatternFillFlags =
+
+#if X_BYTE_ORDER != X_LITTLE_ENDIAN
+
+        BIT_ORDER_IN_BYTE_MSBFIRST |
+
+#endif /* X_BYTE_ORDER */
+
+        HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN;
+    pXAAInfo->SetupForMono8x8PatternFill = ATIMach64SetupForMono8x8PatternFill;
+    pXAAInfo->SubsequentMono8x8PatternFillRect =
+        ATIMach64SubsequentMono8x8PatternFillRect;
+
+    /*
+     * Use scanline version of colour expansion, not only for the non-ix86
+     * case, but also to avoid PCI retries.
+     */
+    pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags =
+        LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X |
+        CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD;
+    if (pATI->XModifier != 1)
+        pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags |= TRIPLE_BITS_24BPP;
+    pXAAInfo->NumScanlineColorExpandBuffers = 1;
+
+    /* Align bitmap data on a 64-byte boundary */
+    pATI->ExpansionBitmapWidth =        /* DWord size in bits */
+        ((pATI->displayWidth * pATI->XModifier) + 31) & ~31U;
+    pATI->ExpansionBitmapScanlinePtr[1] =
+        (CARD32 *)xnfalloc((pATI->ExpansionBitmapWidth >> 3) + 63);
+    pATI->ExpansionBitmapScanlinePtr[0] =
+        (pointer)(((unsigned long)pATI->ExpansionBitmapScanlinePtr[1] + 63) &
+                  ~63UL);
+    pXAAInfo->ScanlineColorExpandBuffers =
+        (CARD8 **)pATI->ExpansionBitmapScanlinePtr;
+    pXAAInfo->SetupForScanlineCPUToScreenColorExpandFill =
+        ATIMach64SetupForScanlineCPUToScreenColorExpandFill;
+    pXAAInfo->SubsequentScanlineCPUToScreenColorExpandFill =
+        ATIMach64SubsequentScanlineCPUToScreenColorExpandFill;
+    pXAAInfo->SubsequentColorExpandScanline =
+        ATIMach64SubsequentColorExpandScanline;
+
+    /* The engine does not support the following primitives for 24bpp */
+    if (pATI->XModifier != 1)
+        return ATIMach64MaxY;
+
+    /* Solid lines */
+    pXAAInfo->SetupForSolidLine = ATIMach64SetupForSolidLine;
+    pXAAInfo->SubsequentSolidHorVertLine = ATIMach64SubsequentSolidHorVertLine;
+    pXAAInfo->SubsequentSolidBresenhamLine =
+        ATIMach64SubsequentSolidBresenhamLine;
+
+    return ATIMach64MaxY;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,513 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h,v 1.41tsi Exp $ */
+/*
+ * Copyright 1999 through 2004 by Marc Aurele La France (TSI @ UQV), [email protected]
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of Marc Aurele La France not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Marc Aurele La France makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
+ * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * DRI support by:
+ *    Gareth Hughes <[email protected]>
+ *    Leif Delgass <[email protected]>
+ */
+
+#ifndef ___ATISTRUCT_H___
+#define ___ATISTRUCT_H___ 1
+
+#include "atibank.h"
+#include "aticlock.h"
+#include "atiregs.h"
+
+#ifdef XF86DRI_DEVEL
+
+/*
+ * DRI support
+ */
+#define _XF86DRI_SERVER_
+#include "atidripriv.h"
+#include "mach64_dri.h"
+#include "sarea.h"
+#include "xf86drm.h"
+#include "dri.h"
+ 
+#endif /* XF86DRI_DEVEL */
+
+#ifdef TV_OUT
+
+#include "vbe.h"
+
+#endif /* TV_OUT */
+
+#include "xaa.h"
+#include "xf86Cursor.h"
+#include "xf86Pci.h"
+#include "xf86Resources.h"
+
+#define CacheSlotOf(____Register) ((____Register) / UnitOf(DWORD_SELECT))
+
+/*
+ * This is probably as good a place as any to put this note, as it applies to
+ * the entire driver, but especially here.  CARD8's are used rather than the
+ * appropriate enum types because the latter would nearly quadruple storage
+ * requirements (they are stored as int's).  This reduces the usefulness of
+ * enum types to their ability to declare index values.  I've also elected to
+ * forgo the strong typing capabilities of enum types.  C is not terribly adept
+ * at strong typing anyway.
+ */
+
+/* A structure for local data related to video modes */
+typedef struct _ATIHWRec
+{
+    /* Clock number for mode */
+    CARD8 clock;
+
+    /* The CRTC used to drive the screen (VGA, 8514, Mach64) */
+    CARD8 crtc;
+
+    /* Colour lookup table */
+    CARD8 lut[256 * 3];
+
+#ifndef AVOID_CPIO
+
+    /* VGA registers */
+    CARD8 genmo, crt[25], seq[5], gra[9], attr[21];
+
+    /* VGA Wonder registers */
+    CARD8             a3,         a6, a7,             ab, ac, ad, ae,
+          b0, b1, b2, b3,     b5, b6,     b8, b9, ba,         bd, be, bf;
+
+    /* Shadow VGA CRTC registers */
+    CARD8 shadow_vga[25];
+
+#endif /* AVOID_CPIO */
+
+    /* Generic DAC registers */
+    CARD8 dac_read, dac_write, dac_mask;
+
+    /* IBM RGB 514 registers */
+    CARD8 ibmrgb514[0x0092U];   /* All that's needed for now */
+
+    /* Mach64 PLL registers */
+    CARD8 pll_vclk_cntl, pll_vclk_post_div,
+          pll_vclk0_fb_div, pll_vclk1_fb_div,
+          pll_vclk2_fb_div, pll_vclk3_fb_div,
+          pll_xclk_cntl, pll_ext_vpll_cntl;
+
+    /* Mach64 CPIO registers */
+    CARD32 crtc_h_total_disp, crtc_h_sync_strt_wid,
+           crtc_v_total_disp, crtc_v_sync_strt_wid,
+           crtc_off_pitch, crtc_gen_cntl, dsp_config, dsp_on_off,
+           ovr_clr, ovr_wid_left_right, ovr_wid_top_bottom,
+           cur_clr0, cur_clr1, cur_offset,
+           cur_horz_vert_posn, cur_horz_vert_off,
+           clock_cntl, bus_cntl, mem_cntl, mem_vga_wp_sel, mem_vga_rp_sel,
+           dac_cntl, gen_test_cntl, config_cntl, mpp_config, mpp_strobe_seq,
+           tvo_cntl;
+
+    /* LCD registers */
+    CARD32 lcd_index, config_panel, lcd_gen_ctrl,
+           horz_stretching, vert_stretching, ext_vert_stretch;
+
+    /* Shadow Mach64 CRTC registers */
+    CARD32 shadow_h_total_disp, shadow_h_sync_strt_wid,
+           shadow_v_total_disp, shadow_v_sync_strt_wid;
+
+    /* Mach64 MMIO Block 0 registers and related subfields */
+    CARD32 dst_off_pitch;
+    CARD16 dst_x, dst_y, dst_height;
+    CARD32 dst_bres_err, dst_bres_inc, dst_bres_dec, dst_cntl;
+    CARD32 src_off_pitch;
+    CARD16 src_x, src_y, src_width1, src_height1,
+           src_x_start, src_y_start, src_width2, src_height2;
+    CARD32 src_cntl;
+    CARD32 host_cntl;
+    CARD32 pat_reg0, pat_reg1, pat_cntl;
+    CARD16 sc_left, sc_right, sc_top, sc_bottom;
+    CARD32 dp_bkgd_clr, dp_frgd_clr, dp_write_mask, dp_chain_mask,
+           dp_pix_width, dp_mix, dp_src;
+    CARD32 clr_cmp_clr, clr_cmp_msk, clr_cmp_cntl;
+    CARD32 context_mask, context_load_cntl;
+
+    /* Mach64 MMIO Block 1 registers */
+    CARD32 overlay_y_x_start, overlay_y_x_end, overlay_graphics_key_clr,
+           overlay_graphics_key_msk, overlay_key_cntl, overlay_scale_inc,
+           overlay_scale_cntl, scaler_height_width, scaler_test,
+           scaler_buf0_offset, scaler_buf1_offset, scaler_buf_pitch,
+           video_format, overlay_exclusive_horz, overlay_exclusive_vert,
+           buf0_offset, buf0_pitch, buf1_offset, buf1_pitch,
+           scaler_colour_cntl, scaler_h_coeff0, scaler_h_coeff1,
+           scaler_h_coeff2, scaler_h_coeff3, scaler_h_coeff4, gui_cntl,
+           scaler_buf0_offset_u, scaler_buf0_offset_v, scaler_buf1_offset_u,
+           scaler_buf1_offset_v;
+
+    /* Clock map pointers */
+    const CARD8 *ClockMap, *ClockUnmap;
+
+    /* Clock programming data */
+    int FeedbackDivider, ReferenceDivider, PostDivider;
+
+#ifndef AVOID_CPIO
+
+    /* This is used by ATISwap() */
+    pointer frame_buffer;
+    ATIBankProcPtr SetBank;
+    unsigned int nBank, nPlane;
+
+#endif /* AVOID_CPIO */
+
+} ATIHWRec;
+
+/*
+ * This structure defines the driver's private area.
+ */
+typedef struct _ATIRec
+{
+    /*
+     * Definitions related to XF86Config "Chipset" specifications.
+     */
+    CARD8 Chipset;
+
+    /*
+     * Adapter-related definitions.
+     */
+    CARD8 Adapter;
+
+#ifndef AVOID_CPIO
+
+    CARD8 VGAAdapter;
+
+#endif /* AVOID_CPIO */
+
+    /*
+     * Chip-related definitions.
+     */
+    CARD32 config_chip_id;
+    CARD16 ChipType;
+    CARD8 Chip;
+    CARD8 ChipClass, ChipRevision, ChipRev, ChipVersion, ChipFoundry;
+
+#ifndef AVOID_CPIO
+
+    CARD8 Coprocessor, ChipHasSUBSYS_CNTL;
+
+#endif /* AVOID_CPIO */
+
+    /*
+     * Processor I/O decoding definitions.
+     */
+    CARD8 CPIODecoding;
+    IOADDRESS CPIOBase;
+
+#ifndef AVOID_CPIO
+
+    /*
+     * Processor I/O port definition for VGA.
+     */
+    IOADDRESS CPIO_VGABase;
+
+    /*
+     * Processor I/O port definitions for VGA Wonder.
+     */
+    IOADDRESS CPIO_VGAWonder;
+    CARD8 B2Reg;        /* The B2 mirror */
+    CARD8 VGAOffset;    /* Low index for CPIO_VGAWonder */
+
+#endif /* AVOID_CPIO */
+
+    /*
+     * DAC-related definitions.
+     */
+
+#ifndef AVOID_CPIO
+
+    IOADDRESS CPIO_DAC_MASK, CPIO_DAC_DATA, CPIO_DAC_READ, CPIO_DAC_WRITE,
+              CPIO_DAC_WAIT;
+
+#endif /* AVOID_CPIO */
+
+    CARD16 DAC;
+    CARD8 rgbBits;
+
+    /*
+     * Definitions related to system bus interface.
+     */
+    pciVideoPtr PCIInfo;
+    CARD8 BusType;
+    CARD8 SharedAccelerator;
+
+#ifndef AVOID_CPIO
+
+    CARD8 SharedVGA;
+    resRange VGAWonderResources[2];
+
+#endif /* AVOID_CPIO */
+
+    /*
+     * Definitions related to video memory.
+     */
+    CARD8 MemoryType;
+    int VideoRAM;
+
+    /*
+     * BIOS-related definitions.
+     */
+    unsigned long BIOSBase;
+    CARD8 I2CType, Tuner, Decoder, Audio;
+
+    /*
+     * Definitions related to video memory apertures.
+     */
+    pointer pMemory, pShadow;
+    pointer pMemoryLE;          /* Always little-endian */
+    unsigned long LinearBase;
+    int LinearSize, FBPitch, FBBytesPerPixel;
+
+#ifndef AVOID_CPIO
+
+    /*
+     * Banking interface.
+     */
+    miBankInfoRec BankInfo;
+    pointer pBank;
+    CARD8 UseSmallApertures;
+
+#endif /* AVOID_CPIO */
+
+    /*
+     * Definitions related to MMIO register apertures.
+     */
+    pointer pMMIO, pBlock[2];
+    unsigned long Block0Base, Block1Base;
+
+    /*
+     * XAA interface.
+     */
+    XAAInfoRecPtr pXAAInfo;
+    int nAvailableFIFOEntries, nFIFOEntries, nHostFIFOEntries;
+    CARD8 EngineIsBusy, EngineIsLocked, XModifier;
+    CARD32 dst_cntl;    /* For SetupFor/Subsequent communication */
+    CARD32 sc_left_right, sc_top_bottom;
+    CARD16 sc_left, sc_right, sc_top, sc_bottom;        /* Current scissors */
+    pointer pHOST_DATA; /* Current HOST_DATA_* transfer window address */
+    CARD32 *ExpansionBitmapScanlinePtr[2];
+    int ExpansionBitmapWidth;
+
+    /*
+     * Cursor-related definitions.
+     */
+    xf86CursorInfoPtr pCursorInfo;
+    pointer pCursorPage, pCursorImage;
+    unsigned long CursorBase;
+    CARD32 CursorOffset;
+    CARD16 CursorXOffset, CursorYOffset;
+    CARD8 Cursor;
+
+    /*
+     * MMIO cache.
+     */
+    CARD32 MMIOCache[CacheSlotOf(DWORD_SELECT) + 1];
+    CARD8  MMIOCached[(CacheSlotOf(DWORD_SELECT) + 8) >> 3];
+
+    /*
+     * Clock-related definitions.
+     */
+    int ClockNumberToProgramme, ReferenceNumerator, ReferenceDenominator;
+    int ProgrammableClock, maxClock;
+    ClockRec ClockDescriptor;
+    CARD16 BIOSClocks[16];
+    CARD8 Clock;
+
+    /*
+     * DSP register data.
+     */
+    int XCLKFeedbackDivider, XCLKReferenceDivider, XCLKPostDivider;
+    CARD16 XCLKMaxRASDelay, XCLKPageFaultDelay,
+           DisplayLoopLatency, DisplayFIFODepth;
+
+    /*
+     * LCD panel data.
+     */
+    int LCDPanelID, LCDClock, LCDHorizontal, LCDVertical;
+    unsigned LCDHSyncStart, LCDHSyncWidth, LCDHBlankWidth;
+    unsigned LCDVSyncStart, LCDVSyncWidth, LCDVBlankWidth;
+    int LCDVBlendFIFOSize;
+
+    /*
+     * Data used by ATIAdjustFrame().
+     */
+    int AdjustDepth, AdjustMaxX, AdjustMaxY;
+    unsigned long AdjustMask, AdjustMaxBase;
+
+    /*
+     * DGA and non-DGA common data.
+     */
+    DisplayModePtr currentMode;
+    CARD8 depth, bitsPerPixel;
+    short int displayWidth;
+    int pitchInc;
+    rgb weight;
+
+#ifndef AVOID_DGA
+
+    /*
+     * DGA-related data.
+     */
+    DGAModePtr pDGAMode;
+    DGAFunctionRec ATIDGAFunctions;
+    int nDGAMode;
+
+    /*
+     * XAAForceTransBlit alters the behavior of 'SetupForScreenToScreenCopy',
+     * such that ~0 is interpreted as a legitimate transparency key.
+     */
+    CARD8 XAAForceTransBlit;
+
+#endif /* AVOID_DGA */
+
+    /*
+     * XVideo-related data.
+     */
+    DevUnion XVPortPrivate[1];
+    FBLinearPtr pXVBuffer;
+    RegionRec VideoClip;
+    int SurfacePitch, SurfaceOffset;
+    CARD8 AutoPaint, DoubleBuffer, CurrentBuffer, ActiveSurface;
+
+    /*
+     * Data saved by ATIUnlock() and restored by ATILock().
+     */
+    struct
+    {
+        /* Mach64 registers */
+        CARD32 crtc_int_cntl, crtc_gen_cntl, i2c_cntl_0, hw_debug,
+               scratch_reg3, bus_cntl, lcd_index, mem_cntl, i2c_cntl_1,
+               dac_cntl, gen_test_cntl, mpp_config, mpp_strobe_seq, tvo_cntl;
+
+#ifndef AVOID_CPIO
+
+        CARD32 config_cntl;
+
+        /* Mach8/Mach32 registers */
+        CARD16 clock_sel, misc_options, mem_bndry, mem_cfg;
+
+        /* VGA Wonder registers */
+        CARD8 a6, ab, b1, b4, b5, b6, b8, b9, be;
+
+        /* VGA registers */
+        CARD8 crt03, crt11;
+
+        /* VGA shadow registers */
+        CARD8 shadow_crt03, shadow_crt11;
+
+#endif /* AVOID_CPIO */
+
+    } LockData;
+
+    /* Mode data */
+    ATIHWRec OldHW, NewHW;
+    int MaximumInterlacedPitch;
+    Bool InterlacedSeen;
+
+    /*
+     * Resource Access Control entity index.
+     */
+    int iEntity;
+
+    /*
+     * Driver options.
+     */
+    CARD8 OptionAccel:1;        /* Use hardware draw engine */
+    CARD8 OptionBIOSDisplay:1;  /* Allow BIOS interference */
+    CARD8 OptionBlend:1;        /* Force horizontal blending */
+    CARD8 OptionCRTDisplay:1;   /* Display on both CRT and digital panel */
+    CARD8 OptionCSync:1;        /* Use composite sync */
+    CARD8 OptionDevel:1;        /* Intentionally undocumented */
+
+#ifndef AVOID_CPIO
+
+    CARD8 OptionLinear:1;       /* Use linear fb aperture when available */
+
+#endif /* AVOID_CPIO */
+ 
+#ifdef TV_OUT
+
+    CARD8 OptionTvOut;          /* Enable TV out if TV is connected */
+    CARD8 OptionTvStd;          /* Requested TV standard - see ATITVStandard enum in atioption.h */
+
+#endif /* TV_OUT */
+
+    CARD8 OptionMMIOCache:1;    /* Cache MMIO writes */
+    CARD8 OptionTestMMIOCache:1;/* Test MMIO cache integrity */
+    CARD8 OptionPanelDisplay:1; /* Prefer digital panel over CRT */
+    CARD8 OptionProbeClocks:1;  /* Force probe for fixed clocks */
+    CARD8 OptionShadowFB:1;     /* Use shadow frame buffer */
+    CARD8 OptionLCDSync:1;      /* Temporary */
+    CARD8 OptionOffScrnPixmap:1;  /* Off screen pixmap */
+
+    /*
+     * State flags.
+     */
+    CARD8 Unlocked, Mapped, Closeable;
+    CARD8 MMIOInLinear;
+
+    /*
+     * Wrapped functions.
+     */
+    CloseScreenProcPtr CloseScreen;
+
+#ifdef XF86DRI_DEVEL
+
+    /*
+     * DRI data.
+     */
+    int directRenderingEnabled;
+    DRIInfoPtr pDRIInfo;
+    int drmFD;
+    int irq;
+    int numVisualConfigs;
+    __GLXvisualConfig *pVisualConfigs;
+    ATIConfigPrivPtr pVisualConfigsPriv;
+    ATIDRIServerInfoPtr pDRIServerInfo;
+    Bool NeedDRISync;
+    Bool have3DWindows;
+                                                                                
+    /* offscreen memory management */
+    int               backLines;
+    FBAreaPtr         backArea;
+    int               depthTexLines;
+    FBAreaPtr         depthTexArea;
+    CARD8 OptionIsPCI;           /* Force PCI mode */
+    CARD8 OptionDMAMode;         /* async, sync, mmio */
+    CARD8 OptionAGPMode;         /* AGP mode */
+    CARD8 OptionAGPSize;         /* AGP size in MB */
+    CARD8 OptionLocalTextures;   /* Use local textures + AGP textures (only valid for AGP) */
+    CARD8 OptionBufferSize;      /* Command/dma buffer size in MB */
+
+#endif /* XF86DRI_DEVEL */
+
+#ifdef TV_OUT
+    /* TV out */
+    vbeInfoPtr pVBE;
+    xf86Int10InfoPtr pInt10;
+    int vbemode; /* saved text mode */
+    Bool tvActive;
+#endif /* TV_OUT */
+} ATIRec;
+
+#define ATIPTR(_p) ((ATIPtr)((_p)->driverPrivate))
+
+#endif /* ___ATISTRUCT_H___ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,171 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man,v 1.29 2006/01/21 01:17:59 mvojkovi Exp $ 
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH NV __drivermansuffix__ __vendorversion__
+.SH NAME
+nv \- NVIDIA video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI "  Identifier \*q"  devname \*q
+.B  "  Driver \*qnv\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B nv 
+is an __xservername__ driver for NVIDIA video cards.  The driver supports 2D 
+acceleration and provides support for the following framebuffer depths:
+8, 15, 16 (except Riva128) and 24.  All
+visual types are supported for depth 8, TrueColor and DirectColor
+visuals are supported for the other depths with the exception of
+the Riva128 which only supports TrueColor in the higher depths. 
+
+.SH SUPPORTED HARDWARE
+The
+.B nv
+driver supports PCI and AGP video cards based on the following NVIDIA chips:
+.TP 22
+.B RIVA 128
+NV3
+.TP 22
+.B RIVA TNT
+NV4
+.TP 22
+.B RIVA TNT2
+NV5
+.TP 22
+.B GeForce 256, QUADRO 
+NV10
+.TP 22
+.B GeForce2, QUADRO2
+NV11 & NV15  
+.TP 22
+.B GeForce3, QUADRO DCC
+NV20
+.TP 22
+.B nForce, nForce2
+NV1A, NV1F
+.TP 22
+.B GeForce4, QUADRO4
+NV17, NV18, NV25, NV28
+.TP 22
+.B GeForce FX, QUADRO FX
+NV30, NV31, NV34, NV35, NV36, NV37, NV38 
+.TP 22
+.B GeForce 6XXX
+NV40, NV41, NV43, NV44, NV45, C51
+.TP 22
+.B GeForce 7XXX
+G70, G71, G72, G73
+
+.SH CONFIGURATION DETAILS
+Please refer to __xconfigfile__(__filemansuffix__) for general configuration
+details.  This section only covers configuration details specific to this
+driver.
+.PP
+The driver auto-detects the chipset type and the amount of video memory
+present for all chips.
+.PP
+The following driver
+.B Options
+are supported:
+.TP
+.BI "Option \*qHWCursor\*q \*q" boolean \*q
+Enable or disable the HW cursor.  Default: on.
+.TP
+.BI "Option \*qNoAccel\*q \*q" boolean \*q
+Disable or enable acceleration.  Default: acceleration is enabled.
+.TP
+.BI "Option \*qUseFBDev\*q \*q" boolean \*q
+Enable or disable use of on OS-specific fb interface (and is not supported
+on all OSs).  See fbdevhw(__drivermansuffix__) for further information.
+Default: off.
+.TP
+.BI "Option \*qCrtcNumber\*q \*q" integer \*q
+GeForce2 MX, nForce2, Quadro4, GeForce4, Quadro FX and GeForce FX 
+may have two video outputs.  
+The driver attempts to autodetect
+which one the monitor is connected to.  In the case that autodetection picks
+the wrong one, this option may be used to force usage of a particular output. 
+The options are "0" or "1".
+Default: autodetected.
+.TP
+.BI "Option \*qFlatPanel\*q \*q" boolean \*q
+The driver usually can autodetect the presence of a digital flat panel.  In
+the case that this fails, this option can be used to force the driver to 
+treat the attached device as a digital flat panel.  With this 
+driver, a digital flat panel will only work if it was POSTed by the BIOS, 
+that is, the
+machine must have booted to the panel.  If you have a dual head card
+you may also need to set the option CrtcNumber described above.
+Default: off.
+.TP
+.BI "Option \*qFPDither\*q \*q" boolean \*q
+Many digital flat panels (particularly ones on laptops) have only 6 bits 
+per component color resolution.
+This option tells the driver to dither from 8 bits per component to 6 before
+the flat panel truncates it. This is only supported in depth 24 on GeForce2 MX, 
+nForce2, GeForce4, Quadro4, Geforce FX and Quadro FX.
+Default: off.
+.TP
+.BI "Option \*qFPScale\*q \*q" boolean \*q 
+Supported only on GeForce4, Quadro4, Geforce FX and Quadro FX.  This option 
+tells to the driver to scale lower resolutions up to the flat panel's native
+resolution.  Default: on.
+.TP 
+.BI "Option \*qRotate\*q \*qCW\*q"
+.TP
+.BI "Option \*qRotate\*q \*qCCW\*q"
+Rotate the display clockwise or counterclockwise.  This mode is unaccelerated.
+Default: no rotation.
+
+Note: The Resize and Rotate extension will be disabled if the Rotate "CW" or
+Rotate "CCW" options are used.
+.TP
+.BI "Option \*qRotate\*q \*qRandR\*q"
+Enable rotation of the screen using the Resize and Rotate extension.
+This mode is unaccelerated.
+Default: no rotation support.
+.TP
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
+Enable or disable use of the shadow framebuffer layer.  Default: off.
+.SH "SEE ALSO"
+__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: David McKay, Jarno Paananen, Chas Inman, Dave Schmenk, 
+Mark Vojkovich
+.SH COPYRIGHT
+.LP
+NOTICE TO USER:   The source code  is copyrighted under  U.S. and
+international laws.  Users and possessors of this source code are
+hereby granted a nonexclusive,  royalty-free copyright license to
+use this code in individual and commercial software.
+.LP
+Any use of this source code must include,  in the user documentation and
+internal comments to the code,  notices to the end user as follows:
+.LP
+Copyright 1993-2003 NVIDIA, Corporation.  All rights reserved.
+.LP
+NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY
+OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"
+WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPORATION 
+DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT,  
+AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL
+NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCIDENTAL, 
+OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RESULTING FROM 
+LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION
+OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.
+.LP
+U.S. Government  End  Users.   This source code  is a "commercial
+item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),
+consisting  of "commercial  computer  software"  and  "commercial
+computer  software  documentation,"  as such  terms  are  used in
+48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Government 
+only as  a commercial end item.   Consistent with  48 C.F.R.
+12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),
+all U.S. Government End Users  acquire the source code  with only
+those rights set forth herein.                                   
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2188 @@
+/* $XdotOrg: driver/xf86-video-nv/src/nv_driver.c,v 1.21 2006/01/24 16:45:29 aplattner Exp $ */
+/* $XConsortium: nv_driver.c /main/3 1996/10/28 05:13:37 kaleb $ */
+/*
+ * Copyright 1996-1997  David J. McKay
+ *
+ * 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 J. MCKAY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION 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
+
+/* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen
+   <[email protected]> */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.142 2006/01/23 18:35:53 mvojkovi Exp $ */
+
+#include "nv_include.h"
+
+#include "xf86int10.h"
+
+const   OptionInfoRec * RivaAvailableOptions(int chipid, int busid);
+Bool    RivaGetScrnInfoRec(PciChipsets *chips, int chip);
+
+/*
+ * Forward definitions for the functions that make up the driver.
+ */
+/* Mandatory functions */
+static const OptionInfoRec * NVAvailableOptions(int chipid, int busid);
+static void    NVIdentify(int flags);
+static Bool    NVProbe(DriverPtr drv, int flags);
+static Bool    NVPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool    NVScreenInit(int Index, ScreenPtr pScreen, int argc,
+                            char **argv);
+static Bool    NVEnterVT(int scrnIndex, int flags);
+static Bool    NVEnterVTFBDev(int scrnIndex, int flags);
+static void    NVLeaveVT(int scrnIndex, int flags);
+static Bool    NVCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool    NVSaveScreen(ScreenPtr pScreen, int mode);
+
+/* Optional functions */
+static void    NVFreeScreen(int scrnIndex, int flags);
+static ModeStatus NVValidMode(int scrnIndex, DisplayModePtr mode,
+			      Bool verbose, int flags);
+#ifdef RANDR
+static Bool    NVDriverFunc(ScrnInfoPtr pScrnInfo, xorgDriverFuncOp op,
+			      pointer data);
+#endif
+
+/* Internally used functions */
+
+static Bool	NVMapMem(ScrnInfoPtr pScrn);
+static Bool	NVMapMemFBDev(ScrnInfoPtr pScrn);
+static Bool	NVUnmapMem(ScrnInfoPtr pScrn);
+static void	NVSave(ScrnInfoPtr pScrn);
+static void	NVRestore(ScrnInfoPtr pScrn);
+static Bool	NVModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+
+
+/*
+ * This contains the functions needed by the server after loading the
+ * driver module.  It must be supplied, and gets added the driver list by
+ * the Module Setup funtion in the dynamic case.  In the static case a
+ * reference to this is compiled in, and this requires that the name of
+ * this DriverRec be an upper-case version of the driver name.
+ */
+
+_X_EXPORT DriverRec NV = {
+        NV_VERSION,
+	NV_DRIVER_NAME,
+        NVIdentify,
+        NVProbe,
+	NVAvailableOptions,
+        NULL,
+        0
+};
+
+/* Known cards as of 2006/01/12  */
+
+static SymTabRec NVKnownChipsets[] =
+{
+  { 0x12D20018, "RIVA 128" },
+
+  { 0x10DE0020, "RIVA TNT" },
+
+  { 0x10DE0028, "RIVA TNT2" },
+  { 0x10DE002A, "Unknown TNT2" },
+  { 0x10DE002C, "Vanta" },
+  { 0x10DE0029, "RIVA TNT2 Ultra" },
+  { 0x10DE002D, "RIVA TNT2 Model 64" },
+
+  { 0x10DE00A0, "Aladdin TNT2" },
+
+  { 0x10DE0100, "GeForce 256" },
+  { 0x10DE0101, "GeForce DDR" },
+  { 0x10DE0103, "Quadro" },
+
+  { 0x10DE0110, "GeForce2 MX/MX 400" },
+  { 0x10DE0111, "GeForce2 MX 100/200" },
+  { 0x10DE0112, "GeForce2 Go" },
+  { 0x10DE0113, "Quadro2 MXR/EX/Go" },
+
+  { 0x10DE01A0, "GeForce2 Integrated GPU" },
+
+  { 0x10DE0150, "GeForce2 GTS" },
+  { 0x10DE0151, "GeForce2 Ti" },
+  { 0x10DE0152, "GeForce2 Ultra" },
+  { 0x10DE0153, "Quadro2 Pro" },
+
+  { 0x10DE0170, "GeForce4 MX 460" },
+  { 0x10DE0171, "GeForce4 MX 440" },
+  { 0x10DE0172, "GeForce4 MX 420" },
+  { 0x10DE0173, "GeForce4 MX 440-SE" },
+  { 0x10DE0174, "GeForce4 440 Go" },
+  { 0x10DE0175, "GeForce4 420 Go" },
+  { 0x10DE0176, "GeForce4 420 Go 32M" },
+  { 0x10DE0177, "GeForce4 460 Go" },
+  { 0x10DE0178, "Quadro4 550 XGL" },
+#if defined(__powerpc__)
+  { 0x10DE0179, "GeForce4 MX (Mac)" },
+#else
+  { 0x10DE0179, "GeForce4 440 Go 64M" },
+#endif
+  { 0x10DE017A, "Quadro NVS" },
+  { 0x10DE017C, "Quadro4 500 GoGL" },
+  { 0x10DE017D, "GeForce4 410 Go 16M" },
+
+  { 0x10DE0181, "GeForce4 MX 440 with AGP8X" },
+  { 0x10DE0182, "GeForce4 MX 440SE with AGP8X" },
+  { 0x10DE0183, "GeForce4 MX 420 with AGP8X" },
+  { 0x10DE0185, "GeForce4 MX 4000" },
+  { 0x10DE0186, "GeForce4 448 Go" },
+  { 0x10DE0187, "GeForce4 488 Go" },
+  { 0x10DE0188, "Quadro4 580 XGL" },
+#if defined(__powerpc__)
+  { 0x10DE0189, "GeForce4 MX with AGP8X (Mac)" },
+#endif
+  { 0x10DE018A, "Quadro4 NVS 280 SD" },
+  { 0x10DE018B, "Quadro4 380 XGL" },
+  { 0x10DE018C, "Quadro NVS 50 PCI" },
+  { 0x10DE018D, "GeForce4 448 Go" },
+
+  { 0x10DE01F0, "GeForce4 MX Integrated GPU" },
+
+  { 0x10DE0200, "GeForce3" },
+  { 0x10DE0201, "GeForce3 Ti 200" },
+  { 0x10DE0202, "GeForce3 Ti 500" },
+  { 0x10DE0203, "Quadro DCC" },
+
+  { 0x10DE0250, "GeForce4 Ti 4600" },
+  { 0x10DE0251, "GeForce4 Ti 4400" },
+  { 0x10DE0253, "GeForce4 Ti 4200" },
+  { 0x10DE0258, "Quadro4 900 XGL" },
+  { 0x10DE0259, "Quadro4 750 XGL" },
+  { 0x10DE025B, "Quadro4 700 XGL" },
+
+  { 0x10DE0280, "GeForce4 Ti 4800" },
+  { 0x10DE0281, "GeForce4 Ti 4200 with AGP8X" },
+  { 0x10DE0282, "GeForce4 Ti 4800 SE" },
+  { 0x10DE0286, "GeForce4 4200 Go" },
+  { 0x10DE028C, "Quadro4 700 GoGL" },
+  { 0x10DE0288, "Quadro4 980 XGL" },
+  { 0x10DE0289, "Quadro4 780 XGL" },
+
+  { 0x10DE0301, "GeForce FX 5800 Ultra" },
+  { 0x10DE0302, "GeForce FX 5800" },
+  { 0x10DE0308, "Quadro FX 2000" },
+  { 0x10DE0309, "Quadro FX 1000" },
+
+  { 0x10DE0311, "GeForce FX 5600 Ultra" },
+  { 0x10DE0312, "GeForce FX 5600" },
+  { 0x10DE0314, "GeForce FX 5600XT" },
+  { 0x10DE031A, "GeForce FX Go5600" },
+  { 0x10DE031B, "GeForce FX Go5650" },
+  { 0x10DE031C, "Quadro FX Go700" },
+
+  { 0x10DE0320, "GeForce FX 5200" },
+  { 0x10DE0321, "GeForce FX 5200 Ultra" },
+  { 0x10DE0322, "GeForce FX 5200" },
+  { 0x10DE0323, "GeForce FX 5200LE" },
+  { 0x10DE0324, "GeForce FX Go5200" },
+  { 0x10DE0325, "GeForce FX Go5250" },
+  { 0x10DE0326, "GeForce FX 5500" },
+  { 0x10DE0327, "GeForce FX 5100" },
+  { 0x10DE0328, "GeForce FX Go5200 32M/64M" },
+#if defined(__powerpc__)
+  { 0x10DE0329, "GeForce FX 5200 (Mac)" },
+#endif
+  { 0x10DE032A, "Quadro NVS 55/280 PCI" },
+  { 0x10DE032B, "Quadro FX 500/600 PCI" },
+  { 0x10DE032C, "GeForce FX Go53xx Series" },
+  { 0x10DE032D, "GeForce FX Go5100" },
+
+  { 0x10DE0330, "GeForce FX 5900 Ultra" },
+  { 0x10DE0331, "GeForce FX 5900" },
+  { 0x10DE0332, "GeForce FX 5900XT" },
+  { 0x10DE0333, "GeForce FX 5950 Ultra" },
+  { 0x10DE0334, "GeForce FX 5900ZT" },
+  { 0x10DE0338, "Quadro FX 3000" },
+  { 0x10DE033F, "Quadro FX 700" },
+
+  { 0x10DE0341, "GeForce FX 5700 Ultra" },
+  { 0x10DE0342, "GeForce FX 5700" },
+  { 0x10DE0343, "GeForce FX 5700LE" },
+  { 0x10DE0344, "GeForce FX 5700VE" },
+  { 0x10DE0347, "GeForce FX Go5700" },
+  { 0x10DE0348, "GeForce FX Go5700" },
+  { 0x10DE034C, "Quadro FX Go1000" },
+  { 0x10DE034E, "Quadro FX 1100" },
+
+  { 0x10DE0040, "GeForce 6800 Ultra" },
+  { 0x10DE0041, "GeForce 6800" },
+  { 0x10DE0042, "GeForce 6800 LE" },
+  { 0x10DE0043, "GeForce 6800 XE" },
+  { 0x10DE0045, "GeForce 6800 GT" },
+  { 0x10DE0046, "GeForce 6800 GT" },
+  { 0x10DE0047, "GeForce 6800 GS" },
+  { 0x10DE0048, "GeForce 6800 XT" },
+  { 0x10DE004E, "Quadro FX 4000" },
+
+  { 0x10DE00C0, "GeForce 6800 GS" },
+  { 0x10DE00C1, "GeForce 6800" },
+  { 0x10DE00C2, "GeForce 6800 LE" },
+  { 0x10DE00C3, "GeForce 6800 XT" },
+  { 0x10DE00C8, "GeForce Go 6800" },
+  { 0x10DE00C9, "GeForce Go 6800 Ultra" },
+  { 0x10DE00CC, "Quadro FX Go1400" },
+  { 0x10DE00CD, "Quadro FX 3450/4000 SDI" },
+  { 0x10DE00CE, "Quadro FX 1400" },
+
+  { 0x10DE0140, "GeForce 6600 GT" },
+  { 0x10DE0141, "GeForce 6600" },
+  { 0x10DE0142, "GeForce 6600 LE" },
+  { 0x10DE0143, "GeForce 6600 VE" },
+  { 0x10DE0144, "GeForce Go 6600" },
+  { 0x10DE0145, "GeForce 6610 XL" },
+  { 0x10DE0146, "GeForce Go 6600 TE/6200 TE" },
+  { 0x10DE0147, "GeForce 6700 XL" },
+  { 0x10DE0148, "GeForce Go 6600" },
+  { 0x10DE0149, "GeForce Go 6600 GT" },
+  { 0x10DE014E, "Quadro FX 540" },
+  { 0x10DE014F, "GeForce 6200" },
+
+  { 0x10DE0160, "GeForce 6500" },
+  { 0x10DE0161, "GeForce 6200 TurboCache(TM)" },
+  { 0x10DE0162, "GeForce 6200SE TurboCache(TM)" },
+  { 0x10DE0163, "GeForce 6200 LE" },
+  { 0x10DE0164, "GeForce Go 6200" },
+  { 0x10DE0165, "Quadro NVS 285" },
+  { 0x10DE0166, "GeForce Go 6400" },
+  { 0x10DE0167, "GeForce Go 6200" },
+  { 0x10DE0168, "GeForce Go 6400" },
+  { 0x10DE0169, "GeForce 6250" },
+
+  { 0x10DE0211, "GeForce 6800" },
+  { 0x10DE0212, "GeForce 6800 LE" },
+  { 0x10DE0215, "GeForce 6800 GT" },
+  { 0x10DE0218, "GeForce 6800 XT" },
+
+  { 0x10DE0221, "GeForce 6200" },
+
+  { 0x10DE0090, "GeForce 7800 GTX" },
+  { 0x10DE0091, "GeForce 7800 GTX" },
+  { 0x10DE0092, "GeForce 7800 GT" },
+  { 0x10DE0093, "GeForce 7800 GS" },
+  { 0x10DE0095, "GeForce 7800 SLI" },
+  { 0x10DE0098, "GeForce Go 7800" },
+  { 0x10DE0099, "GeForce Go 7800 GTX" },
+  { 0x10DE009D, "Quadro FX 4500" },
+
+  { 0x10DE01D1, "GeForce 7300 LE" },
+  { 0x10DE01D6, "GeForce Go 7200" },
+  { 0x10DE01D7, "GeForce Go 7300" },
+  { 0x10DE01D8, "GeForce Go 7400" },
+  { 0x10DE01DA, "Quadro NVS 110M" },
+  { 0x10DE01DB, "Quadro NVS 120M" },
+  { 0x10DE01DC, "Quadro FX 350M" },
+  { 0x10DE01DE, "Quadro FX 350" },
+  { 0x10DE01DF, "GeForce 7300 GS" },
+
+  { 0x10DE0398, "GeForce Go 7600" },
+  { 0x10DE0399, "GeForce Go 7600 GT"},
+  { 0x10DE039A, "Quadro NVS 300M" },
+  { 0x10DE039C, "Quadro FX 550M" },
+
+  { 0x10DE0298, "GeForce Go 7900 GS" },
+  { 0x10DE0299, "GeForce Go 7900 GTX" },
+  { 0x10DE029A, "Quadro FX 2500M" },
+  { 0x10DE029B, "Quadro FX 1500M" },
+
+  { 0x10DE0240, "GeForce 6150" },
+  { 0x10DE0241, "GeForce 6150 LE" },
+  { 0x10DE0242, "GeForce 6100" },
+  { 0x10DE0244, "GeForce Go 6150" },
+  { 0x10DE0247, "GeForce Go 6100" },
+
+  {-1, NULL}
+};
+
+
+/*
+ * List of symbols from other modules that this module references.  This
+ * list is used to tell the loader that it is OK for symbols here to be
+ * unresolved providing that it hasn't been told that they haven't been
+ * told that they are essential via a call to xf86LoaderReqSymbols() or
+ * xf86LoaderReqSymLists().  The purpose is this is to avoid warnings about
+ * unresolved symbols that are not required.
+ */
+
+static const char *vgahwSymbols[] = {
+    "vgaHWUnmapMem",
+    "vgaHWDPMSSet",
+    "vgaHWFreeHWRec",
+    "vgaHWGetHWRec",
+    "vgaHWGetIndex",
+    "vgaHWInit",
+    "vgaHWMapMem",
+    "vgaHWProtect",
+    "vgaHWRestore",
+    "vgaHWSave",
+    "vgaHWSaveScreen",
+    NULL
+};
+
+static const char *fbSymbols[] = {
+    "fbPictureInit",
+    "fbScreenInit",
+    NULL
+};
+
+static const char *xaaSymbols[] = {
+    "XAACopyROP",
+    "XAACreateInfoRec",
+    "XAADestroyInfoRec",
+    "XAAFallbackOps",
+    "XAAInit",
+    "XAAPatternROP",
+    NULL
+};
+
+static const char *ramdacSymbols[] = {
+    "xf86CreateCursorInfoRec",
+    "xf86DestroyCursorInfoRec",
+    "xf86InitCursor",
+    NULL
+};
+
+static const char *ddcSymbols[] = {
+    "xf86PrintEDID",
+    "xf86DoEDID_DDC2",
+    "xf86SetDDCproperties",
+    NULL
+};
+
+#ifdef XFree86LOADER
+static const char *vbeSymbols[] = {
+    "VBEInit",
+    "vbeFree",
+    "vbeDoEDID",
+    NULL
+};
+#endif
+
+static const char *i2cSymbols[] = {
+    "xf86CreateI2CBusRec",
+    "xf86I2CBusInit",
+    NULL
+};
+
+static const char *shadowSymbols[] = {
+    "ShadowFBInit",
+    NULL
+};
+
+static const char *fbdevHWSymbols[] = {
+    "fbdevHWInit",
+    "fbdevHWUseBuildinMode",
+
+    "fbdevHWGetVidmem",
+
+    /* colormap */
+    "fbdevHWLoadPaletteWeak",
+
+    /* ScrnInfo hooks */
+    "fbdevHWAdjustFrameWeak",
+    "fbdevHWEnterVT",
+    "fbdevHWLeaveVTWeak",
+    "fbdevHWModeInit",
+    "fbdevHWSave",
+    "fbdevHWSwitchModeWeak",
+    "fbdevHWValidModeWeak",
+
+    "fbdevHWMapMMIO",
+    "fbdevHWMapVidmem",
+
+    NULL
+};
+
+static const char *int10Symbols[] = {
+    "xf86FreeInt10",
+    "xf86InitInt10",
+    NULL
+};
+
+static const char *rivaSymbols[] = {
+   "RivaGetScrnInfoRec",
+   "RivaAvailableOptions",
+    NULL
+};
+
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(nvSetup);
+
+static XF86ModuleVersionInfo nvVersRec =
+{
+    "nv",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    NV_MAJOR_VERSION, NV_MINOR_VERSION, NV_PATCHLEVEL,
+    ABI_CLASS_VIDEODRV,                     /* This is a video driver */
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0,0,0,0}
+};
+
+_X_EXPORT XF86ModuleData nvModuleData = { &nvVersRec, nvSetup, NULL };
+#endif
+
+
+typedef enum {
+    OPTION_SW_CURSOR,
+    OPTION_HW_CURSOR,
+    OPTION_NOACCEL,
+    OPTION_SHADOW_FB,
+    OPTION_FBDEV,
+    OPTION_ROTATE,
+    OPTION_VIDEO_KEY,
+    OPTION_FLAT_PANEL,
+    OPTION_FP_DITHER,
+    OPTION_CRTC_NUMBER,
+    OPTION_FP_SCALE,
+    OPTION_FP_TWEAK
+} NVOpts;
+
+
+static const OptionInfoRec NVOptions[] = {
+    { OPTION_SW_CURSOR,         "SWcursor",     OPTV_BOOLEAN,   {0}, FALSE },
+    { OPTION_HW_CURSOR,         "HWcursor",     OPTV_BOOLEAN,   {0}, FALSE },
+    { OPTION_NOACCEL,           "NoAccel",      OPTV_BOOLEAN,   {0}, FALSE },
+    { OPTION_SHADOW_FB,         "ShadowFB",     OPTV_BOOLEAN,   {0}, FALSE },
+    { OPTION_FBDEV,             "UseFBDev",     OPTV_BOOLEAN,   {0}, FALSE },
+    { OPTION_ROTATE,		"Rotate",	OPTV_ANYSTR,	{0}, FALSE },
+    { OPTION_VIDEO_KEY,		"VideoKey",	OPTV_INTEGER,	{0}, FALSE },
+    { OPTION_FLAT_PANEL,	"FlatPanel",	OPTV_BOOLEAN,	{0}, FALSE },
+    { OPTION_FP_DITHER, 	"FPDither",	OPTV_BOOLEAN,	{0}, FALSE },
+    { OPTION_CRTC_NUMBER,	"CrtcNumber",	OPTV_INTEGER,	{0}, FALSE },
+    { OPTION_FP_SCALE,          "FPScale",      OPTV_BOOLEAN,   {0}, FALSE },
+    { OPTION_FP_TWEAK,          "FPTweak",      OPTV_INTEGER,   {0}, FALSE },
+    { -1,                       NULL,           OPTV_NONE,      {0}, FALSE }
+};
+
+/*
+ * This is intentionally screen-independent.  It indicates the binding
+ * choice made in the first PreInit.
+ */
+static int pix24bpp = 0;
+
+
+static Bool
+NVGetRec(ScrnInfoPtr pScrn)
+{
+    /*
+     * Allocate an NVRec, and hook it into pScrn->driverPrivate.
+     * pScrn->driverPrivate is initialised to NULL, so we can check if
+     * the allocation has already been done.
+     */
+    if (pScrn->driverPrivate != NULL)
+        return TRUE;
+
+    pScrn->driverPrivate = xnfcalloc(sizeof(NVRec), 1);
+    /* Initialise it */
+
+    return TRUE;
+}
+
+static void
+NVFreeRec(ScrnInfoPtr pScrn)
+{
+    if (pScrn->driverPrivate == NULL)
+        return;
+    xfree(pScrn->driverPrivate);
+    pScrn->driverPrivate = NULL;
+}
+
+
+#ifdef XFree86LOADER
+
+static pointer
+nvSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = FALSE;
+
+    /* This module should be loaded only once, but check to be sure. */
+
+    if (!setupDone) {
+        setupDone = TRUE;
+        xf86AddDriver(&NV, module, 0);
+
+        /*
+         * Modules that this driver always requires may be loaded here
+         * by calling LoadSubModule().
+         */
+
+        /*
+         * Tell the loader about symbols from other modules that this module
+         * might refer to.
+         */
+        LoaderRefSymLists(vgahwSymbols, xaaSymbols, fbSymbols,
+                          ramdacSymbols, shadowSymbols, rivaSymbols,
+                          i2cSymbols, ddcSymbols, vbeSymbols,
+                          fbdevHWSymbols, int10Symbols, NULL);
+
+        /*
+         * The return value must be non-NULL on success even though there
+         * is no TearDownProc.
+         */
+        return (pointer)1;
+    } else {
+        if (errmaj) *errmaj = LDR_ONCEONLY;
+        return NULL;
+    }
+}
+
+
+#endif /* XFree86LOADER */
+
+static const OptionInfoRec *
+NVAvailableOptions(int chipid, int busid)
+{
+    if(chipid == 0x12D20018) {
+	if (!xf86LoadOneModule("riva128", NULL)) {
+	    return NULL;
+	} else
+	    return RivaAvailableOptions(chipid, busid);
+    }
+    
+    return NVOptions;
+}
+
+/* Mandatory */
+static void
+NVIdentify(int flags)
+{
+    xf86PrintChipsets(NV_NAME, "driver for NVIDIA chipsets", NVKnownChipsets);
+}
+
+
+static Bool
+NVGetScrnInfoRec(PciChipsets *chips, int chip)
+{
+    ScrnInfoPtr pScrn;
+
+    pScrn = xf86ConfigPciEntity(NULL, 0, chip,
+                                chips, NULL, NULL, NULL,
+                                NULL, NULL);
+
+    if(!pScrn) return FALSE;
+
+    pScrn->driverVersion    = NV_VERSION;
+    pScrn->driverName       = NV_DRIVER_NAME;
+    pScrn->name             = NV_NAME;
+
+    pScrn->Probe            = NVProbe;
+    pScrn->PreInit          = NVPreInit;
+    pScrn->ScreenInit       = NVScreenInit;
+    pScrn->SwitchMode       = NVSwitchMode;
+    pScrn->AdjustFrame      = NVAdjustFrame;
+    pScrn->EnterVT          = NVEnterVT;
+    pScrn->LeaveVT          = NVLeaveVT;
+    pScrn->FreeScreen       = NVFreeScreen;
+    pScrn->ValidMode        = NVValidMode;
+
+    return TRUE;
+}
+
+#define MAX_CHIPS MAXSCREENS
+
+
+static CARD32 
+NVGetPCIXpressChip (pciVideoPtr pVideo)
+{
+    volatile CARD32 *regs;
+    CARD32 pciid, pcicmd;
+    PCITAG Tag = ((pciConfigPtr)(pVideo->thisCard))->tag;
+
+    pcicmd = pciReadLong(Tag, PCI_CMD_STAT_REG);
+    pciWriteLong(Tag, PCI_CMD_STAT_REG, pcicmd | PCI_CMD_MEM_ENABLE);
+    
+    regs = xf86MapPciMem(-1, VIDMEM_MMIO, Tag, pVideo->memBase[0], 0x2000);
+
+    pciid = regs[0x1800/4];
+
+    xf86UnMapVidMem(-1, (pointer)regs, 0x2000);
+
+    pciWriteLong(Tag, PCI_CMD_STAT_REG, pcicmd);
+
+    if((pciid & 0x0000ffff) == 0x000010DE) 
+       pciid = 0x10DE0000 | (pciid >> 16);
+    else 
+    if((pciid & 0xffff0000) == 0xDE100000) /* wrong endian */
+       pciid = 0x10DE0000 | ((pciid << 8) & 0x0000ff00) |
+                            ((pciid >> 8) & 0x000000ff);
+
+    return pciid;
+}
+
+
+/* Mandatory */
+static Bool
+NVProbe(DriverPtr drv, int flags)
+{
+    int i;
+    GDevPtr *devSections;
+    int *usedChips;
+    SymTabRec NVChipsets[MAX_CHIPS + 1];
+    PciChipsets NVPciChipsets[MAX_CHIPS + 1];
+    pciVideoPtr *ppPci;
+    int numDevSections;
+    int numUsed;
+    Bool foundScreen = FALSE;
+
+
+    if ((numDevSections = xf86MatchDevice(NV_DRIVER_NAME, &devSections)) <= 0) 
+        return FALSE;  /* no matching device section */
+
+    if (!(ppPci = xf86GetPciVideoInfo())) 
+        return FALSE;  /* no PCI cards found */
+
+    numUsed = 0;
+
+    /* Create the NVChipsets and NVPciChipsets from found devices */
+    while (*ppPci && (numUsed < MAX_CHIPS)) {
+        if(((*ppPci)->vendor == PCI_VENDOR_NVIDIA_SGS) || 
+           ((*ppPci)->vendor == PCI_VENDOR_NVIDIA)) 
+        {
+            SymTabRec *nvchips = NVKnownChipsets;
+            int pciid = ((*ppPci)->vendor << 16) | (*ppPci)->chipType;
+            int token = pciid;
+
+            if((token & 0xfff0) == 0x00F0) 
+                token = NVGetPCIXpressChip(*ppPci);
+
+            while(nvchips->name) {
+               if(token == nvchips->token)
+                  break;
+               nvchips++;
+            }
+
+            if(nvchips->name) { /* found one */
+               NVChipsets[numUsed].token = pciid;
+               NVChipsets[numUsed].name = nvchips->name;
+               NVPciChipsets[numUsed].numChipset = pciid; 
+               NVPciChipsets[numUsed].PCIid = pciid;
+               NVPciChipsets[numUsed].resList = RES_SHARED_VGA;
+               numUsed++;
+            } else if ((*ppPci)->vendor == PCI_VENDOR_NVIDIA) {
+               /* look for a compatible devices which may be newer than 
+                  the NVKnownChipsets list above.  */
+               switch(token & 0xfff0) {
+               case 0x0170:   
+               case 0x0180:
+               case 0x0250:
+               case 0x0280:
+               case 0x0300:
+               case 0x0310:
+               case 0x0320:
+               case 0x0330:
+               case 0x0340:
+               case 0x0040:
+               case 0x00C0:
+               case 0x0120:
+               case 0x0140:
+               case 0x0160:
+               case 0x01D0:
+               case 0x0090:
+               case 0x0210:
+               case 0x0220:
+               case 0x0240:
+               case 0x0290:
+               case 0x0390:
+                   NVChipsets[numUsed].token = pciid;
+                   NVChipsets[numUsed].name = "Unknown NVIDIA chip";
+                   NVPciChipsets[numUsed].numChipset = pciid;
+                   NVPciChipsets[numUsed].PCIid = pciid;
+                   NVPciChipsets[numUsed].resList = RES_SHARED_VGA;
+                   numUsed++;
+                   break;
+               default:  break;  /* we don't recognize it */
+               }
+            }
+        }
+        ppPci++;
+    }
+
+    /* terminate the list */
+    NVChipsets[numUsed].token = -1;
+    NVChipsets[numUsed].name = NULL; 
+    NVPciChipsets[numUsed].numChipset = -1;
+    NVPciChipsets[numUsed].PCIid = -1;
+    NVPciChipsets[numUsed].resList = RES_UNDEFINED;
+
+    numUsed = xf86MatchPciInstances(NV_NAME, 0, NVChipsets, NVPciChipsets,
+                                    devSections, numDevSections, drv,
+                                    &usedChips);
+                        
+    if (numUsed <= 0) 
+        return FALSE;
+
+    if (flags & PROBE_DETECT)
+	foundScreen = TRUE;
+    else for (i = 0; i < numUsed; i++) {
+        pciVideoPtr pPci;
+
+        pPci = xf86GetPciInfoForEntity(usedChips[i]);
+        if(pPci->vendor == PCI_VENDOR_NVIDIA_SGS) {
+            if (!xf86LoadDrvSubModule(drv, "riva128")) {
+                  continue;
+            }
+            xf86LoaderReqSymLists(rivaSymbols, NULL);
+            if(RivaGetScrnInfoRec(NVPciChipsets, usedChips[i]))
+                foundScreen = TRUE;
+        } else {
+            if(NVGetScrnInfoRec(NVPciChipsets, usedChips[i])) 
+	        foundScreen = TRUE;
+	}    
+    }
+
+    xfree(devSections);
+    xfree(usedChips);
+
+    return foundScreen;
+}
+
+/* Usually mandatory */
+Bool
+NVSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+    return NVModeInit(xf86Screens[scrnIndex], mode);
+}
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+void 
+NVAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    int startAddr;
+    NVPtr pNv = NVPTR(pScrn);
+    NVFBLayout *pLayout = &pNv->CurrentLayout;
+
+    startAddr = (((y*pLayout->displayWidth)+x)*(pLayout->bitsPerPixel/8));
+    NVSetStartAddress(pNv, startAddr);
+}
+
+
+/*
+ * This is called when VT switching back to the X server.  Its job is
+ * to reinitialise the video mode.
+ *
+ * We may wish to unmap video/MMIO memory too.
+ */
+
+/* Mandatory */
+static Bool
+NVEnterVT(int scrnIndex, int flags)
+{
+    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    NVPtr pNv = NVPTR(pScrn);
+
+    if (!NVModeInit(pScrn, pScrn->currentMode))
+        return FALSE;
+    NVAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+    if(pNv->overlayAdaptor)
+        NVResetVideo(pScrn);
+    return TRUE;
+}
+
+static Bool
+NVEnterVTFBDev(int scrnIndex, int flags)
+{
+    fbdevHWEnterVT(scrnIndex,flags);
+    return TRUE;
+}
+
+/*
+ * This is called when VT switching away from the X server.  Its job is
+ * to restore the previous (text) mode.
+ *
+ * We may wish to remap video/MMIO memory too.
+ */
+
+/* Mandatory */
+static void
+NVLeaveVT(int scrnIndex, int flags)
+{
+    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    NVPtr pNv = NVPTR(pScrn);
+
+    NVSync(pScrn);
+    NVRestore(pScrn);
+    NVLockUnlock(pNv, 1);
+}
+
+
+
+static void 
+NVBlockHandler (
+    int i, 
+    pointer blockData, 
+    pointer pTimeout,
+    pointer pReadmask
+)
+{
+    ScreenPtr     pScreen = screenInfo.screens[i];
+    ScrnInfoPtr   pScrnInfo = xf86Screens[i];
+    NVPtr         pNv = NVPTR(pScrnInfo);
+
+    if (pNv->DMAKickoffCallback)
+        (*pNv->DMAKickoffCallback)(pScrnInfo);
+    
+    pScreen->BlockHandler = pNv->BlockHandler;
+    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+    pScreen->BlockHandler = NVBlockHandler;
+
+    if (pNv->VideoTimerCallback) 
+        (*pNv->VideoTimerCallback)(pScrnInfo, currentTime.milliseconds);
+
+}
+
+
+/*
+ * This is called at the end of each server generation.  It restores the
+ * original (text) mode.  It should also unmap the video memory, and free
+ * any per-generation data allocated by the driver.  It should finish
+ * by unwrapping and calling the saved CloseScreen function.
+ */
+
+/* Mandatory */
+static Bool
+NVCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    NVPtr pNv = NVPTR(pScrn);
+
+    if (pScrn->vtSema) {
+        NVSync(pScrn);
+        NVRestore(pScrn);
+        NVLockUnlock(pNv, 1);
+    }
+
+    NVUnmapMem(pScrn);
+    vgaHWUnmapMem(pScrn);
+    if (pNv->AccelInfoRec)
+        XAADestroyInfoRec(pNv->AccelInfoRec);
+    if (pNv->CursorInfoRec)
+        xf86DestroyCursorInfoRec(pNv->CursorInfoRec);
+    if (pNv->ShadowPtr)
+        xfree(pNv->ShadowPtr);
+    if (pNv->DGAModes)
+        xfree(pNv->DGAModes);
+    if (pNv->overlayAdaptor)
+	xfree(pNv->overlayAdaptor);
+    if (pNv->blitAdaptor)
+        xfree(pNv->blitAdaptor);
+
+    pScrn->vtSema = FALSE;
+    pScreen->CloseScreen = pNv->CloseScreen;
+    pScreen->BlockHandler = pNv->BlockHandler;
+    return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+}
+
+/* Free up any persistent data structures */
+
+/* Optional */
+static void
+NVFreeScreen(int scrnIndex, int flags)
+{
+    /*
+     * This only gets called when a screen is being deleted.  It does not
+     * get called routinely at the end of a server generation.
+     */
+    if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
+	vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+    NVFreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static ModeStatus
+NVValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+    NVPtr pNv = NVPTR(xf86Screens[scrnIndex]);
+
+    if(pNv->fpWidth && pNv->fpHeight) {
+      if((pNv->fpWidth < mode->HDisplay) || (pNv->fpHeight < mode->VDisplay)) {
+         xf86DrvMsg(scrnIndex, X_INFO, "Mode \"%s\" is larger than "
+                    "BIOS programmed panel size of %d x %d.  Removing.\n",
+                     mode->name, pNv->fpWidth, pNv->fpHeight);
+         return (MODE_BAD);
+      }
+    }
+
+    return (MODE_OK);
+}
+
+static void
+nvProbeDDC(ScrnInfoPtr pScrn, int index)
+{
+    vbeInfoPtr pVbe;
+
+    if (xf86LoadSubModule(pScrn, "vbe")) {
+        pVbe = VBEInit(NULL,index);
+        ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+	vbeFree(pVbe);
+    }
+}
+
+
+Bool NVI2CInit(ScrnInfoPtr pScrn)
+{
+    char *mod = "i2c";
+
+    if (xf86LoadSubModule(pScrn, mod)) {
+        xf86LoaderReqSymLists(i2cSymbols,NULL);
+
+        mod = "ddc";
+        if(xf86LoadSubModule(pScrn, mod)) {
+            xf86LoaderReqSymLists(ddcSymbols, NULL);
+            return NVDACi2cInit(pScrn);
+        } 
+    }
+
+    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+              "Couldn't load %s module.  DDC probing can't be done\n", mod);
+
+    return FALSE;
+}
+
+/* Mandatory */
+Bool
+NVPreInit(ScrnInfoPtr pScrn, int flags)
+{
+    NVPtr pNv;
+    MessageType from;
+    int i, max_width, max_height;
+    ClockRangePtr clockRanges;
+    const char *s;
+
+    if (flags & PROBE_DETECT) {
+        nvProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index );
+	return TRUE;
+    }
+
+    /*
+     * Note: This function is only called once at server startup, and
+     * not at the start of each server generation.  This means that
+     * only things that are persistent across server generations can
+     * be initialised here.  xf86Screens[] is (pScrn is a pointer to one
+     * of these).  Privates allocated using xf86AllocateScrnInfoPrivateIndex()  
+     * are too, and should be used for data that must persist across
+     * server generations.
+     *
+     * Per-generation data should be allocated with
+     * AllocateScreenPrivateIndex() from the ScreenInit() function.
+     */
+
+    /* Check the number of entities, and fail if it isn't one. */
+    if (pScrn->numEntities != 1)
+	return FALSE;
+
+    /* Allocate the NVRec driverPrivate */
+    if (!NVGetRec(pScrn)) {
+	return FALSE;
+    }
+    pNv = NVPTR(pScrn);
+
+    /* Get the entity, and make sure it is PCI. */
+    pNv->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+    if (pNv->pEnt->location.type != BUS_PCI)
+	return FALSE;
+ 
+    /* Find the PCI info for this screen */
+    pNv->PciInfo = xf86GetPciInfoForEntity(pNv->pEnt->index);
+    pNv->PciTag = pciTag(pNv->PciInfo->bus, pNv->PciInfo->device,
+			  pNv->PciInfo->func);
+
+    pNv->Primary = xf86IsPrimaryPci(pNv->PciInfo);
+
+    /* Initialize the card through int10 interface if needed */
+    if (xf86LoadSubModule(pScrn, "int10")) {
+ 	xf86LoaderReqSymLists(int10Symbols, NULL);
+#if !defined(__alpha__) && !defined(__powerpc__)
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n");
+        pNv->pInt = xf86InitInt10(pNv->pEnt->index);
+#endif
+    }
+   
+    xf86SetOperatingState(resVgaIo, pNv->pEnt->index, ResUnusedOpr);
+    xf86SetOperatingState(resVgaMem, pNv->pEnt->index, ResDisableOpr);
+
+    /* Set pScrn->monitor */
+    pScrn->monitor = pScrn->confScreen->monitor;
+
+    /*
+     * Set the Chipset and ChipRev, allowing config file entries to
+     * override.
+     */
+    if (pNv->pEnt->device->chipset && *pNv->pEnt->device->chipset) {
+	pScrn->chipset = pNv->pEnt->device->chipset;
+        pNv->Chipset = xf86StringToToken(NVKnownChipsets, pScrn->chipset);
+        from = X_CONFIG;
+    } else if (pNv->pEnt->device->chipID >= 0) {
+	pNv->Chipset = pNv->pEnt->device->chipID;
+	pScrn->chipset = (char *)xf86TokenToString(NVKnownChipsets, 
+                                                   pNv->Chipset);
+	from = X_CONFIG;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
+		   pNv->Chipset);
+    } else {
+	from = X_PROBED;
+	pNv->Chipset = (pNv->PciInfo->vendor << 16) | pNv->PciInfo->chipType;
+
+        if((pNv->Chipset & 0xfff0) == 0x00F0)
+            pNv->Chipset = NVGetPCIXpressChip(pNv->PciInfo);
+
+	pScrn->chipset = (char *)xf86TokenToString(NVKnownChipsets, 
+                                                   pNv->Chipset);
+        if(!pScrn->chipset)
+          pScrn->chipset = "Unknown NVIDIA chipset";
+    }
+
+    if (pNv->pEnt->device->chipRev >= 0) {
+	pNv->ChipRev = pNv->pEnt->device->chipRev;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
+		   pNv->ChipRev);
+    } else {
+	pNv->ChipRev = pNv->PciInfo->chipRev;
+    }
+
+    /*
+     * This shouldn't happen because such problems should be caught in
+     * NVProbe(), but check it just in case.
+     */
+    if (pScrn->chipset == NULL) {
+	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		   "ChipID 0x%04X is not recognised\n", pNv->Chipset);
+	xf86FreeInt10(pNv->pInt);
+	return FALSE;
+    }
+    if (pNv->Chipset < 0) {
+	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		   "Chipset \"%s\" is not recognised\n", pScrn->chipset);
+	xf86FreeInt10(pNv->pInt);
+	return FALSE;
+    }
+
+    xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
+
+
+    /*
+     * The first thing we should figure out is the depth, bpp, etc.
+     */
+
+    if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb)) {
+	xf86FreeInt10(pNv->pInt);
+	return FALSE;
+    } else {
+	/* Check that the returned depth is one we support */
+	switch (pScrn->depth) {
+            case 8:
+            case 15:
+            case 16:
+            case 24:
+                /* OK */
+                break;
+            default:
+                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Given depth (%d) is not supported by this driver\n",
+                    pScrn->depth);
+		xf86FreeInt10(pNv->pInt);
+                return FALSE;
+	}
+    }
+    xf86PrintDepthBpp(pScrn);
+
+    /* Get the depth24 pixmap format */
+    if (pScrn->depth == 24 && pix24bpp == 0)
+	pix24bpp = xf86GetBppFromDepth(pScrn, 24);
+
+    /*
+     * This must happen after pScrn->display has been set because
+     * xf86SetWeight references it.
+     */
+    if (pScrn->depth > 8) {
+	/* The defaults are OK for us */
+	rgb zeros = {0, 0, 0};
+
+	if (!xf86SetWeight(pScrn, zeros, zeros)) {
+	    xf86FreeInt10(pNv->pInt);
+	    return FALSE;
+	}
+    }
+
+    if (!xf86SetDefaultVisual(pScrn, -1)) {
+	xf86FreeInt10(pNv->pInt);
+	return FALSE;
+    } else {
+	/* We don't currently support DirectColor at > 8bpp */
+	if (pScrn->depth > 8 && (pScrn->defaultVisual != TrueColor)) {
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
+		       " (%s) is not supported at depth %d\n",
+		       xf86GetVisualName(pScrn->defaultVisual), pScrn->depth);
+	    xf86FreeInt10(pNv->pInt);
+	    return FALSE;
+	}
+    }
+
+    /* The vgahw module should be loaded here when needed */
+    if (!xf86LoadSubModule(pScrn, "vgahw")) {
+	xf86FreeInt10(pNv->pInt);
+	return FALSE;
+    }
+    
+    xf86LoaderReqSymLists(vgahwSymbols, NULL);
+
+    /*
+     * Allocate a vgaHWRec
+     */
+    if (!vgaHWGetHWRec(pScrn)) {
+	xf86FreeInt10(pNv->pInt);
+	return FALSE;
+    }
+    
+    /* We use a programmable clock */
+    pScrn->progClock = TRUE;
+
+    /* Collect all of the relevant option flags (fill in pScrn->options) */
+    xf86CollectOptions(pScrn, NULL);
+
+    /* Process the options */
+    if (!(pNv->Options = xalloc(sizeof(NVOptions))))
+	return FALSE;
+    memcpy(pNv->Options, NVOptions, sizeof(NVOptions));
+    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pNv->Options);
+
+    /* Set the bits per RGB for 8bpp mode */
+    if (pScrn->depth == 8)
+	pScrn->rgbBits = 8;
+
+    from = X_DEFAULT;
+    pNv->HWCursor = TRUE;
+    /*
+     * The preferred method is to use the "hw cursor" option as a tri-state
+     * option, with the default set above.
+     */
+    if (xf86GetOptValBool(pNv->Options, OPTION_HW_CURSOR, &pNv->HWCursor)) {
+	from = X_CONFIG;
+    }
+    /* For compatibility, accept this too (as an override) */
+    if (xf86ReturnOptValBool(pNv->Options, OPTION_SW_CURSOR, FALSE)) {
+	from = X_CONFIG;
+	pNv->HWCursor = FALSE;
+    }
+    xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+		pNv->HWCursor ? "HW" : "SW");
+
+    pNv->FpScale = TRUE;
+    if (xf86GetOptValBool(pNv->Options, OPTION_FP_SCALE, &pNv->FpScale)) {
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Flat panel scaling %s\n",
+                   pNv->FpScale ? "on" : "off");
+    }
+    if (xf86ReturnOptValBool(pNv->Options, OPTION_NOACCEL, FALSE)) {
+	pNv->NoAccel = TRUE;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
+    }
+    if (xf86ReturnOptValBool(pNv->Options, OPTION_SHADOW_FB, FALSE)) {
+	pNv->ShadowFB = TRUE;
+	pNv->NoAccel = TRUE;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 
+		"Using \"Shadow Framebuffer\" - acceleration disabled\n");
+    }
+    if (xf86ReturnOptValBool(pNv->Options, OPTION_FBDEV, FALSE)) {
+	pNv->FBDev = TRUE;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 
+		"Using framebuffer device\n");
+    }
+    if (pNv->FBDev) {
+	/* check for linux framebuffer device */
+	if (!xf86LoadSubModule(pScrn, "fbdevhw")) {
+	    xf86FreeInt10(pNv->pInt);
+	    return FALSE;
+	}
+	
+	xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
+	if (!fbdevHWInit(pScrn, pNv->PciInfo, NULL)) {
+	    xf86FreeInt10(pNv->pInt);
+	    return FALSE;
+	}
+	pScrn->SwitchMode    = fbdevHWSwitchModeWeak();
+	pScrn->AdjustFrame   = fbdevHWAdjustFrameWeak();
+	pScrn->EnterVT       = NVEnterVTFBDev;
+	pScrn->LeaveVT       = fbdevHWLeaveVTWeak();
+	pScrn->ValidMode     = fbdevHWValidModeWeak();
+    }
+    pNv->Rotate = 0;
+    pNv->RandRRotation = FALSE;
+    if ((s = xf86GetOptValString(pNv->Options, OPTION_ROTATE))) {
+      if(!xf86NameCmp(s, "CW")) {
+	pNv->ShadowFB = TRUE;
+	pNv->NoAccel = TRUE;
+	pNv->HWCursor = FALSE;
+	pNv->Rotate = 1;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 
+		"Rotating screen clockwise - acceleration disabled\n");
+      } else
+      if(!xf86NameCmp(s, "CCW")) {
+	pNv->ShadowFB = TRUE;
+	pNv->NoAccel = TRUE;
+	pNv->HWCursor = FALSE;
+	pNv->Rotate = -1;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 
+		"Rotating screen counter clockwise - acceleration disabled\n");
+      } else
+      if(!xf86NameCmp(s, "RandR")) {
+#ifdef RANDR
+	pNv->ShadowFB = TRUE;
+	pNv->NoAccel = TRUE;
+	pNv->HWCursor = FALSE;
+	pNv->RandRRotation = TRUE;
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+		"Using RandR rotation - acceleration disabled\n");
+#else
+	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		"This driver was not compiled with support for the Resize and "
+		"Rotate extension.  Cannot honor 'Option \"Rotate\" "
+		"\"RandR\"'.\n");
+#endif
+      } else {
+	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 
+		"\"%s\" is not a valid value for Option \"Rotate\"\n", s);
+	xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
+		"Valid options are \"CW\", \"CCW\", and \"RandR\"\n");
+      }
+    }
+
+    if(xf86GetOptValInteger(pNv->Options, OPTION_VIDEO_KEY, &(pNv->videoKey))) {
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n",
+                                pNv->videoKey);
+    } else {
+        pNv->videoKey =  (1 << pScrn->offset.red) | 
+                          (1 << pScrn->offset.green) |
+        (((pScrn->mask.blue >> pScrn->offset.blue) - 1) << pScrn->offset.blue); 
+    }
+
+    if (xf86GetOptValBool(pNv->Options, OPTION_FLAT_PANEL, &(pNv->FlatPanel))) {
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "forcing %s usage\n",
+                   pNv->FlatPanel ? "DFP" : "CRTC");
+    } else {
+        pNv->FlatPanel = -1;   /* autodetect later */
+    }
+
+    pNv->FPDither = FALSE;
+    if (xf86GetOptValBool(pNv->Options, OPTION_FP_DITHER, &(pNv->FPDither))) 
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "enabling flat panel dither\n");
+
+    if (xf86GetOptValInteger(pNv->Options, OPTION_CRTC_NUMBER,
+                             &pNv->CRTCnumber)) 
+    {
+	if((pNv->CRTCnumber < 0) || (pNv->CRTCnumber > 1)) {
+           pNv->CRTCnumber = -1;
+           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 
+                      "Invalid CRTC number.  Must be 0 or 1\n");
+        }
+    } else {
+        pNv->CRTCnumber = -1; /* autodetect later */
+    }
+
+
+    if (xf86GetOptValInteger(pNv->Options, OPTION_FP_TWEAK, 
+                             &pNv->PanelTweak))
+    {
+        pNv->usePanelTweak = TRUE;
+    } else {
+        pNv->usePanelTweak = FALSE;
+    }
+    
+    if (pNv->pEnt->device->MemBase != 0) {
+	/* Require that the config file value matches one of the PCI values. */
+	if (!xf86CheckPciMemBase(pNv->PciInfo, pNv->pEnt->device->MemBase)) {
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		"MemBase 0x%08lX doesn't match any PCI base register.\n",
+		pNv->pEnt->device->MemBase);
+	    xf86FreeInt10(pNv->pInt);
+	    NVFreeRec(pScrn);
+	    return FALSE;
+	}
+	pNv->FbAddress = pNv->pEnt->device->MemBase;
+	from = X_CONFIG;
+    } else {
+	if (pNv->PciInfo->memBase[1] != 0) {
+	    pNv->FbAddress = pNv->PciInfo->memBase[1] & 0xff800000;
+	    from = X_PROBED;
+	} else {
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "No valid FB address in PCI config space\n");
+	    xf86FreeInt10(pNv->pInt);
+	    NVFreeRec(pScrn);
+	    return FALSE;
+	}
+    }
+    xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n",
+	       (unsigned long)pNv->FbAddress);
+
+    if (pNv->pEnt->device->IOBase != 0) {
+	/* Require that the config file value matches one of the PCI values. */
+	if (!xf86CheckPciMemBase(pNv->PciInfo, pNv->pEnt->device->IOBase)) {
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		"IOBase 0x%08lX doesn't match any PCI base register.\n",
+		pNv->pEnt->device->IOBase);
+	    xf86FreeInt10(pNv->pInt);
+	    NVFreeRec(pScrn);
+	    return FALSE;
+	}
+	pNv->IOAddress = pNv->pEnt->device->IOBase;
+	from = X_CONFIG;
+    } else {
+	if (pNv->PciInfo->memBase[0] != 0) {
+	    pNv->IOAddress = pNv->PciInfo->memBase[0] & 0xffffc000;
+	    from = X_PROBED;
+	} else {
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			"No valid MMIO address in PCI config space\n");
+	    xf86FreeInt10(pNv->pInt);
+	    NVFreeRec(pScrn);
+	    return FALSE;
+	}
+    }
+    xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n",
+	       (unsigned long)pNv->IOAddress);
+     
+    if (xf86RegisterResources(pNv->pEnt->index, NULL, ResExclusive)) {
+	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		"xf86RegisterResources() found resource conflicts\n");
+	xf86FreeInt10(pNv->pInt);
+	NVFreeRec(pScrn);
+	return FALSE;
+    }
+
+    switch (pNv->Chipset & 0x0ff0) {
+    case 0x0100:   /* GeForce 256 */
+    case 0x0110:   /* GeForce2 MX */
+    case 0x0150:   /* GeForce2 */
+    case 0x0170:   /* GeForce4 MX */
+    case 0x0180:   /* GeForce4 MX (8x AGP) */
+    case 0x01A0:   /* nForce */
+    case 0x01F0:   /* nForce2 */
+         pNv->Architecture =  NV_ARCH_10;
+         break;
+    case 0x0200:   /* GeForce3 */
+    case 0x0250:   /* GeForce4 Ti */
+    case 0x0280:   /* GeForce4 Ti (8x AGP) */
+         pNv->Architecture =  NV_ARCH_20;
+         break;
+    case 0x0300:   /* GeForce FX 5800 */
+    case 0x0310:   /* GeForce FX 5600 */
+    case 0x0320:   /* GeForce FX 5200 */
+    case 0x0330:   /* GeForce FX 5900 */
+    case 0x0340:   /* GeForce FX 5700 */
+         pNv->Architecture =  NV_ARCH_30;
+         break;
+    case 0x0040:   /* GeForce 6800 */
+    case 0x00C0:   /* GeForce 6800 */
+    case 0x0120:   /* GeForce 6800 */
+    case 0x0140:   /* GeForce 6600 */
+    case 0x0160:   /* GeForce 6200 */
+    case 0x01D0:   /* GeForce 7200, 7300, 7400 */
+    case 0x0090:   /* GeForce 7800 */
+    case 0x0210:   /* GeForce 6800 */
+    case 0x0220:   /* GeForce 6200 */
+    case 0x0290:   /* GeForce 7900 */
+    case 0x0390:   /* GeForce 7600 */
+    case 0x0240:   /* GeForce 6100 */
+         pNv->Architecture =  NV_ARCH_40;
+         break;
+    default:
+         pNv->Architecture =  NV_ARCH_04;
+         break;
+    }
+
+    pNv->alphaCursor = (pNv->Architecture >= NV_ARCH_10) &&
+                       ((pNv->Chipset & 0x0ff0) != 0x0100);
+
+    NVCommonSetup(pScrn);
+
+    if (pNv->FBDev) {
+       pScrn->videoRam = fbdevHWGetVidmem(pScrn)/1024;
+    } else {
+       pScrn->videoRam = pNv->RamAmountKBytes;
+    }
+    xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kBytes\n",
+               pScrn->videoRam);
+	
+    pNv->FbMapSize = pScrn->videoRam * 1024;
+
+    /*
+     * If the driver can do gamma correction, it should call xf86SetGamma()
+     * here.
+     */
+
+    {
+	Gamma zeros = {0.0, 0.0, 0.0};
+
+	if (!xf86SetGamma(pScrn, zeros)) {
+	    xf86FreeInt10(pNv->pInt);
+	    return FALSE;
+	}
+    }
+
+    if(pNv->Architecture >= NV_ARCH_40)
+       pNv->FbUsableSize = pNv->FbMapSize - (560 * 1024);
+    else
+       pNv->FbUsableSize = pNv->FbMapSize - (128 * 1024);
+    pNv->ScratchBufferSize = (pNv->Architecture < NV_ARCH_10) ? 8192 : 16384;
+    pNv->ScratchBufferStart = pNv->FbUsableSize - pNv->ScratchBufferSize;
+    pNv->CursorStart = pNv->FbUsableSize + (32 * 1024);
+
+    /*
+     * Setup the ClockRanges, which describe what clock ranges are available,
+     * and what sort of modes they can be used for.
+     */
+
+    clockRanges = xnfcalloc(sizeof(ClockRange), 1);
+    clockRanges->next = NULL;
+    clockRanges->minClock = pNv->MinVClockFreqKHz;
+    clockRanges->maxClock = pNv->MaxVClockFreqKHz;
+    clockRanges->clockIndex = -1;		/* programmable */
+    clockRanges->doubleScanAllowed = TRUE;
+    if((pNv->Architecture == NV_ARCH_20) ||
+         ((pNv->Architecture == NV_ARCH_10) && 
+           ((pNv->Chipset & 0x0ff0) != 0x0100) &&
+           ((pNv->Chipset & 0x0ff0) != 0x0150)))
+    {
+       /* HW is broken */
+       clockRanges->interlaceAllowed = FALSE;
+    } else {
+       clockRanges->interlaceAllowed = TRUE;
+    }
+
+    if(pNv->FlatPanel == 1) {
+       clockRanges->interlaceAllowed = FALSE;
+       clockRanges->doubleScanAllowed = FALSE;
+    }
+
+    if(pNv->Architecture < NV_ARCH_10) {
+       max_width = (pScrn->bitsPerPixel > 16) ? 2032 : 2048;
+       max_height = 2048;
+    } else {
+       max_width = (pScrn->bitsPerPixel > 16) ? 4080 : 4096;
+       max_height = 4096;
+    }
+
+    /*
+     * xf86ValidateModes will check that the mode HTotal and VTotal values
+     * don't exceed the chipset's limit if pScrn->maxHValue and
+     * pScrn->maxVValue are set.  Since our NVValidMode() already takes
+     * care of this, we don't worry about setting them here.
+     */
+    i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
+                          pScrn->display->modes, clockRanges,
+                          NULL, 256, max_width,
+                          512, 128, max_height,
+                          pScrn->display->virtualX,
+                          pScrn->display->virtualY,
+                          pNv->ScratchBufferStart,
+                          LOOKUP_BEST_REFRESH);
+
+    if (i < 1 && pNv->FBDev) {
+	fbdevHWUseBuildinMode(pScrn);
+	pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */
+	i = 1;
+    }
+    if (i == -1) {
+	xf86FreeInt10(pNv->pInt);
+	NVFreeRec(pScrn);
+	return FALSE;
+    }
+
+    /* Prune the modes marked as invalid */
+    xf86PruneDriverModes(pScrn);
+
+    if (i == 0 || pScrn->modes == NULL) {
+	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
+	xf86FreeInt10(pNv->pInt);
+	NVFreeRec(pScrn);
+	return FALSE;
+    }
+
+    /*
+     * Set the CRTC parameters for all of the modes based on the type
+     * of mode, and the chipset's interlace requirements.
+     *
+     * Calling this is required if the mode->Crtc* values are used by the
+     * driver and if the driver doesn't provide code to set them.  They
+     * are not pre-initialised at all.
+     */
+    xf86SetCrtcForModes(pScrn, 0);
+
+    /* Set the current mode to the first in the list */
+    pScrn->currentMode = pScrn->modes;
+
+    /* Print the list of modes being used */
+    xf86PrintModes(pScrn);
+
+    /* Set display resolution */
+    xf86SetDpi(pScrn, 0, 0);
+
+
+    /*
+     * XXX This should be taken into account in some way in the mode valdation
+     * section.
+     */
+
+    if (xf86LoadSubModule(pScrn, "fb") == NULL) {
+	xf86FreeInt10(pNv->pInt);
+	NVFreeRec(pScrn);
+	return FALSE;
+    }
+
+    xf86LoaderReqSymLists(fbSymbols, NULL);
+    
+    /* Load XAA if needed */
+    if (!pNv->NoAccel) {
+	if (!xf86LoadSubModule(pScrn, "xaa")) {
+	    xf86FreeInt10(pNv->pInt);
+	    NVFreeRec(pScrn);
+	    return FALSE;
+	}
+	xf86LoaderReqSymLists(xaaSymbols, NULL);
+    }
+
+    /* Load ramdac if needed */
+    if (pNv->HWCursor) {
+	if (!xf86LoadSubModule(pScrn, "ramdac")) {
+	    xf86FreeInt10(pNv->pInt);
+	    NVFreeRec(pScrn);
+	    return FALSE;
+	}
+	xf86LoaderReqSymLists(ramdacSymbols, NULL);
+    }
+
+    /* Load shadowfb if needed */
+    if (pNv->ShadowFB) {
+	if (!xf86LoadSubModule(pScrn, "shadowfb")) {
+	    xf86FreeInt10(pNv->pInt);
+	    NVFreeRec(pScrn);
+	    return FALSE;
+	}
+	xf86LoaderReqSymLists(shadowSymbols, NULL);
+    }
+
+    pNv->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel;
+    pNv->CurrentLayout.depth = pScrn->depth;
+    pNv->CurrentLayout.displayWidth = pScrn->displayWidth;
+    pNv->CurrentLayout.weight.red = pScrn->weight.red;
+    pNv->CurrentLayout.weight.green = pScrn->weight.green;
+    pNv->CurrentLayout.weight.blue = pScrn->weight.blue;
+    pNv->CurrentLayout.mode = pScrn->currentMode;
+
+    xf86FreeInt10(pNv->pInt);
+
+    pNv->pInt = NULL;
+    return TRUE;
+}
+
+
+/*
+ * Map the framebuffer and MMIO memory.
+ */
+
+static Bool
+NVMapMem(ScrnInfoPtr pScrn)
+{
+    NVPtr pNv;
+        
+    pNv = NVPTR(pScrn);
+
+    pNv->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
+				 pNv->PciTag, pNv->FbAddress,
+				 pNv->FbMapSize);
+    if (pNv->FbBase == NULL)
+	return FALSE;
+
+    pNv->FbStart = pNv->FbBase;
+
+    return TRUE;
+}
+
+Bool
+NVMapMemFBDev(ScrnInfoPtr pScrn)
+{
+    NVPtr pNv;
+
+    pNv = NVPTR(pScrn);
+
+    pNv->FbBase = fbdevHWMapVidmem(pScrn);
+    if (pNv->FbBase == NULL)
+        return FALSE;
+
+    pNv->FbStart = pNv->FbBase;
+
+    return TRUE;
+}
+
+/*
+ * Unmap the framebuffer and MMIO memory.
+ */
+
+static Bool
+NVUnmapMem(ScrnInfoPtr pScrn)
+{
+    NVPtr pNv;
+    
+    pNv = NVPTR(pScrn);
+
+    xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pNv->FbBase, pNv->FbMapSize);
+    pNv->FbBase = NULL;
+    pNv->FbStart = NULL;
+
+    return TRUE;
+}
+
+
+/*
+ * Initialise a new mode. 
+ */
+
+static Bool
+NVModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+    vgaRegPtr vgaReg;
+    NVPtr pNv = NVPTR(pScrn);
+    NVRegPtr nvReg;
+
+    /* Initialise the ModeReg values */
+    if (!vgaHWInit(pScrn, mode))
+	return FALSE;
+    pScrn->vtSema = TRUE;
+
+    vgaReg = &hwp->ModeReg;
+    nvReg = &pNv->ModeReg;
+
+    if(!NVDACInit(pScrn, mode))
+        return FALSE;
+
+    NVLockUnlock(pNv, 0);
+    if(pNv->twoHeads) {
+        VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+        VGA_WR08(pNv->PCIO, 0x03D5, nvReg->crtcOwner);
+        NVLockUnlock(pNv, 0);
+    }
+
+    /* Program the registers */
+    vgaHWProtect(pScrn, TRUE);
+
+    NVDACRestore(pScrn, vgaReg, nvReg, FALSE);
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+    /* turn on LFB swapping */
+    {
+	unsigned char tmp;
+
+	VGA_WR08(pNv->PCIO, 0x3d4, 0x46);
+	tmp = VGA_RD08(pNv->PCIO, 0x3d5);
+	tmp |= (1 << 7);
+	VGA_WR08(pNv->PCIO, 0x3d5, tmp);
+    }
+#endif
+
+    NVResetGraphics(pScrn);
+
+    vgaHWProtect(pScrn, FALSE);
+
+    pNv->CurrentLayout.mode = mode;
+
+    return TRUE;
+}
+
+/*
+ * Restore the initial (text) mode.
+ */
+static void 
+NVRestore(ScrnInfoPtr pScrn)
+{
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+    vgaRegPtr vgaReg = &hwp->SavedReg;
+    NVPtr pNv = NVPTR(pScrn);
+    NVRegPtr nvReg = &pNv->SavedReg;
+
+    NVLockUnlock(pNv, 0);
+
+    if(pNv->twoHeads) {
+        VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+        VGA_WR08(pNv->PCIO, 0x03D5, pNv->CRTCnumber * 0x3);
+        NVLockUnlock(pNv, 0);
+    }
+
+    /* Only restore text mode fonts/text for the primary card */
+    vgaHWProtect(pScrn, TRUE);
+    NVDACRestore(pScrn, vgaReg, nvReg, pNv->Primary);
+    if(pNv->twoHeads) {
+        VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+        VGA_WR08(pNv->PCIO, 0x03D5, nvReg->crtcOwner);
+    }
+    vgaHWProtect(pScrn, FALSE);
+}
+
+static void NVBacklightEnable(NVPtr pNv,  Bool on)
+{
+    /* This is done differently on each laptop.  Here we
+       define the ones we know for sure. */
+
+#if defined(__powerpc__)
+    if((pNv->Chipset == 0x10DE0179) || 
+       (pNv->Chipset == 0x10DE0189) || 
+       (pNv->Chipset == 0x10DE0329))
+    {
+       /* NV17,18,34 Apple iMac, iBook, PowerBook */
+      CARD32 tmp_pmc, tmp_pcrt;
+      tmp_pmc = pNv->PMC[0x10F0/4] & 0x7FFFFFFF;
+      tmp_pcrt = pNv->PCRTC0[0x081C/4] & 0xFFFFFFFC;
+      if(on) {
+          tmp_pmc |= (1 << 31);
+          tmp_pcrt |= 0x1;
+      }
+      pNv->PMC[0x10F0/4] = tmp_pmc;
+      pNv->PCRTC0[0x081C/4] = tmp_pcrt;
+    }
+#endif
+    
+    if(pNv->LVDS) {
+       if(pNv->twoHeads && ((pNv->Chipset & 0x0ff0) != 0x0110)) {
+           pNv->PMC[0x130C/4] = on ? 3 : 7; 
+       }
+    } else {
+       CARD32 fpcontrol;
+
+       fpcontrol = pNv->PRAMDAC[0x0848/4] & 0xCfffffCC;
+
+       /* cut the TMDS output */
+       if(on) fpcontrol |= pNv->fpSyncs;
+       else fpcontrol |= 0x20000022;
+
+       pNv->PRAMDAC[0x0848/4] = fpcontrol;
+    }
+}
+
+static void
+NVDPMSSetLCD(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
+{
+  NVPtr pNv = NVPTR(pScrn);
+
+  if (!pScrn->vtSema) return;
+
+  vgaHWDPMSSet(pScrn, PowerManagementMode, flags);
+
+  switch (PowerManagementMode) {
+  case DPMSModeStandby:  /* HSync: Off, VSync: On */
+  case DPMSModeSuspend:  /* HSync: On, VSync: Off */
+  case DPMSModeOff:      /* HSync: Off, VSync: Off */
+    NVBacklightEnable(pNv, 0);
+    break;
+  case DPMSModeOn:       /* HSync: On, VSync: On */
+    NVBacklightEnable(pNv, 1);
+  default:
+    break;
+  }
+}
+
+
+static void
+NVDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
+{
+  unsigned char crtc1A;
+  vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+  if (!pScrn->vtSema) return;
+
+  crtc1A = hwp->readCrtc(hwp, 0x1A) & ~0xC0;
+
+  switch (PowerManagementMode) {
+  case DPMSModeStandby:  /* HSync: Off, VSync: On */
+    crtc1A |= 0x80;
+    break;
+  case DPMSModeSuspend:  /* HSync: On, VSync: Off */
+    crtc1A |= 0x40;
+    break;
+  case DPMSModeOff:      /* HSync: Off, VSync: Off */
+    crtc1A |= 0xC0;
+    break;
+  case DPMSModeOn:       /* HSync: On, VSync: On */
+  default:
+    break;
+  }
+
+  /* vgaHWDPMSSet will merely cut the dac output */
+  vgaHWDPMSSet(pScrn, PowerManagementMode, flags);
+
+  hwp->writeCrtc(hwp, 0x1A, crtc1A);
+}
+
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+    ScrnInfoPtr pScrn;
+    vgaHWPtr hwp;
+    NVPtr pNv;
+    int ret;
+    VisualPtr visual;
+    unsigned char *FBStart;
+    int width, height, displayWidth, offscreenHeight, shadowHeight;
+    BoxRec AvailFBArea;
+
+    /* 
+     * First get the ScrnInfoRec
+     */
+    pScrn = xf86Screens[pScreen->myNum];
+
+    hwp = VGAHWPTR(pScrn);
+    pNv = NVPTR(pScrn);
+
+    /* Map the NV memory and MMIO areas */
+    if (pNv->FBDev) {
+        if (!NVMapMemFBDev(pScrn)) {
+            return FALSE;
+        }
+    } else {
+        if (!NVMapMem(pScrn)) {
+            return FALSE;
+         }
+    }
+
+    /* Map the VGA memory when the primary video */
+    if (pNv->Primary && !pNv->FBDev) {
+	hwp->MapSize = 0x10000;
+	if (!vgaHWMapMem(pScrn))
+	    return FALSE;
+    }
+
+    if (pNv->FBDev) {
+	fbdevHWSave(pScrn);
+	if (!fbdevHWModeInit(pScrn, pScrn->currentMode))
+	    return FALSE;
+    } else {
+	/* Save the current state */
+	NVSave(pScrn);
+	/* Initialise the first mode */
+	if (!NVModeInit(pScrn, pScrn->currentMode))
+	    return FALSE;
+    }
+
+    /* Darken the screen for aesthetic reasons and set the viewport */
+    NVSaveScreen(pScreen, SCREEN_SAVER_ON);
+    pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+    /*
+     * The next step is to setup the screen's visuals, and initialise the
+     * framebuffer code.  In cases where the framebuffer's default
+     * choices for things like visual layouts and bits per RGB are OK,
+     * this may be as simple as calling the framebuffer's ScreenInit()
+     * function.  If not, the visuals will need to be setup before calling
+     * a fb ScreenInit() function and fixed up after.
+     *
+     * For most PC hardware at depths >= 8, the defaults that fb uses
+     * are not appropriate.  In this driver, we fixup the visuals after.
+     */
+
+    /*
+     * Reset the visual list.
+     */
+    miClearVisualTypes();
+
+    /* Setup the visuals we support. */
+
+    if (!miSetVisualTypes(pScrn->depth, 
+                          miGetDefaultVisualMask(pScrn->depth), 8,
+                          pScrn->defaultVisual))
+	  return FALSE;
+    if (!miSetPixmapDepths ()) return FALSE;
+
+    /*
+     * Call the framebuffer layer's ScreenInit function, and fill in other
+     * pScreen fields.
+     */
+
+    width = pScrn->virtualX;
+    height = pScrn->virtualY;
+    displayWidth = pScrn->displayWidth;
+
+
+    if(pNv->Rotate) {
+	height = pScrn->virtualX;
+	width = pScrn->virtualY;
+    }
+
+    /* If RandR rotation is enabled, leave enough space in the
+     * framebuffer for us to rotate the screen dimensions without
+     * changing the pitch.
+     */
+    if(pNv->RandRRotation)
+        shadowHeight = max(width, height);
+    else
+        shadowHeight = height;
+
+    if(pNv->ShadowFB) {
+ 	pNv->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width);
+        pNv->ShadowPtr = xalloc(pNv->ShadowPitch * shadowHeight);
+	displayWidth = pNv->ShadowPitch / (pScrn->bitsPerPixel >> 3);
+        FBStart = pNv->ShadowPtr;
+    } else {
+	pNv->ShadowPtr = NULL;
+	FBStart = pNv->FbStart;
+    }
+
+    switch (pScrn->bitsPerPixel) {
+        case 8:
+        case 16:
+        case 32:
+            ret = fbScreenInit(pScreen, FBStart, width, height,
+                               pScrn->xDpi, pScrn->yDpi,
+                               displayWidth, pScrn->bitsPerPixel);
+            break;
+        default:
+            xf86DrvMsg(scrnIndex, X_ERROR,
+                       "Internal error: invalid bpp (%d) in NVScreenInit\n",
+                       pScrn->bitsPerPixel);
+            ret = FALSE;
+            break;
+    }
+    if (!ret)
+	return FALSE;
+
+    if (pScrn->bitsPerPixel > 8) {
+        /* Fixup RGB ordering */
+        visual = pScreen->visuals + pScreen->numVisuals;
+        while (--visual >= pScreen->visuals) {
+	    if ((visual->class | DynamicClass) == DirectColor) {
+		visual->offsetRed = pScrn->offset.red;
+		visual->offsetGreen = pScrn->offset.green;
+		visual->offsetBlue = pScrn->offset.blue;
+		visual->redMask = pScrn->mask.red;
+		visual->greenMask = pScrn->mask.green;
+		visual->blueMask = pScrn->mask.blue;
+	    }
+	}
+    }
+
+    fbPictureInit (pScreen, 0, 0);
+    
+    xf86SetBlackWhitePixels(pScreen);
+
+    if(!pNv->ShadowFB) /* hardware cursor needs to wrap this layer */
+	NVDGAInit(pScreen);
+
+    offscreenHeight = pNv->ScratchBufferStart /
+                     (pScrn->displayWidth * pScrn->bitsPerPixel >> 3);
+    if(offscreenHeight > 32767)
+        offscreenHeight = 32767;
+
+    AvailFBArea.x1 = 0;
+    AvailFBArea.y1 = 0;
+    AvailFBArea.x2 = pScrn->displayWidth;
+    AvailFBArea.y2 = offscreenHeight;
+    xf86InitFBManager(pScreen, &AvailFBArea);
+    
+    if (!pNv->NoAccel)
+	NVAccelInit(pScreen);
+    
+    miInitializeBackingStore(pScreen);
+    xf86SetBackingStore(pScreen);
+    xf86SetSilkenMouse(pScreen);
+
+    /* Initialize software cursor.  
+	Must precede creation of the default colormap */
+    miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+    /* Initialize HW cursor layer. 
+	Must follow software cursor initialization*/
+    if (pNv->HWCursor) { 
+	if(!NVCursorInit(pScreen))
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 
+		"Hardware cursor initialization failed\n");
+    }
+
+    /* Initialise default colourmap */
+    if (!miCreateDefColormap(pScreen))
+	return FALSE;
+
+    /* Initialize colormap layer.  
+	Must follow initialization of the default colormap */
+    if(!xf86HandleColormaps(pScreen, 256, 8,
+	(pNv->FBDev ? fbdevHWLoadPaletteWeak() : NVDACLoadPalette), 
+	NULL, CMAP_RELOAD_ON_MODE_SWITCH | CMAP_PALETTED_TRUECOLOR))
+	return FALSE;
+
+    if(pNv->ShadowFB) {
+	RefreshAreaFuncPtr refreshArea = NVRefreshArea;
+
+	if(pNv->Rotate || pNv->RandRRotation) {
+	   pNv->PointerMoved = pScrn->PointerMoved;
+	   if(pNv->Rotate)
+	       pScrn->PointerMoved = NVPointerMoved;
+
+	   switch(pScrn->bitsPerPixel) {
+               case 8:	refreshArea = NVRefreshArea8;	break;
+               case 16:	refreshArea = NVRefreshArea16;	break;
+               case 32:	refreshArea = NVRefreshArea32;	break;
+	   }
+           if(!pNv->RandRRotation) {
+               xf86DisableRandR();
+               xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                          "Driver rotation enabled, RandR disabled\n");
+           }
+	}
+
+	ShadowFBInit(pScreen, refreshArea);
+    }
+
+    if(pNv->FlatPanel)
+       xf86DPMSInit(pScreen, NVDPMSSetLCD, 0);
+    else
+       xf86DPMSInit(pScreen, NVDPMSSet, 0);
+    
+    pScrn->memPhysBase = pNv->FbAddress;
+    pScrn->fbOffset = 0;
+
+    if(pNv->Rotate == 0 && !pNv->RandRRotation)
+       NVInitVideo(pScreen);
+
+    pScreen->SaveScreen = NVSaveScreen;
+
+    /* Wrap the current CloseScreen function */
+    pNv->CloseScreen = pScreen->CloseScreen;
+    pScreen->CloseScreen = NVCloseScreen;
+
+    pNv->BlockHandler = pScreen->BlockHandler;
+    pScreen->BlockHandler = NVBlockHandler;
+
+#ifdef RANDR
+    /* Install our DriverFunc.  We have to do it this way instead of using the
+     * HaveDriverFuncs argument to xf86AddDriver, because InitOutput clobbers
+     * pScrn->DriverFunc */
+    pScrn->DriverFunc = NVDriverFunc;
+#endif
+
+    /* Report any unused options (only for the first generation) */
+    if (serverGeneration == 1) {
+	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+    }
+    return TRUE;
+}
+
+static Bool
+NVSaveScreen(ScreenPtr pScreen, int mode)
+{
+    return vgaHWSaveScreen(pScreen, mode);
+}
+
+static void
+NVSave(ScrnInfoPtr pScrn)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    NVRegPtr nvReg = &pNv->SavedReg;
+    vgaHWPtr pVga = VGAHWPTR(pScrn);
+    vgaRegPtr vgaReg = &pVga->SavedReg;
+
+    NVLockUnlock(pNv, 0);
+    if(pNv->twoHeads) {
+        VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+        VGA_WR08(pNv->PCIO, 0x03D5, pNv->CRTCnumber * 0x3);
+        NVLockUnlock(pNv, 0);
+    }
+
+    NVDACSave(pScrn, vgaReg, nvReg, pNv->Primary);
+}
+
+#ifdef RANDR
+static Bool
+NVRandRGetInfo(ScrnInfoPtr pScrn, Rotation *rotations)
+{
+    NVPtr pNv = NVPTR(pScrn);
+
+    if(pNv->RandRRotation)
+       *rotations = RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_270;
+    else
+       *rotations = RR_Rotate_0;
+
+    return TRUE;
+}
+
+static Bool
+NVRandRSetConfig(ScrnInfoPtr pScrn, xorgRRConfig *config)
+{
+    NVPtr pNv = NVPTR(pScrn);
+
+    switch(config->rotation) {
+        case RR_Rotate_0:
+            pNv->Rotate = 0;
+            pScrn->PointerMoved = pNv->PointerMoved;
+            break;
+
+        case RR_Rotate_90:
+            pNv->Rotate = -1;
+            pScrn->PointerMoved = NVPointerMoved;
+            break;
+
+        case RR_Rotate_270:
+            pNv->Rotate = 1;
+            pScrn->PointerMoved = NVPointerMoved;
+            break;
+
+        default:
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Unexpected rotation in NVRandRSetConfig!\n");
+            pNv->Rotate = 0;
+            pScrn->PointerMoved = pNv->PointerMoved;
+            return FALSE;
+    }
+
+    return TRUE;
+}
+
+static Bool
+NVDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer data)
+{
+    switch(op) {
+       case RR_GET_INFO:
+          return NVRandRGetInfo(pScrn, (Rotation*)data);
+       case RR_SET_CONFIG:
+          return NVRandRSetConfig(pScrn, (xorgRRConfig*)data);
+       default:
+          return FALSE;
+    }
+
+    return FALSE;
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_hw.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1578 @@
+ /***************************************************************************\
+|*                                                                           *|
+|*       Copyright 1993-2003 NVIDIA, Corporation.  All rights reserved.      *|
+|*                                                                           *|
+|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
+|*     international laws.  Users and possessors of this source code are     *|
+|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
+|*     use this code in individual and commercial software.                  *|
+|*                                                                           *|
+|*     Any use of this source code must include,  in the user documenta-     *|
+|*     tion and  internal comments to the code,  notices to the end user     *|
+|*     as follows:                                                           *|
+|*                                                                           *|
+|*       Copyright 1993-2003 NVIDIA, Corporation.  All rights reserved.      *|
+|*                                                                           *|
+|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
+|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
+|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
+|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
+|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
+|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
+|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
+|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
+|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
+|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
+|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
+|*                                                                           *|
+|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
+|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
+|*     consisting  of "commercial  computer  software"  and  "commercial     *|
+|*     computer  software  documentation,"  as such  terms  are  used in     *|
+|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
+|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
+|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
+|*     all U.S. Government End Users  acquire the source code  with only     *|
+|*     those rights set forth herein.                                        *|
+|*                                                                           *|
+ \***************************************************************************/
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_hw.c,v 1.20 2006/01/21 01:17:59 mvojkovi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "nv_local.h"
+#include "compiler.h"
+#include "nv_include.h"
+
+
+void NVLockUnlock (
+    NVPtr pNv,
+    Bool  Lock
+)
+{
+    CARD8 cr11;
+
+    VGA_WR08(pNv->PCIO, 0x3D4, 0x1F);
+    VGA_WR08(pNv->PCIO, 0x3D5, Lock ? 0x99 : 0x57);
+
+    VGA_WR08(pNv->PCIO, 0x3D4, 0x11);
+    cr11 = VGA_RD08(pNv->PCIO, 0x3D5);
+    if(Lock) cr11 |= 0x80;
+    else cr11 &= ~0x80;
+    VGA_WR08(pNv->PCIO, 0x3D5, cr11);
+}
+
+int NVShowHideCursor (
+    NVPtr pNv,
+    int   ShowHide
+)
+{
+    int current = pNv->CurrentState->cursor1;
+
+    pNv->CurrentState->cursor1 = (pNv->CurrentState->cursor1 & 0xFE) |
+                                 (ShowHide & 0x01);
+    VGA_WR08(pNv->PCIO, 0x3D4, 0x31);
+    VGA_WR08(pNv->PCIO, 0x3D5, pNv->CurrentState->cursor1);
+
+    if(pNv->Architecture == NV_ARCH_40) {  /* HW bug */
+       volatile CARD32 curpos = pNv->PRAMDAC[0x0300/4];
+       pNv->PRAMDAC[0x0300/4] = curpos;
+    }
+
+    return (current & 0x01);
+}
+
+/****************************************************************************\
+*                                                                            *
+* The video arbitration routines calculate some "magic" numbers.  Fixes      *
+* the snow seen when accessing the framebuffer without it.                   *
+* It just works (I hope).                                                    *
+*                                                                            *
+\****************************************************************************/
+
+typedef struct {
+  int graphics_lwm;
+  int video_lwm;
+  int graphics_burst_size;
+  int video_burst_size;
+  int valid;
+} nv4_fifo_info;
+
+typedef struct {
+  int pclk_khz;
+  int mclk_khz;
+  int nvclk_khz;
+  char mem_page_miss;
+  char mem_latency;
+  int memory_width;
+  char enable_video;
+  char gr_during_vid;
+  char pix_bpp;
+  char mem_aligned;
+  char enable_mp;
+} nv4_sim_state;
+
+typedef struct {
+  int graphics_lwm;
+  int video_lwm;
+  int graphics_burst_size;
+  int video_burst_size;
+  int valid;
+} nv10_fifo_info;
+
+typedef struct {
+  int pclk_khz;
+  int mclk_khz;
+  int nvclk_khz;
+  char mem_page_miss;
+  char mem_latency;
+  int memory_type;
+  int memory_width;
+  char enable_video;
+  char gr_during_vid;
+  char pix_bpp;
+  char mem_aligned;
+  char enable_mp;
+} nv10_sim_state;
+
+
+static void nvGetClocks(NVPtr pNv, unsigned int *MClk, unsigned int *NVClk)
+{
+    unsigned int pll, N, M, MB, NB, P;
+
+    if(pNv->Architecture >= NV_ARCH_40) {
+       pll = pNv->PMC[0x4020/4];
+       P = (pll >> 16) & 0x07;
+       pll = pNv->PMC[0x4024/4];
+       M = pll & 0xFF;
+       N = (pll >> 8) & 0xFF;
+       if(((pNv->Chipset & 0xfff0) == 0x0290) ||
+          ((pNv->Chipset & 0xfff0) == 0x0390))
+       {
+          MB = 1;
+          NB = 1;
+       } else {
+          MB = (pll >> 16) & 0xFF;
+          NB = (pll >> 24) & 0xFF;
+       }
+       *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
+
+       pll = pNv->PMC[0x4000/4];
+       P = (pll >> 16) & 0x07;  
+       pll = pNv->PMC[0x4004/4];
+       M = pll & 0xFF;
+       N = (pll >> 8) & 0xFF;
+       MB = (pll >> 16) & 0xFF;
+       NB = (pll >> 24) & 0xFF;
+
+       *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
+    } else
+    if(pNv->twoStagePLL) {
+       pll = pNv->PRAMDAC0[0x0504/4];
+       M = pll & 0xFF; 
+       N = (pll >> 8) & 0xFF; 
+       P = (pll >> 16) & 0x0F;
+       pll = pNv->PRAMDAC0[0x0574/4];
+       if(pll & 0x80000000) {
+           MB = pll & 0xFF; 
+           NB = (pll >> 8) & 0xFF;
+       } else {
+           MB = 1;
+           NB = 1;
+       }
+       *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
+
+       pll = pNv->PRAMDAC0[0x0500/4];
+       M = pll & 0xFF; 
+       N = (pll >> 8) & 0xFF; 
+       P = (pll >> 16) & 0x0F;
+       pll = pNv->PRAMDAC0[0x0570/4];
+       if(pll & 0x80000000) {
+           MB = pll & 0xFF;
+           NB = (pll >> 8) & 0xFF;
+       } else {
+           MB = 1;
+           NB = 1;
+       }
+       *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
+    } else 
+    if(((pNv->Chipset & 0x0ff0) == 0x0300) ||
+       ((pNv->Chipset & 0x0ff0) == 0x0330))
+    {
+       pll = pNv->PRAMDAC0[0x0504/4];
+       M = pll & 0x0F; 
+       N = (pll >> 8) & 0xFF;
+       P = (pll >> 16) & 0x07;
+       if(pll & 0x00000080) {
+           MB = (pll >> 4) & 0x07;     
+           NB = (pll >> 19) & 0x1f;
+       } else {
+           MB = 1;
+           NB = 1;
+       }
+       *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
+
+       pll = pNv->PRAMDAC0[0x0500/4];
+       M = pll & 0x0F;
+       N = (pll >> 8) & 0xFF;
+       P = (pll >> 16) & 0x07;
+       if(pll & 0x00000080) {
+           MB = (pll >> 4) & 0x07;
+           NB = (pll >> 19) & 0x1f;
+       } else {
+           MB = 1;
+           NB = 1;
+       }
+       *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
+    } else {
+       pll = pNv->PRAMDAC0[0x0504/4];
+       M = pll & 0xFF; 
+       N = (pll >> 8) & 0xFF; 
+       P = (pll >> 16) & 0x0F;
+       *MClk = (N * pNv->CrystalFreqKHz / M) >> P;
+
+       pll = pNv->PRAMDAC0[0x0500/4];
+       M = pll & 0xFF; 
+       N = (pll >> 8) & 0xFF; 
+       P = (pll >> 16) & 0x0F;
+       *NVClk = (N * pNv->CrystalFreqKHz / M) >> P;
+    }
+
+#if 0
+    ErrorF("NVClock = %i MHz, MEMClock = %i MHz\n", *NVClk/1000, *MClk/1000);
+#endif
+}
+
+
+static void nv4CalcArbitration (
+    nv4_fifo_info *fifo,
+    nv4_sim_state *arb
+)
+{
+    int data, pagemiss, cas,width, video_enable, bpp;
+    int nvclks, mclks, pclks, vpagemiss, crtpagemiss, vbs;
+    int found, mclk_extra, mclk_loop, cbs, m1, p1;
+    int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
+    int us_m, us_n, us_p, video_drain_rate, crtc_drain_rate;
+    int vpm_us, us_video, vlwm, video_fill_us, cpm_us, us_crt,clwm;
+
+    fifo->valid = 1;
+    pclk_freq = arb->pclk_khz;
+    mclk_freq = arb->mclk_khz;
+    nvclk_freq = arb->nvclk_khz;
+    pagemiss = arb->mem_page_miss;
+    cas = arb->mem_latency;
+    width = arb->memory_width >> 6;
+    video_enable = arb->enable_video;
+    bpp = arb->pix_bpp;
+    mp_enable = arb->enable_mp;
+    clwm = 0;
+    vlwm = 0;
+    cbs = 128;
+    pclks = 2;
+    nvclks = 2;
+    nvclks += 2;
+    nvclks += 1;
+    mclks = 5;
+    mclks += 3;
+    mclks += 1;
+    mclks += cas;
+    mclks += 1;
+    mclks += 1;
+    mclks += 1;
+    mclks += 1;
+    mclk_extra = 3;
+    nvclks += 2;
+    nvclks += 1;
+    nvclks += 1;
+    nvclks += 1;
+    if (mp_enable)
+        mclks+=4;
+    nvclks += 0;
+    pclks += 0;
+    found = 0;
+    vbs = 0;
+    while (found != 1)
+    {
+        fifo->valid = 1;
+        found = 1;
+        mclk_loop = mclks+mclk_extra;
+        us_m = mclk_loop *1000*1000 / mclk_freq;
+        us_n = nvclks*1000*1000 / nvclk_freq;
+        us_p = nvclks*1000*1000 / pclk_freq;
+        if (video_enable)
+        {
+            video_drain_rate = pclk_freq * 2;
+            crtc_drain_rate = pclk_freq * bpp/8;
+            vpagemiss = 2;
+            vpagemiss += 1;
+            crtpagemiss = 2;
+            vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
+            if (nvclk_freq * 2 > mclk_freq * width)
+                video_fill_us = cbs*1000*1000 / 16 / nvclk_freq ;
+            else
+                video_fill_us = cbs*1000*1000 / (8 * width) / mclk_freq;
+            us_video = vpm_us + us_m + us_n + us_p + video_fill_us;
+            vlwm = us_video * video_drain_rate/(1000*1000);
+            vlwm++;
+            vbs = 128;
+            if (vlwm > 128) vbs = 64;
+            if (vlwm > (256-64)) vbs = 32;
+            if (nvclk_freq * 2 > mclk_freq * width)
+                video_fill_us = vbs *1000*1000/ 16 / nvclk_freq ;
+            else
+                video_fill_us = vbs*1000*1000 / (8 * width) / mclk_freq;
+            cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
+            us_crt =
+            us_video
+            +video_fill_us
+            +cpm_us
+            +us_m + us_n +us_p
+            ;
+            clwm = us_crt * crtc_drain_rate/(1000*1000);
+            clwm++;
+        }
+        else
+        {
+            crtc_drain_rate = pclk_freq * bpp/8;
+            crtpagemiss = 2;
+            crtpagemiss += 1;
+            cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
+            us_crt =  cpm_us + us_m + us_n + us_p ;
+            clwm = us_crt * crtc_drain_rate/(1000*1000);
+            clwm++;
+        }
+        m1 = clwm + cbs - 512;
+        p1 = m1 * pclk_freq / mclk_freq;
+        p1 = p1 * bpp / 8;
+        if ((p1 < m1) && (m1 > 0))
+        {
+            fifo->valid = 0;
+            found = 0;
+            if (mclk_extra ==0)   found = 1;
+            mclk_extra--;
+        }
+        else if (video_enable)
+        {
+            if ((clwm > 511) || (vlwm > 255))
+            {
+                fifo->valid = 0;
+                found = 0;
+                if (mclk_extra ==0)   found = 1;
+                mclk_extra--;
+            }
+        }
+        else
+        {
+            if (clwm > 519)
+            {
+                fifo->valid = 0;
+                found = 0;
+                if (mclk_extra ==0)   found = 1;
+                mclk_extra--;
+            }
+        }
+        if (clwm < 384) clwm = 384;
+        if (vlwm < 128) vlwm = 128;
+        data = (int)(clwm);
+        fifo->graphics_lwm = data;
+        fifo->graphics_burst_size = 128;
+        data = (int)((vlwm+15));
+        fifo->video_lwm = data;
+        fifo->video_burst_size = vbs;
+    }
+}
+
+static void nv4UpdateArbitrationSettings (
+    unsigned      VClk, 
+    unsigned      pixelDepth, 
+    unsigned     *burst,
+    unsigned     *lwm,
+    NVPtr        pNv
+)
+{
+    nv4_fifo_info fifo_data;
+    nv4_sim_state sim_data;
+    unsigned int MClk, NVClk, cfg1;
+
+    nvGetClocks(pNv, &MClk, &NVClk);
+
+    cfg1 = pNv->PFB[0x00000204/4];
+    sim_data.pix_bpp        = (char)pixelDepth;
+    sim_data.enable_video   = 0;
+    sim_data.enable_mp      = 0;
+    sim_data.memory_width   = (pNv->PEXTDEV[0x0000/4] & 0x10) ? 128 : 64;
+    sim_data.mem_latency    = (char)cfg1 & 0x0F;
+    sim_data.mem_aligned    = 1;
+    sim_data.mem_page_miss  = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
+    sim_data.gr_during_vid  = 0;
+    sim_data.pclk_khz       = VClk;
+    sim_data.mclk_khz       = MClk;
+    sim_data.nvclk_khz      = NVClk;
+    nv4CalcArbitration(&fifo_data, &sim_data);
+    if (fifo_data.valid)
+    {
+        int  b = fifo_data.graphics_burst_size >> 4;
+        *burst = 0;
+        while (b >>= 1) (*burst)++;
+        *lwm   = fifo_data.graphics_lwm >> 3;
+    }
+}
+
+static void nv10CalcArbitration (
+    nv10_fifo_info *fifo,
+    nv10_sim_state *arb
+)
+{
+    int data, pagemiss, width, video_enable, bpp;
+    int nvclks, mclks, pclks, vpagemiss, crtpagemiss;
+    int nvclk_fill;
+    int found, mclk_extra, mclk_loop, cbs, m1;
+    int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
+    int us_m, us_m_min, us_n, us_p, crtc_drain_rate;
+    int vus_m;
+    int vpm_us, us_video, cpm_us, us_crt,clwm;
+    int clwm_rnd_down;
+    int m2us, us_pipe_min, p1clk, p2;
+    int min_mclk_extra;
+    int us_min_mclk_extra;
+
+    fifo->valid = 1;
+    pclk_freq = arb->pclk_khz; /* freq in KHz */
+    mclk_freq = arb->mclk_khz;
+    nvclk_freq = arb->nvclk_khz;
+    pagemiss = arb->mem_page_miss;
+    width = arb->memory_width/64;
+    video_enable = arb->enable_video;
+    bpp = arb->pix_bpp;
+    mp_enable = arb->enable_mp;
+    clwm = 0;
+
+    cbs = 512;
+
+    pclks = 4; /* lwm detect. */
+
+    nvclks = 3; /* lwm -> sync. */
+    nvclks += 2; /* fbi bus cycles (1 req + 1 busy) */
+
+    mclks  = 1;   /* 2 edge sync.  may be very close to edge so just put one. */
+
+    mclks += 1;   /* arb_hp_req */
+    mclks += 5;   /* ap_hp_req   tiling pipeline */
+
+    mclks += 2;    /* tc_req     latency fifo */
+    mclks += 2;    /* fb_cas_n_  memory request to fbio block */
+    mclks += 7;    /* sm_d_rdv   data returned from fbio block */
+
+    /* fb.rd.d.Put_gc   need to accumulate 256 bits for read */
+    if (arb->memory_type == 0)
+      if (arb->memory_width == 64) /* 64 bit bus */
+        mclks += 4;
+      else
+        mclks += 2;
+    else
+      if (arb->memory_width == 64) /* 64 bit bus */
+        mclks += 2;
+      else
+        mclks += 1;
+
+    if ((!video_enable) && (arb->memory_width == 128))
+    {  
+      mclk_extra = (bpp == 32) ? 31 : 42; /* Margin of error */
+      min_mclk_extra = 17;
+    }
+    else
+    {
+      mclk_extra = (bpp == 32) ? 8 : 4; /* Margin of error */
+      /* mclk_extra = 4; */ /* Margin of error */
+      min_mclk_extra = 18;
+    }
+
+    nvclks += 1; /* 2 edge sync.  may be very close to edge so just put one. */
+    nvclks += 1; /* fbi_d_rdv_n */
+    nvclks += 1; /* Fbi_d_rdata */
+    nvclks += 1; /* crtfifo load */
+
+    if(mp_enable)
+      mclks+=4; /* Mp can get in with a burst of 8. */
+    /* Extra clocks determined by heuristics */
+
+    nvclks += 0;
+    pclks += 0;
+    found = 0;
+    while(found != 1) {
+      fifo->valid = 1;
+      found = 1;
+      mclk_loop = mclks+mclk_extra;
+      us_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
+      us_m_min = mclks * 1000*1000 / mclk_freq; /* Minimum Mclk latency in us */
+      us_min_mclk_extra = min_mclk_extra *1000*1000 / mclk_freq;
+      us_n = nvclks*1000*1000 / nvclk_freq;/* nvclk latency in us */
+      us_p = pclks*1000*1000 / pclk_freq;/* nvclk latency in us */
+      us_pipe_min = us_m_min + us_n + us_p;
+
+      vus_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
+
+      if(video_enable) {
+        crtc_drain_rate = pclk_freq * bpp/8; /* MB/s */
+
+        vpagemiss = 1; /* self generating page miss */
+        vpagemiss += 1; /* One higher priority before */
+
+        crtpagemiss = 2; /* self generating page miss */
+        if(mp_enable)
+            crtpagemiss += 1; /* if MA0 conflict */
+
+        vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
+
+        us_video = vpm_us + vus_m; /* Video has separate read return path */
+
+        cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
+        us_crt =
+          us_video  /* Wait for video */
+          +cpm_us /* CRT Page miss */
+          +us_m + us_n +us_p /* other latency */
+          ;
+
+        clwm = us_crt * crtc_drain_rate/(1000*1000);
+        clwm++; /* fixed point <= float_point - 1.  Fixes that */
+      } else {
+        crtc_drain_rate = pclk_freq * bpp/8; /* bpp * pclk/8 */
+
+        crtpagemiss = 1; /* self generating page miss */
+        crtpagemiss += 1; /* MA0 page miss */
+        if(mp_enable)
+            crtpagemiss += 1; /* if MA0 conflict */
+        cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
+        us_crt =  cpm_us + us_m + us_n + us_p ;
+        clwm = us_crt * crtc_drain_rate/(1000*1000);
+        clwm++; /* fixed point <= float_point - 1.  Fixes that */
+
+          /* Finally, a heuristic check when width == 64 bits */
+          if(width == 1){
+              nvclk_fill = nvclk_freq * 8;
+              if(crtc_drain_rate * 100 >= nvclk_fill * 102)
+                      clwm = 0xfff; /*Large number to fail */
+
+              else if(crtc_drain_rate * 100  >= nvclk_fill * 98) {
+                  clwm = 1024;
+                  cbs = 512;
+              }
+          }
+      }
+
+
+      /*
+        Overfill check:
+
+        */
+
+      clwm_rnd_down = ((int)clwm/8)*8;
+      if (clwm_rnd_down < clwm)
+          clwm += 8;
+
+      m1 = clwm + cbs -  1024; /* Amount of overfill */
+      m2us = us_pipe_min + us_min_mclk_extra;
+
+      /* pclk cycles to drain */
+      p1clk = m2us * pclk_freq/(1000*1000); 
+      p2 = p1clk * bpp / 8; /* bytes drained. */
+
+      if((p2 < m1) && (m1 > 0)) {
+          fifo->valid = 0;
+          found = 0;
+          if(min_mclk_extra == 0)   {
+            if(cbs <= 32) {
+              found = 1; /* Can't adjust anymore! */
+            } else {
+              cbs = cbs/2;  /* reduce the burst size */
+            }
+          } else {
+            min_mclk_extra--;
+          }
+      } else {
+        if (clwm > 1023){ /* Have some margin */
+          fifo->valid = 0;
+          found = 0;
+          if(min_mclk_extra == 0)   
+              found = 1; /* Can't adjust anymore! */
+          else 
+              min_mclk_extra--;
+        }
+      }
+
+      if(clwm < (1024-cbs+8)) clwm = 1024-cbs+8;
+      data = (int)(clwm);
+      /*  printf("CRT LWM: %f bytes, prog: 0x%x, bs: 256\n", clwm, data ); */
+      fifo->graphics_lwm = data;   fifo->graphics_burst_size = cbs;
+
+      fifo->video_lwm = 1024;  fifo->video_burst_size = 512;
+    }
+}
+
+static void nv10UpdateArbitrationSettings (
+    unsigned      VClk, 
+    unsigned      pixelDepth, 
+    unsigned     *burst,
+    unsigned     *lwm,
+    NVPtr        pNv
+)
+{
+    nv10_fifo_info fifo_data;
+    nv10_sim_state sim_data;
+    unsigned int MClk, NVClk, cfg1;
+
+    nvGetClocks(pNv, &MClk, &NVClk);
+
+    cfg1 = pNv->PFB[0x0204/4];
+    sim_data.pix_bpp        = (char)pixelDepth;
+    sim_data.enable_video   = 1;
+    sim_data.enable_mp      = 0;
+    sim_data.memory_type    = (pNv->PFB[0x0200/4] & 0x01) ? 1 : 0;
+    sim_data.memory_width   = (pNv->PEXTDEV[0x0000/4] & 0x10) ? 128 : 64;
+    sim_data.mem_latency    = (char)cfg1 & 0x0F;
+    sim_data.mem_aligned    = 1;
+    sim_data.mem_page_miss  = (char)(((cfg1>>4) &0x0F) + ((cfg1>>31) & 0x01));
+    sim_data.gr_during_vid  = 0;
+    sim_data.pclk_khz       = VClk;
+    sim_data.mclk_khz       = MClk;
+    sim_data.nvclk_khz      = NVClk;
+    nv10CalcArbitration(&fifo_data, &sim_data);
+    if (fifo_data.valid) {
+        int  b = fifo_data.graphics_burst_size >> 4;
+        *burst = 0;
+        while (b >>= 1) (*burst)++;
+        *lwm   = fifo_data.graphics_lwm >> 3;
+    }
+}
+
+
+static void nv30UpdateArbitrationSettings (
+    NVPtr        pNv,
+    unsigned     *burst,
+    unsigned     *lwm
+)   
+{
+    unsigned int MClk, NVClk;
+    unsigned int fifo_size, burst_size, graphics_lwm;
+
+    fifo_size = 2048;
+    burst_size = 512;
+    graphics_lwm = fifo_size - burst_size;
+
+    nvGetClocks(pNv, &MClk, &NVClk);
+    
+    *burst = 0;
+    burst_size >>= 5;
+    while(burst_size >>= 1) (*burst)++;
+    *lwm = graphics_lwm >> 3;
+}
+
+static void nForceUpdateArbitrationSettings (
+    unsigned      VClk,
+    unsigned      pixelDepth,
+    unsigned     *burst,
+    unsigned     *lwm,
+    NVPtr        pNv
+)
+{
+    nv10_fifo_info fifo_data;
+    nv10_sim_state sim_data;
+    unsigned int M, N, P, pll, MClk, NVClk, memctrl;
+
+    if((pNv->Chipset & 0x0FF0) == 0x01A0) {
+       unsigned int uMClkPostDiv;
+
+       uMClkPostDiv = (pciReadLong(pciTag(0, 0, 3), 0x6C) >> 8) & 0xf;
+       if(!uMClkPostDiv) uMClkPostDiv = 4; 
+       MClk = 400000 / uMClkPostDiv;
+    } else {
+       MClk = pciReadLong(pciTag(0, 0, 5), 0x4C) / 1000;
+    }
+
+    pll = pNv->PRAMDAC0[0x0500/4];
+    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
+    NVClk  = (N * pNv->CrystalFreqKHz / M) >> P;
+    sim_data.pix_bpp        = (char)pixelDepth;
+    sim_data.enable_video   = 0;
+    sim_data.enable_mp      = 0;
+    sim_data.memory_type    = (pciReadLong(pciTag(0, 0, 1), 0x7C) >> 12) & 1;
+    sim_data.memory_width   = 64;
+
+    memctrl = pciReadLong(pciTag(0, 0, 3), 0x00) >> 16;
+
+    if((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) {
+        int dimm[3];
+
+        dimm[0] = (pciReadLong(pciTag(0, 0, 2), 0x40) >> 8) & 0x4F;
+        dimm[1] = (pciReadLong(pciTag(0, 0, 2), 0x44) >> 8) & 0x4F;
+        dimm[2] = (pciReadLong(pciTag(0, 0, 2), 0x48) >> 8) & 0x4F;
+
+        if((dimm[0] + dimm[1]) != dimm[2]) {
+             ErrorF("WARNING: "
+              "your nForce DIMMs are not arranged in optimal banks!\n");
+        } 
+    }
+
+    sim_data.mem_latency    = 3;
+    sim_data.mem_aligned    = 1;
+    sim_data.mem_page_miss  = 10;
+    sim_data.gr_during_vid  = 0;
+    sim_data.pclk_khz       = VClk;
+    sim_data.mclk_khz       = MClk;
+    sim_data.nvclk_khz      = NVClk;
+    nv10CalcArbitration(&fifo_data, &sim_data);
+    if (fifo_data.valid)
+    {
+        int  b = fifo_data.graphics_burst_size >> 4;
+        *burst = 0;
+        while (b >>= 1) (*burst)++;
+        *lwm   = fifo_data.graphics_lwm >> 3;
+    }
+}
+
+
+/****************************************************************************\
+*                                                                            *
+*                          RIVA Mode State Routines                          *
+*                                                                            *
+\****************************************************************************/
+
+/*
+ * Calculate the Video Clock parameters for the PLL.
+ */
+static void CalcVClock (
+    int           clockIn,
+    int          *clockOut,
+    U032         *pllOut,
+    NVPtr        pNv
+)
+{
+    unsigned lowM, highM;
+    unsigned DeltaNew, DeltaOld;
+    unsigned VClk, Freq;
+    unsigned M, N, P;
+    
+    DeltaOld = 0xFFFFFFFF;
+
+    VClk = (unsigned)clockIn;
+    
+    if (pNv->CrystalFreqKHz == 13500) {
+        lowM  = 7;
+        highM = 13;
+    } else {
+        lowM  = 8;
+        highM = 14;
+    }
+
+    for (P = 0; P <= 4; P++) {
+        Freq = VClk << P;
+        if ((Freq >= 128000) && (Freq <= 350000)) {
+            for (M = lowM; M <= highM; M++) {
+                N = ((VClk << P) * M) / pNv->CrystalFreqKHz;
+                if(N <= 255) {
+                    Freq = ((pNv->CrystalFreqKHz * N) / M) >> P;
+                    if (Freq > VClk)
+                        DeltaNew = Freq - VClk;
+                    else
+                        DeltaNew = VClk - Freq;
+                    if (DeltaNew < DeltaOld) {
+                        *pllOut   = (P << 16) | (N << 8) | M;
+                        *clockOut = Freq;
+                        DeltaOld  = DeltaNew;
+                    }
+                }
+            }
+        }
+    }
+}
+
+static void CalcVClock2Stage (
+    int           clockIn,
+    int          *clockOut,
+    U032         *pllOut,
+    U032         *pllBOut,
+    NVPtr        pNv
+)
+{
+    unsigned DeltaNew, DeltaOld;
+    unsigned VClk, Freq;
+    unsigned M, N, P;
+
+    DeltaOld = 0xFFFFFFFF;
+
+    *pllBOut = 0x80000401;  /* fixed at x4 for now */
+
+    VClk = (unsigned)clockIn;
+
+    for (P = 0; P <= 6; P++) {
+        Freq = VClk << P;
+        if ((Freq >= 400000) && (Freq <= 1000000)) {
+            for (M = 1; M <= 13; M++) {
+                N = ((VClk << P) * M) / (pNv->CrystalFreqKHz << 2);
+                if((N >= 5) && (N <= 255)) {
+                    Freq = (((pNv->CrystalFreqKHz << 2) * N) / M) >> P;
+                    if (Freq > VClk)
+                        DeltaNew = Freq - VClk;
+                    else
+                        DeltaNew = VClk - Freq;
+                    if (DeltaNew < DeltaOld) {
+                        *pllOut   = (P << 16) | (N << 8) | M;
+                        *clockOut = Freq;
+                        DeltaOld  = DeltaNew;
+                    }
+                }
+            }
+        }
+    }
+}
+
+/*
+ * Calculate extended mode parameters (SVGA) and save in a 
+ * mode state structure.
+ */
+void NVCalcStateExt (
+    NVPtr pNv,
+    RIVA_HW_STATE *state,
+    int            bpp,
+    int            width,
+    int            hDisplaySize,
+    int            height,
+    int            dotClock,
+    int		   flags 
+)
+{
+    int pixelDepth, VClk;
+    /*
+     * Save mode parameters.
+     */
+    state->bpp    = bpp;    /* this is not bitsPerPixel, it's 8,15,16,32 */
+    state->width  = width;
+    state->height = height;
+    /*
+     * Extended RIVA registers.
+     */
+    pixelDepth = (bpp + 1)/8;
+    if(pNv->twoStagePLL)
+        CalcVClock2Stage(dotClock, &VClk, &state->pll, &state->pllB, pNv);
+    else
+        CalcVClock(dotClock, &VClk, &state->pll, pNv);
+
+    switch (pNv->Architecture)
+    {
+        case NV_ARCH_04:
+            nv4UpdateArbitrationSettings(VClk, 
+                                         pixelDepth * 8, 
+                                        &(state->arbitration0),
+                                        &(state->arbitration1),
+                                         pNv);
+            state->cursor0  = 0x00;
+            state->cursor1  = 0xbC;
+	    if (flags & V_DBLSCAN)
+		state->cursor1 |= 2;
+            state->cursor2  = 0x00000000;
+            state->pllsel   = 0x10000700;
+            state->config   = 0x00001114;
+            state->general  = bpp == 16 ? 0x00101100 : 0x00100100;
+            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
+            break;
+        case NV_ARCH_10:
+        case NV_ARCH_20:
+        case NV_ARCH_30:
+        default:
+            if((pNv->Chipset & 0xfff0) == 0x0240) {
+                state->arbitration0 = 256; 
+                state->arbitration1 = 0x0480; 
+            } else
+            if(((pNv->Chipset & 0xffff) == 0x01A0) ||
+               ((pNv->Chipset & 0xffff) == 0x01f0))
+            {
+                nForceUpdateArbitrationSettings(VClk,
+                                          pixelDepth * 8,
+                                         &(state->arbitration0),
+                                         &(state->arbitration1),
+                                          pNv);
+            } else if(pNv->Architecture < NV_ARCH_30) {
+                nv10UpdateArbitrationSettings(VClk, 
+                                          pixelDepth * 8, 
+                                         &(state->arbitration0),
+                                         &(state->arbitration1),
+                                          pNv);
+            } else {
+                nv30UpdateArbitrationSettings(pNv,
+                                         &(state->arbitration0),
+                                         &(state->arbitration1));
+            }
+            state->cursor0  = 0x80 | (pNv->CursorStart >> 17);
+            state->cursor1  = (pNv->CursorStart >> 11) << 2;
+	    state->cursor2  = pNv->CursorStart >> 24;
+	    if (flags & V_DBLSCAN) 
+		state->cursor1 |= 2;
+            state->pllsel   = 0x10000700;
+            state->config   = pNv->PFB[0x00000200/4];
+            state->general  = bpp == 16 ? 0x00101100 : 0x00100100;
+            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
+            break;
+    }
+
+    if(bpp != 8) /* DirectColor */
+	state->general |= 0x00000030;
+
+    state->repaint0 = (((width / 8) * pixelDepth) & 0x700) >> 3;
+    state->pixel    = (pixelDepth > 2) ? 3 : pixelDepth;
+}
+
+
+void NVLoadStateExt (
+    NVPtr pNv,
+    RIVA_HW_STATE *state
+)
+{
+    int i, j;
+
+    pNv->PMC[0x0140/4] = 0x00000000;
+    pNv->PMC[0x0200/4] = 0xFFFF00FF;
+    pNv->PMC[0x0200/4] = 0xFFFFFFFF;
+
+    pNv->PTIMER[0x0200] = 0x00000008;
+    pNv->PTIMER[0x0210] = 0x00000003;
+    pNv->PTIMER[0x0140] = 0x00000000;
+    pNv->PTIMER[0x0100] = 0xFFFFFFFF;
+
+    if(pNv->Architecture == NV_ARCH_04) {
+        pNv->PFB[0x0200/4] = state->config;
+    } else 
+    if((pNv->Architecture < NV_ARCH_40) ||
+       ((pNv->Chipset & 0xfff0) == 0x0040))
+    {
+        for(i = 0; i < 8; i++) {
+           pNv->PFB[(0x0240 + (i * 0x10))/4] = 0;
+           pNv->PFB[(0x0244 + (i * 0x10))/4] = pNv->FbMapSize - 1;
+        }
+    } else {
+        int regions = 12;
+
+        if(((pNv->Chipset & 0xfff0) == 0x0090) ||
+           ((pNv->Chipset & 0xfff0) == 0x01D0) ||
+           ((pNv->Chipset & 0xfff0) == 0x0290) ||
+           ((pNv->Chipset & 0xfff0) == 0x0390))
+        {
+           regions = 15;
+        }
+ 
+       for(i = 0; i < regions; i++) {
+          pNv->PFB[(0x0600 + (i * 0x10))/4] = 0;
+          pNv->PFB[(0x0604 + (i * 0x10))/4] = pNv->FbMapSize - 1;
+       }
+    }
+
+    if(pNv->Architecture >= NV_ARCH_40) {
+       pNv->PRAMIN[0x0000] = 0x80000010;
+       pNv->PRAMIN[0x0001] = 0x00101202;
+       pNv->PRAMIN[0x0002] = 0x80000011;
+       pNv->PRAMIN[0x0003] = 0x00101204;
+       pNv->PRAMIN[0x0004] = 0x80000012;
+       pNv->PRAMIN[0x0005] = 0x00101206;
+       pNv->PRAMIN[0x0006] = 0x80000013;
+       pNv->PRAMIN[0x0007] = 0x00101208;
+       pNv->PRAMIN[0x0008] = 0x80000014;
+       pNv->PRAMIN[0x0009] = 0x0010120A;
+       pNv->PRAMIN[0x000A] = 0x80000015;
+       pNv->PRAMIN[0x000B] = 0x0010120C;
+       pNv->PRAMIN[0x000C] = 0x80000016;
+       pNv->PRAMIN[0x000D] = 0x0010120E;
+       pNv->PRAMIN[0x000E] = 0x80000017;
+       pNv->PRAMIN[0x000F] = 0x00101210;
+       pNv->PRAMIN[0x0800] = 0x00003000;
+       pNv->PRAMIN[0x0801] = pNv->FbMapSize - 1;
+       pNv->PRAMIN[0x0802] = 0x00000002;
+       pNv->PRAMIN[0x0808] = 0x02080062;
+       pNv->PRAMIN[0x0809] = 0x00000000;
+       pNv->PRAMIN[0x080A] = 0x00001200;
+       pNv->PRAMIN[0x080B] = 0x00001200;
+       pNv->PRAMIN[0x080C] = 0x00000000;
+       pNv->PRAMIN[0x080D] = 0x00000000;
+       pNv->PRAMIN[0x0810] = 0x02080043;
+       pNv->PRAMIN[0x0811] = 0x00000000;
+       pNv->PRAMIN[0x0812] = 0x00000000;
+       pNv->PRAMIN[0x0813] = 0x00000000;
+       pNv->PRAMIN[0x0814] = 0x00000000;
+       pNv->PRAMIN[0x0815] = 0x00000000;
+       pNv->PRAMIN[0x0818] = 0x02080044;
+       pNv->PRAMIN[0x0819] = 0x02000000;
+       pNv->PRAMIN[0x081A] = 0x00000000;
+       pNv->PRAMIN[0x081B] = 0x00000000;
+       pNv->PRAMIN[0x081C] = 0x00000000;
+       pNv->PRAMIN[0x081D] = 0x00000000;
+       pNv->PRAMIN[0x0820] = 0x02080019;
+       pNv->PRAMIN[0x0821] = 0x00000000;
+       pNv->PRAMIN[0x0822] = 0x00000000;
+       pNv->PRAMIN[0x0823] = 0x00000000;
+       pNv->PRAMIN[0x0824] = 0x00000000;
+       pNv->PRAMIN[0x0825] = 0x00000000;
+       pNv->PRAMIN[0x0828] = 0x020A005C;
+       pNv->PRAMIN[0x0829] = 0x00000000;
+       pNv->PRAMIN[0x082A] = 0x00000000;
+       pNv->PRAMIN[0x082B] = 0x00000000;
+       pNv->PRAMIN[0x082C] = 0x00000000;
+       pNv->PRAMIN[0x082D] = 0x00000000;
+       pNv->PRAMIN[0x0830] = 0x0208009F;
+       pNv->PRAMIN[0x0831] = 0x00000000;
+       pNv->PRAMIN[0x0832] = 0x00001200;
+       pNv->PRAMIN[0x0833] = 0x00001200;
+       pNv->PRAMIN[0x0834] = 0x00000000;
+       pNv->PRAMIN[0x0835] = 0x00000000;
+       pNv->PRAMIN[0x0838] = 0x0208004A;
+       pNv->PRAMIN[0x0839] = 0x02000000;
+       pNv->PRAMIN[0x083A] = 0x00000000;
+       pNv->PRAMIN[0x083B] = 0x00000000;
+       pNv->PRAMIN[0x083C] = 0x00000000;
+       pNv->PRAMIN[0x083D] = 0x00000000;
+       pNv->PRAMIN[0x0840] = 0x02080077;
+       pNv->PRAMIN[0x0841] = 0x00000000;
+       pNv->PRAMIN[0x0842] = 0x00001200;
+       pNv->PRAMIN[0x0843] = 0x00001200;
+       pNv->PRAMIN[0x0844] = 0x00000000;
+       pNv->PRAMIN[0x0845] = 0x00000000;
+       pNv->PRAMIN[0x084C] = 0x00003002;
+       pNv->PRAMIN[0x084D] = 0x00007FFF;
+       pNv->PRAMIN[0x084E] = pNv->FbUsableSize | 0x00000002;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+       pNv->PRAMIN[0x080A] |= 0x01000000;
+       pNv->PRAMIN[0x0812] |= 0x01000000;
+       pNv->PRAMIN[0x081A] |= 0x01000000;
+       pNv->PRAMIN[0x0822] |= 0x01000000;
+       pNv->PRAMIN[0x082A] |= 0x01000000;
+       pNv->PRAMIN[0x0832] |= 0x01000000;
+       pNv->PRAMIN[0x083A] |= 0x01000000;
+       pNv->PRAMIN[0x0842] |= 0x01000000;  
+       pNv->PRAMIN[0x0819] = 0x01000000;
+       pNv->PRAMIN[0x0839] = 0x01000000;
+#endif
+    } else {
+       pNv->PRAMIN[0x0000] = 0x80000010;
+       pNv->PRAMIN[0x0001] = 0x80011201;  
+       pNv->PRAMIN[0x0002] = 0x80000011;
+       pNv->PRAMIN[0x0003] = 0x80011202; 
+       pNv->PRAMIN[0x0004] = 0x80000012;
+       pNv->PRAMIN[0x0005] = 0x80011203;
+       pNv->PRAMIN[0x0006] = 0x80000013;
+       pNv->PRAMIN[0x0007] = 0x80011204;
+       pNv->PRAMIN[0x0008] = 0x80000014;
+       pNv->PRAMIN[0x0009] = 0x80011205;
+       pNv->PRAMIN[0x000A] = 0x80000015;
+       pNv->PRAMIN[0x000B] = 0x80011206;
+       pNv->PRAMIN[0x000C] = 0x80000016;
+       pNv->PRAMIN[0x000D] = 0x80011207;
+       pNv->PRAMIN[0x000E] = 0x80000017;
+       pNv->PRAMIN[0x000F] = 0x80011208;
+       pNv->PRAMIN[0x0800] = 0x00003000;
+       pNv->PRAMIN[0x0801] = pNv->FbMapSize - 1;
+       pNv->PRAMIN[0x0802] = 0x00000002;
+       pNv->PRAMIN[0x0803] = 0x00000002;
+       if(pNv->Architecture >= NV_ARCH_10)
+          pNv->PRAMIN[0x0804] = 0x01008062;
+       else
+          pNv->PRAMIN[0x0804] = 0x01008042;
+       pNv->PRAMIN[0x0805] = 0x00000000;
+       pNv->PRAMIN[0x0806] = 0x12001200;
+       pNv->PRAMIN[0x0807] = 0x00000000;
+       pNv->PRAMIN[0x0808] = 0x01008043;
+       pNv->PRAMIN[0x0809] = 0x00000000;
+       pNv->PRAMIN[0x080A] = 0x00000000;
+       pNv->PRAMIN[0x080B] = 0x00000000;
+       pNv->PRAMIN[0x080C] = 0x01008044;
+       pNv->PRAMIN[0x080D] = 0x00000002;
+       pNv->PRAMIN[0x080E] = 0x00000000;
+       pNv->PRAMIN[0x080F] = 0x00000000;
+       pNv->PRAMIN[0x0810] = 0x01008019;
+       pNv->PRAMIN[0x0811] = 0x00000000;
+       pNv->PRAMIN[0x0812] = 0x00000000;
+       pNv->PRAMIN[0x0813] = 0x00000000;
+       pNv->PRAMIN[0x0814] = 0x0100A05C;
+       pNv->PRAMIN[0x0815] = 0x00000000;
+       pNv->PRAMIN[0x0816] = 0x00000000;
+       pNv->PRAMIN[0x0817] = 0x00000000;
+       if(pNv->WaitVSyncPossible)
+          pNv->PRAMIN[0x0818] = 0x0100809F;
+       else
+          pNv->PRAMIN[0x0818] = 0x0100805F;
+       pNv->PRAMIN[0x0819] = 0x00000000;
+       pNv->PRAMIN[0x081A] = 0x12001200;
+       pNv->PRAMIN[0x081B] = 0x00000000;
+       pNv->PRAMIN[0x081C] = 0x0100804A;
+       pNv->PRAMIN[0x081D] = 0x00000002;
+       pNv->PRAMIN[0x081E] = 0x00000000;
+       pNv->PRAMIN[0x081F] = 0x00000000;
+       pNv->PRAMIN[0x0820] = 0x01018077;
+       pNv->PRAMIN[0x0821] = 0x00000000;
+       pNv->PRAMIN[0x0822] = 0x12001200;
+       pNv->PRAMIN[0x0823] = 0x00000000;
+       pNv->PRAMIN[0x0824] = 0x00003002;
+       pNv->PRAMIN[0x0825] = 0x00007FFF;
+       pNv->PRAMIN[0x0826] = pNv->FbUsableSize | 0x00000002;
+       pNv->PRAMIN[0x0827] = 0x00000002;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+       pNv->PRAMIN[0x0804] |= 0x00080000;
+       pNv->PRAMIN[0x0808] |= 0x00080000;
+       pNv->PRAMIN[0x080C] |= 0x00080000;
+       pNv->PRAMIN[0x0810] |= 0x00080000;
+       pNv->PRAMIN[0x0814] |= 0x00080000;
+       pNv->PRAMIN[0x0818] |= 0x00080000;
+       pNv->PRAMIN[0x081C] |= 0x00080000;
+       pNv->PRAMIN[0x0820] |= 0x00080000;
+       pNv->PRAMIN[0x080D] = 0x00000001;
+       pNv->PRAMIN[0x081D] = 0x00000001;
+#endif
+    }
+
+    if(pNv->Architecture < NV_ARCH_10) {
+       if((pNv->Chipset & 0x0fff) == 0x0020) {
+           pNv->PRAMIN[0x0824] |= 0x00020000;
+           pNv->PRAMIN[0x0826] += pNv->FbAddress;
+       }
+       pNv->PGRAPH[0x0080/4] = 0x000001FF;
+       pNv->PGRAPH[0x0080/4] = 0x1230C000;
+       pNv->PGRAPH[0x0084/4] = 0x72111101;
+       pNv->PGRAPH[0x0088/4] = 0x11D5F071;
+       pNv->PGRAPH[0x008C/4] = 0x0004FF31;
+       pNv->PGRAPH[0x008C/4] = 0x4004FF31;
+
+       pNv->PGRAPH[0x0140/4] = 0x00000000;
+       pNv->PGRAPH[0x0100/4] = 0xFFFFFFFF;
+       pNv->PGRAPH[0x0170/4] = 0x10010100;
+       pNv->PGRAPH[0x0710/4] = 0xFFFFFFFF;
+       pNv->PGRAPH[0x0720/4] = 0x00000001;
+
+       pNv->PGRAPH[0x0810/4] = 0x00000000;
+       pNv->PGRAPH[0x0608/4] = 0xFFFFFFFF; 
+    } else {
+       pNv->PGRAPH[0x0080/4] = 0xFFFFFFFF;
+       pNv->PGRAPH[0x0080/4] = 0x00000000;
+
+       pNv->PGRAPH[0x0140/4] = 0x00000000;
+       pNv->PGRAPH[0x0100/4] = 0xFFFFFFFF;
+       pNv->PGRAPH[0x0144/4] = 0x10010100;
+       pNv->PGRAPH[0x0714/4] = 0xFFFFFFFF;
+       pNv->PGRAPH[0x0720/4] = 0x00000001;
+       pNv->PGRAPH[0x0710/4] &= 0x0007ff00;
+       pNv->PGRAPH[0x0710/4] |= 0x00020100;
+
+       if(pNv->Architecture == NV_ARCH_10) {
+           pNv->PGRAPH[0x0084/4] = 0x00118700;
+           pNv->PGRAPH[0x0088/4] = 0x24E00810;
+           pNv->PGRAPH[0x008C/4] = 0x55DE0030;
+
+           for(i = 0; i < 32; i++)
+             pNv->PGRAPH[(0x0B00/4) + i] = pNv->PFB[(0x0240/4) + i];
+
+           pNv->PGRAPH[0x640/4] = 0;
+           pNv->PGRAPH[0x644/4] = 0;
+           pNv->PGRAPH[0x684/4] = pNv->FbMapSize - 1;
+           pNv->PGRAPH[0x688/4] = pNv->FbMapSize - 1;
+
+           pNv->PGRAPH[0x0810/4] = 0x00000000;
+           pNv->PGRAPH[0x0608/4] = 0xFFFFFFFF;
+       } else {
+           if(pNv->Architecture >= NV_ARCH_40) {
+              pNv->PGRAPH[0x0084/4] = 0x401287c0;
+              pNv->PGRAPH[0x008C/4] = 0x60de8051;
+              pNv->PGRAPH[0x0090/4] = 0x00008000;
+              pNv->PGRAPH[0x0610/4] = 0x00be3c5f;
+
+              j = pNv->REGS[0x1540/4] & 0xff;
+              if(j) {
+                  for(i = 0; !(j & 1); j >>= 1, i++);
+                  pNv->PGRAPH[0x5000/4] = i;
+              }
+
+              if((pNv->Chipset & 0xfff0) == 0x0040) {
+                 pNv->PGRAPH[0x09b0/4] = 0x83280fff;
+                 pNv->PGRAPH[0x09b4/4] = 0x000000a0;
+              } else {
+                 pNv->PGRAPH[0x0820/4] = 0x83280eff;
+                 pNv->PGRAPH[0x0824/4] = 0x000000a0;
+              }
+
+              switch(pNv->Chipset & 0xfff0) {
+              case 0x0040:
+              case 0x0210:
+                 pNv->PGRAPH[0x09b8/4] = 0x0078e366;
+                 pNv->PGRAPH[0x09bc/4] = 0x0000014c;
+                 pNv->PFB[0x033C/4] &= 0xffff7fff;
+                 break;
+              case 0x00C0:
+              case 0x0120:
+                 pNv->PGRAPH[0x0828/4] = 0x007596ff;
+                 pNv->PGRAPH[0x082C/4] = 0x00000108;
+                 break;
+              case 0x0160:
+              case 0x01D0:
+              case 0x0240:
+                 pNv->PMC[0x1700/4] = pNv->PFB[0x020C/4];
+                 pNv->PMC[0x1704/4] = 0;
+                 pNv->PMC[0x1708/4] = 0;
+                 pNv->PMC[0x170C/4] = pNv->PFB[0x020C/4];
+                 pNv->PGRAPH[0x0860/4] = 0;
+                 pNv->PGRAPH[0x0864/4] = 0;
+                 pNv->PRAMDAC[0x0608/4] |= 0x00100000;
+                 break;
+              case 0x0140:
+                 pNv->PGRAPH[0x0828/4] = 0x0072cb77;
+                 pNv->PGRAPH[0x082C/4] = 0x00000108;
+                 break;
+              case 0x0220:
+                 pNv->PGRAPH[0x0860/4] = 0;
+                 pNv->PGRAPH[0x0864/4] = 0;
+                 pNv->PRAMDAC[0x0608/4] |= 0x00100000;
+                 break;
+              case 0x0090:
+              case 0x0290:
+              case 0x0390:
+                 pNv->PRAMDAC[0x0608/4] |= 0x00100000;
+                 pNv->PGRAPH[0x0828/4] = 0x07830610;
+                 pNv->PGRAPH[0x082C/4] = 0x0000016A;
+                 break;
+              default:
+                 break;
+              };
+
+              pNv->PGRAPH[0x0b38/4] = 0x2ffff800;
+              pNv->PGRAPH[0x0b3c/4] = 0x00006000;
+              pNv->PGRAPH[0x032C/4] = 0x01000000; 
+              pNv->PGRAPH[0x0220/4] = 0x00001200;
+           } else
+           if(pNv->Architecture == NV_ARCH_30) {
+              pNv->PGRAPH[0x0084/4] = 0x40108700;
+              pNv->PGRAPH[0x0890/4] = 0x00140000;
+              pNv->PGRAPH[0x008C/4] = 0xf00e0431;
+              pNv->PGRAPH[0x0090/4] = 0x00008000;
+              pNv->PGRAPH[0x0610/4] = 0xf04b1f36;
+              pNv->PGRAPH[0x0B80/4] = 0x1002d888;
+              pNv->PGRAPH[0x0B88/4] = 0x62ff007f;
+           } else {
+              pNv->PGRAPH[0x0084/4] = 0x00118700;
+              pNv->PGRAPH[0x008C/4] = 0xF20E0431;
+              pNv->PGRAPH[0x0090/4] = 0x00000000;
+              pNv->PGRAPH[0x009C/4] = 0x00000040;
+
+              if((pNv->Chipset & 0x0ff0) >= 0x0250) {
+                 pNv->PGRAPH[0x0890/4] = 0x00080000;
+                 pNv->PGRAPH[0x0610/4] = 0x304B1FB6; 
+                 pNv->PGRAPH[0x0B80/4] = 0x18B82880; 
+                 pNv->PGRAPH[0x0B84/4] = 0x44000000; 
+                 pNv->PGRAPH[0x0098/4] = 0x40000080; 
+                 pNv->PGRAPH[0x0B88/4] = 0x000000ff; 
+              } else {
+                 pNv->PGRAPH[0x0880/4] = 0x00080000;
+                 pNv->PGRAPH[0x0094/4] = 0x00000005;
+                 pNv->PGRAPH[0x0B80/4] = 0x45CAA208; 
+                 pNv->PGRAPH[0x0B84/4] = 0x24000000;
+                 pNv->PGRAPH[0x0098/4] = 0x00000040;
+                 pNv->PGRAPH[0x0750/4] = 0x00E00038;
+                 pNv->PGRAPH[0x0754/4] = 0x00000030;
+                 pNv->PGRAPH[0x0750/4] = 0x00E10038;
+                 pNv->PGRAPH[0x0754/4] = 0x00000030;
+              }
+           }
+
+           if((pNv->Architecture < NV_ARCH_40) ||
+              ((pNv->Chipset & 0xfff0) == 0x0040)) 
+           {
+              for(i = 0; i < 32; i++) {
+                pNv->PGRAPH[(0x0900/4) + i] = pNv->PFB[(0x0240/4) + i];
+                pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0240/4) + i];
+              }
+           } else {
+              if(((pNv->Chipset & 0xfff0) == 0x0090) ||
+                 ((pNv->Chipset & 0xfff0) == 0x01D0) ||
+                 ((pNv->Chipset & 0xfff0) == 0x0290) ||
+                 ((pNv->Chipset & 0xfff0) == 0x0390))
+              {
+                 for(i = 0; i < 60; i++) {
+                   pNv->PGRAPH[(0x0D00/4) + i] = pNv->PFB[(0x0600/4) + i];
+                   pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0600/4) + i];
+                 }
+              } else {
+                 for(i = 0; i < 48; i++) {
+                   pNv->PGRAPH[(0x0900/4) + i] = pNv->PFB[(0x0600/4) + i];
+                   if(((pNv->Chipset & 0xfff0) != 0x0160) &&
+                      ((pNv->Chipset & 0xfff0) != 0x0220) &&
+                      ((pNv->Chipset & 0xfff0) != 0x0240))
+                   {
+                      pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0600/4) + i];
+                   }
+                 }
+              }
+           }
+
+           if(pNv->Architecture >= NV_ARCH_40) {
+              if((pNv->Chipset & 0xfff0) == 0x0040) {
+                 pNv->PGRAPH[0x09A4/4] = pNv->PFB[0x0200/4];
+                 pNv->PGRAPH[0x09A8/4] = pNv->PFB[0x0204/4];
+                 pNv->PGRAPH[0x69A4/4] = pNv->PFB[0x0200/4];
+                 pNv->PGRAPH[0x69A8/4] = pNv->PFB[0x0204/4];
+
+                 pNv->PGRAPH[0x0820/4] = 0;
+                 pNv->PGRAPH[0x0824/4] = 0;
+                 pNv->PGRAPH[0x0864/4] = pNv->FbMapSize - 1;
+                 pNv->PGRAPH[0x0868/4] = pNv->FbMapSize - 1;
+              } else {
+                 if(((pNv->Chipset & 0xfff0) == 0x0090) ||
+                    ((pNv->Chipset & 0xfff0) == 0x01D0) ||
+                    ((pNv->Chipset & 0xfff0) == 0x0290) ||
+                    ((pNv->Chipset & 0xfff0) == 0x0390)) 
+                 {
+                    pNv->PGRAPH[0x0DF0/4] = pNv->PFB[0x0200/4];
+                    pNv->PGRAPH[0x0DF4/4] = pNv->PFB[0x0204/4];
+                 } else {
+                    pNv->PGRAPH[0x09F0/4] = pNv->PFB[0x0200/4];
+                    pNv->PGRAPH[0x09F4/4] = pNv->PFB[0x0204/4];
+                 }
+                 pNv->PGRAPH[0x69F0/4] = pNv->PFB[0x0200/4];
+                 pNv->PGRAPH[0x69F4/4] = pNv->PFB[0x0204/4];
+
+                 pNv->PGRAPH[0x0840/4] = 0;
+                 pNv->PGRAPH[0x0844/4] = 0;
+                 pNv->PGRAPH[0x08a0/4] = pNv->FbMapSize - 1;
+                 pNv->PGRAPH[0x08a4/4] = pNv->FbMapSize - 1;
+              }
+           } else {
+              pNv->PGRAPH[0x09A4/4] = pNv->PFB[0x0200/4];
+              pNv->PGRAPH[0x09A8/4] = pNv->PFB[0x0204/4];
+              pNv->PGRAPH[0x0750/4] = 0x00EA0000;
+              pNv->PGRAPH[0x0754/4] = pNv->PFB[0x0200/4];
+              pNv->PGRAPH[0x0750/4] = 0x00EA0004;
+              pNv->PGRAPH[0x0754/4] = pNv->PFB[0x0204/4];
+
+              pNv->PGRAPH[0x0820/4] = 0;
+              pNv->PGRAPH[0x0824/4] = 0;
+              pNv->PGRAPH[0x0864/4] = pNv->FbMapSize - 1;
+              pNv->PGRAPH[0x0868/4] = pNv->FbMapSize - 1;
+           }
+
+           pNv->PGRAPH[0x0B20/4] = 0x00000000;
+           pNv->PGRAPH[0x0B04/4] = 0xFFFFFFFF;
+       }
+    }
+    pNv->PGRAPH[0x053C/4] = 0;
+    pNv->PGRAPH[0x0540/4] = 0;
+    pNv->PGRAPH[0x0544/4] = 0x00007FFF;
+    pNv->PGRAPH[0x0548/4] = 0x00007FFF;
+
+    pNv->PFIFO[0x0140] = 0x00000000;
+    pNv->PFIFO[0x0141] = 0x00000001;
+    pNv->PFIFO[0x0480] = 0x00000000;
+    pNv->PFIFO[0x0494] = 0x00000000;
+    if(pNv->Architecture >= NV_ARCH_40)
+       pNv->PFIFO[0x0481] = 0x00010000;
+    else
+       pNv->PFIFO[0x0481] = 0x00000100;
+    pNv->PFIFO[0x0490] = 0x00000000;
+    pNv->PFIFO[0x0491] = 0x00000000;
+    if(pNv->Architecture >= NV_ARCH_40)
+       pNv->PFIFO[0x048B] = 0x00001213;
+    else
+       pNv->PFIFO[0x048B] = 0x00001209;
+    pNv->PFIFO[0x0400] = 0x00000000;
+    pNv->PFIFO[0x0414] = 0x00000000;
+    pNv->PFIFO[0x0084] = 0x03000100;
+    pNv->PFIFO[0x0085] = 0x00000110;
+    pNv->PFIFO[0x0086] = 0x00000112;
+    pNv->PFIFO[0x0143] = 0x0000FFFF;
+    pNv->PFIFO[0x0496] = 0x0000FFFF;
+    pNv->PFIFO[0x0050] = 0x00000000;
+    pNv->PFIFO[0x0040] = 0xFFFFFFFF;
+    pNv->PFIFO[0x0415] = 0x00000001;
+    pNv->PFIFO[0x048C] = 0x00000000;
+    pNv->PFIFO[0x04A0] = 0x00000000;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+    pNv->PFIFO[0x0489] = 0x800F0078;
+#else
+    pNv->PFIFO[0x0489] = 0x000F0078;
+#endif
+    pNv->PFIFO[0x0488] = 0x00000001;
+    pNv->PFIFO[0x0480] = 0x00000001;
+    pNv->PFIFO[0x0494] = 0x00000001;
+    pNv->PFIFO[0x0495] = 0x00000001;
+    pNv->PFIFO[0x0140] = 0x00000001;
+
+    if(pNv->Architecture >= NV_ARCH_10) {
+        if(pNv->twoHeads) {
+           pNv->PCRTC0[0x0860/4] = state->head;
+           pNv->PCRTC0[0x2860/4] = state->head2;
+        }
+        pNv->PRAMDAC[0x0404/4] |= (1 << 25);
+    
+        pNv->PMC[0x8704/4] = 1;
+        pNv->PMC[0x8140/4] = 0;
+        pNv->PMC[0x8920/4] = 0;
+        pNv->PMC[0x8924/4] = 0;
+        pNv->PMC[0x8908/4] = pNv->FbMapSize - 1;
+        pNv->PMC[0x890C/4] = pNv->FbMapSize - 1;
+        pNv->PMC[0x1588/4] = 0;
+
+        pNv->PCRTC[0x0810/4] = state->cursorConfig;
+        pNv->PCRTC[0x0830/4] = state->displayV - 3;
+        pNv->PCRTC[0x0834/4] = state->displayV - 1;
+    
+        if(pNv->FlatPanel) {
+           if((pNv->Chipset & 0x0ff0) == 0x0110) {
+               pNv->PRAMDAC[0x0528/4] = state->dither;
+           } else 
+           if(pNv->twoHeads) {
+               pNv->PRAMDAC[0x083C/4] = state->dither;
+           }
+    
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x53);
+           VGA_WR08(pNv->PCIO, 0x03D5, state->timingH);
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x54);
+           VGA_WR08(pNv->PCIO, 0x03D5, state->timingV);
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x21);
+           VGA_WR08(pNv->PCIO, 0x03D5, 0xfa);
+        }
+
+        VGA_WR08(pNv->PCIO, 0x03D4, 0x41);
+        VGA_WR08(pNv->PCIO, 0x03D5, state->extra);
+    }
+
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x19);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->repaint0);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x1A);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->repaint1);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x25);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->screen);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x28);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->pixel);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x2D);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->horiz);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x1C);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->fifo);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x1B);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->arbitration0);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x20);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->arbitration1);
+    if(pNv->Architecture >= NV_ARCH_30) {
+      VGA_WR08(pNv->PCIO, 0x03D4, 0x47);
+      VGA_WR08(pNv->PCIO, 0x03D5, state->arbitration1 >> 8);
+    }
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x30);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->cursor0);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x31);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->cursor1);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x2F);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->cursor2);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x39);
+    VGA_WR08(pNv->PCIO, 0x03D5, state->interlace);
+
+    if(!pNv->FlatPanel) {
+       pNv->PRAMDAC0[0x050C/4] = state->pllsel;
+       pNv->PRAMDAC0[0x0508/4] = state->vpll;
+       if(pNv->twoHeads)
+          pNv->PRAMDAC0[0x0520/4] = state->vpll2;
+       if(pNv->twoStagePLL) {
+          pNv->PRAMDAC0[0x0578/4] = state->vpllB;
+          pNv->PRAMDAC0[0x057C/4] = state->vpll2B;
+       }
+    } else {
+       pNv->PRAMDAC[0x0848/4] = state->scale;
+       pNv->PRAMDAC[0x0828/4] = state->crtcSync;
+    }
+    pNv->PRAMDAC[0x0600/4] = state->general;
+
+    pNv->PCRTC[0x0140/4] = 0;
+    pNv->PCRTC[0x0100/4] = 1;
+
+    pNv->CurrentState = state;
+}
+
+void NVUnloadStateExt
+(
+    NVPtr pNv,
+    RIVA_HW_STATE *state
+)
+{
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x19);
+    state->repaint0     = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x1A);
+    state->repaint1     = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x25);
+    state->screen       = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x28);
+    state->pixel        = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x2D);
+    state->horiz        = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x1C);
+    state->fifo         = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x1B);
+    state->arbitration0 = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x20);
+    state->arbitration1 = VGA_RD08(pNv->PCIO, 0x03D5);
+    if(pNv->Architecture >= NV_ARCH_30) {
+       VGA_WR08(pNv->PCIO, 0x03D4, 0x47);
+       state->arbitration1 |= (VGA_RD08(pNv->PCIO, 0x03D5) & 1) << 8;
+    }
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x30);
+    state->cursor0      = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x31);
+    state->cursor1      = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x2F);
+    state->cursor2      = VGA_RD08(pNv->PCIO, 0x03D5);
+    VGA_WR08(pNv->PCIO, 0x03D4, 0x39);
+    state->interlace    = VGA_RD08(pNv->PCIO, 0x03D5);
+    state->vpll         = pNv->PRAMDAC0[0x0508/4];
+    if(pNv->twoHeads)
+       state->vpll2     = pNv->PRAMDAC0[0x0520/4];
+    if(pNv->twoStagePLL) {
+        state->vpllB    = pNv->PRAMDAC0[0x0578/4];
+        state->vpll2B   = pNv->PRAMDAC0[0x057C/4];
+    }
+    state->pllsel       = pNv->PRAMDAC0[0x050C/4];
+    state->general      = pNv->PRAMDAC[0x0600/4];
+    state->scale        = pNv->PRAMDAC[0x0848/4];
+    state->config       = pNv->PFB[0x0200/4];
+
+    if(pNv->Architecture >= NV_ARCH_10) {
+        if(pNv->twoHeads) {
+           state->head     = pNv->PCRTC0[0x0860/4];
+           state->head2    = pNv->PCRTC0[0x2860/4];
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+           state->crtcOwner = VGA_RD08(pNv->PCIO, 0x03D5);
+        }
+        VGA_WR08(pNv->PCIO, 0x03D4, 0x41);
+        state->extra = VGA_RD08(pNv->PCIO, 0x03D5);
+        state->cursorConfig = pNv->PCRTC[0x0810/4];
+
+        if((pNv->Chipset & 0x0ff0) == 0x0110) {
+           state->dither = pNv->PRAMDAC[0x0528/4];
+        } else 
+        if(pNv->twoHeads) {
+            state->dither = pNv->PRAMDAC[0x083C/4];
+        }
+
+        if(pNv->FlatPanel) {
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x53);
+           state->timingH = VGA_RD08(pNv->PCIO, 0x03D5);
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x54);
+           state->timingV = VGA_RD08(pNv->PCIO, 0x03D5);
+        }
+    }
+
+    if(pNv->FlatPanel) {
+       state->crtcSync = pNv->PRAMDAC[0x0828/4];
+    }
+}
+
+void NVSetStartAddress (
+    NVPtr   pNv,
+    CARD32 start
+)
+{
+    pNv->PCRTC[0x800/4] = start;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,63 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h,v 1.9 2000/10/06 12:31:03 eich Exp $ */
+
+#ifndef __NV_INCLUDE_H__
+#define __NV_INCLUDE_H__
+
+/* All drivers should typically include these */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86_ansic.h"
+#include "compiler.h"
+
+/* Drivers for PCI hardware need this */
+#include "xf86PciInfo.h"
+
+/* Drivers that need to access the PCI config space directly need this */
+#include "xf86Pci.h"
+
+/* All drivers initialising the SW cursor need this */
+#include "mipointer.h"
+
+/* All drivers implementing backing store need this */
+#include "mibstore.h"
+
+#include "micmap.h"
+
+#include "xf86DDC.h"
+
+#include "vbe.h"
+
+#include "xf86RAC.h"
+
+#include "nv_const.h"
+
+#include "dixstruct.h"
+#include "scrnintstr.h"
+
+#include "fb.h"
+
+#include "xaa.h"
+#include "xf86cmap.h"
+#include "shadowfb.h"
+#include "fbdevhw.h"
+
+#include "xf86xv.h"
+#include <X11/extensions/Xv.h>
+
+#include "vgaHW.h"
+
+#include "xf86Cursor.h"
+#include "xf86DDC.h"
+
+#include "region.h"
+
+#ifdef RANDR
+#include <X11/extensions/randr.h>
+#endif
+
+#include "nv_local.h"
+#include "nv_type.h"
+#include "nv_proto.h"
+
+#endif /* __NV_INCLUDE_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,730 @@
+ /***************************************************************************\
+|*                                                                           *|
+|*       Copyright 2003 NVIDIA, Corporation.  All rights reserved.           *|
+|*                                                                           *|
+|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
+|*     international laws.  Users and possessors of this source code are     *|
+|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
+|*     use this code in individual and commercial software.                  *|
+|*                                                                           *|
+|*     Any use of this source code must include,  in the user documenta-     *|
+|*     tion and  internal comments to the code,  notices to the end user     *|
+|*     as follows:                                                           *|
+|*                                                                           *|
+|*       Copyright 2003 NVIDIA, Corporation.  All rights reserved.           *|
+|*                                                                           *|
+|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
+|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
+|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
+|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
+|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
+|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
+|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
+|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
+|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
+|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
+|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
+|*                                                                           *|
+|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
+|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
+|*     consisting  of "commercial  computer  software"  and  "commercial     *|
+|*     computer  software  documentation,"  as such  terms  are  used in     *|
+|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
+|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
+|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
+|*     all U.S. Government End Users  acquire the source code  with only     *|
+|*     those rights set forth herein.                                        *|
+|*                                                                           *|
+ \***************************************************************************/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.48 2005/09/14 02:28:03 mvojkovi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "nv_include.h"
+
+/*
+ * Override VGA I/O routines.
+ */
+static void NVWriteCrtc(vgaHWPtr pVga, CARD8 index, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PCIO, pVga->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+    VGA_WR08(pNv->PCIO, pVga->IOBase + VGA_CRTC_DATA_OFFSET,  value);
+}
+static CARD8 NVReadCrtc(vgaHWPtr pVga, CARD8 index)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PCIO, pVga->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+    return (VGA_RD08(pNv->PCIO, pVga->IOBase + VGA_CRTC_DATA_OFFSET));
+}
+static void NVWriteGr(vgaHWPtr pVga, CARD8 index, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PVIO, VGA_GRAPH_INDEX, index);
+    VGA_WR08(pNv->PVIO, VGA_GRAPH_DATA,  value);
+}
+static CARD8 NVReadGr(vgaHWPtr pVga, CARD8 index)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PVIO, VGA_GRAPH_INDEX, index);
+    return (VGA_RD08(pNv->PVIO, VGA_GRAPH_DATA));
+}
+static void NVWriteSeq(vgaHWPtr pVga, CARD8 index, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PVIO, VGA_SEQ_INDEX, index);
+    VGA_WR08(pNv->PVIO, VGA_SEQ_DATA,  value);
+}
+static CARD8 NVReadSeq(vgaHWPtr pVga, CARD8 index)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PVIO, VGA_SEQ_INDEX, index);
+    return (VGA_RD08(pNv->PVIO, VGA_SEQ_DATA));
+}
+static void NVWriteAttr(vgaHWPtr pVga, CARD8 index, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    volatile CARD8 tmp;
+
+    tmp = VGA_RD08(pNv->PCIO, pVga->IOBase + VGA_IN_STAT_1_OFFSET);
+    if (pVga->paletteEnabled)
+        index &= ~0x20;
+    else
+        index |= 0x20;
+    VGA_WR08(pNv->PCIO, VGA_ATTR_INDEX,  index);
+    VGA_WR08(pNv->PCIO, VGA_ATTR_DATA_W, value);
+}
+static CARD8 NVReadAttr(vgaHWPtr pVga, CARD8 index)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    volatile CARD8 tmp;
+
+    tmp = VGA_RD08(pNv->PCIO, pVga->IOBase + VGA_IN_STAT_1_OFFSET);
+    if (pVga->paletteEnabled)
+        index &= ~0x20;
+    else
+        index |= 0x20;
+    VGA_WR08(pNv->PCIO, VGA_ATTR_INDEX, index);
+    return (VGA_RD08(pNv->PCIO, VGA_ATTR_DATA_R));
+}
+static void NVWriteMiscOut(vgaHWPtr pVga, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PVIO, VGA_MISC_OUT_W, value);
+}
+static CARD8 NVReadMiscOut(vgaHWPtr pVga)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    return (VGA_RD08(pNv->PVIO, VGA_MISC_OUT_R));
+}
+static void NVEnablePalette(vgaHWPtr pVga)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    volatile CARD8 tmp;
+
+    tmp = VGA_RD08(pNv->PCIO, pVga->IOBase + VGA_IN_STAT_1_OFFSET);
+    VGA_WR08(pNv->PCIO, VGA_ATTR_INDEX, 0x00);
+    pVga->paletteEnabled = TRUE;
+}
+static void NVDisablePalette(vgaHWPtr pVga)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    volatile CARD8 tmp;
+
+    tmp = VGA_RD08(pNv->PCIO, pVga->IOBase + VGA_IN_STAT_1_OFFSET);
+    VGA_WR08(pNv->PCIO, VGA_ATTR_INDEX, 0x20);
+    pVga->paletteEnabled = FALSE;
+}
+static void NVWriteDacMask(vgaHWPtr pVga, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PDIO, VGA_DAC_MASK, value);
+}
+static CARD8 NVReadDacMask(vgaHWPtr pVga)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    return (VGA_RD08(pNv->PDIO, VGA_DAC_MASK));
+}
+static void NVWriteDacReadAddr(vgaHWPtr pVga, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PDIO, VGA_DAC_READ_ADDR, value);
+}
+static void NVWriteDacWriteAddr(vgaHWPtr pVga, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PDIO, VGA_DAC_WRITE_ADDR, value);
+}
+static void NVWriteDacData(vgaHWPtr pVga, CARD8 value)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    VGA_WR08(pNv->PDIO, VGA_DAC_DATA, value);
+}
+static CARD8 NVReadDacData(vgaHWPtr pVga)
+{
+    NVPtr pNv = (NVPtr)pVga->MMIOBase;
+    return (VGA_RD08(pNv->PDIO, VGA_DAC_DATA));
+}
+
+static Bool 
+NVIsConnected (ScrnInfoPtr pScrn, int output)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    volatile U032 *PRAMDAC = pNv->PRAMDAC0;
+    CARD32 reg52C, reg608;
+    Bool present;
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+               "Probing for analog device on output %s...\n", 
+                output ? "B" : "A");
+
+    if(output) PRAMDAC += 0x800;
+
+    reg52C = PRAMDAC[0x052C/4];
+    reg608 = PRAMDAC[0x0608/4];
+
+    PRAMDAC[0x0608/4] = reg608 & ~0x00010000;
+
+    PRAMDAC[0x052C/4] = reg52C & 0x0000FEEE;
+    usleep(1000);
+    PRAMDAC[0x052C/4] |= 1;
+
+    pNv->PRAMDAC0[0x0610/4] = 0x94050140;
+    pNv->PRAMDAC0[0x0608/4] |= 0x00001000;
+
+    usleep(1000);
+
+    present = (PRAMDAC[0x0608/4] & (1 << 28)) ? TRUE : FALSE;
+
+    if(present)
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "  ...found one\n");
+    else
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "  ...can't find one\n");
+
+    pNv->PRAMDAC0[0x0608/4] &= 0x0000EFFF;
+
+    PRAMDAC[0x052C/4] = reg52C;
+    PRAMDAC[0x0608/4] = reg608;
+
+    return present;
+}
+
+static void
+NVSelectHeadRegisters(ScrnInfoPtr pScrn, int head)
+{
+    NVPtr pNv = NVPTR(pScrn);
+
+    if(head) {
+       pNv->PCIO = pNv->PCIO0 + 0x2000;
+       pNv->PCRTC = pNv->PCRTC0 + 0x800;
+       pNv->PRAMDAC = pNv->PRAMDAC0 + 0x800;
+       pNv->PDIO = pNv->PDIO0 + 0x2000;
+    } else {
+       pNv->PCIO = pNv->PCIO0;
+       pNv->PCRTC = pNv->PCRTC0;
+       pNv->PRAMDAC = pNv->PRAMDAC0;
+       pNv->PDIO = pNv->PDIO0;
+    }
+}
+
+static xf86MonPtr 
+NVProbeDDC (ScrnInfoPtr pScrn, int bus)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    xf86MonPtr MonInfo = NULL;
+
+    if(!pNv->I2C) return NULL;
+
+    pNv->DDCBase = bus ? 0x36 : 0x3e;
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
+               "Probing for EDID on I2C bus %s...\n", bus ? "B" : "A");
+
+    if ((MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pNv->I2C))) {
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                  "DDC detected a %s:\n", MonInfo->features.input_type ?
+                  "DFP" : "CRT");
+       xf86PrintEDID( MonInfo );
+    } else {
+       xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
+                  "  ... none found\n");
+    }
+
+    return MonInfo;
+}
+
+static void nv4GetConfig (NVPtr pNv)
+{
+    if (pNv->PFB[0x0000/4] & 0x00000100) {
+        pNv->RamAmountKBytes = ((pNv->PFB[0x0000/4] >> 12) & 0x0F) * 1024 * 2
+                              + 1024 * 2;
+    } else {
+        switch (pNv->PFB[0x0000/4] & 0x00000003) {
+        case 0:
+            pNv->RamAmountKBytes = 1024 * 32;
+            break;
+        case 1:
+            pNv->RamAmountKBytes = 1024 * 4;
+            break;
+        case 2:
+            pNv->RamAmountKBytes = 1024 * 8;
+            break;
+        case 3:
+        default:
+            pNv->RamAmountKBytes = 1024 * 16;
+            break;
+        }
+    }
+    pNv->CrystalFreqKHz = (pNv->PEXTDEV[0x0000/4] & 0x00000040) ? 14318 : 13500;
+    pNv->CURSOR         = &(pNv->PRAMIN[0x1E00]);
+    pNv->MinVClockFreqKHz = 12000;
+    pNv->MaxVClockFreqKHz = 350000;
+}
+
+static void nv10GetConfig (NVPtr pNv)
+{
+    CARD32 implementation = pNv->Chipset & 0x0ff0;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+    /* turn on big endian register access */
+    if(!(pNv->PMC[0x0004/4] & 0x01000001)) {
+       pNv->PMC[0x0004/4] = 0x01000001;
+       mem_barrier();
+    }
+#endif
+
+    if(implementation == 0x01a0) {
+        int amt = pciReadLong(pciTag(0, 0, 1), 0x7C);
+        pNv->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024;
+    } else if(implementation == 0x01f0) {
+        int amt = pciReadLong(pciTag(0, 0, 1), 0x84);
+        pNv->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024;
+    } else {
+        pNv->RamAmountKBytes = (pNv->PFB[0x020C/4] & 0xFFF00000) >> 10;
+    }
+
+    if(pNv->RamAmountKBytes > 256*1024)
+        pNv->RamAmountKBytes = 256*1024;
+
+    pNv->CrystalFreqKHz = (pNv->PEXTDEV[0x0000/4] & (1 << 6)) ? 14318 : 13500;
+    
+    if(pNv->twoHeads && (implementation != 0x0110))
+    {
+       if(pNv->PEXTDEV[0x0000/4] & (1 << 22))
+           pNv->CrystalFreqKHz = 27000;
+    }
+
+    pNv->CURSOR           = NULL;  /* can't set this here */
+    pNv->MinVClockFreqKHz = 12000;
+    pNv->MaxVClockFreqKHz = pNv->twoStagePLL ? 400000 : 350000;
+}
+
+
+void
+NVCommonSetup(ScrnInfoPtr pScrn)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    vgaHWPtr pVga = VGAHWPTR(pScrn);
+    CARD16 implementation = pNv->Chipset & 0x0ff0;
+    xf86MonPtr monitorA, monitorB;
+    Bool mobile = FALSE;
+    Bool tvA = FALSE;
+    Bool tvB = FALSE;
+    int FlatPanel = -1;   /* really means the CRTC is slaved */
+    Bool Television = FALSE;
+    
+    /*
+     * Override VGA I/O routines.
+     */
+    pVga->writeCrtc         = NVWriteCrtc;
+    pVga->readCrtc          = NVReadCrtc;
+    pVga->writeGr           = NVWriteGr;
+    pVga->readGr            = NVReadGr;
+    pVga->writeAttr         = NVWriteAttr;
+    pVga->readAttr          = NVReadAttr;
+    pVga->writeSeq          = NVWriteSeq;
+    pVga->readSeq           = NVReadSeq;
+    pVga->writeMiscOut      = NVWriteMiscOut;
+    pVga->readMiscOut       = NVReadMiscOut;
+    pVga->enablePalette     = NVEnablePalette;
+    pVga->disablePalette    = NVDisablePalette;
+    pVga->writeDacMask      = NVWriteDacMask;
+    pVga->readDacMask       = NVReadDacMask;
+    pVga->writeDacWriteAddr = NVWriteDacWriteAddr;
+    pVga->writeDacReadAddr  = NVWriteDacReadAddr;
+    pVga->writeDacData      = NVWriteDacData;
+    pVga->readDacData       = NVReadDacData;
+    /*
+     * Note: There are different pointers to the CRTC/AR and GR/SEQ registers.
+     * Bastardize the intended uses of these to make it work.
+     */
+    pVga->MMIOBase   = (CARD8 *)pNv;
+    pVga->MMIOOffset = 0;
+    
+    pNv->REGS = xf86MapPciMem(pScrn->scrnIndex, 
+                              VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, 
+                              pNv->PciTag, pNv->IOAddress, 0x01000000);
+
+    pNv->PRAMIN   = pNv->REGS + (0x00710000/4);
+    pNv->PCRTC0   = pNv->REGS + (0x00600000/4);
+    pNv->PRAMDAC0 = pNv->REGS + (0x00680000/4);
+    pNv->PFB      = pNv->REGS + (0x00100000/4);
+    pNv->PFIFO    = pNv->REGS + (0x00002000/4);
+    pNv->PGRAPH   = pNv->REGS + (0x00400000/4);
+    pNv->PEXTDEV  = pNv->REGS + (0x00101000/4);
+    pNv->PTIMER   = pNv->REGS + (0x00009000/4);
+    pNv->PMC      = pNv->REGS + (0x00000000/4);
+    pNv->FIFO     = pNv->REGS + (0x00800000/4);
+
+    /* 8 bit registers */
+    pNv->PCIO0    = (U008*)pNv->REGS + 0x00601000;
+    pNv->PDIO0    = (U008*)pNv->REGS + 0x00681000;
+    pNv->PVIO     = (U008*)pNv->REGS + 0x000C0000;
+
+    pNv->twoHeads =  (pNv->Architecture >= NV_ARCH_10) &&
+                     (implementation != 0x0100) &&
+                     (implementation != 0x0150) &&
+                     (implementation != 0x01A0) &&
+                     (implementation != 0x0200);
+
+    pNv->fpScaler = (pNv->FpScale && pNv->twoHeads && (implementation!=0x0110));
+
+    pNv->twoStagePLL = (implementation == 0x0310) ||
+                       (implementation == 0x0340) ||
+                       (pNv->Architecture >= NV_ARCH_40);
+
+    pNv->WaitVSyncPossible = (pNv->Architecture >= NV_ARCH_10) &&
+                             (implementation != 0x0100);
+
+    pNv->BlendingPossible = ((pNv->Chipset & 0xffff) != 0x0020);
+
+    /* look for known laptop chips */
+    switch(pNv->Chipset & 0xffff) {
+    case 0x0112:
+    case 0x0174:
+    case 0x0175:
+    case 0x0176:
+    case 0x0177:
+    case 0x0179:
+    case 0x017C:
+    case 0x017D:
+    case 0x0186:
+    case 0x0187:
+    case 0x018D:
+    case 0x0228:
+    case 0x0286:
+    case 0x028C:
+    case 0x0316:
+    case 0x0317:
+    case 0x031A:
+    case 0x031B:
+    case 0x031C:
+    case 0x031D:
+    case 0x031E:
+    case 0x031F:
+    case 0x0324:
+    case 0x0325:
+    case 0x0328:
+    case 0x0329:
+    case 0x032C:
+    case 0x032D:
+    case 0x0347:
+    case 0x0348:
+    case 0x0349:
+    case 0x034B:
+    case 0x034C:
+    case 0x0160:
+    case 0x0166:
+    case 0x0169:
+    case 0x016B:
+    case 0x016C:
+    case 0x016D:
+    case 0x00C8:
+    case 0x00CC:
+    case 0x0144:
+    case 0x0146:
+    case 0x0148:
+    case 0x0098:
+    case 0x0099:
+        mobile = TRUE;
+        break;
+    default:
+        break;
+    }
+
+    if(pNv->Architecture == NV_ARCH_04)
+        nv4GetConfig(pNv);
+    else
+        nv10GetConfig(pNv);
+
+    NVSelectHeadRegisters(pScrn, 0);
+
+    NVLockUnlock(pNv, 0);
+
+    NVI2CInit(pScrn);
+
+    pNv->Television = FALSE;
+
+    if(!pNv->twoHeads) {
+       pNv->CRTCnumber = 0;
+       if((monitorA = NVProbeDDC(pScrn, 0))) {
+           FlatPanel = monitorA->features.input_type ? 1 : 0;
+
+           /* NV4 doesn't support FlatPanels */
+           if((pNv->Chipset & 0x0fff) <= 0x0020)
+              FlatPanel = 0;
+       } else {
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x28);
+           if(VGA_RD08(pNv->PCIO, 0x03D5) & 0x80) {
+              VGA_WR08(pNv->PCIO, 0x03D4, 0x33);
+              if(!(VGA_RD08(pNv->PCIO, 0x03D5) & 0x01)) 
+                 Television = TRUE;
+              FlatPanel = 1;
+           } else {
+              FlatPanel = 0;
+           }
+           xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                         "HW is currently programmed for %s\n",
+                          FlatPanel ? (Television ? "TV" : "DFP") : "CRT");
+       } 
+
+       if(pNv->FlatPanel == -1) {
+           pNv->FlatPanel = FlatPanel;
+           pNv->Television = Television;
+       } else {
+           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+                      "Forcing display type to %s as specified\n", 
+                       pNv->FlatPanel ? "DFP" : "CRT");
+       }
+    } else {
+       CARD8 outputAfromCRTC, outputBfromCRTC;
+       int CRTCnumber = -1;
+       CARD8 slaved_on_A, slaved_on_B;
+       Bool analog_on_A, analog_on_B;
+       CARD32 oldhead;
+       CARD8 cr44;
+      
+       if(implementation != 0x0110) {
+           if(pNv->PRAMDAC0[0x0000052C/4] & 0x100)
+               outputAfromCRTC = 1;
+           else            
+               outputAfromCRTC = 0;
+           if(pNv->PRAMDAC0[0x0000252C/4] & 0x100)
+               outputBfromCRTC = 1;
+           else
+               outputBfromCRTC = 0;
+          analog_on_A = NVIsConnected(pScrn, 0);
+          analog_on_B = NVIsConnected(pScrn, 1);
+       } else {
+          outputAfromCRTC = 0;
+          outputBfromCRTC = 1;
+          analog_on_A = FALSE;
+          analog_on_B = FALSE;
+       }
+
+       VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+       cr44 = VGA_RD08(pNv->PCIO, 0x03D5);
+
+       VGA_WR08(pNv->PCIO, 0x03D5, 3);
+       NVSelectHeadRegisters(pScrn, 1);
+       NVLockUnlock(pNv, 0);
+
+       VGA_WR08(pNv->PCIO, 0x03D4, 0x28);
+       slaved_on_B = VGA_RD08(pNv->PCIO, 0x03D5) & 0x80;
+       if(slaved_on_B) {
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x33);
+           tvB = !(VGA_RD08(pNv->PCIO, 0x03D5) & 0x01);
+       }
+
+       VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+       VGA_WR08(pNv->PCIO, 0x03D5, 0);
+       NVSelectHeadRegisters(pScrn, 0);
+       NVLockUnlock(pNv, 0);
+
+       VGA_WR08(pNv->PCIO, 0x03D4, 0x28);
+       slaved_on_A = VGA_RD08(pNv->PCIO, 0x03D5) & 0x80; 
+       if(slaved_on_A) {
+           VGA_WR08(pNv->PCIO, 0x03D4, 0x33);
+           tvA = !(VGA_RD08(pNv->PCIO, 0x03D5) & 0x01);
+       }
+
+       oldhead = pNv->PCRTC0[0x00000860/4];
+       pNv->PCRTC0[0x00000860/4] = oldhead | 0x00000010;
+
+       monitorA = NVProbeDDC(pScrn, 0);
+       monitorB = NVProbeDDC(pScrn, 1);
+
+       if(slaved_on_A && !tvA) {
+          CRTCnumber = 0;
+          FlatPanel = 1;
+          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                    "CRTC 0 is currently programmed for DFP\n");
+       } else 
+       if(slaved_on_B && !tvB) {
+          CRTCnumber = 1;
+          FlatPanel = 1;
+          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                    "CRTC 1 is currently programmed for DFP\n");
+       } else
+       if(analog_on_A) {
+          CRTCnumber = outputAfromCRTC;
+          FlatPanel = 0;
+          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                    "CRTC %i appears to have a CRT attached\n", CRTCnumber);
+       } else
+       if(analog_on_B) {
+           CRTCnumber = outputBfromCRTC;
+           FlatPanel = 0;
+           xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                    "CRTC %i appears to have a CRT attached\n", CRTCnumber);
+       } else
+       if(slaved_on_A) {
+          CRTCnumber = 0;
+          FlatPanel = 1;
+          Television = 1;
+          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                    "CRTC 0 is currently programmed for TV\n");
+       } else
+       if(slaved_on_B) {
+          CRTCnumber = 1;
+          FlatPanel = 1;
+          Television = 1;
+          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                    "CRTC 1 is currently programmed for TV\n");
+       } else
+       if(monitorA) {
+           FlatPanel = monitorA->features.input_type ? 1 : 0;
+       } else 
+       if(monitorB) {
+           FlatPanel = monitorB->features.input_type ? 1 : 0;
+       }
+
+       if(pNv->FlatPanel == -1) {
+          if(FlatPanel != -1) {
+             pNv->FlatPanel = FlatPanel;
+             pNv->Television = Television;
+          } else {
+             xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Unable to detect display type...\n");
+             if(mobile) {
+                 xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
+                            "...On a laptop, assuming DFP\n");
+                 pNv->FlatPanel = 1;
+             } else {
+                 xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
+                            "...Using default of CRT\n");
+                 pNv->FlatPanel = 0;
+             }
+          }
+       } else {
+           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+                      "Forcing display type to %s as specified\n", 
+                       pNv->FlatPanel ? "DFP" : "CRT");
+       }
+
+       if(pNv->CRTCnumber == -1) {
+          if(CRTCnumber != -1) pNv->CRTCnumber = CRTCnumber;
+          else {
+             xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Unable to detect which CRTCNumber...\n");
+             if(pNv->FlatPanel) pNv->CRTCnumber = 1;
+             else pNv->CRTCnumber = 0;
+             xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
+                        "...Defaulting to CRTCNumber %i\n", pNv->CRTCnumber);
+          }
+       } else {
+           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+                      "Forcing CRTCNumber %i as specified\n", pNv->CRTCnumber);
+       }
+     
+       if(monitorA) {
+           if((monitorA->features.input_type && pNv->FlatPanel) ||
+              (!monitorA->features.input_type && !pNv->FlatPanel))
+           {
+               if(monitorB) { 
+                  xfree(monitorB);
+                  monitorB = NULL;
+               }
+           } else {
+              xfree(monitorA);
+              monitorA = NULL;
+           }
+       }
+
+       if(monitorB) {
+           if((monitorB->features.input_type && !pNv->FlatPanel) ||
+              (!monitorB->features.input_type && pNv->FlatPanel)) 
+           {
+              xfree(monitorB);
+           } else {
+              monitorA = monitorB;
+           }
+           monitorB = NULL;
+       }
+
+       if(implementation == 0x0110)
+           cr44 = pNv->CRTCnumber * 0x3;
+
+       pNv->PCRTC0[0x00000860/4] = oldhead;
+
+       VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
+       VGA_WR08(pNv->PCIO, 0x03D5, cr44);
+       NVSelectHeadRegisters(pScrn, pNv->CRTCnumber);
+    }
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+              "Using %s on CRTC %i\n",
+              pNv->FlatPanel ? (pNv->Television ? "TV" : "DFP") : "CRT", 
+              pNv->CRTCnumber);
+
+    if(pNv->FlatPanel && !pNv->Television) {
+       pNv->fpWidth = pNv->PRAMDAC[0x0820/4] + 1;
+       pNv->fpHeight = pNv->PRAMDAC[0x0800/4] + 1;
+       pNv->fpSyncs = pNv->PRAMDAC[0x0848/4] & 0x30000033;
+       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Panel size is %i x %i\n",
+                  pNv->fpWidth, pNv->fpHeight);
+    }
+
+    if(monitorA)
+      xf86SetDDCproperties(pScrn, monitorA);
+/* add mangle for fptweak */
+	if(monitorA)
+	{
+
+xf86DrvMsg(pScrn->scrnIndex, X_INFO,"Chipset = 0x%x\n",pNv->Chipset);
+/*
+		if(((pNv->Chipset & 0xffff) == 0x0338)  ||
+		   ((pNv->Chipset & 0xffff) == 0x034e))
+*/
+		switch(pNv->Chipset & 0xffff) 
+		{
+	 		case 0x0338:
+		 	case 0x034e:
+				if((!strcmp(monitorA->vendor.name,"SUN")&&
+		    			(monitorA->vendor.prod_id == 0x586 )))
+    				{
+        				pNv->usePanelTweak = TRUE;
+					pNv->PanelTweak = 1;
+				}
+				break;
+			default:
+				break;
+    		} 
+	}
+
+    if(!pNv->FlatPanel || (pScrn->depth != 24) || !pNv->twoHeads)
+        pNv->FPDither = FALSE;
+
+    pNv->LVDS = FALSE;
+    if(pNv->FlatPanel && pNv->twoHeads) {
+        pNv->PRAMDAC0[0x08B0/4] = 0x00010004;
+        if(pNv->PRAMDAC0[0x08B4/4] & 1)
+           pNv->LVDS = TRUE;
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel is %s\n", 
+                   pNv->LVDS ? "LVDS" : "TMDS");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,213 @@
+/*
+   Copyright (c) 1999,  The XFree86 Project Inc. 
+   Written by Mark Vojkovich <[email protected]>
+*/
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c,v 1.5 2000/03/13 18:49:29 mvojkovi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "nv_local.h"
+#include "nv_include.h"
+#include "nv_type.h"
+#include "shadowfb.h"
+#include "servermd.h"
+
+
+void
+NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    int width, height, Bpp, FBPitch;
+    unsigned char *src, *dst;
+   
+    Bpp = pScrn->bitsPerPixel >> 3;
+    FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel);
+
+    while(num--) {
+	width = (pbox->x2 - pbox->x1) * Bpp;
+	height = pbox->y2 - pbox->y1;
+	src = pNv->ShadowPtr + (pbox->y1 * pNv->ShadowPitch) + 
+						(pbox->x1 * Bpp);
+	dst = pNv->FbStart + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp);
+
+	while(height--) {
+	    memcpy(dst, src, width);
+	    dst += FBPitch;
+	    src += pNv->ShadowPitch;
+	}
+	
+	pbox++;
+    }
+} 
+
+void
+NVPointerMoved(int index, int x, int y)
+{
+    ScrnInfoPtr pScrn = xf86Screens[index];
+    NVPtr pNv = NVPTR(pScrn);
+    int newX, newY;
+
+    if(pNv->Rotate == 1) {
+	newX = pScrn->pScreen->height - y - 1;
+	newY = x;
+    } else {
+	newX = y;
+	newY = pScrn->pScreen->width - x - 1;
+    }
+
+    (*pNv->PointerMoved)(index, newX, newY);
+}
+
+void
+NVRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    int count, width, height, y1, y2, dstPitch, srcPitch;
+    CARD8 *dstPtr, *srcPtr, *src;
+    CARD32 *dst;
+
+    if(!pNv->Rotate) {
+       NVRefreshArea(pScrn, num, pbox);
+       return;
+    }
+
+    dstPitch = pScrn->displayWidth;
+    srcPitch = -pNv->Rotate * pNv->ShadowPitch;
+
+    while(num--) {
+	width = pbox->x2 - pbox->x1;
+	y1 = pbox->y1 & ~3;
+	y2 = (pbox->y2 + 3) & ~3;
+	height = (y2 - y1) >> 2;  /* in dwords */
+
+	if(pNv->Rotate == 1) {
+	    dstPtr = pNv->FbStart + 
+			(pbox->x1 * dstPitch) + pScrn->virtualX - y2;
+	    srcPtr = pNv->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1;
+	} else {
+	    dstPtr = pNv->FbStart + 
+			((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
+	    srcPtr = pNv->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1;
+	}
+
+	while(width--) {
+	    src = srcPtr;
+	    dst = (CARD32*)dstPtr;
+	    count = height;
+	    while(count--) {
+		*(dst++) = src[0] | (src[srcPitch] << 8) | 
+					(src[srcPitch * 2] << 16) | 
+					(src[srcPitch * 3] << 24);
+		src += srcPitch * 4;
+	    }
+	    srcPtr += pNv->Rotate;
+	    dstPtr += dstPitch;
+	}
+
+	pbox++;
+    }
+} 
+
+
+void
+NVRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    int count, width, height, y1, y2, dstPitch, srcPitch;
+    CARD16 *dstPtr, *srcPtr, *src;
+    CARD32 *dst;
+
+    if(!pNv->Rotate) {
+       NVRefreshArea(pScrn, num, pbox);
+       return;
+    }
+
+    dstPitch = pScrn->displayWidth;
+    srcPitch = -pNv->Rotate * pNv->ShadowPitch >> 1;
+
+    while(num--) {
+	width = pbox->x2 - pbox->x1;
+	y1 = pbox->y1 & ~1;
+	y2 = (pbox->y2 + 1) & ~1;
+	height = (y2 - y1) >> 1;  /* in dwords */
+
+	if(pNv->Rotate == 1) {
+	    dstPtr = (CARD16*)pNv->FbStart + 
+			(pbox->x1 * dstPitch) + pScrn->virtualX - y2;
+	    srcPtr = (CARD16*)pNv->ShadowPtr + 
+			((1 - y2) * srcPitch) + pbox->x1;
+	} else {
+	    dstPtr = (CARD16*)pNv->FbStart + 
+			((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
+	    srcPtr = (CARD16*)pNv->ShadowPtr + 
+			(y1 * srcPitch) + pbox->x2 - 1;
+	}
+
+	while(width--) {
+	    src = srcPtr;
+	    dst = (CARD32*)dstPtr;
+	    count = height;
+	    while(count--) {
+		*(dst++) = src[0] | (src[srcPitch] << 16);
+		src += srcPitch * 2;
+	    }
+	    srcPtr += pNv->Rotate;
+	    dstPtr += dstPitch;
+	}
+
+	pbox++;
+    }
+}
+
+
+void
+NVRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+    NVPtr pNv = NVPTR(pScrn);
+    int count, width, height, dstPitch, srcPitch;
+    CARD32 *dstPtr, *srcPtr, *src, *dst;
+
+    if(!pNv->Rotate) {
+       NVRefreshArea(pScrn, num, pbox);
+       return;
+    }
+
+    dstPitch = pScrn->displayWidth;
+    srcPitch = -pNv->Rotate * pNv->ShadowPitch >> 2;
+
+    while(num--) {
+	width = pbox->x2 - pbox->x1;
+	height = pbox->y2 - pbox->y1;
+
+	if(pNv->Rotate == 1) {
+	    dstPtr = (CARD32*)pNv->FbStart + 
+			(pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2;
+	    srcPtr = (CARD32*)pNv->ShadowPtr + 
+			((1 - pbox->y2) * srcPitch) + pbox->x1;
+	} else {
+	    dstPtr = (CARD32*)pNv->FbStart + 
+			((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1;
+	    srcPtr = (CARD32*)pNv->ShadowPtr + 
+			(pbox->y1 * srcPitch) + pbox->x2 - 1;
+	}
+
+	while(width--) {
+	    src = srcPtr;
+	    dst = dstPtr;
+	    count = height;
+	    while(count--) {
+		*(dst++) = *src;
+		src += srcPitch;
+	    }
+	    srcPtr += pNv->Rotate;
+	    dstPtr += dstPitch;
+	}
+
+	pbox++;
+    }
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,180 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.51 2005/04/16 23:57:26 mvojkovi Exp $ */
+
+#ifndef __NV_STRUCT_H__
+#define __NV_STRUCT_H__
+
+#include "colormapst.h"
+#include "vgaHW.h"
+#include "xaa.h"
+#include "xf86Cursor.h"
+#include "xf86int10.h"
+
+#define NV_ARCH_04  0x04
+#define NV_ARCH_10  0x10
+#define NV_ARCH_20  0x20
+#define NV_ARCH_30  0x30
+#define NV_ARCH_40  0x40
+
+
+#define BITMASK(t,b) (((unsigned)(1U << (((t)-(b)+1)))-1)  << (b))
+#define MASKEXPAND(mask) BITMASK(1?mask,0?mask)
+#define SetBF(mask,value) ((value) << (0?mask))
+#define GetBF(var,mask) (((unsigned)((var) & MASKEXPAND(mask))) >> (0?mask) )
+#define SetBitField(value,from,to) SetBF(to, GetBF(value,from))
+#define SetBit(n) (1<<(n))
+#define Set8Bits(value) ((value)&0xff)
+
+typedef struct {
+    int bitsPerPixel;
+    int depth;
+    int displayWidth;
+    rgb weight;
+    DisplayModePtr mode;
+} NVFBLayout;
+
+typedef struct _riva_hw_state
+{
+    U032 bpp;
+    U032 width;
+    U032 height;
+    U032 interlace;
+    U032 repaint0;
+    U032 repaint1;
+    U032 screen;
+    U032 scale;
+    U032 dither;
+    U032 extra;
+    U032 fifo;
+    U032 pixel;
+    U032 horiz;
+    U032 arbitration0;
+    U032 arbitration1;
+    U032 pll;
+    U032 pllB;
+    U032 vpll;
+    U032 vpll2;
+    U032 vpllB;
+    U032 vpll2B;
+    U032 pllsel;
+    U032 general;
+    U032 crtcOwner;
+    U032 head;
+    U032 head2;
+    U032 config;
+    U032 cursorConfig;
+    U032 cursor0;
+    U032 cursor1;
+    U032 cursor2;
+    U032 timingH;
+    U032 timingV;
+    U032 displayV;
+    U032 crtcSync;
+} RIVA_HW_STATE, *NVRegPtr;
+
+
+typedef struct {
+    RIVA_HW_STATE       SavedReg;
+    RIVA_HW_STATE       ModeReg;
+    RIVA_HW_STATE       *CurrentState;
+    CARD32              Architecture;
+    CARD32              CursorStart;
+    EntityInfoPtr       pEnt;
+    pciVideoPtr         PciInfo;
+    PCITAG              PciTag;
+    int                 Chipset;
+    int                 ChipRev;
+    Bool                Primary;
+    CARD32              IOAddress;
+    unsigned long       FbAddress;
+    unsigned char *     FbBase;
+    unsigned char *     FbStart;
+    CARD32              FbMapSize;
+    CARD32              FbUsableSize;
+    CARD32              ScratchBufferSize;
+    CARD32              ScratchBufferStart;
+    Bool                NoAccel;
+    Bool                HWCursor;
+    Bool                FpScale;
+    Bool                ShadowFB;
+    unsigned char *     ShadowPtr;
+    int                 ShadowPitch;
+    CARD32              MinVClockFreqKHz;
+    CARD32              MaxVClockFreqKHz;
+    CARD32              CrystalFreqKHz;
+    CARD32              RamAmountKBytes;
+
+    volatile U032 *REGS;
+    volatile U032 *PCRTC0;
+    volatile U032 *PCRTC;
+    volatile U032 *PRAMDAC0;
+    volatile U032 *PFB;
+    volatile U032 *PFIFO;
+    volatile U032 *PGRAPH;
+    volatile U032 *PEXTDEV;
+    volatile U032 *PTIMER;
+    volatile U032 *PMC;
+    volatile U032 *PRAMIN;
+    volatile U032 *FIFO;
+    volatile U032 *CURSOR;
+    volatile U008 *PCIO0;
+    volatile U008 *PCIO;
+    volatile U008 *PVIO;
+    volatile U008 *PDIO0;
+    volatile U008 *PDIO;
+    volatile U032 *PRAMDAC;
+
+    XAAInfoRecPtr       AccelInfoRec;
+    xf86CursorInfoPtr   CursorInfoRec;
+    DGAModePtr          DGAModes;
+    int                 numDGAModes;
+    Bool                DGAactive;
+    int                 DGAViewportStatus;
+    void		(*PointerMoved)(int index, int x, int y);
+    ScreenBlockHandlerProcPtr BlockHandler;
+    CloseScreenProcPtr  CloseScreen;
+    Bool                FBDev;
+    int			Rotate;
+    NVFBLayout		CurrentLayout;
+    /* Cursor */
+    CARD32              curFg, curBg;
+    CARD32              curImage[256];
+    /* I2C / DDC */
+    I2CBusPtr           I2C;
+    xf86Int10InfoPtr    pInt;
+    void		(*VideoTimerCallback)(ScrnInfoPtr, Time);
+    void		(*DMAKickoffCallback)(ScrnInfoPtr);
+    XF86VideoAdaptorPtr	overlayAdaptor;
+    XF86VideoAdaptorPtr	blitAdaptor;
+    int			videoKey;
+    int			FlatPanel;
+    Bool                FPDither;
+    Bool                Television;
+    int			CRTCnumber;
+    OptionInfoPtr	Options;
+    Bool                alphaCursor;
+    unsigned char       DDCBase;
+    Bool                twoHeads;
+    Bool                twoStagePLL;
+    Bool                fpScaler;
+    int                 fpWidth;
+    int                 fpHeight;
+    CARD32              fpSyncs;
+    Bool                usePanelTweak;
+    int                 PanelTweak;
+    Bool                LVDS;
+
+    CARD32              dmaPut;
+    CARD32              dmaCurrent;
+    CARD32              dmaFree;
+    CARD32              dmaMax;
+    CARD32              *dmaBase;
+
+    CARD32              currentRop;
+    Bool                WaitVSyncPossible;
+    Bool                BlendingPossible;
+    Bool                RandRRotation;
+} NVRec, *NVPtr;
+
+#define NVPTR(p) ((NVPtr)((p)->driverPrivate))
+
+#endif /* __NV_STRUCT_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/etc/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,41 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/08 SMI"
+XCOMM
+
+XCOMM 6223269: Override scanpci library paths to use shared lib instead of static
+scanpci := LDPRELIBS = -L../scanpci/module -R$(MODULEDIR)
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-server -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/etc/sun_extramodes	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+//-------------------------------------------------------------------------
+// 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.
+//
+//-------------------------------------------------------------------------
+//
+// ident "@(#)sun_extramodes 1.4     05/11/08 SMI"
+//
+// Additional timing specs for Sun monitors
+
+// Skip this one for now as it breaks some other common 1600x1200@75Hz displays
+// # 1600x1200 @ 60Hz (Sun) hsync: 74.493kHz
+// Modeline "1600x1200" 132.3 1600 1608 1672 1776 1200 1205 1215 1239 +hsync +vsync
+
+# 1920x1080 @ 60Hz (Sun) hsync: 66.975kHz
+Modeline "1920x1080" 137.7 1920 1928 1992 2056 1080 1082 1086 1112 +hsync +vsync
+
+# 1920x1200 @ 60Hz (Sun 24.1" LCD) hsync: 73.54 kHz
+ModeLine "1920x1200" 151.200 1920 1928 1992 2056 1200 1202 1206 1234 +HSync +VSync
+
+# 1920x1200 @ 70.316Hz (Sun 24" CRT) hsync: 87.192 kHz
+ModeLine "1920x1200" 219.375 1920 1944 2172 2516 1200 1201 1204 1240 -HSync -VSync
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/fbdevhw/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,35 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localmacros 1.2     05/11/08 SMI"
+XCOMM
+
+InstallLibraryModule(fbdevhw,$(MODULEDIR),linux)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/getconfig/getconfig.pl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,432 @@
+#!/usr/bin/perl
+
+# $DHD: xc/programs/Xserver/hw/xfree86/getconfig/getconfig.pl,v 1.13 2003/09/23 05:12:07 dawes Exp $
+
+#
+# Copyright 2003 by David H. Dawes.
+# Copyright 2003 by X-Oz Technologies.
+# 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+# and author(s) shall 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 holder(s) and author(s).
+# 
+# Author: David Dawes <[email protected]>.
+#
+
+
+#
+# This script takes PCI id information, compares it against an ordered list
+# of rules, and prints out the configuration information specified by the
+# last matching rule.
+#
+# This script is called by xf86AutoConfig().
+#
+
+# Command line processing.
+
+$GetconfigVersion = v1.0;
+
+$debug = 0;
+
+$myname = $0;
+$myname =~ s/.*\///;
+
+$signature = "Xorg Foundation getconfig rules file.  Version: ";
+
+while (@ARGV[0] =~ /^-[A-Za-z]$/) {
+    $f = shift;
+    SWITCH: {
+	if ($f eq "-D") {
+	    $debug = 1;
+	    last SWITCH;
+	}
+	if ($f eq "-I") {
+	    push(@searchPaths, split(/,/, shift));
+	    last SWITCH;
+	}
+	if ($f eq "-V") {
+	    printf STDERR "$myname: Version %vd.\n", $GetconfigVersion;
+	    exit 0;
+	}
+	if ($f eq "-X") {
+	    $XorgVersionNumeric = shift;
+	    if (!defined($XorgVersionNumeric)) {
+		print STDERR "$myname: -X requires the Xorg version.\n";
+		exit 1;
+	    }
+	}
+	if ($f eq "-b") {
+	    $subsys = oct(shift);
+	    if (!defined($subsys)) {
+		print STDERR "$myname: -b requires the subsys id.\n";
+		exit 1;
+	    }
+	    last SWITCH;
+	}
+	if ($f eq "-c") {
+	    $class = oct(shift);
+	    if (!defined($class)) {
+		print STDERR "$myname: -c requires the class value.\n";
+		exit 1;
+	    }
+	    last SWITCH;
+	}
+	if ($f eq "-d") {
+	    $device = oct(shift);
+	    if (!defined($device)) {
+		print STDERR "$myname: -d requires the device id.\n";
+		exit 1;
+	    }
+	    last SWITCH;
+	}
+	if ($f eq "-r") {
+	    $revision = oct(shift);
+	    if (!defined($revision)) {
+		print STDERR "$myname: -r requires the device revision.\n";
+		exit 1;
+	    }
+	    last SWITCH;
+	}
+	if ($f eq "-s") {
+	    $subsysVendor = oct(shift);
+	    if (!defined($subsysVendor)) {
+		print STDERR "$myname: -s requires the subsysVendor id.\n";
+		exit 1;
+	    }
+	    last SWITCH;
+	}
+	if ($f eq "-v") {
+	    $vendor = oct(shift);
+	    if (!defined($vendor)) {
+		print STDERR "$myname: -v requires the vendor id.\n";
+		exit 1;
+	    }
+	    last SWITCH;
+	}
+    }
+}
+
+printf STDERR "$myname: Version %vd.\n", $GetconfigVersion;
+
+if (defined($XorgVersionNumeric)) {
+    $XorgVersionMajor = $XorgVersionNumeric / 10000000;
+    $XorgVersionMinor = ($XorgVersionNumeric % 10000000) / 100000;
+    $XorgVersionPatch = ($XorgVersionNumeric % 100000) / 1000;
+    $XorgVersionSnapshot = $XorgVersionNumeric % 1000;
+    $XorgVersion = chr($XorgVersionMajor) . chr($XorgVersionMinor) .
+		chr($XorgVersionPatch) . chr($XorgVersionSnapshot);
+}
+
+if ($debug) {
+    printf STDERR "$myname: Xorg Version: %d, %d.%d.%d.%d, %vd.\n",
+	$XorgVersionNumeric, $XorgVersionMajor, $XorgVersionMinor,
+	$XorgVersionPatch, $XorgVersionSnapshot, $XorgVersion;
+} else {
+    printf STDERR "$myname: Xorg Version: %vd.\n", $XorgVersion;
+}
+  
+
+# The rules here are just basic vendor ID to driver mappings.
+# Ideally this is all that would be required.  More complicated configuration
+# rules will be provided in external files.
+
+# XXX This set of basic rules isn't complete yet.
+
+@rules = (
+
+# Set the weight for the built-in rules.
+['$weight = 500'],
+
+# APM
+['$vendor == 0x1142',
+	'apm'],
+
+# ARK
+['$vendor == 0xedd8',
+	'apm'],
+
+# ATI
+['$vendor == 0x1002',
+	'ati'],
+
+# AST
+['$vendor == 0x1A03',
+	'ast'],
+
+# Chips & Technologies
+['$vendor == 0x102c',
+	'chips'],
+
+# Cirrus
+['$vendor == 0x1013',
+	'cirrus'],
+
+# Intel
+['$vendor == 0x8086',
+	'i810'],
+['$vendor == 0x8086 && ($chipType == 0x00d1 || $chipType == 0x7800)',
+	'i740'],
+
+# Matrox
+['$vendor == 0x102b',
+	'mga'],
+
+# Neomagic
+['$vendor == 0x10c8',
+	'neomagic'],
+
+# Number Nine
+['$vendor == 0x105d',
+	'i128'],
+
+# NVIDIA
+['$vendor == 0x10de || $vendor == 0x12d2',
+	'nv'],
+
+# S3
+['$vendor == 0x5333 && ($device == 0x88d0 ||' .
+			'$device == 0x88d1 ||' .
+			'$device == 0x88f0 ||' .
+			'$device == 0x8811 ||' .
+			'$device == 0x8812 ||' .
+			'$device == 0x8814 ||' .
+			'$device == 0x8901)',
+	's3'],
+
+# S3 virge
+['$vendor == 0x5333 && ($device == 0x5631 ||' .
+			'$device == 0x883d ||' .
+			'$device == 0x8a01 ||' .
+			'$device == 0x8a10 ||' .
+			'$device == 0x8c01 ||' .
+			'$device == 0x8c03 ||' .
+			'$device == 0x8904 ||' .
+			'$device == 0x8a13)',
+	's3virge'],
+
+# S3 Savage
+['$vendor == 0x5333 && ($device >= 0x8a20 && $device <= 0x8a22 ||' .
+			'$device == 0x9102 ||' .
+			'$device >= 0x8c10 && $device <= 0x8c13 ||' .
+			'$device == 0x8a25 ||' .
+			'$device == 0x8a26 ||' .
+			'$device >= 0x8d01 && $device <= 0x8d04 ||' .
+			'$device >= 0x8c2a && $device <= 0x8c2f ||' .
+			'$device == 0x8c22 ||' .
+			'$device == 0x8c24 ||' .
+			'$device == 0x8c26)',
+	'savage'],
+
+# SIS
+['$vendor == 0x1039',
+	'sis'],
+
+# SMI
+['$vendor == 0x126f',
+	'siliconmotion'],
+
+# 3Dfx
+['$vendor == 0x121a',
+	'tdfx'],
+
+# 3Dlabs
+['$vendor == 0x3d3d',
+	'glint'],
+
+# Trident
+['$vendor == 0x1023',
+	'trident'],
+
+# Tseng Labs
+['$vendor == 0x100c',
+	'tseng'],
+
+# VIA
+['$vendor == 0x1106',
+	'via'],
+
+# VMware
+['$vendor == 0x15ad',
+	'vmware'],
+
+);
+
+# Reverse the search path list, since the later rules have higher priority
+# than earlier ones (weighting being equal).
+
+@searchPaths = reverse(@searchPaths);
+
+if ($debug) {
+    $i = 0;
+    for $path (@searchPaths) {
+	print STDERR "$myname: Search path $i is: \"$path\".\n";
+	$i++;
+    }
+}
+
+print STDERR "$myname: ", $#rules + 1, " built-in rule", plural($#rules + 1),
+			".\n";
+
+for $path (@searchPaths) {
+    while (<$path/*.cfg>) {
+	@tmp = readRulesFile($_);
+	if (defined(@tmp[0])) {
+	    push @rules, @tmp;
+	}
+    }
+}
+
+if ($debug) {
+    $i = 0;
+    for $r (@rules) {
+	print STDERR "$myname: rule $i is: \'@$r\'.\n";
+	$i++
+    }
+}
+
+$i = 0;
+$e = 0;
+$weight = 0;
+$w = 0;
+for $r (@rules) {
+    ($cond, $d, @o) = @$r;
+    $result = eval $cond;
+    if ($@) {
+	print STDERR "$myname: Error evaluating rule $i \'$cond\': $@";
+	$e++;
+    }
+    if ($debug) {
+	print STDERR "$myname: rule $i \'$cond\' evaluates to \'$result\'.\n";
+    }
+    if ($result && defined($d) && $weight >= $w) {
+	$driver = $d;
+	@opts = @o;
+	$w = $weight;
+    }
+    $i++;
+}
+
+print STDERR "$myname: Evaluated $i rule", plural($i),
+		" with $e error", plural($e), ".\n";
+
+print STDERR "$myname: Weight of result is $w.\n";
+
+if ($debug) {
+    if (defined($driver)) {
+	print STDERR "$myname: Driver is \'$driver\'.\n";
+    } else {
+	print STDERR "$myname: No driver.\n";
+    }
+    if (defined(@opts)) {
+	print STDERR "$myname: options are:\n";
+	for $opt (@opts) {
+	    print STDERR "\t$opt\n";
+	}
+    } else {
+	print STDERR "$myname: No options.\n";
+    }
+}
+
+print "$driver\n";
+for $opt (@opts) {
+    print "$opt\n";
+}
+
+exit 0;
+
+# Subroutines.
+
+sub readRulesFile {
+    my ($file) = @_;
+    my $signatureOK = 0;
+    my @r, @tmp;
+    my $line, $cont, $prevcont, $fileversion;
+
+    undef @tmp;
+    undef @r;
+
+    if (open(RF, "<$file")) {
+	$prevcont = 0;
+	while (<RF>) {
+	    chop;
+	    $line = $_;
+	    next if ($line =~ /^#/);
+	    next if ($line =~ /^\s*$/);
+	    if (!$signatureOK) {
+		if ($line  =~ /^$signature(.*)$/) {
+		    $fileversion = $1;
+		    $signatureOK = 1;
+		    print STDERR
+			"$myname: rules file \'$file\' has version $fileversion.\n";
+		    next;
+		}
+	    }
+	    if (!$signatureOK) {
+		print STDERR "$myname: file \'$file\' has bad signature.\n";
+		close(RF);
+		last;
+	    }
+	    $cont = 0;
+	    if ($line =~ s/\\\s*$//) {
+		$cont = 1;
+	    }
+	    if (!$prevcont && $line =~ /^\S+/) {
+		if (defined(@tmp[0])) {
+		    push(@r,[@tmp]);
+		}
+		undef @tmp;
+	    }
+	    if ($prevcont) {
+		push(@tmp, pop(@tmp) . $line);
+	    } else {
+		push(@tmp, $line);
+	    }
+	    $prevcont = $cont;
+	}
+	if (defined(@tmp[0])) {
+	    push(@r,[@tmp]);
+	}
+	if (!defined(@r[0])) {
+	    print STDERR "$myname: no rules in file \'$file\'.\n";
+	} else {
+	    print STDERR "$myname: ", $#r + 1,
+			" rule", plural($#r + 1),
+			" added from file \'$file\'.\n";
+	}
+    } else {
+	print STDERR "$myname: cannot open file \'$file\'.\n";
+    }
+
+    return @r;
+}
+
+sub plural {
+    my ($count) = @_;
+
+    if ($count != 1) {
+	return "s";
+    } else {
+	return "";
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/getconfig/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,38 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-server -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/getconfig/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localmacros 1.2     05/11/08 SMI"
+XCOMM
+
+XCOMM Change perl path to always use OS provided perl, even if user has
+XCOMM replaced /usr/bin/perl with a link to their own version
+
+AllTarget(getconfig-sun)
+        LinkBuildModule(getconfig-sun,.)
+
+getconfig-sun: getconfig.pl
+        RemoveFile($@)
+        sed 's|/usr/bin/perl|/usr/perl5/bin/perl|' getconfig.pl > $@
+        chmod a+x $@
+
+InstallNamedProg(getconfig-sun,getconfig-sun,$(BINDIR))
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/loader/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,41 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/08 SMI"
+XCOMM
+
+/* Override host.def which sets this to -D__sparc__ since that causes build 
+ * errors in asm code in elfloader.c that assumes gcc syntax for asm inlines.
+ */
+#if defined(SparcArchitecture) || defined(sparc)
+# define OSServerExtraDefines /**/
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,126 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile,v 1.4 2002/10/17 02:22:49 dawes Exp $
+XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile,v 1.8 2005/11/06 03:49:22 alanc Exp $
+XCOMM
+XCOMM Copyright 2001 The XFree86 Project, Inc.  All Rights Reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, sublicense, and/or sell copies of the Software, and to permit
+XCOMM persons to whom the Software is furnished to do so, subject to the
+XCOMM following conditions:
+XCOMM
+XCOMM The above copyright notice and this permission notice shall be included
+XCOMM in all copies or substantial portions of the Software.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+XCOMM IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR
+XCOMM OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+XCOMM ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+XCOMM OTHER DEALINGS IN THE SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of the XFree86 Project shall
+XCOMM not be used in advertising or otherwise to promote the sale, use or other
+XCOMM dealings in this Software without prior written authorization from the
+XCOMM XFree86 Project.
+XCOMM
+
+/* This is a combined Imakefile intended for all SunOS variants */
+
+#include <Server.tmpl>
+
+#if !HasGcc 
+# if HasSunC
+#  if !defined(AsmArch) || !defined(AsmFlags)
+#   error "Unsupported Architecture for building Xorg server with Sun compilers."
+#   error "Need to use gcc or add AsmArch & AsmFlag settings in xc/config/cf/sun.cf"
+#  endif
+PROWORKS_ASM_ARCH = AsmArch
+PROWORKS_ASM_FLAGS = AsmFlags
+PROWORKS_INOUT_SRC = solaris-$(PROWORKS_ASM_ARCH).S
+PROWORKS_INOUT_OBJ = solaris-$(PROWORKS_ASM_ARCH).o
+
+all:: $(PROWORKS_ASM_ARCH).il
+includes:: $(PROWORKS_ASM_ARCH).il
+
+CppFileTarget($(PROWORKS_ASM_ARCH).il,solaris-$(PROWORKS_ASM_ARCH).S,-DINLINE_ASM,NullParameter)
+
+$(PROWORKS_INOUT_OBJ): $(PROWORKS_INOUT_SRC)
+	$(AS) -P -o $@ $(PROWORKS_ASM_FLAGS) $(PROWORKS_INOUT_SRC)
+
+# elif defined(i386Architecture)
+PROWORKS_INOUT_SRC = sun_inout.s
+PROWORKS_INOUT_OBJ = sun_inout.o
+# endif
+#endif
+
+#if defined(i386Architecture) && (OSMinorVersion < 8)
+IO_SRC   = sysv_io.c
+IO_OBJ   = sysv_io.o
+KBD_SRCS = sysv_kbd.c std_kbdEv.c
+KBD_OBJS = sysv_kbd.o std_kbdEv.o
+VTSW_SRC = VTsw_usl.c
+VTSW_OBJ = VTsw_usl.o
+#else
+IO_SRC   = sun_io.c
+IO_OBJ   = sun_io.o
+#if SunSolarisXorgBuilds  /* Add xkbtable support */
+KBD_SRCS = sun_kbd.c sun_kbdEv.c sun_xkbtable.c sun_loginfo.c
+KBD_OBJS = sun_kbd.o sun_kbdEv.o sun_xkbtable.o sun_loginfo.o
+EXTRA_DEFINES =  -DDFLT_XKB_CONFIG_ROOT=\"$(LIBDIR)/xkb\" -DHAVE_ABSOLUTE_MOUSE_SCALING
+InstallNonExecFile(xkbtable.map,$(LIBDIR)/xkb)
+#else
+KBD_SRCS = sun_kbd.c sun_kbdEv.c
+KBD_OBJS = sun_kbd.o sun_kbdEv.o
+#endif
+VTSW_SRC = VTsw_noop.c
+VTSW_OBJ = VTsw_noop.o
+#endif
+
+#if defined(i386Architecture) || defined(AMD64Architecture)
+AGP_SRC = sun_agp.c
+AGP_OBJ = sun_agp.o
+#else
+AGP_SRC = agp_noop.c
+AGP_OBJ = agp_noop.o
+#endif
+
+#ifdef SVR4Architecture
+SYSVIPCDEFINES = -DHAVE_SYSV_IPC
+#endif
+
+SRCS = sun_bios.c sun_init.c $(IO_SRC) $(KBD_SRCS) $(PROWORKS_INOUT_SRC) \
+       sun_mouse.c sun_vid.c $(AGP_SRC) libc_wrapper.c kmod_noop.c sun_apm.c \
+       posix_tty.c sigiostubs.c stdPci.c stdResource.c $(VTSW_SRC)
+OBJS = sun_bios.o sun_init.o $(IO_OBJ) $(KBD_OBJS) $(PROWORKS_INOUT_OBJ) \
+       sun_mouse.o sun_vid.o $(AGP_OBJ) libc_wrapper.o kmod_noop.o sun_apm.o \
+       posix_tty.o sigiostubs.o stdPci.o stdResource.o $(VTSW_OBJ)
+
+INCLUDES = -I. -I$(XF86OSSRC) -I$(XF86COMSRC) \
+	   -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(SERVERSRC)/Xext \
+	   -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+DEFINES = -DUSESTDRES $(VENDOR_DEFINES) $(SYSVIPCDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalAsmObjectRule()
+
+LinkSourceFile($(VTSW_SRC),../shared)
+LinkSourceFile(agp_noop.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(sysv_io.c,../sysv)
+LinkSourceFile(sysv_kbd.c,../shared)
+
+DependTarget()
+LintTarget()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_apm.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,202 @@
+/* $XFree86$ */
+/* Copyright 2005 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.
+ */
+
+#include "X.h"
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "xf86_OSlib.h"
+
+#ifndef PLEASE_FIX_THIS
+#define APM_STANDBY_REQ 0xa01
+#define APM_SUSPEND_REQ 0xa02
+#define APM_NORMAL_RESUME 0xa03
+#define APM_CRIT_RESUME 0xa04
+#define APM_BATTERY_LOW 0xa05
+#define APM_POWER_CHANGE 0xa06
+#define APM_UPDATE_TIME 0xa07
+#define APM_CRIT_SUSPEND_REQ 0xa08
+#define APM_USER_STANDBY_REQ 0xa09
+#define APM_USER_SUSPEND_REQ 0xa0a
+#define APM_SYS_STANDBY_RESUME 0xa0b
+#define APM_IOC_NEXTEVENT 0xa0c
+#define APM_IOC_RESUME 0xa0d
+#define APM_IOC_SUSPEND 0xa0e
+#define APM_IOC_STANDBY 0xa0f
+#endif
+
+typedef struct apm_event_info 
+{
+	int	type;
+}apm_event_info;
+
+/*
+ This may be replaced with a better device name
+ very soon...
+*/
+#define APM_DEVICE "/dev/apm"
+
+static pointer APMihPtr = NULL;
+static void sunCloseAPM(void);
+
+static struct {
+    u_int apmBsd;
+    pmEvent xf86;
+} sunToXF86Array [] = {
+    { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY },
+    { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND },
+    { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
+    { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME },
+    { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY },
+    { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
+    { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
+    { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND },
+    { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY },
+    { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND },
+    { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+#ifdef APM_CAPABILITY_CHANGE
+    { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED },
+#endif
+};
+
+#define numApmEvents (sizeof(sunToXF86Array) / sizeof(sunToXF86Array[0]))
+
+static pmEvent
+sunToXF86(int type)
+{
+    int i;
+
+    for (i = 0; i < numApmEvents; i++) {
+	if (type == sunToXF86Array[i].apmBsd) {
+	    return sunToXF86Array[i].xf86;
+	}
+    }
+    return XF86_APM_UNKNOWN;
+}
+
+/*
+ * APM events can be requested direclty from /dev/apm 
+ */
+static int 
+sunPMGetEventFromOS(int fd, pmEvent *events, int num)
+{
+    struct apm_event_info sunEvent;
+    int i;
+
+    for (i = 0; i < num; i++) {
+	
+	if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) {
+	    if (errno != EAGAIN) {
+		xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT"
+			" errno = %d\n", errno);
+	    }
+	    break;
+	}
+	events[i] = sunToXF86(sunEvent.type);
+    }
+	    xf86Msg(X_WARNING, "Got some events\n");
+    return i;
+}
+
+/*
+ * XXX This won't work on /dev/apm !
+ *     We should either use /dev/apm_ctl (and kill apmd(8))
+ *     or talk to apmd (but its protocol is not publically available)...
+ */
+static pmWait
+sunPMConfirmEventToOs(int fd, pmEvent event)
+{
+    switch (event) {
+/* XXX: NOT CURRENTLY RETURNED FROM OS */
+      case XF86_APM_SYS_STANDBY:
+      case XF86_APM_USER_STANDBY:
+        if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0)
+            return PM_WAIT;  /* should we stop the Xserver in standby, too? */
+        else
+            return PM_NONE;
+      case XF86_APM_SYS_SUSPEND:
+      case XF86_APM_CRITICAL_SUSPEND:
+      case XF86_APM_USER_SUSPEND:
+	    xf86Msg(X_WARNING, "Got SUSPENDED\n");
+        if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0)
+            return PM_CONTINUE;
+        else {
+	    xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND"
+		" errno = %d\n", errno);
+            return PM_FAILED;
+	}
+      case XF86_APM_STANDBY_RESUME:
+      case XF86_APM_NORMAL_RESUME:
+      case XF86_APM_CRITICAL_RESUME:
+      case XF86_APM_STANDBY_FAILED:
+      case XF86_APM_SUSPEND_FAILED:
+	    xf86Msg(X_WARNING, "Got RESUME\n");
+        if (ioctl( fd, APM_IOC_RESUME, NULL ) == 0)
+            return PM_CONTINUE;
+        else {
+	    xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME"
+		" errno = %d\n", errno);
+            return PM_FAILED;
+	}
+      default:
+	return PM_NONE;
+    }
+}
+
+PMClose
+xf86OSPMOpen(void)
+{
+    int fd;
+
+    if (APMihPtr || !xf86Info.pmFlag) {
+	return NULL;
+    }
+
+    if ((fd = open(APM_DEVICE, O_RDWR)) == -1) {
+	return NULL;
+    }
+    xf86PMGetEventFromOs = sunPMGetEventFromOS;
+    xf86PMConfirmEventToOs = sunPMConfirmEventToOs;
+    APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL);
+    return sunCloseAPM;
+}
+
+static void
+sunCloseAPM(void)
+{
+    int fd;
+
+    if (APMihPtr) {
+	fd = xf86RemoveInputHandler(APMihPtr);
+	close(fd);
+	APMihPtr = NULL;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,174 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.2 2002/10/11 01:40:37 dawes Exp $ */
+/* $XdotOrg: $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the 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 Thomas Roell and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.  Thomas Roell and
+ * David Dawes makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER 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 2005 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.
+ */
+
+/* Solaris support routines for builtin "keyboard" driver */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "sun_kbd.h"
+
+#ifdef SUNSOFT
+# ifdef XKB
+#  include "sun_xkbtable.h"
+# endif
+#endif
+
+static sunKbdPrivRec sunKeyboardPriv;
+
+_X_HIDDEN void
+xf86KbdInit(void)
+{
+    const char *kbdName = "keyboard";
+    pointer *kbdOptions = NULL;
+    IDevPtr pDev;
+
+    /* There should be a better way to find the keyboard device name, but
+       this seems to work for now. */
+    for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
+	if (!xf86NameCmp(pDev->driver, "keyboard")) {
+	    kbdName = pDev->identifier;
+	    kbdOptions = pDev->commonOptions;
+	    break;
+	}
+    }
+
+    if (xf86Info.kbdFd < 0) {
+	xf86Info.kbdFd = sunKbdOpen(kbdName, kbdOptions);
+	if (xf86Info.kbdFd < 0) {
+	    FatalError("Unable to open keyboard: /dev/kbd\n");
+	}
+    }
+
+    memset(&sunKeyboardPriv, 0, sizeof(sunKbdPrivRec));    
+    if (sunKbdInit(&sunKeyboardPriv, xf86Info.kbdFd,
+		   kbdName, kbdOptions)	!= Success) {
+    	FatalError("Unable to initialize keyboard driver\n");
+    }
+
+#ifdef SUNSOFT
+    /* Probe keyboard settings if not specified in configuration */
+    if (xf86Info.xkbcomponents_specified != TRUE) {
+	sun_find_xkbnames(sunKeyboardPriv.ktype, sunKeyboardPriv.klayout,
+	    &xf86Info.xkbkeymap, &xf86Info.xkbmodel, &xf86Info.xkblayout);
+    }
+#endif
+}
+
+_X_HIDDEN int
+xf86KbdOn(void)
+{
+    if (sunKbdOn(&sunKeyboardPriv) != Success) {
+	FatalError("Enabling keyboard");
+    }
+
+    return xf86Info.kbdFd;
+}
+
+_X_HIDDEN int
+xf86KbdOff(void)
+{
+    if (sunKbdOff(&sunKeyboardPriv) != Success) {
+	FatalError("Disabling keyboard");
+    }
+
+    return xf86Info.kbdFd;
+}
+
+_X_EXPORT void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+    sunKbdSoundBell(&sunKeyboardPriv, loudness, pitch, duration);
+}
+
+_X_HIDDEN void
+xf86SetKbdLeds(int leds)
+{
+    sunKbdSetLeds(&sunKeyboardPriv, leds);
+}
+
+_X_HIDDEN int
+xf86GetKbdLeds(void)
+{
+    return sunKbdGetLeds(&sunKeyboardPriv);
+}
+
+_X_HIDDEN void
+xf86SetKbdRepeat(char rad)
+{
+    sunKbdSetRepeat(&sunKeyboardPriv, rad);
+}
+
+/*
+ * Lets try reading more than one keyboard event at a time in the hopes that
+ * this will be slightly more efficient.  Or we could just try the MicroSoft
+ * method, and forget about efficiency. :-)
+ */
+_X_HIDDEN void
+xf86KbdEvents(void)
+{
+    Firm_event event[64];
+    int        nBytes, i;
+
+    /* I certainly hope its not possible to read partial events */
+
+    if ((nBytes = read(xf86Info.kbdFd, (char *)event, sizeof(event))) > 0)
+    {
+	for (i = 0; i < (nBytes / sizeof(Firm_event)); i++)
+	    sunPostKbdEvent(sunKeyboardPriv.ktype, &event[i]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,726 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.1 2001/05/28 02:42:31 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <[email protected]>
+ * Copyright 1999 by David Holland <[email protected])
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the 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 Thomas Roell, David Dawes, and David Holland not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  Thomas Roell, David Dawes, and
+ * David Holland make no representations about the suitability of this software
+ * for any purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THOMAS ROELL, DAVID DAWES, AND DAVID HOLLAND DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL THOMAS ROELL, DAVID DAWES, OR DAVID HOLLAND
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 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 2004-2005 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.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.3 2004/06/13 04:50:21 alanc Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSKbd.h"
+#include "sun_kbd.h"
+
+/* Define to provide support for using /dev/audio to ring the bell instead of
+   the keyboard beeper */
+#define AUDIO_BELL
+
+#ifdef AUDIO_BELL
+#include <sys/audio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#include <math.h>
+#include <poll.h>
+#endif
+
+#ifdef SUNSOFT
+# ifdef XKB
+#  include "sun_xkbtable.h"
+# endif
+#endif
+
+/***************************************************************************
+ * Common implementation of routines shared by "keyboard" driver in sun_io.c
+ * and "kbd" driver (later on in this file)
+ */
+
+#include <sys/stropts.h>
+#include <sys/vuid_event.h>
+#include <sys/kbd.h>
+
+_X_HIDDEN int
+sunKbdOpen(const char *devName, pointer options)
+{
+    int kbdFD;
+    const char *kbdPath = NULL;
+    const char *defaultKbd = "/dev/kbd";
+
+    if (options != NULL) {
+	kbdPath = xf86SetStrOption(options, "Device", NULL);
+    }
+    if (kbdPath == NULL) {
+        kbdPath = defaultKbd;
+    }
+
+    kbdFD = open(kbdPath, O_RDONLY | O_NONBLOCK);
+    
+    if (kbdFD == -1) {
+        xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", devName, kbdPath);
+    } else {
+	xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", devName, kbdPath);
+    }
+    
+    if ((kbdPath != NULL) && (kbdPath != defaultKbd)) {
+	xfree(kbdPath);
+    }
+    return kbdFD;
+}
+
+
+/*
+ * Save initial keyboard state.  This is called at the start of each server
+ * generation.
+ */
+
+_X_HIDDEN int
+sunKbdInit(sunKbdPrivPtr priv, int kbdFD, const char *devName, pointer options)
+{
+    int	ktype, klayout, i;
+    const char *ktype_name;
+
+    priv->kbdFD 	= kbdFD;
+    priv->devName 	= devName;
+    priv->otranslation 	= -1;
+    priv->odirect 	= -1;
+
+    if (options != NULL) {
+	priv->strmod = xf86SetStrOption(options, "StreamsModule", NULL);
+	priv->audioDevName = xf86SetStrOption(options, "BellDevice", NULL);
+
+	if (priv->audioDevName && (priv->audioDevName[0] == '\0')) {
+	    xfree(priv->audioDevName);
+	    priv->audioDevName = NULL;
+	}	
+    } else {
+	priv->strmod 		= NULL;
+	priv->audioDevName	= NULL;
+    }
+
+    if (priv->strmod) {
+	SYSCALL(i = ioctl(priv->kbdFD, I_PUSH, priv->strmod));
+	if (i < 0) {
+	    xf86Msg(X_ERROR,
+		    "%s: cannot push module '%s' onto keyboard device: %s\n",
+		    priv->devName, priv->strmod, strerror(errno));
+	}
+    }
+    
+    SYSCALL(i = ioctl(kbdFD, KIOCTYPE, &ktype));
+    if (i < 0) {
+	xf86Msg(X_ERROR, "%s: Unable to determine keyboard type: %s\n", 
+		devName, strerror(errno));
+	return BadImplementation;
+    }
+    
+    SYSCALL(i = ioctl(kbdFD, KIOCLAYOUT, &klayout));
+    if (i < 0) {	
+	xf86Msg(X_ERROR, "%s: Unable to determine keyboard layout: %s\n", 
+		devName, strerror(errno));
+	return BadImplementation;
+    }
+    
+    switch (ktype) {
+    case KB_SUN3:
+	ktype_name = "Sun Type 3"; break;
+    case KB_SUN4:
+	ktype_name = "Sun Type 4/5/6"; break;
+    case KB_USB:
+	ktype_name = "USB"; break;
+    case KB_PC:
+	ktype_name = "PC"; break;
+    default:
+	ktype_name = "Unknown"; break;
+    }
+
+    xf86Msg(X_PROBED, "%s: Keyboard type: %s (%d)\n",
+	    devName, ktype_name, ktype);
+    xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", devName, klayout);
+
+    priv->ktype 	= ktype;
+    priv->klayout 	= klayout;
+    priv->keyMap	= sunGetKbdMapping(ktype);
+    priv->audioState	= AB_INITIALIZING;
+    priv->oleds 	= sunKbdGetLeds(priv);
+    
+    return Success;
+}
+
+_X_HIDDEN int
+sunKbdOn(sunKbdPrivPtr priv)
+{
+    int	ktrans, kdirect, i;
+
+    SYSCALL(i = ioctl(priv->kbdFD, KIOCGDIRECT, &kdirect));
+    if (i < 0) {
+	xf86Msg(X_ERROR, 
+		"%s: Unable to determine keyboard direct setting: %s\n", 
+		priv->devName, strerror(errno));
+	return BadImplementation;
+    }
+
+    priv->odirect = kdirect;
+    kdirect = 1;
+
+    SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &kdirect));
+    if (i < 0) {
+	xf86Msg(X_ERROR, "%s: Failed turning keyboard direct mode on: %s\n",
+			priv->devName, strerror(errno));
+	return BadImplementation;
+    }
+
+    /* Setup translation */
+
+    SYSCALL(i = ioctl(priv->kbdFD, KIOCGTRANS, &ktrans));
+    if (i < 0) {
+	xf86Msg(X_ERROR, 
+		"%s: Unable to determine keyboard translation mode: %s\n", 
+		priv->devName, strerror(errno));
+	return BadImplementation;
+    }
+
+    priv->otranslation = ktrans;
+    ktrans = TR_UNTRANS_EVENT;
+
+    SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &ktrans));
+    if (i < 0) {	
+	xf86Msg(X_ERROR, "%s: Failed setting keyboard translation mode: %s\n",
+			priv->devName, strerror(errno));
+	return BadImplementation;
+    }
+
+    return Success;
+}
+
+_X_HIDDEN int
+sunKbdOff(sunKbdPrivPtr priv)
+{
+    int i;
+
+    /* restore original state */
+    
+    sunKbdSetLeds(priv, priv->oleds);
+    
+    if (priv->otranslation != -1) {
+        SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &priv->otranslation));
+	if (i < 0) {
+	    xf86Msg(X_ERROR,
+		    "%s: Unable to restore keyboard translation mode: %s\n",
+		    priv->devName, strerror(errno));
+	    return BadImplementation;
+	}
+	priv->otranslation = -1;
+    }
+
+    if (priv->odirect != -1) {
+        SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &priv->odirect));
+	if (i < 0) {
+	    xf86Msg(X_ERROR,
+		    "%s: Unable to restore keyboard direct setting: %s\n",
+		    priv->devName, strerror(errno));
+	    return BadImplementation;
+	}
+	priv->odirect = -1;
+    }
+
+    if (priv->strmod) {
+	SYSCALL(i = ioctl(priv->kbdFD, I_POP, priv->strmod));
+	if (i < 0) {
+            xf86Msg(X_WARNING,
+		    "%s: cannot pop module '%s' off keyboard device: %s\n",
+		    priv->devName, priv->strmod, strerror(errno));
+	}
+    }
+
+    return Success;
+}
+
+#ifdef AUDIO_BELL
+
+/* Helper function to ring bell via audio device instead of keyboard beeper */
+
+#define BELL_RATE       48000   /* Samples per second */
+#define BELL_HZ         50      /* Fraction of a second i.e. 1/x */
+#define BELL_MS         (1000/BELL_HZ)  /* MS */
+#define BELL_SAMPLES    (BELL_RATE / BELL_HZ)
+#define BELL_MIN        3       /* Min # of repeats */
+
+static int
+sunKbdAudioBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
+{
+    static short    samples[BELL_SAMPLES];
+    static short    silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+    static int      lastFreq;
+    int             cnt;
+    int             i;
+    int		    written;
+    int             repeats;
+    int             freq;
+    audio_info_t    audioInfo;
+    struct iovec    iov[IOV_MAX];
+    int		    iovcnt;
+    double	    ampl, cyclen, phase;
+    int		    audioFD;
+
+    if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
+	return 0;
+    }
+
+    if ((priv == NULL) || (priv->audioDevName == NULL)) {
+	return -1;
+    }
+
+    if (priv->audioState == AB_INITIALIZING) {
+	priv->audioState = AB_NORMAL;
+	lastFreq = 0;
+	bzero(silence, sizeof(silence));
+    }
+    
+    audioFD = open(priv->audioDevName, O_WRONLY | O_NONBLOCK);
+    if (audioFD == -1) {
+	xf86Msg(X_ERROR, "%s: cannot open audio device \"%s\": %s\n",
+		priv->devName, priv->audioDevName, strerror(errno));
+	return -1;
+    } 
+
+    freq = pitch;
+    freq = min(freq, (BELL_RATE / 2) - 1);
+    freq = max(freq, 2 * BELL_HZ);
+
+    /*
+     * Ensure full waves per buffer
+     */
+    freq -= freq % BELL_HZ;
+
+    if (freq != lastFreq) {
+	lastFreq = freq;
+	ampl =  16384.0;
+
+	cyclen = (double) freq / (double) BELL_RATE;
+	phase = 0.0;
+
+	for (i = 0; i < BELL_SAMPLES; i++) {
+	    samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
+	    phase += cyclen;
+	    if (phase >= 1.0)
+		phase -= 1.0;
+	}
+    }
+    
+    repeats = (duration + (BELL_MS / 2)) / BELL_MS;
+    repeats = max(repeats, BELL_MIN);
+
+    loudness = max(0, loudness);
+    loudness = min(loudness, 100);
+
+#ifdef DEBUG
+    ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
+	   freq, loudness, duration, repeats);
+#endif
+
+    AUDIO_INITINFO(&audioInfo);
+    audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
+    audioInfo.play.sample_rate = BELL_RATE;
+    audioInfo.play.channels = 2;
+    audioInfo.play.precision = 16;
+    audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
+
+    if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
+	xf86Msg(X_ERROR,
+		"%s: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
+		priv->devName, priv->audioDevName, strerror(errno));
+	close(audioFD);
+	return -1;
+    }
+    
+    iovcnt = 0;
+    
+    for (cnt = 0; cnt <= repeats; cnt++) {
+	iov[iovcnt].iov_base = (char *) samples;
+	iov[iovcnt++].iov_len = sizeof(samples);
+	if (cnt == repeats) {
+	    /* Insert a bit of silence so that multiple beeps are distinct and
+	     * not compressed into a single tone.
+	     */
+	    iov[iovcnt].iov_base = (char *) silence;
+	    iov[iovcnt++].iov_len = sizeof(silence);
+	}	    
+	if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
+	    written = writev(audioFD, iov, iovcnt);
+
+	    if ((written < ((int)(sizeof(samples) * iovcnt)))) {
+		/* audio buffer was full! */
+
+		int naptime;
+
+		if (written == -1) {
+		    if (errno != EAGAIN) {
+			xf86Msg(X_ERROR,
+			       "%s: writev failed on audio device \"%s\": %s\n",
+				priv->devName, priv->audioDevName,
+				strerror(errno));
+			close(audioFD);
+			return -1;
+		    }
+		    i = iovcnt;
+		} else {
+		    i = ((sizeof(samples) * iovcnt) - written)
+			/ sizeof(samples);
+		}
+		cnt -= i;
+		
+		/* sleep a little to allow audio buffer to drain */
+		naptime = BELL_MS * i;
+		poll(NULL, 0, naptime);
+
+		i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
+		iovcnt = 0;
+		if ((written != -1) && (i > 0)) {
+		    iov[iovcnt].iov_base = ((char *) samples) + i;
+		    iov[iovcnt++].iov_len = sizeof(samples) - i;
+		}
+	    } else {
+		iovcnt = 0;
+	    }
+	}
+    }
+    
+    close(audioFD);
+    return 0;
+}
+
+#endif /* AUDIO_BELL */
+
+_X_HIDDEN void
+sunKbdSoundBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
+{
+    int	kbdCmd, i;
+
+    if (loudness && pitch)
+    {
+#ifdef AUDIO_BELL
+	if (priv->audioDevName != NULL) {
+	    if (sunKbdAudioBell(priv, loudness, pitch, duration) == 0) {
+		return;
+	    }
+	}
+#endif
+	
+ 	kbdCmd = KBD_CMD_BELL;
+		
+	SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
+	if (i < 0) {
+	    xf86Msg(X_ERROR, "%s: Failed to activate bell: %s\n",
+                priv->devName, strerror(errno));
+	}
+	
+	usleep(duration * loudness * 20);
+	
+	kbdCmd = KBD_CMD_NOBELL;
+	SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
+	if (i < 0) {
+	     xf86Msg(X_ERROR, "%s: Failed to deactivate bell: %s\n",
+                priv->devName, strerror(errno));
+	}
+    }
+}
+
+_X_HIDDEN void
+sunKbdSetLeds(sunKbdPrivPtr priv, int leds)
+{
+    int i;
+	
+    SYSCALL(i = ioctl(priv->kbdFD, KIOCSLED, &leds));
+    if (i < 0) {
+	xf86Msg(X_ERROR, "%s: Failed to set keyboard LED's: %s\n",
+                priv->devName, strerror(errno));
+    }
+}
+
+_X_HIDDEN int
+sunKbdGetLeds(sunKbdPrivPtr priv)
+{
+    int i, leds = 0;
+
+    SYSCALL(i = ioctl(priv->kbdFD, KIOCGLED, &leds));
+    if (i < 0) {
+        xf86Msg(X_ERROR, "%s: Failed to get keyboard LED's: %s\n",
+                priv->devName, strerror(errno));
+    }
+    return leds;
+}
+
+/* ARGSUSED0 */
+_X_HIDDEN void
+sunKbdSetRepeat(sunKbdPrivPtr priv, char rad)
+{
+    /* Nothing to do */
+}
+
+/***************************************************************************
+ * Routines called from "kbd" driver via proc vectors filled in by
+ * xf86OSKbdPreInit().
+ */
+
+
+static int
+KbdInit(InputInfoPtr pInfo, int what)
+{
+    /* Does nothing now - sunKbdInit called from OpenKeyboard instead */
+    return Success;
+}
+
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+    return sunKbdOn(priv);
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+    return sunKbdOff(priv);
+}
+
+
+static void
+SoundKbdBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+    sunKbdSoundBell(priv, loudness, pitch, duration);
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+    int real_leds = sunKbdGetLeds(priv);
+
+    real_leds &= ~(LED_CAPS_LOCK | LED_NUM_LOCK | LED_SCROLL_LOCK | LED_COMPOSE);
+
+    if (leds & XLED1)  real_leds |= LED_CAPS_LOCK;
+    if (leds & XLED2)  real_leds |= LED_NUM_LOCK;
+    if (leds & XLED3)  real_leds |= LED_SCROLL_LOCK;
+    if (leds & XLED4)  real_leds |= LED_COMPOSE;
+    
+    sunKbdSetLeds(priv, real_leds);
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+    int leds = 0;
+    int real_leds = sunKbdGetLeds(priv);
+
+    if (real_leds & LED_CAPS_LOCK)	leds |= XLED1;
+    if (real_leds & LED_NUM_LOCK)	leds |= XLED2;
+    if (real_leds & LED_SCROLL_LOCK)	leds |= XLED3;
+    if (real_leds & LED_COMPOSE)	leds |= XLED4;
+	
+    return leds;
+}
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+    
+    sunKbdSetRepeat(priv, rad);
+}
+
+static void
+KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+    /* Should probably do something better here */
+    xf86KbdGetMapping(pKeySyms, pModMap);
+}
+
+static void
+ReadInput(InputInfoPtr pInfo)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+    Firm_event event[64];
+    int        nBytes, i;
+
+    /* I certainly hope its not possible to read partial events */
+
+    if ((nBytes = read(pInfo->fd, (char *)event, sizeof(event))) > 0)
+    {
+        for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) {
+	    pKbd->PostEvent(pInfo, priv->keyMap[event[i].id],
+			    event[i].value == VKEY_DOWN ? TRUE : FALSE);
+	}
+    }
+}
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+    pInfo->fd = sunKbdOpen(pInfo->name, pInfo->options);
+
+    if (pInfo->fd >= 0) {
+	KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+	sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+	if (sunKbdInit(priv, pInfo->fd, pInfo->name, pInfo->options)
+	    != Success) {
+	    close(pInfo->fd);
+	    pInfo->fd = -1;
+	    return FALSE;
+	}
+#ifdef SUNSOFT
+# ifdef XKB
+	else {
+	    /* Probe keyboard settings if not specified in configuration */
+	    char *xkbkeymap = NULL, *xkbmodel = NULL, *xkblayout = NULL;
+	    int i, found;
+	    
+	    const char *kbdDefaults[] = {
+		"Protocol",         "standard",
+		"AutoRepeat",       "500 30",
+		"XkbRules",         "xorg",
+		"XkbModel",         "pc105",
+		"XkbLayout",        "us",
+		"Panix106",         "off",
+		"CustomKeycodes",   "off",
+		NULL, NULL, 	    /* leave room to add XkbKeymap if needed */
+		NULL 		    /* list terminator */
+	    };
+	    
+	    sun_find_xkbnames(priv->ktype, priv->klayout,
+			      &xkbkeymap, &xkbmodel, &xkblayout);
+
+#define SetXkbDefaults(OPTION, VALUE) \
+	if (VALUE != NULL) { \
+	    for (i = 0, found = 0; kbdDefaults[i] != NULL; i += 2) { \
+		if (strcmp(kbdDefaults[i], OPTION) == 0) { \
+		    kbdDefaults[i+1] = VALUE; found++; \
+		    xf86Msg(X_PROBED, "%s: %s = %s\n", priv->devName, \
+			    OPTION, VALUE); \
+		    break; \
+		} \
+	    } \
+	}
+	    
+#define AddXkbDefaults(OPTION, VALUE) \
+	if (VALUE != NULL) { \
+	    for (i = 0; kbdDefaults[i] != NULL; i += 2) \
+	    { /* skip to end */ ; } \
+	    kbdDefaults[i++] = OPTION; \
+	    kbdDefaults[i++] = VALUE; \
+	}
+
+	    SetXkbDefaults("XkbModel", xkbmodel);
+	    SetXkbDefaults("XkbLayout", xkblayout);
+	    AddXkbDefaults("XkbKeymap", xkbkeymap);
+
+	    xf86CollectInputOptions(pInfo, kbdDefaults, NULL);
+	}
+# endif
+#endif
+	pInfo->read_input = ReadInput;
+	return TRUE;
+    } else {
+	return FALSE;
+    }
+}
+
+_X_EXPORT Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+    KbdDevPtr pKbd = pInfo->private;
+
+    pKbd->KbdInit       = KbdInit;
+    pKbd->KbdOn         = KbdOn;
+    pKbd->KbdOff        = KbdOff;
+    pKbd->Bell          = SoundKbdBell;
+    pKbd->SetLeds       = SetKbdLeds;
+    pKbd->GetLeds       = GetKbdLeds;
+    pKbd->SetKbdRepeat  = SetKbdRepeat;
+    pKbd->KbdGetMapping = KbdGetMapping;
+
+    pKbd->RemapScanCode = NULL;
+    pKbd->GetSpecialKey = NULL;
+    pKbd->SpecialKey    = NULL;
+
+    pKbd->OpenKeyboard = OpenKeyboard;
+
+    pKbd->vtSwitchSupported = FALSE;
+    pKbd->CustomKeycodes = FALSE;
+
+    pKbd->private = xcalloc(sizeof(sunKbdPrivRec), 1);
+    if (pKbd->private == NULL) {
+       xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+       return FALSE;
+    } else {
+	sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+	priv->otranslation = -1;
+	priv->odirect = -1;
+    }
+
+    return TRUE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,73 @@
+/* Copyright 2005 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.
+ */
+
+#ifndef _XORG_SUN_KBD_H_
+#define _XORG_SUN_KBD_H_
+
+/*
+ * Keyboard common implementation routines shared by "keyboard" driver
+ * in sun_io.c and "kbd" driver in sun_kbd.c
+ */
+
+typedef struct {
+    int			kbdFD;
+    const char *	devName;
+    int 		ktype;		/* Keyboard type from KIOCTYPE */
+    int 		klayout;	/* Keyboard layout from KIOCLAYOUT */
+    Bool		kbdActive;	/* Have we set kbd modes for X? */
+    int 		otranslation;	/* Original translation mode */
+    int 		odirect;	/* Original "direct" mode setting */
+    unsigned char	oleds;		/* Original LED state */
+    const char *	strmod;		/* Streams module pushed on kbd device */
+    const char *	audioDevName;	/* Audio device path to use for bell
+					   or NULL to use keyboard beeper */
+    enum {AB_INITIALIZING, AB_NORMAL} audioState;
+    const unsigned char *keyMap;
+} sunKbdPrivRec, *sunKbdPrivPtr;
+
+/* sun_kbd.c */
+extern int  sunKbdOpen	(const char *devName, pointer options);
+extern int  sunKbdInit	(sunKbdPrivPtr priv, int kbdFD,
+			 const char *devName, pointer options);
+extern int  sunKbdOn	(sunKbdPrivPtr priv);
+extern int  sunKbdOff	(sunKbdPrivPtr priv);
+    
+extern void sunKbdSoundBell 	(sunKbdPrivPtr priv,
+				 int loudness, int pitch, int duration);
+
+extern void sunKbdSetLeds 	(sunKbdPrivPtr priv, int leds);
+extern int  sunKbdGetLeds 	(sunKbdPrivPtr priv);
+extern void sunKbdSetRepeat 	(sunKbdPrivPtr priv, char rad);
+
+/* sun_kbdEv.c */
+#include <sys/vuid_event.h>
+extern void sunPostKbdEvent	(int ktype, Firm_event *event);
+
+extern const unsigned char *sunGetKbdMapping(int ktype);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,902 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.5 2003/08/26 19:00:36 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Copyright 1993 by David Dawes <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the 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 Thomas Roell and David Dawes not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Thomas Roell and David Dawes make no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* [JCH-96/01/21] Extended std reverse map to four buttons. */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.5 2005/05/21 07:46:37 alanc Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "sun_kbd.h"
+
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "xf86Xinput.h"
+#else
+#include "inputstr.h"
+#endif
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#include <sys/kbd.h>
+#include "atKeynames.h"
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+#define XE_POINTER  1
+#define XE_KEYBOARD 2
+
+#ifdef XTESTEXT1
+
+#define	XTestSERVER_SIDE
+#include <X11/extensions/xtestext1.h>
+extern short xtest_mousex;
+extern short xtest_mousey;
+extern int   on_steal_input;
+extern Bool  XTestStealKeyData();
+extern void  XTestStealMotionData();
+
+#ifdef XINPUT
+#define ENQUEUE(ev, code, direction, dev_type) \
+  (ev)->u.u.detail = (code); \
+  (ev)->u.u.type   = (direction); \
+  if (!on_steal_input ||  \
+      XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+			xtest_mousex, xtest_mousey)) \
+  xf86eqEnqueue((ev))
+#else
+#define ENQUEUE(ev, code, direction, dev_type) \
+  (ev)->u.u.detail = (code); \
+  (ev)->u.u.type   = (direction); \
+  if (!on_steal_input ||  \
+      XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+			xtest_mousex, xtest_mousey)) \
+  mieqEnqueue((ev))
+#endif
+
+#else /* ! XTESTEXT1 */
+
+#ifdef XINPUT
+#define ENQUEUE(ev, code, direction, dev_type) \
+  (ev)->u.u.detail = (code); \
+  (ev)->u.u.type   = (direction); \
+  xf86eqEnqueue((ev))
+#else
+#define ENQUEUE(ev, code, direction, dev_type) \
+  (ev)->u.u.detail = (code); \
+  (ev)->u.u.type   = (direction); \
+  mieqEnqueue((ev))
+#endif
+
+#endif
+
+static void startautorepeat(long keycode);
+static CARD32 processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg);
+
+static OsTimerPtr sunTimer = NULL;
+
+/* Map the Solaris keycodes to the "XFree86" keycodes. */
+/*
+ * This doesn't seem right.  It probably needs to be dependent on a keyboard
+ * type.
+ */
+
+/* Additional Sun Japanese Keyboard Keys not defined in common/atKeynames.h */
+#define KEY_Kanji	0x82
+#define KEY_Execute	0x83
+
+#ifdef SUNSOFT
+/* On Solaris we swap the modifier numbers for AltGraph & NumLock from the
+ * values listed in common/atKeynames.h
+ */
+#undef NumLockMask
+#undef AltLangMask
+#define NumLockMask     Mod3Mask
+#define AltLangMask     Mod2Mask
+#endif SUNSOFT
+
+static unsigned char map[256] = {
+#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__x86)
+	KEY_NOTUSED,		/*   0 */
+	KEY_Tilde,		/*   1 */
+	KEY_1,			/*   2 */
+	KEY_2,			/*   3 */
+	KEY_3,			/*   4 */
+	KEY_4,			/*   5 */
+	KEY_5,			/*   6 */
+	KEY_6,			/*   7 */
+	KEY_7,			/*   8 */
+	KEY_8,			/*   9 */
+	KEY_9,			/*  10 */
+	KEY_0,			/*  11 */
+	KEY_Minus,		/*  12 */
+	KEY_Equal,		/*  13 */
+	0x7D, /*KEY_P_YEN*/	/*  14 */
+	KEY_BackSpace,		/*  15 */
+	KEY_Tab,		/*  16 */
+	KEY_Q,			/*  17 */
+	KEY_W,			/*  18 */
+	KEY_E,			/*  19 */
+	KEY_R,			/*  20 */
+	KEY_T,			/*  21 */
+	KEY_Y,			/*  22 */
+	KEY_U,			/*  23 */
+	KEY_I,			/*  24 */
+	KEY_O,			/*  25 */
+	KEY_P,			/*  26 */
+	KEY_LBrace,		/*  27 */
+	KEY_RBrace,		/*  28 */
+	KEY_BSlash,		/*  29 */
+	KEY_CapsLock,		/*  30 */
+	KEY_A,			/*  31 */
+	KEY_S,			/*  32 */
+	KEY_D,			/*  33 */
+	KEY_F,			/*  34 */
+	KEY_G,			/*  35 */
+	KEY_H,			/*  36 */
+	KEY_J,			/*  37 */
+	KEY_K,			/*  38 */
+	KEY_L,			/*  39 */
+	KEY_SemiColon,		/*  40 */
+	KEY_Quote,		/*  41 */
+	KEY_UNKNOWN,		/*  42 */
+	KEY_Enter,		/*  43 */
+	KEY_ShiftL,		/*  44 */
+	KEY_Less,		/*  45 */
+	KEY_Z,			/*  46 */
+	KEY_X,			/*  47 */
+	KEY_C,			/*  48 */
+	KEY_V,			/*  49 */
+	KEY_B,			/*  50 */
+	KEY_N,			/*  51 */
+	KEY_M,			/*  52 */
+	KEY_Comma,		/*  53 */
+	KEY_Period,		/*  54 */
+	KEY_Slash,		/*  55 */
+	KEY_BSlash2,		/*  56 */
+	KEY_ShiftR,		/*  57 */
+	KEY_LCtrl,		/*  58 */
+	KEY_LMeta,		/*  59 */
+	KEY_Alt,		/*  60 */
+	KEY_Space,		/*  61 */
+	KEY_AltLang,		/*  62 */
+	KEY_RMeta,		/*  63 */
+	KEY_RCtrl,		/*  64 */
+	KEY_Menu,		/*  65 */
+	KEY_UNKNOWN,		/*  66 */
+	KEY_UNKNOWN,		/*  67 */
+	KEY_UNKNOWN,		/*  68 */
+	KEY_UNKNOWN,		/*  69 */
+	KEY_UNKNOWN,		/*  70 */
+	KEY_UNKNOWN,		/*  71 */
+	KEY_UNKNOWN,		/*  72 */
+	KEY_UNKNOWN,		/*  73 */
+	KEY_UNKNOWN,		/*  74 */
+	KEY_Insert,		/*  75 */
+	KEY_Delete,		/*  76 */
+	KEY_UNKNOWN,		/*  77 */
+	KEY_UNKNOWN,		/*  78 */
+	KEY_Left,		/*  79 */
+	KEY_Home,		/*  80 */
+	KEY_End,		/*  81 */
+	KEY_UNKNOWN,		/*  82 */
+	KEY_Up,			/*  83 */
+	KEY_Down,		/*  84 */
+	KEY_PgUp,		/*  85 */
+	KEY_PgDown,		/*  86 */
+	KEY_UNKNOWN,		/*  87 */
+	KEY_UNKNOWN,		/*  88 */
+	KEY_Right,		/*  89 */
+	KEY_NumLock,		/*  90 */
+	KEY_KP_7,		/*  91 */
+	KEY_KP_4,		/*  92 */
+	KEY_KP_1,		/*  93 */
+	KEY_UNKNOWN,		/*  94 */
+	KEY_KP_Divide,		/*  95 */
+	KEY_KP_8,		/*  96 */
+	KEY_KP_5,		/*  97 */
+	KEY_KP_2,		/*  98 */
+	KEY_KP_0,		/*  99 */
+	KEY_KP_Multiply,	/* 100 */
+	KEY_KP_9,		/* 101 */
+	KEY_KP_6,		/* 102 */
+	KEY_KP_3,		/* 103 */
+	KEY_KP_Decimal,		/* 104 */
+	KEY_KP_Minus,		/* 105 */
+	KEY_KP_Plus,		/* 106 */
+	KEY_UNKNOWN,		/* 107 */
+	KEY_KP_Enter,		/* 108 */
+	KEY_UNKNOWN,		/* 109 */
+	KEY_Escape,		/* 110 */
+	KEY_UNKNOWN,		/* 111 */
+	KEY_F1,			/* 112 */
+	KEY_F2,			/* 113 */
+	KEY_F3,			/* 114 */
+	KEY_F4,			/* 115 */
+	KEY_F5,			/* 116 */
+	KEY_F6,			/* 117 */
+	KEY_F7,			/* 118 */
+	KEY_F8,			/* 119 */
+	KEY_F9,			/* 120 */
+	KEY_F10,		/* 121 */
+	KEY_F11,		/* 122 */
+	KEY_F12,		/* 123 */
+	KEY_Print,		/* 124 */
+	KEY_ScrollLock,		/* 125 */
+	KEY_Pause,		/* 126 */
+	KEY_UNKNOWN,		/* 127 */
+	KEY_UNKNOWN,		/* 128 */
+	KEY_UNKNOWN,		/* 129 */
+	KEY_UNKNOWN,		/* 130 */
+	KEY_NFER,		/* 131 */
+	KEY_XFER,		/* 132 */
+	KEY_HKTG,		/* 133 */
+	KEY_UNKNOWN,		/* 134 */
+#elif defined(sparc) || defined(__sparc__)
+	KEY_UNKNOWN,		/* 0x00 */
+	KEY_UNKNOWN,		/* 0x01 */
+	KEY_UNKNOWN,		/* 0x02 */
+	KEY_UNKNOWN,		/* 0x03 */
+	KEY_UNKNOWN,		/* 0x04 */
+	KEY_F1,			/* 0x05 */
+	KEY_F2,			/* 0x06 */
+	KEY_F10,		/* 0x07 */
+	KEY_F3,			/* 0x08 */
+	KEY_F11,		/* 0x09 */
+	KEY_F4,			/* 0x0A */
+	KEY_F12,		/* 0x0B */
+	KEY_F5,			/* 0x0C */
+	KEY_UNKNOWN,		/* 0x0D */
+	KEY_F6,			/* 0x0E */
+	KEY_UNKNOWN,		/* 0x0F */
+	KEY_F7,			/* 0x10 */
+	KEY_F8,			/* 0x11 */
+	KEY_F9,			/* 0x12 */
+	KEY_Alt,		/* 0x13 */
+	KEY_Up,			/* 0x14 */
+	KEY_Pause,		/* 0x15 */
+	KEY_SysReqest,		/* 0x16 */
+	KEY_ScrollLock,		/* 0x17 */
+	KEY_Left,		/* 0x18 */
+	KEY_UNKNOWN,		/* 0x19 */
+	KEY_UNKNOWN,		/* 0x1A */
+	KEY_Down,		/* 0x1B */
+	KEY_Right,		/* 0x1C */
+	KEY_Escape,		/* 0x1D */
+	KEY_1,			/* 0x1E */
+	KEY_2,			/* 0x1F */
+	KEY_3,			/* 0x20 */
+	KEY_4,			/* 0x21 */
+	KEY_5,			/* 0x22 */
+	KEY_6,			/* 0x23 */
+	KEY_7,			/* 0x24 */
+	KEY_8,			/* 0x25 */
+	KEY_9,			/* 0x26 */
+	KEY_0,			/* 0x27 */
+	KEY_Minus,		/* 0x28 */
+	KEY_Equal,		/* 0x29 */
+	KEY_Tilde,		/* 0x2A */
+	KEY_BackSpace,		/* 0x2B */
+	KEY_Insert,		/* 0x2C */
+	KEY_UNKNOWN,		/* 0x2D */
+	KEY_KP_Divide,		/* 0x2E */
+	KEY_KP_Multiply,	/* 0x2F */
+	KEY_UNKNOWN,		/* 0x30 */
+	KEY_UNKNOWN,		/* 0x31 */
+	KEY_KP_Decimal,		/* 0x32 */
+	KEY_UNKNOWN,		/* 0x33 */
+	KEY_Home,		/* 0x34 */
+	KEY_Tab,		/* 0x35 */
+	KEY_Q,			/* 0x36 */
+	KEY_W,			/* 0x37 */
+	KEY_E,			/* 0x38 */
+	KEY_R,			/* 0x39 */
+	KEY_T,			/* 0x3A */
+	KEY_Y,			/* 0x3B */
+	KEY_U,			/* 0x3C */
+	KEY_I,			/* 0x3D */
+	KEY_O,			/* 0x3E */
+	KEY_P,			/* 0x3F */
+	KEY_LBrace,		/* 0x40 */
+	KEY_RBrace,		/* 0x41 */
+	KEY_Delete,		/* 0x42 */
+	KEY_UNKNOWN,		/* 0x43 */
+	KEY_KP_7,		/* 0x44 */
+	KEY_KP_8,		/* 0x45 */
+	KEY_KP_9,		/* 0x46 */
+	KEY_KP_Minus,		/* 0x47 */
+	KEY_UNKNOWN,		/* 0x48 */
+	KEY_UNKNOWN,		/* 0x49 */
+	KEY_End,		/* 0x4A */
+	KEY_UNKNOWN,		/* 0x4B */
+	KEY_LCtrl,		/* 0x4C */
+	KEY_A,			/* 0x4D */
+	KEY_S,			/* 0x4E */
+	KEY_D,			/* 0x4F */
+	KEY_F,			/* 0x50 */
+	KEY_G,			/* 0x51 */
+	KEY_H,			/* 0x52 */
+	KEY_J,			/* 0x53 */
+	KEY_K,			/* 0x54 */
+	KEY_L,			/* 0x55 */
+	KEY_SemiColon,		/* 0x56 */
+	KEY_Quote,		/* 0x57 */
+	KEY_BSlash,		/* 0x58 */
+	KEY_Enter,		/* 0x59 */
+	KEY_KP_Enter,		/* 0x5A */
+	KEY_KP_4,		/* 0x5B */
+	KEY_KP_5,		/* 0x5C */
+	KEY_KP_6,		/* 0x5D */
+	KEY_KP_0,		/* 0x5E */
+	KEY_UNKNOWN,		/* 0x5F */
+	KEY_PgUp,		/* 0x60 */
+	KEY_UNKNOWN,		/* 0x61 */
+	KEY_NumLock,		/* 0x62 */
+	KEY_ShiftL,		/* 0x63 */
+	KEY_Z,			/* 0x64 */
+	KEY_X,			/* 0x65 */
+	KEY_C,			/* 0x66 */
+	KEY_V,			/* 0x67 */
+	KEY_B,			/* 0x68 */
+	KEY_N,			/* 0x69 */
+	KEY_M,			/* 0x6A */
+	KEY_Comma,		/* 0x6B */
+	KEY_Period,		/* 0x6C */
+	KEY_Slash,		/* 0x6D */
+	KEY_ShiftR,		/* 0x6E */
+	KEY_UNKNOWN,		/* 0x6F */
+	KEY_KP_1,		/* 0x70 */
+	KEY_KP_2,		/* 0x71 */
+	KEY_KP_3,		/* 0x72 */
+	KEY_UNKNOWN,		/* 0x73 */
+	KEY_UNKNOWN,		/* 0x74 */
+	KEY_UNKNOWN,		/* 0x75 */
+	KEY_UNKNOWN,		/* 0x76 */
+	KEY_CapsLock,		/* 0x77 */
+	KEY_LMeta,		/* 0x78 */
+	KEY_Space,		/* 0x79 */
+	KEY_RMeta,		/* 0x7A */
+	KEY_PgDown,		/* 0x7B */
+	KEY_UNKNOWN,		/* 0x7C */
+	KEY_KP_Plus,		/* 0x7D */
+	KEY_UNKNOWN,		/* 0x7E */
+	KEY_UNKNOWN,		/* 0x7F */
+#endif
+	/* The rest default to KEY_UNKNOWN */
+};
+
+#if defined(KB_USB)
+static unsigned char usbmap[256] = {
+/*
+ * partially taken from ../bsd/bsd_KbdMap.c
+ *
+ * added keycodes for Sun special keys (left function keys, audio control)
+ */
+	/* 0 */ KEY_NOTUSED,
+	/* 1 */ KEY_NOTUSED,
+	/* 2 */ KEY_NOTUSED,
+	/* 3 */ KEY_NOTUSED,
+	/* 4 */ KEY_A,		
+	/* 5 */ KEY_B,
+	/* 6 */ KEY_C,
+	/* 7 */ KEY_D,
+	/* 8 */ KEY_E,
+	/* 9 */ KEY_F,
+	/* 10 */ KEY_G,
+	/* 11 */ KEY_H,
+	/* 12 */ KEY_I,
+	/* 13 */ KEY_J,
+	/* 14 */ KEY_K,
+	/* 15 */ KEY_L,
+	/* 16 */ KEY_M,
+	/* 17 */ KEY_N,
+	/* 18 */ KEY_O,
+	/* 19 */ KEY_P,
+	/* 20 */ KEY_Q,
+	/* 21 */ KEY_R,
+	/* 22 */ KEY_S,
+	/* 23 */ KEY_T,
+	/* 24 */ KEY_U,
+	/* 25 */ KEY_V,
+	/* 26 */ KEY_W,
+	/* 27 */ KEY_X,
+	/* 28 */ KEY_Y,
+	/* 29 */ KEY_Z,
+	/* 30 */ KEY_1,		/* 1 !*/
+	/* 31 */ KEY_2,		/* 2 @ */
+	/* 32 */ KEY_3,		/* 3 # */
+	/* 33 */ KEY_4,		/* 4 $ */
+	/* 34 */ KEY_5,		/* 5 % */
+	/* 35 */ KEY_6,		/* 6 ^ */
+	/* 36 */ KEY_7,		/* 7 & */
+	/* 37 */ KEY_8,		/* 8 * */
+	/* 38 */ KEY_9,		/* 9 ( */
+	/* 39 */ KEY_0,		/* 0 ) */
+	/* 40 */ KEY_Enter,	/* Return  */
+	/* 41 */ KEY_Escape,	/* Escape */
+	/* 42 */ KEY_BackSpace,	/* Backspace Delete */
+	/* 43 */ KEY_Tab,	/* Tab */
+	/* 44 */ KEY_Space,	/* Space */
+	/* 45 */ KEY_Minus,	/* - _ */
+	/* 46 */ KEY_Equal,	/* = + */
+	/* 47 */ KEY_LBrace,	/* [ { */
+	/* 48 */ KEY_RBrace,	/* ] } */
+	/* 49 */ KEY_BSlash,	/* \ | */
+	/* 50 */ KEY_BSlash,	/* \ _ # ~ on some keyboards */
+	/* 51 */ KEY_SemiColon,	/* ; : */
+	/* 52 */ KEY_Quote,	/* ' " */
+	/* 53 */ KEY_Tilde,	/* ` ~ */
+	/* 54 */ KEY_Comma,	/* , <  */
+	/* 55 */ KEY_Period,	/* . > */
+	/* 56 */ KEY_Slash,	/* / ? */
+	/* 57 */ KEY_CapsLock,	/* Caps Lock */
+	/* 58 */ KEY_F1,		/* F1 */
+	/* 59 */ KEY_F2,		/* F2 */
+	/* 60 */ KEY_F3,		/* F3 */
+	/* 61 */ KEY_F4,		/* F4 */
+	/* 62 */ KEY_F5,		/* F5 */
+	/* 63 */ KEY_F6,		/* F6 */
+	/* 64 */ KEY_F7,		/* F7 */
+	/* 65 */ KEY_F8,		/* F8 */
+	/* 66 */ KEY_F9,		/* F9 */
+	/* 67 */ KEY_F10,	/* F10 */
+	/* 68 */ KEY_F11,	/* F11 */
+	/* 69 */ KEY_F12,	/* F12 */
+	/* 70 */ KEY_Print,	/* PrintScrn SysReq */
+	/* 71 */ KEY_ScrollLock,	/* Scroll Lock */
+	/* 72 */ KEY_Pause,	/* Pause Break */
+	/* 73 */ KEY_Insert,	/* Insert XXX  Help on some Mac Keyboards */
+	/* 74 */ KEY_Home,	/* Home */
+	/* 75 */ KEY_PgUp,	/* Page Up */
+	/* 76 */ KEY_Delete,	/* Delete */
+	/* 77 */ KEY_End,	/* End */
+	/* 78 */ KEY_PgDown,	/* Page Down */
+	/* 79 */ KEY_Right,	/* Right Arrow */
+	/* 80 */ KEY_Left,	/* Left Arrow */
+	/* 81 */ KEY_Down,	/* Down Arrow */
+	/* 82 */ KEY_Up,		/* Up Arrow */
+	/* 83 */ KEY_NumLock,	/* Num Lock */
+	/* 84 */ KEY_KP_Divide,	/* Keypad / */
+	/* 85 */ KEY_KP_Multiply, /* Keypad * */
+	/* 86 */ KEY_KP_Minus,	/* Keypad - */
+	/* 87 */ KEY_KP_Plus,	/* Keypad + */
+	/* 88 */ KEY_KP_Enter,	/* Keypad Enter */
+	/* 89 */ KEY_KP_1,	/* Keypad 1 End */
+	/* 90 */ KEY_KP_2,	/* Keypad 2 Down */
+	/* 91 */ KEY_KP_3,	/* Keypad 3 Pg Down */
+	/* 92 */ KEY_KP_4,	/* Keypad 4 Left  */
+	/* 93 */ KEY_KP_5,	/* Keypad 5 */
+	/* 94 */ KEY_KP_6,	/* Keypad 6 */
+	/* 95 */ KEY_KP_7,	/* Keypad 7 Home */
+	/* 96 */ KEY_KP_8,	/* Keypad 8 Up */
+	/* 97 */ KEY_KP_9,	/* KEypad 9 Pg Up */
+	/* 98 */ KEY_KP_0,	/* Keypad 0 Ins */
+	/* 99 */ KEY_KP_Decimal,	/* Keypad . Del */
+	/* 100 */ KEY_Less,	/* < > on some keyboards */
+	/* 101 */ KEY_Menu,	/* Menu */
+	/* 102 */ KEY_Power,	/* Sun: Power */
+	/* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
+	/* 104 */ KEY_NOTUSED,
+	/* 105 */ KEY_NOTUSED,
+	/* 106 */ KEY_NOTUSED,
+	/* 107 */ KEY_NOTUSED,
+	/* 108 */ KEY_NOTUSED,
+	/* 109 */ KEY_NOTUSED,
+	/* 110 */ KEY_NOTUSED,
+	/* 111 */ KEY_NOTUSED,
+	/* 112 */ KEY_NOTUSED,
+	/* 113 */ KEY_NOTUSED,
+	/* 114 */ KEY_NOTUSED,
+	/* 115 */ KEY_NOTUSED,
+	/* 116 */ KEY_L7,	/* Sun: Open */
+	/* 117 */ KEY_Help,	/* Sun: Help */
+	/* 118 */ KEY_L3,	/* Sun: Props */
+	/* 119 */ KEY_L5,	/* Sun: Front */
+	/* 120 */ KEY_L1,	/* Sun: Stop */
+	/* 121 */ KEY_L2,	/* Sun: Again */
+	/* 122 */ KEY_L4,	/* Sun: Undo */
+	/* 123 */ KEY_L10,	/* Sun: Cut */
+	/* 124 */ KEY_L6,	/* Sun: Copy */
+	/* 125 */ KEY_L8,	/* Sun: Paste */
+	/* 126 */ KEY_L9,	/* Sun: Find */
+	/* 127 */ KEY_Mute,	/* Sun: AudioMute */
+	/* 128 */ KEY_AudioRaise,	/* Sun: AudioRaise */
+	/* 129 */ KEY_AudioLower,	/* Sun: AudioLower */
+	/* 130 */ KEY_NOTUSED,
+	/* 131 */ KEY_NOTUSED,
+	/* 132 */ KEY_NOTUSED,
+	/* 133 */ KEY_NOTUSED,
+	/* 134 */ KEY_NOTUSED,
+	/* 135 */ KEY_BSlash2,	/* Sun Japanese Kbd: Backslash / Underscore */
+	/* 136 */ KEY_XFER,	/* Sun Japanese Kbd: Henkan Mode */
+	/* 137 */ KEY_Yen,	/* Sun Japanese Kbd: Yen / Brokenbar */
+	/* 138 */ KEY_Kanji,	/* Sun Japanese Kbd: Kanji */
+	/* 139 */ KEY_Execute,	/* Sun Japanese Kbd: Execute */
+	/* 140 */ KEY_NOTUSED,
+	/* 141 */ KEY_NOTUSED,
+	/* 142 */ KEY_NOTUSED,
+	/* 143 */ KEY_NOTUSED,
+	/* 144 */ KEY_NOTUSED,
+	/* 145 */ KEY_NOTUSED,
+	/* 146 */ KEY_NOTUSED,
+	/* 147 */ KEY_NOTUSED,
+	/* 148 */ KEY_NOTUSED,
+	/* 149 */ KEY_NOTUSED,
+	/* 150 */ KEY_NOTUSED,
+	/* 151 */ KEY_NOTUSED,
+	/* 152 */ KEY_NOTUSED,
+	/* 153 */ KEY_NOTUSED,
+	/* 154 */ KEY_NOTUSED,
+	/* 155 */ KEY_NOTUSED,
+	/* 156 */ KEY_NOTUSED,
+	/* 157 */ KEY_NOTUSED,
+	/* 158 */ KEY_NOTUSED,
+	/* 159 */ KEY_NOTUSED,
+	/* 160 */ KEY_NOTUSED,
+	/* 161 */ KEY_NOTUSED,
+	/* 162 */ KEY_NOTUSED,
+	/* 163 */ KEY_NOTUSED,
+	/* 164 */ KEY_NOTUSED,
+	/* 165 */ KEY_NOTUSED,
+	/* 166 */ KEY_NOTUSED,
+	/* 167 */ KEY_NOTUSED,
+	/* 168 */ KEY_NOTUSED,
+	/* 169 */ KEY_NOTUSED,
+	/* 170 */ KEY_NOTUSED,
+	/* 171 */ KEY_NOTUSED,
+	/* 172 */ KEY_NOTUSED,
+	/* 173 */ KEY_NOTUSED,
+	/* 174 */ KEY_NOTUSED,
+	/* 175 */ KEY_NOTUSED,
+	/* 176 */ KEY_NOTUSED,
+	/* 177 */ KEY_NOTUSED,
+	/* 178 */ KEY_NOTUSED,
+	/* 179 */ KEY_NOTUSED,
+	/* 180 */ KEY_NOTUSED,
+	/* 181 */ KEY_NOTUSED,
+	/* 182 */ KEY_NOTUSED,
+	/* 183 */ KEY_NOTUSED,
+	/* 184 */ KEY_NOTUSED,
+	/* 185 */ KEY_NOTUSED,
+	/* 186 */ KEY_NOTUSED,
+	/* 187 */ KEY_NOTUSED,
+	/* 188 */ KEY_NOTUSED,
+	/* 189 */ KEY_NOTUSED,
+	/* 190 */ KEY_NOTUSED,
+	/* 191 */ KEY_NOTUSED,
+	/* 192 */ KEY_NOTUSED,
+	/* 193 */ KEY_NOTUSED,
+	/* 194 */ KEY_NOTUSED,
+	/* 195 */ KEY_NOTUSED,
+	/* 196 */ KEY_NOTUSED,
+	/* 197 */ KEY_NOTUSED,
+	/* 198 */ KEY_NOTUSED,
+	/* 199 */ KEY_NOTUSED,
+	/* 200 */ KEY_NOTUSED,
+	/* 201 */ KEY_NOTUSED,
+	/* 202 */ KEY_NOTUSED,
+	/* 203 */ KEY_NOTUSED,
+	/* 204 */ KEY_NOTUSED,
+	/* 205 */ KEY_NOTUSED,
+	/* 206 */ KEY_NOTUSED,
+	/* 207 */ KEY_NOTUSED,
+	/* 208 */ KEY_NOTUSED,
+	/* 209 */ KEY_NOTUSED,
+	/* 210 */ KEY_NOTUSED,
+	/* 211 */ KEY_NOTUSED,
+	/* 212 */ KEY_NOTUSED,
+	/* 213 */ KEY_NOTUSED,
+	/* 214 */ KEY_NOTUSED,
+	/* 215 */ KEY_NOTUSED,
+	/* 216 */ KEY_NOTUSED,
+	/* 217 */ KEY_NOTUSED,
+	/* 218 */ KEY_NOTUSED,
+	/* 219 */ KEY_NOTUSED,
+	/* 220 */ KEY_NOTUSED,
+	/* 221 */ KEY_NOTUSED,
+	/* 222 */ KEY_NOTUSED,
+	/* 223 */ KEY_NOTUSED,
+	/* 224 */ KEY_LCtrl,	/* Left Control */
+	/* 225 */ KEY_ShiftL,	/* Left Shift */
+	/* 226 */ KEY_Alt,	/* Left Alt */
+	/* 227 */ KEY_LMeta,	/* Left Meta */
+	/* 228 */ KEY_RCtrl,	/* Right Control */
+	/* 229 */ KEY_ShiftR,	/* Right Shift */
+	/* 230 */ KEY_AltLang,	/* Right Alt, AKA AltGr */
+	/* 231 */ KEY_RMeta,	/* Right Meta */
+};
+
+#endif /* KB_USB */
+
+_X_HIDDEN const unsigned char *
+sunGetKbdMapping(int ktype) {
+#if defined(KB_USB)
+    if (ktype == KB_USB)
+        return usbmap;
+    else
+#endif
+        return map;
+}
+
+
+/*
+ * sunPostKbdEvent --
+ *	Translate the raw hardware Firm_event into an XEvent, and tell DIX
+ *	about it. KeyCode preprocessing and so on is done ...
+ *
+ * Most of the Solaris stuff has whacked Panix/PC98 support in the
+ * interests of simplicity - DWH 8/30/99
+ */
+
+_X_HIDDEN void
+sunPostKbdEvent(int sun_ktype, Firm_event *event)
+{
+    Bool        down;
+    KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
+    Bool        updateLeds = FALSE;
+    xEvent      kevent;
+    KeySym      *keysym;
+    int         keycode;
+    static int  lockkeys = 0;
+
+    /* Give down a value */
+    if (event->value == VKEY_DOWN)
+	down = TRUE;
+    else
+	down = FALSE;
+
+
+#if defined(KB_USB)
+    if(sun_ktype == KB_USB)
+	keycode = usbmap[event->id];
+    else
+#endif
+	keycode = map[event->id];
+
+    /*
+     * and now get some special keysequences
+     */
+    
+#ifdef XKB
+    if (((xf86Info.ddxSpecialKeys == SKWhenNeeded) &&
+	 (!xf86Info.ActionKeyBindingsSet)) ||
+	noXkbExtension || (xf86Info.ddxSpecialKeys == SKAlways))
+#endif
+    {
+	if (!(ModifierDown(ShiftMask)) &&
+	    ((ModifierDown(ControlMask | AltMask)) ||
+	     (ModifierDown(ControlMask | AltLangMask))))
+	{
+	    switch (keycode) {
+	    /*
+	     * The idea here is to pass the scancode down to a list of 
+	     * registered routines.  There should be some standard conventions
+	     * for processing certain keys.
+	     */
+	    case KEY_BackSpace:
+		xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+		break;
+		
+	    /*
+	     * Check grabs
+	     */
+	    case KEY_KP_Divide:
+		xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
+		break;
+	    case KEY_KP_Multiply:
+		xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+		break;
+		
+	    /*
+	     * Video mode switches
+	     */
+	    case KEY_KP_Minus:   /* Keypad - */
+		if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+		if (!xf86Info.dontZoom) return;
+		break;
+		
+	    case KEY_KP_Plus:   /* Keypad + */
+		if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+		if (!xf86Info.dontZoom) return;
+		break;
+	    }
+	}
+    }
+
+    /*
+     * Now map the scancodes to real X-keycodes ...
+     */
+    if (keycode == KEY_NOTUSED) {
+	xf86MsgVerb(X_INFO, 0,
+	    "raw code %d mapped to KEY_NOTUSED -- please report\n", event->id);
+	return;
+    }
+    if (keycode == KEY_UNKNOWN) {
+	xf86MsgVerb(X_INFO, 0,
+	    "raw code %d mapped to KEY_UNKNOWN -- please report\n", event->id);
+	return;
+    }
+    keycode += MIN_KEYCODE;
+    keysym = keyc->curKeySyms.map +
+	     (keyc->curKeySyms.mapWidth *
+	      (keycode - keyc->curKeySyms.minKeyCode));
+
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+    {
+	/*
+	 * Toggle lock keys.
+	 */
+#define CAPSFLAG 0x01
+#define NUMFLAG 0x02
+#define SCROLLFLAG 0x04
+#define MODEFLAG 0x08
+
+	if (down) {
+	    /*
+	     * Handle the KeyPresses of the lock keys.
+	     */
+
+	    switch (keysym[0]) {
+
+	    case XK_Caps_Lock:
+		if (lockkeys & CAPSFLAG) {
+		    lockkeys &= ~CAPSFLAG;
+		    return;
+		}
+		lockkeys |= CAPSFLAG;
+		updateLeds = TRUE;
+		xf86Info.capsLock = down;
+		break;
+
+	    case XK_Num_Lock:
+		if (lockkeys & NUMFLAG) {
+		    lockkeys &= ~NUMFLAG;
+		    return;
+		}
+		lockkeys |= NUMFLAG;
+		updateLeds = TRUE;
+		xf86Info.numLock = down;
+		break;
+
+	    case XK_Scroll_Lock:
+		if (lockkeys & SCROLLFLAG) {
+		    lockkeys &= ~SCROLLFLAG;
+		    return;
+		}
+		lockkeys |= SCROLLFLAG;
+		updateLeds = TRUE;
+		xf86Info.scrollLock = down;
+		break;
+	    }
+	} else {
+	    /*
+	     * Handle the releases of the lock keys.
+	     */
+
+	    switch (keysym[0]) {
+
+	    case XK_Caps_Lock:
+		if (lockkeys & CAPSFLAG)
+		    return;
+		updateLeds = TRUE;
+		xf86Info.capsLock = down;
+		break;
+
+	    case XK_Num_Lock:
+		if (lockkeys & NUMFLAG)
+		    return;
+		updateLeds = TRUE;
+		xf86Info.numLock = down;
+		break;
+
+	    case XK_Scroll_Lock:
+		if (lockkeys & SCROLLFLAG)
+		    return;
+		updateLeds = TRUE;
+		xf86Info.scrollLock = down;
+		break;
+	    }
+	}
+
+  	if (updateLeds)
+	    xf86KbdLeds();
+
+	/*
+	 * If this keycode is not a modifier key, and its down initiate the
+	 * autorepeate sequence.  (Only necessary if not using XKB).
+	 *
+	 * If its not down, then reset the timer.
+	 */
+	if (!keyc->modifierMap[keycode]) {
+	    if (down) {
+		startautorepeat(keycode);
+	    } else {
+		TimerFree(sunTimer);
+		sunTimer = NULL;
+	    }
+  	}
+    }
+
+    xf86Info.lastEventTime =
+	kevent.u.keyButtonPointer.time =
+	    GetTimeInMillis();
+
+    /*
+     * And now send these prefixes ...
+     * NOTE: There cannot be multiple Mode_Switch keys !!!!
+     */
+
+    ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
+}
+
+
+
+/*
+ * Autorepeat stuff
+ */
+
+void
+startautorepeat(long keycode)
+{
+    sunTimer = TimerSet(sunTimer, 		/* Timer */
+			0, 			/* Flags */
+			xf86Info.kbdDelay,	/* millis */
+			processautorepeat,	/* callback */
+			(pointer) keycode);	/* arg for timer */
+}
+
+CARD32
+processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+    xEvent kevent;
+    int    keycode;
+
+    keycode = (long)arg;
+
+    xf86Info.lastEventTime =
+	kevent.u.keyButtonPointer.time =
+	    GetTimeInMillis();
+
+    /*
+     * Repeat a key by faking a KeyRelease, and a KeyPress event in rapid
+     * succession
+     */
+
+    ENQUEUE(&kevent, keycode,  KeyRelease, XE_KEYBOARD);
+    ENQUEUE(&kevent, keycode,  KeyPress, XE_KEYBOARD);
+
+    /* And return the appropriate value so we get rescheduled */
+    return xf86Info.kbdRate;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_loginfo.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,69 @@
+/* Copyright 2005 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.
+ */
+
+/*
+ * Custom hack for Solaris to report pkg/patch info - should not be put into
+ * X.Org Community release since they don't use our packages/patches, and
+ * since it cheats a bit to get the information quickly.   This could easily
+ * break because we're using private/undocumented interfaces which may change
+ * at any time, but since it's just displaying the information for human
+ * consumption by people reading the logfiles, and we don't depend on it in
+ * any way, we can live with that.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "os.h"
+
+_X_HIDDEN void
+sunLogInfo(void)
+{
+    char pibuf[16384]; /* Should be enough for even the longest patch list */
+    const char *pkgs[] = { "SUNWxorg-server", "SUNWxorg-graphics-ddx", NULL };
+    const char *p;
+    int i;
+    FILE *pkginfo;
+    
+    for (i = 0; pkgs[i] != NULL; i++) {
+	p = pkgs[i];
+	snprintf(pibuf, sizeof(pibuf), "/var/sadm/pkg/%s/pkginfo", p);
+	pkginfo = fopen(pibuf, "r");
+
+	if (pkginfo != NULL) {
+	    while(fgets(pibuf, sizeof(pibuf), pkginfo) != NULL) {
+		if (strncmp(pibuf, "VERSION=", 8) == 0) {
+		    ErrorF("%s package version: %s", p, pibuf+8);
+		} else if (strncmp(pibuf, "PATCHLIST=", 10) == 0) {
+		    ErrorF("%s patches applied: %s", p, pibuf+10);
+		}
+	    }
+	    fclose(pkginfo);
+	}
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,684 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.4 2002/01/25 21:56:21 tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.8 2005/07/28 02:38:23 alanc Exp $ */
+/*
+ * Copyright 1999-2001 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.
+ */
+/* Copyright 2004-2005 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.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSlib.h"
+#include "xf86OSmouse.h"
+
+#if defined(__SOL8__) || !defined(__i386)
+
+#include "xisb.h"
+#include "mipointer.h"
+#include <sys/stropts.h>
+#include <sys/vuid_event.h>
+#include <sys/msio.h>
+
+/* Wheel mouse support in VUID drivers in Solaris 9 updates & Solaris 10 */
+#ifdef WHEEL_DEVID /* Defined in vuid_event.h if VUID wheel support present */
+# define HAVE_VUID_WHEEL
+#endif
+#ifdef HAVE_VUID_WHEEL
+# include <sys/vuid_wheel.h>
+#endif
+
+/* Support for scaling absolute coordinates to screen size in 
+ * Solaris 10 updates and beyond */
+#if !defined(HAVE_ABSOLUTE_MOUSE_SCALING)
+# ifdef MSIOSRESOLUTION /* Defined in msio.h if scaling support present */
+#  define HAVE_ABSOLUTE_MOUSE_SCALING
+# endif
+#endif
+
+/* Names of protocols that are handled internally here. */
+
+static const char *internalNames[] = {
+	"VUID",
+	NULL
+};
+
+static const char *solarisMouseDevs[] = {
+    /* Device file:	Protocol: 			*/
+    "/dev/mouse",	"VUID",		/* USB or SPARC */
+#if defined(__i386) || defined(__x86)
+    "/dev/kdmouse",	"PS/2",		/* PS/2 */
+#endif
+    NULL
+};
+
+typedef struct _VuidMseRec {
+    struct _VuidMseRec *next;    
+    InputInfoPtr	pInfo;
+    Firm_event 		event;
+    unsigned char *	buffer;
+    char *		strmod;
+    Bool(*wrapped_device_control)(DeviceIntPtr device, int what);
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+    Ms_screen_resolution	 absres;
+#endif
+} VuidMseRec, *VuidMsePtr;
+
+static VuidMsePtr	vuidMouseList = NULL;
+
+static int  vuidMouseProc(DeviceIntPtr pPointer, int what);
+static void vuidReadInput(InputInfoPtr pInfo);
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse);
+static void vuidMouseAdjustFrame(int index, int x, int y, int flags);
+
+static int vuidMouseGeneration = 0;
+static int vuidMouseScreenIndex;
+#define vuidMouseScreenPrivate(s) ((s)->devPrivates[vuidMouseScreenIndex].ptr)
+#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
+
+static inline
+VuidMsePtr getVuidMsePriv(InputInfoPtr pInfo)
+{
+    VuidMsePtr m = vuidMouseList;
+
+    while ((m != NULL) && (m->pInfo != pInfo)) {
+	m = m->next;
+    }
+
+    return m;
+}
+
+
+/*
+ * Initialize and enable the mouse wheel, if present.
+ *
+ * Returns 1 if mouse wheel was successfully enabled.
+ * Returns 0 if an error occurred or if there is no mouse wheel.
+ */
+static int
+vuidMouseWheelInit(InputInfoPtr pInfo)
+{
+#ifdef HAVE_VUID_WHEEL
+    wheel_state wstate;
+    int nwheel = -1;
+    int i;
+
+    wstate.vers = VUID_WHEEL_STATE_VERS;
+    wstate.id = 0;
+    wstate.stateflags = -1;
+
+    SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel));
+    if (i != 0)
+	return (0);
+
+    SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate));
+    if (i != 0) {
+	xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name);
+	return (0);
+    }
+
+    wstate.stateflags |= VUID_WHEEL_STATE_ENABLED;
+
+    SYSCALL(i = ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate));
+    if (i != 0) {
+	xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name);
+	return (0);
+    }
+
+    return (1);
+#else
+    return (0);
+#endif
+}
+
+
+/* This function is called when the protocol is "VUID". */
+static Bool
+vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+    MouseDevPtr pMse = pInfo->private;
+    VuidMsePtr pVuidMse;
+    int buttons, i;
+
+    pVuidMse = xcalloc(sizeof(VuidMseRec), 1);
+    if (pVuidMse == NULL) {
+	xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name);
+	xfree(pMse);
+	return FALSE;
+    }
+
+    pMse->protocol = protocol;
+    xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+    /* Collect the options, and process the common options. */
+    xf86CollectInputOptions(pInfo, NULL, NULL);
+    xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+    /* Check if the device can be opened. */
+    pInfo->fd = xf86OpenSerial(pInfo->options);
+    if (pInfo->fd == -1) {
+	if (xf86GetAllowMouseOpenFail())
+	    xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+	else {
+	    xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+	    xfree(pVuidMse);
+	    xfree(pMse);
+	    return FALSE;
+	}
+    }
+
+    pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
+
+    pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL);
+    if (pVuidMse->strmod) {
+	SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
+ 	if (i < 0) {
+	    xf86Msg(X_ERROR,
+		    "%s: cannot push module '%s' onto mouse device: %s\n",
+		    pInfo->name, pVuidMse->strmod, strerror(errno));
+	    xf86CloseSerial(pInfo->fd);
+	    pInfo->fd = -1;
+	    xfree(pVuidMse->strmod);
+	    xfree(pVuidMse);
+	    xfree(pMse);
+	    return FALSE;
+	}
+    }
+
+    buttons = xf86SetIntOption(pInfo->options, "Buttons", 0);
+    if (buttons == 0) {
+	SYSCALL(i = ioctl(pInfo->fd, MSIOBUTTONS, &buttons));
+	if (i == 0) {
+	    pInfo->conf_idev->commonOptions =
+		xf86ReplaceIntOption(pInfo->conf_idev->commonOptions, 
+				     "Buttons", buttons);
+	    xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n",
+		    pInfo->name, buttons);
+	}
+    }
+
+    if (pVuidMse->strmod) { 
+	SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
+	if (i == -1) {
+	    xf86Msg(X_WARNING,
+		    "%s: cannot pop module '%s' off mouse device: %s\n",
+		    pInfo->name, pVuidMse->strmod, strerror(errno));
+	}
+    }
+
+    xf86CloseSerial(pInfo->fd);
+    pInfo->fd = -1;
+
+    /* Process common mouse options (like Emulate3Buttons, etc). */
+    pMse->CommonOptions(pInfo);
+
+    /* Setup the local procs. */
+    pVuidMse->wrapped_device_control = pInfo->device_control;
+    pInfo->device_control = vuidMouseProc;
+    pInfo->read_input = vuidReadInput;
+
+    pMse->xisbscale = sizeof(Firm_event);
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING    
+    pVuidMse->absres.height = pVuidMse->absres.width = 0;
+#endif
+    pVuidMse->pInfo = pInfo;
+    pVuidMse->next = vuidMouseList; 
+    vuidMouseList = pVuidMse;
+
+    pInfo->flags |= XI86_CONFIGURED;
+    return TRUE;
+}
+
+static void
+vuidFlushAbsEvents(InputInfoPtr pInfo, int absX, int absY, 
+		   Bool *absXset, Bool *absYset)
+{
+#ifdef DEBUG
+    ErrorF("vuidFlushAbsEvents: %d,%d (set: %d, %d)\n", absX, absY, 
+	   *absXset, *absYset);
+#endif
+    if ((*absXset) && (*absYset)) {
+	xf86PostMotionEvent(pInfo->dev, 
+			    /* is_absolute: */    TRUE,
+			    /* first_valuator: */ 0,
+			    /* num_valuators: */  2,
+			    absX, absY);
+    } else if (*absXset) {
+	xf86PostMotionEvent(pInfo->dev, 
+			    /* is_absolute: */    TRUE,
+			    /* first_valuator: */ 0,
+			    /* num_valuators: */  1,
+			    absX);
+    } else if (*absYset) {
+	xf86PostMotionEvent(pInfo->dev, 
+			    /* is_absolute: */    TRUE,
+			    /* first_valuator: */ 1,
+			    /* num_valuators: */  1,
+			    absY);
+    }
+
+    *absXset = FALSE;
+    *absYset = FALSE;
+}
+
+static void
+vuidReadInput(InputInfoPtr pInfo)
+{
+    MouseDevPtr pMse;
+    VuidMsePtr pVuidMse;
+    int buttons;
+    int dx = 0, dy = 0, dz = 0, dw = 0;
+    unsigned int n;
+    int c; 
+    unsigned char *pBuf;
+    int wmask;
+    int absX, absY;
+    Bool absXset = FALSE, absYset = FALSE;
+
+    pMse = pInfo->private;
+    pVuidMse = getVuidMsePriv(pInfo);
+    buttons = pMse->lastButtons;
+    XisbBlockDuration(pMse->buffer, -1);
+    pBuf = pVuidMse->buffer;
+    n = 0;
+
+    do {
+	while (n < sizeof(Firm_event) && (c = XisbRead(pMse->buffer)) >= 0) {
+	    pBuf[n++] = (unsigned char)c;
+	}
+
+	if (n == 0)
+	    return;
+
+	if (n != sizeof(Firm_event)) {
+	    xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n",
+			pInfo->name, n);
+	}
+
+#ifdef DEBUG
+	ErrorF("vuidReadInput: event type: %3d value: %5d\n",
+	       pVuidMse->event.id, pVuidMse->event.value);
+#endif
+
+	if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) {
+	    /* button */
+	    int butnum = pVuidMse->event.id - BUT_FIRST;
+
+	    if (butnum < 3)
+		butnum = 2 - butnum;
+	    if (!pVuidMse->event.value)
+		buttons &= ~(1 << butnum);
+	    else
+		buttons |= (1 << butnum);
+	} else if (pVuidMse->event.id >= VLOC_FIRST &&
+		   pVuidMse->event.id <= VLOC_LAST) {
+	    /* axis */
+	    int delta = pVuidMse->event.value;
+	    switch(pVuidMse->event.id) {
+	    case LOC_X_DELTA:
+		dx += delta;
+		break;
+	    case LOC_Y_DELTA:
+		dy -= delta;
+		break;
+	    case LOC_X_ABSOLUTE:
+		if (absXset) {
+		    vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+		}
+		absX = delta;
+		absXset = TRUE;
+		break;
+	    case LOC_Y_ABSOLUTE:
+		if (absYset) {
+		    vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+		}
+		absY = delta;
+		absYset = TRUE;
+		break;
+	    }
+	} 
+#ifdef HAVE_VUID_WHEEL
+	else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) {
+	    if (vuid_id_offset(pVuidMse->event.id) == 0)
+		dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+	    else
+		dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+	}
+#endif
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+	else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) {
+	    /* force sending absolute resolution scaling ioctl */
+	    pVuidMse->absres.height = pVuidMse->absres.width = 0;
+	    vuidMouseSendScreenSize(miPointerCurrentScreen(), pVuidMse);
+	}
+#endif
+
+	n = 0;
+	if ((c = XisbRead(pMse->buffer)) >= 0) {
+	    /* Another packet.  Handle it right away. */
+	    pBuf[n++] = c;
+	}
+    } while (n != 0);
+
+    if (absXset || absYset) {
+	vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+    }
+
+    pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+    return;
+}
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse)
+{
+    InputInfoPtr pInfo = pVuidMse->pInfo;
+    ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+    int result;
+
+    if ((pVuidMse->absres.width != pScr->currentMode->HDisplay) || 
+	(pVuidMse->absres.height != pScr->currentMode->VDisplay))
+    {
+	pVuidMse->absres.width = pScr->currentMode->HDisplay;
+	pVuidMse->absres.height = pScr->currentMode->VDisplay;
+
+	do {
+	    result = ioctl(pInfo->fd, MSIOSRESOLUTION, &(pVuidMse->absres));
+	} while ( (result != 0) && (errno == EINTR) );
+
+	if (result != 0) {
+	    xf86Msg(X_WARNING, 
+		    "%s: couldn't set absolute mouse scaling resolution: %s\n",
+		    pInfo->name, strerror(errno));
+#ifdef DEBUG
+	} else {
+	    xf86Msg(X_INFO, 
+		    "%s: absolute mouse scaling resolution set to %d x %d\n", 
+		    pInfo->name, 
+		    pVuidMse->absres.width, pVuidMse->absres.height);
+#endif
+	}
+    }
+}
+
+static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
+{
+      ScrnInfoPtr	pScrn = xf86Screens[index];
+      ScreenPtr		pScreen = pScrn->pScreen;
+      xf86AdjustFrameProc *wrappedAdjustFrame 
+	  = (xf86AdjustFrameProc *) vuidMouseScreenPrivate(pScreen);
+      VuidMsePtr	m;
+
+      if(wrappedAdjustFrame) {
+        pScrn->AdjustFrame = wrappedAdjustFrame;
+        (*pScrn->AdjustFrame)(index, x, y, flags);
+        pScrn->AdjustFrame = vuidMouseAdjustFrame;
+      }
+
+      if (miPointerCurrentScreen() == pScreen) {
+	  for (m = vuidMouseList; m != NULL ; m = m->next) {
+	      vuidMouseSendScreenSize(pScreen, m);
+	  }
+      }
+}
+#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
+
+
+static int
+vuidMouseProc(DeviceIntPtr pPointer, int what)
+{
+    InputInfoPtr pInfo;
+    MouseDevPtr pMse;
+    VuidMsePtr pVuidMse;
+    int ret = Success;
+    int i;
+
+    pInfo = pPointer->public.devicePrivate;
+    pMse = pInfo->private;
+    pMse->device = pPointer;
+
+    pVuidMse = getVuidMsePriv(pInfo);
+    if (pVuidMse == NULL) {
+	return BadImplementation;
+    }
+    
+    switch (what) {
+
+    case DEVICE_INIT:
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+	if (vuidMouseGeneration != serverGeneration) {
+	    if ((vuidMouseScreenIndex = AllocateScreenPrivateIndex()) >= 0) {
+		for (i = 0; i < screenInfo.numScreens; i++) {
+		    ScreenPtr pScreen = screenInfo.screens[i];
+		    ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+		    vuidMouseScreenPrivate(pScreen)
+			= (pointer) pScrn->AdjustFrame;
+		    pScrn->AdjustFrame = vuidMouseAdjustFrame;
+		}
+	    }
+	    vuidMouseGeneration = serverGeneration;
+	}
+#endif    	
+	ret = pVuidMse->wrapped_device_control(pPointer, what);
+	break;
+	
+    case DEVICE_ON:
+	ret = pVuidMse->wrapped_device_control(pPointer, DEVICE_ON);
+
+	if ((ret == Success) && (pInfo->fd != -1)) {
+	    int fmt = VUID_FIRM_EVENT;
+	    
+	    if (pVuidMse->strmod) {
+		SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
+		if (i < 0) {
+		    xf86Msg(X_WARNING,
+			"%s: cannot push module '%s' onto mouse device: %s\n",
+			pInfo->name, pVuidMse->strmod, strerror(errno));
+		    xfree(pVuidMse->strmod);
+		    pVuidMse->strmod = NULL;
+		}
+	    }
+	    SYSCALL(i = ioctl(pInfo->fd, VUIDSFORMAT, &fmt));
+	    if (i < 0) {
+		xf86Msg(X_WARNING,
+			"%s: cannot set mouse device to VUID mode: %s\n",
+			pInfo->name, strerror(errno));
+	    }
+	    vuidMouseWheelInit(pInfo);
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING	    
+	    vuidMouseSendScreenSize(screenInfo.screens[0], pVuidMse);
+#endif	    
+	    xf86FlushInput(pInfo->fd);
+	}
+	break;
+
+    case DEVICE_OFF:
+    case DEVICE_CLOSE:
+	if (pInfo->fd != -1) {
+	    if (pVuidMse->strmod) {
+		SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
+		if (i == -1) {
+		    xf86Msg(X_WARNING,
+		      "%s: cannot pop module '%s' off mouse device: %s\n",
+		      pInfo->name, pVuidMse->strmod, strerror(errno));
+		}
+	    }
+	}
+	ret = pVuidMse->wrapped_device_control(pPointer, what);
+	break;
+
+    default: /* Should never be called, but just in case */
+	ret = pVuidMse->wrapped_device_control(pPointer, what);
+	break;
+    }
+    return ret;
+}
+
+static Bool
+sunMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+    /* The protocol is guaranteed to be one of the internalNames[] */
+    if (xf86NameCmp(protocol, "VUID") == 0) {
+	return vuidPreInit(pInfo, protocol, flags);
+    }
+    return TRUE;
+}    
+
+static const char **
+BuiltinNames(void)
+{
+    return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+    int i;
+
+    for (i = 0; internalNames[i]; i++)
+	if (xf86NameCmp(protocol, internalNames[i]) == 0)
+	    return TRUE;
+
+    return FALSE;
+}
+
+static const char *
+DefaultProtocol(void)
+{
+    return "Auto";
+}
+
+static Bool
+solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol, 
+	const char **device)
+{
+    *protocol = "VUID";
+    *device = "/dev/mouse";
+    return TRUE;
+}
+
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+    const char *pdev = NULL;
+    const char *pproto = NULL;
+    MouseDevPtr pMse = pInfo->private;
+
+    if (pInfo->fd == -1) {
+	/* probe to find device/protocol to use */
+	if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+	    /* Set the Device option. */
+	    pInfo->conf_idev->commonOptions =
+	     xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev);
+	    xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+	      pInfo->name, pdev);
+	}
+    } else if (pMse->protocolID == PROT_AUTO) {
+	pdev = xf86CheckStrOption(pInfo->conf_idev->commonOptions, 
+		"Device", NULL);
+	solarisMouseAutoProbe(pInfo, &pproto, &pdev);
+    }
+    return pproto;
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+    const char *pdev = NULL;
+    const char *pproto = protocol;
+
+    if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+	/* Set the Device option. */
+	pInfo->conf_idev->commonOptions =
+	  xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev);
+	xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+	  pInfo->name, pdev);
+    }
+    return pdev;
+}
+
+#else /* __SOL8__ || !__i386 */
+
+#undef MSE_MISC
+#define MSE_MISC 0
+
+#endif /* !__SOL8__ && __i386 */
+
+static int
+SupportedInterfaces(void)
+{
+    /* XXX This needs to be checked. */
+    return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_XPS2 | MSE_MISC;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+    OSMouseInfoPtr p;
+
+    p = xcalloc(sizeof(OSMouseInfoRec), 1);
+    if (!p)
+	return NULL;
+    p->SupportedInterfaces = SupportedInterfaces;
+#if defined(__SOL8__) || !defined(__i386)
+    p->BuiltinNames = BuiltinNames;
+    p->CheckProtocol = CheckProtocol;
+    p->PreInit = sunMousePreInit;
+    p->DefaultProtocol = DefaultProtocol;
+    p->SetupAuto = SetupAuto;
+    p->FindDevice = FindDevice;
+#endif
+    return p;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,262 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.2 2001/10/28 03:34:03 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h> /* get __x86 definition if not set by compiler */
+
+#if defined(i386) || defined(__x86)
+#define _NEED_SYSI86
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#ifdef SUNSOFT
+static int apertureDevFD_ro = -1;
+static int apertureDevFD_rw = -1;
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section 					   */
+/***************************************************************************/
+
+char *apertureDevName = NULL;
+
+Bool
+xf86LinearVidMem(void)
+{
+	int	mmapFd;
+
+	if (apertureDevName)
+	    return TRUE;
+
+	apertureDevName = "/dev/xsvc";
+	if ((mmapFd = open(apertureDevName, O_RDWR)) < 0)
+	{
+	    apertureDevName = "/dev/fbs/aperture";
+	    if((mmapFd = open(apertureDevName, O_RDWR)) < 0)
+	    {
+		xf86MsgVerb(X_WARNING, 0,
+		    "xf86LinearVidMem: failed to open %s (%s)\n",
+		    apertureDevName, strerror(errno));
+		xf86MsgVerb(X_WARNING, 0,
+		    "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc"
+		    " device driver required\n");
+		xf86MsgVerb(X_WARNING, 0,
+		    "xf86LinearVidMem: linear memory access disabled\n");
+		apertureDevName = NULL;
+		return FALSE;
+	    }
+	}
+#ifdef SUNSOFT
+	apertureDevFD_rw = mmapFd;
+	if ((apertureDevFD_ro = open(apertureDevName, O_RDONLY)) < 0)
+	{
+	  xf86MsgVerb(X_WARNING, 0,
+		      "xf86LinearVidMem: failed to open %s (%s)\n",
+		      apertureDevName, strerror(errno));
+	  xf86MsgVerb(X_WARNING, 0,
+		      "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc"
+		      " device driver required\n");
+	  xf86MsgVerb(X_WARNING, 0,
+		      "xf86LinearVidMem: linear memory access disabled\n");
+	  apertureDevName = NULL;
+	  return FALSE;
+	}
+#else
+	close(mmapFd);
+#endif
+	return TRUE;
+}
+
+pointer
+xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
+{
+	pointer base;
+	int fd;
+	char vtname[20];
+
+	/*
+	 * Solaris 2.1 x86 SVR4 (10/27/93)
+	 * The server must treat the virtual terminal device file as the
+	 * standard SVR4 /dev/pmem.
+	 *
+	 * Using the /dev/vtXX device as /dev/pmem only works for the
+	 * A0000-FFFFF region - If we wish you mmap the linear aperture
+	 * it requires a device driver.
+	 *
+	 * So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and
+	 * try to use the /dev/fbs/aperture or /dev/xsvc driver if the server
+	 * tries to mmap anything > FFFFF.  Its very very unlikely that the
+	 * server will try to mmap anything below FFFFF that can't be handled
+	 * by /dev/vtXX.
+	 *
+	 * DWH - 2/23/94
+	 * DWH - 1/31/99 (Gee has it really been 5 years?)
+	 *
+	 * Solaris 2.8 7/26/99
+	 * Use /dev/xsvc for everything
+	 *
+	 * DWH - 7/26/99 - Solaris8/dev/xsvc changes
+	 *
+	 * TSI - 2001.09 - SPARC changes
+	 */
+
+#if defined(i386) && !defined(__SOL8__)
+	if(Base < 0xFFFFF)
+		sprintf(vtname, "/dev/vt%02d", xf86Info.vtno);
+	else
+#endif
+	{
+		if (!xf86LinearVidMem())
+			FatalError("xf86MapVidMem:  no aperture device\n");
+
+		strcpy(vtname, apertureDevName);
+	}
+#ifdef SUNSOFT
+	fd = dup((Flags & VIDMEM_READONLY) ? apertureDevFD_ro : apertureDevFD_rw);
+#else
+	fd = open(vtname, (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+#endif
+	if (fd < 0)
+		FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+			   vtname, strerror(errno));
+
+	base = mmap(NULL, Size,
+		    (Flags & VIDMEM_READONLY) ?
+			PROT_READ : (PROT_READ | PROT_WRITE),
+		     MAP_SHARED, fd, (off_t)Base);
+	close(fd);
+	if (base == MAP_FAILED)
+		FatalError("xf86MapVidMem:  mmap failure:  %s\n",
+			   strerror(errno));
+
+	return(base);
+}
+
+/* ARGSUSED */
+void
+xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+	munmap(Base, Size);
+}
+
+/***************************************************************************/
+/* I/O Permissions section						   */
+/***************************************************************************/
+
+#if defined(i386) || defined(__x86)
+static Bool ExtendedEnabled = FALSE;
+#endif
+
+Bool
+xf86EnableIO(void)
+{
+#if defined(i386) || defined(__x86)
+	if (ExtendedEnabled)
+		return TRUE;
+
+	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
+		xf86Msg(X_WARNING,"xf86EnableIOPorts: Failed to set IOPL for I/O\n");
+		return FALSE;
+	}
+	ExtendedEnabled = TRUE;
+#endif /* i386 */
+	return TRUE;
+}
+
+void
+xf86DisableIO(void)
+{
+#if defined(i386) || defined(__x86)
+	if(!ExtendedEnabled)
+		return;
+
+	sysi86(SI86V86, V86SC_IOPL, 0);
+
+	ExtendedEnabled = FALSE;
+#endif /* i386 */
+}
+
+
+/***************************************************************************/
+/* Interrupt Handling section						   */
+/***************************************************************************/
+
+Bool xf86DisableInterrupts(void)
+{
+#if defined(i386) || defined(__x86)
+	if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
+		return FALSE;
+
+#ifdef __GNUC__
+	__asm__ __volatile__("cli");
+#else
+	asm("cli");
+#endif /* __GNUC__ */
+
+	if (!ExtendedEnabled)
+		sysi86(SI86V86, V86SC_IOPL, 0);
+#endif /* i386 */
+
+	return TRUE;
+}
+
+void xf86EnableInterrupts(void)
+{
+#if defined(i386) || defined(__x86)
+	if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
+		return;
+
+#ifdef __GNUC__
+	__asm__ __volatile__("sti");
+#else
+	asm("sti");
+#endif /* __GNUC__ */
+
+	if (!ExtendedEnabled)
+		sysi86(SI86V86, V86SC_IOPL, 0);
+#endif /* i386 */
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
+	unsigned long Size)
+{
+}
+
+Bool
+xf86CheckMTRR(int ScreenNum)
+{
+	return FALSE;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_xkbtable.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,219 @@
+/* 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.
+ */
+
+#pragma ident   "@(#)sun_xkbtable.c	1.4	05/11/08 SMI"
+
+#ifdef XKB
+#include "xf86.h"
+#include "sun_xkbtable.h"
+
+#define MAXLINELEN              256
+
+static char    *getaline(FILE *);
+static char    *skipwhite(char *);
+
+static int		global_linenumber = 0;
+#define	commentchar '#'/* Comment char */
+static char		line[MAXLINELEN + 1];
+static char	       *whitespace = " \t\n";
+
+static char *
+getaline(
+    FILE    *fp
+)
+{
+    char    *ptr;
+    char    *tmp;
+    int      index;
+    int      c;
+
+
+    while(1) {
+	ptr = fgets(line, MAXLINELEN, fp);
+        if (!ptr) {
+	    (void) fclose(fp);
+            return NULL;
+        }
+
+        global_linenumber++;
+
+        if (ptr[0] == commentchar) {        /* Comment line */
+            continue; 
+        }
+
+        if (ptr[0] == '\n') {               /* Blank line */
+            continue;
+        }
+
+        tmp = strchr(ptr, '#');
+        if (tmp != NULL) {
+            *tmp = '\0';
+        }
+
+        if (ptr[strlen(ptr) - 1] == '\n') {
+            ptr[strlen(ptr) - 1] = '\0';    /* get rid of '\n' */
+        }
+
+        ptr = skipwhite(ptr);
+        if (*ptr) {
+            break;
+        }
+
+    }
+    return ptr;
+}
+
+
+/*
+ * Skips over the white space character in the string. 
+ */
+
+static char *
+skipwhite(
+    char *ptr
+)
+{
+    while ((*ptr == ' ') || (*ptr == '\t')) {
+        ptr++;
+    }
+
+    if (*ptr == '\n') {             /* This should not occur. but .. */
+        ptr = '\0';
+    }
+
+    return ptr;
+}
+
+/*
+ * Looks up in the .../etc/keytables/xkbtable.map file for the appropriate 
+ * XKB names for the keyboard
+ */
+
+int
+sun_find_xkbnames(
+    int          kb_type,	/* input */
+    int          kb_layout,	/* input */
+    char       **xkb_keymap,	/* output */
+    char       **xkb_model,	/* output */
+    char       **xkb_layout	/* output */
+)
+{
+    const char  *type, *layout;
+    char	*keymap, *defkeymap = NULL;	/* XKB Keymap name */
+    char	*model , *defmodel = NULL;	/* XKB model name */
+    char	*xkblay, *defxkblay = NULL;	/* XKB layout name */
+    FILE        *fp;
+    int          found_error,
+                 found_keytable;
+
+    fp = fopen(DFLT_XKB_CONFIG_ROOT "/xkbtable.map", "r");
+    if (fp == NULL) {
+	xf86Msg(X_WARNING, DFLT_XKB_CONFIG_ROOT "/xkbtable.map not found.\n"
+	  "\tCannot automap keyboard layout.\n");
+        return !Success;
+    } 
+
+    global_linenumber = 0;
+    found_error = 0;
+    found_keytable = 0;
+
+    while (getaline(fp)) { 
+	type = strtok(line, " \t\n");
+	if (type == NULL) {
+	    found_error = 1;
+	}
+	
+	layout = strtok(NULL, " \t\n");
+	if (layout == NULL) {
+	    found_error = 1;
+	}
+	
+	keymap = strtok(NULL, " \t\n");
+	if (keymap == NULL) {
+	    found_error = 1;
+	}
+
+	/* These two are optional entries */
+	model = strtok(NULL, " \t\n");
+	if ((model == NULL) || (*model == commentchar)) {
+	    model = xkblay = NULL;
+	} else {
+	    xkblay = strtok(NULL, " \t\n");
+	    if ((xkblay !=NULL) && (*xkblay == commentchar)) {
+		xkblay = NULL;
+	    }
+	}
+
+	if (found_error) {
+	    found_error = 0;
+	    continue;
+	}
+	
+	/* record default entry if/when found */
+	if (*type == '*') {
+	    if (defkeymap == NULL) {
+		defkeymap = keymap;
+		defmodel = model;
+		defxkblay = xkblay;
+	    }
+	} else if (atoi(type) == kb_type) {
+	    if (*type == '*') {
+		if (defkeymap == NULL) {
+		    defkeymap = keymap;
+		    defmodel = model;
+		    defxkblay = xkblay;
+		}
+	    } else if (atoi(layout) == kb_layout) {
+		found_keytable = 1;
+		break;
+	    }
+	}
+    }
+    (void) fclose(fp);
+             
+    if (! found_keytable ) {
+	keymap = defkeymap;
+	model = defmodel;
+	xkblay = defxkblay;
+    }
+
+    if ((keymap != NULL) && (strcmp(keymap,"-") !=0)) {
+	xf86Msg(X_PROBED, "XKB: keymap: \"%s\"\n", keymap);
+	*xkb_keymap = keymap;
+    }
+    if ((model != NULL) && (strcmp(model,"-") !=0)) {
+	*xkb_model = model;
+	xf86Msg(X_PROBED, "XKB: model: \"%s\"\n", model);
+    }
+    if ((xkblay != NULL) && (strcmp(xkblay,"-") !=0)) {
+	*xkb_layout = xkblay;
+	xf86Msg(X_PROBED, "XKB: layout: \"%s\"\n", xkblay);
+    }
+    return Success;
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_xkbtable.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,50 @@
+/* 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.
+ */
+
+#ifndef _SUN_XKBTABLE_H
+#define	_SUN_XKBTABLE_H
+
+#pragma ident	"@(#)sun_xkbtable.h	1.2	05/11/08 SMI"
+
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+
+/*
+ * Functions for autodetecting Sun keyboard type and mapping to XKB names
+ */
+extern int
+sun_find_xkbnames(
+    int          kb_type,	/* input */
+    int          kb_layout,	/* input */
+    char       **xkb_keymap,	/* output */
+    char       **xkb_model,	/* output */
+    char       **xkb_layout	/* output */
+);
+
+#endif /* _SUN_XKBTABLE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/os-support/sunos/xkbtable.map	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,203 @@
+##########################################################################
+#
+# Copyright 2005 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.
+#
+##########################################################################
+#
+# ident "@(#)xkbtable.map	1.7	05/11/08 SMI"
+#
+# xkbtable.map
+#
+# The xkbtable map associates a keyboard with its corresponding XKB names,
+# in order to associate it
+#
+# The keyboard Type and Layout are generally obtained from the kernel using
+# appropriate ioctl calls.  The keyboard Type is stored in a keyboard PROM.
+# The keyboard Layout may be stored in a keyboard PROM or determined by a 
+# DIP switch setting.
+#
+# Format of an entry:
+# Type  Layout  XKB_Keymap	XKB_Model	XKB_Layout
+#
+# The XKB_Model and XKB_Layout fields are optional, but you must specify an
+# XKB_model in order to specify an XKB_Layout
+#
+# The XKB_Keymap field may be - to specify not setting the keymap and using
+# the XKB_Model and XKB_Layout to lookup the rules in the xorg.rules file
+#
+# The layout field may be a * to indicate a default entry for a keyboard
+# of the specified type if an exact match is not found.
+#
+# The type & layout fields may be both be a * to indicate a default entry 
+# for a keyboard if an exact match is not found, and a default entry of 
+# the correct type is not found.
+#
+##############################################################################
+#
+# Type 4 Keyboards
+#
+4	0	-	sun_type4		us	# US4
+4	1	-	sun_type4		us	# US4
+4	2	-	sun_type4_euro		fr	# FranceBelg4
+4	3	-	sun_type4_ca		ca	# Canada4
+4	4	-	sun_type4_euro		dk	# Denmark4
+4	5	-	sun_type4_euro		de	# Germany4
+4	6	-	sun_type4_euro		it	# Italy4
+4	7	-	sun_type4_euro		nl	# Netherland4
+4	8	-	sun_type4_euro		no	# Norway4
+4	9	-	sun_type4_euro		pt	# Portugal4
+4	10	-	sun_type4_euro		es	# SpainLatAm4
+4	11	-	sun_type4_euro		se	# SwedenFin4
+4	12	-	sun_type4_euro		fr_CH	# Switzer_Fr4
+4	13	-	sun_type4_euro		de_CH	# Switzer_Ge4
+4	14	-	sun_type4_euro		gb	# UK4
+4	16	-	sun_type4		ko	# Korea4
+4	17	-	sun_type4		tw	# Taiwan4
+4	32	-	sun_type4_jp		jp	# Japan4
+#
+# Uncomment either the PC compatible or Sun compatible layout
+# Sun 101A -- PC compatible layout:
+4	19	-	sun_type5		us	# US101A_PC
+# Sun 101A -- Sun compatible layout:
+#4	19	-	sun_type5		us	# US101A_Sun
+#
+#
+# Type 5 Keyboards
+#
+# Type 5 keyboards identify themselves as type 4 for backward compatibility
+#
+4	33	-	sun_type5		us	# US5
+4	34	-	sun_type5_unix		us	# US_UNIX5
+4	35	-	sun_type5_euro		fr	# France5
+4	36	-	sun_type5_euro		dk	# Denmark5
+4	37	-	sun_type5_euro		de	# Germany5
+4	38	-	sun_type5_euro		it	# Italy5
+4	39	-	sun_type5_euro		nl	# Netherland5
+4	40	-	sun_type5_euro		no	# Norway5
+4	41	-	sun_type5_euro		pt	# Portugal5
+4	42	-	sun_type5_euro		es	# Spain5
+4	43	-	sun_type5_euro		se	# Sweden5
+4	44	-	sun_type5_euro		fr_CH	# Switzer_Fr5
+4	45	-	sun_type5_euro		de_CH	# Switzer_Ge5
+4	46	-	sun_type5_euro		gb	# UK5
+4	47	-	sun_type5		ko	# Korea5
+4	48	-	sun_type5		tw	# Taiwan5
+4	49	-	sun_type5_jp		jp	# Japan5
+4	50	-	sun_type5_euro		fr_CA	# Canada_Fr5
+4	51	-	sun_type5_euro		hu	# Hungary5
+4	52	-	sun_type5_euro		pl	# Poland5
+4	53	-	sun_type5_euro		cz	# Czech5
+4	54	-	sun_type5_euro		ru	# Russia5
+4	55	-	sun_type5_euro		lv	# Latvia5
+4	57	-	sun_type5_euro		gr	# Greece5
+4	59	-	sun_type5_euro		lt	# Lithuania5
+4	63	-	sun_type5_euro		fr_CA	# Canada_Fr5_TBITS5
+4	56	-	sun_type5_euro		tr	# TurkeyQ5
+4	58	-	sun_type5_euro		ar	# Arabic5
+4	60	-	sun_type5_euro		be	# Belgian5
+4	62	-	sun_type5_euro		tr_f	# TurkeyF5
+#
+# Type 5 Hobo Keyboards
+#
+4	80	-	sun_type5_hobo		us	# US5_Hobo
+4	81	-	sun_type5_unix_hobo	us	# US_UNIX5_Hobo
+4	82	-	sun_type5_euro_hobo	fr	# France5_Hobo
+4	83	-	sun_type5_euro_hobo	dk	# Denmark5_Hobo
+4	84	-	sun_type5_euro_hobo	de	# Germany5_Hobo
+4	85	-	sun_type5_euro_hobo	it	# Italy5_Hobo
+4	86	-	sun_type5_euro_hobo	nl	# Netherland5_Hobo
+4	87	-	sun_type5_euro_hobo	no	# Norway5_Hobo
+4	88	-	sun_type5_euro_hobo	pt	# Portugal5_Hobo
+4	89	-	sun_type5_euro_hobo	es	# Spain5_Hobo
+4	90	-	sun_type5_euro_hobo	se	# Sweden5_Hobo
+4	91	-	sun_type5_euro_hobo	fr_CH	# Switzer_Fr5_Hobo
+4	92	-	sun_type5_euro_hobo	de_CH	# Switzer_Ge5_Hobo
+4	93	-	sun_type5_euro_hobo	gb	# UK5_Hobo
+4	94	-	sun_type5_hobo		ko	# Korea5_Hobo
+4	95	-	sun_type5_hobo		tw	# Taiwan5_Hobo
+4	96	-	sun_type5_jp_hobo	jp	# Japan5_Hobo
+4	97	-	sun_type5_euro_hobo	fr_CA	# Canada_Fr5_Hobo
+#
+# Type 101 Keyboards (Solaris x86 Keyboards)
+#
+101	*	-	pc105			us	# MS_US101A_x86
+101	1	-	pc105			us	# US101A_x86
+101	34	-	pc105				# J3100_x86
+101	35	-	pc105			fr	# France_x86
+101	36	-	pc105			dk	# Denmark_x86
+101	37	-	pc105			de	# Germany_x86
+101	38	-	pc105			it	# Italy_x86
+101	39	-	pc105			nl	# Netherland_x86
+101	40	-	pc105			no	# Norway_x86
+101	41	-	pc105			pt     	# Portugal_x86
+101	42	-	pc105			es	# Spain_x86
+101	43	-	pc105			se	# Sweden_x86
+101	44	-	pc105			fr_CH	# Switzer_Fr_x86
+101	45	-	pc105			de_CH	# Switzer_Ge_x86
+101	46	-	pc105			gb	# UK_x86
+101	47	-	pc105			ko	# Korea_x86
+101	48	-	pc105			tw	# Taiwan_x86
+101	49	-	jp106			jp	# Japan_x86
+101	50	-	pc105			fr_CA	# Canada_Fr2_x86
+101	51	-	pc105			hu	# Hungary_x86
+101	52	-	pc105			pl	# Poland_x86
+101	53	-	pc105			cz	# Czech_x86
+101	54	-	pc105			ru	# Russia_x86
+101	55	-	pc105			lv	# Latvia_x86
+101	56	-	pc105			tr	# Turkey_x86
+101	57	-	pc105			el	# Greece_x86
+101	59	-	pc105			lt	# Lithuania_x86
+101	1001	-	pc105			us	# MS_US101A_x86
+#
+# Type 6 USB Keyboards
+#
+6	*	-	sun_type6_usb		us	# US6_usb
+6	6	-	sun_type6_euro_usb	dk	# Denmark6_usb
+6	7	-	sun_type6_euro_usb	fi	# Finnish6_usb
+6	8	-	sun_type6_euro_usb	fr	# France6_usb
+6	9	-	sun_type6_euro_usb	de	# Germany6_usb
+6	14	-	sun_type6_euro_usb	it	# Italy6_usb
+6	15	-	sun_type7_jp_usb	jp	# Japan7_usb
+6	16	-	sun_type6_usb		ko	# Korea6_usb
+6	18	-	sun_type6_euro_usb	nl	# Netherland6_usb
+6	19	-	sun_type6_euro_usb	no	# Norway6_usb
+6	22	-	sun_type6_euro_usb	pt	# Portugal6_usb
+6	23	-	sun_type6_euro_usb	ru	# Russia6_usb
+6	25	-	sun_type6_euro_usb	es	# Spain6_usb
+6	26	-	sun_type6_euro_usb	se	# Sweden6_usb
+6	27	-	sun_type6_euro_usb	fr_CH	# Switzer_Fr6_usb
+6	28	-	sun_type6_euro_usb	de_CH	# Switzer_Ge6_usb
+6	30	-	sun_type6_usb		tw	# Taiwan6_usb
+6	32	-	sun_type6_euro_usb	gb	# UK6_usb
+6	33	-	sun_type6_usb		us	# US6_usb
+6	1	-	sun_type6_euro_usb	ar	# Arabic6_usb
+6	2	-	sun_type6_euro_usb	be	# Belgian6_usb
+6	31	-	sun_type6_euro_usb	tr	# TurkeyQ6_usb
+6	35	-	sun_type6_euro_usb	tr_f	# TurkeyF6_usb
+6	271	-	sun_type6_jp_usb	jp	# Japan6_usb
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/vbe/vbe_module.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,74 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe_module.c,v 1.4 2002/09/16 18:06:15 eich Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86str.h"
+#include "vbe.h"
+
+extern const char *vbe_ddcSymbols[];
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(vbeSetup);
+
+static XF86ModuleVersionInfo vbeVersRec =
+{
+    "vbe",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    1, 1, 0,
+    ABI_CLASS_VIDEODRV,		/* needs the video driver ABI */
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_NONE,
+    {0,0,0,0}
+};
+
+XF86ModuleData vbeModuleData = { &vbeVersRec, vbeSetup, NULL };
+
+static xf86MonPtr
+vbeProbeDDC(int entityIndex, ScrnInfoPtr scrp)
+{
+   vbeInfoPtr pVbe;
+   xf86MonPtr MonInfo = NULL;
+
+   pVbe = VBEInit(NULL, entityIndex);
+   MonInfo = vbeDoEDID(pVbe, NULL);
+   if (MonInfo) {
+        xf86DrvMsg(scrp->scrnIndex, X_PROBED,
+        "VBE DDC detected a %s:\n", MonInfo->features.input_type ?
+        "DFP" : "CRT");
+        xf86PrintEDID( MonInfo );
+        xf86DrvMsg(scrp->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n\n");
+   }
+
+   return (MonInfo);
+}
+
+static pointer
+vbeSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = FALSE;
+    
+    if (!setupDone) {
+	setupDone = TRUE;
+	LoaderRefSymLists(vbe_ddcSymbols,NULL);
+	/*
+	 * Tell the loader about symbols from other modules that this module
+	 * might refer to.
+	 */
+	xf86FallbackDDCProbe = vbeProbeDDC;
+    } 
+    /*
+     * The return value must be non-NULL on success even though there
+     * is no TearDownProc.
+     */
+    return (pointer)1;
+}
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,233 @@
+XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile,v 1.3 2004/09/02 01:10:29 kem Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile,v 1.25 2003/10/31 15:02:55 tsi Exp $
+
+#include <Server.tmpl>
+
+XCOMM CDEBUGFLAGS=-g -Wall -ansi -pedantic
+
+#if DoLoadableServer
+LDSRCS	= libc_wrapper.c loader.c loadmod.c
+LDOBJS	= libc_wrapper.o loader.o loadmod.o
+#endif
+
+#if HasNCurses
+TEXTSRC	= text-mode.c
+TEXTOBJ	= text-mode.o
+#endif
+
+#if !HasStrlcat
+STRLSRCS = strlcat.c strlcpy.c
+STRLOBJS = strlcat.o strlcpy.o
+#endif
+
+#if !HasSnprintf
+SNPRINTFSRCS = snprintf.c
+SNPRINTFOBJS = snprintf.o
+#endif
+
+#if HasDlopen
+SRCS	=\
+	accessx.c\
+	card-cfg.c\
+	cards.c\
+	config.c\
+	expert.c\
+	help.c\
+	interface.c\
+	keyboard-cfg.c\
+	$(LDSRCS) \
+	monitor-cfg.c\
+	mouse-cfg.c\
+	options.c\
+	screen-cfg.c\
+	screen.c\
+	$(SNPRINTFSRCS)\
+	startx.c\
+	$(STRLSRCS)\
+	stubs.c\
+	$(TEXTSRC)\
+	vidmode.c\
+	xf86config.c\
+	dummy.c 
+#else
+SRCS	=\
+	accessx.c\
+	card-cfg.c\
+	cards.c\
+	config.c\
+	expert.c\
+	help.c\
+	interface.c\
+	keyboard-cfg.c\
+	$(LDSRCS) \
+	monitor-cfg.c\
+	mouse-cfg.c\
+	options.c\
+	screen-cfg.c\
+	screen.c\
+	$(SNPRINTFSRCS)\
+	startx.c\
+	$(STRLSRCS)\
+	stubs.c\
+	$(TEXTSRC)\
+	vidmode.c\
+	xf86config.c
+#endif
+
+#if HasDlopen
+OBJS	=\
+	accessx.o\
+	cards.o\
+	config.o\
+	card-cfg.o\
+	expert.o\
+	help.o\
+	interface.o\
+	keyboard-cfg.o\
+	$(LDOBJS) \
+	monitor-cfg.o\
+	mouse-cfg.o\
+	options.o\
+	screen-cfg.o\
+	screen.o\
+	$(SNPRINTFOBJS)\
+	startx.o\
+	$(STRLOBJS)\
+	stubs.o\
+	$(TEXTOBJ)\
+	vidmode.o\
+	xf86config.o\
+	dummy.o
+#else
+OBJS	=\
+	accessx.o\
+	cards.o\
+	config.o\
+	card-cfg.o\
+	expert.o\
+	help.o\
+	interface.o\
+	keyboard-cfg.o\
+	$(LDOBJS) \
+	monitor-cfg.o\
+	mouse-cfg.o\
+	options.o\
+	screen-cfg.o\
+	screen.o\
+	$(SNPRINTFOBJS)\
+	startx.o\
+	$(STRLOBJS)\
+	stubs.o\
+	$(TEXTOBJ)\
+	vidmode.o\
+	xf86config.o
+#endif
+
+PROG	= xorgcfg
+
+#if HasDlopen
+DUMMYGENSRC = dummygen.c
+DUMMYGENTOOL = dummygen
+#endif
+
+XBMPICS =\
+	card.xbm\
+	keyboard.xbm\
+	monitor.xbm\
+	mouse.xbm\
+	left.xbm\
+	right.xbm\
+	up.xbm\
+	down.xbm\
+	wider.xbm\
+	narrower.xbm\
+	shorter.xbm\
+	taller.xbm
+
+XPMPICS =\
+	card.xpm\
+	computer.xpm\
+	keyboard.xpm\
+	monitor.xpm\
+	mouse.xpm
+
+#if HasDlopen
+dummy.c ::  $(DUMMYGENTOOL) $(DUMMYGENSRC)
+	./$(DUMMYGENTOOL)
+
+clean::
+	RemoveFiles($(DUMMYGENTOOL) dummy.c)
+#endif
+
+AllTarget(ProgramTargetName($(PROG)))
+
+#if DoLoadableServer
+LOADERLIB      = -L../loader -lxloader -L../dummylib -ldummy
+MODULEDEFINES  = -DUSE_MODULES
+INCLUDES       = -I../common -I../scanpci -I../loader -I$(XF86OSSRC) \
+		 -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+		 -I$(FONTLIBSRC)/include
+#if !HasSnprintf
+SNPRINTF_DEFS  = -DNEED_SNPRINTF
+#endif
+WRAPPERDEFINES = -DSELF_CONTAINED_WRAPPER $(SNPRINTF_DEFS)
+#endif
+
+#if HasNCurses
+CURSESLIB = NCursesLibName
+CURSESDEFINES  = -DHAS_NCURSES
+#endif
+
+XF86CONFIGFILE = XConfigFile
+XF86CONFIGDIR = XConfigDir
+XF86CONSOLEDEFS = XFree86ConsoleDefines
+
+DEFINES        = -DXF86CONFIG=\"$(XF86CONFIGFILE)\" $(MODULEDEFINES) \
+		 $(CURSESDEFINES) \
+		 -DPROJECT_ROOT=\"$(PROJECTROOT)\" \
+		 -DXF86CONFIGDIR=\"$(XF86CONFIGDIR)\" $(XF86CONSOLEDEFS) \
+		 $(CONFIG_DEFINES) $(XKBDEFRULESDEFS)
+
+#if HasDlopen
+DLLIB = DlLibrary
+#endif
+
+LOCAL_LIBRARIES = $(BUILDLIBDIR)/libxkbfile.so \
+		  $(BUILDLIBDIR)/libxkbui.a \
+		  $(BUILDLIBDIR)/libxf86config.a \
+		  $(BUILDLIBDIR)/libXxf86misc.so \
+		  $(BUILDLIBDIR)/libXxf86vm.so \
+		  $(BUILDLIBDIR)/libXaw.so \
+		  $(XMULIB) \
+		  $(XTOOLLIB) \
+		  $(XPMLIB) $(EXTRAXAWCLIENTLIBS) $(LOADERLIB) $(DLLIB) \
+		  $(EXTENSIONLIB) \
+		  $(XONLYLIB) \
+		  $(CURSESLIB) RegexLibrary -lm
+
+NormalProgramTarget($(PROG),$(OBJS),,$(LOCAL_LIBRARIES),)
+InstallProgramWithFlags($(PROG),$(BINDIR),NullParameter)
+InstallMultipleFlags($(XBMPICS),$(INCDIR)/X11/bitmaps,$(INSTINCFLAGS))
+InstallMultipleFlags($(XPMPICS),$(INCDIR)/X11/pixmaps,$(INSTINCFLAGS))
+CppRawFileTarget(XOrgCfg.ad,XOrgCfg.cpp,-D__VENDORNAME__="$(VENDORNAMESHORT)" -D__VENDORVERS__="$(VENDORMANVERSION)",NullParameter)
+InstallAppDefaults(XOrgCfg)
+
+InstallManPage(xorgcfg,$(MANDIR))
+
+NormalLibraryObjectRule()
+
+#if DoLoadableServer
+LinkSourceFile(libc_wrapper.c, $(XF86OSSRC)/shared)
+SpecialCObjectRule(libc_wrapper,NullParameter,$(WRAPPERDEFINES) $(EXT_DEFINES))
+#endif
+
+#if !HasStrlcat
+LinkSourceFile(strlcat.c,$(LIBSRC)/misc)
+LinkSourceFile(strlcpy.c,$(LIBSRC)/misc)
+#endif
+
+#if !HasSnprintf
+LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
+#endif
+
+DependTarget()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/XOrgCfg.cpp	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1853 @@
+!!
+!! Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+!! 
+!! 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
+!! CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+!! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+!! OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+!! SOFTWARE.
+!! 
+!! Except as contained in this notice, the name of Conectiva Linux shall
+!! not be used in advertising or otherwise to promote the sale, use or other
+!! dealings in this Software without prior written authorization from
+!! Conectiva Linux.
+!!
+!! Author: Paulo C�sar Pereira de Andrade <[email protected]>
+!!
+!! $XFree86: xc/programs/Xserver/hw/xfree86/xorgcfg/XF86Cfg.ad,v 1.13 2001/05/15 18:22:23 paulo Exp $
+!!
+
+*Form.background:			gray85
+*Label.background:			gray85
+!! keyboard
+*Core.background:			gray85
+*Label.foreground:			gray20
+*Command.background:			gray80
+*Command.foreground:			gray20
+*Command.borderWidth:			0
+*Command.displayList:\
+foreground	gray60;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray90;\
+lines		-1,0,0,0,0,-1
+
+*Text.?.foreground:			gray20
+*Text.borderWidth:			0
+*Text.background:			gray96
+*Text.?.cursorColor:			rgb:d/5/5
+*Text.displayList:\
+foreground	white;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray40;\
+lines		-1,0,0,0,0,-1
+
+*baseTranslations: #override \
+<Key>Escape:	vidmode-restore()
+
+*List.background:			gray96
+*List.foreground:			gray20
+*Viewport.borderColor:			gray40
+*List.borderColor:			gray40
+
+*MenuButton.background:			gray80
+*MenuButton.foreground:			gray20
+*MenuButton.borderWidth:		0
+*MenuButton.displayList:\
+line-style	solid;\
+foreground	gray40;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray90;\
+lines		-1,0,0,0,0,-1;\
+line-style	onoffdash;\
+foreground	gray80;\
+draw-rect	1,1,-2,-2
+
+*SimpleMenu.background:			gray80
+*SimpleMenu.?.foreground:		gray20
+*SimpleMenu.borderWidth:		0
+*SimpleMenu.displayList:\
+foreground	gray40;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray90;\
+lines		-1,0,0,0,0,-1
+
+*Dialog.displayList:\
+foreground	gray40;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray90;\
+lines		-1,0,0,0,0,-1
+
+*Toggle.background:			gray80
+*Toggle.foreground:			gray20
+*Toggle.borderWidth:			0
+*Toggle.displayList:\
+foreground	gray90;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray40;\
+lines		-1,0,0,0,0,-1
+
+*mouse.bitmap:				mouse.xbm
+*keyboard.bitmap:			keyboard.xbm
+*card.bitmap:				card.xbm
+*monitor.bitmap:			monitor.xbm
+
+*Label.borderWidth:			0
+*Viewport.forceBars:			True
+*Viewport.allowVert:			True
+*Viewport.useRight:			True
+
+.xorgcfg.geometry:			396x454
+.xorgcfg.minWidth:			396
+.xorgcfg.minHeight:			454
+.xorgcfg.maxWidth:			396
+.xorgcfg.maxHeight:			454
+
+.xorgcfg.config.geometry:		370x400
+.xorgcfg.config.minWidth:		370
+.xorgcfg.config.maxWidth:		370
+.xorgcfg.config.minHeight:		400
+.xorgcfg.config.maxHeight:		400
+
+*work.width:				320
+*work.height:				240
+
+*error.label.label:\
+Not all required fields\n\
+were filled, or the specified\n\
+identifier is duplicated.
+*error.label.vertDistance:		30
+*error.label.borderWidth:		0
+*error.label.leftBitmap:		Excl
+*error.command.fromVert:		label
+*error.command.label:			Ok
+*error.command.vertDistance:		20
+
+*Scrollbar.translations:\
+<BtnDown>:	StartScroll(Continuous) MoveThumb() NotifyThumb()\n\
+<BtnMotion>:	MoveThumb() NotifyThumb()\n\
+<BtnUp>:	NotifyScroll(Proportional) EndScroll()
+
+*Scrollbar.background:		gray80
+*Scrollbar.foreground:		rgb:a/5/5
+*Scrollbar.borderWidth:		0
+*Scrollbar.thumb:		vlines2
+*Scrollbar.displayList:\
+foreground	gray90;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray40;\
+lines		-1,0,0,0,0,-1
+
+*Text.Translations: #override \
+<Enter>:	no-op()\n\
+<Leave>:	no-op()\n\
+<Btn1Down>:	set-keyboard-focus() select-start()
+
+*top.identifier.Translations: #override \
+<Enter>:	no-op()\n\
+<Leave>:	no-op()\n\
+<Key>Return:	no-op()\n\
+<Btn1Down>:	set-keyboard-focus() select-start()
+
+*List.showCurrent:		True
+*Tip.timeout:			100
+*Tip.background:		rgb:f/f/8
+*Tip.foreground:		gray20
+*Tip.borderWidth:		0
+*Tip.displayList:\
+foreground	rgb:8/8/4;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	rgb:f/f/c;\
+lines		-1,0,0,0,0,-1
+
+*Toggle.internalHeight:		2
+*Toggle.internalWidth:		2
+*mouse.label:			Mouse
+*keyboard.label:		Keyboard
+*card.label:			Card
+*monitor.label:			Monitor
+
+*commands.borderWidth:		0
+*commands.defaultDistance:	2
+*commands.?.bottom:		chainTop
+*commands.height:		50
+
+*commands.keyboard.fromHoriz:	mouse
+*card.fromHoriz:		keyboard
+*monitor.fromHoriz:		card
+
+*commands.mouse*new.label:	Add new mouse
+*commands.keyboard*new.label:	Add new keyboard
+*commands.card*new.label:	Add new video card
+*commands.monitor*new.label:	Add new monitor
+*commands.mouse*configure.label:	Configure mouse(s)
+*commands.keyboard*configure.label:	Configure keyboard(s)
+*commands.card*configure.label:		Configure video card(s)
+*commands.monitor*configure.label:	Configure monitor(s)
+*commands.mouse*SimpleMenu*newMouse.label:	New mouse
+*commands.keyboard*SimpleMenu*newKeyboard.label:New keyboard
+*commands.card*SimpleMenu*newcard.label:	New card
+*commands.monitor*SimpleMenu*newMonitor.label:	New monitor
+
+*commands.MenuButton.translations: \
+<Enter>:	highlight()\n\
+<Leave>:	reset()\n\
+Any<BtnDown>:	highlight() set() PopupMenu()
+
+*hpane.showGrip:		False
+*hpane.expert.label:		Expert Mode
+*topM.min:			200
+*topM.max:			200
+*topM.justify:			left
+*topM.label:			Configure Layout
+*topM*layout.label:		Configure Layout
+*topM*screen.label:		Configure Screen
+*topM*modeline.label:		Configure Modeline
+*topM*accessx.label:		Configure AccessX
+*topM.showGrip:			False
+*work.showGrip:			False
+
+*MenuButton.leftBitmap:		menu10
+*SmeBSB.HorizontalMargins:	18
+
+*back.label:			<< Back
+*next.label:			Next >>
+*ok.label:			Ok
+*cancel.label:			Cancel
+*yes.label:			Yes
+*no.label:			No
+
+*help.label:			Help
+*quit.label:			Quit
+*next.fromHoriz:		back
+*config*ok.fromHoriz:		next
+*bottom*cancel.fromHoriz:	ok
+*top.displayList:\
+foreground	gray60;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1
+*bottom.displayList:\
+foreground	gray60;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1
+*work.displayList:\
+foreground	gray60;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1
+*options.pane.Form.displayList:\
+foreground	gray60;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1
+
+*top.label.label:		Identifier:
+*top.label.borderWidth:		0
+*top.identifier.fromHoriz:	label
+*top.label.internalHeight:	3
+*top.label.justify:		left
+*top.label.left:		chainLeft
+*top.label.right:		chainLeft
+*top.identifier.left:		chainLeft
+*top.identifier.right:		chainRight
+
+*bottom.layout.translations:	#override \
+<Key>Return:	rename-layout()
+*bottom.layout.label:		New server layout
+*bottom.layout.tip:		Type a text and press Return to rename this layout
+*bottom.Command.height:		25
+*bottom.Text.height:		25
+*bottom.MenuButton.height:	25
+*bottom*new.label:		New server layout
+*layout.fromHoriz:		select
+*help.fromHoriz:		layout
+*bottom.layout.justify:		left
+*bottom.select.label:		Layout
+*bottom.select.left:		chainLeft
+*bottom.select.right:		chainLeft
+*bottom.layout.left:		chainLeft
+*quit.fromHoriz:		help
+*bottom.?.left:			chainRight
+*bottom.?.right:		chainRight
+*bottom.?.top:			chainBottom
+*bottom.?.bottom:		chainBottom
+
+*pane.bottom.min:		30
+*pane.bottom.max:		30
+*pane.bottom.showGrip:		False
+*pane.bottom.defaultDistance:	5
+
+!! Wellcome message
+*work.wellcome.borderWidth:	0
+*work.wellcome.label:		Welcome to __VENDORNAME__ __VENDORVERS__ setup program
+*work.?.borderWidth:		0
+!*work.?.width:			310
+*work.?.height:			290
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! mouseDP widget
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*mouseDP*Label.internalHeight:		0
+*mouseDP*Label.borderWidth:		0
+*mouseDP.labelD.vertDistance:		0
+*mouseDP.labelD.label:			Select mouse device
+*mouseDP.device.fromVert:		labelD
+*mouseDP.viewportD.fromVert:		device
+*mouseDP.device.width:			332
+*mouseDP.viewportD.vertDistance:	2
+*mouseDP.viewportD.listD.longest:	135
+*mouseDP.viewportD.width:		330
+*mouseDP.viewportD.height:		87
+*mouseDP.labelP.label:			Select mouse protocol
+*mouseDP.labelP.vertDistance:		10
+*mouseDP.labelP.fromVert:		viewportD
+*mouseDP.viewportP.fromVert:		labelP
+*mouseDP.viewportP.forceBars:		True
+*mouseDP.viewportP.allowVert:		True
+*mouseDP.viewportP.useRight:		True
+*mouseDP.viewportP.listP.longest:	172
+*mouseDP.viewportP.width:		330
+*mouseDP.viewportP.height:		110
+*mouseDP.viewportP.vertDistance:	6
+*mouseDP*List.verticalList:		True
+*mouseDP.emulate3.fromVert:		viewportP
+*mouseDP.emulate3.width:		180
+*mouseDP.apply.label:			Apply changes
+*mouseDP.apply.fromVert:		viewportP
+*mouseDP.apply.fromHoriz:		emulate3
+*mouseDP.apply.width:			116
+*mouseDP.emulate3.vertDistance:		10
+*mouseDP.apply.vertDistance:		10
+*mouseDP.emulate3.label:		Emulate 3 buttons
+*mouseDP.emulate3.tip:			Select if your mouse has only two buttons
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! keyboardML widget
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*keyboardML.Label.vertDistance:		8
+*keyboardML.MenuButton.vertDistance:	8
+*keyboardML.keyboard.vertDistance:	10
+*keyboardML.Label.borderWidth:		0
+*keyboardML.Label.width:		115
+*keyboardML.MenuButton.width:		185
+*keyboardML.MenuButton.justify:		left
+*keyboardML.Label.internalWidth:	0
+*keyboardML.Label.justify:		right
+*keyboardML.labelR.label:		Xkb rules:
+*keyboardML.rules.left:			chainRight
+*keyboardML.rules.right:		chainRight
+*keyboardML.rules.fromHoriz:		labelR
+*keyboardML.model.fromVert:		rules
+*keyboardML.labelM.fromVert:		rules
+*keyboardML.model.left:			chainRight
+*keyboardML.model.right:		chainRight
+*keyboardML.model.fromHoriz:		labelM
+*keyboardML.labelM.label:		Keyboard model:
+*keyboardML.layout.left:		chainRight
+*keyboardML.layout.right:		chainRight
+*keyboardML.layout.fromVert:		model
+*keyboardML.labelL.fromVert:		model
+*keyboardML.layout.fromHoriz:		labelL
+*keyboardML.labelL.label:		Keyboard layout:
+*keyboardML.variant.fromVert:		labelL
+*keyboardML.variant.fromHoriz:		labelV
+*keyboardML.labelV.fromVert:		labelL
+*keyboardML.labelV.label:		Xkb variant:
+*keyboardML.options.fromVert:		labelV
+*keyboardML.options.fromHoriz:		labelO
+*keyboardML.labelO.fromVert:		labelV
+*keyboardML.labelO.label:		Xkb options:
+*keyboardML.keyboard.fromVert:		labelO
+*keyboardML.keyboard.borderWidth:	0
+*keyboardML.keyboard.width:		305
+*keyboardML.keyboard.height:		121
+*keyboardML.apply.vertDistance:		16
+*keyboardML.apply.fromVert:		keyboard
+*keyboardML.apply.label:		Apply changes
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! cardModel widget
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*cardModel.label.internalHeight:	0
+*cardModel.keyboard.borderWidth:	0
+*cardModel.label.label:			Card model filter
+*cardModel.label.internalHeight:	2
+*cardModel.label.borderWidth:		0
+*cardModel.viewport.vertDistance:	2
+*cardModel.viewport.fromVert:		filter
+*cardModel.filter.fromHoriz:		label
+*cardModel.filter.width:		90
+*cardModel.viewport.width:		340
+*cardModel.viewport.height:		218
+*cardModel.driver.justify:		left
+*cardModel.driverL.label:		Driver
+*cardModel.driverL.fromVert:		viewport
+*cardModel.driverL.width:		50
+*cardModel.driverL.justify:		right
+*cardModel.driver.fromVert:		viewport
+*cardModel.driver.fromHoriz:		driverL
+*cardModel.driver.width:		250
+*cardModel.driver.left:			chainRight
+*cardModel.driver.right:		chainRight
+*cardModel.busidL.label:		BusID
+*cardModel.busidL.fromVert:		driver
+*cardModel.busidL.width:		50
+*cardModel.busidL.justify:		right
+*cardModel.busid.fromVert:		driver
+*cardModel.busid.fromHoriz:		busidL
+*cardModel.busid.width:			250
+*cardModel.busid.left:			chainRight
+*cardModel.busid.right:			chainRight
+*cardModel.viewport.forceBars:		True
+*cardModel.viewport.allowVert:		True
+*cardModel.viewport.useRight:		True
+*cardModel.viewport.list.longest:	350
+*cardModel.filter.tip:			Type name or vendor of your card and press enter
+*cardModel.filter.translations:	#override \
+<Key>Return:	filter-card()
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! main widget
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*work.cpu.backgroundPixmap:		computer.xpm
+*work.mouse.backgroundPixmap:		mouse.xpm
+*work.keyboard.backgroundPixmap:	keyboard.xpm
+*work.card.backgroundPixmap:		card.xpm
+*work.monitor.backgroundPixmap:		monitor.xpm
+
+*work.cpu.x:				130
+*work.cpu.y:				160
+*work.cpu.width:			30
+*work.cpu.height:			50
+*work.mouse.width:			26
+*work.mouse.height:			35
+*work.keyboard.width:			60
+*work.keyboard.height:			28
+*work.card.width:			41
+*work.card.height:			40
+*work.monitor.width:			47
+*work.monitor.height:			40
+
+.xorgcfg.pane.work.Simple.borderWidth:	1
+.xorgcfg.pane.work.Simple.translations:\
+Any<Btn1Down>:	select-device()\n\
+Any<Btn1Motion>:	move-device()\n\
+Any<Btn1Up>:	unselect-device()\n\
+Any<Btn3Down>:	device-popup()\n\
+Any<Btn3Up>:	device-popdown()
+
+.xorgcfg.pane.work.screen.translations:\
+Any<Btn1Down>:	select-device()\n\
+Any<Btn1Motion>:	move-device()\n\
+Any<Btn1Up>:	unselect-device()\n\
+Any<Btn3Down>:	device-popup()\n\
+Any<Btn3Up>:	device-popdown()
+
+Xorgcfg.translations:	#override \
+<Message>WM_PROTOCOLS:	quit()
+.xorgcfg.config.translations:	#override \
+<Message>WM_PROTOCOLS:	config-cancel()
+.xorgcfg.options.translations:	#override \
+<Message>WM_PROTOCOLS:	options-cancel()
+.xorgcfg.quit.translations:	#override \
+<Message>WM_PROTOCOLS:	quit-cancel()
+.xorgcfg.error.translations:	#override \
+<Message>WM_PROTOCOLS:	error-cancel()
+.xorgcfg.force.translations:	#override \
+<Message>WM_PROTOCOLS:	addmode-cancel()
+.xorgcfg.addMode.translations:	#override \
+<Message>WM_PROTOCOLS:	addmode-cancel()
+.xorgcfg.accessx.translations:	#override \
+<Message>WM_PROTOCOLS:	accessx-close()
+.xorgcfg.test.translations:	#override \
+<Message>WM_PROTOCOLS:	testmode-cancel()
+.xorgcfg.Expert.translations:	#override \
+<Message>WM_PROTOCOLS:	expert-close()
+.xorgcfg.options.moduleOptions.translations:	#override \
+<Message>WM_PROTOCOLS:	module-options-close()
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Options
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+.xorgcfg.options.geometry:		400x176
+.xorgcfg.options.minWidth:		400
+.xorgcfg.options.maxWidth:		400
+.xorgcfg.options.minHeight:		176
+.xorgcfg.options.maxHeight:		176
+
+*options*commands.remove.fromHoriz:	add
+*options*commands.update.fromHoriz:	remove
+*options*commands.help.fromHoriz:	update
+*options*commands.min:			30
+*options*commands.max:			30
+*options*commands.showGrip:		False
+*options*commands.defaultDistance:	4
+*options*commands.?.width:		100
+*options*commands.?.height:		20
+
+*options*name.fromHoriz:		label1
+*options*label2.fromHoriz:		name
+*options*value.fromHoriz:		label2
+*options*label3.fromHoriz:		value
+*options*viewport.fromVert:		name
+*options*Label.borderWidth:		0
+*options.pane.form.Label.internalWidth:	0
+*options.pane.form.Label.height:	21
+*options.pane.form.Text.height:		19
+*options.pane.form.Label.top:		chainTop
+*options.pane.form.Text.top:		chainTop
+*options.pane.form.Label.bottom:	chainTop
+*options.pane.form.Text.bottom:		chainTop
+*options.pane.form.Label.horizDistance:	0
+*options.pane.form.Text.horizDistance:	0
+*options.pane.form.Label.vertDistance:	8
+*options.pane.form.Text.vertDistance:	8
+*options.pane.form.Text.width:		147
+*options*viewport.width:		390
+*options*viewport.height:		50
+
+*options*viewport.horizDistance:	7
+*options*label1.horizDistance:		5
+*options*viewport.left:			chainLeft
+*options*viewport.right:		chainRight
+*options*list.longest:			376
+
+*options*driverOpts.label:		Options for module\ 
+*options*driverOpts.justify:		left
+*options*driverOpts.width:		278
+*options*popdown.label:			Popdown dialog
+*options*driverOpts.tip:		This menu shows:\n\
+ o option name\n\
+ o option type
+
+.xorgcfg*options.moduleOptions.geometry:			360x245
+.xorgcfg*options.moduleOptions.minWidth:			360
+.xorgcfg*options.moduleOptions.maxWidth:			360
+.xorgcfg*options.moduleOptions.minHeight:			245
+.xorgcfg*options.moduleOptions.maxHeight:			245
+*options.moduleOptions*descriptions*labelType.label:		Select option
+*options.moduleOptions*descriptions*labelType.width:		348
+*options.moduleOptions*descriptions*module.fromVert:		labelType
+*options.moduleOptions*descriptions*module.label:		Module
+*options.moduleOptions*descriptions*Label.horizDistance:	8
+*options.moduleOptions*descriptions*option.fromVert:		labelType
+*options.moduleOptions*descriptions*option.label:		Option
+*options.moduleOptions*descriptions*option.fromHoriz:		viewM
+*options.moduleOptions*descriptions*viewM.fromVert:		module
+*options.moduleOptions*descriptions*viewM.width:		120
+*options.moduleOptions*descriptions*viewM.height:		94
+*options.moduleOptions*descriptions*modL.longest:		100
+*options.moduleOptions*descriptions*viewO.fromHoriz:		viewM
+*options.moduleOptions*descriptions*viewO.fromVert:		option
+*options.moduleOptions*descriptions*viewO.width:		220
+*options.moduleOptions*descriptions*viewO.height:		94
+*options.moduleOptions*descriptions*optL.longest:		220
+*options.moduleOptions*descriptions*desc.horizDistance:		4
+*options.moduleOptions*descriptions*desc.fromVert:		viewM
+*options.moduleOptions*descriptions*desc.width:			348
+*options.moduleOptions*descriptions*desc.height:		62
+*options.moduleOptions*descriptions*desc.wrap:			word
+*options.moduleOptions*descriptions*desc.scrollVertical:	Always
+*options.moduleOptions*descriptions*desc.Scrollbar.foreground:	rgb:a/5/5
+*options.moduleOptions*descriptions*desc.Scrollbar.borderWidth:	1
+*options.moduleOptions*descriptions*desc.Scrollbar.borderColor:	gray60
+*options.moduleOptions*descriptions.showGrip:			False
+*options.moduleOptions*popdown.label:				Popdown dialog
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! monitor
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*monitorl*Viewport.width:		320
+*monitorl*Text.width:			200
+*monitorl*Text.tip:\
+Select standard value from the list\n\
+below, or enter specific value here.
+
+*monitorl*hlabel.justify:		left
+*monitorl*hlabel.width:			134
+*monitorl*hlabel.label:			Horizontal sync
+*monitorl*hsync.fromHoriz:		hlabel
+*monitorl*hviewport.fromVert:		hsync
+*monitorl*hviewport.width:		354
+*monitorl*hviewport.height:		156
+*monitorl*hlist.longest:		386
+
+*monitorl*vlabel.justify:		left
+*monitorl*vlabel.width:			134
+*monitorl*vlabel.vertDistance:		12
+*monitorl*vsync.vertDistance:		12
+*monitorl*vlabel.fromVert:		hviewport
+*monitorl*vsync.fromVert:		hviewport
+*monitorl*vlabel.label:			Vertical sync
+*monitorl*vsync.fromHoriz:		vlabel
+*monitorl*vviewport.fromVert:		vsync
+*monitorl*vviewport.width:		354
+*monitorl*vviewport.height:		20
+*monitorl*vlist.longest:		80
+
+*monitorl*clabel.vertDistance:		12
+*monitorl*clabel.fromVert:		vviewport
+*monitorl*clabel.label:			Select card connected to monitor
+*monitorl*cmenu.fromVert:		clabel
+*monitorl*cmenu.width:			302
+*monitorl*cmenu.justify:		left
+*monitorl*none.label:			None
+
+!! vidtune
+*vidtune.Repeater.borderWidth:		1
+*vidtune.Repeater.borderColor:		gray90
+*vidtune.Repeater.shapeStyle:		ellipse
+*vidtune.Repeater.foreground:		gray30
+*vidtune.Repeater.background:		gray80
+*vidtune.Repeater.width:		31
+*vidtune.Repeater.height:		29
+*vidtune.Repeater.repeatDelay:		200
+*vidtune.Repeater.decay:		0
+*vidtune.Repeater.displayList:\
+line-width	2;\
+foreground	gray65;\
+draw-arc	0,0,-0,-0,230,180;\
+foreground	gray95;\
+draw-arc	0,0,-0,-0,40,180;\
+foreground	gray80;\
+draw-arc	0,0,-0,-0,220,10;\
+draw-arc	0,0,-0,-0,40,10
+*vidtune.Repeater.translations:\
+<Enter>:	set-values(1, borderColor, gray50)\n\
+<Leave>:	set-values(1, borderColor, gray90)\n\
+<Btn1Down>:	set-values(1, borderColor, gray90) set() start()\n\
+<Btn1Up>:	stop() unset()
+*vidtune.left.bitmap:			left.xbm
+*vidtune.right.bitmap:			right.xbm
+*vidtune.up.bitmap:			up.xbm
+*vidtune.down.bitmap:			down.xbm
+*vidtune.wider.bitmap:			wider.xbm
+*vidtune.narrower.bitmap:		narrower.xbm
+*vidtune.shorter.bitmap:		shorter.xbm
+*vidtune.taller.bitmap:			taller.xbm
+
+*vidtune.vesaB.label:			Add standard VESA mode to current screen
+*vidtune.vesaB.width:			384
+
+*vidtune.screenB.fromVert:		mode
+*vidtune.screenB.width:			160
+*vidtune.screenB.horizDistance:		80
+*vidtune.prev.fromVert:			vesaB
+*vidtune.mode.fromVert:			vesaB
+*vidtune.next.fromVert:			vesaB
+*vidtune.prev.horizDistance:		54
+*vidtune.prev.label:			<<
+*vidtune.mode.fromHoriz:		prev
+*vidtune.mode.width:			160
+*vidtune.next.label:			>>
+*vidtune.next.fromHoriz:		mode
+
+*vidtune.up.fromVert:			screenB
+*vidtune.up.horizDistance:		143
+*vidtune.left.horizDistance:		98
+*vidtune.left.vertDistance:		16
+*vidtune.left.fromVert:			up
+*vidtune.monitor.fromVert:		up
+*vidtune.monitor.vertDistance:		0
+*vidtune.monitor.fromHoriz:		left
+*vidtune.right.vertDistance:		16
+*vidtune.right.fromVert:		up
+*vidtune.right.fromHoriz:		monitor
+*vidtune.down.horizDistance:		143
+*vidtune.down.fromVert:			monitor
+*vidtune.wider.fromVert:		left
+*vidtune.wider.horizDistance:		91
+*vidtune.narrower.fromVert:		down
+*vidtune.narrower.fromHoriz:		wider
+*vidtune.shorter.fromVert:		down
+*vidtune.shorter.fromHoriz:		narrower
+*vidtune.taller.fromVert:		right
+*vidtune.taller.fromHoriz:		shorter
+*vidtune.monitor.width:			47
+*vidtune.monitor.height:		40
+*vidtune.monitor.backgroundPixmap:	monitor.xpm
+*vidtune.narrower.horizDistance:	0
+*vidtune.shorter.horizDistance:		2
+*vidtune.taller.horizDistance:		0
+*vidtune.wider.vertDistance:		20
+*vidtune.taller.vertDistance:		20
+*vidtune.narrower.vertDistance:		0
+*vidtune.shorter.vertDistance:		0
+*vidtune.down.vertDistance:		0
+
+*vidtune.monitor.tip:\
+\                  WARNING\n\
+\  Using the  controls here  may damage your\n\
+monitor.  You can safely skip  this section\n\
+of the configuration process.\n\
+\n\
+Press ESC if your monitor goes out of sync.
+
+*vidtune.background:			white
+*vidtune.form.borderWidth:		0
+*vidtune.form.background:		white
+*vidtune.form.defaultDistance:		0
+*vidtune.form.vertDistance:		3
+*vidtune.form.horizDistance:		4
+*vidtune.form.Label.foreground:		gray20
+*vidtune.form.Label.background:		white
+*vidtune.form.Label.font:		-*-fixed-*-*-*-*-10-*-*-*-*-*-*-1
+*vidtune.form.Label.vertDistance:	0
+*vidtune*Label.justify:			right
+
+*vidtune.form.fromVert:			auto
+*vidtune*hsyncstart.label:		HSyncStart:
+*vidtune*hsyncstart.width:		95
+*vidtune*v-hsyncstart.width:		40
+*vidtune*v-hsyncstart.fromHoriz:	hsyncstart
+*vidtune*vsyncstart.fromHoriz:		v-hsyncstart
+*vidtune*v-vsyncstart.fromHoriz:	vsyncstart
+*vidtune*vsyncstart.label:		VSyncStart:
+*vidtune*vsyncstart.width:		95
+*vidtune*v-vsyncstart.width:		40
+*vidtune*hsyncend.label:		HSyncEnd:
+*vidtune*hsyncend.width:		95
+*vidtune*v-hsyncend.width:		40
+*vidtune*v-hsyncend.fromHoriz:		hsyncend
+*vidtune*hsyncend.fromVert:		hsyncstart
+*vidtune*v-hsyncend.fromVert:		v-hsyncstart
+*vidtune*vsyncend.label:		VSyncEnd:
+*vidtune*vsyncend.width:		95
+*vidtune*v-vsyncend.width:		40
+*vidtune*vsyncend.fromHoriz:		v-hsyncend
+*vidtune*v-vsyncend.fromHoriz:		vsyncend
+*vidtune*vsyncend.fromVert:		hsyncstart
+*vidtune*v-vsyncend.fromVert:		v-vsyncstart
+*vidtune*htotal.label:			HTotal:
+*vidtune*htotal.width:			95
+*vidtune*v-htotal.width:		40
+*vidtune*v-htotal.fromHoriz:		htotal
+*vidtune*htotal.fromVert:		hsyncend
+*vidtune*v-htotal.fromVert:		v-hsyncend
+*vidtune*vtotal.label:			VTotal:
+*vidtune*vtotal.width:			95
+*vidtune*v-vtotal.width:		40
+*vidtune*vtotal.fromHoriz:		v-htotal
+*vidtune*v-vtotal.fromHoriz:		vtotal
+*vidtune*vtotal.fromVert:		vsyncend
+*vidtune*v-vtotal.fromVert:		v-vsyncend
+*vidtune*flags.label:			Flags:
+*vidtune*flags.width:			142
+*vidtune*v-flags.width:			156
+*vidtune*v-flags.justify:		left
+*vidtune*v-flags.fromHoriz:		flags
+*vidtune*flags.fromVert:		vtotal
+*vidtune*v-flags.fromVert:		v-vtotal
+*vidtune*clock.label:			Pixel Clock (MHz):
+*vidtune*clock.width:			142
+*vidtune*v-clock.width:			48
+*vidtune*v-clock.fromHoriz:		clock
+*vidtune*clock.fromVert:		flags
+*vidtune*v-clock.fromVert:		v-flags
+*vidtune*hsync.label:			Horizontal Sync (kHz):
+*vidtune*hsync.width:			142
+*vidtune*v-hsync.width:			48
+*vidtune*v-hsync.fromHoriz:		hsync
+*vidtune*hsync.fromVert:		clock
+*vidtune*v-hsync.fromVert:		v-clock
+*vidtune*vsync.label:			Vertical Sync (Hz):
+*vidtune*vsync.width:			142
+*vidtune*v-vsync.width:			48
+*vidtune*v-vsync.fromHoriz:		vsync
+*vidtune*vsync.fromVert:		hsync
+*vidtune*v-vsync.fromVert:		v-hsync
+
+*vidtune.auto.horizDistance:		43
+*vidtune.auto.fromVert:			narrower
+*vidtune.auto.label:			Auto
+!*vidtune.auto.state:			True
+*vidtune.apply.fromVert:		narrower
+*vidtune.apply.fromHoriz:		auto
+*vidtune.apply.label:			Apply
+*vidtune.restore.fromHoriz:		apply
+*vidtune.restore.horizDistance:		4
+*vidtune.restore.fromVert:		narrower
+*vidtune.restore.label:			Restore
+*vidtune.update.fromVert:		narrower
+*vidtune.update.fromHoriz:		restore
+*vidtune.update.label:			Update
+*vidtune.test.fromVert:			narrower
+*vidtune.test.fromHoriz:		update
+*vidtune.test.label:			Test
+
+*vidtune.Label.background:		white
+*vidtune.addto.vertDistance:		4
+*vidtune.addto.fromHoriz:		add
+*vidtune.addto.fromVert:		form
+*vidtune.addto.label:			mode to
+*vidtune.addto.horizDistance:		0
+*vidtune.ident.vertDistance:		4
+*vidtune.ident.horizDistance:		0
+*vidtune.ident.fromVert:		form
+*vidtune.ident.fromHoriz:		addto
+*vidtune.ident.width:			98
+*vidtune.ident.justify:			left
+*vidtune.as.vertDistance:		4
+*vidtune.as.horizDistance:		0
+*vidtune.as.fromVert:			form
+*vidtune.as.fromHoriz:			ident
+*vidtune.as.label:			as:
+*vidtune.text.vertDistance:		4
+*vidtune.text.horizDistance:		0
+*vidtune.text.fromVert:			form
+*vidtune.text.fromHoriz:		as
+*vidtune.text.width:			136
+*vidtune.add.vertDistance:		4
+*vidtune.add.fromVert:			form
+*vidtune.add.label:			Add
+.xorgcfg.force.geometry:		308x58
+.xorgcfg.force.minWidth:		308
+.xorgcfg.force.maxWidth:		308
+.xorgcfg.force.minHeight:		58
+.xorgcfg.force.maxHeight:		58
+.xorgcfg.force.?.label:			There is already a modeline with the\n\
+specified identifier. Add anyway?
+
+.xorgcfg.addMode.geometry:		460x80
+.xorgcfg.addMode.minWidth:		460
+.xorgcfg.addMode.maxWidth:		460
+.xorgcfg.addMode.minHeight:		80
+.xorgcfg.addMode.maxHeight:		80
+.xorgcfg.addMode.?.label:		XF86VidModeAddModeLine returned True,\n\
+but no modeline was added to the current Screen.\n\
+Do you want to add it to the Monitor section?
+
+.xorgcfg.test.?.label:			\        Testing modeline...\n\n\
+Press ESC or stop button to quit.
+.xorgcfg.test.geometry:			308x72
+.xorgcfg.test.minWidth:			308
+.xorgcfg.test.maxWidth:			308
+.xorgcfg.test.minHeight:		72
+.xorgcfg.test.maxHeight:		72
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! screen
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*screenD*depthL.label:			Default color depth:
+*screenD*depthL.height:			20
+*screenD*1.fromHoriz:			depthL
+*screenD*4.fromHoriz:			1
+*screenD*8.fromHoriz:			4
+*screenD*16.fromHoriz:			8
+*screenD*24.fromHoriz:			16
+*screenD*1.width:			24
+*screenD*4.width:			24
+*screenD*8.width:			24
+*screenD*16.width:			24
+*screenD*24.width:			24
+*screenD*1.horizDistance:		5
+*screenD*4.horizDistance:		5
+*screenD*8.horizDistance:		5
+*screenD*16.horizDistance:		5
+*screenD*24.horizDistance:		5
+*screenD*modeL.fromVert:		depthL
+*screenD*modeL.vertDistance:		14
+*screenD*modeL.label:			Select resolution(s):
+*screenD*viewL.fromVert:		modeL
+*screenD*select.fromHoriz:		viewL
+*screenD*unselect.fromHoriz:		viewL
+*screenD*select.fromVert:		modeL
+*screenD*unselect.fromVert:		select
+*screenD*up.fromHoriz:			viewL
+*screenD*down.fromHoriz:		viewL
+*screenD*up.fromVert:			unselect
+*screenD*down.fromVert:			up
+*screenD*viewR.fromHoriz:		select
+*screenD*viewR.fromVert:		modeL
+*screenD*select.bitmap:			right.xbm
+*screenD*unselect.bitmap:		left.xbm
+*screenD*up.bitmap:			up.xbm
+*screenD*down.bitmap:			down.xbm
+*screenD*viewL.width:			155
+*screenD*viewR.width:			155
+*screenD*viewL.height:			188
+*screenD*viewR.height:			188
+*screenD*listLeft.longest:		128
+*screenD*listRight.longest:		128
+*screenD*rotate.tip:			Don't select any option if\n\
+your monitor is not rotated.
+*screenD*rotate.vertDistance:		14
+*screenD*rotate.fromVert:		viewL
+*screenD*rotate.label:			Rotate screen:
+*screenD*CW.tip:			Clock wise
+*screenD*CW.vertDistance:		14
+*screenD*CW.fromVert:			viewL
+*screenD*CW.fromHoriz:			rotate
+*screenD*CW.label:			CW
+*screenD*CW.width:			40
+*screenD*CCW.tip:			Counter-clock wise
+*screenD*CCW.vertDistance:		14
+*screenD*CCW.fromVert:			viewL
+*screenD*CCW.fromHoriz:			CW
+*screenD*CCW.label:			CCW
+*screenD*CCW.width:			40
+
+*work.screen.width:			100
+*work.screen.height:			80
+
+
+*Dialog.background:			gray85
+*quit.ask.label:			Write configuration to
+*quit.ask.value.translations:	#override \
+<Key>Return:	write-config()
+*quit.ask.label.justify:		left
+*quit.ask.value.width:			250
+*quit.ask.icon:				Excl
+.xorgcfg.quit.geometry:			280x100
+.xorgcfg.quit.minWidth:			280
+.xorgcfg.quit.maxWidth:			280
+.xorgcfg.quit.minHeight:		100
+.xorgcfg.quit.maxHeight:		100
+
+*error.notice.label:			Failed to write configuration file.
+.xorgcfg.error.geometry:		280x50
+.xorgcfg.error.minWidth:		260
+.xorgcfg.error.maxWidth:		260
+.xorgcfg.error.minHeight:		50
+.xorgcfg.error.maxHeight:		50
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! accessx
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*Accessx*Label.font:			-*-fixed-medium-r-*-*-13-*-*-*-*-*-iso8859-1
+*Accessx.Form.Toggle.font:		-*-fixed-medium-r-*-*-13-*-*-*-*-*-iso8859-1
+*Accessx*Label.background:		white
+*Accessx*Label.justify:			left
+*Accessx*Label.internalHeight:		0
+*Accessx*Label.internalWidth:		0
+*Accessx*Label.foreground:		gray35
+*Accessx*Toggle.internalHeight:		0
+*Accessx.Toggle.internalWidth:		18
+*Accessx.Toggle.justify:		left
+*Accessx.Toggle.foreground:		gray30
+*Accessx.Toggle.background:		white
+*Accessx*Toggle.highlightThickness:	0
+*Accessx.Toggle.foreground:		rgb:f/7/7
+*Accessx.Toggle.displayList:\
+foreground	white;\
+points		0,0,-1,0;\
+foreground	rgb:f/7/7;\
+fill-poly	0,2,0,-3,8,6
+*Accessx.Toggle.translations: \
+<Btn1Down>,<Btn1Up>: toggle() notify()\n\
+<Enter>: set-values(1, displayList, "foreground white;points 0,0,-1,0;fill-poly 0,1,10,6,0,-2;foreground rgb:7/7/f;fill-poly 0,2,0,-3,8,6")\n\
+<Leave>: set-values(1, displayList, "foreground white;points 0,0,-1,0;foreground rgb:f/7/7;fill-poly 0,2,0,-3,8,6")
+*Accessx.Form.borderWidth:		1
+*Accessx.Form.borderColor:		rgb:f/a/a
+*Accessx.Form.vertDistance:		0
+*Accessx.Form.defaultDistance:		2
+*Accessx.borderWidth:			0
+*accessxForm.background:		white
+*Accessx*Form.background:		white
+*Accessx.background:			white
+*accessxForm.enable.label:		Enable AccessX
+*accessxForm.enable.width:		208
+*accessxForm.apply.fromHoriz:		enable
+*accessxForm.apply.label:		Apply changes
+*accessxForm.Accessx.fromVert:		enable
+*Accessx.timeoutToggle.background:	white
+*Accessx.timeoutToggle.foreground:	rgb:7/7/f
+*Accessx.timeoutToggle.displayList:\
+foreground	rgb:a/a/f;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	rgb:2/2/a;\
+lines		-1,0,0,0,0,-1
+
+*Accessx.Form.Toggle.background:	white
+*Accessx.Form.Toggle.foreground:	rgb:7/7/f
+*Accessx.Form.Toggle.displayList:\
+foreground	rgb:a/a/f;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	rgb:2/2/a;\
+lines		-1,0,0,0,0,-1
+*Accessx.Form.Toggle.translations: \
+<Btn1Down>,<Btn1Up>: toggle() notify()\n\
+<Enter>: set-values(1, displayList, "foreground rgb:a/a/f;lines 1,-1,-1,-1,-1,1;foreground rgb:2/2/a;lines -1,0,0,0,0,-1;foreground rgb:f/7/7;draw-rect 1,1,-2,-2")\n\
+<Leave>: set-values(1, displayList, "foreground rgb:a/a/f;lines 1,-1,-1,-1,-1,1;foreground rgb:2/2/a;lines -1,0,0,0,0,-1")
+
+*Accessx.timeoutToggle.internalWidth:	4
+*Accessx.timeoutToggle.translations:\
+<Btn1Down>,<Btn1Up>:	toggle() notify()
+*Accessx.timeoutToggle.internalWidth:	4
+*Accessx.timeoutToggle.internalHeight:	1
+*Accessx.timeoutToggle.vertDistance:	6
+*Accessx.timeoutToggle.label:		Time Out
+*Accessx.timeoutLabel.fromHoriz:	timeoutToggle
+*Accessx.timeoutLabel.vertDistance:	7
+*Accessx.timeoutLabel.label:		Time (min)
+*Accessx.Label.background:		white
+*Accessx.timeoutNumber.vertDistance:	1
+*Accessx.timeoutNumber.fromHoriz:	timeoutLabel
+*Accessx.timeoutNumber.font:		6x9
+*Accessx.timeoutNumber.label:		??
+*Accessx.timeoutScroller.fromVert:	timeoutNumber
+*Accessx.timeoutScroller.fromHoriz:	timeoutLabel
+*Accessx.timeoutScroller.width:		133
+*Accessx.timeoutScroller.horizDistance:	31
+*Accessx*Scrollbar.vertDistance:	0
+*Accessx*Scrollbar.orientation:		horizontal
+*Accessx*Scrollbar.thumb:		black
+*Accessx*Scrollbar.height:		8
+*Accessx*Scrollbar.minimumThumb:	5
+*Accessx*Scrollbar.borderWidth:		1
+*Accessx*Scrollbar.borderColor:		white
+*Accessx*Scrollbar.foreground:		rgb:f/7/7
+*Accessx*Scrollbar.background:		gray95
+*Accessx*Scrollbar.displayList:\
+foreground	gray80;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	gray90;\
+lines		-1,0,0,0,0,-1
+*Accessx.sticky.fromVert:		timeoutToggle
+*Accessx.sticky.vertDistance:		6
+*Accessx.sticky.label:			Enable StickyKeys
+*Accessx.sticky.width:			304
+*Accessx.stickyForm.fromVert:		sticky
+*Accessx.stickyForm.Toggle.width:	148
+*Accessx.stickyForm.Toggle.internalHeight:	1
+*Accessx.stickyForm.auto.label:		Auto off
+*Accessx.stickyForm.beep.fromHoriz:	auto
+*Accessx.stickyForm.beep.label:		Modifiers beep
+*Accessx.mouseKeys.fromVert:		stickyForm
+*Accessx.mouseKeys.width:		304
+*Accessx.mouseKeys.vertDistance:	6
+*Accessx.mouseKeys.label:		Enable MouseKeys
+*Accessx.mouseForm.fromVert:		mouseKeys
+*Accessx.mouseForm.speedLabel.vertDistance:	7
+*Accessx.mouseForm.speedLabel.label:	Peak speed (pixels/sec)
+*Accessx.mouseForm.speedNumber.fromHoriz:	speedLabel
+*Accessx.mouseForm.speedNumber.font:	6x9
+*Accessx.mouseForm.speedNumber.label:		???
+*Accessx.mouseForm.speedScroller.fromHoriz:	speedLabel
+*Accessx.mouseForm.speedScroller.fromVert:	speedNumber
+*Accessx.mouseForm.speedScroller.width:		133
+*Accessx.mouseForm.timeLabel.fromVert:	speedScroller
+*Accessx.mouseForm.timeLabel.label:	Time to peak (sec)
+*Accessx.mouseForm.timeLabel.vertDistance:	7
+*Accessx.mouseForm.timeNumber.label:	???
+*Accessx.mouseForm.timeNumber.fromVert:	speedScroller
+*Accessx.mouseForm.timeNumber.fromHoriz:	timeLabel
+*Accessx.mouseForm.timeNumber.font:	6x9
+*Accessx.mouseForm.timeScroller.fromHoriz:	timeLabel
+*Accessx.mouseForm.timeScroller.fromVert:	timeNumber
+*Accessx.mouseForm.timeScroller.width:	133
+*Accessx.mouseForm.timeScroller.horizDistance:	37
+*Accessx.mouseForm.delayLabel.fromVert:	timeScroller
+*Accessx.mouseForm.delayLabel.label:	Motion delay (sec)
+*Accessx.mouseForm.delayLabel.tip:\
+Time between the initial key press\n\
+and the first repeated motion event
+*Accessx.mouseForm.delayLabel.vertDistance:	7
+*Accessx.mouseForm.delayNumber.label:	???
+*Accessx.mouseForm.delayNumber.fromVert:	timeScroller
+*Accessx.mouseForm.delayNumber.fromHoriz:	delayLabel
+*Accessx.mouseForm.delayNumber.font:	6x9
+*Accessx.mouseForm.delayScroller.fromHoriz:	delayLabel
+*Accessx.mouseForm.delayScroller.fromVert:	delayNumber
+*Accessx.mouseForm.delayScroller.width:	133
+*Accessx.mouseForm.delayScroller.horizDistance:	37
+*Accessx.repeatKeys.fromVert:		mouseForm
+*Accessx.repeatKeys.width:		304
+*Accessx.repeatKeys.vertDistance:	6
+*Accessx.repeatKeys.label:		Enable RepeatKeys
+*Accessx.repeatForm.fromVert:		repeatKeys
+*Accessx.repeatForm.rateLabel.vertDistance:	7
+*Accessx.repeatForm.rateLabel.label:	Repeat rate (sec/key)
+*Accessx.repeatForm.rateNumber.fromHoriz:	rateLabel
+*Accessx.repeatForm.rateNumber.font:	6x9
+*Accessx.repeatForm.rateNumber.label:	????
+*Accessx.repeatForm.rateScroller.fromHoriz:	rateLabel
+*Accessx.repeatForm.rateScroller.fromVert:	rateNumber
+*Accessx.repeatForm.rateScroller.width:	133
+*Accessx.repeatForm.rateScroller.horizDistance:	16
+*Accessx.repeatForm.delayLabel.fromVert:	rateScroller
+*Accessx.repeatForm.delayLabel.label:	Repeat delay (sec)
+*Accessx.repeatForm.delayLabel.vertDistance:	7
+*Accessx.repeatForm.delayNumber.label:	????
+*Accessx.repeatForm.delayNumber.fromVert:	rateScroller
+*Accessx.repeatForm.delayNumber.fromHoriz:	delayLabel
+*Accessx.repeatForm.delayNumber.font:	6x9
+*Accessx.repeatForm.delayScroller.fromHoriz:	delayLabel
+*Accessx.repeatForm.delayScroller.fromVert:	delayNumber
+*Accessx.repeatForm.delayScroller.width:	133
+*Accessx.repeatForm.delayScroller.horizDistance:	37
+*Accessx.slow.fromVert:			repeatForm
+*Accessx.slow.vertDistance:		6
+*Accessx.slow.label:			Enable SlowKeys
+*Accessx.slow.width:			304
+*Accessx.slowForm.fromVert:		slow
+*Accessx.slowForm.Toggle.horizDistance:	4
+*Accessx.slowForm.Toggle.internalWidth:	4
+*Accessx.slowForm.Toggle.internalHeight:	1
+*Accessx.slowForm.beep.label:		Beep when key is
+*Accessx.slowForm.beep.vertDistance:	3
+*Accessx.slowForm.pressed.fromHoriz:	beep
+*Accessx.slowForm.pressed.label:	pressed
+*Accessx.slowForm.accepted.fromHoriz:	pressed
+*Accessx.slowForm.accepted.label:	accepted
+*Accessx.slowForm.slowLabel.fromVert:	accepted
+*Accessx.slowForm.slowLabel.label:	Key delay (sec)
+*Accessx.slowForm.slowLabel.vertDistance:	7
+*Accessx.slowForm.slowNumber.label:	???
+*Accessx.slowForm.slowNumber.fromVert:	accepted
+*Accessx.slowForm.slowNumber.fromHoriz:	slowLabel
+*Accessx.slowForm.slowNumber.font:	6x9
+*Accessx.slowForm.slowScroller.fromHoriz:	slowLabel
+*Accessx.slowForm.slowScroller.fromVert:	slowNumber
+*Accessx.slowForm.slowScroller.width:	133
+*Accessx.slowForm.slowScroller.horizDistance:	58
+*Accessx.bounce.fromVert:		slowForm
+*Accessx.bounce.vertDistance:		6
+*Accessx.bounce.label:			Enable BounceKeys
+*Accessx.bounce.width:			304
+*Accessx.bounceForm.fromVert:		bounce
+*Accessx.bounceForm.bounceLabel.label:	Debounce time (sec)
+*Accessx.bounceForm.bounceLabel.vertDistance:	7
+*Accessx.bounceForm.bounceNumber.label:	???
+*Accessx.bounceForm.bounceNumber.fromHoriz:	bounceLabel
+*Accessx.bounceForm.bounceNumber.font:	6x9
+*Accessx.bounceForm.bounceScroller.fromHoriz:	bounceLabel
+*Accessx.bounceForm.bounceScroller.fromVert:	bounceNumber
+*Accessx.bounceForm.bounceScroller.width:	133
+*Accessx.bounceForm.bounceScroller.horizDistance:	30
+
+*accessx.geometry:			220x253
+*accessx.minWidth:			220
+*accessx.maxWidth:			220
+*accessx.minHeight:			253
+*accessx.maxHeight:			253
+*accessx*lock.fromVert:			label
+*accessx*div.fromVert:			label
+*accessx*div.fromHoriz:			lock
+*accessx*mul.fromVert:			label
+*accessx*mul.fromHoriz:			div
+*accessx*minus.fromVert:		label
+*accessx*minus.fromHoriz:		mul
+*accessx*7.fromVert:			lock
+*accessx*8.fromVert:			div
+*accessx*8.fromHoriz:			7
+*accessx*9.fromVert:			mul
+*accessx*9.fromHoriz:			8
+*accessx*plus.fromVert:			minus
+*accessx*plus.fromHoriz:		9
+*accessx*4.fromVert:			7
+*accessx*5.fromVert:			8
+*accessx*5.fromHoriz:			4
+*accessx*6.fromVert:			9
+*accessx*6.fromHoriz:			5
+*accessx*1.fromVert:			4
+*accessx*2.fromVert:			5
+*accessx*2.fromHoriz:			1
+*accessx*3.fromVert:			6
+*accessx*3.fromHoriz:			2
+*accessx*enter.fromVert:		plus
+*accessx*enter.fromHoriz:		3
+*accessx*0.fromVert:			2
+*accessx*del.fromVert:			3
+*accessx*del.fromHoriz:			0
+*accessx.form.background:		gray80
+*accessx*Label.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1
+*accessx*label.font:			fixed
+*accessx*Label.font:			-*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1
+*accessx*Label.width:			50
+*accessx*Label.height:			35
+*accessx*label.width:			212
+*accessx*label.height:			50
+*accessx*plus.height:			74
+*accessx*enter.height:			74
+*accessx*0.width:			104
+*accessx*lock.label:			Num\nLock
+*accessx*div.label:			/\n\ 
+*accessx*mul.label:			*\n\ 
+*accessx*minus.label:			-\n\ 
+*accessx*7.label:			7\n\ 
+*accessx*8.label:			8\n\ 
+*accessx*9.label:			9\n\ 
+*accessx*plus.label:			+\n\ \n\ \n\ \n\ 
+*accessx*4.label:			4\n\ 
+*accessx*5.label:			5\n\ 
+*accessx*6.label:			6\n\ 
+*accessx*1.label:			1\n\ 
+*accessx*2.label:			2\n\ 
+*accessx*3.label:			3\n\ 
+*accessx*enter.label:			Enter\n\ \n\ \n\ \n\ 
+*accessx*0.label:			0\n\ 
+*accessx*del.label:			.\n\ \n\ 
+*accessx*label.displayList:\
+foreground	white;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	gray20;\
+lines		-1,0,0,0,0,-1
+*accessx*label.label:\
+If your mouse does not work, use\n\
+the  numeric  keypad,  following\n\
+the diagram bellow.
+*accessx*div.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\
+draw-string	4,30, "Button 1"
+*accessx*mul.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\
+draw-string	4,30, "Button 2"
+*accessx*minus.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\
+draw-string	4,30, "Button 3"
+*accessx*7.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	20,20,20,30,30,20
+*accessx*8.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	30,20,20,30,40,30
+*accessx*9.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	20,20,30,30,30,20
+*accessx*plus.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\
+draw-string	9,46, "Double";\
+draw-string	14,60, "Click"
+*accessx*4.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	22,22,30,30,30,14
+*accessx*5.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-10*-*-*-*-*-*-1;\
+draw-string	14,30, "Click"
+*accessx*6.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	30,22,22,30,22,14
+*accessx*1.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	20,20,20,30,30,30
+*accessx*2.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	28,30,20,22,36,22
+*accessx*3.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+fill-poly	20,30,30,30,30,20
+*accessx*enter.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\
+draw-string	9,46, "Toggle";\
+draw-string	10,60, "Speed"
+*accessx*0.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\
+draw-string	26,30, "Button Lock"
+*accessx*del.displayList:\
+foreground	gray20;\
+lines		+1,-1,-1,-1,-1,+1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1;\
+foreground	red;\
+font		-*-helvetica-bold-o-*-*-8-*-*-*-*-*-*-1;\
+draw-string	12,21, "Button";\
+draw-string	9,30, "Release"
+
+*panner.width:		100
+*panner.height:		100
+
+*help*text.properties:\
+default?family=Times&weight=Medium&slant=R&pixelsize=12&registry=ISO8859&encoding=1,\
+b?weight=Bold,\
+strong?weight=Bold,\
+i?slant=I,\
+em?slant=I,\
+address?slant=I,\
+h1?pixelsize=24&weight=Bold,\
+h2?pixelsize=20&weight=Bold,\
+h3?pixelsize=17&weight=Bold,\
+h4?pixelsize=14&weight=Bold,\
+h5?pixelsize=12&weight=Bold,\
+h6?pixelsize=10&weight=Bold,\
+pre?family=Courier&pixelsize=10,\
+kbd?family=Courier&pixelsize=10,\
+code?family=Courier&pixelsize=10,\
+samp?family=Courier&pixelsize=10,\
+tt?family=Courier&pixelsize=10
+*help*commands.min:	22
+*help*commands.max:	22
+*help*commands.showGrip:False
+*help*wrap:		word
+*help*commands.close.label:	Close
+.xorgcfg.help.geometry:		320x369
+.xorgcfg.help.minWidth:		320
+.xorgcfg.help.maxWidth:		320
+.xorgcfg.help.minHeight:	369
+.xorgcfg.help.maxHeight:	369
+.xorgcfg.help.translations:	#override \
+<Message>WM_PROTOCOLS:	help-close()
+*help*text.translations:\
+<Key>Up:	scroll-one-line-down()\n\
+<Key>Down:	scroll-one-line-up()\n\
+<Key>Next:	next-page()\n\
+<Key>Prior:	previous-page()\n\
+<Key>space:	next-page()\n\
+<Key>BackSpace:	previous-page()\n\
+<Key>Home:	beginning-of-file()\n\
+<Key>End:	end-of-file()
+*help*text*displayCaret:	False
+*help*text.leftMargin:		10
+*help*text.rightMargin:		10
+
+*help.helpDevices:\
+<h2>Configuring devices</h2>\
+You can arrange the icons pressing the <i>left mouse button</i> \
+and dragging them.\
+<p>\
+To configure a device, press the <i>right mouse button</i> and choose the \
+<tt>configure</tt> option.\
+
+*help.helpScreen:\
+<h2>Configuring screens</h2>\
+You can drag the monitors to set the screen layout form <b>Xinerama</b> \
+pressing the <i>left mouse button</i> and moving them.\
+<p>\
+Press the <i>right mouse button</i> to set configure or set options for \
+the given screen.
+
+*help.helpModeline:\
+<h2>Configuring modelines</h2>\
+<b><font size=+1 color=red>The controls here may damage your \
+monitor.</font></b> \
+<p>\
+You can safelly skip this stage of the configuration process.\
+<p>\
+When not running in <b>Xinerama</b> mode, you can configure modelines \
+for every configured monitor. Set the <b>Auto</b> toggle to see the changes \
+while the <i>control buttons</i> are pressed.\
+<p>\
+Note that the <i>arrow</i> buttons are repeaters. Press they only once \
+and they will show the changes in the <i>text labels</i>.\
+<p>\
+<font color=forestgreen>Press <b>ESC</b> if the monitor goes out of sync.</font>
+
+*help.helpAccessX:\
+<h2>Configuring accessx</h2>\
+This interface is expected to allow customizing most of the <b>accessx</b> \
+options.\
+<p>\
+Press in the <b>Enable ???</b> label to set specific options.\
+<p>\
+<font color=red>Note</font>: currently, if you press the \
+<tt><b>Apply changes</b></tt> button there is no way to undo your changes.</font>
+
+
+*Expert.geometry:				640x460
+*Expert*vpane.min:				64
+*Expert*vpane.max:				64
+*Expert*vpane.showGrip:				False
+*Expert*vpane.close.showGrip:			False
+*Expert*vpane.close.min:			26
+*Expert*vpane.close.max:			26
+*panner.internalSpace:				1
+*panner.shadowThickness:			0
+*panner.shadowColor:				gray60
+*panner.backgroundStipple:			black
+*panner.borderColor:				gray40
+
+*expert*tree.hSpace:				12
+*expert*tree*Box.hSpace:			4
+*expert*tree*vSpace:				4
+*expert*tree*LogFile.Text.width:		192
+*expert*tree*RgbPath.Text.width:		192
+*expert*tree*ModulePath.Text.width:		192
+
+*expert*tree*Form.defaultDistance:		4
+
+*expert*tree.backgroundPixmap:			xlogo64?foreground=gray90&background=gray92
+*expert*tree.foreground:			gray45
+
+*expert*tree*Label.backgroundPixmap:		ParentRelative
+
+*expert*tree*Box.backgroundPixmap:		gradient:vertical?dimension=3&start=gray85&end=gray95
+*expert*tree*Box.borderWidth:			0
+*expert*tree*Box.background:			gray85
+*expert*Box.displayList:\
+foreground	gray40;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1
+
+*expert*tree*Form.backgroundPixmap:		gradient:vertical?dimension=3&start=gray85&end=gray95
+*expert*tree*Form.borderWidth:			0
+*expert*tree*Form.background:			gray85
+*expert*Form.displayList:\
+foreground	gray40;\
+lines		1,-1,-1,-1,-1,1;\
+foreground	white;\
+lines		-1,0,0,0,0,-1
+
+*expert*tree*Text.width:			160
+
+*expert*tree*fontpath.Text.width:		228
+*expert*tree*fontpath.up.fromHoriz:		remove
+*expert*tree*fontpath.down.fromHoriz:		up
+*expert*tree*fontpath.value.fromVert:		remove
+*expert*tree*fontpath.valueNew.fromVert:	new
+
+*expert*tree*modulepath.Text.width:		228
+*expert*tree*modulepath.value.fromVert:		remove
+*expert*tree*modulepath.valueNew.fromVert:	new
+
+*expert*tree*module.options.fromHoriz:		remove
+*expert*tree*module.label.fromVert:		remove
+*expert*tree*module.value.fromHoriz:		new
+*expert*tree*module.value.width:		78
+
+*expert*tree*video*Label.justify:		left
+*expert*tree*video.options.fromHoriz:		remove
+*expert*tree*video.adaptor.fromHoriz:		options
+*expert*tree*video.vendorL.width:		78
+*expert*tree*video.vendorL.label:		VendorName
+*expert*tree*video.vendorL.fromVert:		remove
+*expert*tree*video.vendor.fromVert:		remove
+*expert*tree*video.vendor.fromHoriz:		vendorL
+*expert*tree*video.boardL.width:		78
+*expert*tree*video.boardL.label:		BoardName
+*expert*tree*video.boardL.fromVert:		vendor
+*expert*tree*video.board.fromVert:		vendor
+*expert*tree*video.board.fromHoriz:		boardL
+*expert*tree*video.busidL.width:		78
+*expert*tree*video.busidL.label:		BusID
+*expert*tree*video.busidL.fromVert:		board
+*expert*tree*video.busid.fromVert:		board
+*expert*tree*video.busid.fromHoriz:		busidL
+*expert*tree*video.driverL.width:		78
+*expert*tree*video.driverL.label:		Driver
+*expert*tree*video.driverL.fromVert:		busid
+*expert*tree*video.driver.fromVert:		busid
+*expert*tree*video.driver.fromHoriz:		driverL
+*expert*tree*video.value.fromHoriz:		new
+*expert*tree*video.value.width:			78
+*expert*tree*VideoPort.fromVert:		driver
+*expert*tree*VideoPort.horizDistance:		120
+*expert*tree*video.value.width:			149
+
+*expert*tree*port.value.fromHoriz:		new
+*expert*tree*port.options.fromHoriz:		remove
+*expert*tree*port.label.fromVert:		remove
+*expert*tree*port.value.width:			78
+
+*expert*tree*modes.mode.fromHoriz:		remove
+*expert*tree*modes.value.fromHoriz:		new
+*expert*tree*modes.value.width:			78
+
+*expert*tree*modeline.label.fromHoriz:		remove
+*expert*tree*modeline.modeline.fromVert:	remove
+*expert*tree*modeline.modeline.width:		480
+*expert*tree*modeline.value.fromHoriz:		new
+*expert*tree*modeline.value.width:		120
+*expert*tree*modeline.modelineNew.fromVert:	value
+*expert*tree*modeline.modelineNew.width:	480
+
+*expert*tree*monitor.options.fromHoriz:		remove
+*expert*tree*monitor.label.fromHoriz:		options
+
+*expert*tree*monitor.Label.justify:		left
+*expert*tree*monitor.Text.width:		120
+*expert*tree*monitor.vendorL.width:		100
+*expert*tree*monitor.vendorL.label:		VendorName
+*expert*tree*monitor.vendorL.fromVert:		remove
+*expert*tree*monitor.vendor.fromVert:		remove
+*expert*tree*monitor.vendor.fromHoriz:		vendorL
+*expert*tree*monitor.modelnameL.width:		100
+*expert*tree*monitor.modelnameL.label:		ModelName
+*expert*tree*monitor.modelnameL.fromVert:	vendor
+*expert*tree*monitor.modelname.fromVert:	vendor
+*expert*tree*monitor.modelname.fromHoriz:	modelnameL
+*expert*tree*monitor.widthL.width:		100
+*expert*tree*monitor.widthL.label:		Width (mm)
+*expert*tree*monitor.widthL.fromVert:		modelname
+*expert*tree*monitor.width.fromVert:		modelname
+*expert*tree*monitor.width.fromHoriz:		widthL
+*expert*tree*monitor.heightL.width:		100
+*expert*tree*monitor.heightL.label:		Height (mm)
+*expert*tree*monitor.heightL.fromVert:		width
+*expert*tree*monitor.height.fromVert:		width
+*expert*tree*monitor.height.fromHoriz:		heightL
+*expert*tree*monitor.hsyncL.width:		100
+*expert*tree*monitor.hsyncL.label:		Hsync
+*expert*tree*monitor.hsyncL.fromVert:		heightL
+*expert*tree*monitor.hsync.fromVert:		height
+*expert*tree*monitor.hsync.fromHoriz:		hsyncL
+*expert*tree*monitor.vrefreshL.width:		100
+*expert*tree*monitor.vrefreshL.label:		Vrefresh
+*expert*tree*monitor.vrefreshL.fromVert:	hsync
+*expert*tree*monitor.vrefresh.fromVert:		hsync
+*expert*tree*monitor.vrefresh.fromHoriz:	vrefreshL
+*expert*tree*monitor.gammaRedL.width:		100
+*expert*tree*monitor.gammaRedL.label:		Gamma (red)
+*expert*tree*monitor.gammaRedL.fromVert:	vrefresh
+*expert*tree*monitor.gammaRed.fromVert:		vrefresh
+*expert*tree*monitor.gammaRed.fromHoriz:	gammaRedL
+*expert*tree*monitor.gammaGreenL.width:		100
+*expert*tree*monitor.gammaGreenL.label:		Gamma (green)
+*expert*tree*monitor.gammaGreenL.fromVert:	gammaRed
+*expert*tree*monitor.gammaGreen.fromVert:	gammaRed
+*expert*tree*monitor.gammaGreen.fromHoriz:	gammaGreenL
+*expert*tree*monitor.gammaBlueL.width:		100
+*expert*tree*monitor.gammaBlueL.label:		Gamma (blue)
+*expert*tree*monitor.gammaBlueL.fromVert:	gammaGreen
+*expert*tree*monitor.gammaBlue.fromVert:	gammaGreen
+*expert*tree*monitor.gammaBlue.fromHoriz:	gammaBlueL
+*expert*tree*monitor.value.width:		191
+*expert*tree*monitor.value.fromHoriz:		new
+
+*expert*tree*device.Label.justify:		left
+*expert*tree*device.options.fromHoriz:		remove
+*expert*tree*device.label.fromHoriz:		options
+*expert*tree*device.vendorL.label:		VendorName
+*expert*tree*device.vendorL.width:		100
+*expert*tree*device.vendorL.fromVert:		remove
+*expert*tree*device.vendor.fromVert:		remove
+*expert*tree*device.vendor.fromHoriz:		vendorL
+*expert*tree*device.boardL.label:		BoardName
+*expert*tree*device.boardL.width:		100
+*expert*tree*device.boardL.fromVert:		vendor
+*expert*tree*device.board.fromVert:		vendor
+*expert*tree*device.board.fromHoriz:		boardL
+*expert*tree*device.chipsetL.label:		Chipset
+*expert*tree*device.chipsetL.width:		100
+*expert*tree*device.chipsetL.fromVert:		board
+*expert*tree*device.chipset.fromVert:		board
+*expert*tree*device.chipset.fromHoriz:		chipsetL
+*expert*tree*device.busidL.label:		BusID
+*expert*tree*device.busidL.width:		100
+*expert*tree*device.busidL.fromVert:		chipset
+*expert*tree*device.busid.fromVert:		chipset
+*expert*tree*device.busid.fromHoriz:		chipsetL
+*expert*tree*device.cardL.label:		Card
+*expert*tree*device.cardL.width:		100
+*expert*tree*device.cardL.fromVert:		busid
+*expert*tree*device.card.fromVert:		busid
+*expert*tree*device.card.fromHoriz:		cardL
+*expert*tree*device.driverL.label:		Driver
+*expert*tree*device.driverL.width:		100
+*expert*tree*device.driverL.fromVert:		card
+*expert*tree*device.driver.fromVert:		card
+*expert*tree*device.driver.fromHoriz:		driverL
+*expert*tree*device.ramdacL.label:		Ramdac
+*expert*tree*device.ramdacL.width:		100
+*expert*tree*device.ramdacL.fromVert:		driverL
+*expert*tree*device.ramdac.fromVert:		driver
+*expert*tree*device.ramdac.fromHoriz:		ramdacL
+*expert*tree*device.dacSpeedL.label:		DacSpeed
+*expert*tree*device.dacSpeedL.width:		100
+*expert*tree*device.dacSpeedL.fromVert:		ramdac
+*expert*tree*device.dacSpeed.fromVert:		ramdac
+*expert*tree*device.dacSpeed.fromHoriz:		dacSpeedL
+*expert*tree*device.videoRamL.label:		VideoRam
+*expert*tree*device.videoRamL.width:		100
+*expert*tree*device.videoRamL.fromVert:		dacSpeed
+*expert*tree*device.videoRam.fromVert:		dacSpeed
+*expert*tree*device.videoRam.fromHoriz:		videoRamL
+*expert*tree*device.textClockFreqL.label:	TextClockFreq
+*expert*tree*device.textClockFreqL.width:	100
+*expert*tree*device.textClockFreqL.fromVert:	videoRam
+*expert*tree*device.textClockFreq.fromVert:	videoRam
+*expert*tree*device.textClockFreq.fromHoriz:	textClockFreqL
+*expert*tree*device.biosBaseL.label:		BiosBase
+*expert*tree*device.biosBaseL.width:		100
+*expert*tree*device.biosBaseL.fromVert:		textClockFreq
+*expert*tree*device.biosBase.fromVert:		textClockFreq
+*expert*tree*device.biosBase.fromHoriz:		biosBaseL
+*expert*tree*device.memBaseL.label:		MemBase
+*expert*tree*device.memBaseL.width:		100
+*expert*tree*device.memBaseL.fromVert:		biosBase
+*expert*tree*device.memBase.fromVert:		biosBase
+*expert*tree*device.memBase.fromHoriz:		memBaseL
+*expert*tree*device.ioBaseL.label:		IOBase
+*expert*tree*device.ioBaseL.width:		100
+*expert*tree*device.ioBaseL.fromVert:		memBase
+*expert*tree*device.ioBase.fromVert:		memBase
+*expert*tree*device.ioBase.fromHoriz:		ioBaseL
+*expert*tree*device.clockChipL.label:		ClockChip
+*expert*tree*device.clockChipL.width:		100
+*expert*tree*device.clockChipL.fromVert:	ioBase
+*expert*tree*device.clockChip.fromVert:		ioBase
+*expert*tree*device.clockChip.fromHoriz:	clockChipL
+*expert*tree*device.devClockL.label:		Clocks
+*expert*tree*device.devClockL.width:		100
+*expert*tree*device.devClockL.fromVert:		clockChip
+*expert*tree*device.devClock.fromVert:		clockChip
+*expert*tree*device.devClock.fromHoriz:		devClockL
+*expert*tree*device.chipIdL.label:		ChipId
+*expert*tree*device.chipIdL.width:		100
+*expert*tree*device.chipIdL.fromVert:		devClock
+*expert*tree*device.chipId.fromVert:		devClock
+*expert*tree*device.chipId.fromHoriz:		chipIdL
+*expert*tree*device.chipRevL.label:		ChipRev
+*expert*tree*device.chipRevL.width:		100
+*expert*tree*device.chipRevL.fromVert:		chipId
+*expert*tree*device.chipRev.fromVert:		chipId
+*expert*tree*device.chipRev.fromHoriz:		chipRevL
+*expert*tree*device.irqL.label:			IRQ
+*expert*tree*device.irqL.width:			100
+*expert*tree*device.irqL.fromVert:		chipRev
+*expert*tree*device.irq.fromVert:		chipRev
+*expert*tree*device.irq.fromHoriz:		irqL
+*expert*tree*device.screenL.label:		Screen
+*expert*tree*device.screenL.width:		100
+*expert*tree*device.screenL.fromVert:		irq
+*expert*tree*device.screen.fromVert:		irq
+*expert*tree*device.screen.fromHoriz:		screenL
+*expert*tree*device.value.fromHoriz:		new
+
+*expert*tree*screen.Label.justify:		left
+*expert*tree*screen.options.fromHoriz:		remove
+*expert*tree*screen.label.fromHoriz:		options
+*expert*tree*screen.defaultDepthL.label:	DefaultDepth
+*expert*tree*screen.defaultDepthL.width:	92
+*expert*tree*screen.defaultDepthL.fromVert:	remove
+*expert*tree*screen.defaultDepth.fromVert:	remove
+*expert*tree*screen.defaultDepth.fromHoriz:	defaultDepthL
+*expert*tree*screen.defaultBppL.label:		DefaultBpp
+*expert*tree*screen.defaultBppL.width:		92
+*expert*tree*screen.defaultBppL.fromVert:	defaultDepth
+*expert*tree*screen.defaultBpp.fromVert:	defaultDepth
+*expert*tree*screen.defaultBpp.fromHoriz:	defaultBppL
+*expert*tree*screen.defaultFbBppL.label:	DefaultFbBpp
+*expert*tree*screen.defaultFbBppL.width:	92
+*expert*tree*screen.defaultFbBppL.fromVert:	defaultBpp
+*expert*tree*screen.defaultFbBpp.fromVert:	defaultBpp
+*expert*tree*screen.defaultFbBpp.fromHoriz:	defaultFbBppL
+*expert*tree*screen.monitorL.label:		Monitor
+*expert*tree*screen.monitorL.width:		92
+*expert*tree*screen.monitorL.fromVert:		defaultFbBpp
+*expert*tree*screen.monitor.fromVert:		defaultFbBpp
+*expert*tree*screen.monitor.fromHoriz:		monitorL
+*expert*tree*screen.deviceL.label:		Device
+*expert*tree*screen.deviceL.width:		92
+*expert*tree*screen.deviceL.fromVert:		monitor
+*expert*tree*screen.device.fromVert:		monitor
+*expert*tree*screen.device.fromHoriz:		deviceL
+*expert*tree*screen.value.fromHoriz:		new
+
+*expert*tree*adaptor.label.fromHoriz:		remove
+
+*expert*tree*display.Label.width:		64
+*expert*tree*display.Label.justify:		left
+*expert*tree*display.options.fromHoriz:		remove
+*expert*tree*display.viewportL.label:		Viewport
+*expert*tree*display.viewportL.fromVert:	remove
+*expert*tree*display.viewport.fromVert:		remove
+*expert*tree*display.viewport.fromHoriz:	viewportL
+*expert*tree*display.virtualL.label:		Virtual
+*expert*tree*display.virtualL.fromVert:		viewport
+*expert*tree*display.virtual.fromVert:		viewport
+*expert*tree*display.virtual.fromHoriz:		virtualL
+*expert*tree*display.depthL.label:		Depth
+*expert*tree*display.depthL.fromVert:		virtual
+*expert*tree*display.depth.fromVert:		virtual
+*expert*tree*display.depth.fromHoriz:		depthL
+*expert*tree*display.bppL.label:		FbBPP
+*expert*tree*display.bppL.fromVert:		depth
+*expert*tree*display.bpp.fromVert:		depth
+*expert*tree*display.bpp.fromHoriz:		bppL
+*expert*tree*display.visualL.label:		Visual
+*expert*tree*display.visualL.fromVert:		bpp
+*expert*tree*display.visual.fromVert:		bpp
+*expert*tree*display.visual.fromHoriz:		visualL
+*expert*tree*display.weightL.label:		Weight
+*expert*tree*display.weightL.fromVert:		visual
+*expert*tree*display.weight.fromVert:		visual
+*expert*tree*display.weight.fromHoriz:		weightL
+*expert*tree*display.blackL.label:		Black
+*expert*tree*display.blackL.fromVert:		weight
+*expert*tree*display.black.fromVert:		weight
+*expert*tree*display.black.fromHoriz:		blackL
+*expert*tree*display.whiteL.label:		White
+*expert*tree*display.whiteL.fromVert:		black
+*expert*tree*display.white.fromVert:		black
+*expert*tree*display.white.fromHoriz:		whiteL
+
+*expert*tree*mode.label.fromHoriz:		remove
+*expert*tree*mode.value.fromHoriz:		new
+*expert*tree*mode.value.width:			100
+
+*expert*tree*input.options.fromHoriz:		remove
+*expert*tree*input.label.fromHoriz:		options
+*expert*tree*input.driverL.label:		Driver
+*expert*tree*input.driverL.fromVert:		remove
+*expert*tree*input.driver.fromVert:		remove
+*expert*tree*input.driver.fromHoriz:		driverL
+*expert*tree*input.value.fromHoriz:		new
+
+*expert*tree*layout.options.fromHoriz:		remove
+*expert*tree*layout.label.fromHoriz:		options
+*expert*tree*layout.value.fromHoriz:		new
+
+*expert*tree*adjacency.Text.width:		46
+*expert*tree*adjacency.MenuButton.width:	122
+*expert*tree*adjacency.label.fromHoriz:		remove
+*expert*tree*adjacency.scrnumL.label:		Screen number
+*expert*tree*adjacency.scrnumL.horizDistance:	50
+*expert*tree*adjacency.scrnum.width:		32
+*expert*tree*adjacency.scrnumL.fromVert:	remove
+*expert*tree*adjacency.scrnum.fromVert:		remove
+*expert*tree*adjacency.scrnum.fromHoriz:	scrnumL
+*expert*tree*adjacency.above.label:		Above
+*expert*tree*adjacency.above.fromVert:		scrnumL
+*expert*tree*adjacency.above.vertDistance:	20
+*expert*tree*adjacency.above.horizDistance:	96
+*expert*tree*adjacency.below.label:		Below
+*expert*tree*adjacency.below.horizDistance:	96
+*expert*tree*adjacency.leftOf.label:		LeftOf
+*expert*tree*adjacency.leftOf.fromVert:		above
+*expert*tree*adjacency.screen.fromVert:		above
+*expert*tree*adjacency.screen.fromHoriz:	leftOf
+*expert*tree*adjacency.rightOf.label:		RightOf
+*expert*tree*adjacency.rightOf.fromVert:	above
+*expert*tree*adjacency.rightOf.fromHoriz:	screen
+*expert*tree*adjacency.below.fromVert:		screen
+*expert*tree*adjacency.relative.label:		Relative
+*expert*tree*adjacency.relative.horizDistance:	53
+*expert*tree*adjacency.relative.fromVert:	below
+*expert*tree*adjacency.absolute.fromVert:	below
+*expert*tree*adjacency*absolute.label:		Absolute
+*expert*tree*adjacency*absolute.fromHoriz:	relative
+*expert*tree*adjacency*adjxL.label:		X
+*expert*tree*adjacency*adjxL.horizDistance:	42
+*expert*tree*adjacency*adjxL.fromVert:		absolute
+*expert*tree*adjacency*adjx.fromVert:		absolute
+*expert*tree*adjacency*adjx.fromHoriz:		adjxL
+*expert*tree*adjacency*adjyL.label:		Y
+*expert*tree*adjacency*adjyL.horizDistance:	12
+*expert*tree*adjacency*adjyL.fromVert:		absolute
+*expert*tree*adjacency*adjyL.fromHoriz:		adjx
+*expert*tree*adjacency*adjy.fromVert:		absolute
+*expert*tree*adjacency*adjy.fromHoriz:		adjyL
+
+*expert*tree*inputref.options.fromHoriz:	remove
+*expert*tree*inputref.label.fromHoriz:		options
+
+*expert*tree*vendor.Text.width:			100
+*expert*tree*vendor.options.fromHoriz:		remove
+*expert*tree*vendor.label.fromHoriz:		options
+*expert*tree*vendor.value.fromHoriz:		new
+
+*expert*tree*vendorSub.Text.width:		140
+*expert*tree*vendorSub.options.fromHoriz:	remove
+*expert*tree*vendorSub.label.fromHoriz:		options
+*expert*tree*vendorSub.nameL.label:		Name
+*expert*tree*vendorSub.nameL.fromVert:		remove
+*expert*tree*vendorSub.name.fromVert:		remove
+*expert*tree*vendorSub.name.fromHoriz:		nameL
+*expert*tree*vendorSub.value.fromHoriz:		new
+
+*expert*tree*dri.Text.width:			100
+*expert*tree*dri.Label.width:			78
+*expert*tree*dri.Label.justify:			left
+*expert*tree*dri.nameL.label:			Group name
+*expert*tree*dri.name.fromHoriz:		nameL
+*expert*tree*dri.groupL.label:			Group
+*expert*tree*dri.groupL.fromVert:		name
+*expert*tree*dri.group.fromVert:		name
+*expert*tree*dri.group.fromHoriz:		groupL
+*expert*tree*dri.modeL.label:			Mode
+*expert*tree*dri.modeL.fromVert:		group
+*expert*tree*dri.mode.fromVert:			group
+*expert*tree*dri.mode.fromHoriz:		modeL
+
+*expert*tree*buffers.Label.width:		50
+*expert*tree*buffers.Text.width:		100
+*expert*tree*buffers.countL.label:		Count
+*expert*tree*buffers.countL.fromVert:		remove
+*expert*tree*buffers.count.fromVert:		remove
+*expert*tree*buffers.count.fromHoriz:		countL
+*expert*tree*buffers.sizeL.label:		Size
+*expert*tree*buffers.sizeL.fromVert:		count
+*expert*tree*buffers.size.fromVert:		count
+*expert*tree*buffers.size.fromHoriz:		sizeL
+*expert*tree*buffers.flagsL.label:		Flags
+*expert*tree*buffers.flagsL.fromVert:		size
+*expert*tree*buffers.flags.fromVert:		size
+*expert*tree*buffers.flags.fromHoriz:		flagsL
+*Expert*close.label:				Close
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,699 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo C�sar Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/cards.c,v 1.14 2002/09/12 15:19:07 tsi Exp $
+ */
+
+#define CARDS_PRIVATE
+#include "cards.h"
+
+#undef SERVER	/* defined in config.h, but of no use here */
+
+/* return values from ReadCardsLine. */
+#define ERROR		-3
+#define UNKNOWN		-2
+#define END		-1
+#define	NOTUSEFUL	0
+#define	NAME		1
+#define	CHIPSET		2
+#define	SERVER		3
+#define	DRIVER		4
+#define	RAMDAC		5
+#define	CLOCKCHIP	6
+#define	DACSPEED	7
+#define	NOCLOCKPROBE	8
+#define	UNSUPPORTED	9
+#define	SEE		10
+#define	LINE		11
+
+/*
+ * Prototypes
+ */
+static int ReadCardsLine(FILE*, char*);	/* must have 256 bytes */
+static int CompareCards(_Xconst void *left, _Xconst void *right);
+static int BCompareCards(_Xconst void *left, _Xconst void *right);
+static void DoReadCardsDatabase(void);
+static char **DoFilterCardNames(char *pattern, int *result);
+
+#ifdef USE_MODULES
+
+typedef struct {
+    int ivendor;
+    unsigned short vendor;
+    unsigned short valid_vendor;
+    char *chipsets;
+    int num_chipsets;
+} chipset_check;
+#endif
+
+/*
+ * Initialization
+ */
+static int linenum = 0;
+static char *Cards = "lib/X11/Cards";
+CardsEntry **CardsDB;
+int NumCardsEntry;
+
+/*
+ * Implementation
+ */
+#ifdef USE_MODULES
+const pciVendorInfo *xf86PCIVendorInfo;
+#endif
+
+#ifdef USE_MODULES
+void
+InitializePciInfo(void)
+{
+    xf86PCIVendorInfo = pciVendorInfoList;
+}
+
+void
+CheckChipsets(xf86cfgModuleOptions *opts, int *err)
+{
+    int i, j, ichk, ivnd = 0, vendor = -1, device;
+    const pciDeviceInfo **pDev;
+    SymTabPtr chips = opts->chipsets;
+    chipset_check *check = NULL;
+    int num_check = 0;
+
+    if (!chips) {
+	CheckMsg(CHECKER_NO_CHIPSETS, "WARNING No chipsets specified.\n");
+	++*err;
+	return;
+    }
+
+    while (chips->name) {
+	device = chips->token & 0xffff;
+	vendor = (chips->token & 0xffff0000) >> 16;
+	if (vendor == 0)
+	    vendor = opts->vendor;
+
+	for (ichk = 0; ichk < num_check; ichk++)
+	    if (check[ichk].vendor == vendor)
+		break;
+	if (ichk >= num_check) {
+	    check = (chipset_check*)
+		XtRealloc((XtPointer)check,
+			  sizeof(chipset_check) * (num_check + 1));
+	    check[num_check].vendor = vendor;
+	    memset(&check[num_check], 0, sizeof(chipset_check));
+	    ++num_check;
+	}
+
+	/* Search for vendor in xf86PCIVendorInfo */
+	if (xf86PCIVendorInfo) {
+	    for (ivnd = 0; xf86PCIVendorInfo[ivnd].VendorID; ivnd++)
+		if (vendor == xf86PCIVendorInfo[ivnd].VendorID)
+		    break;
+	}
+	if (xf86PCIVendorInfo && xf86PCIVendorInfo[ivnd].VendorID) {
+	    check[ichk].valid_vendor = 1;
+	    check[ichk].ivendor = ivnd;
+	}
+	else {
+	    CheckMsg(CHECKER_CANNOT_VERIFY_CHIPSET,
+		     "WARNING Cannot verify chipset \"%s\" (0x%x)\n",
+		      chips->name, device);
+	    ++*err;
+	    ++chips;
+	    continue;
+	}
+
+	if (xf86PCIVendorInfo &&
+	    (pDev = xf86PCIVendorInfo[ivnd].Device) != NULL) {
+	    if (check[ichk].chipsets == NULL) {
+		for (j = 0; pDev[j]; j++)
+		    ;
+		check[ichk].chipsets = (char*)XtCalloc(1, j);
+	    }
+	    for (j = 0; pDev[j]; j++) {
+		if (device == pDev[j]->DeviceID) {
+		    if (strcmp(chips->name, pDev[j]->DeviceName)) {
+			CheckMsg(CHECKER_NOMATCH_CHIPSET_STRINGS,
+			     "WARNING chipset strings don't match: \"%s\" \"%s\" (0x%x)\n",
+			     chips->name, xf86PCIVendorInfo[ivnd].Device[j]->DeviceName,
+			     device);
+			++*err;
+		    }
+		    break;
+		}
+	    }
+	    if (!pDev[j]) {
+		CheckMsg(CHECKER_CHIPSET_NOT_LISTED,
+		     "WARNING chipset \"%s\" (0x%x) not in list.\n", chips->name, device);
+		++*err;
+	    }
+	    else
+		check[ichk].chipsets[j] = 1;
+	}
+	++chips;
+    }
+
+    for (i = 0; i < num_check; i++) {
+	if (!check[i].valid_vendor) {
+	    CheckMsg(CHECKER_CHIPSET_NO_VENDOR,
+		     "WARNING No such vendor 0x%x\n", vendor);
+	    ++*err;
+	}
+	for (j = 0; j < check[i].num_chipsets; j++) {
+	    if (xf86PCIVendorInfo && !check[i].chipsets[j]) {
+		CheckMsg(CHECKER_CHIPSET_NOT_SUPPORTED,
+			 "NOTICE chipset \"%s\" (0x%x) not listed as supported.\n",
+			 xf86PCIVendorInfo[check[i].ivendor].Device[j]->DeviceName,
+			 xf86PCIVendorInfo[check[i].ivendor].Device[j]->DeviceID);
+	    }
+	}
+	XtFree(check[i].chipsets);
+    }
+
+    XtFree((XtPointer)check);
+}
+#endif
+
+void
+ReadCardsDatabase(void)
+{
+#ifdef USE_MODULES
+    if (!nomodules) {
+	int i, j, ivendor, idevice;
+	char name[256];
+	_Xconst char *vendor, *device;
+	CardsEntry *entry = NULL, *tmp;
+	xf86cfgModuleOptions *opts = module_options;
+	const pciDeviceInfo **pDev;
+
+	/* Only list cards that have a driver installed */
+	while (opts) {
+	    if (opts->chipsets) {
+		SymTabPtr chips = opts->chipsets;
+
+		while (chips->name) {
+		    vendor = opts->name;
+		    device = chips->name;
+		    ivendor = (chips->token & 0xffff0000) >> 16;
+		    idevice = chips->token & 0xffff0;
+		    if (ivendor == 0)
+			ivendor = opts->vendor;
+
+		    if (xf86PCIVendorInfo) {
+			for (i = 0; xf86PCIVendorInfo[i].VendorName; i++)
+			    if (ivendor == xf86PCIVendorInfo[i].VendorID) {
+				vendor = xf86PCIVendorInfo[i].VendorName;
+				break;
+			    }
+			if (xf86PCIVendorInfo[i].VendorName) {
+			    if ((pDev = xf86PCIVendorInfo[i].Device)) {
+				for (j = 0; pDev[j]; j++)
+				    if (idevice == pDev[j]->DeviceID) {
+					device = pDev[j]->DeviceName;
+					break;
+				    }
+			    }
+			}
+		    }
+
+		    /* Since frequently there is more than one driver for a
+		     * single vendor, it is required to avoid duplicates.
+		     */
+		    XmuSnprintf(name, sizeof(name), "%s %s", vendor, device);
+		    tmp = LookupCard(name);
+
+		    if (tmp == NULL || strcmp(tmp->chipset, chips->name) ||
+			strcmp(tmp->driver, opts->name)) {
+			entry = (CardsEntry*)XtCalloc(1, sizeof(CardsEntry));
+			if (NumCardsEntry % 16 == 0) {
+			    CardsDB = (CardsEntry**)XtRealloc((XtPointer)CardsDB,
+				    sizeof(CardsEntry*) * (NumCardsEntry + 16));
+			}
+			CardsDB[NumCardsEntry++] = entry;
+			entry->name = XtNewString(name);
+
+			/* XXX no private copy of strings */
+			entry->chipset = (char*)chips->name;
+			entry->driver = opts->name;
+
+			/* better than linear searchs to find duplicates */
+			qsort(CardsDB, NumCardsEntry, sizeof(CardsEntry*),
+			      CompareCards);
+		    }
+		    ++chips;
+		}
+	    }
+	    opts = opts->next;
+	}
+
+	/* fix entries with the same name */
+	for (i = 0; i < NumCardsEntry - 2;) {
+	    for (j = i + 1; j < NumCardsEntry - 1 &&
+		 strcmp(CardsDB[i]->name, CardsDB[j]->name) == 0; j++)
+		    ;
+
+	    if (i + 1 != j) {
+		while (i < j) {
+		    char *str;
+
+		    if (strcmp(CardsDB[i]->chipset, CardsDB[j]->chipset))
+			str = CardsDB[i]->chipset;
+		    else
+			str = CardsDB[i]->driver;
+
+		    XmuSnprintf(name, sizeof(name), "%s (%s)",
+				CardsDB[i]->name, str);
+		    XtFree(CardsDB[i]->name);
+		    CardsDB[i]->name = XtNewString(name);
+
+		    ++i;
+		}
+	    }
+	    else
+		++i;
+	}
+
+	/* make sure data is valid to bsearch in */
+	qsort(CardsDB, NumCardsEntry, sizeof(CardsEntry*), CompareCards);
+    }
+    else
+#endif
+	DoReadCardsDatabase();
+}
+
+static void
+DoReadCardsDatabase(void)
+{
+    char buffer[256];
+    FILE *fp = fopen(Cards, "r");
+    int i, result;
+    CardsEntry *entry = NULL;
+    static char *CardsError = "Error reading Cards database, at line %d (%s).\n";
+
+    if (fp == NULL) {
+	fprintf(stderr, "Cannot open Cards database.\n");
+	exit(1);
+    }
+
+    while ((result = ReadCardsLine(fp, buffer)) != END) {
+	switch (result) {
+	    case ERROR:
+		fprintf(stderr, CardsError, linenum, buffer);
+		break;
+	    case UNKNOWN:
+		fprintf(stderr,
+			"Unknown field type in Cards database, at line %d (%s).\n",
+			linenum, buffer);
+		break;
+	    case NAME:
+		entry = calloc(1, sizeof(CardsEntry));
+		if (NumCardsEntry % 16 == 0) {
+		    CardsDB = realloc(CardsDB, sizeof(CardsEntry*) *
+				      (NumCardsEntry + 16));
+		    if (CardsDB == NULL) {
+			fprintf(stderr, "Out of memory reading Cards database.\n");
+			exit(1);
+		    }
+		}
+		CardsDB[NumCardsEntry++] = entry;
+		entry->name = strdup(buffer);
+		break;
+	    case CHIPSET:
+		if (entry == NULL || entry->chipset != NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+#if 0
+		else
+		    entry->chipset = strdup(buffer);
+#endif
+		break;
+	    case SERVER:
+		if (entry == NULL || entry->server != NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->server = strdup(buffer);
+		break;
+	    case DRIVER:
+		if (entry == NULL || entry->driver != NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->driver = strdup(buffer);
+		break;
+	    case RAMDAC:
+		if (entry == NULL || entry->ramdac != NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->ramdac = strdup(buffer);
+		break;
+	    case CLOCKCHIP:
+		if (entry == NULL || entry->clockchip != NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->clockchip = strdup(buffer);
+		break;
+	    case DACSPEED:
+		if (entry == NULL || entry->dacspeed != NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->dacspeed = strdup(buffer);
+		break;
+	    case NOCLOCKPROBE:
+		if (entry == NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->flags |= F_NOCLOCKPROBE;
+		break;
+	    case UNSUPPORTED:
+		if (entry == NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->flags |= F_UNSUPPORTED;
+		break;
+	    case SEE:
+		if (entry == NULL || entry->see != NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else
+		    entry->see = strdup(buffer);
+		break;
+	    case LINE:
+		if (entry == NULL) {
+		    fprintf(stderr, CardsError, linenum, buffer);
+		}
+		else if (entry->lines == NULL)
+		    entry->lines = strdup(buffer);
+		else {
+		    char *str = malloc(strlen(entry->lines) + strlen(buffer) + 2);
+
+		    sprintf(str, "%s\n%s", entry->lines, buffer);
+		    free(entry->lines);
+		    entry->lines = str;
+		}
+		break;
+	}
+    }
+
+    fclose(fp);
+
+    qsort(CardsDB, NumCardsEntry, sizeof(CardsEntry*), CompareCards);
+
+#ifdef DEBUG
+    for (i = 0; i < NumCardsEntry - 1; i++) {
+	if (strcmp(CardsDB[i]->name, CardsDB[i+1]->name) == 0)
+	    fprintf(stderr, "Duplicate entry in Cards database: (%s).\n",
+		    CardsDB[i]->name);
+    }
+#endif
+
+    for (i = 0; i < NumCardsEntry - 1; i++) {
+	if (CardsDB[i]->see != NULL) {
+	    if ((entry = LookupCard(CardsDB[i]->see)) == NULL) {
+		fprintf(stderr, "Cannot find card '%s' for filling defaults.\n",
+			CardsDB[i]->see);
+		continue;
+	    }
+	    if (CardsDB[i]->chipset == NULL && entry->chipset != NULL)
+		CardsDB[i]->chipset = strdup(entry->chipset);
+	    if (CardsDB[i]->server == NULL && entry->server != NULL)
+		CardsDB[i]->server = strdup(entry->server);
+	    if (CardsDB[i]->driver == NULL && entry->driver != NULL)
+		CardsDB[i]->driver = strdup(entry->driver);
+	    if (CardsDB[i]->ramdac == NULL && entry->ramdac != NULL)
+		CardsDB[i]->ramdac = strdup(entry->ramdac);
+	    if (CardsDB[i]->clockchip == NULL && entry->clockchip != NULL)
+		CardsDB[i]->clockchip = strdup(entry->clockchip);
+	    if (CardsDB[i]->dacspeed == NULL && entry->dacspeed != NULL)
+		CardsDB[i]->dacspeed = strdup(entry->dacspeed);
+	    if (CardsDB[i]->flags & F_NOCLOCKPROBE)
+		CardsDB[i]->flags |= F_NOCLOCKPROBE;
+	    if (CardsDB[i]->flags & F_UNSUPPORTED)
+		CardsDB[i]->flags |= F_UNSUPPORTED;
+	    if (entry->lines != NULL) {
+		if (CardsDB[i]->lines == NULL)
+		    CardsDB[i]->lines = strdup(entry->lines);
+		else {
+		    char *str = malloc(strlen(entry->lines) +
+					      strlen(CardsDB[i]->lines) + 2);
+
+		    sprintf(str, "%s\n%s", CardsDB[i]->lines, entry->lines);
+		    free(CardsDB[i]->lines);
+		    CardsDB[i]->lines = str;
+		}
+	    }
+	    if (entry->see != NULL) {
+#ifdef DEBUG
+		fprintf(stderr, "Nested SEE entry: %s -> %s -> %s\n",
+			CardsDB[i]->name, CardsDB[i]->see, entry->see);
+#endif
+		CardsDB[i]->see = strdup(entry->see);
+		--i;
+		continue;
+	    }
+	    free(CardsDB[i]->see);
+	    CardsDB[i]->see = NULL;
+	}
+    }
+}
+
+CardsEntry *
+LookupCard(char *name)
+{
+    CardsEntry **ptr;
+
+    if (NumCardsEntry == 0 || CardsDB == 0)
+	return NULL;
+
+    ptr = (CardsEntry**)bsearch(name, CardsDB, NumCardsEntry,
+				sizeof(CardsEntry*), BCompareCards);
+
+    return (ptr != NULL ? *ptr : NULL);
+}
+
+char **
+GetCardNames(int *result)
+{
+    char **cards = NULL;
+    int ncards;
+
+    for (ncards = 0; ncards < NumCardsEntry; ncards++) {
+	if (ncards % 16 == 0) {
+	    if ((cards = (char**)realloc(cards, sizeof(char*) *
+					 (ncards + 16))) == NULL) {
+		fprintf(stderr, "Out of memory.\n");
+		exit(1);
+	    }
+	}
+	cards[ncards] = strdup(CardsDB[ncards]->name);
+    }
+
+    *result = ncards;
+
+    return (cards);
+}
+
+char **
+FilterCardNames(char *pattern, int *result)
+{
+#ifdef USE_MODULES
+    if (!nomodules) {
+	char **cards = NULL;
+	int i, ncards = 0;
+
+	for (i = 0; i < NumCardsEntry; i++) {
+	    if (strstr(CardsDB[i]->name, pattern) == NULL)
+		continue;
+	    if (ncards % 16 == 0) {
+		if ((cards = (char**)realloc(cards, sizeof(char*) *
+					     (ncards + 16))) == NULL) {
+		    fprintf(stderr, "Out of memory.\n");
+		    exit(1);
+		}
+	    }
+	    cards[ncards] = strdup(CardsDB[i]->name);
+	    ++ncards;
+	}
+
+	*result = ncards;
+
+	return (cards);
+    }
+#endif
+    return (DoFilterCardNames(pattern, result));
+}
+
+static char **
+DoFilterCardNames(char *pattern, int *result)
+{
+    FILE *fp;
+    char **cards = NULL;
+    int len, ncards = 0;
+    char *cmd, *ptr, buffer[256];
+
+    cmd = malloc(32 + (strlen(pattern) * 2) + strlen(Cards));
+
+    strcpy(cmd, "egrep -i '^NAME\\ .*");
+    len = strlen(cmd);
+    ptr = pattern;
+    while (*ptr) {
+	if (!isalnum(*ptr)) {
+	    cmd[len++] = '\\';
+	}
+	cmd[len++] = *ptr++;
+    }
+    cmd[len] = '\0';
+    strcat(cmd, ".*$' ");
+    strcat(cmd, Cards);
+    strcat(cmd, " | sort");
+    /*sprintf(cmd, "egrep -i '^NAME\\ .*%s.*$' %s | sort", pattern, Cards);*/
+
+    if ((fp = popen(cmd, "r")) == NULL) {
+	fprintf(stderr, "Cannot read Cards database.\n");
+	exit(1);
+    }
+    while (fgets(buffer, sizeof(buffer), fp) != NULL) {
+	ptr = buffer + strlen(buffer) - 1;
+	while (isspace(*ptr) && ptr > buffer)
+	    --ptr;
+	if (!isspace(*ptr) && ptr > buffer)
+	    ptr[1] = '\0';
+	ptr = buffer;
+	while (!isspace(*ptr) && *ptr)	/* skip NAME */
+	    ++ptr;
+	while (isspace(*ptr) && *ptr)
+	    ++ptr;
+	if (ncards % 16 == 0) {
+	    if ((cards = (char**)realloc(cards, sizeof(char*) *
+					 (ncards + 16))) == NULL) {
+		fprintf(stderr, "Out of memory.\n");
+		exit(1);
+	    }
+	}
+	cards[ncards++] = strdup(ptr);
+    }
+    free(cmd);
+
+    *result = ncards;
+
+    return (cards);
+}
+
+static int
+ReadCardsLine(FILE *fp, char *value)
+{
+    char name[32], buffer[256], *ptr, *end;
+    int result = NOTUSEFUL;
+
+    ++linenum;
+
+    if (fgets(buffer, sizeof(buffer), fp) == NULL)
+	return (END);
+
+    ptr = buffer;
+    /* skip initial spaces; should'nt bother about this.. */
+    while (isspace(*ptr) && *ptr)
+	++ptr;
+
+    if (*ptr == '#' || *ptr == '\0')
+	return (NOTUSEFUL);
+
+    end = ptr;
+    while (!isspace(*end) && *end)
+	++end;
+    if (end - ptr > sizeof(buffer) - 1) {
+	strncpy(value, buffer, 255);
+	value[255] = '\0';
+	return (ERROR);
+    }
+    strncpy(name, ptr, end - ptr);
+    name[end - ptr] = '\0';
+
+    /* read the optional arguments */
+    ptr = end;
+    while (isspace(*ptr) && *ptr)
+	++ptr;
+
+    end = ptr + strlen(ptr) - 1;
+    while (isspace(*end) && end > ptr)
+	--end;
+    if (!isspace(*end))
+	++end;
+    *end = '\0';
+
+    if (strcmp(name, "NAME") == 0)
+	result = NAME;
+    else if (strcmp(name, "CHIPSET") == 0)
+	result = CHIPSET;
+    else if (strcmp(name, "SERVER") == 0)
+	result = SERVER;
+    else if (strcmp(name, "DRIVER") == 0)
+	result = DRIVER;
+    else if (strcmp(name, "RAMDAC") == 0)
+	result = RAMDAC;
+    else if (strcmp(name, "CLOCKCHIP") == 0)
+	result = CLOCKCHIP;
+    else if (strcmp(name, "DACSPEED") == 0)
+	result = DACSPEED;
+    else if (strcmp(name, "NOCLOCKPROBE") == 0)
+	result = NOCLOCKPROBE;
+    else if (strcmp(name, "UNSUPPORTED") == 0)
+	result = UNSUPPORTED;
+    else if (strcmp(name, "SEE") == 0)
+	result = SEE;
+    else if (strcmp(name, "LINE") == 0)
+	result = LINE;
+    else if (strcmp(name, "END") == 0)
+	result = END;
+    else {
+	strcpy(value, name);
+	return (UNKNOWN);
+    }
+
+    /* value *must* have at least 256 bytes */
+    strcpy(value, ptr);
+
+    return (result);
+}
+
+static int
+CompareCards(_Xconst void *left, _Xconst void *right)
+{
+    return strcasecmp((*(CardsEntry**)left)->name, (*(CardsEntry**)right)->name);
+}
+
+static int
+BCompareCards(_Xconst void *name, _Xconst void *card)
+{
+  if (card == NULL)
+	return 0;
+
+  return (strcasecmp((char*)name, (*(CardsEntry**)card)->name));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo C�sar Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.c,v 1.8tsi Exp $
+ */
+
+#include "config.h"
+#include "mouse-cfg.h"
+#include "keyboard-cfg.h"
+#include "card-cfg.h"
+#include "monitor-cfg.h"
+#include "screen-cfg.h"
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Shell.h>
+
+/*
+ * Prototypes
+ */
+void BackCallback(Widget, XtPointer, XtPointer);
+void NextCallback(Widget, XtPointer, XtPointer);
+void ApplyCallback(Widget, XtPointer, XtPointer);
+void CloseCallback(Widget, XtPointer, XtPointer);
+void ErrorCallback(Widget, XtPointer, XtPointer);
+
+/*
+ * Initialization
+ */
+XF86SetupFunction mouse_functions[] = {
+    MouseDeviceAndProtocol,
+};
+
+XF86SetupFunction keyboard_functions[] = {
+    KeyboardModelAndLayout,
+};
+
+XF86SetupFunction card_functions[] = {
+    CardModel,
+};
+
+XF86SetupFunction monitor_functions[] = {
+    MonitorLayout,
+};
+
+XF86SetupFunction screen_functions[] = {
+    ScreenDialog,
+};
+
+XF86SetupFunctionList function_lists[] = {
+    {mouse_functions, sizeof(mouse_functions) / sizeof(mouse_functions[0]),},
+    {keyboard_functions, sizeof(keyboard_functions) / sizeof(keyboard_functions[0]),},
+    {card_functions, sizeof(card_functions) / sizeof(card_functions[0]),},
+    {monitor_functions, sizeof(monitor_functions) / sizeof(monitor_functions[0]),},
+    {screen_functions, sizeof(screen_functions) / sizeof(screen_functions[0]),},
+};
+
+XF86SetupInfo xf86info = {
+    sizeof(function_lists) / sizeof(function_lists[0]),
+    MOUSE,
+    function_lists,
+};
+
+Widget configp, current, ok, back, next;
+static Widget shell, errcurrent, oldcurrent;
+
+static int config_status, config_popped;
+
+static ConfigCheckFunction config_function;
+
+Widget ident_widget;
+char *ident_string;
+XF86ConfigPtr XF86Config;
+
+/*
+ * Implementation
+ */
+void
+StartConfig(void)
+{
+    static int first = 1;
+    Widget pane, top, bottom, cancel;
+    const char *filename;
+    char *p, *name;
+
+    if (!first)
+	return;
+    first = 0;
+
+    /* Read initial configuration */
+    if (getuid() == 0)
+    	filename = xf86openConfigFile(CONFPATH, XF86Config_path, NULL);
+    else {
+	/* Relative path must be used for non-root users */
+        name = XF86Config_path;
+        while (p = strchr(name, '/'))
+		name = p + 1;
+  	XF86Config_path = name;
+    	filename = xf86openConfigFile(USER_CONFPATH, XF86Config_path, NULL);
+    }
+
+    if (filename == NULL) {
+	int length = XF86Config_path ? strlen(XF86Config_path) : -1;
+
+	if (length > 2 &&
+	    XF86Config_path[length - 2] == '-' &&
+	    XF86Config_path[length - 1] == '4') {
+	    XF86Config_path[length - 2] = '\0';
+	    filename = xf86openConfigFile(getuid() == 0 ?
+					  CONFPATH : USER_CONFPATH,
+					  XF86Config_path, NULL);
+	}
+
+	if (filename == NULL) {
+	    fprintf(stderr, "Cannot open config file.\n");
+	    exit(1);
+	}
+    }
+    XF86Config_path = (char *)filename;
+    if ((XF86Config = xf86readConfigFile()) == NULL) {
+	fprintf(stderr, "Problem when parsing config file\n");
+	exit(1);
+    }
+
+#ifdef sun
+    /* If .xorg.conf in the path, replace it with xorg.conf */
+    if (p = strstr(XF86Config_path, ".xorg.conf")) {
+	strncpy(p, "xorg.conf", strlen("xorg.conf"));
+	p[strlen("xorg.conf")] = '\0';
+    }
+#endif
+
+    shell = XtCreatePopupShell("config", transientShellWidgetClass,
+			       toplevel, NULL, 0);
+    pane = XtCreateManagedWidget("pane", panedWidgetClass,
+				 shell, NULL, 0);
+    top = XtCreateManagedWidget("top", formWidgetClass,
+				pane, NULL, 0);
+    (void) XtCreateManagedWidget("label", labelWidgetClass,
+				  top, NULL, 0);
+    ident_widget = XtVaCreateManagedWidget("identifier", asciiTextWidgetClass,
+					   top,
+					   XtNeditType, XawtextEdit,
+					   NULL, 0);
+    configp = XtCreateManagedWidget("work", formWidgetClass,
+				    pane, NULL, 0);
+    current = XtCreateManagedWidget("wellcome", labelWidgetClass,
+				    configp, NULL, 0);
+    bottom = XtCreateManagedWidget("bottom", formWidgetClass,
+				   pane, NULL, 0);
+    back = XtCreateManagedWidget("back", commandWidgetClass,
+				 bottom, NULL, 0);
+    XtAddCallback(back, XtNcallback, BackCallback, (XtPointer)&xf86info);
+    next = XtCreateManagedWidget("next", commandWidgetClass,
+				 bottom, NULL, 0);
+    XtAddCallback(next, XtNcallback, NextCallback, (XtPointer)&xf86info);
+    ok = XtCreateManagedWidget("ok", commandWidgetClass,
+			       bottom, NULL, 0);
+    XtAddCallback(ok, XtNcallback, ApplyCallback, (XtPointer)NULL);
+    cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
+				   bottom, NULL, 0);
+    XtAddCallback(cancel, XtNcallback, CloseCallback, (XtPointer)NULL);
+
+    XtRealizeWidget(shell);
+
+    XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1);
+}
+
+/*ARGSUSED*/
+Bool
+ConfigLoop(ConfigCheckFunction config_fn)
+{
+    Arg args[1];
+    config_popped = True;
+    XtPopup(shell, XtGrabExclusive);
+
+    config_function = config_fn;
+    while (config_popped)
+	XtAppProcessEvent(XtWidgetToApplicationContext(shell), XtIMAll);
+
+    XtSetArg(args[0], XtNstring, &ident_string);
+    XtGetValues(ident_widget, args, 1);
+
+    return (config_status);
+}
+
+/*ARGSUSED*/
+void
+ConfigError(void)
+{
+    static int first = 1;
+
+    if (first) {
+	Widget command;
+
+	errcurrent = XtCreateWidget("error", formWidgetClass,
+			 	     configp, NULL, 0);
+	(void) XtCreateManagedWidget("label", labelWidgetClass,
+				      errcurrent, NULL, 0);
+	command = XtCreateManagedWidget("command", commandWidgetClass,
+					errcurrent, NULL, 0);
+	XtAddCallback(command, XtNcallback, ErrorCallback, NULL);
+
+	XtRealizeWidget(errcurrent);
+    }
+
+    oldcurrent = current;
+    XtChangeManagedSet(&current, 1, NULL, NULL, &errcurrent, 1);
+    current = errcurrent;
+
+    XtSetSensitive(ok, False);
+}
+
+/*ARGSUSED*/
+void
+ErrorCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XtChangeManagedSet(&errcurrent, 1, NULL, NULL, &oldcurrent, 1);
+    current = oldcurrent;
+
+    XtSetSensitive(ok, True);
+}
+
+/*ARGSUSED*/
+void
+BackCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XF86SetupInfo *info = (XF86SetupInfo*)user_data;
+    int idx = info->lists[info->cur_list].cur_function - 1;
+
+    if (idx >= 0 && info->lists[info->cur_list].num_functions > 0) {
+	info->lists[info->cur_list].cur_function = idx;
+	if (idx - 1 == -1)
+	    XtSetSensitive(back, False);
+	if (!XtIsSensitive(next))
+	    XtSetSensitive(next, True);
+	(info->lists[info->cur_list].functions[idx])(info);
+    }
+}
+
+/*ARGSUSED*/
+void
+NextCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XF86SetupInfo *info = (XF86SetupInfo*)user_data;
+    int idx = info->lists[info->cur_list].cur_function + 1;
+
+    if (idx < info->lists[info->cur_list].num_functions) {
+	info->lists[info->cur_list].cur_function = idx;
+	if (idx + 1 == info->lists[info->cur_list].num_functions)
+	    XtSetSensitive(next, False);
+	if (!XtIsSensitive(back))
+	    XtSetSensitive(back, True);
+	(info->lists[info->cur_list].functions[idx])(info);
+    }
+}
+
+/*ARGSUSED*/
+void
+CloseCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XtPopdown(shell);
+    config_popped = False;
+    config_status = False;
+    /* make sure it is sensitive */
+    XtSetSensitive(ok, True);
+    xf86info.lists[xf86info.cur_list].cur_function = 0;
+}
+
+/*ARGSUSED*/
+void
+ApplyCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    Arg args[1];
+
+    XtSetArg(args[0], XtNstring, &ident_string);
+    XtGetValues(ident_widget, args, 1);
+
+    if (config_function == NULL || (*config_function)()) {
+	XtPopdown(shell);
+	config_popped = False;
+	config_status = True;
+	xf86info.lists[xf86info.cur_list].cur_function = 0;
+    }
+    else
+	ConfigError();
+}
+
+/*ARGSUSED*/
+void
+ConfigCancelAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    CloseCallback(w, NULL, NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo C�sar Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.h,v 1.21 2004/02/13 23:58:52 dawes Exp $
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "xorg-config.h"
+#endif
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+#ifdef sun
+#undef index
+#undef rindex
+#include <strings.h>
+#endif
+#include <unistd.h>
+
+#include <stdarg.h>
+
+#ifdef __UNIXOS2__
+#define strcasecmp stricmp
+#define setenv putenv
+#define PATH_MAX 260
+#endif
+
+/* Get PATH_MAX */
+#ifndef PATH_MAX
+# if defined(_POSIX_SOURCE)
+#  include <limits.h>
+# else
+#  define _POSIX_SOURCE
+#  include <limits.h>
+#  undef _POSIX_SOURCE
+# endif
+# ifndef PATH_MAX
+#  ifdef MAXPATHLEN
+#   define PATH_MAX MAXPATHLEN
+#  else
+#   define PATH_MAX 1024
+#  endif
+# endif
+#endif
+
+#include <xf86Parser.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKM.h>
+#include <X11/extensions/XKBfile.h>
+#include <X11/extensions/XKBui.h>
+#include <X11/extensions/XKBrules.h>
+
+#ifndef _xf86cfg_config_h
+#define _xf86cfg_config_h
+
+/* Must match the offset in the xf86info structure at config.c,
+ * and is used also by interface.c
+ */
+#define MOUSE			0
+#define KEYBOARD		1
+#define CARD			2
+#define MONITOR			3
+#define SCREEN			4
+#define SERVER			5
+
+#define	UNUSED			0
+#define	USED			1
+
+#define CONFIG_LAYOUT	0
+#define CONFIG_SCREEN	1
+#define CONFIG_MODELINE	2
+#define CONFIG_ACCESSX	3
+extern int config_mode;
+
+#ifndef __UNIXOS2__
+#ifdef sun
+#define CONFPATH	"%A," "%R," \
+			"/etc/X11/%R," "%P/etc/X11/%R," \
+			"%E," "%F," \
+			"/etc/X11/%F," "%P/etc/X11/%F," \
+			"%D/%X," \
+			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X," \
+			"/etc/X11/.%S," \
+			"/etc/X11/.%X"
+#define USER_CONFPATH	"/etc/X11/%S," "%P/etc/X11/%S," \
+                        "/etc/X11/%G," "%P/etc/X11/%G," \
+                        "/etc/X11/%X," "%P/etc/X11/%X," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X," \
+			"/etc/X11/.%S," \
+			"/etc/X11/.%X"
+#else
+#define CONFPATH	"%A," "%R," \
+			"/etc/X11/%R," "%P/etc/X11/%R," \
+			"%E," "%F," \
+			"/etc/X11/%F," "%P/etc/X11/%F," \
+			"%D/%X," \
+			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X"
+#define USER_CONFPATH	"/etc/X11/%S," "%P/etc/X11/%S," \
+                        "/etc/X11/%G," "%P/etc/X11/%G," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X"
+#endif
+#else
+#define CONFPATH	"%&"XF86CONFIGDIR"/%R," "%&"XF86CONFIGDIR"/%X," \
+			"%A," "%R," \
+			"/etc/X11/%R," "%P/etc/X11/%R," \
+			"%E," "%F," \
+			"/etc/X11/%F," "%P/etc/X11/%F," \
+			"%D/%X," \
+			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X"
+#define USER_CONFPATH	"%&"XF86CONFIGDIR"/%X," "%&"XF86CONFIGDIR"/%X," \
+			"/etc/X11/%S," "%P/etc/X11/%S," \
+                        "/etc/X11/%G," "%P/etc/X11/%G," \
+			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+			"%P/etc/X11/%X," \
+			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+			"%P/lib/X11/%X"
+#endif
+
+/*
+ * Types
+ */
+typedef struct _XF86SetupInfo XF86SetupInfo;
+typedef void (*XF86SetupFunction)(XF86SetupInfo*);
+
+typedef struct _XF86SetupFunctionList {
+    XF86SetupFunction *functions;
+    int num_functions;
+    int cur_function;
+} XF86SetupFunctionList;
+
+struct _XF86SetupInfo {
+    int num_lists;
+    int cur_list;
+    XF86SetupFunctionList *lists;
+};
+
+typedef Bool (*ConfigCheckFunction)(void);
+
+typedef struct _xf86cfgDevice xf86cfgDevice;
+
+struct _xf86cfgDevice {
+    XtPointer config;
+    Widget widget;
+    int type, state, refcount;
+};
+
+typedef struct {
+    XF86ConfScreenPtr screen;
+    Widget widget;
+    int type, state, refcount;
+    xf86cfgDevice *card;
+    xf86cfgDevice *monitor;
+    short row, column;
+    XRectangle rect;
+    short rotate;
+} xf86cfgScreen;
+
+/* this structure is used just to restore
+   properly the monitors layout in the
+   screen window configuration.
+ */
+typedef struct {
+    XF86ConfLayoutPtr layout;
+    xf86cfgScreen **screen;
+    XPoint *position;
+    int num_layouts;
+} xf86cfgLayout;
+
+/* The vidmode extension usage is controlled by this structure.
+ * The information is read at startup, and added monitors cannot
+ * be configured, since they are not attached to a particular screen.
+ */
+typedef struct _xf86cfgVidMode xf86cfgVidmode;
+
+typedef struct {
+    XF86ConfLayoutPtr layout;	/* current layout */
+    Widget cpu;
+    xf86cfgLayout **layouts;
+    Cardinal num_layouts;
+    xf86cfgScreen **screens;
+    Cardinal num_screens;
+    xf86cfgDevice **devices;
+    Cardinal num_devices;
+    xf86cfgVidmode **vidmodes;
+    Cardinal num_vidmodes;
+} xf86cfgComputer;
+
+/*
+ * Prototypes
+ */
+void StartConfig(void);
+Bool ConfigLoop(ConfigCheckFunction);
+void ConfigError(void);
+void ChangeScreen(XF86ConfMonitorPtr, XF86ConfMonitorPtr,
+		  XF86ConfDevicePtr, XF86ConfDevicePtr);
+void SetTip(xf86cfgDevice*);
+Bool startx(void);
+void endx(void);
+void startaccessx(void);
+void ConfigCancelAction(Widget, XEvent*, String*, Cardinal*);
+void ExpertConfigureStart(void);
+void ExpertConfigureEnd(void);
+void ExpertCloseAction(Widget, XEvent*, String*, Cardinal*);
+void ExpertCallback(Widget, XtPointer, XtPointer);
+
+/*
+ * Initialization
+ */
+extern Widget toplevel, configp, current, back, next;
+extern XtAppContext appcon;
+extern XF86SetupInfo xf86info;
+extern Widget ident_widget;
+extern char *ident_string;
+extern XF86ConfigPtr XF86Config;
+extern char *XF86Config_path;
+extern char *XF86Module_path;
+extern char *XFree86_path;
+extern char *XF86Font_path;
+extern char *XF86RGB_path;
+extern char *XFree86Dir;
+extern xf86cfgComputer computer;
+extern Atom wm_delete_window;
+extern Display *DPY;
+extern Pixmap menuPixmap;
+#ifdef USE_MODULES
+extern int nomodules;
+#endif
+
+#endif /* _xf86cfg_config_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/dummygen.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2005 Sun Microsystems (http://www.sun.com)
+ *
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/dummy.c v 1.1 2005/04/08 23:58:52 Exp $
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define MAXSYMS 256 
+#define MAXLINE 512
+
+static char *dixsymfile = "../loader/dixsym.c";
+static char *misymfile = "../loader/misym.c";
+static char *fontsymfile = "../loader/fontsym.c";
+static char *extsymfile = "../loader/extsym.c";
+static char *xf86symfile = "../loader/xf86sym.c";
+static char *xorgsymfile = "loadmod.c";
+static char *outputfile = "dummy.c";
+
+static char	*xf86excludesyms[MAXSYMS];
+static char	line[MAXLINE];
+static int 	endfile;
+static FILE	*ofp;
+
+static char *dixexcludesyms[ ] = {
+		"Xstrdup",
+		"XNFstrdup",
+		"LogVWrite",
+		"FatalError",
+		"ErrorF",
+		"VErrorF",
+		"Error",
+		"kNFalloc",
+		"XNFalloc",
+		"XNFcalloc",
+		"XNFrealloc",
+		"Xalloc",
+		"Xcalloc",
+		"Xfree",
+		"Xrealloc",
+		NULL
+};
+
+static char *xf86initexcludesyms[ ] = {
+		"xf86GetErrno",
+		"xf86ErrorF",
+		"xf86strlcat",
+		"xf86strlcpy",
+		"xf86strncat",
+		"xf86HUGE_VAL",
+		NULL
+};
+
+typedef enum {
+    RET_EOF = 0,
+    RET_DEF,
+    RET_FUNC,
+    RET_VAR,
+    RET_COM,
+    RET_OTHER
+} rettype;
+
+static void
+errexit(char *format, char *str) {
+	int	i;
+	char 	*p;
+
+	if (str)
+		fprintf (stderr, format, str);
+	else
+		fprintf (stderr, format);
+
+	i = 0;
+	while (xf86excludesyms[i]) 
+		free(xf86excludesyms[i++]); 
+	exit (1);
+}
+
+static rettype
+readline(FILE *fp) {
+        char    ch;
+	int	i = 0;
+
+	endfile = 0;
+
+        /* skip leading spaces */
+        while ((ch = fgetc(fp)) == ' ');
+
+	line[i] = ch;
+	while (((line[i] != '\n') && (line[i] != EOF)) ||
+		((line[i] == '\n') && (line[i-1] == '\\'))) {
+		if ((line[i] == '\n') && (line[i-1] == '\\'))
+			i--;
+		else
+			if (++i >= MAXLINE)
+				errexit("Line exceeds maximum.\n", NULL);
+		line[i] = fgetc(fp);
+	}
+
+	if (line[i] == '\n')
+		line[i] = '\0';
+	else
+		if (line[i] == EOF) {
+			if (i == 0)
+				return (RET_EOF);
+			else 
+				endfile = 1;
+		}
+
+	/* Processing line */
+	if ((line[0] == '/' && line[1] == '*') || (line[0] == '*'))
+		return (RET_COM);
+	if (!strncmp(line, "#if", 3) || !strncmp(line, "#else", 5) ||
+		!strncmp(line, "#endif", 6) || !strncmp(line, "# if", 4) ||
+		!strncmp(line, "# else", 6) || !strncmp(line, "# endif", 7))
+		return (RET_DEF);
+	if (!strncmp(line, "SYMFUNC", 7) && strncmp(line, "SYMFUNCALIAS", 12))	
+		return (RET_FUNC);
+	if (!strncmp(line, "SYMVAR", 6))
+		return (RET_VAR);
+
+	return (RET_OTHER);
+}
+
+void 
+processsyms(char *file, char **exclude) {
+	FILE 	*fp;
+	int	i;
+	int	skip;
+	rettype	ret;
+	char	*p, *q;
+
+	if (!(fp = fopen(file, "r")))
+		errexit("Open %s failed\n", file);
+
+	fprintf(ofp, "\n/* Functions and variable from %s */\n", file);
+
+	while ((ret = readline(fp)) != RET_EOF) {
+		if ((ret == RET_COM) || (ret == RET_OTHER))
+			continue;
+		
+		if (ret == RET_DEF)
+			fprintf(ofp, "%s\n", line);
+			
+		if ((ret == RET_FUNC) || (ret == RET_VAR)) {
+			if (!(p = strchr(line, '(')))
+				errexit("Format error: %s\n", line);
+			if (!(q = strchr(p, ')')))
+				errexit("Format error: %s\n", line);
+			*q = '\0';
+			p++;
+			if (exclude) {
+				i = 0;
+				skip = 0;
+				while (exclude[i]) {
+					if (!strcmp(p, exclude[i])) {
+						skip = 1;
+						break;
+					}
+					i++;
+				}
+				if (skip)
+					continue;
+			}
+
+			if (ret == RET_FUNC)
+				fprintf(ofp, "    void %s( ) { }\n", p);
+			else
+				fprintf(ofp, "    int %s;\n", p);
+
+			if (endfile) {
+				fclose(fp);
+				return;
+			}
+		}
+	}
+
+	fclose(fp);
+	return;
+}
+
+int
+main(int argc, char *argv[]) {
+	int 	i, len;
+	rettype	ret;
+	char	*p, *q;
+	FILE	*fp;
+
+	/* Initialize xf86excludesyms[] */
+	for (i = 0; i < MAXSYMS; i++)
+		xf86excludesyms[i] = 0;
+
+	/* Create xf86excludesyms[] */
+	i = 0;
+	while (xf86initexcludesyms[i]) {
+		if (i >= MAXSYMS)
+			errexit("Error: xf86 exclude symbols exceeds MAXSYMS\n", NULL);
+		len = strlen(xf86initexcludesyms[i]);
+		if (xf86excludesyms[i] = malloc(len + 1)) {
+			memcpy((void *)xf86excludesyms[i], 
+			(void *)xf86initexcludesyms[i], len);
+			xf86excludesyms[i][len] = '\0';
+			i++;
+		}
+		else
+			errexit("Error: malloc failed\n", NULL);
+	}
+
+	if (!(fp = fopen(xorgsymfile, "r")))
+		errexit("Open %s failed\n", xorgsymfile);
+
+	while ((ret = readline(fp)) != RET_EOF) {
+		if (i >= MAXSYMS)
+			errexit("Error: xf86 exclude symbols exceeds MAXSYMS\n", NULL);
+		if ((ret == RET_COM) || (ret == RET_OTHER))
+			continue;
+
+		if ((ret == RET_FUNC) || (ret == RET_VAR)) {
+			if (!(p = strchr(line, '(')))
+				errexit("Format error: %s\n", line);
+			if (!(q = strchr(p, ')')))
+				errexit("Format error: %s\n", line);
+			*q = '\0';
+			p++;
+			len = strlen(p);
+			if (xf86excludesyms[i] = malloc(len + 1)) {
+				memcpy((void *)xf86excludesyms[i], p, len);
+				xf86excludesyms[i][len] = '\0';
+				i++;
+			}
+			else
+				errexit("Error: malloc failed\n", NULL);
+		}
+		if (endfile)
+			break;
+	}
+
+
+	if (!(ofp = fopen(outputfile, "w")))
+		errexit("Open %s failed\n", outputfile);
+
+	processsyms(dixsymfile, dixexcludesyms);
+	processsyms(misymfile, NULL);
+	processsyms(fontsymfile, NULL);
+	processsyms(extsymfile, NULL);
+	processsyms(xf86symfile, xf86excludesyms);
+
+	fclose(ofp);
+
+	i = 0;
+	while (xf86excludesyms[i]) 
+		free(xf86excludesyms[i++]);
+ 
+	return (0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2324 @@
+/* $XdotOrg: $ */
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo César Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c,v 1.36 2002/10/19 20:04:21 herrb Exp $
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Composite.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Simple.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/MenuButton.h>
+#include <X11/Xaw/SmeBSB.h>
+#include <X11/Xaw/SmeLine.h>
+#include <X11/Xaw/SimpleMenP.h>
+#include <X11/Xaw/Dialog.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include "xf86config.h"
+#include "mouse-cfg.h"
+#include "keyboard-cfg.h"
+#include "card-cfg.h"
+#include "monitor-cfg.h"
+#include "screen-cfg.h"
+#include "screen.h"
+#include "cards.h"
+#include "options.h"
+#include "vidmode.h"
+#include "help.h"
+#include "stubs.h"
+
+#define randomize()		srand((unsigned)time((time_t*)NULL))
+#ifdef PROJECT_ROOT
+#define DefaultXFree86Dir	PROJECT_ROOT
+#else
+#define DefaultXFree86Dir	"/usr/X11R6"
+#endif
+
+#define IS_KBDDRIV(S) ((strcasecmp((S),"kbd") == 0) || \
+	(strcasecmp((S), "keyboard") == 0))
+
+#ifdef sun
+#define DefaultOpenwinDir	"/usr/openwin"
+#endif
+
+/*
+ * Prototypes
+ */
+void DrawCables(void);
+static void DrawCable(Display*, Window, int, int, int, int);
+static void ComputerEventHandler(Widget, XtPointer, XEvent*, Boolean*);
+void SelectDeviceAction(Widget, XEvent*, String*, Cardinal*);
+void MoveDeviceAction(Widget, XEvent*, String*, Cardinal*);
+void UnselectDeviceAction(Widget, XEvent*, String*, Cardinal*);
+void RenameLayoutAction(Widget, XEvent*, String*, Cardinal*);
+void DevicePopupMenu(Widget, XEvent*, String*, Cardinal*);
+void DevicePopdownMenu(Widget, XEvent*, String*, Cardinal*);
+void AddDeviceCallback(Widget, XtPointer, XtPointer);
+void QuitCallback(Widget, XtPointer, XtPointer);
+void SmeConfigureDeviceCallback(Widget, XtPointer, XtPointer);
+void ConfigureDeviceCallback(Widget, XtPointer, XtPointer);
+void EnableDeviceCallback(Widget, XtPointer, XtPointer);
+void DisableDeviceCallback(Widget, XtPointer, XtPointer);
+void RemoveDeviceCallback(Widget, XtPointer, XtPointer);
+void InitializeDevices(void);
+void SetConfigModeCallback(Widget, XtPointer, XtPointer);
+void SelectLayoutCallback(Widget, XtPointer, XtPointer);
+void DefaultLayoutCallback(Widget, XtPointer, XtPointer);
+void RemoveLayoutCallback(Widget, XtPointer, XtPointer);
+void OptionsCallback(Widget, XtPointer, XtPointer);
+xf86cfgDevice *AddDevice(int, XtPointer, int, int);
+static Bool AskConfig(void);
+void WriteConfigAction(Widget, XEvent*, String*, Cardinal*);
+static void ScreenSetup(Bool);
+void QuitAction(Widget, XEvent*, String*, Cardinal*);
+void PopdownErrorCallback(Widget, XtPointer, XtPointer);
+static void ErrorCancelAction(Widget, XEvent*, String*, Cardinal*);
+static void QuitCancelAction(Widget, XEvent*, String*, Cardinal*);
+static void HelpCallback(Widget, XtPointer, XtPointer);
+void UpdateMenuDeviceList(int);
+
+extern void AccessXConfigureStart(void);
+extern void AccessXConfigureEnd(void);
+extern void CloseAccessXAction(Widget, XEvent*, String*, Cardinal*);
+
+#ifdef HAS_NCURSES
+extern void TextMode(void);
+#endif
+
+static void Usage(void);
+
+/*
+ * Initialization
+ */
+Widget toplevel, work, config, layout, layoutsme, layoutp, topMenu;
+XtAppContext appcon;
+
+Pixmap menuPixmap;
+
+char *XF86Config_path = NULL;
+char *XF86Module_path = NULL;
+char *XFree86_path = NULL;
+char *XF86Font_path = NULL;
+char *XF86RGB_path = NULL;
+char *XkbConfig_path = NULL;
+char *XFree86Dir;
+#ifdef sun
+char *OpenwinDir;
+#endif
+static char XF86Config_path_static[1024];
+static char XkbConfig_path_static[1024];
+Bool xf86config_set = False;
+
+int textmode = False;
+#ifdef USE_MODULES
+int nomodules = False;
+#endif
+int  noverify = False;
+
+xf86cfgComputer computer;
+xf86cfgDevice cpu_device;
+Cursor no_cursor;
+static Widget device, layoutm, popup, commands;
+static int xpos, ypos;
+int sxpos, sypos;
+static char no_cursor_data[] = { 0,0,0,0, 0,0,0,0 };
+static GC cablegc, cablegcshadow;
+Atom wm_delete_window;
+static Bool config_set = False;
+static Widget mouseSme, mouseMenu, keyboardSme, keyboardMenu,
+       cardSme, cardMenu, monitorSme, monitorMenu;
+
+int config_mode = CONFIG_LAYOUT;
+
+static XtActionsRec actions[] = {
+    {"filter-card", CardFilterAction},
+    {"select-device", SelectDeviceAction},
+    {"move-device", MoveDeviceAction},
+    {"unselect-device", UnselectDeviceAction},
+    {"device-popup", DevicePopupMenu},
+    {"device-popdown", DevicePopdownMenu},
+    {"rename-layout", RenameLayoutAction},
+    {"write-config", WriteConfigAction},
+    {"quit", QuitAction},
+    {"vidmode-restore", VidmodeRestoreAction},
+    {"config-cancel", ConfigCancelAction},
+    {"options-cancel", OptionsCancelAction},
+    {"error-cancel", ErrorCancelAction},
+    {"quit-cancel", QuitCancelAction},
+    {"addmode-cancel", CancelAddModeAction},
+    {"accessx-close", CloseAccessXAction},
+    {"testmode-cancel", CancelTestModeAction},
+    {"help-close", HelpCancelAction},
+    {"expert-close", ExpertCloseAction},
+#ifdef USE_MODULES
+    {"module-options-close", ModuleOptionsCancelAction},
+#endif
+};
+
+static char *device_names[] = {
+/* MOUSE	*/
+    "mouse",
+/* KEYBOARD	*/
+    "keyboard",
+/* CARD		*/
+    "card",
+/* MONITOR	*/
+    "monitor",
+/* SCREEN	*/
+    "screen",
+};
+
+static XtResource appResources[] = {
+#if 0
+    {"config",  __XCONFIGFILE__,  XtRString, sizeof(char*),
+      0, XtRString, "/etc/X11/"__XCONFIGFILE__},
+#endif
+    {"menuBitmap",  "MenuBitmap",  XtRString, sizeof(char*),
+      0, XtRString, "menu8"},
+};
+
+static void
+Usage(void)
+{
+    fprintf(stderr,
+"Usage:\n"
+"   xorgcfg [-option ...]\n"
+"\n"
+"Options:\n"
+"   -config <"__XCONFIGFILE__">   Alternate configuration file.\n"
+"   -modulepath <module-path>  "__XSERVERNAME__" modules location.\n"
+"   -serverpath <server-path>  X server to start (if $DISPLAY is not defined).\n"
+"   -fontpath   <font-path>    Font path for fonts.\n"
+"   -rgbpath    <rgb-path>     Where the rgb.txt file is located.\n"
+#ifdef HAS_NCURSES
+"   -textmode                  Use this option for the text only interface.\n"
+#endif
+#ifdef USE_MODULES
+"   -nomodules                 Use this option if xorgcfg is slow to start.\n"
+"   -verbose <number>          Verbosity used in the loader (default 1).\n"
+#endif
+"   -verify                    Verify modules/options integrity.\n"
+);
+
+    exit(1);
+}
+
+/*
+ * Implementation
+ */
+int
+main(int argc, char *argv[])
+{
+    Widget pane, hpane, expert, popup, mouse, keyboard, card, monitor;
+    Widget bottom, sme, smemodeline, help, quit, layopt;
+    XColor color, tmp;
+    Pixmap pixmap;
+    XGCValues values;
+    XF86ConfLayoutPtr lay;
+    int i, startedx;
+    char *menuPixmapPath = NULL;
+    XrmValue from, to;
+#ifdef sun
+    char *oldPath, *newPath;
+    int pathmodified = 0;
+#endif
+
+    if ((XFree86Dir = getenv("XWINHOME")) == NULL)
+	XFree86Dir = DefaultXFree86Dir;
+
+#ifdef sun
+    if ((OpenwinDir = getenv("OPENWINHOME")) == NULL)
+	OpenwinDir = DefaultOpenwinDir;
+#endif
+
+    chdir(XFree86Dir);
+
+#ifdef USE_MODULES
+    xf86Verbose = 1;
+#endif
+    noverify = True;
+
+    for (i = 1; i < argc; i++) {
+	if (strcmp(argv[i], "-config") == 0 ||
+	    strcmp(argv[i], "-xorgconfig") == 0 ||
+	    strcmp(argv[i], "-xf86config") == 0) {
+	    if (i + 1 < argc) {
+		XF86Config_path = argv[++i];
+		config_set = True;
+	    }
+	} else if (strcmp(argv[i], "-modulepath") == 0) {
+	    if (i + 1 < argc)
+		XF86Module_path = argv[++i];
+	} else if (strcmp(argv[i], "-serverpath") == 0) {
+	    if (i + 1 < argc)
+		XFree86_path = argv[++i];
+	} else if (strcmp(argv[i], "-fontpath") == 0) {
+	    if (i + 1 < argc)
+		XF86Font_path = argv[++i];
+	} else if (strcmp(argv[i], "-rgbpath") == 0) {
+	    if (i + 1 < argc)
+		XF86RGB_path = argv[++i];
+	}
+#ifdef HAS_NCURSES
+	else if (strcmp(argv[i], "-textmode") == 0)
+	    textmode = True;
+#endif
+#ifdef USE_MODULES
+	else if (strcmp(argv[i], "-nomodules") == 0)
+	    nomodules = True;
+	else if (strcmp(argv[i], "-verbose") == 0) {
+	    if (i + 1 < argc)
+		xf86Verbose = atoi(argv[++i]);
+	}
+#endif
+	else if (strcmp(argv[i], "-verify") == 0)
+	    noverify = False;
+	else
+	    Usage();
+    }
+
+#ifdef HAS_NCURSES
+    if (textmode) {
+	TextMode();
+	exit(0);
+    }
+#endif
+    
+    startedx = startx();
+    if (XF86Config_path == NULL)
+	XF86Config_path = XtNewString(__XCONFIGFILE__);
+    if (XkbConfig_path == NULL) {
+	XmuSnprintf(XkbConfig_path_static, sizeof(XkbConfig_path_static),
+		    "%s/%s%s", XFree86Dir, XkbConfigDir, XkbConfigFile);
+	XkbConfig_path = XkbConfig_path_static;
+    }
+
+#ifdef sun
+    if ((oldPath = getenv("XFILESEARCHPATH")) &&
+	(!strstr(oldPath, "/usr/X11/lib"))) {
+	newPath = malloc (strlen ("XFILESEARCHPATH=") + strlen(oldPath) +
+		strlen(":/usr/X11/lib/X11/%T/%N%S") + 1);
+	strcpy (newPath, "XFILESEARCHPATH=");
+	strcat (newPath, oldPath);
+	strcat (newPath, ":/usr/X11/lib/X11/%T/%N%S");
+	putenv (newPath);
+	pathmodified = 1;
+    }
+#endif
+
+    toplevel = XtAppInitialize(&appcon, "XOrgCfg",
+		    	       NULL, 0,
+			       &argc, argv,
+			       NULL, NULL, 0);
+    if (DPY == NULL)
+	DPY = XtDisplay(toplevel);
+
+    XtGetApplicationResources(toplevel, (XtPointer)&menuPixmapPath,
+			      appResources, XtNumber(appResources), NULL, 0);
+    if (menuPixmapPath && strlen(menuPixmapPath)) {
+	from.size = strlen(menuPixmapPath);
+	from.addr = menuPixmapPath;
+	to.size = sizeof(Pixmap);
+	to.addr = (XtPointer)&(menuPixmap);
+	XtConvertAndStore(toplevel, XtRString, &from, XtRBitmap, &to);
+    }
+
+    XtAppAddActions(appcon, actions, XtNumber(actions));
+
+    XawSimpleMenuAddGlobalActions(appcon);
+    XtRegisterGrabAction(DevicePopupMenu, True,
+			 ButtonPressMask | ButtonReleaseMask,
+			 GrabModeAsync, GrabModeAsync);
+
+    pane = XtCreateManagedWidget("pane", panedWidgetClass,
+				 toplevel, NULL, 0);
+    hpane = XtVaCreateManagedWidget("hpane", panedWidgetClass, pane,
+				    XtNorientation, XtorientHorizontal, NULL);
+    topMenu = XtCreateManagedWidget("topM", menuButtonWidgetClass,
+				 hpane, NULL, 0);
+    expert = XtCreateManagedWidget("expert", commandWidgetClass, hpane, NULL, 0);
+    XtAddCallback(expert, XtNcallback, ExpertCallback, NULL);
+    popup = XtCreatePopupShell("menu", simpleMenuWidgetClass,
+			       topMenu, NULL, 0);
+    sme = XtCreateManagedWidget("layout", smeBSBObjectClass,
+				popup, NULL, 0);
+    XtAddCallback(sme, XtNcallback, SetConfigModeCallback,
+		  (XtPointer)CONFIG_LAYOUT);
+    sme = XtCreateManagedWidget("screen", smeBSBObjectClass,
+				popup, NULL, 0);
+    XtAddCallback(sme, XtNcallback, SetConfigModeCallback,
+		  (XtPointer)CONFIG_SCREEN);
+    smemodeline = XtCreateManagedWidget("modeline", smeBSBObjectClass,
+					popup, NULL, 0);
+    XtAddCallback(smemodeline, XtNcallback, SetConfigModeCallback,
+		  (XtPointer)CONFIG_MODELINE);
+    sme = XtCreateManagedWidget("accessx", smeBSBObjectClass,
+				popup, NULL, 0);
+    XtAddCallback(sme, XtNcallback, SetConfigModeCallback,
+		  (XtPointer)CONFIG_ACCESSX);
+
+    commands = XtCreateManagedWidget("commands", formWidgetClass,
+				     pane, NULL, 0);
+
+    mouse = XtVaCreateManagedWidget("mouse", menuButtonWidgetClass,
+				    commands, XtNmenuName, "mouseP", NULL);
+    popup = XtCreatePopupShell("mouseP", simpleMenuWidgetClass,
+			       mouse, NULL, 0);
+    sme = XtCreateManagedWidget("new", smeBSBObjectClass,
+				popup, NULL, 0);
+    XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)MOUSE);
+    mouseSme = XtCreateManagedWidget("configure", smeBSBObjectClass,
+				     popup, NULL, 0);
+    XtAddCallback(mouseSme, XtNcallback, SmeConfigureDeviceCallback,
+		  (XtPointer)MOUSE);
+
+    keyboard = XtVaCreateManagedWidget("keyboard", menuButtonWidgetClass,
+				       commands, XtNmenuName, "keyboardP", NULL);
+    popup = XtCreatePopupShell("keyboardP", simpleMenuWidgetClass,
+			       keyboard, NULL, 0);
+    sme = XtCreateManagedWidget("new", smeBSBObjectClass,
+				popup, NULL, 0);
+    XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)KEYBOARD);
+    keyboardSme = XtCreateManagedWidget("configure", smeBSBObjectClass,
+					popup, NULL, 0);
+    XtAddCallback(keyboardSme, XtNcallback, SmeConfigureDeviceCallback,
+		  (XtPointer)KEYBOARD);
+
+    card = XtVaCreateManagedWidget("card", menuButtonWidgetClass,
+				   commands, XtNmenuName, "cardP", NULL);
+    popup = XtCreatePopupShell("cardP", simpleMenuWidgetClass,
+			       card, NULL, 0);
+    sme = XtCreateManagedWidget("new", smeBSBObjectClass,
+				popup, NULL, 0);
+    XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)CARD);
+    cardSme = XtCreateManagedWidget("configure", smeBSBObjectClass,
+				    popup, NULL, 0);
+    XtAddCallback(cardSme, XtNcallback, SmeConfigureDeviceCallback,
+		  (XtPointer)CARD);
+
+    monitor = XtVaCreateManagedWidget("monitor", menuButtonWidgetClass,
+				      commands, XtNmenuName, "monitorP", NULL);
+    popup = XtCreatePopupShell("monitorP", simpleMenuWidgetClass,
+			       monitor, NULL, 0);
+    sme = XtCreateManagedWidget("new", smeBSBObjectClass,
+				popup, NULL, 0);
+    XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)MONITOR);
+    monitorSme = XtCreateManagedWidget("configure", smeBSBObjectClass,
+				       popup, NULL, 0);
+    XtAddCallback(monitorSme, XtNcallback, SmeConfigureDeviceCallback,
+		  (XtPointer)MONITOR);
+
+    work = XtCreateManagedWidget("work", compositeWidgetClass,
+				 pane, NULL, 0);
+
+    bottom = XtCreateManagedWidget("bottom", formWidgetClass,
+				   pane, NULL, 0);
+    layoutm = XtCreateManagedWidget("select", menuButtonWidgetClass,
+				    bottom, NULL, 0);
+    layout = XtVaCreateManagedWidget("layout", asciiTextWidgetClass,
+				     bottom,
+				     XtNeditType, XawtextEdit,
+				     NULL);
+    layoutp = XtCreatePopupShell("menu", simpleMenuWidgetClass,
+				 bottom, NULL, 0);
+    sme = XtCreateManagedWidget("new", smeBSBObjectClass, layoutp,
+				NULL, 0);
+    XtAddCallback(sme, XtNcallback, SelectLayoutCallback, NULL);
+    help = XtCreateManagedWidget("help", commandWidgetClass,
+				 bottom, NULL, 0);
+    XtAddCallback(help, XtNcallback, HelpCallback, NULL);
+    quit = XtCreateManagedWidget("quit", commandWidgetClass,
+				 bottom, NULL, 0);
+    XtAddCallback(quit, XtNcallback, QuitCallback, NULL);
+
+    XtRealizeWidget(toplevel);
+    XtRealizeWidget(topMenu);
+
+    pixmap = XCreateBitmapFromData(XtDisplay(toplevel), XtWindow(toplevel),
+				   no_cursor_data, 8, 8);
+    XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "black",
+		     &color, &tmp);
+    no_cursor = XCreatePixmapCursor(XtDisplay(toplevel), pixmap, pixmap,
+				    &color, &color, 0, 0);
+
+    XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray55",
+		     &color, &tmp);
+    values.line_width = 3;
+    values.foreground = color.pixel;
+    cablegcshadow = XCreateGC(XtDisplay(toplevel), XtWindow(toplevel),
+			GCForeground | GCLineWidth, &values);
+    XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray85",
+		     &color, &tmp);
+    values.line_width = 1;
+    values.foreground = color.pixel;
+    cablegc = XCreateGC(XtDisplay(toplevel), XtWindow(toplevel),
+			GCForeground | GCLineWidth, &values);
+
+    computer.cpu = XtCreateManagedWidget("cpu", simpleWidgetClass,
+					 work, NULL, 0);
+    cpu_device.widget = computer.cpu;
+    cpu_device.type = SERVER;
+
+    XtAddEventHandler(work, ExposureMask, False,
+		      ComputerEventHandler, (XtPointer)NULL);
+
+    wm_delete_window = XInternAtom(DPY, "WM_DELETE_WINDOW", False);
+    XSetWMProtocols(DPY, XtWindow(toplevel), &wm_delete_window, 1);
+
+    StartConfig();
+    InitializeDevices();
+    UpdateMenuDeviceList(MOUSE);
+    UpdateMenuDeviceList(KEYBOARD);
+    UpdateMenuDeviceList(CARD);
+    UpdateMenuDeviceList(MONITOR);
+    XtSetSensitive(smemodeline, VideoModeInitialize());
+
+    lay = XF86Config->conf_layout_lst;
+    while (lay != NULL) {
+	sme = XtVaCreateManagedWidget("sme", smeBSBObjectClass,
+				      layoutp,
+				      XtNlabel, lay->lay_identifier,
+				      XtNmenuName, lay->lay_identifier,
+				      XtNleftBitmap, menuPixmap,
+				      NULL);
+	XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay);
+	if (layoutsme == NULL)
+	    layoutsme = sme;
+	layopt = XtCreatePopupShell(lay->lay_identifier, simpleMenuWidgetClass,
+				    layoutp, NULL, 0);
+	sme = XtCreateManagedWidget("default", smeBSBObjectClass,
+				    layopt, NULL, 0);
+	XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL);
+	sme = XtCreateManagedWidget("remove", smeBSBObjectClass,
+				    layopt, NULL, 0);
+	XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL);
+	XtRealizeWidget(layopt);
+
+	lay = (XF86ConfLayoutPtr)(lay->list.next);
+    }
+    SelectLayoutCallback(layoutsme,
+			 XF86Config->conf_layout_lst, NULL);
+
+    startaccessx();
+    if (startedx) {
+	switch (fork()) {
+	    case 0: {
+		char path[PATH_MAX];
+
+#ifdef sun
+                XmuSnprintf(path, sizeof(path), "%s/bin/twm", OpenwinDir);
+#else
+		XmuSnprintf(path, sizeof(path), "%s/bin/twm", XFree86Dir);
+#endif
+		execl(path, "twm", (void *)NULL);
+		exit(-127);
+	    }	break;
+	    case -1:
+		fprintf(stderr, "Cannot fork.\n");
+		exit(1);
+		break;
+	    default:
+		break;
+	}
+    }
+
+#ifdef USE_MODULES
+    if (!nomodules)
+	LoaderInitializeOptions();
+#endif
+
+    /* ReadCardsDatabase() must be called after LoaderInitializeOptions() */
+    ReadCardsDatabase();
+
+    if (!config_set && startedx) {
+	XtFree(XF86Config_path);
+#ifndef XF86CONFIG
+# define XF86CONFIG __XCONFIGFILE__
+#endif
+#ifdef XF86CONFIGDIR
+	XF86Config_path = XtNewString(XF86CONFIGDIR "/" XF86CONFIG);
+#else
+	XF86Config_path = XtNewString("/etc/X11/" XF86CONFIG);
+#endif
+    }
+    XtAppMainLoop(appcon);
+    if (startedx)
+	endx();
+
+#ifdef sun
+    if (pathmodified)
+        putenv(oldPath);
+#endif
+
+    return (0);
+}
+
+static Widget shell_cf;
+static int write_cf, asking_cf;
+static int cf_state = 0;
+#define	CF_XF86Config	1
+#define	CF_XKBConfig	2
+#define CF_First	CF_XF86Config
+#define CF_Last		CF_XKBConfig
+
+/*ARGSUSED*/
+static void
+WriteConfig(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    asking_cf = 0;
+    XtPopdown(shell_cf);
+    write_cf = (long)user_data;
+}
+
+/*ARGSUSED*/
+void
+QuitCancelAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    WriteConfig(w, (XtPointer)-1, NULL);
+}
+
+/*ARGSUSED*/
+void
+WriteConfigAction(Widget w, XEvent *event,
+		  String *params, Cardinal *num_params)
+{
+    WriteConfig(w, (XtPointer)True, NULL);
+}
+
+static Bool
+AskConfig(void)
+{
+    static Widget dialog;
+
+    if (shell_cf == NULL) {
+	Arg args[1];
+	char *l, *label;
+	int len;
+
+	shell_cf = XtCreatePopupShell("quit", transientShellWidgetClass,
+				      toplevel, NULL, 0);
+	dialog = XtVaCreateManagedWidget("ask", dialogWidgetClass, shell_cf,
+					 XtNvalue, XF86Config_path, NULL);
+	XawDialogAddButton(dialog, "yes", WriteConfig, (XtPointer)1);
+	XawDialogAddButton(dialog, "no", WriteConfig, (XtPointer)0);
+	XawDialogAddButton(dialog, "cancel", WriteConfig, (XtPointer)-1);
+	XtRealizeWidget(shell_cf);
+	XSetWMProtocols(DPY, XtWindow(shell_cf), &wm_delete_window, 1);
+	XtSetArg(args[0], XtNlabel, &l);
+	XtGetValues(dialog, args, 1);
+	label = XtMalloc(len = (strlen(l) + strlen(XF86CONFIG) + 2));
+	XmuSnprintf(label, len, "%s\n", XF86CONFIG);
+	strcat(label, l);
+	XtSetArg(args[0], XtNlabel, label);
+	XtSetValues(dialog, args, 1);
+	XtFree(label);
+    }
+    else {
+	Arg args[2];
+	Cardinal num_args = 0;
+	char *l, *label = NULL, *str = "";
+
+	XtSetArg(args[0], XtNlabel, &l);
+	XtGetValues(dialog, args, 1);
+	switch (cf_state) {
+	    case CF_XF86Config:
+		str = XF86CONFIG;
+		XtSetArg(args[num_args], XtNvalue, XF86Config_path);
+		++num_args;
+		break;
+	    case CF_XKBConfig:
+		str = "XKB";
+		XtSetArg(args[num_args], XtNvalue, XkbConfig_path);
+		++num_args;
+		break;
+	}
+	l = strchr(l, '\n');
+	if (l != NULL) {
+	    label = XtMalloc(strlen(str) + strlen(l) + 1);
+	    strcpy(label, str);
+	    strcat(label, l);
+	    XtSetArg(args[num_args], XtNlabel, label);
+	    ++num_args;
+	}
+	XtSetValues(dialog, args, num_args);
+	if (l != NULL)
+	    XtFree(label);
+    }
+
+    asking_cf = 1;
+
+    XtPopup(shell_cf, XtGrabExclusive);
+    while (asking_cf)
+	XtAppProcessEvent(XtWidgetToApplicationContext(shell_cf), XtIMAll);
+
+    if (write_cf > 0) {
+	switch (cf_state) {
+	    case CF_XF86Config:
+		XF86Config_path = XawDialogGetValueString(dialog);
+		XmuSnprintf(XF86Config_path_static,
+			    sizeof(XF86Config_path_static),
+			    "%s", XF86Config_path);
+		XF86Config_path = XF86Config_path_static;
+		break;
+	    case CF_XKBConfig:
+		XkbConfig_path = XawDialogGetValueString(dialog);
+		XmuSnprintf(XkbConfig_path_static,
+			    sizeof(XkbConfig_path_static),
+			    "%s", XkbConfig_path);
+		XkbConfig_path = XkbConfig_path_static;
+		break;
+	}
+    }
+
+    return (write_cf);
+}
+
+/*ARGSUSED*/
+void
+PopdownErrorCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XtPopdown((Widget)user_data);
+}
+
+/*ARGSUSED*/
+void
+ErrorCancelAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    XtPopdown((Widget)w);
+}
+
+/*ARGSUSED*/
+void
+QuitAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    QuitCallback(w, NULL, NULL);
+}
+
+/*ARGSUSED*/
+void
+QuitCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    for (cf_state = CF_First; cf_state <= CF_Last; cf_state++) {
+	if (cf_state == CF_XKBConfig && xkb_info == NULL)
+	    continue;
+	
+	switch (AskConfig()) {
+	    case 0:
+		break;
+	    case 1:
+		if ((cf_state == CF_XF86Config &&
+		     !xf86writeConfigFile(XF86Config_path, XF86Config)) ||
+		    (cf_state == CF_XKBConfig &&
+		     !WriteXKBConfiguration(XkbConfig_path,
+					    &xkb_info->config))) {
+		    static Widget shell;
+
+		    if (shell == NULL) {
+			Widget dialog;
+
+			shell = XtCreatePopupShell("error",
+				transientShellWidgetClass,
+				toplevel, NULL, 0);
+			dialog = XtVaCreateManagedWidget("notice",
+				 dialogWidgetClass,
+				 shell, XtNvalue, NULL,
+				 NULL);
+			XawDialogAddButton(dialog, "ok", PopdownErrorCallback,
+					   (XtPointer)shell);
+			XtRealizeWidget(shell);
+			XSetWMProtocols(DPY, XtWindow(shell),
+					&wm_delete_window, 1);
+		    }
+		    XtPopup(shell, XtGrabExclusive);
+		    return;
+		}
+		break;
+	    default:
+		return;
+	}
+    }
+
+    endx();
+    exit(0);
+}
+
+void
+InitializeDevices(void)
+{
+    xf86cfgDevice *device;
+    int mouse_x, mouse_y, keyboard_x, keyboard_y,
+	card_x, card_y, monitor_x, monitor_y, len;
+    XF86ConfInputPtr input = XF86Config->conf_input_lst;
+    XF86ConfDevicePtr card = XF86Config->conf_device_lst;
+    XF86ConfMonitorPtr monitor = XF86Config->conf_monitor_lst;
+    XF86OptionPtr flags = NULL;
+    char buffer[4096], *tip;
+    Arg args[1];
+
+    if (XF86Config->conf_flags != NULL)
+	flags = XF86Config->conf_flags->flg_option_lst;
+
+    len = 0;
+    while (flags && len < sizeof(buffer) - 1) {
+	len += XmuSnprintf(buffer + len, sizeof(buffer) - len,
+			   "Option     \"%s\"",
+			   flags->opt_name);
+	if (flags->opt_val != NULL)
+	    len += XmuSnprintf(buffer + len, sizeof(buffer) - len,
+			       " \"%s\"\n",
+			       flags->opt_val);
+	else
+	    len += XmuSnprintf(buffer + len, sizeof(buffer) - len,
+			       "%s", "\n");
+	flags = (XF86OptionPtr)(flags->list.next);
+    }
+
+    if (len) {
+	tip = XtNewString(buffer);
+	XtSetArg(args[0], XtNtip, tip);
+	XtSetValues(computer.cpu, args, 1);
+    }
+
+#define DEFAULT_MOUSE_WIDTH	30
+#define DEFAULT_MOUSE_HEIGHT	40
+#define DEFAULT_KEYBOARD_WIDTH	48
+#define DEFAULT_KEYBOARD_HEIGHT	36
+    mouse_x = work->core.width - (work->core.width >> 2);
+    mouse_y = work->core.height - DEFAULT_MOUSE_HEIGHT;
+    keyboard_x = 6;
+    keyboard_y = work->core.height - DEFAULT_KEYBOARD_HEIGHT;
+
+    while (input != NULL) {
+	if (input->inp_driver) {
+	    if (strcasecmp(input->inp_driver, "mouse") == 0) {
+		device = AddDevice(MOUSE, (XtPointer)input, mouse_x, mouse_y);
+		SetTip(device);
+		if ((mouse_x += DEFAULT_MOUSE_WIDTH) > work->core.width) {
+		    if ((mouse_y -= DEFAULT_MOUSE_HEIGHT) < (work->core.height >> 1))
+			mouse_y = work->core.height >> 1;
+		    mouse_x = work->core.width - (work->core.width >> 2);
+		}
+	    }
+	    else if (IS_KBDDRIV(input->inp_driver)) {
+		device = AddDevice(KEYBOARD, (XtPointer)input, keyboard_x, keyboard_y);
+		SetTip(device);
+		if ((keyboard_x += DEFAULT_KEYBOARD_WIDTH) >
+		    work->core.width - (work->core.width >> 2))  {
+		    if ((keyboard_y -= DEFAULT_KEYBOARD_HEIGHT) < (work->core.height >> 1))
+			keyboard_y = work->core.height >> 1;
+		    keyboard_x = 6;
+		}
+	    }
+	}
+	input = (XF86ConfInputPtr)(input->list.next);
+    }
+
+#define DEFAULT_CARD_WIDTH	45
+#define DEFAULT_CARD_HEIGHT	46
+    card_x = 6;
+    card_y = (work->core.height >> 1) - 20 - DEFAULT_CARD_HEIGHT;
+    while (card != NULL) {
+	device = AddDevice(CARD, (XtPointer)card, card_x, card_y);
+	SetTip(device);
+	if ((card_x += DEFAULT_CARD_WIDTH) > work->core.width) {
+	    if ((card_y -= DEFAULT_CARD_HEIGHT) < (work->core.height >> 2))
+		card_y = work->core.height >> 2;
+	    card_x = 6;
+	}
+	card = (XF86ConfDevicePtr)(card->list.next);
+    }
+
+#define DEFAULT_MONITOR_WIDTH	48
+#define DEFAULT_MONITOR_HEIGHT	48
+    monitor_x = 6;
+    monitor_y = 6;
+    while (monitor != NULL) {
+	XF86ConfScreenPtr screen = XF86Config->conf_screen_lst;
+
+	device = AddDevice(MONITOR, (XtPointer)monitor, monitor_x, monitor_y);
+	SetTip(device);
+	if ((monitor_x += DEFAULT_MONITOR_WIDTH) > work->core.width) {
+	    if ((monitor_y += DEFAULT_MONITOR_HEIGHT) >
+		(work->core.height >> 2) - DEFAULT_MONITOR_HEIGHT)
+		monitor_y = (work->core.height >> 2) - DEFAULT_MONITOR_HEIGHT;
+	    monitor_x = 6;
+	}
+
+	while (screen != NULL) {
+	    if (screen->scrn_monitor == monitor) {
+		card = XF86Config->conf_device_lst;
+		while (card != NULL) {
+		    if (screen->scrn_device == card) {
+			xf86cfgScreen *scr = (xf86cfgScreen*)
+			    XtCalloc(1, sizeof(xf86cfgScreen));
+			int i;
+
+			for (i = 0; i < computer.num_devices; i++)
+			    if ((XF86ConfDevicePtr)(computer.devices[i]->config)
+				== card)
+				break;
+			scr->screen = screen;
+			scr->card = computer.devices[i];
+			scr->monitor = device;
+			scr->refcount = 0;
+			++scr->card->refcount;
+			++scr->monitor->refcount;
+			computer.screens = (xf86cfgScreen**)
+				XtRealloc((XtPointer)computer.screens,
+					  sizeof(xf86cfgScreen*) *
+					  (computer.num_screens + 1));
+			CreateScreenWidget(scr);
+			scr->type = SCREEN;
+			computer.screens[computer.num_screens++] = scr;
+			SetTip((xf86cfgDevice*)scr);
+			break;
+		    }
+		    card = (XF86ConfDevicePtr)(card->list.next);
+		}
+		device->state = USED;
+	    }
+	    screen = (XF86ConfScreenPtr)(screen->list.next);
+	}
+
+	monitor = (XF86ConfMonitorPtr)(monitor->list.next);
+    }
+}
+
+xf86cfgDevice *
+AddDevice(int type, XtPointer config, int x, int y)
+{
+    switch (type) {
+	case MOUSE:
+	case KEYBOARD:
+	case CARD:
+	case MONITOR:
+	    computer.devices = (xf86cfgDevice**)
+		XtRealloc((XtPointer)computer.devices,
+			  sizeof(xf86cfgDevice*) * (computer.num_devices + 1));
+	    computer.devices[computer.num_devices] = (xf86cfgDevice*)
+		XtCalloc(1, sizeof(xf86cfgDevice));
+	    computer.devices[computer.num_devices]->config = config;
+	    computer.devices[computer.num_devices]->widget =
+		XtVaCreateManagedWidget(device_names[type], simpleWidgetClass,
+					work,
+					XtNx, x,
+					XtNy, y,
+					XtNtip, NULL,
+					NULL);
+	    computer.devices[computer.num_devices]->type = type;
+	    computer.devices[computer.num_devices]->state = UNUSED;
+	    computer.devices[computer.num_devices]->refcount = 0;
+	    ++computer.num_devices;
+	    break;
+	default:
+	    fprintf(stderr, "Bad argument to AddDevice.\n");
+	    exit(1);
+	    return (NULL);
+    }
+
+    UpdateMenuDeviceList(type);
+
+    return (computer.devices[computer.num_devices - 1]);
+}
+
+/*ARGSUSED*/
+static void
+HelpCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    char *topic = NULL;
+
+    switch (config_mode) {
+	case CONFIG_LAYOUT:
+	    topic = HELP_DEVICES;
+	    break;
+	case CONFIG_SCREEN:
+	    topic = HELP_SCREEN;
+	    break;
+	case CONFIG_MODELINE:
+	    topic = HELP_MODELINE;
+	    break;
+	case CONFIG_ACCESSX:
+	    topic = HELP_ACCESSX;
+	    break;
+    }
+    Help(topic);
+}
+
+void
+SelectLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i, j;
+    XF86ConfLayoutPtr lay = (XF86ConfLayoutPtr)user_data;
+    XF86ConfInputrefPtr input;
+    XF86ConfAdjacencyPtr adj;
+    Widget sme, layopt;
+    Arg args[1];
+    char *str;
+
+			       /* XXX Needs to check computer.layout,
+				* because this function should also create
+				* a new layout...
+				*/
+    if (lay == computer.layout && computer.layout)
+	return;
+
+    if (computer.layout != NULL) {
+	for (i = 0; i < computer.num_layouts; i++) {
+	    if (computer.layouts[i]->layout == computer.layout)
+		break;
+	}
+	if (i < computer.num_layouts) {
+	    XtFree((XtPointer)computer.layouts[i]->screen);
+	    XtFree((XtPointer)computer.layouts[i]->position);
+	}
+	else {
+	    computer.layouts = (xf86cfgLayout**)
+		XtRealloc((XtPointer)computer.layouts, sizeof(xf86cfgLayout*) *
+			  (computer.num_layouts + 1));
+	    ++computer.num_layouts;
+	}
+	computer.layouts[i] = (xf86cfgLayout*)XtCalloc(1, sizeof(xf86cfgLayout));
+	computer.layouts[i]->layout = computer.layout;
+	computer.layouts[i]->num_layouts = computer.num_screens;
+	computer.layouts[i]->screen = (xf86cfgScreen**)
+	    XtMalloc(sizeof(xf86cfgScreen*) * computer.num_screens);
+	computer.layouts[i]->position = (XPoint*)
+	    XtMalloc(sizeof(XPoint) * computer.num_screens);
+	for (j = 0; j < computer.num_screens; j++) {
+	    computer.layouts[i]->screen[j] = computer.screens[j];
+	    computer.layouts[i]->position[j].x = computer.screens[j]->widget->core.x;
+	    computer.layouts[i]->position[j].y = computer.screens[j]->widget->core.y;
+	}
+    }
+
+    if (lay != NULL) {
+	for (i = 0; i < computer.num_layouts; i++)
+	    if (computer.layouts[i]->layout == lay) {
+		for (j = 0; j < computer.layouts[i]->num_layouts; j++) {
+		    int k;
+
+		    for (k = 0; k < computer.num_screens; k++)
+			if (computer.screens[k] == computer.layouts[i]->screen[j]) {
+			    XtMoveWidget(computer.screens[k]->widget,
+					 computer.layouts[i]->position[j].x,
+					 computer.layouts[i]->position[j].y);
+			}
+		}
+		break;
+	    }
+
+	layoutsme = w;
+	XtSetArg(args[0], XtNlabel, &str);
+	XtGetValues(w, args, 1);
+	XtSetArg(args[0], XtNstring, str);
+	XtSetValues(layout, args, 1);
+    }
+
+    computer.layout = lay;
+
+    for (i = 0; i < computer.num_devices; i++)
+	computer.devices[i]->state = UNUSED;
+    for (i = 0; i < computer.num_screens; i++)
+	computer.screens[i]->state = UNUSED;
+
+    if (lay == NULL) {
+	char name[64];
+	XF86ConfLayoutPtr l;
+	int num_layouts = 0;
+
+	l = XF86Config->conf_layout_lst;
+	while (l != NULL) {
+	    if (l->lay_adjacency_lst == NULL &&
+		l->lay_inactive_lst == NULL &&
+		l->lay_input_lst == NULL &&
+		l->lay_option_lst == NULL &&
+		l->lay_comment == NULL) {
+		for (i = 0;
+		     i < ((CompositeWidget)layout)->composite.num_children; i++)
+		    if (strcmp(XtName(((CompositeWidget)layout)->composite.
+			       children[i]), l->lay_identifier) == 0) {
+			layoutsme = ((CompositeWidget)layout)->composite.children[i];
+		    }
+		computer.layout = l;
+		XtSetArg(args[0], XtNstring, l->lay_identifier);
+		XtSetValues(layout, args, 1);
+		if (config_mode == CONFIG_LAYOUT)
+		    DrawCables();
+		if (config_mode == CONFIG_SCREEN)
+		    ScreenSetup(True);
+		return;
+	    }
+	    ++num_layouts;
+	    l = (XF86ConfLayoutPtr)(l->list.next);
+	}
+	do {
+	    XmuSnprintf(name, sizeof(name), "Layout%d", num_layouts);
+	    ++num_layouts;
+	} while (xf86findLayout(name,
+		 XF86Config->conf_layout_lst) != NULL);
+	l = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec));
+
+	l->lay_identifier = XtNewString(name);
+	XF86Config->conf_layout_lst =
+	    xf86addLayout(XF86Config->conf_layout_lst, l);
+	layoutsme = XtVaCreateManagedWidget("sme", smeBSBObjectClass,
+					    layoutp,
+					    XtNlabel, name,
+					    XtNmenuName, l->lay_identifier,
+					    XtNleftBitmap, menuPixmap,
+					    NULL);
+	XtAddCallback(layoutsme, XtNcallback,
+		      SelectLayoutCallback, (XtPointer)l);
+
+	layopt = XtCreatePopupShell(l->lay_identifier, simpleMenuWidgetClass,
+				    layoutp, NULL, 0);
+	sme = XtCreateManagedWidget("default", smeBSBObjectClass,
+				    layopt, NULL, 0);
+	XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL);
+	sme = XtCreateManagedWidget("remove", smeBSBObjectClass,
+				    layopt, NULL, 0);
+	XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL);
+	XtRealizeWidget(layopt);
+
+	computer.layout = l;
+	XtSetArg(args[0], XtNstring, name);
+	XtSetValues(layout, args, 1);
+	if (config_mode == CONFIG_LAYOUT)
+	    DrawCables();
+	if (config_mode == CONFIG_SCREEN)
+	    ScreenSetup(True);
+	return;
+    }
+
+    input = lay->lay_input_lst;
+    adj = lay->lay_adjacency_lst;
+
+    for (i = 0; i < computer.num_devices; i++)
+	if (computer.devices[i]->config != NULL &&
+	    (computer.devices[i]->type == MOUSE ||
+	     computer.devices[i]->type == KEYBOARD)) {
+	    while (input != NULL) {
+		if (strcmp(input->iref_inputdev_str, ((XF86ConfInputPtr)
+		    (computer.devices[i]->config))->inp_identifier) == 0) {
+		    computer.devices[i]->state = USED;
+		    break;
+		}
+		input = (XF86ConfInputrefPtr)(input->list.next);
+	    }
+	    input = lay->lay_input_lst;
+	}
+
+    for (i = 0; i < computer.num_devices; i++)
+	if (computer.devices[i]->type == CARD) {
+	    while (adj != NULL) {
+		XF86ConfScreenPtr screen = adj->adj_screen;
+
+		if (computer.devices[i]->config != NULL &&
+		    strcmp(screen->scrn_device_str, ((XF86ConfDevicePtr)
+		    (computer.devices[i]->config))->dev_identifier) == 0) {
+		    int j;
+
+		    for (j = 0; j < computer.num_screens; j++)
+			if (computer.screens[j]->card == computer.devices[i])
+			    break;
+		    computer.screens[j]->card->state = USED;
+		    if (computer.screens[j]->monitor != NULL)
+			computer.screens[j]->monitor->state = USED;
+		    computer.screens[j]->state = USED;
+		}
+
+		adj = (XF86ConfAdjacencyPtr)(adj->list.next);
+	    }
+	    adj = lay->lay_adjacency_lst;
+	}
+
+    if (config_mode == CONFIG_LAYOUT)
+	DrawCables();
+    else if (config_mode == CONFIG_SCREEN)
+	ScreenSetup(True);
+}
+
+/*ARGSUSED*/
+void
+DefaultLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    Widget layopt, sme;
+    int i;
+    char *str;
+    XF86ConfLayoutPtr prev, tmp, lay;
+
+    str = w && XtParent(w) ? XtName(XtParent(w)) : NULL;
+    if (str == NULL)
+	return;
+
+    prev = XF86Config->conf_layout_lst;
+    lay = xf86findLayout(str, prev);
+    if (prev == lay)
+	return;
+
+    tmp = prev;
+    while (tmp != NULL) {
+	if (tmp == lay)
+	    break;
+	prev = tmp;
+	tmp = (XF86ConfLayoutPtr)(tmp->list.next);
+    }
+
+    for (i = 1; i < ((CompositeWidget)layoutp)->composite.num_children; i++)
+	XtDestroyWidget(((CompositeWidget)layoutp)->composite.children[i]);
+    for (i = 0; i < layoutp->core.num_popups; i++)
+	XtDestroyWidget(layoutp->core.popup_list[i]);
+
+    prev->list.next = lay->list.next;
+    lay->list.next = XF86Config->conf_layout_lst;
+    XF86Config->conf_layout_lst = lay;
+
+    layoutsme = NULL;
+    lay = XF86Config->conf_layout_lst;
+    while (lay != NULL) {
+	sme = XtVaCreateManagedWidget("sme", smeBSBObjectClass,
+				      layoutp,
+				      XtNlabel, lay->lay_identifier,
+				      XtNmenuName, lay->lay_identifier,
+				      XtNleftBitmap, menuPixmap,
+				      NULL);
+	XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay);
+	if (layoutsme == NULL)
+	    layoutsme = sme;
+	layopt = XtCreatePopupShell(lay->lay_identifier, simpleMenuWidgetClass,
+				    layoutp, NULL, 0);
+	sme = XtCreateManagedWidget("default", smeBSBObjectClass,
+				    layopt, NULL, 0);
+	XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL);
+	sme = XtCreateManagedWidget("remove", smeBSBObjectClass,
+				    layopt, NULL, 0);
+	XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL);
+	XtRealizeWidget(layopt);
+
+	lay = (XF86ConfLayoutPtr)(lay->list.next);
+    }
+    SelectLayoutCallback(layoutsme,
+			 XF86Config->conf_layout_lst, NULL);
+}
+
+/*ARGSUSED*/
+void
+RemoveLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XF86ConfLayoutPtr prev, tmp, lay, rem;
+    Widget sme = NULL;
+    int i;
+    char *str;
+    Arg args[1];
+
+    str = w && XtParent(w) ? XtName(XtParent(w)) : NULL;
+    if (str == NULL)
+	return;
+
+    prev = XF86Config->conf_layout_lst;
+    lay = xf86findLayout(str, prev);
+    tmp = prev;
+    while (tmp != NULL) {
+	if (tmp == lay)
+	    break;
+	prev = tmp;
+	tmp = (XF86ConfLayoutPtr)(tmp->list.next);
+    }
+
+    rem = lay;
+    if (tmp != NULL)
+	lay = (XF86ConfLayoutPtr)(tmp->list.next);
+    if (lay == NULL && prev != tmp)
+	lay = prev;
+
+    if (lay != NULL) {
+	int i;
+
+	for (i = 0; i < ((CompositeWidget)layoutp)->composite.num_children;
+	    i++) {
+	    XtSetArg(args[0], XtNlabel, &str);
+	    XtGetValues(((CompositeWidget)layoutp)->composite.children[i],
+			args, 1);
+	    if (strcmp(lay->lay_identifier, str) == 0) {
+		layoutsme = ((CompositeWidget)layoutp)->composite.children[i];
+		break;
+	    }
+	}
+	SelectLayoutCallback(layoutsme, lay, NULL);
+    }
+    else {
+	computer.layout = NULL;
+	XtSetArg(args[0], XtNstring, "");
+	XtSetValues(layout, args, 1);
+
+	for (i = 0; i < computer.num_devices; i++)
+	    computer.devices[i]->state = UNUSED;
+	DrawCables();
+    }
+
+    for (i = 0; i < ((CompositeWidget)layoutp)->composite.num_children; i++) {
+	XtSetArg(args[0], XtNlabel, &str);
+	XtGetValues(((CompositeWidget)layoutp)->composite.children[i], args, 1);
+	if (strcmp(rem->lay_identifier, str) == 0) {
+	    sme = ((CompositeWidget)layoutp)->composite.children[i];
+	    break;
+	}
+    }
+
+    xf86removeLayout(XF86Config, rem);
+    if (sme)
+	XtDestroyWidget(sme);
+}
+
+void
+SetTip(xf86cfgDevice *device)
+{
+    XF86OptionPtr option = NULL;
+    char *tip, buffer[4096];
+    Arg args[1];
+    int len = 0;
+
+    XtSetArg(args[0], XtNtip, &tip);
+    XtGetValues(device->widget, args, 1);
+
+    switch (device->type) {
+	case MOUSE: {
+	    XF86ConfInputPtr mouse = (XF86ConfInputPtr)device->config;
+
+	    if (mouse == NULL)
+		return;
+	    len = XmuSnprintf(buffer, sizeof(buffer),
+			      "Identifier \"%s\"\n"
+			      "Driver     \"mouse\"\n",
+			      mouse->inp_identifier);
+	    option = mouse->inp_option_lst;
+	}   break;
+	case KEYBOARD: {
+    	    XF86ConfInputPtr keyboard = (XF86ConfInputPtr)device->config;
+
+	    if (keyboard == NULL)
+		return;
+	    len = XmuSnprintf(buffer, sizeof(buffer),
+			      "Identifier \"%s\"\n"
+			      "Driver     \"keyboard\"\n",
+			      keyboard->inp_identifier);
+	    option = keyboard->inp_option_lst;
+	}   break;
+	case CARD: {
+	    XF86ConfDevicePtr card = (XF86ConfDevicePtr)device->config;
+
+	    if (card == NULL)
+		return;
+	    len = XmuSnprintf(buffer, sizeof(buffer),
+			      "Identifier \"%s\"\n"
+			      "Driver     \"%s\"\n",
+			      card->dev_identifier,
+			      card->dev_driver);
+	    option = card->dev_option_lst;
+	}   break;
+	case MONITOR: {
+	    XF86ConfMonitorPtr monitor = (XF86ConfMonitorPtr)device->config;
+
+	    if (monitor == NULL)
+		return;
+	    if (monitor->mon_vendor != NULL)
+	    	len = XmuSnprintf(buffer, sizeof(buffer),
+			      "Identifier \"%s\"\n"
+			      "Vendor     \"%s\"\n",
+			      monitor->mon_identifier,
+			      monitor->mon_vendor);
+	    else 
+	    	len = XmuSnprintf(buffer, sizeof(buffer),
+			      "Identifier \"%s\"\n",
+			      monitor->mon_identifier);
+	    option = monitor->mon_option_lst;
+	}   break;
+	case SCREEN: {
+	    XF86ConfScreenPtr screen = (XF86ConfScreenPtr)device->config;
+
+	    if (screen == NULL)
+		return;
+	    len = XmuSnprintf(buffer, sizeof(buffer),
+			      "Identifier \"%s\"\n",
+			      screen->scrn_identifier);
+	    if (screen->scrn_device_str != NULL)
+		len += XmuSnprintf(buffer + len, sizeof(buffer),
+				   "Device     \"%s\"\n",
+				   screen->scrn_device_str);
+	    if (screen->scrn_monitor_str != NULL)
+		len += XmuSnprintf(buffer + len, sizeof(buffer),
+				   "Monitor    \"%s\"\n",
+				   screen->scrn_monitor_str);
+	    option = screen->scrn_option_lst;
+	}   break;
+	case SERVER: {
+	    len = XmuSnprintf(buffer, sizeof(buffer),
+			      "%s\n", "Server Flags");
+	    option = XF86Config->conf_flags->flg_option_lst;
+	}   break;
+    }
+
+    while (option && len < sizeof(buffer) - 1) {
+	len += XmuSnprintf(buffer + len, sizeof(buffer) - len,
+			   "Option     \"%s\"",
+			   option->opt_name);
+	if (option->opt_val != NULL)
+	    len += XmuSnprintf(buffer + len, sizeof(buffer) - len,
+			       " \"%s\"\n",
+			       option->opt_val);
+	else
+	    len += XmuSnprintf(buffer + len, sizeof(buffer) - len,
+			       "%s", "\n");
+	option = (XF86OptionPtr)(option->list.next);
+    }
+
+    tip = buffer;
+    XtSetArg(args[0], XtNtip, tip);
+    XtSetValues(device->widget, args, 1);
+}
+
+/*ARGSUSED*/
+void
+AddDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    AddDevice((long)user_data, NULL, 6, 6);
+}
+
+void
+SmeConfigureDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i;
+
+    switch ((long)user_data) {
+	case MOUSE:
+	case KEYBOARD:
+	case CARD:
+	case MONITOR:
+	    for (i = 0; i < computer.num_devices; i++)
+		if (computer.devices[i]->type == (long)user_data) {
+		    config = computer.devices[i]->widget;
+		    ConfigureDeviceCallback(w, NULL, NULL);
+		}
+	    break;
+
+	/* hack for newly added devices */
+	case -(MOUSE + 100):
+	case -(KEYBOARD + 100):
+	case -(CARD + 100):
+	case -(MONITOR + 100):
+	    for (i = 0; i < computer.num_devices; i++)
+		if (-(computer.devices[i]->type + 100) == (long)user_data &&
+		    computer.devices[i]->config == NULL) {
+		    config = computer.devices[i]->widget;
+		    ConfigureDeviceCallback(w, NULL, NULL);
+		}
+	    break;
+
+	default:
+	    for (i = 0; i < computer.num_devices; i++)
+		if (computer.devices[i]->config == user_data) {
+		    config = computer.devices[i]->widget;
+		    ConfigureDeviceCallback(w, NULL, NULL);
+		}
+	    break;
+    }
+}
+
+void
+ConfigureDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i, j;
+
+    if (config_mode == CONFIG_LAYOUT) {
+	for (i = 0; i < computer.num_devices; i++) {
+	    if (computer.devices[i]->widget == config) {
+		switch (computer.devices[i]->type) {
+		    case MOUSE: {
+			XF86ConfInputPtr mouse =
+			    MouseConfig(computer.devices[i]->config);
+
+			if (mouse != NULL && computer.devices[i]->config == NULL) {
+			    XF86Config->conf_input_lst =
+				xf86addInput(XF86Config->conf_input_lst,
+					     mouse);
+			    computer.devices[i]->config = (XtPointer)mouse;
+			}
+			SetTip(computer.devices[i]);
+		    }	break;
+		    case KEYBOARD: {
+			XF86ConfInputPtr keyboard =
+			    KeyboardConfig(computer.devices[i]->config);
+
+			if (keyboard != NULL && computer.devices[i]->config == NULL) {
+			    XF86Config->conf_input_lst =
+				xf86addInput(XF86Config->conf_input_lst,
+					     keyboard);
+			    computer.devices[i]->config = (XtPointer)keyboard;
+			}
+			SetTip(computer.devices[i]);
+		    }	break;
+		    case CARD: {
+			XF86ConfDevicePtr card =
+			    CardConfig(computer.devices[i]->config);
+
+			if (card != NULL && computer.devices[i]->config == NULL) {
+			    XF86Config->conf_device_lst =
+				xf86addDevice(XF86Config->conf_device_lst,
+					      card);
+			    computer.devices[i]->config = (XtPointer)card;
+			}
+			SetTip(computer.devices[i]);
+			for (j = 0; j < computer.num_screens; j++)
+			    if (computer.screens[j]->card->widget == config)
+				SetTip((xf86cfgDevice*)computer.screens[j]);
+		    }	break;
+		    case MONITOR: {
+			XF86ConfMonitorPtr monitor =
+			    MonitorConfig(computer.devices[i]->config);
+
+			if (monitor != NULL && computer.devices[i]->config == NULL) {
+			    XF86Config->conf_monitor_lst =
+				xf86addMonitor(XF86Config->conf_monitor_lst,
+					       monitor);
+			    computer.devices[i]->config = (XtPointer)monitor;
+			}
+			SetTip(computer.devices[i]);
+			for (j = 0; j < computer.num_screens; j++)
+			    if (computer.screens[j]->monitor->widget == config)
+				SetTip((xf86cfgDevice*)computer.screens[j]);
+		    }	break;
+		}
+		/* Need to update because it may have been renamed */
+		UpdateMenuDeviceList(computer.devices[i]->type);
+		break;
+	    }
+	}
+    }
+    else if (config_mode == CONFIG_SCREEN) {
+	for (i = 0; i < computer.num_screens; i++)
+	    if (computer.screens[i]->widget == config) {
+		if (ScreenConfig(computer.screens[i]->screen) != NULL)
+		    SetTip((xf86cfgDevice*)computer.screens[i]);
+	    }
+    }
+}
+
+void
+OptionsCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i;
+    XF86OptionPtr *options = NULL;
+#ifdef USE_MODULES
+    xf86cfgModuleOptions *drv_opts = NULL;
+#endif
+
+    if (config_mode == CONFIG_SCREEN) {
+	for (i = 0; i < computer.num_screens; i++)
+	    if (computer.screens[i]->widget == config) {
+		options = &(computer.screens[i]->screen->scrn_option_lst);
+		break;
+	    }
+    }
+    else {
+	for (i = 0; i < computer.num_devices; i++)
+	    if (computer.devices[i]->widget == config)
+		break;
+
+	if (i >= computer.num_devices) {
+	    if (XF86Config->conf_flags == NULL)
+		XF86Config->conf_flags = (XF86ConfFlagsPtr)
+		    XtCalloc(1, sizeof(XF86ConfFlagsRec));
+	    options = &(XF86Config->conf_flags->flg_option_lst);
+	}
+	else {
+	    switch (computer.devices[i]->type) {
+		case MOUSE:
+		case KEYBOARD:
+		    options = (XF86OptionPtr*)&(((XF86ConfInputPtr)
+			(computer.devices[i]->config))->inp_option_lst);
+#ifdef USE_MODULES
+		    if (!nomodules) {
+			char *drv = ((XF86ConfInputPtr)
+				(computer.devices[i]->config))->inp_driver;
+
+			if (drv) {
+			    drv_opts = module_options;
+			    while (drv_opts) {
+				if (drv_opts->type == InputModule &&
+				    strcmp(drv_opts->name, drv) == 0)
+				    break;
+				drv_opts = drv_opts->next;
+			    }
+			}
+		    }
+#endif
+
+		    break;
+		case CARD:
+		    options = (XF86OptionPtr*)&(((XF86ConfDevicePtr)
+			(computer.devices[i]->config))->dev_option_lst);
+#ifdef USE_MODULES
+		    if (!nomodules) {
+			char *drv = ((XF86ConfDevicePtr)
+				(computer.devices[i]->config))->dev_driver;
+
+			if (drv) {
+			    drv_opts = module_options;
+			    while (drv_opts) {
+				if (drv_opts->type == VideoModule &&
+				    strcmp(drv_opts->name, drv) == 0)
+				    break;
+				drv_opts = drv_opts->next;
+			    }
+			}
+		    }
+#endif
+		    break;
+		case MONITOR:
+		    options = (XF86OptionPtr*)&(((XF86ConfMonitorPtr)
+			(computer.devices[i]->config))->mon_option_lst);
+		    break;
+	    }
+	}
+    }
+
+#ifdef USE_MODULES
+    OptionsPopup(options, drv_opts ? drv_opts->name : NULL,
+		 drv_opts ? drv_opts->option : NULL);
+#else
+    OptionsPopup(options);
+#endif
+    if (config_mode == CONFIG_SCREEN) {
+	XF86OptionPtr option, options;
+	int rotate = 0;
+
+	options = computer.screens[i]->screen->scrn_option_lst;
+	if ((option = xf86findOption(options, "Rotate")) != NULL) {
+	    if (option->opt_val != NULL)
+		rotate = strcasecmp(option->opt_val, "CW") == 0 ? 1 :
+			 strcasecmp(option->opt_val, "CCW") == 0 ? -1 : 0;
+	    XtFree(option->opt_val);
+	    option->opt_val = XtNewString(rotate > 0 ? "CW" : "CCW");
+	    computer.screens[i]->rotate = rotate;
+	}
+	else
+	    computer.screens[i]->rotate = 0;
+	UpdateScreenUI();
+	AdjustScreenUI();
+	SetTip((xf86cfgDevice*)computer.screens[i]);
+    }
+    else {
+	if (i >= computer.num_devices)
+	    SetTip(&cpu_device);
+	else
+	    SetTip(computer.devices[i]);
+    }
+}
+
+void
+EnableDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i;
+
+    if (config_mode == CONFIG_SCREEN) {
+	for (i = 0; i < computer.num_screens; i++)
+	    if (computer.screens[i]->widget == config) {
+		computer.screens[i]->state = USED;
+		computer.screens[i]->card->state = USED;
+		ScreenSetup(False);
+		return;
+	    }
+    }
+
+    for (i = 0; i < computer.num_devices; i++)
+	if (computer.devices[i]->widget == config) {
+	    if (computer.devices[i]->state == USED)
+		return;
+	    computer.devices[i]->state = USED;
+	    DrawCables();
+	    break;
+	}
+    if (i >= computer.num_devices || computer.layout == NULL)
+	return;
+    switch (computer.devices[i]->type) {
+	case MOUSE:
+	case KEYBOARD: {
+	    int nmouses = 0, nkeyboards = 0;
+	    XF86ConfInputPtr input = (XF86ConfInputPtr)
+		(computer.devices[i]->config);
+	    XF86ConfInputrefPtr nex, iref = computer.layout->lay_input_lst;
+	    XF86OptionPtr option;
+
+	    nex = iref;
+	    while (nex != NULL) {
+		if (strcasecmp(nex->iref_inputdev->inp_driver, "mouse") == 0)
+		    ++nmouses;
+		else if (IS_KBDDRIV(nex->iref_inputdev->inp_driver))
+		    ++nkeyboards;
+		iref = nex;
+		nex = (XF86ConfInputrefPtr)(nex->list.next);
+	    }
+	    nex = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec));
+	    nex->list.next = NULL;
+	    nex->iref_inputdev = input;
+	    nex->iref_inputdev_str = XtNewString(input->inp_identifier);
+	    if (nmouses == 0 && computer.devices[i]->type == MOUSE) 
+		option = xf86newOption(XtNewString("CorePointer"), NULL);
+	    else if (nkeyboards == 0 && computer.devices[i]->type == KEYBOARD)
+		option = xf86newOption(XtNewString("CoreKeyboard"), NULL);
+	    else
+		option = xf86newOption(XtNewString("SendCoreEvents"), NULL);
+	    nex->iref_option_lst = option;
+	    computer.layout->lay_input_lst =
+		xf86addInputref(computer.layout->lay_input_lst, nex);
+	}   break;
+	case CARD:
+	    for (i = 0; i < computer.num_screens; i++) {
+		if (computer.screens[i]->card->widget == config &&
+		    computer.screens[i]->state != USED) {
+		    XF86ConfAdjacencyPtr adj;
+
+		    adj = (XF86ConfAdjacencyPtr)
+			XtCalloc(1, sizeof(XF86ConfAdjacencyRec));
+		    adj->adj_screen = computer.screens[i]->screen;
+		    adj->adj_screen_str = XtNewString(computer.screens[i]->
+			screen->scrn_identifier);
+		    computer.layout->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
+			xf86addListItem((GenericListPtr)computer.layout->
+				    lay_adjacency_lst, (GenericListPtr)adj);
+		    computer.screens[i]->state = USED;
+		}
+	    }
+	    break;
+	case MONITOR:
+	    break;
+    }
+}
+
+void
+DisableDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i;
+
+    if (config_mode == CONFIG_SCREEN) {
+	for (i = 0; i < computer.num_screens; i++)
+	    if (computer.screens[i]->widget == config) {
+		computer.screens[i]->state = UNUSED;
+		computer.screens[i]->card->state = UNUSED;
+		ScreenSetup(False);
+		return;
+	    }
+    }
+
+    for (i = 0; i < computer.num_devices; i++)
+	if (computer.devices[i]->widget == config) {
+	    if (computer.devices[i]->state == UNUSED)
+		return;
+	    computer.devices[i]->state = UNUSED;
+	    DrawCables();
+	    break;
+	}
+    if (i >= computer.num_devices || computer.layout == NULL)
+	return;
+    switch (computer.devices[i]->type) {
+	case MOUSE:
+	case KEYBOARD:
+	    xf86removeInputRef(computer.layout,
+		(XF86ConfInputPtr)(computer.devices[i]->config));
+	    break;
+	case CARD: {
+	    XF86ConfAdjacencyPtr adj;
+	    int j;
+
+	    if (computer.layout == NULL)
+		break;
+	    for (j = 0; j < computer.num_screens; j++)
+		if (computer.screens[j]->card->widget == config) {
+		    adj = computer.layout->lay_adjacency_lst;
+		    while (adj != NULL) {
+			if (adj->adj_screen == computer.screens[j]->screen) {
+			    xf86removeAdjacency(computer.layout, adj);
+			    break;
+			}
+			adj = (XF86ConfAdjacencyPtr)(adj->list.next);
+		    }
+		    computer.screens[j]->state = UNUSED;
+		    break;
+		}
+	}   break;
+	case MONITOR:
+	    break;
+    }
+}
+
+/* ARGSUSED */
+void
+RemoveDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i, j;
+
+    for (i = 0; i < computer.num_screens; i++)
+	if (computer.screens[i]->widget == config) {
+	    RemoveScreen(computer.screens[i]->monitor,
+			 computer.screens[i]->card);
+	    ScreenSetup(False);
+	    return;
+	}
+
+    for (i = 0; i < computer.num_devices; i++) {
+	if (computer.devices[i]->widget == config) {
+	    switch (computer.devices[i]->type) {
+		case MOUSE:
+		case KEYBOARD:
+		    xf86removeInput(XF86Config,
+			(XF86ConfInputPtr)(computer.devices[i]->config));
+		    break;
+		case CARD:
+		case MONITOR:
+		    break;
+	    }
+
+	    if (computer.devices[i]->type == CARD) {
+		for (j = 0; j < computer.num_screens; j++)
+		    if (computer.screens[j]->card == computer.devices[i]) {
+			RemoveScreen(computer.screens[j]->monitor,
+				     computer.devices[i]);
+			--j;
+		    }
+		if (computer.devices[i]->refcount <= 0)
+		    xf86removeDevice(XF86Config,
+			(XF86ConfDevicePtr)(computer.devices[i]->config));
+	    }
+	    else if (computer.devices[i]->type == MONITOR) {
+		for (j = 0; j < computer.num_screens; j++)
+		    if (computer.screens[j]->monitor == computer.devices[i]) {
+			RemoveScreen(computer.devices[i],
+				     computer.screens[j]->card);
+			--j;
+		    }
+		if (computer.devices[i]->refcount <= 0)
+		    xf86removeMonitor(XF86Config,
+			(XF86ConfMonitorPtr)(computer.devices[i]->config));
+	    }
+
+	    if (computer.devices[i]->refcount <= 0) {
+		int type = computer.devices[i]->type;
+
+		XtDestroyWidget(computer.devices[i]->widget);
+		XtFree((XtPointer)computer.devices[i]);
+		if (--computer.num_devices > i)
+		    memmove(&computer.devices[i], &computer.devices[i + 1],
+			    (computer.num_devices - i) * sizeof(xf86cfgDevice*));
+
+		DrawCables();
+		UpdateMenuDeviceList(type);
+	    }
+
+	    break;
+	}
+    }
+}
+
+void
+UpdateMenuDeviceList(int type)
+{
+    Widget sme = NULL, menu = NULL;
+    int i, count;
+    static char *mouseM = "mouseM", *keyboardM = "keyboardM",
+		*cardM = "cardM", *monitorM = "monitorM";
+
+    for (i = count = 0; i < computer.num_devices; i++)
+	if (computer.devices[i]->type == type)
+	    ++count;
+
+    switch (type) {
+	case MOUSE:
+	    sme = mouseSme;
+	    menu = mouseMenu;
+	    break;
+	case KEYBOARD:
+	    sme = keyboardSme;
+	    menu = keyboardMenu;
+	    break;
+	case CARD:
+	    sme = cardSme;
+	    menu = cardMenu;
+	    break;
+	case MONITOR:
+	    sme = monitorSme;
+	    menu = monitorMenu;
+	    break;
+    }
+
+    if (menu)
+	for (i = ((CompositeWidget)menu)->composite.num_children - 1; i >= 0; i--)
+	    XtDestroyWidget(((CompositeWidget)menu)->composite.children[i]);
+
+    if (count < 2) {
+	XtVaSetValues(sme, XtNmenuName, NULL, XtNleftBitmap, None, NULL);
+	return;
+    }
+
+    switch (type) {
+	case MOUSE:
+	    if (mouseMenu == NULL)
+		menu = mouseMenu =
+		    XtCreatePopupShell(mouseM, simpleMenuWidgetClass,
+				       XtParent(mouseSme), NULL, 0);
+	    XtVaSetValues(mouseSme, XtNmenuName, mouseM,
+			  XtNleftBitmap, menuPixmap, NULL);
+	    break;
+	case KEYBOARD:
+	    if (keyboardMenu == NULL)
+		menu = keyboardMenu =
+		    XtCreatePopupShell(keyboardM, simpleMenuWidgetClass,
+				       XtParent(keyboardSme), NULL, 0);
+	    XtVaSetValues(keyboardSme, XtNmenuName, keyboardM,
+			  XtNleftBitmap, menuPixmap, NULL);
+	    break;
+	case CARD:
+	    if (cardMenu == NULL)
+		menu = cardMenu =
+		    XtCreatePopupShell(cardM, simpleMenuWidgetClass,
+				       XtParent(cardSme), NULL, 0);
+	    XtVaSetValues(cardSme, XtNmenuName, cardM,
+			  XtNleftBitmap, menuPixmap, NULL);
+	    break;
+	case MONITOR:
+	    if (monitorMenu == NULL)
+		menu = monitorMenu =
+		    XtCreatePopupShell(monitorM, simpleMenuWidgetClass,
+				       XtParent(monitorSme), NULL, 0);
+	    XtVaSetValues(monitorSme, XtNmenuName, monitorM,
+			  XtNleftBitmap, menuPixmap, NULL);
+	    break;
+    }
+
+    for (i = 0; i < computer.num_devices; i++)
+	if (computer.devices[i]->type == type) {
+	    char *label = NULL;
+
+	    if (computer.devices[i]->config) {
+		switch (type) {
+		    case MOUSE:
+		    case KEYBOARD:
+			label = ((XF86ConfInputPtr)computer.devices[i]->config)
+			    ->inp_identifier;
+			break;
+		    case CARD:
+			label = ((XF86ConfDevicePtr)computer.devices[i]->config)
+			    ->dev_identifier;
+			break;
+		    case MONITOR:
+			label = ((XF86ConfMonitorPtr)computer.devices[i]->config)
+			    ->mon_identifier;
+			break;
+		}
+	    }
+	    else {
+		switch (type) {
+		    case MOUSE:
+			label = "newMouse";
+			break;
+		    case KEYBOARD:
+			label = "newKeyboard";
+			break;
+		    case CARD:
+			label = "newCard";
+			break;
+		    case MONITOR:
+			label = "newMonitor";
+			break;
+		}
+	    }
+
+	    sme = XtCreateManagedWidget(label, smeBSBObjectClass, menu, NULL, 0);
+	    XtAddCallback(sme, XtNcallback, SmeConfigureDeviceCallback,
+			  computer.devices[i]->config ?
+			  computer.devices[i]->config :
+			  (XtPointer) (-((long)type + 100)));
+	}
+}
+
+/*ARGSUSED*/
+void
+SelectDeviceAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    device = w;
+    xpos = event->xbutton.x_root;
+    ypos = event->xbutton.y_root;
+    XDefineCursor(XtDisplay(device), XtWindow(device), no_cursor);
+
+    if (config_mode == CONFIG_SCREEN) {
+	sxpos = device->core.x;
+	sypos = device->core.y;
+    }
+}
+
+/*ARGSUSED*/
+void
+MoveDeviceAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    int dx, dy, x, y, oldx, oldy;
+
+    if (device == NULL || device != w)
+	return;
+
+    dx = event->xbutton.x_root - xpos;
+    dy = event->xbutton.y_root - ypos;
+
+    oldx = device->core.x;
+    oldy = device->core.y;
+    x = device->core.x + dx;
+    y = device->core.y + dy;
+
+    if (x < 0)
+	x = 0;
+    else if (x + device->core.width > XtParent(device)->core.width)
+	x = XtParent(device)->core.width - device->core.width;
+    if (y < 0)
+	y = 0;
+    else if (y + device->core.height > XtParent(device)->core.height)
+	y = XtParent(device)->core.height - device->core.height;
+
+    dx = x - oldx;
+    dy = y - oldy;
+
+    XRaiseWindow(XtDisplay(device), XtWindow(device));
+    XtMoveWidget(device, x, y);
+
+    xpos += dx;
+    ypos += dy;
+}
+
+/*ARGSUSED*/
+void
+UnselectDeviceAction(Widget w, XEvent *ev, String *params, Cardinal *num_params)
+{
+    if (device != NULL) {
+	XUndefineCursor(XtDisplay(device), XtWindow(device));
+
+	if (config_mode == CONFIG_SCREEN)
+	    ScreenSetup(False);
+	device = NULL;
+    }
+}
+
+/*ARGSUSED*/
+void
+DevicePopupMenu(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    static Widget configure, options, enable, disable, remove;
+    static int first = 1;
+    int i;
+    xf86cfgDevice *dev;
+
+    if (first) {
+	first = 0;
+
+	popup = XtCreatePopupShell("popup", simpleMenuWidgetClass,
+				   toplevel, NULL, 0);
+	configure = XtCreateManagedWidget("configure", smeBSBObjectClass,
+					  popup, NULL, 0);
+	XtAddCallback(configure, XtNcallback, ConfigureDeviceCallback, NULL);
+	options = XtCreateManagedWidget("options", smeBSBObjectClass,
+					popup, NULL, 0);
+	XtAddCallback(options, XtNcallback, OptionsCallback, NULL);
+	XtCreateManagedWidget("line", smeLineObjectClass,
+			      popup, NULL, 0);
+	enable = XtCreateManagedWidget("enable", smeBSBObjectClass,
+				       popup, NULL, 0);
+	XtAddCallback(enable, XtNcallback, EnableDeviceCallback, NULL);
+	disable = XtCreateManagedWidget("disable", smeBSBObjectClass,
+					popup, NULL, 0);
+	XtAddCallback(disable, XtNcallback, DisableDeviceCallback, NULL);
+	XtCreateManagedWidget("line", smeLineObjectClass,
+			      popup, NULL, 0);
+	remove = XtCreateManagedWidget("remove", smeBSBObjectClass,
+				       popup, NULL, 0);
+	XtAddCallback(remove, XtNcallback, RemoveDeviceCallback, NULL);
+
+	XtRealizeWidget(popup);
+    }
+
+    dev = NULL;
+    if (config_mode == CONFIG_LAYOUT) {
+	for (i = 0; i < computer.num_devices; i++)
+	    if (computer.devices[i]->widget == w) {
+		dev = computer.devices[i];
+		break;
+	    }
+	if (i >= computer.num_devices && strcmp(XtName(w), "cpu"))
+	    return;
+	if (dev == NULL)
+	    dev = &cpu_device;
+    }
+    else if (config_mode == CONFIG_SCREEN) {
+	for (i = 0; i < computer.num_screens; i++)
+	    if (computer.screens[i]->widget == w) {
+		dev = (xf86cfgDevice*)computer.screens[i];
+		break;
+	    }
+    }
+    if (dev == NULL)
+	return;
+
+    config = w;
+
+    if (dev->type != SERVER) {
+	XtSetSensitive(configure, True);
+	XtSetSensitive(remove, True);
+	XtSetSensitive(options, dev->config != NULL);
+	if (computer.layout == NULL || dev->config == NULL ||
+	    dev->type == MONITOR) {
+	    XtSetSensitive(enable, False);
+	    XtSetSensitive(disable, False);
+	}
+	else if (dev->state == USED) {
+	    XtSetSensitive(enable, False);
+	    XtSetSensitive(disable, True);
+	}
+	else {
+	    XtSetSensitive(enable, True);
+	    XtSetSensitive(disable, False);
+	}
+    }
+    else {
+	XtSetSensitive(configure, False);
+	XtSetSensitive(options, True);
+	XtSetSensitive(enable, False);
+	XtSetSensitive(disable, False);
+	XtSetSensitive(remove, False);
+    }
+
+    XtMoveWidget(popup, event->xbutton.x_root, event->xbutton.y_root);
+    XtPopup(popup, XtGrabNone);
+}
+
+/*ARGSUSED*/
+void
+DevicePopdownMenu(Widget w, XEvent *event, String *params, Cardinal *num_params)
+{
+    if (popup && XtIsRealized(popup))
+	XtPopdown(popup);
+}
+
+void RenameLayoutAction(Widget w, XEvent *event,
+			String *params, Cardinal *num_params)
+{
+    XF86ConfLayoutPtr lay = XF86Config->conf_layout_lst;
+    Arg args[1];
+    char *name;
+
+    XtSetArg(args[0], XtNstring, &name);
+    XtGetValues(layout, args, 1);
+
+    if (computer.layout == NULL || (computer.layout &&
+	strcasecmp(name, computer.layout->lay_identifier)) == 0)
+	return;
+
+    if (name == NULL && *name == '\0') {
+	/* tell user about error */
+	return;
+    }
+
+    while (lay) {
+	if (strcasecmp(name, lay->lay_identifier) == 0)
+	    /* tell user about error */
+	    return;
+	lay = (XF86ConfLayoutPtr)(lay->list.next);
+    }
+
+    XtSetArg(args[0], XtNlabel, name);
+    XtSetValues(layoutsme, args, 1);
+    xf86renameLayout(XF86Config, computer.layout, name);
+}
+
+/*ARGSUSED*/
+static void
+ComputerEventHandler(Widget w, XtPointer closure,
+		     XEvent *event, Boolean *continue_to_dispatch)
+{
+    if (event->xexpose.count > 1)
+	return;
+
+    if (config_mode == CONFIG_LAYOUT)
+	DrawCables();
+}
+
+void
+DrawCables(void)
+{
+    Display *display;
+    Window window;
+    int ox, oy, i;
+    xf86cfgScreen **scr = computer.screens;
+
+    if (config_mode != CONFIG_LAYOUT)
+	return;
+
+    ox = computer.cpu->core.x + (computer.cpu->core.width >> 1);
+    oy = computer.cpu->core.y + (computer.cpu->core.height >> 1);
+
+    display = XtDisplay(work);
+    window = XtWindow(work);
+    XClearWindow(display, window);
+
+    for (i = 0; i < computer.num_devices; i++) {
+	if (computer.devices[i]->state == USED &&
+	    computer.devices[i]->type != MONITOR)
+	    DrawCable(display, window, ox, oy,
+		      computer.devices[i]->widget->core.x +
+			    (computer.devices[i]->widget->core.width>>1),
+		      computer.devices[i]->widget->core.y +
+			    (computer.devices[i]->widget->core.height>>1));
+
+    }
+    for (i = 0; i < computer.num_screens; i++) {
+	if (scr[i]->monitor != NULL)
+	    DrawCable(display, window,
+		      scr[i]->card->widget->core.x +
+			    (scr[i]->card->widget->core.width>>1),
+		      scr[i]->card->widget->core.y +
+			    (scr[i]->card->widget->core.height>>1),
+		      scr[i]->monitor->widget->core.x +
+			    (scr[i]->monitor->widget->core.width>>1),
+		      scr[i]->monitor->widget->core.y +
+			    (scr[i]->monitor->widget->core.height>>1));
+    }
+}
+
+static void
+DrawCable(Display *display, Window window, int o_x, int o_y, int d_x, int d_y)
+{
+    XDrawLine(display, window, cablegcshadow, o_x, o_y, d_x, d_y);
+    XDrawLine(display, window, cablegc, o_x, o_y, d_x, d_y);
+}
+
+/*ARGSUSED*/
+void
+SetConfigModeCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i, mode = (long)user_data;
+    Arg args[3];
+    char *ptr;
+    static Dimension height;
+
+    if (mode == config_mode)
+	return;
+    XtSetArg(args[0], XtNlabel, &ptr);
+    XtGetValues(w, args, 1);
+    XtSetArg(args[0], XtNlabel, ptr);
+    XtSetValues(topMenu, args, 1);
+
+    if (config_mode == CONFIG_LAYOUT) {
+	XtSetArg(args[0], XtNheight, &height);
+	XtGetValues(commands, args, 1);
+	for (i = 0; i < computer.num_devices; i++)
+	    XtUnmapWidget(computer.devices[i]->widget);
+	XtUnmapWidget(commands);
+	XtUnmapWidget(computer.cpu);
+	XtSetSensitive(commands, False);
+	XtSetArg(args[0], XtNheight, 1);
+	XtSetArg(args[1], XtNmin, 1);
+	XtSetArg(args[2], XtNmax, 1);
+	XtSetValues(commands, args, 3);
+    }
+    else if (config_mode == CONFIG_SCREEN) {
+	for (i = 0; i < computer.num_screens; i++)
+	    XtUnmapWidget(computer.screens[i]->widget);
+    }
+    else if (config_mode == CONFIG_MODELINE) {
+	VideoModeConfigureEnd();
+	XtSetSensitive(layout, True);
+	XtSetSensitive(layoutm, True);
+    }
+    else if (config_mode == CONFIG_ACCESSX) {
+	AccessXConfigureEnd();
+	XtSetSensitive(layout, True);
+	XtSetSensitive(layoutm, True);
+    }
+
+    config_mode = mode;
+    XClearWindow(XtDisplay(work), XtWindow(work));
+    if (mode == CONFIG_LAYOUT) {
+	for (i = 0; i < computer.num_devices; i++)
+	    XtMapWidget(computer.devices[i]->widget);
+	XtSetArg(args[0], XtNheight, height);
+	XtSetArg(args[1], XtNmin, height);
+	XtSetArg(args[2], XtNmax, height);
+	XtSetValues(commands, args, 3);
+	XtMapWidget(commands);
+	XtMapWidget(computer.cpu);
+	XtSetSensitive(commands, True);
+	DrawCables();
+    }
+    else if (mode == CONFIG_SCREEN) {
+	for (i = 0; i < computer.num_screens; i++)
+	    XtMapWidget(computer.screens[i]->widget);
+	ScreenSetup(True);
+    }
+    else if (mode == CONFIG_MODELINE) {
+	VideoModeConfigureStart();
+	XtSetSensitive(layout, False);
+	XtSetSensitive(layoutm, False);
+    }
+    else if (mode == CONFIG_ACCESSX) {
+	AccessXConfigureStart();
+	XtSetSensitive(layout, False);
+	XtSetSensitive(layoutm, False);
+    }
+}
+
+static void
+ScreenSetup(Bool check)
+{
+    if (check) {
+	int i;
+
+	for (i = 0; i < computer.num_layouts; i++)
+	    if (computer.layouts[i]->layout == computer.layout)
+		break;
+
+	/* Just to put the screens in the correct positions */
+	if (i >= computer.num_layouts)
+	    AdjustScreenUI();
+    }
+
+    UpdateScreenUI();
+    AdjustScreenUI();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo C�sar Pereira de Andrade <[email protected]>
+ *
+ * $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c,v 1.2 2004/04/23 19:54:18 eich Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c,v 1.19 2002/06/06 21:03:32 paulo Exp $
+ */
+
+#include "config.h"
+#include "cards.h"
+#include "options.h"
+#include "loader.h"
+#include "stubs.h"
+#include <X11/Xresource.h>
+#include <X11/Xos.h>
+
+#ifdef USE_MODULES
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#if defined(X_POSIX_C_SOURCE)
+#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+#include <setjmp.h>
+#undef _POSIX_C_SOURCE
+#else
+#include <setjmp.h>
+#endif
+#include <signal.h>
+#include <ctype.h>
+
+#include <stdarg.h>
+
+#ifndef SIGNALRETURNSINT
+void sig_handler(int);
+#else
+int sig_handler(int);
+#endif	/* SIGNALRETURNSINT */
+
+static Bool EnumDatabase(XrmDatabase*, XrmBindingList, XrmQuarkList,
+			 XrmRepresentation*, XrmValue*, XPointer);
+
+static sigjmp_buf jmp;
+int signal_caught;
+int error_level;
+char *loaderPath, **loaderList, **ploaderList;
+extern XrmDatabase options_xrm;
+extern int noverify;
+extern ModuleType module_type;
+static OptionInfoPtr option;
+
+extern FontModule *font_module;
+extern int numFontModules;
+
+char **checkerLegend;
+int *checkerErrors;
+
+#ifndef SIGNALRETURNSINT
+void
+#else
+int
+#endif
+sig_handler(int sig)
+{
+    char *str;
+
+    switch (sig) {
+	case SIGTRAP:
+	    str = "TRAP";
+	    break;
+	case SIGBUS:
+	    str = "BUS";
+	    break;
+	case SIGSEGV:
+	    str = "SEGV";
+	    break;
+	case SIGILL:
+	    str = "ILL";
+	    break;
+	case SIGFPE:
+	    str = "FPE";
+	    break;
+	default:
+	    str = "???";
+	    break;
+    }
+
+    if (signal_caught == 1) {
+	ErrorF("  ERROR I am dead.\n");
+	exit(1);
+    }
+    else if (signal_caught == 2)
+	abort();
+    ++signal_caught;
+    ErrorF("  ERROR SIG%s caught!\n", str);
+    if (!noverify)
+	error_level += 50;
+    siglongjmp(jmp, 1);
+    /*NOTREACHED*/
+}
+
+void
+CheckMsg(int code, char *fmt, ...)
+{
+    va_list ap;
+
+    ++checkerErrors[code];
+    ErrorF("%3d ", code);
+
+    va_start(ap, fmt);
+    VErrorF(fmt, ap);
+    va_end(ap);
+}
+
+static Bool
+EnumDatabase(XrmDatabase *db, XrmBindingList bindings, XrmQuarkList quarks,
+	     XrmRepresentation *type, XrmValue *value, XPointer closure)
+{
+    char *res = XrmQuarkToString(quarks[1]);
+
+    if (res) {
+	option = module_options->option;
+	while (option->name) {
+	    if (strcasecmp(option->name, res) == 0)
+		return (False);
+	    ++option;
+	}
+	CheckMsg(CHECKER_OPTION_UNUSED,
+		 "WARNING %s.%s is not used\n",
+		 XrmQuarkToString(quarks[0]), res);
+	++error_level;
+    }
+
+    return (False);
+}
+
+Bool
+LoaderInitializeOptions(void)
+{
+    static int first = 1;
+    static char *modules = "lib/modules";
+    volatile Bool options_ok = False;
+    char *ptr, query[256];
+    char *ptr2, query2[256];
+    char *type;
+    XrmValue value;
+    XrmQuark names[2];
+    XrmQuark classes[2];
+    volatile int i;
+    static ModuleType module_types[] = {
+	GenericModule, FontRendererModule, InputModule, VideoModule, NullModule
+    };
+
+    /* The offset in this vector must match loader.h:enum ModuleType values */
+    static char *module_strs[] = {
+	"Null Module", "Video Module", "Input Module", "Generic Module", "Font Module"
+    };
+
+    if (first) {
+	checkerLegend = (char**)
+	    XtCalloc(1, sizeof(char*) * (CHECKER_LAST_MESSAGE + 1));
+	checkerErrors = (int*)
+	    XtCalloc(1, sizeof(int) * (CHECKER_LAST_MESSAGE + 1));
+	xf86cfgLoaderInit();
+	first = 0;
+
+	checkerLegend[CHECKER_OPTIONS_FILE_MISSING] =
+	"The Options file, normally /usr/X11R6/lib/X11/Options was not found.\n";
+	checkerLegend[CHECKER_OPTION_DESCRIPTION_MISSING] =
+	"No description for the module option. The description should be in\n"
+	"in the Options file, and using the sintax:\n"
+	"Module.Option:	any text describing the option";
+	checkerLegend[CHECKER_LOAD_FAILED] =
+	"Failed to load the module. Usually the loader will print a complete\n"
+	"description for the reason the module was not loaded. Use the -verbose\n"
+	"command line option if it is not printing any messages.";
+	checkerLegend[CHECKER_RECOGNIZED_AS] =
+	"This message means the module code did not follow what was expected\n"
+	"by the checker. For video drivers, it did not call xf86AddDriver,\n"
+	"a input module did not call xf86AddInputDriver and a font renderer\n"
+	"module did not call LoadFont. This message can also be printed if\n"
+	"the module is in the incorrect directory.";
+	checkerLegend[CHECKER_NO_OPTIONS_AVAILABLE] =
+	"The driver does not have an AvailableOptions function, or that\n"
+	"function is returning NULL. If the driver is returning NULL, and\n"
+	"really does not need any options from "__XCONFIGFILE__", than the message\n"
+	"can be ignored.";
+	checkerLegend[CHECKER_NO_VENDOR_CHIPSET] =
+	"The checker could not fetch the PCI chipset/vendor information from\n"
+	"the module. The checker currently wraps xf86PrintChipsets and\n"
+	"xf86MatchPciInstances to read the information from the module.";
+	checkerLegend[CHECKER_CANNOT_VERIFY_CHIPSET] =
+	"The vendor id was not found, so it is not possible to search the list\n"
+	"of chipsets.";
+	checkerLegend[CHECKER_OPTION_UNUSED] =
+	"The option description is defined in the Options file, but the option\n"
+	"was name not retrieved when calling the module AvailableOptions.";
+	checkerLegend[CHECKER_NOMATCH_CHIPSET_STRINGS] =
+	"The string specified in the module does not match the one in\n"
+	"common/xf86PciInfo.h";
+	checkerLegend[CHECKER_CHIPSET_NOT_LISTED] =
+	"This means that common/xf86PciInfo.h does not have an entry for the\n"
+	"given vendor and id.";
+	checkerLegend[CHECKER_CHIPSET_NOT_SUPPORTED] =
+	"The chipset is listed in common/xf86PciInfo.h, but the driver does\n"
+	"not support it, or does not list it in the chipsets fetched by the checker.";
+	checkerLegend[CHECKER_CHIPSET_NO_VENDOR] =
+	"The vendor id specified to xf86MatchPciInstances is not defined in\n"
+	"common/xf86PciInfo.h";
+	checkerLegend[CHECKER_NO_CHIPSETS] =
+	"No chipsets were passed to xf86MatchPciIntances.";
+	checkerLegend[CHECKER_FILE_MODULE_NAME_MISMATCH] =
+	"The module name string does not match the the modname field of the\n"
+	"XF86ModuleVersionInfo structure. This generally is not an error, but\n"
+	"to may be a good idea to use the same string to avoid confusion.";
+    }
+
+    if (XF86Module_path == NULL) {
+	XF86Module_path = malloc(strlen(XFree86Dir) + strlen(modules) + 2);
+	sprintf(XF86Module_path, "%s/%s", XFree86Dir, modules);
+    }
+
+    if (loaderPath == NULL || strcmp(XF86Module_path, loaderPath))
+	loaderPath = strdup(XF86Module_path);
+    else
+	/* nothing new */
+	return (True);
+
+    if (!noverify) {
+	options_ok = InitializeOptionsDatabase();
+	InitializePciInfo();
+    }
+
+
+    for (i = 0; module_types[i] != NullModule; i++) {
+	xf86cfgLoaderInitList(module_types[i]);
+	if (!noverify)
+	    ErrorF("================= Checking modules of type \"%s\" =================\n",
+		   module_strs[module_types[i]]);
+
+	if (loaderList) {
+	    for (ploaderList = loaderList; *ploaderList; ploaderList++) {
+		signal_caught = 0;
+		signal(SIGTRAP, sig_handler);
+		signal(SIGBUS, sig_handler);
+		signal(SIGSEGV, sig_handler);
+		signal(SIGILL, sig_handler);
+		signal(SIGFPE, sig_handler);
+		if (sigsetjmp(jmp, 1) == 0) {
+		    if (!noverify) {
+			int ok, nfont_modules;
+
+			nfont_modules = numFontModules;
+			error_level = 0;
+			ErrorF("CHECK MODULE %s\n", *ploaderList);
+			if ((ok = xf86cfgCheckModule(module_types[i])) == 0) {
+			    CheckMsg(CHECKER_LOAD_FAILED,
+				     "ERROR Failed to load module.\n");
+			    error_level += 50;
+			}
+			else if (module_type != module_types[i]) {
+			    CheckMsg(CHECKER_RECOGNIZED_AS,
+				     "WARNING %s recognized as a \"%s\"\n", *ploaderList,
+				     module_strs[module_type]);
+			    ++error_level;
+			}
+			if (ok) {
+			    if (options_ok) {
+				if ((module_options == NULL || module_options->option == NULL) &&
+				    module_type != GenericModule) {
+				    CheckMsg(CHECKER_NO_OPTIONS_AVAILABLE,
+					     "WARNING Not a generic module, but no options available.\n");
+				    ++error_level;
+				}
+				else if (module_options && strcmp(module_options->name, *ploaderList) == 0) {
+				    ErrorF("  CHECK OPTIONS\n");
+				    option = module_options->option;
+
+				    while (option->name) {
+					XmuSnprintf(query, sizeof(query), "%s.%s", *ploaderList, option->name);
+					for (ptr = query, ptr2 = query2; *ptr; ptr++) {
+					    if (*ptr != '_' && *ptr != ' ' && *ptr != '\t')
+						*ptr2 = tolower(*ptr);
+					}
+					*ptr2 = '\0';
+					/* all resources are in lowercase */
+					if (!XrmGetResource(options_xrm, query2, "Module.Option", &type, &value) ||
+					    value.addr == NULL) {
+					    CheckMsg(CHECKER_OPTION_DESCRIPTION_MISSING,
+						     "WARNING no description for %s\n", query);
+					    ++error_level;
+					}
+					++option;
+				    }
+
+				    /* now do a linear search for Options file entries that are not
+				     * in the driver.
+				     */
+				    names[0] = XrmPermStringToQuark(module_options->name);
+				    classes[0] = XrmPermStringToQuark("Option");
+				    names[1] = classes[1] = NULLQUARK;
+				    (void)XrmEnumerateDatabase(options_xrm, (XrmNameList)&names, (XrmClassList)&classes,
+							       XrmEnumOneLevel, EnumDatabase, NULL);
+				}
+			    }
+			    else {
+				CheckMsg(CHECKER_OPTIONS_FILE_MISSING,
+					 "ERROR Options file missing.\n");
+				error_level += 10;
+			    }
+
+			    if (module_type == VideoModule &&
+				(module_options == NULL || module_options->vendor < 0 ||
+				 module_options->chipsets == NULL)) {
+				CheckMsg(CHECKER_NO_VENDOR_CHIPSET,
+				         "WARNING No vendor/chipset information available.\n");
+				++error_level;
+			    }
+			    else if (module_type == VideoModule) {
+				if (module_options == NULL) {
+				    /* No description for this, if this happen,
+				     * something really strange happened. */
+				    ErrorF("  ERROR No module_options!?!\n");
+				    error_level += 50;
+				}
+				else {
+				    ErrorF("  CHECK CHIPSETS\n");
+				    CheckChipsets(module_options, &error_level);
+				}
+			    }
+
+			    /* font modules check */
+			    if (module_type == FontRendererModule) {
+				if (strcmp(*ploaderList, font_module->name)) {
+				    /* not an error */
+				    ErrorF("  NOTICE FontModule->name specification mismatch: \"%s\" \"%s\"\n",
+					   *ploaderList, font_module->name);
+				}
+				if (nfont_modules + 1 != numFontModules) {
+				    /* not an error */
+				    ErrorF("  NOTICE font module \"%s\" loaded more than one font renderer.\n",
+					   *ploaderList);
+				}
+			    }
+			    else if (nfont_modules != numFontModules) {
+				ErrorF("  WARNING number of font modules changed from %d to %d.\n",
+				       nfont_modules, numFontModules);
+				++error_level;
+			    }
+			}
+			ErrorF("  SUMMARY error_level set to %d.\n\n", error_level);
+		    }
+		    else
+			(void)xf86cfgCheckModule(module_types[i]);
+		}
+		signal(SIGTRAP, SIG_DFL);
+		signal(SIGBUS, SIG_DFL);
+		signal(SIGSEGV, SIG_DFL);
+		signal(SIGILL, SIG_DFL);
+		signal(SIGFPE, SIG_DFL);
+	    }
+	    xf86cfgLoaderFreeList();
+	}
+	else
+	    ErrorF("  ERROR Failed to initialize module list.\n");
+    }
+
+    if (!noverify) {
+	ErrorF("===================================== LEGEND ===============================\n");
+	ErrorF("NOTICE lines are just informative.\n");
+	ErrorF("WARNING lines add 1 to error_level.\n");
+	ErrorF("ERROR lines add 2 or more (based on the severity of the error) to error_level.\n\n");
+	for (i = 0; i <= CHECKER_LAST_MESSAGE; i++)
+	    if (checkerErrors[i]) {
+		ErrorF("%3d\n%s\n\n", i, checkerLegend[i]);
+	    }
+    }
+
+    return (True);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo César Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h,v 1.6 2001/07/07 01:43:58 paulo Exp $
+ */
+
+#ifdef USE_MODULES
+#ifndef LOADER_PRIVATE
+#include "config.h"
+#include "stubs.h"
+
+#else
+
+#ifndef XFree86LOADER
+#define XFree86LOADER		/* not really */
+#endif
+#define IN_LOADER
+
+#include "xf86.h"
+#include "xf86str.h"
+#include "xf86Opt.h"
+#include "xf86Module.h"
+
+#ifndef XINPUT
+#define XINPUT
+#endif
+#include "xf86Xinput.h"
+
+#include <X11/fonts/fontmod.h>
+#include "loaderProcs.h"
+
+#include <sym.h>
+#include <xf86_ansic.h>
+
+void LoaderDefaultFunc(void);
+#endif
+
+#ifndef _xf86cfg_loader_h
+#define _xf86cfg_loader_h
+
+void xf86cfgLoaderInit(void);
+void xf86cfgLoaderInitList(int);
+void xf86cfgLoaderFreeList(void);
+
+#ifndef LOADER_PRIVATE
+/* common/xf86Opt.h */
+typedef struct {
+    double freq;
+    int units;
+} OptFrequency;
+
+typedef union {
+    unsigned long       num;
+    char *              str;
+    double              realnum;
+    Bool		xbool;
+    OptFrequency	freq;
+} ValueUnion;
+
+typedef enum {
+    OPTV_NONE = 0,
+    OPTV_INTEGER,
+    OPTV_STRING,                /* a non-empty string */
+    OPTV_ANYSTR,                /* Any string, including an empty one */
+    OPTV_REAL,
+    OPTV_BOOLEAN,
+    OPTV_FREQ
+} OptionValueType;
+
+typedef enum {
+    OPTUNITS_HZ = 1,
+    OPTUNITS_KHZ,
+    OPTUNITS_MHZ
+} OptFreqUnits;
+
+typedef struct {
+    int                 token;
+    const char*         name;
+    OptionValueType     type;
+    ValueUnion          value;
+    Bool                found;
+} OptionInfoRec, *OptionInfoPtr;
+
+/* fontmod.h */
+typedef void (*InitFont)(void);
+
+typedef struct {
+    InitFont	initFunc;
+    char *	name;
+    void	*module;
+} FontModule;
+
+extern FontModule *FontModuleList;
+
+typedef struct {
+    int                 token;          /* id of the token */
+    const char *        name;           /* token name */
+} SymTabRec, *SymTabPtr;
+#endif	/* !LOADER_PRIVATE */
+
+typedef enum {
+    NullModule = 0,
+    VideoModule,
+    InputModule,
+    GenericModule,
+    FontRendererModule
+} ModuleType;
+
+int xf86cfgCheckModule(ModuleType);
+
+typedef struct _xf86cfgModuleOptions {
+    char *name;
+    ModuleType type;
+    OptionInfoPtr option;
+    int vendor;
+    SymTabPtr chipsets;
+    struct _xf86cfgModuleOptions *next;
+} xf86cfgModuleOptions;
+
+extern xf86cfgModuleOptions *module_options;
+
+/* When adding a new code to the LEGEND, also update checkerLegend
+ * in loader.c
+ */
+extern char **checkerLegend;
+extern int *checkerErrors;
+#define	CHECKER_OPTIONS_FILE_MISSING			1
+#define	CHECKER_OPTION_DESCRIPTION_MISSING		2
+#define CHECKER_LOAD_FAILED				3
+#define CHECKER_RECOGNIZED_AS				4
+#define CHECKER_NO_OPTIONS_AVAILABLE			5
+#define CHECKER_NO_VENDOR_CHIPSET			6
+#define CHECKER_CANNOT_VERIFY_CHIPSET			7
+#define	CHECKER_OPTION_UNUSED				8
+#define CHECKER_NOMATCH_CHIPSET_STRINGS			9
+#define CHECKER_CHIPSET_NOT_LISTED			10
+#define CHECKER_CHIPSET_NOT_SUPPORTED			11
+#define CHECKER_CHIPSET_NO_VENDOR			12
+#define CHECKER_NO_CHIPSETS				13
+#define CHECKER_FILE_MODULE_NAME_MISMATCH		14
+
+#define CHECKER_LAST_MESSAGE				14
+
+extern void CheckMsg(int, char*, ...);
+
+#ifndef LOADER_PRIVATE
+int LoaderInitializeOptions(void);
+#endif
+#endif /* USE_MODULES */
+
+#endif /* _xf86cfg_loader_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loadmod.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,765 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo C�sar Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/loadmod.c,v 1.16 2003/03/12 16:40:28 tsi Exp $
+ */
+
+#ifdef USE_MODULES
+#include <setjmp.h>
+
+#ifndef HAS_GLIBC_SIGSETJMP
+#if defined(setjmp) && defined(__GNU_LIBRARY__) && \
+    (!defined(__GLIBC__) || (__GLIBC__ < 2) || \
+     ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 3)))
+#define HAS_GLIBC_SIGSETJMP 1
+#endif
+#endif
+
+#define LOADER_PRIVATE
+#include "loader.h"
+#include "xf86PciInfo.h"
+
+#define	True		1
+#define False		0
+#define XtPointer	char*
+#define XtMalloc	malloc
+#define XtCalloc	calloc
+#define XtRealloc	realloc
+#define XtFree		free
+#define XtNew(t)	malloc(sizeof(t))
+#define XtNewString(s)	((s) ? strdup(s) : NULL)
+
+#define	pointer void*
+
+/* XXX beware (or fix it) libc functions called here are the xf86 ones */
+
+static void AddModuleOptions(char*, const OptionInfoRec*);
+#if 0
+void xf86AddDriver(DriverPtr, void*, int);
+Bool xf86ServerIsOnlyDetecting(void);
+void xf86AddInputDriver(InputDriverPtr, pointer, int);
+void xf86AddModuleInfo(ModuleInfoPtr, void*);
+Bool xf86LoaderCheckSymbol(const char*);
+void xf86LoaderRefSymLists(const char **, ...);
+void xf86LoaderReqSymLists(const char **, ...);
+void xf86Msg(int, const char*, ...);
+void xf86MsgVerb(int, int, const char*, ...);
+void xf86PrintChipsets(const char*, const char*, SymTabPtr);
+void xf86ErrorFVerb(int verb, const char *format, ...);
+pciVideoPtr *xf86GetPciVideoInfo(void);
+int xf86MatchDevice(const char*, GDevPtr**);
+int xf86MatchPciInstances(const char*, int, SymTabPtr, PciChipsets*, GDevPtr*, int, DriverPtr,int**);
+int xf86MatchIsaInstances(const char*, SymTabPtr, pointer*, DriverPtr, pointer, GDevPtr*, int, int**);
+void *xf86LoadDrvSubModule(DriverPtr drv, const char*);
+void xf86DrvMsg(int, int, const char*, ...);
+pciConfigPtr *xf86GetPciConfigInfo(void);
+Bool xf86IsPrimaryPci(pcVideoPtr*);
+Bool xf86CheckPciSlot(int bus, int device, int func);
+#endif
+
+extern char *loaderPath, **loaderList, **ploaderList;
+xf86cfgModuleOptions *module_options;
+FontModule *font_module;
+int numFontModules;
+
+extern int noverify, error_level;
+
+int xf86ShowUnresolved = 1;
+
+LOOKUP miLookupTab[]      = {{0,0}};
+LOOKUP dixLookupTab[]     = {{0,0}};
+LOOKUP fontLookupTab[]    = {{0,0}};
+LOOKUP extLookupTab[]     = {{0,0}};
+LOOKUP xfree86LookupTab[] = {
+       /* Loader functions */
+   SYMFUNC(LoaderDefaultFunc)
+   SYMFUNC(LoadSubModule)
+   SYMFUNC(DuplicateModule)
+   SYMFUNC(LoaderErrorMsg)
+   SYMFUNC(LoaderCheckUnresolved)
+   SYMFUNC(LoadExtension)
+   SYMFUNC(LoadFont)
+   SYMFUNC(LoaderReqSymbols)
+   SYMFUNC(LoaderReqSymLists)
+   SYMFUNC(LoaderRefSymbols)
+   SYMFUNC(LoaderRefSymLists)
+   SYMFUNC(UnloadSubModule)
+   SYMFUNC(LoaderSymbol)
+   SYMFUNC(LoaderListDirs)
+   SYMFUNC(LoaderFreeDirList)
+   SYMFUNC(LoaderGetOS)
+
+   /*
+    * these here are our own interfaces to libc functions
+    */
+   SYMFUNC(xf86abort)
+   SYMFUNC(xf86abs)
+   SYMFUNC(xf86acos)
+   SYMFUNC(xf86asin)
+   SYMFUNC(xf86atan)
+   SYMFUNC(xf86atan2)
+   SYMFUNC(xf86atof)
+   SYMFUNC(xf86atoi)
+   SYMFUNC(xf86atol)
+   SYMFUNC(xf86bsearch)
+   SYMFUNC(xf86ceil)
+   SYMFUNC(xf86calloc)
+   SYMFUNC(xf86clearerr)
+   SYMFUNC(xf86close)
+   SYMFUNC(xf86cos)
+   SYMFUNC(xf86exit)
+   SYMFUNC(xf86exp)
+   SYMFUNC(xf86fabs)
+   SYMFUNC(xf86fclose)
+   SYMFUNC(xf86feof)
+   SYMFUNC(xf86ferror)
+   SYMFUNC(xf86fflush)
+   SYMFUNC(xf86fgetc)
+   SYMFUNC(xf86fgetpos)
+   SYMFUNC(xf86fgets)
+   SYMFUNC(xf86finite)
+   SYMFUNC(xf86floor)
+   SYMFUNC(xf86fmod)
+   SYMFUNC(xf86fopen)
+   SYMFUNC(xf86fprintf)
+   SYMFUNC(xf86fputc)
+   SYMFUNC(xf86fputs)
+   SYMFUNC(xf86fread)
+   SYMFUNC(xf86free)
+   SYMFUNC(xf86freopen)
+   SYMFUNC(xf86frexp)
+   SYMFUNC(xf86fscanf)
+   SYMFUNC(xf86fseek)
+   SYMFUNC(xf86fsetpos)
+   SYMFUNC(xf86ftell)
+   SYMFUNC(xf86fwrite)
+   SYMFUNC(xf86getc)
+   SYMFUNC(xf86getenv)
+   SYMFUNC(xf86getpagesize)
+   SYMFUNC(xf86hypot)
+   SYMFUNC(xf86ioctl)
+   SYMFUNC(xf86isalnum)
+   SYMFUNC(xf86isalpha)
+   SYMFUNC(xf86iscntrl)
+   SYMFUNC(xf86isdigit)
+   SYMFUNC(xf86isgraph)
+   SYMFUNC(xf86islower)
+   SYMFUNC(xf86isprint)
+   SYMFUNC(xf86ispunct)
+   SYMFUNC(xf86isspace)
+   SYMFUNC(xf86isupper)
+   SYMFUNC(xf86isxdigit)
+   SYMFUNC(xf86labs)
+   SYMFUNC(xf86ldexp)
+   SYMFUNC(xf86log)
+   SYMFUNC(xf86log10)
+   SYMFUNC(xf86lseek)
+   SYMFUNC(xf86malloc)
+   SYMFUNC(xf86memchr)
+   SYMFUNC(xf86memcmp)
+   SYMFUNC(xf86memcpy)
+#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__ia64__) || defined (__amd64__)
+   /*
+    * Some PPC, SPARC, and IA64 compilers generate calls to memcpy to handle
+    * structure copies.  This causes a problem both here and in shared
+    * libraries as there is no way to map the name of the call to the
+    * correct function.
+    */
+   SYMFUNC(memcpy)
+   /*
+    * Some PPC, SPARC, and IA64 compilers generate calls to memset to handle 
+    * aggregate initializations.
+    */
+   SYMFUNC(memset)
+#endif
+   SYMFUNC(xf86memmove)
+   SYMFUNC(xf86memset)
+   SYMFUNC(xf86mmap)
+   SYMFUNC(xf86modf)
+   SYMFUNC(xf86munmap)
+   SYMFUNC(xf86open)
+   SYMFUNC(xf86perror)
+   SYMFUNC(xf86pow)
+   SYMFUNC(xf86printf)
+   SYMFUNC(xf86qsort)
+   SYMFUNC(xf86read)
+   SYMFUNC(xf86realloc)
+   SYMFUNC(xf86remove)
+   SYMFUNC(xf86rename)
+   SYMFUNC(xf86rewind)
+   SYMFUNC(xf86setbuf)
+   SYMFUNC(xf86setvbuf)
+   SYMFUNC(xf86sin)
+   SYMFUNC(xf86snprintf)
+   SYMFUNC(xf86sprintf)
+   SYMFUNC(xf86sqrt)
+   SYMFUNC(xf86sscanf)
+   SYMFUNC(xf86strcat)
+   SYMFUNC(xf86strcmp)
+   SYMFUNC(xf86strcasecmp)
+   SYMFUNC(xf86strcpy)
+   SYMFUNC(xf86strcspn)
+   SYMFUNC(xf86strerror)
+   SYMFUNC(xf86strlen)
+   SYMFUNC(xf86strncmp)
+   SYMFUNC(xf86strncasecmp)
+   SYMFUNC(xf86strncpy)
+   SYMFUNC(xf86strpbrk)
+   SYMFUNC(xf86strchr)
+   SYMFUNC(xf86strrchr)
+   SYMFUNC(xf86strspn)
+   SYMFUNC(xf86strstr)
+   SYMFUNC(xf86strtod)
+   SYMFUNC(xf86strtok)
+   SYMFUNC(xf86strtol)
+   SYMFUNC(xf86strtoul)
+   SYMFUNC(xf86tan)
+   SYMFUNC(xf86tmpfile)
+   SYMFUNC(xf86tolower)
+   SYMFUNC(xf86toupper)
+   SYMFUNC(xf86ungetc)
+   SYMFUNC(xf86vfprintf)
+   SYMFUNC(xf86vsnprintf)
+   SYMFUNC(xf86vsprintf)
+   SYMFUNC(xf86write)
+  
+/* non-ANSI C functions */
+   SYMFUNC(xf86opendir)
+   SYMFUNC(xf86closedir)
+   SYMFUNC(xf86readdir)
+   SYMFUNC(xf86rewinddir)
+   SYMFUNC(xf86ffs)
+   SYMFUNC(xf86strdup)
+   SYMFUNC(xf86bzero)
+   SYMFUNC(xf86usleep)
+   SYMFUNC(xf86execl)
+
+   SYMFUNC(xf86getsecs)
+   SYMFUNC(xf86fpossize)      /* for returning sizeof(fpos_t) */
+
+   SYMFUNC(xf86stat)
+   SYMFUNC(xf86fstat)
+   SYMFUNC(xf86access)
+   SYMFUNC(xf86geteuid)
+   SYMFUNC(xf86getegid)
+   SYMFUNC(xf86getpid)
+   SYMFUNC(xf86mknod)
+   SYMFUNC(xf86chmod)
+   SYMFUNC(xf86chown)
+   SYMFUNC(xf86sleep)
+   SYMFUNC(xf86mkdir)
+   SYMFUNC(xf86shmget)
+   SYMFUNC(xf86shmat)
+   SYMFUNC(xf86shmdt)
+   SYMFUNC(xf86shmctl)
+#ifdef HAS_GLIBC_SIGSETJMP
+   SYMFUNC(xf86setjmp)
+   SYMFUNC(xf86setjmp0)
+#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+   SYMFUNCALIAS("xf86setjmp1",__sigsetjmp)
+#else
+   SYMFUNC(xf86setjmp1)
+#endif
+#else
+   SYMFUNCALIAS("xf86setjmp",setjmp)
+   SYMFUNCALIAS("xf86setjmp0",setjmp)
+   SYMFUNC(xf86setjmp1)
+#endif
+   SYMFUNCALIAS("xf86longjmp",longjmp)
+   SYMFUNC(xf86getjmptype)
+   SYMFUNC(xf86setjmp1_arg2)
+   SYMFUNC(xf86setjmperror)
+
+    SYMFUNC(xf86AddDriver)
+    SYMFUNC(xf86ServerIsOnlyDetecting)
+    SYMFUNC(xf86AddInputDriver)
+    SYMFUNC(xf86AddModuleInfo)
+    SYMFUNC(xf86LoaderCheckSymbol)
+
+    SYMFUNC(xf86LoaderRefSymLists)
+    SYMFUNC(xf86LoaderReqSymLists)
+    SYMFUNC(xf86Msg)
+    SYMFUNC(xf86MsgVerb)
+    SYMFUNC(ErrorF)
+    SYMFUNC(xf86PrintChipsets)
+    SYMFUNC(xf86ErrorFVerb)
+    SYMFUNC(xf86GetPciVideoInfo)
+    SYMFUNC(xf86MatchDevice)
+    SYMFUNC(xf86MatchPciInstances)
+    SYMFUNC(xf86MatchIsaInstances)
+    SYMFUNC(Xfree)
+    SYMFUNC(xf86LoadDrvSubModule)
+    SYMFUNC(xf86DrvMsg)
+    SYMFUNC(xf86GetPciConfigInfo)
+    SYMFUNC(xf86IsPrimaryPci)
+    SYMFUNC(xf86CheckPciSlot)
+    SYMFUNC(XNFalloc)
+    SYMFUNC(XNFrealloc)
+    SYMFUNC(XNFcalloc)
+    {0,0}
+};
+
+static SymTabRec ATIChipsets[] = {
+    { PCI_CHIP_MACH64CT, "Mach 64 CT" },
+    { PCI_CHIP_MACH64CX, "Mach 64 CX" },
+    { PCI_CHIP_MACH64ET, "Mach 64 ET" },
+    { PCI_CHIP_MACH64GB, "Mach 64 GB" },
+    { PCI_CHIP_MACH64GD, "Mach 64 GD" },
+    { PCI_CHIP_MACH64GI, "Mach 64 GI" },
+    { PCI_CHIP_MACH64GL, "Mach 64 GL" },
+    { PCI_CHIP_MACH64GM, "Mach 64 GM" },
+    { PCI_CHIP_MACH64GN, "Mach 64 GN" },
+    { PCI_CHIP_MACH64GO, "Mach 64 GO" },
+    { PCI_CHIP_MACH64GP, "Mach 64 GP" },
+    { PCI_CHIP_MACH64GQ, "Mach 64 GQ" },
+    { PCI_CHIP_MACH64GR, "Mach 64 GR" },
+    { PCI_CHIP_MACH64GS, "Mach 64 GS" },
+    { PCI_CHIP_MACH64GT, "Mach 64 GT" },
+    { PCI_CHIP_MACH64GU, "Mach 64 GU" },
+    { PCI_CHIP_MACH64GV, "Mach 64 GV" },
+    { PCI_CHIP_MACH64GW, "Mach 64 GW" },
+    { PCI_CHIP_MACH64GX, "Mach 64 GX" },
+    { PCI_CHIP_MACH64GY, "Mach 64 GY" },
+    { PCI_CHIP_MACH64GZ, "Mach 64 GZ" },
+    { PCI_CHIP_MACH64LB, "Mach 64 LB" },
+    { PCI_CHIP_MACH64LD, "Mach 64 LD" },
+    { PCI_CHIP_MACH64LG, "Mach 64 LG" },
+    { PCI_CHIP_MACH64LI, "Mach 64 LI" },
+    { PCI_CHIP_MACH64LM, "Mach 64 LM" },
+    { PCI_CHIP_MACH64LN, "Mach 64 LN" },
+    { PCI_CHIP_MACH64LP, "Mach 64 LP" },
+    { PCI_CHIP_MACH64LQ, "Mach 64 LQ" },
+    { PCI_CHIP_MACH64LR, "Mach 64 LR" },
+    { PCI_CHIP_MACH64LS, "Mach 64 LS" },
+    { PCI_CHIP_MACH64VT, "Mach 64 VT" },
+    { PCI_CHIP_MACH64VU, "Mach 64 VU" },
+    { PCI_CHIP_MACH64VV, "Mach 64 VV" },
+    { PCI_CHIP_R200_QI, "R200 QI" },
+    { PCI_CHIP_R200_QJ, "R200 QJ" },
+    { PCI_CHIP_R200_QK, "R200 QK" },
+    { PCI_CHIP_RS300_5836, "R300 5836" },
+    { PCI_CHIP_RS300_5837, "R300 5837" },
+    { PCI_CHIP_RV250_Le, "RV250 Le" },
+    { PCI_CHIP_RV250_Ln, "RV250 Ln" },
+    {-1, NULL}
+};
+
+static DriverPtr driver;
+static ModuleInfoPtr info;
+static SymTabPtr chips;
+static int vendor;
+ModuleType module_type = GenericModule;
+
+static void
+AddModuleOptions(char *name, const OptionInfoRec *option)
+{
+    xf86cfgModuleOptions *ptr;
+    const OptionInfoRec *tmp;
+    SymTabPtr ctmp;
+    int count;
+    SymTabRec *symptr;
+
+    /* XXX If the module is already in the list, then it means that
+     * it is now being properly loaded by xf86cfg and the "fake" entry
+     * added in xf86cfgLoaderInitList() isn't required anymore.
+     * Currently:
+     *	ati and vmware are known to fail. */
+    for (ptr = module_options; ptr; ptr = ptr->next)
+	if (strcmp(name, ptr->name) == 0) {
+	    fprintf(stderr, "Module %s already in list!\n", name);
+	    return;
+	}
+
+    ptr = XtNew(xf86cfgModuleOptions);
+    ptr->name = XtNewString(name);
+    ptr->type = module_type;
+    if (option) {
+	for (count = 0, tmp = option; tmp->name != NULL; tmp++, count++)
+	    ;
+	++count;
+	ptr->option = XtCalloc(1, count * sizeof(OptionInfoRec));
+	for (count = 0, tmp = option; tmp->name != NULL; count++, tmp++) {
+	    memcpy(&ptr->option[count], tmp, sizeof(OptionInfoRec));
+	    ptr->option[count].name = XtNewString(tmp->name);
+	    if (tmp->type == OPTV_STRING || tmp->type == OPTV_ANYSTR)
+		ptr->option[count].value.str = XtNewString(tmp->value.str);
+	}
+    }
+    else
+	ptr->option = NULL;
+
+    /* Exception handling: ati driver does not call xf86MatchPciInstances(),
+       below is workaround */
+    if ((vendor == -1 || !chips) &&  (!strcmp(name, "ati"))) {
+	vendor = PCI_VENDOR_ATI;
+	chips = ATIChipsets;
+    }
+    if (vendor != -1 && chips) {
+	ptr->vendor = vendor;
+	for (count = 0, ctmp = chips; ctmp->name; ctmp++, count++)
+	    ;
+	++count;
+	ptr->chipsets = XtCalloc(1, count * sizeof(SymTabRec));
+	for (count = 0, ctmp = chips; ctmp->name != NULL; count++, ctmp++) {
+	    memcpy(&ptr->chipsets[count], ctmp, sizeof(SymTabRec));
+	    ptr->chipsets[count].name = XtNewString(ctmp->name);
+	}
+    }
+    else
+	ptr->chipsets = NULL;
+
+    ptr->next = module_options;
+    module_options = ptr;
+}
+
+extern void xf86WrapperInit(void);
+
+void
+xf86cfgLoaderInit(void)
+{
+    LoaderInit();
+    xf86WrapperInit();
+}
+
+void
+xf86cfgLoaderInitList(int type)
+{
+    static const char *generic[] = {
+	".",
+	NULL
+    };
+    static const char *video[] = {
+	"drivers",
+	NULL
+    };
+    static const char *input[] = {
+	"input",
+	NULL
+    };
+    static const char *font[] = {
+	"fonts",
+	NULL
+    };
+    const char **subdirs;
+
+    switch (type) {
+	case GenericModule:
+	    subdirs = generic;
+	    break;
+	case VideoModule:
+	    subdirs = video;
+	    break;
+	case InputModule:
+	    subdirs = input;
+	    break;
+	case FontRendererModule:
+	    subdirs = font;
+	    break;
+	default:
+	    fprintf(stderr, "Invalid value passed to xf86cfgLoaderInitList.\n");
+	    subdirs = generic;
+	    break;
+    }
+    LoaderSetPath(loaderPath);
+    loaderList = LoaderListDirs(subdirs, NULL);
+
+    /* XXX Xf86cfg isn't able to provide enough wrapper functions
+     * to these drivers. Maybe the drivers could also be changed
+     * to work better when being loaded "just for testing" */
+    /* Workaround for ati is in place, and nmware no long cuases problem,
+     * do not need to do the following to make ati/vmware duplicate */
+    /*
+    if (type == VideoModule) {
+	module_type = VideoModule;
+	AddModuleOptions("vmware", NULL);
+	AddModuleOptions("ati", NULL);
+	module_type = NullModule;
+    }
+    */
+}
+
+void
+xf86cfgLoaderFreeList(void)
+{
+    LoaderFreeDirList(loaderList);
+}
+
+int
+xf86cfgCheckModule(ModuleType modtype)
+{
+    int errmaj, errmin;
+    ModuleDescPtr module;
+    int nfonts;
+    FontModule *fonts, *pfont_module;
+    char name[64];
+    int i = 0;
+    void (*Identify)();
+    Bool (*Probe)();
+
+    driver = NULL;
+    chips = NULL;
+    info = NULL;
+    pfont_module = NULL;
+    vendor = -1;
+    module_type = GenericModule;
+
+    if ((module = LoadModule(*ploaderList, NULL, NULL, NULL, NULL,
+			     NULL, &errmaj, &errmin)) == NULL) {
+	LoaderErrorMsg(NULL, *ploaderList, errmaj, errmin);
+	return (0);
+    }
+    else if (driver && driver->AvailableOptions) {
+	/* at least fbdev does not call xf86MatchPciInstances in Probe */
+	/* ati driver is known to fail in probing, but we still need to
+           load it because it loads r128 and radeon symbles */
+	if (!strcmp(*ploaderList, "ati"))
+		AddModuleOptions(*ploaderList, NULL); 
+	if (driver->Identify)
+    		(*driver->Identify)(-1);
+	if (driver->Probe)
+    		(*driver->Probe)(driver, PROBE_DETECT);
+	AddModuleOptions(*ploaderList, (*driver->AvailableOptions)(-1, -1));
+    }
+    else if (info && info->AvailableOptions)
+	AddModuleOptions(*ploaderList, (*info->AvailableOptions)(NULL));
+    /* Exception handling: some video drivers (radeon, r128) do not call 
+       xf86AddDriver(), therefore driver is NULL. Below is workaround  */
+    else if (!driver && (modtype == VideoModule)) {
+	for (i = 0; i < strlen(ploaderList[0]); i++)
+		name[i] = (char) toupper(ploaderList[0][i]);
+	name[i] = '\0';
+	driver = (DriverPtr) LoaderSymbol(name);
+	strncpy(&name[i], "Identify", strlen("Identify") + 1);
+	Identify = (void (*) ()) LoaderSymbol(name);
+	if (Identify) 
+		(*Identify)(-1);
+	strncpy(&name[i], "Probe", strlen("Probe") + 1);
+	Probe = (Bool (*) ()) LoaderSymbol(name);
+	if (Probe) 
+		(*Probe)(driver, PROBE_DETECT);
+	AddModuleOptions(*ploaderList, NULL);
+    }
+
+    if (!noverify) {
+	XF86ModuleData *initdata = NULL;
+	char *p;
+
+	p = XtMalloc(strlen(*ploaderList) + strlen("ModuleData") + 1);
+	strcpy(p, *ploaderList);
+	strcat(p, "ModuleData");
+	initdata = LoaderSymbol(p);
+	if (initdata) {
+	    XF86ModuleVersionInfo *vers;
+
+	    vers = initdata->vers;
+	    if (vers && strcmp(*ploaderList, vers->modname)) {
+		/* This was a problem at some time for some video drivers */
+		CheckMsg(CHECKER_FILE_MODULE_NAME_MISMATCH,
+			 "WARNING file/module name mismatch: \"%s\" \"%s\"\n",
+			 *ploaderList, vers->modname);
+		++error_level;
+	    }
+	}
+	XtFree(p);
+    }
+
+    nfonts = numFontModules;
+    numFontModules = 0;
+    fonts = FontModuleList;
+    if (fonts) {
+	Bool dup = FALSE;
+	while (fonts->name) {
+	    if (strcasecmp(fonts->name, *ploaderList) == 0) {
+		pfont_module = fonts;
+		/* HACK:
+		 * fonts->names points into modules.
+		 * Duplicate string of all remaining names to survive
+		 * unloading. Since new fonts are appended to list
+		 * this will only happen once per renderer.
+		 */
+		dup = TRUE;
+	    }
+	    if (dup)
+		fonts->name = strdup(fonts->name);
+	    ++numFontModules;
+	    ++fonts;
+	}
+    }
+    if (pfont_module)
+	module_type = FontRendererModule;
+    else if (nfonts + 1 <= numFontModules) {
+	/* loader.c will flag a warning if -noverify is not set */
+	pfont_module = &FontModuleList[nfonts];
+	module_type = FontRendererModule;
+    }
+
+    if (font_module) {
+	XtFree((XtPointer)font_module->name);
+	XtFree((XtPointer)font_module);
+	font_module = NULL;
+    }
+    if (pfont_module) {
+	font_module = XtNew(FontModule);
+	memcpy(font_module, pfont_module, sizeof(FontModule));
+	font_module->name = XtNewString(pfont_module->name);
+    }
+
+    UnloadModule(module);
+
+    return (1);
+}
+
+void
+xf86AddDriver(DriverPtr drv, void *module, int flags)
+{
+    driver = drv;
+    if (driver)
+	driver->module = module;
+    module_type = VideoModule;
+}
+
+Bool
+xf86ServerIsOnlyDetecting(void)
+{
+    return (True);
+}
+
+void
+xf86AddInputDriver(InputDriverPtr inp, void *module, int flags)
+{
+    module_type = InputModule;
+}
+
+void
+xf86AddModuleInfo(ModuleInfoPtr inf, void *module)
+{
+    info = inf;
+}
+
+Bool
+xf86LoaderCheckSymbol(const char *symbol)
+{
+    return LoaderSymbol(symbol) != NULL;
+}
+
+void
+xf86LoaderRefSymLists(const char **list0, ...)
+{
+}
+
+void
+xf86LoaderReqSymLists(const char **list0, ...)
+{
+}
+
+#if 0
+void xf86Msg(int type, const char *format, ...)
+{
+}
+#endif
+
+/*ARGSUSED*/
+void
+xf86PrintChipsets(const char *name, const char *msg, SymTabPtr chipsets)
+{
+    vendor = 0;
+    chips = chipsets;
+}
+
+pciVideoPtr *
+xf86GetPciVideoInfo(void)
+{
+    static pciVideoRec pci_video;
+    static pciVideoPtr pci_video_ptr[2] = { &pci_video };
+
+    memset(&pci_video, 0, sizeof(pciVideoRec));
+
+    return (pci_video_ptr);
+}
+
+int
+xf86MatchDevice(const char *name, GDevPtr **gdev)
+{
+    *gdev = NULL;
+
+    return (1);
+}
+
+int
+xf86MatchPciInstances(const char *name, int VendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets,
+		      GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities)
+{
+    vendor = VendorID;
+    if (chips == NULL)
+	chips = chipsets;
+    *foundEntities = NULL;
+
+    return (0);
+}
+
+int
+xf86MatchIsaInstances(const char *name, SymTabPtr chipsets, IsaChipsets *ISAchipsets, DriverPtr drvp,
+		      FindIsaDevProc FindIsaDevice, GDevPtr *devList, int numDevs, int **foundEntities)
+{
+    *foundEntities = NULL;
+
+    return (0);
+}
+
+/*ARGSUSED*/
+void *
+xf86LoadDrvSubModule(DriverPtr drv, const char *name)
+{
+    pointer ret;
+    int errmaj = 0, errmin = 0;
+
+    ret = LoadSubModule(drv->module, name, NULL, NULL, NULL, NULL,
+			&errmaj, &errmin);
+    if (!ret)
+	LoaderErrorMsg(NULL, name, errmaj, errmin);
+    return (ret);
+}
+
+pciConfigPtr *
+xf86GetPciConfigInfo(void)
+{
+    return (NULL);
+}
+
+Bool
+xf86IsPrimaryPci(pciVideoPtr pPci)
+{
+    return (True);
+}
+
+Bool 
+xf86CheckPciSlot(int bus, int device, int func)
+{
+    return (False);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,44 @@
+XCOMM #########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM #########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/03 SMI"
+XCOMM
+
+XCOMM Redefine so that the config file will be in /etc/X11
+#define XConfigDir		/etc/X11
+
+XCOMM  Link with native libraries
+#define LdPreLib /**/
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-cfg -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,3 @@
+
+XCOMM Redefine run time library search path
+CCLINK = LD_RUN_PATH=$(USRLIBDIRPATH)/$(PROG):$(USRLIBDIRPATH):$(SYSTEMUSRLIBDIR) $(CC)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo César Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c,v 1.11tsi Exp $
+ */
+
+#include "xf86config.h"
+#include "mouse-cfg.h"
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/List.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/Viewport.h>
+#include <X11/extensions/xf86misc.h>
+
+/*
+ * Prototypes
+ */
+static void MouseDeviceCallback(Widget, XtPointer, XtPointer);
+static void MouseProtocolCallback(Widget, XtPointer, XtPointer);
+static void MouseEmulateCallback(Widget, XtPointer, XtPointer);
+static void MouseApplyCallback(Widget, XtPointer, XtPointer);
+static Bool MouseConfigCheck(void);
+
+/*
+ * Initialization
+ */
+static struct MouseProtocol {
+    char *name;
+    int type;
+} protocols[] = {
+#ifdef __UNIXOS2__
+    {"OS2Mouse",		MTYPE_AUTOMOUSE},
+#endif
+#ifdef __SCO__
+    {"OsMouse",			MTYPE_AUTOMOUSE},
+#endif
+#if defined(__UNIXWARE__)
+    {"Xqueue",			MTYPE_XQUEUE},
+#endif
+#ifdef WSCONS_SUPPORT
+    {"wsmouse",			MTYPE_AUTOMOUSE},
+#endif
+    {"Auto",			MTYPE_AUTOMOUSE},
+    {"SysMouse",		MTYPE_SYSMOUSE},
+    {"MouseSystems",		MTYPE_MOUSESYS},
+    {"BusMouse",		MTYPE_BUSMOUSE},
+    {"PS/2",			MTYPE_PS_2},
+    {"Microsoft",		MTYPE_MICROSOFT},
+#ifndef __FreeBSD__
+    {"ImPS/2",			MTYPE_IMPS2},
+    {"ExplorerPS/2",		MTYPE_EXPPS2},
+    {"GlidePointPS/2",		MTYPE_GLIDEPOINTPS2},
+    {"MouseManPlusPS/2",	MTYPE_MMANPLUSPS2},
+    {"NetMousePS/2",		MTYPE_NETPS2},
+    {"NetScrollPS/2",		MTYPE_NETSCROLLPS2},
+    {"ThinkingMousePS/2",	MTYPE_THINKINGPS2},
+#endif
+    {"AceCad",			MTYPE_ACECAD},
+    {"GlidePoint",		MTYPE_GLIDEPOINT},
+    {"IntelliMouse",		MTYPE_IMSERIAL},
+    {"Logitech",		MTYPE_LOGITECH},
+    {"MMHitTab",		MTYPE_MMHIT},
+    {"MMSeries",		MTYPE_MMSERIES},
+    {"MouseMan",		MTYPE_LOGIMAN},
+    {"ThinkingMouse",		MTYPE_THINKING},
+};
+
+static Widget text;
+static char *device, *protocol;
+static Bool emulate;
+static XF86ConfInputPtr current_input;
+
+/*
+ * Implementation
+ */
+/*ARGSUSED*/
+XtPointer
+MouseConfig(XtPointer config)
+{
+    XF86ConfInputPtr mouse = (XF86ConfInputPtr)config;
+    XF86OptionPtr option;
+    char mouse_name[32];
+    Arg args[1];
+
+    static char *Device = "Device", *Protocol = "Protocol",
+		*Emulate3Buttons = "Emulate3Buttons",
+		*Emulate3Timeout = "Emulate3Timeout";
+
+    current_input = mouse;
+
+    if (mouse != NULL) {
+	emulate = xf86findOption(mouse->inp_option_lst,
+				 Emulate3Buttons) != NULL;
+	if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL)
+	    device = option->opt_val;
+	else
+	    device = NULL;
+	if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL)
+	    protocol = option->opt_val;
+	else
+	    protocol = NULL;
+
+	XtSetArg(args[0], XtNstring, mouse->inp_identifier);
+	XtSetValues(ident_widget, args, 1);
+    }
+    else {
+	XF86ConfInputPtr input = XF86Config->conf_input_lst;
+	int nmouses = 0;
+
+	while (input != NULL) {
+	    if (strcasecmp(input->inp_driver, "mouse") == 0)
+		++nmouses;
+	    input = (XF86ConfInputPtr)(input->list.next);
+	}
+	do {
+	    XmuSnprintf(mouse_name, sizeof(mouse_name), "Mouse%d", nmouses);
+	    ++nmouses;
+	} while (xf86findInput(mouse_name,
+		 XF86Config->conf_input_lst));
+
+	XtSetArg(args[0], XtNstring, mouse_name);
+	XtSetValues(ident_widget, args, 1);
+
+	emulate = True;
+	device = NULL;
+	protocol = NULL;
+    }
+
+    xf86info.cur_list = MOUSE;
+    XtSetSensitive(back, xf86info.lists[MOUSE].cur_function > 0);
+    XtSetSensitive(next, xf86info.lists[MOUSE].cur_function <
+			 xf86info.lists[MOUSE].num_functions - 1);
+    (xf86info.lists[MOUSE].functions[xf86info.lists[MOUSE].cur_function])
+	(&xf86info);
+
+    if (ConfigLoop(MouseConfigCheck) == True) {
+	XtSetArg(args[0], XtNstring, &device);
+	XtGetValues(text, args, 1);
+	if (mouse == NULL) {
+	    mouse = XtNew(XF86ConfInputRec);
+	    mouse->list.next = NULL;
+	    mouse->inp_identifier = XtNewString(ident_string);
+	    mouse->inp_driver = XtNewString("mouse");
+	    mouse->inp_option_lst = xf86newOption(XtNewString(Device),
+						  XtNewString(device));
+	    xf86addNewOption(mouse->inp_option_lst,
+			     XtNewString(Protocol), XtNewString(protocol));
+	    if (emulate) {
+		xf86addNewOption(mouse->inp_option_lst,
+			         XtNewString(Emulate3Buttons), NULL);
+		xf86addNewOption(mouse->inp_option_lst,
+			         XtNewString(Emulate3Timeout),
+				 XtNewString("50"));
+	    }
+	    mouse->inp_comment = NULL;
+	}
+	else {
+	    if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) {
+		XtFree(option->opt_val);
+		option->opt_val = XtNewString(device);
+		XtFree(option->opt_comment);
+	    }
+	    else {
+		if (mouse->inp_option_lst == NULL)
+		    mouse->inp_option_lst = xf86newOption(XtNewString(Device),
+							  XtNewString(device));
+		else
+		    xf86addNewOption(mouse->inp_option_lst,
+				     XtNewString(Device), XtNewString(device));
+	    }
+
+	    if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) {
+		XtFree(option->opt_val);
+		option->opt_val = XtNewString(protocol);
+		XtFree(option->opt_comment);
+	    }
+	    else
+		xf86addNewOption(mouse->inp_option_lst,
+				 XtNewString(Protocol), XtNewString(protocol));
+
+	    if (emulate == False) {
+		xf86removeOption(&(mouse->inp_option_lst), Emulate3Buttons);
+		xf86removeOption(&(mouse->inp_option_lst), Emulate3Timeout);
+	    }
+	    else if (emulate) {
+		xf86addNewOption(mouse->inp_option_lst,
+				 XtNewString(Emulate3Buttons), NULL);
+		xf86addNewOption(mouse->inp_option_lst,
+				 XtNewString(Emulate3Timeout), XtNewString("50"));
+	    }
+	}
+	if (strcasecmp(mouse->inp_identifier, ident_string))
+	    xf86renameInput(XF86Config, mouse, ident_string);
+
+	return ((XtPointer)mouse);
+    }
+
+    return (NULL);
+}
+
+static Bool
+MouseConfigCheck(void)
+{
+    Arg args[1];
+    XF86ConfInputPtr mouse = XF86Config->conf_input_lst;
+
+    XtSetArg(args[0], XtNstring, &device);
+    XtGetValues(text, args, 1);
+
+    if (ident_string == NULL || strlen(ident_string) == 0 ||
+	device == NULL || strlen(device) == 0 || protocol == NULL)
+	return (False);
+    while (mouse != NULL) {
+	if (mouse != current_input &&
+	    strcasecmp(ident_string, mouse->inp_identifier) == 0)
+	    return (False);
+	mouse = (XF86ConfInputPtr)(mouse->list.next);
+    }
+
+    return (True);
+}
+
+static void
+MouseDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XawListReturnStruct *info = (XawListReturnStruct *)call_data;
+    Arg args[1];
+
+    XtSetArg(args[0], XtNstring, info->string);
+    XtSetValues((Widget)user_data, args, 1);
+    XawTextSetInsertionPoint((Widget)user_data, strlen(info->string));
+}
+
+static void
+MouseProtocolCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XawListReturnStruct *info = (XawListReturnStruct *)call_data;
+
+    protocol = info->string;
+}
+
+static void
+MouseEmulateCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    emulate = (Bool)(long)call_data;
+}
+
+static void
+MouseApplyCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    int i;
+    XF86MiscMouseSettings mouse;
+
+    XF86MiscGetMouseSettings(XtDisplay(w), &mouse);
+
+#ifndef sun
+    XtFree(mouse.device);
+#endif
+
+    if (mouse.baudrate == 0 || mouse.baudrate < 0 || mouse.baudrate > 9600 ||
+	mouse.baudrate % 1200)
+	mouse.baudrate = 1200;
+
+    mouse.type = MTYPE_AUTOMOUSE;
+    for (i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++)
+	if (strcmp(protocols[i].name, protocol) == 0) {
+	    mouse.type = protocols[i].type;
+	    break;
+	}
+
+    mouse.emulate3buttons = emulate;
+    mouse.flags |= MF_REOPEN;
+
+#ifndef sun
+    mouse.device = device;
+#endif
+
+    XFlush(XtDisplay(w));
+    XF86MiscSetMouseSettings(XtDisplay(w), &mouse);
+}
+
+void
+MouseDeviceAndProtocol(XF86SetupInfo *info)
+{
+    static int first = 1, ndevices;
+    static Widget mouse_dp, listD, listP, emul3, apply;
+    static char **devices;
+    static char *dirs[] = {
+	"/dev",
+#ifdef __linux__
+	"/dev/input"
+#endif
+    };
+    static char *patterns[] = {
+#ifdef WSCONS_SUPPORT
+	"wsmouse",
+#endif
+	"cuaa",
+	"mice",
+	"mouse",
+	"ps",
+	"sysmouse",
+	"ttyS",
+    };
+    Arg args[2];
+    int i;
+
+    if (first) {
+	Widget viewport;
+	struct dirent *ent;
+	DIR *dir;
+	char **list;
+	int count;
+
+	first = 0;
+
+	mouse_dp = XtCreateWidget("mouseDP", formWidgetClass,
+				  configp, NULL, 0);
+
+	/* DEVICE */
+	for (count = 0; count < sizeof(dirs) / sizeof(dirs[0]); count++) {
+	    if ((dir = opendir(dirs[count])) != NULL) {
+		int i, len, xlen = strlen(dirs[count]) + 2;
+
+		(void)readdir(dir);
+		(void)readdir(dir);
+		while ((ent = readdir(dir)) != NULL) {
+		    for (i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
+			len = strlen(patterns[i]);
+
+			if (strncmp(patterns[i], ent->d_name, len) == 0) {
+			    len = strlen(ent->d_name) + xlen;
+
+			    devices = (char**)XtRealloc((XtPointer)devices,
+							sizeof(char*) * ++ndevices);
+			    devices[ndevices - 1] = XtMalloc(len);
+			    XmuSnprintf(devices[ndevices - 1], len, "%s/%s",
+					dirs[count], ent->d_name);
+			}
+		    }
+		}
+		closedir(dir);
+	    }
+	}
+
+	(void) XtCreateManagedWidget("labelD", labelWidgetClass,
+				      mouse_dp, NULL, 0);
+	text = XtVaCreateManagedWidget("device", asciiTextWidgetClass,
+				       mouse_dp,
+				       XtNeditType, XawtextEdit,
+				       NULL);
+	viewport = XtCreateManagedWidget("viewportD", viewportWidgetClass,
+					 mouse_dp, NULL, 0);
+
+	listD = XtVaCreateManagedWidget("listD", listWidgetClass,
+					viewport,
+					XtNlist, devices,
+					XtNnumberStrings, ndevices,
+					NULL);
+	XtAddCallback(listD, XtNcallback, MouseDeviceCallback, (XtPointer)text);
+
+	/* PROTOCOL */
+	(void) XtCreateManagedWidget("labelP", labelWidgetClass,
+				      mouse_dp, NULL, 0);
+	viewport = XtCreateManagedWidget("viewportP", viewportWidgetClass,
+					 mouse_dp, NULL, 0);
+
+	list = (char**)XtMalloc(sizeof(char*) *
+				sizeof(protocols)/sizeof(protocols[0]));
+	for (count = 0; count < sizeof(protocols)/sizeof(protocols[0]); count++)
+	    list[count] = XtNewString(protocols[count].name);
+	listP = XtVaCreateManagedWidget("listP", listWidgetClass,
+					viewport,
+					XtNlist, list,
+					XtNnumberStrings, count,
+					NULL);
+	XtAddCallback(listP, XtNcallback, MouseProtocolCallback, NULL);
+
+	emul3 = XtVaCreateManagedWidget("emulate3", toggleWidgetClass,
+					mouse_dp, XtNstate, True, NULL);
+	XtAddCallback(emul3, XtNcallback, MouseEmulateCallback, NULL);
+	apply = XtCreateManagedWidget("apply", commandWidgetClass,
+				      mouse_dp, NULL, 0);
+	XtAddCallback(apply, XtNcallback, MouseApplyCallback, NULL);
+
+	XtRealizeWidget(mouse_dp);
+    }
+
+    if (device != NULL) {
+	for (i = 0; i < ndevices; i++)
+	    if (strcmp(device, devices[i]) == 0) {
+		XtSetArg(args[0], XtNstring, device);
+		XtSetValues(text, args, 1);
+		XawListHighlight(listD, i);
+		break;
+	    }
+
+	if (i >= ndevices) {
+	    devices = (char**)XtRealloc((XtPointer)devices,
+					sizeof(char*) * ++ndevices);
+	    devices[ndevices - 1] = XtNewString(device);
+	    XawListHighlight(listD, ndevices - 1);
+	    XtSetArg(args[0], XtNlist, devices);
+	    XtSetArg(args[1], XtNnumberStrings, ndevices);
+	    XtSetValues(listD, args, 2);
+	}
+	device = devices[i];
+    }
+    else {
+	XtSetArg(args[0], XtNstring, "");
+	XtSetValues(text, args, 1);
+	XawListUnhighlight(listD);
+    }
+
+    if (protocol != NULL) {
+	for (i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++)
+	    if (strcasecmp(protocol, protocols[i].name) == 0) {
+		protocol = protocols[i].name;
+		XawListHighlight(listP, i);
+		break;
+	    }
+    }
+    else {
+	/* "Auto" is the default */
+	protocol = protocols[0].name;
+	XawListHighlight(listP, 0);
+    }
+
+    XtSetArg(args[0], XtNstate, emulate);
+    XtSetValues(emul3, args, 1);
+
+    XtChangeManagedSet(&current, 1, NULL, NULL, &mouse_dp, 1);
+    current = mouse_dp;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,557 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo César Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c,v 1.13tsi Exp $
+ */
+
+#include "xf86config.h"
+#include "screen-cfg.h"
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/List.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/Viewport.h>
+#ifdef USE_MODULES
+#include "loader.h"
+#endif
+
+#define CW	1
+#define CCW	-1
+
+/*
+ * Prototypes
+ */
+static void DepthCallback(Widget, XtPointer, XtPointer);
+static void SelectIndexCallback(Widget, XtPointer, XtPointer);
+static void UnselectIndexCallback(Widget, XtPointer, XtPointer);
+static void SelectCallback(Widget, XtPointer, XtPointer);
+static void UnselectCallback(Widget, XtPointer, XtPointer);
+static void MoveCallback(Widget, XtPointer, XtPointer);
+static void RotateCallback(Widget, XtPointer, XtPointer);
+
+/*
+ * Initialization
+ */
+static char *standard_modes[] = {
+    "640x400",
+    "640x480",
+    "800x600",
+    "1024x768",
+    "1280x960",
+    "1280x1024",
+    "320x200",
+    "320x240",
+    "400x300",
+    "1152x864",
+    "1600x1200",
+    "1800x1400",
+    "512x384",
+    "1400x1050",
+    "2048x1536",
+    "1920x1200",
+    "1920x1440",
+};
+
+static char **modes;
+static int nmodes;
+static int default_depth, sel_index, unsel_index;
+static Widget listL, listR;
+static char **defmodes;
+static int ndefmodes;
+static XF86ConfScreenPtr screen;
+static int rotate;
+
+/*
+ * Implementation
+ */
+XtPointer
+ScreenConfig(XtPointer conf)
+{
+    XF86ConfDisplayPtr disp;
+    Arg args[2];
+    int i, oldrotate;
+
+    screen = (XF86ConfScreenPtr)conf;
+    if (screen == NULL)
+	return (NULL);
+
+    XtSetArg(args[0], XtNstring, screen->scrn_identifier);
+    XtSetValues(ident_widget, args, 1);
+    if ((default_depth = screen->scrn_defaultdepth) <= 0)
+	default_depth = 8;
+    sel_index = unsel_index = -1;
+    for (i = 0; i < computer.num_screens; i++)
+	if (computer.screens[i]->screen == screen) {
+	    SetScreenRotate(computer.screens[i]);
+	    rotate = computer.screens[i]->rotate;
+    }
+    oldrotate = rotate;
+
+    ndefmodes = 0;
+    disp = screen->scrn_display_lst;
+    while (disp != NULL) {
+	if (disp->disp_depth == default_depth) {
+	    XF86ModePtr mod = disp->disp_mode_lst;
+
+	    while (mod != NULL) {
+		if (ndefmodes % 16 == 0)
+		    defmodes = (char**)
+			XtRealloc((XtPointer)defmodes,
+				  (ndefmodes + 16) * sizeof(char*));
+		defmodes[ndefmodes++] = XtNewString(mod->mode_name);
+		mod = (XF86ModePtr)(mod->list.next);
+	    }
+	    break;
+	}
+	disp = (XF86ConfDisplayPtr)(disp->list.next);
+    }
+    if (ndefmodes == 0) {
+	defmodes = (char**)XtMalloc(sizeof(char*));
+	defmodes[0] = XtNewString("640x480");
+	ndefmodes = 1;
+    }
+
+    if (listL != NULL) {
+	XawListUnhighlight(listL);
+	XawListUnhighlight(listR);
+    }
+
+    xf86info.cur_list = SCREEN;
+    XtSetSensitive(back, xf86info.lists[SCREEN].cur_function > 0);
+    XtSetSensitive(next, xf86info.lists[SCREEN].cur_function <
+			 xf86info.lists[SCREEN].num_functions - 1);
+    (xf86info.lists[SCREEN].functions[xf86info.lists[SCREEN].cur_function])
+	(&xf86info);
+
+    if (ConfigLoop(NULL) == True) {
+	XF86ModePtr prev = NULL, mod;
+
+	/* user may have changed the default depth, read variables again */
+	disp = screen->scrn_display_lst;
+	while (disp != NULL) {
+	    if (disp->disp_depth == default_depth)
+		break;
+	    disp = (XF86ConfDisplayPtr)(disp->list.next);
+	}
+
+	if (disp == NULL) {
+	    disp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec));
+	    screen->scrn_display_lst = (XF86ConfDisplayPtr)
+		xf86addListItem((GenericListPtr)(screen->scrn_display_lst),
+			    (GenericListPtr)(disp));
+	    disp->disp_depth = default_depth;
+	}
+
+	if (strcasecmp(screen->scrn_identifier, ident_string))
+	    xf86renameScreen(XF86Config, screen, ident_string);
+
+	screen->scrn_defaultdepth = default_depth;
+
+	XtSetArg(args[0], XtNlist, NULL);
+	XtSetArg(args[1], XtNnumberStrings, 0);
+	XtSetValues(listL, args, 2);
+
+	XtSetArg(args[0], XtNlist, NULL);
+	XtSetArg(args[1], XtNnumberStrings, 0);
+	XtSetValues(listR, args, 2);
+
+	mod = disp->disp_mode_lst;
+	/* free all modes */
+	while (mod != NULL) {
+	    prev = mod;
+	    mod = (XF86ModePtr)(mod->list.next);
+	    XtFree(prev->mode_name);
+	    XtFree((XtPointer)prev);
+	}
+	/* readd modes */
+	for (i = 0; i < ndefmodes; i++) {
+	    mod = XtNew(XF86ModeRec);
+	    mod->mode_name = XtNewString(defmodes[i]);
+	    XtFree(defmodes[i]);
+	    if (i == 0)
+		disp->disp_mode_lst = mod;
+	    else
+		prev->list.next = mod;
+	    prev = mod;
+	}
+	if (i == 0)
+	    disp->disp_mode_lst = NULL;
+	else
+	    mod->list.next = NULL;
+
+	XtFree((XtPointer)defmodes);
+	defmodes = NULL;
+	ndefmodes = 0;
+
+	for (i = 0; i < computer.num_screens; i++)
+	    if (computer.screens[i]->screen == screen)
+		computer.screens[i]->rotate = rotate;
+
+	if (oldrotate != rotate) {
+	    static char *Rotate = "Rotate";
+
+	    if (screen->scrn_option_lst != NULL)
+		xf86removeOption(&screen->scrn_option_lst, Rotate);
+	    if (rotate)
+		screen->scrn_option_lst =
+		    xf86addNewOption(screen->scrn_option_lst,
+				     XtNewString(Rotate),
+				     XtNewString(rotate > 0 ? "CW" : "CCW"));
+	    UpdateScreenUI();
+	    AdjustScreenUI();
+	}
+
+	return ((XtPointer)screen);
+    }
+
+    XtSetArg(args[0], XtNlist, NULL);
+    XtSetArg(args[1], XtNnumberStrings, 0);
+    XtSetValues(listL, args, 2);
+
+    XtSetArg(args[0], XtNlist, NULL);
+    XtSetArg(args[1], XtNnumberStrings, 0);
+    XtSetValues(listR, args, 2);
+
+    for (i = 0; i < ndefmodes; i++)
+	XtFree(defmodes[i]);
+    XtFree((XtPointer)defmodes);
+    defmodes = NULL;
+    ndefmodes = 0;
+
+    return (NULL);
+}
+
+/*ARGSUSED*/
+static void
+DepthCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    if (call_data != NULL)
+	default_depth = (long)user_data;
+}
+
+/*ARGSUSED*/
+static void
+SelectIndexCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XawListReturnStruct *info = (XawListReturnStruct *)call_data;
+
+    sel_index = info->list_index;
+}
+
+/*ARGSUSED*/
+static void
+UnselectIndexCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    XawListReturnStruct *info = (XawListReturnStruct *)call_data;
+
+    unsel_index = info->list_index;
+}
+
+/*ARGSUSED*/
+static void
+SelectCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    Arg args[2];
+
+    if (sel_index < 0 || sel_index >= nmodes)
+	return;
+
+    if (ndefmodes == 1 && *defmodes[0] == '\0') {
+	/* make sure tmp and defentries are not the same pointer */
+	char **tmp = defmodes;
+
+	XtFree(defmodes[0]);
+	defmodes = (char**)XtMalloc(sizeof(char*));
+	--ndefmodes;
+	XtFree((char*)tmp);
+    }
+    else
+	defmodes = (char**)XtRealloc((XtPointer)defmodes,
+				     sizeof(char*) * (ndefmodes + 1));
+    defmodes[ndefmodes++] = XtNewString(modes[sel_index]);
+
+    XtSetArg(args[0], XtNlist, defmodes);
+    XtSetArg(args[1], XtNnumberStrings, ndefmodes);
+    XtSetValues(listR, args, 2);
+
+    XawListUnhighlight(listR);
+    if (ndefmodes > 1 || (ndefmodes == 1 && *defmodes[0] != '\0')) {
+	if (unsel_index >= ndefmodes)
+	    unsel_index = ndefmodes - 1;
+	XawListHighlight(listR, unsel_index = ndefmodes - 1);
+    }
+    else
+	unsel_index = -1;
+
+    /* force realyout */
+    XtUnmanageChild(listR);
+    XtManageChild(listR);
+}
+
+/*ARGSUSED*/
+static void
+UnselectCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    Arg args[2];
+    char **modes;
+    Cardinal num_modes;
+
+    if (unsel_index < 0 || unsel_index >= ndefmodes)
+	return;
+
+    XawListUnhighlight(listL);
+    XtSetArg(args[0], XtNlist, &modes);
+    XtSetArg(args[1], XtNnumberStrings, &num_modes);
+    XtGetValues(listL, args, 2);
+    if (modes) {
+	for (sel_index = 0; sel_index < num_modes; sel_index++)
+	    if (strcmp(defmodes[unsel_index], modes[sel_index]) == 0)
+		break;
+	if (sel_index < num_modes)
+	    XawListHighlight(listL, sel_index);
+	else
+	    sel_index = -1;
+    }
+
+    XtFree(defmodes[unsel_index]);
+    if (--ndefmodes > unsel_index)
+	memmove(&defmodes[unsel_index], &defmodes[unsel_index + 1],
+		(ndefmodes - unsel_index) * sizeof(char*));
+    if (ndefmodes == 0) {
+	char **tmp = defmodes;
+
+	defmodes = (char**)XtMalloc(sizeof(char*));
+	defmodes[0] = XtNewString("");
+	ndefmodes = 1;
+	XtFree((char*)tmp);
+    }
+
+    XtSetArg(args[0], XtNlist, defmodes);
+    XtSetArg(args[1], XtNnumberStrings, ndefmodes);
+    XtSetValues(listR, args, 2);
+
+    XawListUnhighlight(listR);
+    if (ndefmodes > 1 || (ndefmodes == 1 && *defmodes[0] != '\0')) {
+	if (unsel_index >= ndefmodes)
+	    unsel_index = ndefmodes - 1;
+	XawListHighlight(listR, unsel_index);
+    }
+    else
+	unsel_index = -1;
+}
+
+/*ARGSUSED*/
+static void
+MoveCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    char *tmp;
+    Bool down = (long)user_data;
+
+    if (unsel_index < 0 || unsel_index >= ndefmodes)
+	return;
+
+    if ((down && unsel_index + 1 >= ndefmodes) ||
+	(!down && unsel_index - 1 < 0))
+	return;
+
+    tmp = defmodes[unsel_index];
+    if (down) {
+	defmodes[unsel_index] = defmodes[unsel_index + 1];
+	unsel_index++;
+    } else {
+	defmodes[unsel_index] = defmodes[unsel_index - 1];
+	unsel_index--;
+    }
+    defmodes[unsel_index] = tmp;
+
+    XawListUnhighlight(listR);
+    XawListHighlight(listR, unsel_index);
+}
+
+/*ARGSUSED*/
+void
+RotateCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+    if (call_data != NULL)
+	rotate = (long)user_data;
+    else
+	rotate = 0;
+}
+
+void
+ScreenDialog(XF86SetupInfo *info)
+{
+    static Widget dialog, d1, d4, d8, d16, d24, labelRotate, cw, ccw;
+    Arg args[2];
+    XF86ConfMonitorPtr mon = screen->scrn_monitor;
+    XF86ConfModeLinePtr mline = mon != NULL ? mon->mon_modeline_lst : NULL;
+    int i;
+#ifdef USE_MODULES
+    xf86cfgModuleOptions *drv_opts = module_options;
+    Bool foundRotate = False;
+#endif
+
+    while (nmodes > 0)
+	XtFree(modes[--nmodes]);
+    XtFree((XtPointer)modes);
+    modes = NULL;
+    while (mline) {
+	if (nmodes % 16 == 0)
+	    modes = (char**)XtRealloc((XtPointer)modes,
+				      sizeof(char*) * (nmodes + 16));
+	modes[nmodes++] = XtNewString(mline->ml_identifier);
+	mline = (XF86ConfModeLinePtr)(mline->list.next);
+    }
+    for (i = 0; i < sizeof(standard_modes) / sizeof(standard_modes[0]); i++) {
+	if (nmodes % 16 == 0)
+	    modes = (char**)XtRealloc((XtPointer)modes,
+				      sizeof(char*) * (nmodes + 16));
+	modes[nmodes++] = XtNewString(standard_modes[i]);
+    }
+
+    if (dialog == NULL) {
+	Widget command, viewport;
+
+	dialog = XtCreateWidget("screenD", formWidgetClass,
+				configp, NULL, 0);
+	XtCreateManagedWidget("depthL", labelWidgetClass,
+			      dialog, NULL, 0);
+	d1 = XtCreateManagedWidget("1", toggleWidgetClass, dialog, NULL, 0);
+	XtAddCallback(d1, XtNcallback, DepthCallback, (XtPointer)1);
+	d4 = XtVaCreateManagedWidget("4", toggleWidgetClass, dialog,
+				     XtNradioGroup, d1, NULL);
+	XtAddCallback(d4, XtNcallback, DepthCallback, (XtPointer)4);
+	d8 = XtVaCreateManagedWidget("8", toggleWidgetClass, dialog,
+				      XtNradioGroup, d4, NULL);
+	XtAddCallback(d8, XtNcallback, DepthCallback, (XtPointer)8);
+	d16 = XtVaCreateManagedWidget("16", toggleWidgetClass, dialog,
+				      XtNradioGroup, d8, NULL);
+	XtAddCallback(d16, XtNcallback, DepthCallback, (XtPointer)16);
+	d24 = XtVaCreateManagedWidget("24", toggleWidgetClass, dialog,
+				      XtNradioGroup, d16, NULL);
+	XtAddCallback(d24, XtNcallback, DepthCallback, (XtPointer)24);
+
+	XtCreateManagedWidget("modeL", labelWidgetClass, dialog, NULL, 0);
+	viewport = XtCreateManagedWidget("viewL", viewportWidgetClass, dialog,
+					 NULL, 0);
+	listL = XtCreateManagedWidget("listLeft", listWidgetClass, viewport,
+					NULL, 0);
+	XtAddCallback(listL, XtNcallback, SelectIndexCallback, NULL);
+	command = XtCreateManagedWidget("select", commandWidgetClass,
+					dialog, NULL, 0);
+	XtAddCallback(command, XtNcallback, SelectCallback, NULL);
+	command = XtCreateManagedWidget("unselect", commandWidgetClass,
+					dialog, NULL, 0);
+	XtAddCallback(command, XtNcallback, UnselectCallback, NULL);
+	command = XtCreateManagedWidget("up", commandWidgetClass,
+					dialog, NULL, 0);
+	XtAddCallback(command, XtNcallback, MoveCallback, (XtPointer)False);
+	command = XtCreateManagedWidget("down", commandWidgetClass,
+					dialog, NULL, 0);
+	XtAddCallback(command, XtNcallback, MoveCallback, (XtPointer)True);
+	viewport = XtCreateManagedWidget("viewR", viewportWidgetClass, dialog,
+					 NULL, 0);
+	listR = XtCreateManagedWidget("listRight", listWidgetClass, viewport,
+				      NULL, 0);
+	XtAddCallback(listR, XtNcallback, UnselectIndexCallback, NULL);
+
+	labelRotate = XtCreateManagedWidget("rotate", labelWidgetClass,
+					    dialog, NULL, 0);
+	cw = XtCreateManagedWidget("CW", toggleWidgetClass, dialog, NULL, 0);
+	XtAddCallback(cw, XtNcallback, RotateCallback, (XtPointer)CW);
+	ccw = XtVaCreateManagedWidget("CCW", toggleWidgetClass, dialog,
+				      XtNradioGroup, cw, NULL);
+	XtAddCallback(ccw, XtNcallback, RotateCallback, (XtPointer)CCW);
+
+	XtRealizeWidget(dialog);
+    }
+
+#ifdef USE_MODULES
+    if (!nomodules) {
+	while (drv_opts) {
+	    if (drv_opts->type == VideoModule &&
+		strcmp(drv_opts->name, screen->scrn_device->dev_driver) == 0) {
+		OptionInfoPtr opts = drv_opts->option;
+
+		while (opts->name) {
+		    if (xf86nameCompare(opts->name, "Rotate") == 0) {
+			foundRotate = True;
+			break;
+		    }
+		    opts++;
+		}
+		break;
+	    }
+	    drv_opts = drv_opts->next;
+	}
+
+	if (!foundRotate) {
+	    XtUnmapWidget(labelRotate);
+	    XtUnmapWidget(cw);
+	    XtUnmapWidget(ccw);
+	}
+	else {
+	    XtMapWidget(labelRotate);
+	    XtMapWidget(cw);
+	    XtMapWidget(ccw);
+	}
+    }
+#else
+    (void)labelRotate;
+#endif
+    if (rotate == CW) {
+	XtVaSetValues(cw, XtNstate, True, NULL);
+	XtVaSetValues(ccw, XtNstate, False, NULL);
+    }
+    else if (rotate == CCW) {
+	XtVaSetValues(cw, XtNstate, False, NULL);
+	XtVaSetValues(ccw, XtNstate, True, NULL);
+    }
+    else {
+	XtVaSetValues(cw, XtNstate, False, NULL);
+	XtVaSetValues(ccw, XtNstate, False, NULL);
+    }
+
+    XtSetArg(args[0], XtNlist, modes);
+    XtSetArg(args[1], XtNnumberStrings, nmodes);
+    XtSetValues(listL, args, 2);
+
+    XtSetArg(args[0], XtNlist, defmodes);
+    XtSetArg(args[1], XtNnumberStrings, ndefmodes);
+    XtSetValues(listR, args, 2);
+
+    XtSetArg(args[0], XtNstate, True);
+    XtSetValues(default_depth == 1 ? d1 :
+		default_depth == 4 ? d4 :
+		default_depth == 16 ? d16 :
+		default_depth == 24 ? d24 : d8, args, 1);
+
+    XtChangeManagedSet(&current, 1, NULL, NULL, &dialog, 1);
+    current = dialog;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo C�sar Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c,v 1.7 2002/01/07 20:38:29 dawes Exp $
+ */
+
+#include "config.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+
+/*
+ * Initialization
+ */
+static int xpid;
+Display *DPY;
+
+/*
+ * Implementation
+ */
+Bool
+startx(void)
+{
+    int timeout = 8;
+#ifdef sun
+    const char *filename;
+#endif
+
+    if (getenv("DISPLAY") != NULL)
+	/* already running Xserver */
+	return (False);
+
+#ifdef sun
+    /* If there exits any config file, including .xorg.conf, use it. */ 
+    if ((filename = xf86openConfigFile(getuid() == 0 ? CONFPATH : USER_CONFPATH,
+				       XF86Config_path, NULL)) == NULL) {
+	int length = XF86Config_path ? strlen(XF86Config_path) : -1;
+
+	if (length > 2 &&
+	    XF86Config_path[length - 2] == '-' &&
+	    XF86Config_path[length - 1] == '4') {
+	    XF86Config_path[length - 2] = '\0';
+	    filename = xf86openConfigFile(getuid() == 0 ?
+					  CONFPATH : USER_CONFPATH,
+					  XF86Config_path, NULL);
+	}
+    }
+    XF86Config_path = (char *)filename;
+#endif
+
+    if (XF86Config_path == NULL) {
+	char *home, filename[PATH_MAX];
+	char commandline[PATH_MAX * 4];
+	int c_pos;
+	int len;
+	/* 
+	 * The name of the 4.0 binary is XFree86. X might also
+	 * be the name of the 3.3 binary. Therefore don't change
+	 * name to 'X'.
+	 */
+	if (XFree86_path)
+	    c_pos = XmuSnprintf(commandline, sizeof(commandline),
+				"%s/"__XSERVERNAME__" :8 -configure ",XFree86_path);
+	else
+	    c_pos = XmuSnprintf(commandline, sizeof(commandline), 
+				"%s/bin/"__XSERVERNAME__" :8 -configure ", XFree86Dir);
+	if (XF86Module_path && ((len = sizeof(commandline) - c_pos) > 0))
+	    c_pos += XmuSnprintf(commandline + c_pos,len,
+				 " -modulepath %s",XF86Module_path);
+	if (XF86Font_path && ((len = sizeof(commandline) - c_pos) > 0))
+	    c_pos += XmuSnprintf(commandline + c_pos,len,
+				 " -fontpath %s",XF86Font_path);
+	if (XF86RGB_path && ((len = sizeof(commandline) - c_pos) > 0))
+	    c_pos += XmuSnprintf(commandline + c_pos,len,
+				 " -rgbpath %s",XF86RGB_path);
+	
+	if (system(commandline) != 0) {
+	    fprintf(stderr, "Failed to run \"X -configure\".\n");
+	    exit(1);
+	}
+
+	if ((home = getenv("HOME")) == NULL)
+	    home = "/";
+
+#ifndef QNX4
+	XmuSnprintf(filename, sizeof(filename), "%s/"__XCONFIGFILE__".new", home);
+#else
+	XmuSnprintf(filename, sizeof(filename), "//%d%s/"__XCONFIGFILE__".new",
+		    getnid(), home);
+#endif
+
+	/* this memory is never released, even if the value of XF86Config_path is
+	 * changed.
+	 */
+	XF86Config_path = XtNewString(filename);
+    }
+
+    putenv("DISPLAY=:8");
+
+    switch (xpid = fork()) {
+	case 0: {
+	    char path[PATH_MAX];
+	    char *filename, *p;
+	    /* Don't change to X! see above */
+	    if (XFree86_path)
+	        XmuSnprintf(path, sizeof(path), "%s/"__XSERVERNAME__, XFree86_path);
+	    else
+	        XmuSnprintf(path, sizeof(path), "%s/bin/"__XSERVERNAME__, XFree86Dir);
+	    if (getuid() == 0) 
+	    	execl(path, "X", ":8", /*"+xinerama",*/ "+accessx",
+			"-allowMouseOpenFail", 
+			"-xf86config", XF86Config_path, (void *)NULL);
+	    else {
+		/* Use relative path for non-root users */
+		filename = XF86Config_path;
+		while (p = strchr(filename, '/'))
+        		filename = p + 1;
+	    	execl(path, "X", ":8", /*"+xinerama",*/ "+accessx",
+			"-allowMouseOpenFail", 
+			"-xf86config", filename, (void *)NULL);
+	    }
+	    exit(-127);
+	}   break;
+	case -1:
+	    fprintf(stderr, "Cannot fork.\n");
+	    exit(1);
+	    break;
+	default:
+	    break;
+    }
+
+    while (timeout > 0) {
+	int status;
+
+	sleep(timeout -= 2);
+	if (waitpid(xpid, &status, WNOHANG | WUNTRACED) == xpid)
+	    break;
+	else {
+	    DPY = XOpenDisplay(NULL);
+	    if (DPY != NULL)
+		break;
+	}
+    }
+
+    if (DPY == NULL) {
+	fprintf(stderr, "Cannot connect to X server.\n");
+	exit(1);
+    }
+
+    return (True);
+}
+
+void
+endx(void)
+{
+    if (xpid != 0)
+	kill(xpid, SIGTERM);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/text-mode.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,3418 @@
+/* $XdotOrg: $ */
+/*
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * 
+ * 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
+ * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of Conectiva Linux shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Conectiva Linux.
+ *
+ * Author: Paulo César Pereira de Andrade <[email protected]>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/text-mode.c,v 1.25 2003/11/12 00:10:30 dawes Exp $
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#if defined(__SCO__) || defined(__UNIXWARE__) || \
+	(defined(sun) && defined(__SVR4))
+#include <curses.h>
+#else
+#include <ncurses.h>
+#endif
+#include <ctype.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBrules.h>
+#include "cards.h"
+#include "config.h"
+#include "xf86config.h"
+#include "loader.h"
+
+#define IS_KBDDRIV(X) ((strcmp((X),"kbd") == 0) || \
+	(strcmp((X), "keyboard") == 0))
+
+#ifndef PROJECT_ROOT
+#define PROJECT_ROOT "/usr/X11R6"
+#endif
+
+#ifndef __UNIXOS2__
+#define XKB_RULES_DIR PROJECT_ROOT "/lib/X11/xkb/rules"
+#else
+#define XKB_RULES_DIR XF86CONFIGDIR "/xkb/rules"
+#endif
+
+#define CONTROL_A	1
+#define CONTROL_D	4
+#define CONTROL_E	5
+#define CONTROL_K	11
+#define TAB	9
+#define	MIN(a, b)	((a) < (b) ? (a) : (b))
+#define	MAX(a, b)	((a) > (b) ? (a) : (b))
+
+void TextMode(void);
+
+static void ClearScreen(void);
+static void PaintWindow(WINDOW*, char*, int, int, int, int);
+static void PaintBox(WINDOW*, int, int, int, int);
+static void PaintButton(WINDOW*, char*, int, int, int);
+static void PrintWrap(WINDOW*, char*, int, int, int);
+static int Dialog(char*, char*, int, int, char*, char*, int);
+static void PaintItem(WINDOW*, char*, int, int);
+static int DialogMenu(char*, char*, int, int, int, int, char**, char*, char*, int);
+static void PaintCheckItem(WINDOW*, char*, int, int, int);
+static int DialogCheckBox(char*, char*, int, int, int, int, char**, char*, char*, char*);
+static char *DialogInput(char*, char*, int, int, char*, char*, char*, int);
+static void PaintScroller(WINDOW*, int, int, int);
+
+static int MouseConfig(void);
+static int KeyboardConfig(void);
+static int MonitorConfig(void);
+static int CardConfig(void);
+static int ScreenConfig(void);
+static int LayoutConfig(void);
+static int WriteXF86Config(void);
+
+static XF86ConfLayoutPtr CopyLayout(XF86ConfLayoutPtr);
+static XF86ConfAdjacencyPtr CopyAdjacency(XF86ConfAdjacencyPtr);
+static XF86ConfInputrefPtr CopyInputref(XF86ConfInputrefPtr);
+static XF86ConfInactivePtr CopyInactive(XF86ConfInactivePtr);
+static void FreeLayout(XF86ConfLayoutPtr);
+
+extern int string_to_parser_range(char*, parser_range*, int);
+#define PARSER_RANGE_SIZE	256
+/* string must have at least 256 bytes */
+extern int parser_range_to_string(char*, parser_range*, int);
+
+static Bool newconfig;
+
+static chtype screen_attr = A_NORMAL;
+static chtype dialog_attr = A_REVERSE;
+static chtype highlight_border_attr = A_REVERSE;
+static chtype shadow_border_attr = A_REVERSE;
+static chtype title_attr = A_NORMAL;
+static chtype button_active_attr = A_NORMAL;
+static chtype button_inactive_attr = A_NORMAL;
+static int menu_width, item_x;
+static char Edit[] = "Edit ";
+
+static char *main_menu[] = {
+#define	CONF_MOUSE	0
+    "Configure mouse",
+#define	CONF_KEYBOARD	1
+    "Configure keyboard",
+#define	CONF_MONITOR	2
+    "Configure monitor",
+#define	CONF_CARD	3
+    "Configure card",
+#define	CONF_SCREEN	4
+    "Configure screen",
+#define	CONF_LAYOUT	5
+    "Configure layout",
+#define	CONF_FINISH	6
+    "Write "__XCONFIGFILE__" and quit",
+#define	CONF_QUIT	7
+    "Quit",
+};
+
+void
+TextMode(void)
+{
+    static int first = 1;
+    int i, choice = CONF_MOUSE;
+
+#ifdef USE_MODULES
+    if (!nomodules)
+	LoaderInitializeOptions();
+#endif
+    initscr();
+    noecho();
+    nonl();
+    keypad(stdscr, TRUE);
+
+    if (first) {
+	const char *filename;
+
+	first = 0;
+
+	if (has_colors()) {
+	    start_color();
+	    init_pair(1, COLOR_BLACK, COLOR_BLACK);
+	    screen_attr = A_BOLD | COLOR_PAIR(1);
+
+	    init_pair(2, COLOR_BLACK, COLOR_WHITE);
+	    dialog_attr = COLOR_PAIR(2);
+
+	    init_pair(3, COLOR_BLACK, COLOR_WHITE);
+	    shadow_border_attr = A_BOLD | COLOR_PAIR(3);
+
+	    init_pair(4, COLOR_WHITE, COLOR_WHITE);
+	    highlight_border_attr = A_BOLD | COLOR_PAIR(4);
+
+	    init_pair(5, COLOR_WHITE, COLOR_BLUE);
+	    title_attr = A_BOLD | COLOR_PAIR(5);
+	    button_active_attr = title_attr;
+
+	    init_pair(6, COLOR_WHITE, COLOR_BLACK);
+	    button_inactive_attr = A_BOLD | COLOR_PAIR(6);
+	}
+
+	if ((filename = xf86openConfigFile(getuid() == 0 ?
+					   CONFPATH : USER_CONFPATH,
+					   XF86Config_path, NULL)) != NULL) {
+	    XF86Config_path = (char *)filename;
+	    if ((XF86Config = xf86readConfigFile()) == NULL) {
+		ClearScreen();
+		refresh();
+		Dialog("Configuration error",
+		       "Error parsing configuration file.",
+		       7, 50, "  Ok  ", NULL, 0);
+	    }
+	}
+	if (XF86Config == NULL) {
+	    XF86Config = (XF86ConfigPtr)XtCalloc(1, sizeof(XF86ConfigRec));
+	    newconfig = True;
+	}
+	else
+	    newconfig = False;
+    }
+
+    ClearScreen();
+    refresh();
+
+    /*CONSTCOND*/
+    while (1) {
+	int cancel = FALSE;
+
+	ClearScreen();
+	refresh();
+	if (Dialog( __XSERVERNAME__" Configuration",
+		   "This program will create the "__XCONFIGFILE__" file, based on "
+		   "menu selections you make.\n"
+		   "\n"
+#if defined(__SCO__) || defined(__UNIXWARE__)
+		   "The "__XCONFIGFILE__" file usually resides in /etc. A "
+		   "sample "__XCONFIGFILE__" file is supplied with "
+#else
+#ifndef __UNIXOS2__
+		   "The "__XCONFIGFILE__" file usually resides in /usr/X11R6/etc/X11 "
+#else
+		   "The "__XCONFIGFILE__" file usually resides in "XF86CONFIGDIR" "
+#endif
+		   "or /etc/X11. A sample "__XCONFIGFILE__" file is supplied with "
+#endif
+		   __XSERVERNAME__"; it is configured for a standard VGA card and "
+		   "monitor with 640x480 resolution. This program will ask for "
+		   "a pathname when it is ready to write the file.\n"
+		   "\n"
+		   "You can either take the sample "__XCONFIGFILE__" as a base and "
+		   "edit it for your configuration, or let this program "
+		   "produce a base "__XCONFIGFILE__" file for your configuration and "
+		   "fine-tune it.",
+		   20, 60, "   Ok   ", " Cancel ", 0) != 0)
+	    break;
+
+	    while (!cancel) {
+		ClearScreen();
+		refresh();
+		switch (DialogMenu("Main menu",
+				   "Choose one of the options:",
+				   17, 60, 8, sizeof(main_menu) /
+				   sizeof(main_menu[0]), main_menu,
+				   "   Ok   ", " Cancel ", choice)) {
+		    case CONF_MOUSE:
+			i = MouseConfig();
+			if (i > 0 && choice == CONF_MOUSE)
+			    choice = CONF_KEYBOARD;
+			else if (i == 0)
+			    choice = CONF_MOUSE;
+			break;
+		    case CONF_KEYBOARD:
+			i = KeyboardConfig();
+			if (i > 0 && choice <= CONF_KEYBOARD)
+			    choice = CONF_MONITOR;
+			else if (i == 0)
+			    choice = CONF_KEYBOARD;
+			break;
+		    case CONF_MONITOR:
+			i = MonitorConfig();
+			if (i > 0 && choice <= CONF_MONITOR)
+			    choice = CONF_CARD;
+			else if (i == 0)
+			    choice = CONF_MONITOR;
+			break;
+		    case CONF_CARD:
+			i = CardConfig();
+			if (i > 0 && choice <= CONF_CARD)
+			    choice = CONF_SCREEN;
+			else if (i == 0)
+			    choice = CONF_CARD;
+			break;
+		    case CONF_SCREEN:
+			i = ScreenConfig();
+			if (i > 0 && choice <= CONF_SCREEN)
+			    choice = CONF_LAYOUT;
+			else if (i == 0)
+			    choice = CONF_SCREEN;
+			break;
+		    case CONF_LAYOUT:
+			i = LayoutConfig();
+			if (i > 0 && choice <= CONF_LAYOUT)
+			    choice = CONF_FINISH;
+			else if (i == 0)
+			    choice = CONF_LAYOUT;
+			break;
+		    case CONF_FINISH:
+			if (WriteXF86Config() < 0)
+			    break;
+		    /*FALLTROUGH*/
+		    case CONF_QUIT:
+			endwin();
+			exit(0);
+		    default:
+			cancel = TRUE;
+			break;
+		}
+	}
+    }
+
+    endwin();
+}
+
+static int
+WriteXF86Config(void)
+{
+    char *xf86config;
+#ifdef sun
+    char *p;
+#endif
+
+    ClearScreen();
+    refresh();
+
+#ifdef sun
+    /* If .xorg.conf in the path, replace it with xorg.conf */
+    if (p = strstr(XF86Config_path, ".xorg.conf")) {
+	strncpy(p, "xorg.conf", strlen("xorg.conf"));
+	p[strlen("xorg.conf")] = '\0';
+    }
+#endif
+
+    xf86config = DialogInput("Write "__XCONFIGFILE__, "Write configuration to file:",
+			     10, 60, XF86Config_path ? XF86Config_path :
+#ifndef __UNIXOS2__
+			     "/etc/X11/"__XCONFIGFILE__, "  Ok  ", " Cancel ", 0);
+#else
+			     XF86CONFIGDIR"/"__XCONFIGFILE__, "  Ok  ", " Cancel ", 0);
+#endif
+
+    if (xf86config == NULL)
+	return (-1);
+
+    if (newconfig) {
+	if (XF86Config->conf_modules == NULL) {
+	    static char *modules[] = {"extmod", "glx", "dri", "dbe",
+				      "record", "xtrap", "type1", "speedo"};
+	    XF86LoadPtr load;
+	    int i;
+
+	    XF86Config->conf_modules = (XF86ConfModulePtr)
+		XtCalloc(1, sizeof(XF86ConfModuleRec));
+
+	    XF86Config->conf_modules->mod_comment =
+		XtNewString("\tLoad \"freetype\"\n"
+			    "\t# Load \"xtt\"\n");
+
+	    for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
+		load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec));
+		load->load_name = XtNewString(modules[i]);
+		XF86Config->conf_modules->mod_load_lst =
+		    xf86addModule(XF86Config->conf_modules->mod_load_lst, load);
+	    }
+	}
+    }
+
+    if (!xf86writeConfigFile(xf86config, XF86Config)) {
+	char msg[1024];
+
+	XmuSnprintf(msg, sizeof(msg), "Failed to write configuration file %s.",
+		   xf86config);
+	ClearScreen();
+	refresh();
+	(void)Dialog("Write failed!", msg, 8, 60, "  Ok  ", NULL, 0);
+	XtFree(xf86config);
+	return (-1);
+    }
+    XtFree(xf86config);
+
+    return (1);
+}
+
+static char *protocols[] = {
+#ifdef __UNIXOS2__
+    "OS2Mouse",
+#endif
+#ifdef __SCO__
+    "OsMouse",
+#endif
+#ifdef __UNIXWARE__
+    "Xqueue",
+#endif
+#ifdef WSCONS_SUPPORT
+    "wsmouse",
+#endif
+    "Auto",
+    "SysMouse",
+    "MouseSystems",
+    "BusMouse",
+    "PS/2",
+    "Microsoft",
+#ifndef __FreeBSD__
+    "ImPS/2",
+    "ExplorerPS/2",
+    "GlidePointPS/2",
+    "MouseManPlusPS/2",
+    "NetMousePS/2",
+    "NetScrollPS/2",
+    "ThinkingMousePS/2",
+#endif
+    "AceCad",
+    "GlidePoint",
+    "IntelliMouse",
+    "Logitech",
+    "MMHitTab",
+    "MMSeries",
+    "MouseMan",
+    "ThinkingMouse",
+};
+
+static int
+MouseConfig(void)
+{
+    int i, nlist, def, proto, emul;
+    char **list = NULL, *device, *str;
+    XF86ConfInputPtr *inputs = NULL;
+    XF86ConfInputPtr input = XF86Config->conf_input_lst;
+    XF86OptionPtr option;
+
+    nlist = 0;
+    while (input) {
+	if (strcmp(input->inp_driver, "mouse") == 0) {
+	    list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	    list[nlist] = XtMalloc(sizeof(Edit) +
+				   strlen(input->inp_identifier) + 1);
+	    sprintf(list[nlist], "%s%s", Edit, input->inp_identifier);
+	    inputs = (XF86ConfInputPtr*)XtRealloc((XtPointer)inputs, (nlist + 1) *
+					sizeof(XF86ConfInputPtr));
+	    inputs[nlist] = input;
+	    ++nlist;
+	}
+	input = (XF86ConfInputPtr)(input->list.next);
+    }
+
+    input = NULL;
+
+    if (nlist) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*));
+	list[nlist++] = XtNewString("Add new mouse");
+	if (nlist == 2) {
+	    i = strlen("Remove ") + strlen(inputs[0]->inp_identifier) + 1;
+	    list[nlist] = XtMalloc(i);
+	    XmuSnprintf(list[nlist], i, "Remove %s", inputs[0]->inp_identifier);
+	    ++nlist;
+	}
+	else
+	    list[nlist++] = XtNewString("Remove mouse");
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Mouse configuration",
+		       "You can edit or remove a previously configured mouse, "
+		       "or add a new one.", 14, 60, 4, nlist, list,
+		       " Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)inputs);
+	    return (-1);
+	}
+	if (nlist > 2 && i == nlist - 1) {
+	    if (nlist > 3) {
+		for (i = 0; i < nlist - 2; i++) {
+		    /* XXX Remove the "Edit " from list entries */
+		    memmove(list[i], list[i] + sizeof(Edit) - 1,
+			    strlen(list[i]) - sizeof(Edit) + 2);
+		}
+		ClearScreen();
+		refresh();
+		i = DialogMenu("Remove mouse",
+			       "Select which mouse to remove",
+			       13, 60, 4, nlist - 2, list,
+			       " Remove ", " Cancel ", 0);
+		if (i < 0) {
+		    for (i = 0; i < nlist; i++)
+			XtFree(list[i]);
+		    XtFree((XtPointer)list);
+		    XtFree((XtPointer)inputs);
+		    return (-1);
+		}
+		input = inputs[i];
+	    }
+	    else
+		input = inputs[0];
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)inputs);
+	    xf86removeInput(XF86Config, input);
+	    return (0);
+	}
+	if (i < nlist - 2)
+	    input = inputs[i];
+    }
+    for (i = 0; i < nlist; i++)
+	XtFree(list[i]);
+    XtFree((XtPointer)list);
+    XtFree((XtPointer)inputs);
+
+    if (input == NULL) {
+	char label[32];
+
+	input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec));
+	XmuSnprintf(label, sizeof(label), "Mouse%d", nlist ? nlist - 2 : 0);
+	ClearScreen();
+	refresh();
+	input->inp_identifier =
+	    DialogInput("Mouse identifier",
+			"Enter an identifier for your mouse definition:",
+			11, 40, label,
+			" Next >>", " Cancel ", 0);
+	if (input->inp_identifier == NULL) {
+	    XtFree((XtPointer)input);
+	    return (-1);
+	}
+    }
+
+    def = 0;
+    option = xf86findOption(input->inp_option_lst, "Protocol");
+    if (option)
+	for (i = 0; i < sizeof(protocols)/sizeof(protocols[0]); i++)
+	    if (strcasecmp(option->opt_val, protocols[i]) == 0) {
+		def = i;
+		break;
+	    }
+
+    ClearScreen();
+    refresh();
+    i = DialogMenu("Select mouse protocol",
+		   "If you have a serial mouse, it probably will work with "
+		   "the \"Auto\" protocol. But, if it is an old serial "
+		   "mouse probably it is not PNP; in that case, most serial "
+		   "mouses understand the \"Microsoft\" protocol.",
+		   19, 60, 7, sizeof(protocols) /
+		   sizeof(protocols[0]), protocols, " Next >>", " Cancel ", def);
+    if (i < 0) {
+	if (input->inp_driver == NULL) {
+	    XtFree(input->inp_driver);
+	    XtFree((XtPointer)input);
+	}
+	return (i);
+    }
+    proto = i;
+
+    def = 0;
+    if (input->inp_driver) {
+	option = xf86findOption(input->inp_option_lst, "Emulate3Buttons");
+	def = option ? 0 : 1;
+    }
+    ClearScreen();
+    refresh();
+    i = Dialog("Mouse 3 buttons emulation",
+	       "If your mouse has only two buttons, it is recommended that "
+	       "you enable Emulate3Buttons.\n"
+	       "\n"
+	       "Do you want to enable Emulate3Buttons?",
+	       10, 60, " Yes ", " No ", def);
+    if (i < 0)
+	return (i);
+    emul = !i;
+
+    str = NULL;
+    option = xf86findOption(input->inp_option_lst, "Device");
+    if (option)
+	str = option->opt_val;
+    if (str == NULL)
+#ifdef WSCONS_SUPPORT
+	str = "/dev/wsmouse";
+#elif defined(__FreeBSD__)
+	str = "/dev/sysmouse";
+#elif defined(__UNIXOS2__)
+	str = "mouse$";
+#else
+	str = "/dev/mouse";
+#endif
+
+    ClearScreen();
+    refresh();
+    device = DialogInput("Select mouse device",
+		       "Enter mouse device:", 10, 40, str,
+		       " Finish ", " Cancel ", 0);
+    if (device == NULL) {
+	if (input->inp_driver == NULL) {
+	    XtFree(input->inp_driver);
+	    XtFree((XtPointer)input);
+	}
+	return (-1);
+    }
+
+    /* Finish mouse configuration */
+    option = xf86findOption(input->inp_option_lst, "Protocol");
+    if (option) {
+	XtFree((XtPointer)option->opt_val);
+	option->opt_val = XtNewString(protocols[proto]);
+    }
+    else
+	input->inp_option_lst = xf86addNewOption(input->inp_option_lst,
+		XtNewString("Protocol"), XtNewString(protocols[proto]));
+
+    option = xf86findOption(input->inp_option_lst, "Emulate3Buttons");
+    if (option && !emul) {
+	xf86removeOption(&input->inp_option_lst, "Emulate3Buttons");
+    }
+    else if (option == NULL && emul)
+	input->inp_option_lst = xf86addNewOption(input->inp_option_lst,
+		XtNewString("Emulate3Buttons"), NULL);
+
+    option = xf86findOption(input->inp_option_lst, "Device");
+    if (option) {
+	XtFree((XtPointer)option->opt_val);
+	option->opt_val = device;
+    }
+    else
+	input->inp_option_lst = xf86addNewOption(input->inp_option_lst,
+		XtNewString("Device"), device);
+
+    if (input->inp_driver == NULL) {
+	input->inp_driver = XtNewString("mouse");
+	XF86Config->conf_input_lst =
+	    xf86addInput(XF86Config->conf_input_lst, input);
+    }
+
+    return (1);
+}
+
+static int
+KeyboardConfig(void)
+{
+    int i;
+    char *rulesfile;
+    static int first = 1;
+    static XkbRF_RulesPtr rules;
+    static char **models, **layouts;
+    XF86ConfInputPtr *inputs = NULL, input = XF86Config->conf_input_lst;
+    char **list = NULL, *model, *layout;
+    int nlist, def;
+    XF86OptionPtr option;
+
+    nlist = 0;
+    while (input) {
+	if (IS_KBDDRIV(input->inp_driver)) {
+	    list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	    list[nlist] = XtMalloc(sizeof(Edit) +
+				   strlen(input->inp_identifier) + 1);
+	    sprintf(list[nlist], "%s%s", Edit, input->inp_identifier);
+	    inputs = (XF86ConfInputPtr*)XtRealloc((XtPointer)inputs, (nlist + 1) *
+					sizeof(XF86ConfInputPtr));
+	    inputs[nlist] = input;
+	    ++nlist;
+	}
+	input = (XF86ConfInputPtr)(input->list.next);
+    }
+
+    input = NULL;
+
+    if (nlist) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*));
+	list[nlist++] = XtNewString("Add new keyboard");
+	if (nlist == 2) {
+	    i = strlen("Remove ") + strlen(inputs[0]->inp_identifier) + 1;
+	    list[nlist] = XtMalloc(i);
+	    XmuSnprintf(list[nlist], i, "Remove %s", inputs[0]->inp_identifier);
+	    ++nlist;
+	}
+	else
+	    list[nlist++] = XtNewString("Remove keyboard");
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Keyboard configuration",
+		       "You can edit or remove a previously configured "
+		       "keyboard, or add a new one.", 14, 60, 4, nlist, list,
+		       " Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)inputs);
+	    return (-1);
+	}
+	if (nlist > 2 && i == nlist - 1) {
+	    if (nlist > 3) {
+		for (i = 0; i < nlist - 2; i++) {
+		    /* XXX Remove the "Edit " from list entries */
+		    memmove(list[i], list[i] + sizeof(Edit) - 1,
+			    strlen(list[i]) - sizeof(Edit) + 2);
+		}
+		ClearScreen();
+		refresh();
+		i = DialogMenu("Remove keyboard",
+			       "Select which keyboard to remove",
+			       13, 60, 4, nlist - 2, list,
+			       " Remove ", " Cancel ", 0);
+		if (i < 0) {
+		    for (i = 0; i < nlist; i++)
+			XtFree(list[i]);
+		    XtFree((XtPointer)list);
+		    XtFree((XtPointer)inputs);
+		    return (-1);
+		}
+		input = inputs[i];
+	    }
+	    else
+		input = inputs[0];
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)inputs);
+	    xf86removeInput(XF86Config, input);
+	    return (0);
+	}
+	if (i < nlist - 2)
+	    input = inputs[i];
+    }
+    for (i = 0; i < nlist; i++)
+	XtFree(list[i]);
+    XtFree((XtPointer)list);
+    XtFree((XtPointer)inputs);
+
+    if (input == NULL) {
+	char label[32];
+
+	input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec));
+	XmuSnprintf(label, sizeof(label), "Keyboard%d", nlist ? nlist - 2 : 0);
+	ClearScreen();
+	refresh();
+	input->inp_identifier =
+	    DialogInput("Keyboard identifier",
+			"Enter an identifier for your keyboard definition:",
+			11, 40, label,
+			" Next >>", " Cancel ", 0);
+	if (input->inp_identifier == NULL) {
+	    XtFree((XtPointer)input);
+	    return (-1);
+	}
+    }
+
+    if (first) {
+	first = 0;
+#ifdef XFREE98_XKB
+	rulesfile = XKB_RULES_DIR "/xfree98";
+#else
+	rulesfile = XKB_RULES_DIR "/"__XKBDEFRULES__;
+#endif
+	rules = XkbRF_Load(rulesfile, "", True, False);
+	if (rules == NULL) {
+	    ClearScreen();
+	    refresh();
+	    Dialog("Configuration error",
+		   "XKB rules file not found.\n"
+		   "\n"
+		   "Keyboard XKB options will be set to default values.",
+		   10, 50, "  Ok  ", NULL, 0);
+	    if (input->inp_driver == NULL) {
+		input->inp_option_lst =
+		    xf86addNewOption(input->inp_option_lst,
+			XtNewString("XkbModel"), XtNewString("pc101"));
+		input->inp_option_lst =
+		    xf86addNewOption(input->inp_option_lst,
+			XtNewString("XkbLayout"), XtNewString("us"));
+#if defined(USE_DEPRECATED_KEYBOARD_DRIVER)
+		input->inp_driver = XtNewString("keyboard");
+#else
+		input->inp_driver = XtNewString("kbd");
+#endif
+		XF86Config->conf_input_lst =
+		    xf86addInput(XF86Config, input);
+	    }
+	    return (0);
+	}
+	models = (char**)XtMalloc(sizeof(char*) * rules->models.num_desc);
+	for (i = 0; i < rules->models.num_desc; i++)
+	    models[i] = XtNewString(rules->models.desc[i].desc);
+	layouts = (char**)XtMalloc(sizeof(char*) * rules->layouts.num_desc);
+	for (i = 0; i < rules->layouts.num_desc; i++)
+	    layouts[i] = XtNewString(rules->layouts.desc[i].desc);
+    }
+    else if (rules == NULL)
+	return (-1);
+
+    def = 0;
+    option = xf86findOption(input->inp_option_lst, "XkbModel");
+    if (option) {
+	for (i = 0; i < rules->models.num_desc; i++)
+	    if (strcasecmp(option->opt_val, rules->models.desc[i].name) == 0) {
+		def = i;
+		break;
+	    }
+    }
+    ClearScreen();
+    refresh();
+    i = DialogMenu("Keyboard model",
+		   "Please select one of the following keyboard types that is "
+		   "the better description of your keyboard. If nothing really "
+		   "matches, choose \"Generic 101-key PC\".\n",
+		   20, 60, 9, rules->models.num_desc,
+		   models, " Next >>", " Cancel ", def);
+    if (i < 0)
+	return (i);
+    model = rules->models.desc[i].name;
+
+    def = 0;
+    option = xf86findOption(input->inp_option_lst, "XkbLayout");
+    if (option) {
+	for (i = 0; i < rules->layouts.num_desc; i++)
+	    if (strcasecmp(option->opt_val, rules->layouts.desc[i].name) == 0) {
+		def = i;
+		break;
+	    }
+    }
+    ClearScreen();
+    refresh();
+    i = DialogMenu("Keyboard layout",
+	 	   "Select keyboard layout:",
+		   20, 60, 11, rules->layouts.num_desc,
+		   layouts, " Finish ", " Cancel ", def);
+    if (i < 0)
+	return (i);
+    layout = rules->layouts.desc[i].name;
+
+    /* Finish keyboard configuration */
+    option = xf86findOption(input->inp_option_lst, "XkbModel");
+    if (option) {
+	XtFree((XtPointer)option->opt_val);
+	option->opt_val = XtNewString(model);
+    }
+    else
+	input->inp_option_lst = xf86addNewOption(input->inp_option_lst,
+		XtNewString("XkbModel"), XtNewString(model));
+
+    option = xf86findOption(input->inp_option_lst, "XkbLayout");
+    if (option) {
+	XtFree((XtPointer)option->opt_val);
+	option->opt_val = XtNewString(layout);
+    }
+    else
+	input->inp_option_lst = xf86addNewOption(input->inp_option_lst,
+		XtNewString("XkbLayout"), XtNewString(layout));
+
+    if (input->inp_driver == NULL) {
+#if defined(USE_DEPRECATED_KEYBOARD_DRIVER)
+	input->inp_driver = XtNewString("keyboard");
+#else
+	input->inp_driver = XtNewString("kbd");
+#endif
+	XF86Config->conf_input_lst =
+	    xf86addInput(XF86Config->conf_input_lst, input);
+    }
+
+    return (1);
+}
+
+static char *hsync[] = {
+#define	CONF_MONITOR_HSYNC	0
+    "Enter your own horizontal sync range",
+    "31.5; Standard VGA, 640x480 @ 60 Hz",
+    "31.5 - 35.1; Super VGA, 800x600 @ 56 Hz",
+    "31.5, 35.5; 8514 Compatible, 1024x768 @ 87 Hz interlaced (no 800x600)",
+    "31.5, 35.15, 35.5; Super VGA, 1024x768 @ 87 Hz int., 800x600 @ 56 Hz",
+    "31.5 - 37.9; Extended Super VGA, 800x600 @ 60 Hz, 640x480 @ 72 Hz",
+    "31.5 - 48.5; Non-Interlaced SVGA, 1024x768 @ 60 Hz, 800x600 @ 72 Hz",
+    "31.5 - 57.0; High Frequency SVGA, 1024x768 @ 70 Hz",
+    "31.5 - 64.3; Monitor that can do 1280x1024 @ 60 Hz",
+    "31.5 - 79.0; Monitor that can do 1280x1024 @ 74 Hz",
+    "31.5 - 82.0; Monitor that can do 1280x1024 @ 76 Hz",
+    "31.5 - 92.0; Monitor that can do 1280x1024 @ 85 Hz",
+    "31.5 - 108.0; Monitor that can do 1600x1200 @ 85 Hz",
+    "31.5 - 128.5; Monitor that can do 1920x1440 @ 85 Hz",
+    "31.5 - 137.0; Monitor that can do 2048x1536 @ 85 Hz"
+};
+
+static char *vrefresh[] = {
+#define	CONF_MONITOR_VREFRESH	0
+    "Enter your own vertical sync range",
+    "50 - 70",
+    "50 - 90",
+    "50 - 100",
+    "40 - 150",
+};
+
+static int
+MonitorConfig(void)
+{
+    int i;
+    XF86ConfMonitorPtr *monitors = NULL, monitor = XF86Config->conf_monitor_lst;
+    char **list = NULL, *identifier = NULL, *tmp;
+    int nlist, def;
+    char hsync_str[256], vrefresh_str[256];
+
+    hsync_str[0] = vrefresh_str[0] = '\0';
+    nlist = 0;
+    while (monitor) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	list[nlist] = XtMalloc(sizeof(Edit) +
+			       strlen(monitor->mon_identifier) + 1);
+	sprintf(list[nlist], "%s%s", Edit, monitor->mon_identifier);
+	monitors = (XF86ConfMonitorPtr*)XtRealloc((XtPointer)monitors, (nlist + 1) *
+				    sizeof(XF86ConfMonitorPtr));
+	monitors[nlist] = monitor;
+	++nlist;
+	monitor = (XF86ConfMonitorPtr)(monitor->list.next);
+    }
+
+    monitor = NULL;
+
+    if (nlist) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*));
+	list[nlist++] = XtNewString("Add new monitor");
+	if (nlist == 2) {
+	    i = strlen("Remove ") + strlen(monitors[0]->mon_identifier) + 1;
+	    list[nlist] = XtMalloc(i);
+	    XmuSnprintf(list[nlist], i, "Remove %s", monitors[0]->mon_identifier);
+	    ++nlist;
+	}
+	else
+	    list[nlist++] = XtNewString("Remove monitor");
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Monitor configuration",
+		       "You can edit or remove a previously configured "
+		       "monitor, or add a new one.", 14, 60, 4, nlist, list,
+		       " Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)monitors);
+	    return (-1);
+	}
+	if (nlist > 2 && i == nlist - 1) {
+	    if (nlist > 3) {
+		for (i = 0; i < nlist - 2; i++) {
+		    /* XXX Remove the "Edit " from list entries */
+		    memmove(list[i], list[i] + sizeof(Edit) - 1,
+			    strlen(list[i]) - sizeof(Edit) + 2);
+		}
+		ClearScreen();
+		refresh();
+		i = DialogMenu("Remove monitor",
+			       "Select which monitor to remove",
+			       13, 60, 4, nlist - 2, list,
+			       " Remove ", " Cancel ", 0);
+		if (i < 0) {
+		    for (i = 0; i < nlist; i++)
+			XtFree(list[i]);
+		    XtFree((XtPointer)list);
+		    XtFree((XtPointer)monitors);
+		    return (-1);
+		}
+		monitor = monitors[i];
+	    }
+	    else
+		monitor = monitors[0];
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)monitors);
+	    xf86removeMonitor(XF86Config, monitor);
+	    return (0);
+	}
+	if (i < nlist - 2)
+	    monitor = monitors[i];
+    }
+    for (i = 0; i < nlist; i++)
+	XtFree(list[i]);
+    XtFree((XtPointer)list);
+    XtFree((XtPointer)monitors);
+
+    if (monitor == NULL) {
+	char label[32];
+
+	monitor = (XF86ConfMonitorPtr)XtCalloc(1, sizeof(XF86ConfMonitorRec));
+	XmuSnprintf(label, sizeof(label), "Monitor%d", nlist ? nlist - 2 : 0);
+	ClearScreen();
+	refresh();
+	identifier =
+	    DialogInput("Monitor identifier",
+			"Enter an identifier for your monitor definition:",
+			11, 40, label,
+			" Next >>", " Cancel ", 0);
+	if (identifier == NULL) {
+	    XtFree((XtPointer)monitor);
+	    return (-1);
+	}
+    }
+
+    if (monitor->mon_identifier == NULL) {
+	ClearScreen();
+	refresh();
+	i = Dialog("Monitor configuration",
+		   "Now we want to set the specifications of the monitor. The "
+		   "two critical parameters are the vertical refresh rate, which "
+		   "is the rate at which the whole screen is refreshed, and most "
+		   "importantly the horizontal sync rate, which is the rate at "
+		   "which scanlines are displayed.\n"
+		   "\n"
+		   "The valid range for horizontal sync and vertical sync should "
+		   "be documented in the manual of your monitor.",
+		   15, 60, " Next >>", " Cancel ", 0);
+	if (i != 0) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)monitor);
+	    return (-1);
+	}
+    }
+
+    def = 0;
+    if (monitor->mon_identifier) {
+	int len;
+
+	parser_range_to_string(hsync_str, &(monitor->mon_hsync[0]),
+			       monitor->mon_n_hsync);
+	len = strlen(hsync_str);
+	for (i = 1; i < sizeof(hsync) / sizeof(hsync[0]); i++) {
+	    tmp = strchr(hsync[i], ';');
+	    if (strncmp(hsync_str, hsync[i], len) == 0) {
+		def = i;
+		break;
+	    }
+	}
+    }
+    if (hsync_str[0] == '\0')
+	strcpy(hsync_str, "31.5");
+
+    ClearScreen();
+    refresh();
+    i = DialogMenu("Monitor HorizSync",
+		   "You must indicate the horizontal sync range of your "
+		   "monitor. You can either select one of the predefined "
+		   "ranges below that correspond to industry-standard monitor "
+		   "types, or give a specific range.",
+		   22, 78, 11, sizeof(hsync) /
+		   sizeof(hsync[0]), hsync, " Next >>", " Cancel ", def);
+    if (i < 0) {
+	if (monitor->mon_identifier == NULL) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)monitor);
+	}
+	return (-1);
+    }
+    if (i == CONF_MONITOR_HSYNC) {
+	ClearScreen();
+	refresh();
+	tmp = DialogInput("Monitor HorizSync",
+			  "Please enter the horizontal sync range of your "
+			  "monitor, in the format used in the table of monitor "
+			  "types above. You can either specify one or more "
+			  "continuous ranges (e.g. 15-25, 30-50), or one or more "
+			  "fixed sync frequencies.\n"
+			  "\n"
+			  "Horizontal sync range:", 16, 62, hsync_str,
+			  "  Ok  ", " Cancel ", def);
+	if (tmp == NULL) {
+	    if (monitor->mon_identifier == NULL) {
+		XtFree(identifier);
+		XtFree((XtPointer)monitor);
+	    }
+	    return (-1);
+	}
+	XmuSnprintf(hsync_str, sizeof(hsync_str), "%s", tmp);
+	XtFree(tmp);
+    }
+    else {
+	tmp = strchr(hsync[i], ';');
+	strncpy(hsync_str, hsync[i], tmp - hsync[i]);
+	hsync_str[tmp - hsync[i]] = '\0';
+    }
+
+    def = 0;
+    if (monitor->mon_identifier) {
+	parser_range_to_string(vrefresh_str, &(monitor->mon_vrefresh[0]),
+			       monitor->mon_n_vrefresh);
+	for (i = 1; i < sizeof(vrefresh) / sizeof(vrefresh[0]); i++) {
+	    if (strcmp(vrefresh_str, vrefresh[i]) == 0) {
+		def = i;
+		break;
+	    }
+	}
+    }
+    if (vrefresh_str[0] == '\0')
+	strcpy(vrefresh_str, "50 - 70");
+    ClearScreen();
+    refresh();
+    i = DialogMenu("Monitor VertRefresh",
+		   "You must indicate the vertical sync range of your monitor. "
+		   "You can either select one of the predefined ranges below "
+		   "that correspond to industry-standard monitor types, or "
+		   "give a specific range. For interlaced modes, the number "
+		   "that counts is the high one (e.g. 87 Hz rather than 43 Hz).",
+		   19, 60, 5, sizeof(vrefresh) /
+		   sizeof(vrefresh[0]), vrefresh, " Finish ", " Cancel ", def);
+    if (i < 0) {
+	if (monitor->mon_identifier == NULL) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)monitor);
+	}
+	return (i);
+    }
+    if (i == CONF_MONITOR_VREFRESH) {
+	ClearScreen();
+	refresh();
+	tmp = DialogInput("Monitor VertRefresh",
+			  "Vertical sync range:", 10, 50, vrefresh_str,
+			  " Done ", " Cancel ", 0);
+	if (tmp == NULL) {
+	    if (monitor->mon_identifier == NULL) {
+		XtFree(identifier);
+		XtFree((XtPointer)monitor);
+	    }
+	    return (-1);
+	}
+	XmuSnprintf(vrefresh_str, sizeof(vrefresh_str), "%s", tmp);
+	XtFree(tmp);
+    }
+    else
+	strcpy(vrefresh_str, vrefresh[i]);
+
+    /* Finish monitor configuration */
+    monitor->mon_n_hsync = string_to_parser_range(hsync_str,
+	&(monitor->mon_hsync[0]), CONF_MAX_HSYNC);
+    monitor->mon_n_vrefresh = string_to_parser_range(vrefresh_str,
+	&(monitor->mon_vrefresh[0]), CONF_MAX_VREFRESH);
+    if (monitor->mon_identifier == NULL) {
+	monitor->mon_identifier = identifier;
+	XF86Config->conf_monitor_lst =
+	    xf86addMonitor(XF86Config->conf_monitor_lst, monitor);
+    }
+
+    return (1);
+}
+
+static int
+CardConfig(void)
+{
+    int i;
+    XF86ConfDevicePtr *devices = NULL, device = XF86Config->conf_device_lst;
+    char **list = NULL, *identifier = NULL, *driver, *busid, *tmp;
+    int nlist, def;
+    CardsEntry *entry = NULL;
+    static char **drivers;
+    static int ndrivers;
+    static char *xdrivers[] = {
+	"apm",
+	"ark",
+	"ast",
+	"ati",
+	"r128",
+	"radeon",
+	"chips",
+	"cirrus",
+	"cyrix",
+	"fbdev",
+	"glint",
+	"i128",
+	"i740",
+	"i810",
+	"imstt",
+	"mga",
+	"neomagic",
+	"nv",
+	"rendition",
+	"s3",
+	"s3virge",
+	"savage",
+	"siliconmotion",
+	"sis",
+	"tdfx",
+	"tga",
+	"trident",
+	"tseng",
+	"vmware",
+	"vga",
+	"vesa",
+    };
+
+#ifdef USE_MODULES
+    if (!nomodules) {
+	xf86cfgModuleOptions *opts = module_options;
+
+	drivers = NULL;
+	ndrivers = 0;
+	while (opts) {
+	    if (opts->type == VideoModule) {
+		++ndrivers;
+		drivers = (char**)XtRealloc((XtPointer)drivers,
+					    ndrivers * sizeof(char*));
+		/* XXX no private copy */
+		drivers[ndrivers - 1] = opts->name;
+	    }
+	    opts = opts->next;
+	}
+    }
+    else
+#endif
+    {
+	ndrivers = sizeof(xdrivers) / sizeof(xdrivers[0]);
+	drivers = xdrivers;
+    }
+
+    nlist = 0;
+    while (device) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	list[nlist] = XtMalloc(sizeof(Edit) +
+			       strlen(device->dev_identifier) + 1);
+	sprintf(list[nlist], "%s%s", Edit, device->dev_identifier);
+	devices = (XF86ConfDevicePtr*)XtRealloc((XtPointer)devices, (nlist + 1) *
+				    sizeof(XF86ConfDevicePtr));
+	devices[nlist] = device;
+	++nlist;
+	device = (XF86ConfDevicePtr)(device->list.next);
+    }
+
+    device = NULL;
+
+    if (nlist) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*));
+	list[nlist++] = XtNewString("Add new card");
+	if (nlist == 2) {
+	    i = strlen("Remove ") + strlen(devices[0]->dev_identifier) + 1;
+	    list[nlist] = XtMalloc(i);
+	    XmuSnprintf(list[nlist], i, "Remove %s", devices[0]->dev_identifier);
+	    ++nlist;
+	}
+	else
+	    list[nlist++] = XtNewString("Remove device");
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Card configuration",
+		       "You can edit or remove a previously configured "
+		       "card, or add a new one.", 14, 60, 4, nlist, list,
+		       " Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)devices);
+	    return (-1);
+	}
+	if (nlist > 2 && i == nlist - 1) {
+	    if (nlist > 3) {
+		for (i = 0; i < nlist - 2; i++) {
+		    /* XXX Remove the "Edit " from list entries */
+		    memmove(list[i], list[i] + sizeof(Edit) - 1,
+			    strlen(list[i]) - sizeof(Edit) + 2);
+		}
+		ClearScreen();
+		refresh();
+		i = DialogMenu("Remove card",
+			       "Select which card to remove",
+			       13, 60, 4, nlist - 2, list,
+			       " Remove ", " Cancel ", 0);
+		if (i < 0) {
+		    for (i = 0; i < nlist; i++)
+			XtFree(list[i]);
+		    XtFree((XtPointer)list);
+		    XtFree((XtPointer)devices);
+		    return (-1);
+		}
+		device = devices[i];
+	    }
+	    else
+		device = devices[0];
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)devices);
+	    xf86removeDevice(XF86Config, device);
+	    return (0);
+	}
+	if (i < nlist - 2)
+	    device = devices[i];
+    }
+    for (i = 0; i < nlist; i++)
+	XtFree(list[i]);
+    XtFree((XtPointer)list);
+    XtFree((XtPointer)devices);
+
+    if (device == NULL) {
+	char label[32];
+
+	device = (XF86ConfDevicePtr)XtCalloc(1, sizeof(XF86ConfDeviceRec));
+	device->dev_chipid = device->dev_chiprev = device->dev_irq = -1;
+	XmuSnprintf(label, sizeof(label), "Card%d", nlist ? nlist - 2 : 0);
+	ClearScreen();
+	refresh();
+	identifier =
+	    DialogInput("Card identifier",
+			"Enter an identifier for your card definition:",
+			11, 40, label,
+			" Next >>", " Cancel ", 0);
+	if (identifier == NULL) {
+	    XtFree((XtPointer)device);
+	    return (-1);
+	}
+    }
+
+    ClearScreen();
+    refresh();
+    if (Dialog("Card configuration",
+	       "Now we must configure video card specific settings. At this "
+	       "point you can choose to make a selection out of a database of "
+	       "video card definitions.\n"
+	       "\n"
+	       "The database entries include information about the chipset, "
+	       "what driver to run, the Ramdac and ClockChip, and comments "
+	       "that will be included in the Device section. However, a lot "
+	       "of definitions only hint about what driver to run (based on "
+	       "the chipset the card uses) and are untested.\n"
+	       "\n"
+	       "Do you want to look at the card database?",
+	       18, 60, " Yes ", " No ", device->dev_identifier != NULL) == 0) {
+	static char **cards;
+	static int ncards;
+
+	if (cards == NULL) {
+	    ReadCardsDatabase();
+	    cards = GetCardNames(&ncards);
+	    cards = (char**)XtRealloc((XtPointer)cards,
+				      (ncards + 1) * sizeof(char*));
+	    for (i = ncards; i > 0; i--)
+		cards[i] = cards[i - 1];
+	    cards[0] = "** Unlisted card **";
+	    ++ncards;
+	}
+	if (device->dev_card)
+	    entry = LookupCard(device->dev_card);
+	def = 0;
+	if (entry) {
+	    for (i = 0; i < NumCardsEntry; i++)
+		if (strcasecmp(CardsDB[i]->name, entry->name) == 0) {
+		    def = i + 1;
+		    break;
+		}
+	    /* make sure entry is set to null again */
+	    entry = NULL;
+	}
+
+	i = DialogMenu("Card database",
+		       "Select name that better matches your card:",
+		       20, 70, 11, ncards, cards, "Next >>", " Cancel ", def);
+	if (i > 0)
+	    entry = LookupCard(cards[i]);
+    }
+
+    def = 0;
+    tmp = device->dev_driver ? device->dev_driver : entry && entry->driver ?
+	  entry->driver : "vga";
+    for (i = 0; i < ndrivers; i++)
+	if (strcmp(drivers[i], tmp) == 0) {
+	    def = i;
+	    break;
+	}
+
+    ClearScreen();
+    refresh();
+    i = DialogMenu("Card driver",
+		   "You can select the driver for your card here, or just press "
+		   "Enter to use the default/current:", 20, 50, 9,
+		   ndrivers, drivers, "  Ok  ", " Cancel ", def);
+    if (i < 0) {
+	if (device->dev_identifier == NULL) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)device);
+	}
+	return (-1);
+    }
+    driver = ndrivers ? drivers[i] : "vga";
+
+    ClearScreen();
+    refresh();
+    tmp = device->dev_busid ? device->dev_busid : "";
+    busid = DialogInput("Card BusID",
+			"You normally does not need to fill this field "
+			"if you have only one video card:", 11, 50, tmp,
+			" Finish ", " Cancel ", 0);
+
+    /* Finish card configuration */
+    if (entry) {
+	XtFree(device->dev_card);
+	device->dev_card = XtNewString(entry->name);
+	if (entry->chipset) {
+	    XtFree(device->dev_chipset);
+	    device->dev_chipset = XtNewString(entry->chipset);
+	}
+	if (entry->ramdac) {
+	    XtFree(device->dev_ramdac);
+	    device->dev_ramdac = XtNewString(entry->ramdac);
+	}
+	if (entry->clockchip) {
+	    XtFree(entry->clockchip);
+	    device->dev_clockchip = XtNewString(entry->clockchip);
+	}
+    }
+    if (busid) {
+	XtFree(device->dev_busid);
+	if (*busid)
+	    device->dev_busid = busid;
+	else {
+	    device->dev_busid = NULL;
+	    XtFree(busid);
+	}
+    }
+    XtFree(device->dev_driver);
+    device->dev_driver = XtNewString(driver);
+    if (device->dev_identifier == NULL) {
+	device->dev_identifier = identifier;
+	XF86Config->conf_device_lst =
+	    xf86addDevice(XF86Config->conf_device_lst, device);
+    }
+
+    return (1);
+}
+
+static char *depths[] = {
+    "1 bit, monochrome",
+    "4 bit, 16 colors",
+    "8 bit, 256 colors",
+    "15 bits, 32Kb colors",
+    "16 bits, 65Kb colors",
+    "24 bits, 16Mb colors",
+};
+
+static char *modes[] = {
+    "2048x1536",
+    "1920x1440",
+    "1800x1400",
+    "1600x1200",
+    "1400x1050",
+    "1280x1024",
+    "1280x960",
+    "1152x864",
+    "1024x768",
+    "800x600",
+    "640x480",
+    "640x400",
+    "512x384",
+    "400x300",
+    "320x240",
+    "320x200",
+};
+
+static int
+ScreenConfig(void)
+{
+    int i, disp_allocated;
+    XF86ConfScreenPtr *screens = NULL, screen = XF86Config->conf_screen_lst;
+    char **list = NULL, *identifier = NULL;
+    int nlist, def;
+    XF86ConfDevicePtr device = NULL;
+    XF86ConfMonitorPtr monitor = NULL;
+    XF86ConfDisplayPtr display;
+    XF86ModePtr mode, ptr = NULL;
+    char *checks;
+
+    nlist = 0;
+    while (screen) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	list[nlist] = XtMalloc(sizeof(Edit) +
+			       strlen(screen->scrn_identifier) + 1);
+	sprintf(list[nlist], "%s%s", Edit, screen->scrn_identifier);
+	screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens, (nlist + 1) *
+				    sizeof(XF86ConfScreenPtr));
+	screens[nlist] = screen;
+	++nlist;
+	screen = (XF86ConfScreenPtr)(screen->list.next);
+    }
+
+    screen = NULL;
+
+    if (nlist) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*));
+	list[nlist++] = XtNewString("Add new screen");
+	if (nlist == 2) {
+	    i = strlen("Remove ") + strlen(screens[0]->scrn_identifier) + 1;
+	    list[nlist] = XtMalloc(i);
+	    XmuSnprintf(list[nlist], i, "Remove %s", screens[0]->scrn_identifier);
+	    ++nlist;
+	}
+	else
+	    list[nlist++] = XtNewString("Remove screen");
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Screen configuration",
+		       "You can edit or remove a previously configured "
+		       "screen, or add a new one.", 14, 60, 4, nlist, list,
+		       " Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)screens);
+	    return (-1);
+	}
+	if (nlist > 2 && i == nlist - 1) {
+	    if (nlist > 3) {
+		for (i = 0; i < nlist - 2; i++) {
+		    /* XXX Remove the "Edit " from list entries */
+		    memmove(list[i], list[i] + sizeof(Edit) - 1,
+			    strlen(list[i]) - sizeof(Edit) + 2);
+		}
+		ClearScreen();
+		refresh();
+		i = DialogMenu("Remove screen",
+			       "Select which screen to remove",
+			       13, 60, 4, nlist - 2, list,
+			       " Remove ", " Cancel ", 0);
+		if (i < 0) {
+		    for (i = 0; i < nlist; i++)
+			XtFree(list[i]);
+		    XtFree((XtPointer)list);
+		    XtFree((XtPointer)screens);
+		    return (-1);
+		}
+		screen = screens[i];
+	    }
+	    else
+		screen = screens[0];
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)screens);
+	    xf86removeScreen(XF86Config, screen);
+	    return (0);
+	}
+	if (i < nlist - 2)
+	    screen = screens[i];
+    }
+    for (i = 0; i < nlist; i++)
+	XtFree(list[i]);
+    XtFree((XtPointer)list);
+    XtFree((XtPointer)screens);
+
+    if (screen == NULL) {
+	char label[256];
+	XF86ConfDevicePtr *devices = NULL;
+	XF86ConfMonitorPtr *monitors = NULL;
+
+	device = XF86Config->conf_device_lst;
+	monitor = XF86Config->conf_monitor_lst;
+
+	if (device == NULL || monitor == NULL) {
+		ClearScreen();
+		refresh();
+		Dialog("Configuration error",
+		       "You need to configure (at least) one card and one "
+		       "monitor before creating a screen definition.",
+		       9, 50, "  Ok  ", NULL, 0);
+
+		return (-1);
+	}
+
+	XmuSnprintf(label, sizeof(label), "Screen%d", nlist ? nlist - 2 : 0);
+	ClearScreen();
+	refresh();
+	identifier =
+	    DialogInput("Screen identifier",
+			"Enter an identifier for your screen definition:",
+			11, 40, label,
+			" Next >>", " Cancel ", 0);
+	if (identifier == NULL)
+	    return (-1);
+
+	nlist = 0;
+	list = NULL;
+	while (device) {
+	    list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	    list[nlist] = XtNewString(device->dev_identifier);
+	    devices = (XF86ConfDevicePtr*)XtRealloc((XtPointer)devices, (nlist + 1) *
+					sizeof(XF86ConfDevicePtr));
+	    devices[nlist] = device;
+	    ++nlist;
+	    device = (XF86ConfDevicePtr)(device->list.next);
+	}
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Screen card", "Please select a video card:",
+		       13, 60, 4, nlist, list, " Next >>", " Cancel ", 0);
+	for (def = 0; def < nlist; def++)
+	    XtFree(list[def]);
+	XtFree((XtPointer)list);
+	if (i < 0) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)devices);
+	    return (-1);
+	}
+	device = devices[i];
+	XtFree((XtPointer)devices);
+
+	nlist = 0;
+	list = NULL;
+	while (monitor) {
+	    list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	    list[nlist] = XtNewString(monitor->mon_identifier);
+	    monitors = (XF86ConfMonitorPtr*)XtRealloc((XtPointer)monitors, (nlist + 1) *
+					sizeof(XF86ConfMonitorPtr));
+	    monitors[nlist] = monitor;
+	    ++nlist;
+	    monitor = (XF86ConfMonitorPtr)(monitor->list.next);
+	}
+	XmuSnprintf(label, sizeof(label),
+		    "Select the monitor connected to \"%s\":",
+		    device->dev_identifier);
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Screen monitor", label,
+		       13, 60, 4, nlist, list, " Next >>", " Cancel ", 0);
+	for (def = 0; def < nlist; def++)
+	    XtFree(list[def]);
+	XtFree((XtPointer)list);
+	if (i < 0) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)monitors);
+	    return (-1);
+	}
+	monitor = monitors[i];
+	XtFree((XtPointer)monitors);
+
+	screen = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec));
+	screen->scrn_device = device;
+	screen->scrn_monitor = monitor;
+    }
+
+    if (screen->scrn_defaultdepth == 1)
+	def = 0;
+    else if (screen->scrn_defaultdepth == 4)
+	def = 1;
+    else if (screen->scrn_defaultdepth == 8)
+	def = 2;
+    else if (screen->scrn_defaultdepth == 15)
+	def = 3;
+    else if (screen->scrn_defaultdepth == 16)
+	def = 4;
+    else if (screen->scrn_defaultdepth == 24)
+	def = 5;
+    else {
+	if (screen->scrn_device && screen->scrn_device->dev_driver &&
+	    strcmp(screen->scrn_device->dev_driver, "vga") == 0)
+	    def = 1;		/* 4bpp */
+	else
+	    def = 2;		/* 8bpp */
+    }
+    ClearScreen();
+    refresh();
+    i = DialogMenu("Screen depth",
+		   "Please specify which color depth you want to use by default:",
+		   15, 60, 6, sizeof(depths) / sizeof(depths[0]), depths,
+		   " Next >>", " Cancel ", def);
+    if (i < 0) {
+	if (screen->scrn_identifier == NULL) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)screen);
+	}
+	return (-1);
+    }
+    else
+	/* XXX depths must begin with the depth number */
+	screen->scrn_defaultdepth = atoi(depths[i]);
+
+    def = 0;	/* use def to count how many modes are selected*/
+    nlist = 0;
+    list = NULL;
+    checks = XtMalloc(sizeof(modes) / sizeof(modes[0]));
+    /* XXX list fields in the code below are not allocated */
+    disp_allocated = 0;
+    display = screen->scrn_display_lst;
+    while (display && display->disp_depth != screen->scrn_defaultdepth)
+	display = (XF86ConfDisplayPtr)(display->list.next);
+    if (display == NULL) {
+	display = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec));
+	display->disp_white.red = display->disp_black.red = -1;
+	display->disp_depth = screen->scrn_defaultdepth;
+	disp_allocated = 1;
+    }
+    else {
+	mode = display->disp_mode_lst;
+	while (mode) {
+	    for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++)
+		if (strcmp(modes[i], mode->mode_name) == 0) {
+		    break;
+		}
+
+	    if (i == sizeof(modes) / sizeof(modes[0])) {
+		list = (char**)XtRealloc((XtPointer)list,
+					 (nlist + 1) * sizeof(char*));
+		list[nlist] = mode->mode_name;
+		checks = XtRealloc(checks, sizeof(modes) / sizeof(modes[0]) +
+				   nlist + 1);
+		checks[nlist] = 1;
+		++def;
+		nlist++;
+		break;
+	    }
+	    mode = (XF86ModePtr)(mode->list.next);
+	}
+    }
+
+    for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++)
+	checks[i + nlist] = 0;
+
+    mode = display->disp_mode_lst;
+    while (mode) {
+	for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++)
+	    if (strcmp(modes[i], mode->mode_name) == 0) {
+		++def;
+		checks[i + nlist] = 1;
+		break;
+	}
+	mode = (XF86ModePtr)(mode->list.next);
+    }
+
+    if (nlist == 0 && def == 0)
+	checks[7] = 1;	/* 640x480 */
+    list = (char**)XtRealloc((XtPointer)list, (nlist + sizeof(modes) /
+			     sizeof(modes[0])) * sizeof(char*));
+    for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++)
+	list[i + nlist] = modes[i];
+    nlist += sizeof(modes) / sizeof(modes[0]);
+
+    ClearScreen();
+    refresh();
+    i = DialogCheckBox("Screen modes",
+		       "Select the video modes for this screen:",
+		       17, 60, 8, sizeof(modes) / sizeof(modes[0]), modes,
+		       " Finish ", " Cancel ", checks);
+    if (i < 0) {
+	if (screen->scrn_identifier == NULL) {
+	    XtFree(identifier);
+	    XtFree((XtPointer)screen);
+	    XtFree((XtPointer)list);
+	    if (disp_allocated)
+		XtFree((XtPointer)display);
+	}
+	return (-1);
+    }
+
+    mode = display->disp_mode_lst;
+    while (mode) {
+	ptr = (XF86ModePtr)(mode->list.next);
+	XtFree(mode->mode_name);
+	XtFree((XtPointer)mode);
+	mode = ptr;
+    }
+    display->disp_mode_lst = NULL;
+
+    for (i = 0; i < nlist; i++) {
+	if (checks[i]) {
+	    mode = (XF86ModePtr)XtCalloc(1, sizeof(XF86ModeRec));
+	    mode->mode_name = XtNewString(list[i]);
+	    if (display->disp_mode_lst == NULL)
+		display->disp_mode_lst = ptr = mode;
+	    else {
+		ptr->list.next = mode;
+		ptr = mode;
+	    }
+	}
+    }
+    XtFree((XtPointer)list);
+
+    if (disp_allocated) {
+	display->list.next = NULL;
+	if (screen->scrn_display_lst == NULL)
+	    screen->scrn_display_lst = display;
+	else
+	    screen->scrn_display_lst->list.next = display;
+    }
+
+    if (screen->scrn_identifier == NULL) {
+	screen->scrn_identifier = identifier;
+	screen->scrn_monitor_str = XtNewString(monitor->mon_identifier);
+	screen->scrn_device_str = XtNewString(device->dev_identifier);
+	XF86Config->conf_screen_lst =
+	    xf86addScreen(XF86Config->conf_screen_lst, screen);
+    }
+
+    return (1);
+}
+
+static XF86ConfAdjacencyPtr
+CopyAdjacency(XF86ConfAdjacencyPtr ptr)
+{
+    XF86ConfAdjacencyPtr adj = (XF86ConfAdjacencyPtr)
+	XtCalloc(1, sizeof(XF86ConfAdjacencyRec));
+
+    adj->adj_scrnum = ptr->adj_scrnum;
+    adj->adj_screen = ptr->adj_screen;
+    adj->adj_screen_str = XtNewString(ptr->adj_screen_str);
+    adj->adj_top = ptr->adj_top;
+    if (ptr->adj_top_str)
+	adj->adj_top_str = XtNewString(ptr->adj_top_str);
+    adj->adj_bottom = ptr->adj_bottom;
+    if (ptr->adj_bottom_str)
+	adj->adj_bottom_str = XtNewString(ptr->adj_bottom_str);
+    adj->adj_left = ptr->adj_left;
+    if (ptr->adj_left_str)
+	adj->adj_left_str = XtNewString(ptr->adj_left_str);
+    adj->adj_right = ptr->adj_right;
+    if (ptr->adj_right_str)
+	adj->adj_right_str = XtNewString(ptr->adj_right_str);
+    adj->adj_where = ptr->adj_where;
+    adj->adj_x = ptr->adj_x;
+    adj->adj_y = ptr->adj_y;
+    if (ptr->adj_refscreen)
+	adj->adj_refscreen = XtNewString(ptr->adj_refscreen);
+
+    return (adj);
+}
+
+static XF86ConfInactivePtr
+CopyInactive(XF86ConfInactivePtr ptr)
+{
+    XF86ConfInactivePtr inac = (XF86ConfInactivePtr)
+	XtCalloc(1, sizeof(XF86ConfInactiveRec));
+
+    inac->inactive_device = ptr->inactive_device;
+    if (ptr->inactive_device_str)
+	inac->inactive_device_str = XtNewString(ptr->inactive_device_str);
+
+    return (inac);
+}
+
+static XF86ConfInputrefPtr
+CopyInputref(XF86ConfInputrefPtr ptr)
+{
+    XF86ConfInputrefPtr iref = (XF86ConfInputrefPtr)
+	XtCalloc(1, sizeof(XF86ConfInputrefRec));
+    XF86OptionPtr opt = ptr->iref_option_lst;
+
+    iref->iref_inputdev = ptr->iref_inputdev;
+    if (ptr->iref_inputdev_str)
+	iref->iref_inputdev_str = XtNewString(ptr->iref_inputdev_str);
+    while (opt) {
+	iref->iref_option_lst = xf86addNewOption(iref->iref_option_lst,
+	    XtNewString(opt->opt_name),
+	    opt->opt_val ? XtNewString(opt->opt_val) : NULL);
+	opt = (XF86OptionPtr)(opt->list.next);
+    }
+
+    return (iref);
+}
+
+static XF86ConfLayoutPtr
+CopyLayout(XF86ConfLayoutPtr ptr)
+{
+    XF86ConfLayoutPtr lay = (XF86ConfLayoutPtr)
+	XtCalloc(1, sizeof(XF86ConfLayoutRec));
+    XF86ConfAdjacencyPtr adj = ptr->lay_adjacency_lst, padj;
+    XF86ConfInactivePtr inac = ptr->lay_inactive_lst, pinac;
+    XF86ConfInputrefPtr iref = ptr->lay_input_lst, piref;
+    XF86OptionPtr opt = ptr->lay_option_lst;
+
+    if (ptr->lay_identifier)
+	lay->lay_identifier = XtNewString(ptr->lay_identifier);
+    if (adj) {
+	padj = lay->lay_adjacency_lst = CopyAdjacency(adj);
+	adj = (XF86ConfAdjacencyPtr)(adj->list.next);
+	while (adj) {
+	    padj->list.next = CopyAdjacency(adj);
+	    padj = (XF86ConfAdjacencyPtr)(padj->list.next);
+	    adj = (XF86ConfAdjacencyPtr)(adj->list.next);
+	}
+    }
+    if (inac) {
+	pinac = lay->lay_inactive_lst = CopyInactive(inac);
+	inac = (XF86ConfInactivePtr)(inac->list.next);
+	while (inac) {
+	    pinac->list.next = CopyInactive(inac);
+	    pinac = (XF86ConfInactivePtr)(pinac->list.next);
+	    inac = (XF86ConfInactivePtr)(inac->list.next);
+	}
+    }
+    if (iref) {
+	piref = lay->lay_input_lst = CopyInputref(iref);
+	iref = (XF86ConfInputrefPtr)(iref->list.next);
+	while (iref) {
+	    piref->list.next = CopyInputref(iref);
+	    piref = (XF86ConfInputrefPtr)(piref->list.next);
+	    iref = (XF86ConfInputrefPtr)(iref->list.next);
+	}
+    }
+
+    while (opt) {
+	lay->lay_option_lst = xf86addNewOption(lay->lay_option_lst,
+	    XtNewString(opt->opt_name),
+	    opt->opt_val ? XtNewString(opt->opt_val) : NULL);
+	opt = (XF86OptionPtr)(opt->list.next);
+    }
+
+    return (lay);
+}
+
+static void
+FreeLayout(XF86ConfLayoutPtr lay)
+{
+    static XF86ConfigRec xf86config;
+
+    xf86config.conf_layout_lst = lay;
+    xf86removeLayout(&xf86config, lay);
+}
+
+static int
+LayoutConfig(void)
+{
+    int i;
+    XF86ConfLayoutPtr *layouts = NULL, rlayout = NULL,
+		       layout = XF86Config->conf_layout_lst;
+    XF86ConfInputPtr input = XF86Config->conf_input_lst;
+    char **list = NULL, *identifier = NULL;
+    XF86ConfInputPtr *mouses = NULL, *keyboards = NULL, mouse, keyboard;
+    XF86ConfInputrefPtr iref, piref, mref, kref;
+    XF86ConfAdjacencyPtr adj, padj;
+    int nmouses, nkeyboards;
+    int nlist;
+    XF86OptionPtr option;
+    XF86ConfScreenPtr screen, *screens;
+
+    nmouses = nkeyboards = 0;
+    while (input) {
+	if (strcmp(input->inp_driver, "mouse") == 0) {
+	    mouses = (XF86ConfInputPtr*)XtRealloc((XtPointer)mouses,
+			(nmouses + 1) * sizeof(XF86ConfInputPtr));
+	    mouses[nmouses] = input;
+	    ++nmouses;
+	}
+	else if (IS_KBDDRIV(input->inp_driver)) {
+	    keyboards = (XF86ConfInputPtr*)XtRealloc((XtPointer)keyboards,
+			    (nkeyboards + 1) * sizeof(XF86ConfInputPtr));
+	    keyboards[nkeyboards] = input;
+	    ++nkeyboards;
+	}
+	input = (XF86ConfInputPtr)(input->list.next);
+    }
+    if (XF86Config->conf_screen_lst == NULL ||
+	nmouses == 0 || nkeyboards == 0) {
+	XtFree((XtPointer)mouses);
+	XtFree((XtPointer)keyboards);
+	ClearScreen();
+	refresh();
+	Dialog("Configuration error",
+	       "You need to configure (at least) one screen, mouse "
+	       "and keyboard before creating a layout definition.",
+	       9, 50, "  Ok  ", NULL, 0);
+	return (-1);
+    }
+
+    nlist = 0;
+    while (layout) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+	list[nlist] = XtMalloc(sizeof(Edit) +
+			       strlen(layout->lay_identifier) + 1);
+	sprintf(list[nlist], "%s%s", Edit, layout->lay_identifier);
+	layouts = (XF86ConfLayoutPtr*)XtRealloc((XtPointer)layouts, (nlist + 1) *
+				    sizeof(XF86ConfLayoutPtr));
+	layouts[nlist] = layout;
+	++nlist;
+	layout = (XF86ConfLayoutPtr)(layout->list.next);
+    }
+
+    layout = NULL;
+
+    if (nlist) {
+	list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*));
+	list[nlist++] = XtNewString("Add new layout");
+	if (nlist == 2) {
+	    i = strlen("Remove ") + strlen(layouts[0]->lay_identifier) + 1;
+	    list[nlist] = XtMalloc(i);
+	    XmuSnprintf(list[nlist], i, "Remove %s", layouts[0]->lay_identifier);
+	    ++nlist;
+	}
+	else
+	    list[nlist++] = XtNewString("Remove layout");
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Layout configuration",
+		       "You can edit or remove a previously configured "
+		       "layout, or add a new one.", 14, 60, 4, nlist, list,
+		       " Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)layouts);
+	    XtFree((XtPointer)mouses);
+	    XtFree((XtPointer)keyboards);
+	    return (-1);
+	}
+	if (nlist > 2 && i == nlist - 1) {
+	    if (nlist > 3) {
+		for (i = 0; i < nlist - 2; i++) {
+		    /* XXX Remove the "Edit " from list entries */
+		    memmove(list[i], list[i] + sizeof(Edit) - 1,
+			    strlen(list[i]) - sizeof(Edit) + 2);
+		}
+		ClearScreen();
+		refresh();
+		i = DialogMenu("Remove layout",
+			       "Select which layout to remove",
+			       13, 60, 4, nlist - 2, list,
+			       " Remove ", " Cancel ", 0);
+		if (i < 0) {
+		    for (i = 0; i < nlist; i++)
+			XtFree(list[i]);
+		    XtFree((XtPointer)list);
+		    XtFree((XtPointer)layouts);
+		    XtFree((XtPointer)mouses);
+		    XtFree((XtPointer)keyboards);
+		    return (-1);
+		}
+		layout = layouts[i];
+	    }
+	    else
+		layout = layouts[0];
+	    for (i = 0; i < nlist; i++)
+		XtFree(list[i]);
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)layouts);
+	    XtFree((XtPointer)mouses);
+	    XtFree((XtPointer)keyboards);
+	    xf86removeLayout(XF86Config, layout);
+	    return (0);
+	}
+	if (i < nlist - 2)
+	    layout = layouts[i];
+    }
+    for (i = 0; i < nlist; i++)
+	XtFree(list[i]);
+    XtFree((XtPointer)list);
+    XtFree((XtPointer)layouts);
+
+    if (layout == NULL) {
+	char label[32];
+
+	layout = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec));
+	XmuSnprintf(label, sizeof(label), "Layout%d", nlist ? nlist - 2 : 0);
+	ClearScreen();
+	refresh();
+	identifier =
+	    DialogInput("Layout identifier",
+			"Enter an identifier for your layout definition:",
+			11, 40, label,
+			" Next >>", " Cancel ", 0);
+	if (identifier == NULL) {
+	    XtFree((XtPointer)layout);
+	    XtFree((XtPointer)mouses);
+	    XtFree((XtPointer)keyboards);
+	    return (-1);
+	}
+    }
+    else {
+	/* So that we can safely change it */
+	rlayout = layout;
+	layout = CopyLayout(rlayout);
+    }
+
+
+    mouse = keyboard = NULL;
+
+    /*  Mouse */
+    piref = NULL;
+    iref = layout->lay_input_lst;
+    while (iref) {
+	if (strcmp(iref->iref_inputdev->inp_driver, "mouse") == 0) {
+	    if (mouse == NULL)
+		piref = iref;
+	    if (xf86findOption(iref->iref_option_lst, "CorePointer")) {
+		mouse = iref->iref_inputdev;
+		piref = iref;
+		break;
+	    }
+	}
+	iref = (XF86ConfInputrefPtr)(iref->list.next);
+    }
+    if (mouse == NULL) {
+	if (piref) {
+	    mref = piref;
+	    mouse = piref->iref_inputdev;
+	    piref->iref_option_lst =
+		xf86addNewOption(piref->iref_option_lst,
+			       XtNewString("CorePointer"), NULL);
+	}
+	else {
+	    mouse = mouses[0];
+	    mref = iref = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec));
+	    iref->iref_inputdev_str = XtNewString(mouse->inp_identifier);
+	    iref->iref_inputdev = mouse;
+	    iref->iref_option_lst =
+		    xf86addNewOption(iref->iref_option_lst,
+				   XtNewString("CorePointer"), NULL);
+	    iref->list.next = layout->lay_input_lst;
+	    if (layout->lay_input_lst == NULL)
+		layout->lay_input_lst = iref;
+	    else {
+		iref->list.next = layout->lay_input_lst;
+		layout->lay_input_lst = iref;
+	    }
+	}
+    }
+    else
+	mref = piref;
+
+    /* XXX list fields are not allocated */
+    if (nmouses > 1) {
+	nlist = 0;
+	list = (char**)XtMalloc(sizeof(char*));
+	list[nlist++] = mouse->inp_identifier;
+	input = XF86Config->conf_input_lst;
+	while (input) {
+	    if (input != mouse && strcmp(input->inp_driver, "mouse") == 0) {
+		list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+		list[nlist++] = input->inp_identifier;
+	    }
+	    input = (XF86ConfInputPtr)(input->list.next);
+	}
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Select Core Pointer",
+		       "Select the mouse connected to you computer",
+		       12, 60, 4, nlist, list, "  Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    XtFree((XtPointer)mouses);
+	    XtFree((XtPointer)keyboards);
+	    XtFree((XtPointer)list);
+	    if (layout->lay_identifier == NULL)
+		XtFree(identifier);
+	    FreeLayout(layout);
+	    return (-1);
+	}
+	if (i > 0) {
+	    /* Did not select the default one */
+	    iref = layout->lay_input_lst;
+	    while (iref) {
+		if (strcasecmp(iref->iref_inputdev_str, list[i]) == 0) {
+		    if ((option = xf86findOption(iref->iref_option_lst,
+						 "SendCoreEvents")) != NULL) {
+			XtFree(option->opt_name);
+			option->opt_name = XtNewString("CorePointer");
+		    }
+		    else
+			iref->iref_option_lst =
+			    xf86addNewOption(iref->iref_option_lst,
+					  "CorePointer", NULL);
+		    option = xf86findOption(mref->iref_option_lst,
+					    "CorePointer");
+		    XtFree(option->opt_name);
+		    option->opt_name = XtNewString("SendCoreEvents");
+		    break;
+		}
+		iref = (XF86ConfInputrefPtr)(iref->list.next);
+	    }
+	}
+
+	/* XXX Write code to add/remove more mouses here */
+    }
+
+
+    /*  Keyboard */
+    piref = NULL;
+    iref = layout->lay_input_lst;
+    while (iref) {
+	if (IS_KBDDRIV(iref->iref_inputdev->inp_driver)) {
+	    if (keyboard == NULL)
+		piref = iref;
+	    if (xf86findOption(iref->iref_option_lst, "CoreKeyboard")) {
+		keyboard = iref->iref_inputdev;
+		piref = iref;
+		break;
+	    }
+	}
+	iref = (XF86ConfInputrefPtr)(iref->list.next);
+    }
+    if (keyboard == NULL) {
+	if (piref) {
+	    kref = piref;
+	    keyboard = piref->iref_inputdev;
+	    piref->iref_option_lst =
+		xf86addNewOption(piref->iref_option_lst,
+			       XtNewString("CoreKeyboard"), NULL);
+	}
+	else {
+	    keyboard = keyboards[0];
+	    kref = iref = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec));
+	    iref->iref_inputdev_str = XtNewString(keyboard->inp_identifier);
+	    iref->iref_inputdev = keyboard;
+	    iref->iref_option_lst =
+		    xf86addNewOption(iref->iref_option_lst,
+				   XtNewString("CoreKeyboard"), NULL);
+	    iref->list.next = layout->lay_input_lst;
+	    if (layout->lay_input_lst == NULL)
+		layout->lay_input_lst = iref;
+	    else {
+		iref->list.next = layout->lay_input_lst;
+		layout->lay_input_lst = iref;
+	    }
+	}
+    }
+    else
+	kref = piref;
+
+    /* XXX list fields are not allocated */
+    if (nkeyboards > 1) {
+	nlist = 0;
+	list = (char**)XtMalloc(sizeof(char*));
+	list[nlist++] = keyboard->inp_identifier;
+	input = XF86Config->conf_input_lst;
+	while (input) {
+	    if (input != keyboard && IS_KBDDRIV(input->inp_driver)) {
+		list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+		list[nlist++] = input->inp_identifier;
+	    }
+	    input = (XF86ConfInputPtr)(input->list.next);
+	}
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Select Core Keyboard",
+		       "Select the keyboard connected to you computer",
+		       12, 60, 4, nlist, list, "  Ok  ", " Cancel ", 0);
+	if (i < 0) {
+	    XtFree((XtPointer)mouses);
+	    XtFree((XtPointer)keyboards);
+	    XtFree((XtPointer)list);
+	    if (layout->lay_identifier == NULL)
+		XtFree(identifier);
+	    FreeLayout(layout);
+	    return (-1);
+	}
+	if (i > 0) {
+	    /* Did not select the default one */
+	    iref = layout->lay_input_lst;
+	    while (iref) {
+		if (strcasecmp(iref->iref_inputdev_str, list[i]) == 0) {
+		    if ((option = xf86findOption(iref->iref_option_lst,
+						 "SendCoreEvents")) != NULL) {
+			XtFree(option->opt_name);
+			option->opt_name = XtNewString("CoreKeyboard");
+		    }
+		    else
+			iref->iref_option_lst =
+			    xf86addNewOption(iref->iref_option_lst,
+					  "CoreKeyboard", NULL);
+		    option = xf86findOption(kref->iref_option_lst,
+					    "CoreKeyboard");
+		    XtFree(option->opt_name);
+		    option->opt_name = XtNewString("SendCoreEvents");
+		    break;
+		}
+		iref = (XF86ConfInputrefPtr)(iref->list.next);
+	    }
+	}
+
+	/* XXX Write code to add/remove more keyboards here */
+    }
+
+    XtFree((XtPointer)mouses);
+    XtFree((XtPointer)keyboards);
+
+    /* Just one screen */
+    if (XF86Config->conf_screen_lst->list.next == NULL) {
+	ClearScreen();
+	refresh();
+	Dialog("Layout configuration",
+	       (nmouses > 1 || nkeyboards > 1) ?
+	       "As you have only one screen configured, I can now finish "
+	       "creating this Layout configuration."
+		:
+	       "As you have only one screen, mouse and keyboard configured, "
+	       "I can now finish creating this Layout configuration.",
+	       12, 60, " Finish ", NULL, 0);
+
+	goto LayoutFinish;
+    }
+
+
+    /* The code below just adds a screen to the right of the last
+     * one, or allows removing a screen.
+     * Needs some review, and adding more options.
+     */
+
+    /*CONSTCOND*/
+    while (1) {
+	static char *screen_opts[] = {
+	    "Add a new screen to layout",
+	    "Remove screen from layout",
+	    "Finish layout configuration",
+	};
+
+	ClearScreen();
+	refresh();
+	i = DialogMenu("Layout configuration", "Please choose one option:",
+		       12, 60, 3, sizeof(screen_opts) / sizeof(screen_opts[0]),
+		       screen_opts, " Done ", " Cancel all changes ", 2);
+
+	/* cancel */
+	if (i < 0) {
+	    XtFree(identifier);
+	    FreeLayout(layout);
+	    return (-1);
+	}
+
+	/* add new screen */
+	else if (i == 0) {
+	    nlist = 0;
+	    list = NULL;
+	    screens = NULL;
+	    screen = XF86Config->conf_screen_lst;
+	    while (screen) {
+		adj = layout->lay_adjacency_lst;
+		while (adj) {
+		    if (adj->adj_screen == screen)
+			break;
+		    adj = (XF86ConfAdjacencyPtr)(adj->list.next);
+		}
+		if (adj == NULL) {
+		    list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+		    screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens,
+			       (nlist + 1) * sizeof(XF86ConfScreenPtr));
+		    /* NOT duplicated */
+		    list[nlist] = screen->scrn_identifier;
+		    screens[nlist] = screen;
+		    ++nlist;
+		}
+		screen = (XF86ConfScreenPtr)(screen->list.next);
+	    }
+
+	    if (nlist == 0)
+		continue;
+
+	    ClearScreen();
+	    refresh();
+	    i = DialogMenu("Layout add screen", "Choose screen to add:",
+			   12, 60, 3, nlist, list,
+			   " Add ", " Cancel ", 0);
+	    if (i >= 0) {
+		padj = layout->lay_adjacency_lst;
+		adj = (XF86ConfAdjacencyPtr)
+			XtCalloc(1, sizeof(XF86ConfAdjacencyRec));
+		adj->adj_screen = screens[i];
+		if (padj == NULL) {
+		    adj->adj_where = CONF_ADJ_ABSOLUTE;
+		    layout->lay_adjacency_lst = adj;
+		}
+		else {
+		    while (padj->list.next)
+			padj = (XF86ConfAdjacencyPtr)(padj->list.next);
+		    padj->list.next = adj;
+		    adj->adj_where = CONF_ADJ_RIGHTOF;
+		    adj->adj_refscreen =
+			XtNewString(padj->adj_screen->scrn_identifier);
+		}
+	    }
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)screens);
+	}
+
+	/* remove a screen */
+	else if (i == 1) {
+	    nlist = 0;
+	    list = NULL;
+	    screens = NULL;
+	    adj = layout->lay_adjacency_lst;
+
+	    while (adj) {
+		list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*));
+		screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens,
+			   (nlist + 1) * sizeof(XF86ConfScreenPtr));
+		list[nlist] = adj->adj_screen->scrn_identifier;
+		screens[nlist] = adj->adj_screen;
+		++nlist;
+		adj = (XF86ConfAdjacencyPtr)(adj->list.next);
+	    }
+
+	    if (nlist == 0)
+		continue;
+
+	    ClearScreen();
+	    refresh();
+	    i = DialogMenu("Layout remove screen", "Choose screen to remove:",
+			   12, 60, 3, nlist, list,
+			   " Remove ", " Cancel ", 0);
+
+	    adj = padj = layout->lay_adjacency_lst;
+	    while (adj) {
+		if (adj->adj_screen == screens[i]) {
+		    padj = (XF86ConfAdjacencyPtr)(padj->list.next);
+		    if (padj && adj->adj_where == CONF_ADJ_RIGHTOF &&
+			padj->adj_where == CONF_ADJ_RIGHTOF) {
+			XtFree(padj->adj_refscreen);
+			padj->adj_refscreen = XtNewString(adj->adj_refscreen);
+		    }
+		    xf86removeAdjacency(layout, adj);
+		    break;
+		}
+		padj = adj;
+		adj = (XF86ConfAdjacencyPtr)(padj->list.next);
+	    }
+	    XtFree((XtPointer)list);
+	    XtFree((XtPointer)screens);
+	}
+
+	/* finish screen configuration */
+	else
+	    break;
+    }
+
+LayoutFinish:
+    if (layout->lay_adjacency_lst == NULL) {
+	adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec));
+	adj->adj_screen = XF86Config->conf_screen_lst;
+	adj->adj_screen_str = XtNewString(XF86Config->conf_screen_lst->scrn_identifier);
+	adj->adj_where = CONF_ADJ_ABSOLUTE;
+	layout->lay_adjacency_lst = adj;
+    }
+    if (rlayout) {
+	/* just edited this layout */
+	if (nmouses > 1 || nkeyboards > 1) {
+	    XF86ConfAdjacencyPtr tadj = rlayout->lay_adjacency_lst;
+	    XF86ConfInactivePtr tinac = rlayout->lay_inactive_lst;
+	    XF86ConfInputrefPtr tinp = rlayout->lay_input_lst;
+
+	    rlayout->lay_adjacency_lst = layout->lay_adjacency_lst;
+	    rlayout->lay_inactive_lst = layout->lay_inactive_lst;
+	    rlayout->lay_input_lst = layout->lay_input_lst;
+
+	    layout->lay_adjacency_lst = tadj;
+	    layout->lay_inactive_lst = tinac;
+	    layout->lay_input_lst = tinp;
+	    FreeLayout(layout);
+	}
+	return (0);
+    }
+    else {
+	layout->lay_identifier = identifier;
+	XF86Config->conf_layout_lst =
+	    xf86addLayout(XF86Config->conf_layout_lst, layout);
+    }
+
+    return (1);
+}
+
+static void
+ClearScreen(void)
+{
+    int i, j;
+
+    wattrset(stdscr, screen_attr);
+    for (i = 0; i < LINES; i++) {
+	wmove(stdscr, i, 0);
+	for (j = 0; j < COLS; j++)
+	    waddch(stdscr, ACS_PLUS);
+    }
+    touchwin(stdscr);
+}
+
+static int
+Dialog(char *title, char * prompt, int height, int width,
+       char *label1, char *label2, int button)
+{
+    int x, x1, x2, y, key, l1len, l2len;
+    WINDOW *dialog;
+
+    x = (COLS - width) / 2;
+    y = (LINES - height) / 2;
+  
+    dialog = newwin(height, width, y, x);
+    keypad(dialog, TRUE);
+
+    PaintWindow(dialog, title, 0, 0, height, width);
+    wattrset(dialog, dialog_attr);
+    PrintWrap(dialog, prompt, width - 3, 2, 3);
+
+    l1len = strlen(label1);
+    if (label2)
+	l2len = strlen(label2);
+    else {
+	l2len = button = 0;
+    }
+
+    x1 = (width - (l1len + l2len)) / (label2 ? 3 : 2);
+    x2 = x1 + x1 + l1len;
+    y = height - 3;
+    if (!button) {
+	if (label2)
+	    PaintButton(dialog, label2, y, x2, FALSE);
+	PaintButton(dialog, label1, y, x1, TRUE);
+    }
+    else {
+	PaintButton(dialog, label1, y, x1, FALSE);
+	if (label2)
+	    PaintButton(dialog, label2, y, x2, TRUE);
+    }
+    wrefresh(dialog);
+
+    /*CONSTCOND*/
+    while (1) {
+	key = wgetch(dialog);
+	    switch (key) {
+		case KEY_LEFT:
+		case KEY_RIGHT:
+		    if (!button) {
+			if (label2) {
+			    button = 1;
+			    PaintButton(dialog, label1, y, x1, FALSE);
+			    PaintButton(dialog, label2, y, x2, TRUE);
+			}
+
+		    }
+		    else {
+			if (label2) {
+			    button = 0;
+			    PaintButton(dialog, label2, y, x2, FALSE);
+			    PaintButton(dialog, label1, y, x1, TRUE);
+			}
+		    }
+		    wrefresh(dialog);
+		    break;
+		case ' ':
+		case '\r':
+		case '\n':
+		    delwin(dialog);
+		    return button;
+	}
+    }
+    /*NOTREACHED*/
+}
+
+static void
+PaintWindow(WINDOW *win, char *title_str, int y, int x, int height, int width)
+{
+    int i, j;
+
+    if (title_str != NULL) {
+	j = (width - strlen(title_str)) / 2 - 1;
+
+	wattrset(win, title_attr);
+	wmove(win, x, y);
+	for (i = 0; i < j; i++)
+	    waddch(win, ' ');
+	waddstr(win, title_str);
+	for (; i < width; i++)
+	    waddch(win, ' ');
+    }
+
+    wattrset(win, 0);
+
+    for (i = 1; i < height; i++) {
+	wmove(win, y + i, x);
+	for (j = 0; j < width; j++)
+	    if (i == height - 1 && !j)
+		waddch(win, highlight_border_attr | ACS_LLCORNER);
+	    else if (i == height - 1 && j == width - 1)
+		waddch(win, shadow_border_attr | ACS_LRCORNER);
+	    else if (i == height - 1)
+		waddch(win, shadow_border_attr | ACS_HLINE);
+	    else if (!j)
+		waddch(win, highlight_border_attr | ACS_VLINE);
+	    else if (j == width - 1)
+		waddch(win, shadow_border_attr | ACS_VLINE);
+	    else
+		waddch(win, dialog_attr | ' ');
+    }
+
+}
+
+static void
+PaintBox(WINDOW *win, int y, int x, int height, int width)
+{
+    int i, j;
+
+    wattrset(win, 0);
+
+    for (i = 0; i < height; i++) {
+	wmove(win, y + i, x);
+	for (j = 0; j < width; j++)
+	    if (!i && !j)
+		waddch(win, shadow_border_attr | ACS_ULCORNER);
+	    else if (i == height - 1 && !j)
+		waddch(win, shadow_border_attr | ACS_LLCORNER);
+	    else if (!i && j == width-1)
+		waddch(win, highlight_border_attr | ACS_URCORNER);
+	    else if (i == height - 1 && j == width - 1)
+		waddch(win, highlight_border_attr | ACS_LRCORNER);
+	    else if (!i)
+		waddch(win, shadow_border_attr | ACS_HLINE);
+	    else if (i == height - 1)
+		waddch(win, highlight_border_attr | ACS_HLINE);
+	    else if (!j)
+		waddch(win, shadow_border_attr | ACS_VLINE);
+	    else if (j == width - 1)
+		waddch(win, highlight_border_attr | ACS_VLINE);
+	    else
+		waddch(win, dialog_attr | ' ');
+    }
+
+}
+
+static void
+PaintButton(WINDOW *win, char *label, int y, int x, int selected)
+{
+    int i, temp;
+
+    wmove(win, y, x);
+    wattrset(win, selected ? button_active_attr : button_inactive_attr);
+    waddstr(win, selected ? "[" : " ");
+    temp = strspn(label, " ");
+    label += temp;
+    wattrset(win, selected ? button_active_attr : button_inactive_attr);
+    for (i = 0; i < temp; i++)
+      waddch(win, ' ');
+    wattrset(win, selected ? button_active_attr : button_inactive_attr);
+    waddch(win, label[0]);
+    wattrset(win, selected ? button_active_attr : button_inactive_attr);
+    waddstr(win, label + 1);
+    wattrset(win, selected ? button_active_attr : button_inactive_attr);
+    waddstr(win, selected ? "]" : " ");
+    wmove(win, y, x + temp + 1);
+}
+
+static void
+PrintWrap(WINDOW *win, char *prompt, int width, int y, int x)
+{
+    int cur_x, cur_y, len, yinc;
+    char *word, *tempstr = XtMalloc(strlen(prompt) + 1);
+
+    cur_x = x;
+    cur_y = y;
+
+    while (*prompt == '\n') {
+	++cur_y;
+	++prompt;
+    }
+
+    strcpy(tempstr, prompt);
+
+    for (word = strtok(tempstr, " \n"); word != NULL; word = strtok(NULL, " \n")) {
+	yinc = 0;
+	len = strlen(word);
+	while (prompt[word - tempstr + len + yinc] == '\n')
+	    ++yinc;
+	if (cur_x + strlen(word) > width) {
+	    cur_y++;
+	    cur_x = x;
+	}
+	wmove(win, cur_y, cur_x);
+	waddstr(win, word);
+	getyx(win, cur_y, cur_x);
+	if (yinc) {
+	    cur_y += yinc;
+	    cur_x = x;
+	}
+	else
+	    cur_x++;
+    }
+
+    free(tempstr);
+}
+
+static int
+DialogMenu(char *title, char *prompt, int height, int width, int menu_height,
+	   int item_no, char **items, char *label1, char *label2, int choice)
+{
+    int i, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0,
+	scrlx = 0, max_choice, nscroll, max_scroll, x1, x2, l1len, l2len;
+    WINDOW *dialog, *menu;
+
+    max_choice = MIN(menu_height, item_no);
+    max_scroll = MAX(0, item_no - max_choice);
+
+    x = (COLS - width) / 2;
+    y = (LINES - height) / 2;
+  
+    dialog = newwin(height, width, y, x);
+    keypad(dialog, TRUE);
+
+    PaintWindow(dialog, title, 0, 0, height, width);
+
+    wattrset(dialog, dialog_attr);
+    PrintWrap(dialog, prompt, width - 3, 2, 3);
+
+    l1len = strlen(label1);
+    l2len = strlen(label2);
+
+    x1 = (width - (l1len + l2len)) / 3;
+    x2 = x1 + x1 + l1len;
+
+    menu_width = width - 6;
+    getyx(dialog, cur_y, cur_x);
+    box_y = cur_y + 1;
+    box_x = (width - menu_width) / 2 - 1;
+
+    menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1);
+    keypad(menu, TRUE);
+
+    /* draw a box around the menu items */
+    PaintBox(dialog, box_y, box_x, menu_height + 2, menu_width + 2);
+
+    item_x = 3;
+
+    if (choice > menu_height) {
+	scrlx = MIN(max_scroll, choice);
+	choice -= scrlx;
+    }
+
+    for (i = 0; i < max_choice; i++)
+	PaintItem(menu, items[i + scrlx], i, i == choice);
+    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+    wnoutrefresh(menu);
+
+    x = width / 2 - 11;
+    y = height - 3;
+    PaintButton(dialog, label2, y, x2, FALSE);
+    PaintButton(dialog, label1, y, x1, TRUE);
+    wrefresh(dialog);
+
+    /*CONSTCOND*/
+    while (1) {
+	i = choice;
+	key = wgetch(dialog);
+
+	if (menu_height > 1 && key == KEY_PPAGE) {
+	    if (!choice) {
+		if (scrlx) {
+		    /* Scroll menu down */
+		    getyx(dialog, cur_y, cur_x);
+
+		    nscroll = max_choice > scrlx ? -scrlx : -max_choice;
+		    scrollok(menu, TRUE);
+		    wscrl(menu, nscroll);
+		    scrollok(menu, FALSE);
+
+		    PaintItem(menu, items[i = scrlx + nscroll], 0, TRUE);
+		    for (++i; i <= scrlx; i++)
+			PaintItem(menu, items[i], i - (scrlx + nscroll), FALSE);
+		    scrlx += nscroll;
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    i = 0;
+	}
+	else if (menu_height > 1 && key == KEY_NPAGE) {
+	    if (choice == max_choice - 1) {
+		if (scrlx < max_scroll) {
+		    /* Scroll menu up */
+		    getyx(dialog, cur_y, cur_x);
+
+		    nscroll = (scrlx + max_choice > max_scroll ?
+			       max_scroll : scrlx + max_choice) - scrlx;
+		    scrollok(menu, TRUE);
+		    wscrl(menu, nscroll);
+		    scrollok(menu, FALSE);
+
+		    scrlx += nscroll;
+		    for (i = 0; i < max_choice - 1; i++)
+			PaintItem(menu, items[i + scrlx], i, FALSE);
+		    PaintItem(menu, items[i + scrlx], max_choice - 1, TRUE);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    i = max_choice - 1;
+	}
+	else if (key == KEY_UP) {
+	    if (!choice) {
+		if (scrlx) {
+		    /* Scroll menu down */
+		    getyx(dialog, cur_y, cur_x);
+		    if (menu_height > 1) {
+			PaintItem(menu, items[scrlx], 0, FALSE);
+			scrollok(menu, TRUE);
+			wscrl(menu, - 1);
+			scrollok(menu, FALSE);
+		    }
+		    scrlx--;
+		    PaintItem(menu, items[scrlx], 0, TRUE);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    else
+		i = choice - 1;
+	}
+	else if (key == KEY_DOWN) {
+	    if (choice == max_choice - 1) {
+		if (scrlx + choice < item_no - 1) {
+		    /* Scroll menu up */
+		    getyx(dialog, cur_y, cur_x);
+		    if (menu_height > 1) {
+			PaintItem(menu, items[scrlx + max_choice - 1], max_choice - 1, FALSE);
+			scrollok(menu, TRUE);
+			scroll(menu);
+			scrollok(menu, FALSE);
+		    }
+		    scrlx++;
+		    PaintItem(menu, items[scrlx + max_choice - 1], max_choice - 1, TRUE);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    else
+		i = MIN(choice + 1, item_no - 1);
+	}
+
+	if (i != choice) {
+	    getyx(dialog, cur_y, cur_x);
+	    PaintItem(menu, items[scrlx + choice], choice, FALSE);
+
+	    choice = i;
+	    PaintItem(menu, items[scrlx + choice], choice, TRUE);
+	    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+	    wnoutrefresh(menu);
+	    wmove(dialog, cur_y, cur_x);
+	    wrefresh(dialog);
+	    continue;
+	}
+
+	switch (key) {
+	    case TAB:
+	    case KEY_LEFT:
+	    case KEY_RIGHT:
+		if (!button) {
+		    button = 1;
+		    PaintButton(dialog, label1, y, x1, FALSE);
+		    PaintButton(dialog, label2, y, x2, TRUE);
+		}
+		else {
+		    button = 0;
+		    PaintButton(dialog, label2, y, x2, FALSE);
+		    PaintButton(dialog, label1, y, x1, TRUE);
+		}
+		wrefresh(dialog);
+		break;
+	    case ' ':
+	    case '\r':
+	    case '\n':
+		delwin(dialog);
+		return (!button ? scrlx + choice : -1);
+	    default:
+		for (i = scrlx + choice + 1; i < item_no; i++)
+		    if (toupper(items[i][0]) == toupper(key))
+			break;
+		if (i == item_no) {
+		    for (i = 0; i < scrlx + choice; i++)
+			if (toupper(items[i][0]) == toupper(key))
+			    break;
+		}
+		getyx(dialog, cur_y, cur_x);
+		if (i < item_no && i != scrlx + choice) {
+		    if (i >= scrlx && i < scrlx + max_choice) {
+			/* it is already visible */
+			PaintItem(menu, items[scrlx + choice], choice, FALSE);
+			choice = i - scrlx;
+		    }
+		    else {
+			scrlx = MIN(i, max_scroll);
+			choice = i - scrlx;
+			for (i = 0; i < max_choice; i++)
+			    if (i != choice)
+				PaintItem(menu, items[scrlx + i], i, FALSE);
+		    }
+		    PaintItem(menu, items[scrlx + choice], choice, TRUE);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wmove(dialog, cur_y, cur_x);
+		    wrefresh(dialog);
+		}
+		break;
+	}
+    }
+    /*NOTREACHED*/
+}
+
+static void
+PaintItem(WINDOW *win, char *item, int choice, int selected)
+{
+    int i;
+
+    wattrset(win, selected ? title_attr : dialog_attr);
+    wmove(win, choice, 1);
+    for (i = 1; i < menu_width; i++)
+	waddch(win, ' ');
+    wmove(win, choice, item_x);
+    wattrset(win, selected ? title_attr : dialog_attr);
+    waddstr(win, item);
+}
+
+static void
+PaintScroller(WINDOW *win, int offset, int lenght, int visible)
+{
+    int i, pos;
+
+    if (lenght > visible)
+	pos = (visible / (double)lenght) * offset;
+    else
+	pos = offset;
+    wattrset(win, shadow_border_attr);
+    for (i = 0; i < visible; i++) {
+	wmove(win, i, 0);
+	waddch(win, i == pos ? ACS_BLOCK : ACS_VLINE);
+    }
+}
+
+static int
+DialogCheckBox(char *title, char *prompt, int height, int width, int menu_height,
+	       int item_no, char **items, char *label1, char *label2, char *checks)
+{
+    int i, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0,
+	scrlx = 0, max_choice, nscroll, max_scroll, x1, x2, l1len, l2len;
+    WINDOW *dialog, *menu;
+
+    max_choice = MIN(menu_height, item_no);
+    max_scroll = MAX(0, item_no - max_choice);
+
+    x = (COLS - width) / 2;
+    y = (LINES - height) / 2;
+  
+    dialog = newwin(height, width, y, x);
+    keypad(dialog, TRUE);
+
+    PaintWindow(dialog, title, 0, 0, height, width);
+
+    wattrset(dialog, dialog_attr);
+    PrintWrap(dialog, prompt, width - 3, 2, 3);
+
+    l1len = strlen(label1);
+    l2len = strlen(label2);
+
+    x1 = (width - (l1len + l2len)) / 3;
+    x2 = x1 + x1 + l1len;
+
+    menu_width = width - 6;
+    getyx(dialog, cur_y, cur_x);
+    box_y = cur_y + 1;
+    box_x = (width - menu_width) / 2 - 1;
+
+    menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1);
+    keypad(menu, TRUE);
+
+    /* draw a box around the menu items */
+    PaintBox(dialog, box_y, box_x, menu_height + 2, menu_width + 2);
+
+    item_x = 3;
+
+    for (i = 0; i < max_choice; i++)
+	PaintCheckItem(menu, items[i + scrlx], i, i == 0, checks[i + scrlx]);
+    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+    wnoutrefresh(menu);
+
+    x = width / 2 - 11;
+    y = height - 3;
+    PaintButton(dialog, label2, y, x2, FALSE);
+    PaintButton(dialog, label1, y, x1, TRUE);
+    wrefresh(dialog);
+
+    /*CONSTCOND*/
+    while (1) {
+	i = choice;
+	key = wgetch(dialog);
+
+	if (menu_height > 1 && key == KEY_PPAGE) {
+	    if (!choice) {
+		if (scrlx) {
+		    /* Scroll menu down */
+		    getyx(dialog, cur_y, cur_x);
+
+		    nscroll = max_choice > scrlx ? -scrlx : -max_choice;
+		    scrollok(menu, TRUE);
+		    wscrl(menu, nscroll);
+		    scrollok(menu, FALSE);
+
+		    i = scrlx + nscroll;
+		    PaintCheckItem(menu, items[i], 0, TRUE, checks[i]);
+		    for (++i; i <= scrlx; i++)
+			PaintCheckItem(menu, items[i], i - (scrlx + nscroll), FALSE, checks[i]);
+		    scrlx += nscroll;
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    i = 0;
+	}
+	else if (menu_height > 1 && key == KEY_NPAGE) {
+	    if (choice == max_choice - 1) {
+		if (scrlx < max_scroll) {
+		    /* Scroll menu up */
+		    getyx(dialog, cur_y, cur_x);
+
+		    nscroll = (scrlx + max_choice > max_scroll ?
+			       max_scroll : scrlx + max_choice) - scrlx;
+		    scrollok(menu, TRUE);
+		    wscrl(menu, nscroll);
+		    scrollok(menu, FALSE);
+
+		    scrlx += nscroll;
+		    for (i = 0; i < max_choice - 1; i++)
+			PaintCheckItem(menu, items[i + scrlx], i, FALSE, checks[i + scrlx]);
+		    PaintCheckItem(menu, items[i + scrlx], max_choice - 1, TRUE, checks[i + scrlx]);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    i = max_choice - 1;
+	}
+	else if (key == KEY_UP) {
+	    if (!choice) {
+		if (scrlx) {
+		    /* Scroll menu down */
+		    getyx(dialog, cur_y, cur_x);
+		    if (menu_height > 1) {
+			PaintCheckItem(menu, items[scrlx], 0, FALSE, checks[scrlx]);
+			scrollok(menu, TRUE);
+			wscrl(menu, - 1);
+			scrollok(menu, FALSE);
+		    }
+		    scrlx--;
+		    PaintCheckItem(menu, items[scrlx], 0, TRUE, checks[scrlx]);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    else
+		i = choice - 1;
+	}
+	else if (key == KEY_DOWN) {
+	    if (choice == max_choice - 1) {
+		if (scrlx + choice < item_no - 1) {
+		    /* Scroll menu up */
+		    getyx(dialog, cur_y, cur_x);
+		    if (menu_height > 1) {
+			PaintCheckItem(menu, items[scrlx + max_choice - 1], max_choice - 1, FALSE, checks[scrlx + max_choice - 1]);
+			scrollok(menu, TRUE);
+			scroll(menu);
+			scrollok(menu, FALSE);
+		    }
+		    scrlx++;
+		    PaintCheckItem(menu, items[scrlx + max_choice - 1], max_choice - 1, TRUE, checks[scrlx + max_choice - 1]);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wrefresh(dialog);
+		    continue;
+		}
+	    }
+	    else
+		i = MIN(choice + 1, item_no - 1);
+	}
+
+	if (i != choice) {
+	    getyx(dialog, cur_y, cur_x);
+	    PaintCheckItem(menu, items[scrlx + choice], choice, FALSE, checks[scrlx + choice]);
+
+	    choice = i;
+	    PaintCheckItem(menu, items[scrlx + choice], choice, TRUE, checks[scrlx + choice]);
+	    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+	    wnoutrefresh(menu);
+	    wmove(dialog, cur_y, cur_x);
+	    wrefresh(dialog);
+	    continue;
+	}
+
+	switch (key) {
+	    case TAB:
+	    case KEY_LEFT:
+	    case KEY_RIGHT:
+		if (!button) {
+		    button = 1;
+		    PaintButton(dialog, label1, y, x1, FALSE);
+		    PaintButton(dialog, label2, y, x2, TRUE);
+		}
+		else {
+		    button = 0;
+		    PaintButton(dialog, label2, y, x2, FALSE);
+		    PaintButton(dialog, label1, y, x1, TRUE);
+		}
+		wrefresh(dialog);
+		break;
+	    case ' ':
+		getyx(dialog, cur_y, cur_x);
+		checks[scrlx + choice] = !checks[scrlx + choice];
+		PaintCheckItem(menu, items[scrlx + choice], choice, TRUE, checks[scrlx + choice]);
+		wmove(dialog, cur_y, cur_x);
+		wnoutrefresh(menu);
+		wrefresh(dialog);
+		break;
+	    case '\r':
+	    case '\n':
+		delwin(dialog);
+		return (!button ? 0 : -1);
+	    default:
+		for (i = scrlx + choice + 1; i < item_no; i++)
+		    if (toupper(items[i][0]) == toupper(key))
+			break;
+		if (i == item_no) {
+		    for (i = 0; i < scrlx + choice; i++)
+			if (toupper(items[i][0]) == toupper(key))
+			    break;
+		}
+		getyx(dialog, cur_y, cur_x);
+		if (i < item_no && i != scrlx + choice) {
+		    if (i >= scrlx && i < scrlx + max_choice) {
+			/* it is already visible */
+			PaintCheckItem(menu, items[scrlx + choice], choice, FALSE, checks[scrlx + choice]);
+			choice = i - scrlx;
+		    }
+		    else {
+			scrlx = MIN(i, max_scroll);
+			choice = i - scrlx;
+			for (i = 0; i < max_choice; i++)
+			    if (i != choice)
+				PaintCheckItem(menu, items[scrlx + i], i, FALSE, checks[scrlx + i]);
+		    }
+		    PaintCheckItem(menu, items[scrlx + choice], choice, TRUE, checks[scrlx + choice]);
+		    PaintScroller(menu, scrlx + choice, item_no, menu_height);
+		    wnoutrefresh(menu);
+		    wmove(dialog, cur_y, cur_x);
+		    wrefresh(dialog);
+		}
+		break;
+	}
+    }
+    /*NOTREACHED*/
+}
+
+static void
+PaintCheckItem(WINDOW *win, char *item, int choice, int selected, int checked)
+{
+    int i;
+
+    wattrset(win, selected ? title_attr : dialog_attr);
+    wmove(win, choice, 1);
+    for (i = 1; i < menu_width; i++)
+	waddch(win, ' ');
+    wmove(win, choice, item_x);
+    wattrset(win, selected ? title_attr : dialog_attr);
+    wprintw(win, "[%c] ", checked ? 'X' : ' ');
+    waddstr(win, item);
+}
+
+static char *
+DialogInput(char *title, char *prompt, int height, int width, char *init,
+	    char *label1, char *label2, int def_button)
+{
+    int i, x, y, box_y, box_x, box_width, len,
+	input_x = 0, scrlx = 0, key = 0, button = -1, x1, x2, l1len, l2len;
+    char instr[1024 + 1];
+    WINDOW *dialog;
+
+    x = (COLS - width) / 2;
+    y = (LINES - height) / 2;
+
+    dialog = newwin(height, width, y, x);
+    keypad(dialog, TRUE);
+
+    PaintWindow(dialog, title, 0, 0, height, width);
+
+    wattrset(dialog, dialog_attr);
+    PrintWrap(dialog, prompt, width - 3, 2, 3);
+
+    l1len = strlen(label1);
+    l2len = strlen(label2);
+
+    x1 = (width - (l1len + l2len)) / 3;
+    x2 = x1 + x1 + l1len;
+
+    box_width = width - 6;
+    getyx(dialog, y, x);
+    box_y = y + 2;
+    box_x = (width - box_width) / 2;
+    PaintBox(dialog, y + 1, box_x - 1, 3, box_width + 2);
+
+    x = width / 2 - 11;
+    y = height - 3;
+    PaintButton(dialog, label2, y, x2, def_button == 1);
+    PaintButton(dialog, label1, y, x1, def_button == 0);
+
+    memset(instr, '\0', sizeof(instr));
+    wmove(dialog, box_y, box_x);
+    wattrset(dialog, dialog_attr);
+    if (init)
+	strncpy(instr, init, sizeof(instr) - 2);
+
+    input_x = len = strlen(instr);
+    if (input_x >= box_width) {
+	scrlx = input_x - box_width + 1;
+	input_x = box_width - 1;
+	for (i = 0; i < box_width - 1; i++)
+	    waddch(dialog, instr[scrlx + i]);
+    }
+    else
+	waddstr(dialog, instr);
+
+    wmove(dialog, box_y, box_x + input_x);
+  
+    wrefresh(dialog);
+
+    while (1) {
+	key = wgetch(dialog);
+	if (button == -1) {	    /* Input box selected */
+	    switch (key) {
+		case TAB:
+		case KEY_UP:
+		case KEY_DOWN:
+		    break;
+		case KEY_LEFT:
+		    if (scrlx && !input_x) {
+			--scrlx;
+			wmove(dialog, box_y, box_x);
+			for (i = 0; i < box_width; i++)
+			    waddch(dialog, instr[scrlx + input_x + i] ? instr[scrlx + input_x + i] : ' ');
+			wmove(dialog, box_y, input_x + box_x);
+			wrefresh(dialog);
+		    }
+		    else if (input_x) {
+			wmove(dialog, box_y, --input_x + box_x);
+			wrefresh(dialog);
+		    }
+		    continue;
+		case KEY_RIGHT:
+		    if (input_x + scrlx < len) {
+			if (input_x == box_width - 1) {
+			    ++scrlx;
+			    wmove(dialog, box_y, box_x);
+			    for (i = scrlx; i < scrlx + box_width; i++)
+				waddch(dialog, instr[i] ? instr[i] : ' ');
+			    wmove(dialog, box_y, input_x + box_x);
+			    wrefresh(dialog);
+			}
+			else {
+			    wmove(dialog, box_y, ++input_x + box_x);
+			    wrefresh(dialog);
+			}
+		    }
+		    continue;
+		case KEY_BACKSPACE:
+		case 0177:
+#if defined(__SCO__) || defined(__UNIXWARE__)
+		case '\b':
+#endif
+		    if (input_x || scrlx) {
+			wattrset(dialog, dialog_attr);
+
+			if (scrlx + input_x < len)
+			    memmove(instr + scrlx + input_x - 1,
+				    instr + scrlx + input_x,
+				    len - (scrlx + input_x));
+			instr[--len] = '\0';
+
+			if (!input_x) {
+			    scrlx = scrlx < box_width - 1 ? 0 : scrlx - (box_width - 1);
+			    wmove(dialog, box_y, box_x);
+			    for (i = 0; i < box_width; i++)
+				waddch(dialog, instr[scrlx + input_x + i] ? instr[scrlx + input_x + i] : ' ');
+			    input_x = len - scrlx;
+			}
+			else {
+			    wmove(dialog, box_y, --input_x + box_x);
+			    for (i = scrlx + input_x; i < len &&
+				 i < scrlx + box_width; i++)
+				waddch(dialog, instr[i]);
+			    if (i < scrlx + box_width)
+				waddch(dialog, ' ');
+			}
+			wmove(dialog, box_y, input_x + box_x);
+			wrefresh(dialog);
+		    }
+		    continue;
+		case KEY_HOME:
+		case CONTROL_A:
+		    wmove(dialog, box_y, box_x);
+		    if (scrlx != 0) {
+			scrlx = 0;
+			for (i = 0; i < box_width; i++)
+			    waddch(dialog, instr[i] ? instr[i] : ' ');
+		    }
+		    input_x = 0;
+		    wmove(dialog, box_y, box_x);
+		    wrefresh(dialog);
+		    break;
+		case CONTROL_D:
+		    if (input_x + scrlx < len) {
+			memmove(instr + scrlx + input_x,
+				    instr + scrlx + input_x + 1,
+				    len - (scrlx + input_x));
+			instr[--len] = '\0';
+			for (i = scrlx + input_x; i < len &&
+			     i < scrlx + box_width; i++)
+			    waddch(dialog, instr[i]);
+			if (i < scrlx + box_width)
+			    waddch(dialog, ' ');
+			wmove(dialog, box_y, input_x + box_x);
+			wrefresh(dialog);
+		    }
+		    break;
+		case CONTROL_E:
+		case KEY_END:
+		    if (box_width + scrlx < len) {
+			input_x = box_width - 1;
+			scrlx = len - box_width + 1;
+			wmove(dialog, box_y, box_x);
+			for (i = scrlx; i < scrlx + box_width; i++)
+			    waddch(dialog, instr[i] ? instr[i] : ' ');
+			wmove(dialog, box_y, input_x + box_x);
+			wrefresh(dialog);
+		    }
+		    else {
+			input_x = len - scrlx;
+			wmove(dialog, box_y, input_x + box_x);
+			wrefresh(dialog);
+		    }
+		    break;
+		case CONTROL_K:
+		    if (len) {
+			for (i = input_x; i < box_width; i++)
+			    waddch(dialog, ' ');
+			for (i = scrlx + input_x; i < len; i++)
+			    instr[i] = '\0';
+			len = scrlx + input_x;
+			wmove(dialog, box_y, box_x + input_x);
+			wrefresh(dialog);
+		    }
+		    break;
+		default:
+		    if (key < 0x100 && isprint(key)) {
+			if (scrlx + input_x < sizeof(instr) - 1) {
+			    wattrset(dialog, dialog_attr);
+			    if (scrlx + input_x < len) {
+				memmove(instr + scrlx + input_x + 1,
+					instr + scrlx + input_x,
+					len - (scrlx + input_x));
+			    }
+			    instr[scrlx + input_x] = key;
+			    instr[++len] = '\0';
+			    if (input_x == box_width - 1) {
+				scrlx++;
+				wmove(dialog, box_y, box_x);
+				for (i = 0; i < box_width - 1; i++)
+				    waddch(dialog, instr[scrlx + i]);
+			    }
+			    else {
+				wmove(dialog, box_y, input_x++ + box_x);
+				for (i = scrlx + input_x - 1; i < len &&
+				     i < scrlx + box_width; i++)
+				    waddch(dialog, instr[i]);
+				wmove(dialog, box_y, input_x + box_x);
+			    }
+			    wrefresh(dialog);
+			}
+			else
+			    flash();	    /* Alarm user about overflow */
+			continue;
+		    }
+		}
+	    }
+
+	switch (key) {
+	    case KEY_UP:
+	    case KEY_LEFT:
+	        switch (button) {
+		    case -1:
+			button = 1;	/* Indicates "Cancel" button is selected */
+			PaintButton(dialog, label1, y, x1, FALSE);
+			PaintButton(dialog, label2, y, x2, TRUE);
+			wrefresh(dialog);
+			break;
+		    case 0:
+			button = -1;	/* Indicates input box is selected */
+			PaintButton(dialog, label2, y, x2, FALSE);
+			PaintButton(dialog, label1, y, x1, TRUE);
+			wmove(dialog, box_y, box_x + input_x);
+			wrefresh(dialog);
+			break;
+		    case 1:
+			button = 0;	/* Indicates "OK" button is selected */
+			PaintButton(dialog, label2, y, x2, FALSE);
+			PaintButton(dialog, label1, y, x1, TRUE);
+			wrefresh(dialog);
+			break;
+		}
+		break;
+	    case TAB:
+	    case KEY_DOWN:
+	    case KEY_RIGHT:
+		switch (button) {
+		    case -1:
+			button = 0;	/* Indicates "OK" button is selected */
+			PaintButton(dialog, label2, y, x2, FALSE);
+			PaintButton(dialog, label1, y, x1, TRUE);
+			wrefresh(dialog);
+			break;
+		    case 0:
+			button = 1;	/* Indicates "Cancel" button is selected */
+			PaintButton(dialog, label1, y, x1, FALSE);
+			PaintButton(dialog, label2, y, x2, TRUE);
+			wrefresh(dialog);
+			break;
+		    case 1:
+			button = -1;	/* Indicates input box is selected */
+			PaintButton(dialog, label2, y, x2, FALSE);
+			PaintButton(dialog, label1, y, x1, TRUE);
+			wmove(dialog, box_y, box_x + input_x);
+			wrefresh(dialog);
+			break;
+		}
+		break;
+	    case ' ':
+	    case '\r':
+	    case '\n':
+		delwin(dialog);
+		return (button != 1 ? XtNewString(instr) : NULL);
+	}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/Cards	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,3135 @@
+# $XConsortium: Cards /main/27 1996/10/28 05:43:53 kaleb $
+# This is the database of card definitions used by xf86config.
+# Each definition should have a NAME entry, CHIPSET (descriptive) and
+# SERVER (one of Mono, VGA16, SVGA, S3, 8514, Mach8, Mach32, Mach64, AGX,
+# P9000, W32, I128).
+# A reference to another definition is made with SEE (already defined
+# entries are not overridden).
+# Optional entries are RAMDAC (identifier), CLOCKCHIP (identifier),
+# DACSPEED, NOCLOCKPROBE (advises never to probe clocks), UNSUPPORTED
+# (indicates card that is not yet properly supported by a dedicated
+# server). A LINE entry adds a line of text to be included in the
+# Device section (can include options or comments).
+# There's no CLOCKS option (although a Clocks line can be included
+# with LINE), as it is very undesirable to have a Clocks line that
+# is incorrect. The idea is that the Clocks are probed for to be
+# sure (a commented suggested Clocks line can be included).
+#
+# The majority of entries are just a binding of a model name to a
+# chipset/server and untested.
+#
+# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.79 2002/10/16 01:31:05 dawes Exp $
+
+# VGA
+
+NAME * Generic VGA compatible
+SERVER VGA16
+DRIVER vga
+
+NAME * Generic VESA compatible
+SERVER VGA16
+DRIVER vesa
+
+NAME * Unsupported VGA compatible
+SERVER VGA16
+DRIVER vga
+UNSUPPORTED
+
+
+#	  #
+# generic #
+#	  #
+
+NAME ** Alliance Pro Motion (generic)      [apm]
+#CHIPSET apm
+SERVER SVGA
+DRIVER apm
+LINE #Option "no_accel"
+
+NAME ** Ark Logic (generic)                [ark]
+#CHIPSET ark
+SERVER SVGA
+DRIVER ark
+
+NAME ** AST (generic)                      [ast]
+#CHIPSET ast
+SERVER SVGA
+DRIVER ast
+
+NAME ** ATI (generic)                      [ati]
+#CHIPSET ati
+SERVER SVGA
+DRIVER ati
+
+NAME ** ATI Rage 128 based (generic)       [r128]
+#CHIPSET r128
+SERVER SVGA
+DRIVER r128
+
+NAME ** ATI Radeon (generic)               [radeon]
+#CHIPSET radeon
+SERVER SVGA
+DRIVER radeon
+
+NAME ** Chips and Technologies (generic)   [chips]
+#CHIPSET chips
+SERVER SVGA
+DRIVER chips
+LINE # Option "suspend_hack"
+LINE # Option "STN"
+LINE # Option "no_stretch"
+LINE # Option "no_center"
+LINE # Option "use_modeline"
+LINE # Option "fix_panel_size"
+LINE # videoram 512
+LINE # Option "noaccel"
+LINE # Option "no_bitblt"
+LINE # Option "xaa_no_color_exp"
+LINE # Option "xaa_benchmark"
+LINE # Option "hw_cursor"
+LINE # Option "nolinear"
+LINE # MemBase 0x03b00000
+LINE # Option "hw_clocks"
+LINE # Textclockfreq 25.175
+
+NAME ** Cirrus Logic (generic)             [cirrus]
+#CHIPSET cirrus
+SERVER SVGA
+DRIVER cirrus
+LINE # MemBase 0x00e00000		# ISA card that maps to 14Mb
+LINE # MemBase 0x04000000		# VLB card that maps to 64Mb
+LINE # MemBase 0x80000000		# VLB card that maps to 2048Mb
+LINE # MemBase 0x02000000		# VLB card that maps to 32Mb
+LINE # Option "linear"
+LINE # Option "fifo_conservative"
+
+NAME ** Cyrix MediaGX (generic)            [cyrix]
+#CHIPSET cyrix
+SERVER SVGA
+DRIVER cyrix
+
+NAME ** Linux framebuffer (generic)        [fbdev]
+#CHIPSET fbdev
+SERVER SVGA
+DRIVER fbdev
+
+NAME ** 3DLabs, TI (generic)               [glint]
+#CHIPSET glint
+SERVER SVGA
+DRIVER glint
+LINE #Option "no_accel"
+
+NAME ** Number Nine I128 (generic)         [i128]
+#CHIPSET i128
+SERVER SVGA
+DRIVER i128
+
+NAME ** Intel i740 (generic)               [i740]
+#CHIPSET i740
+SERVER SVGA
+DRIVER i740
+
+NAME ** Intel i810 (generic)               [i810]
+#CHIPSET i810
+SERVER SVGA
+DRIVER i810
+
+NAME ** Matrox Graphics (generic)          [mga]
+#CHIPSET mga
+SERVER SVGA
+DRIVER mga
+LINE # Option "mga_sdram"
+
+NAME ** NeoMagic (generic)                 [neomagic]
+#CHIPSET neomagic
+SERVER SVGA
+DRIVER neomagic
+LINE # Chipset    "NM2160"
+LINE # IOBase     0xfea00000
+LINE # MemBase    0xfd000000
+LINE # VideoRam   2048
+LINE # DacSpeed   90
+LINE # Option     "linear"
+LINE # Option     "nolinear"
+LINE # Option     "sw_cursor"
+LINE # Option     "hw_cursor"
+LINE # Option     "no_accel"
+LINE # Option     "intern_disp"
+LINE # Option     "extern_disp"
+LINE # Option     "mmio"
+LINE # Option     "no_mmio"
+LINE # Option     "lcd_center"
+LINE # Option     "no_stretch"
+
+NAME ** NVIDIA (generic)                   [nv]
+#CHIPSET nv
+SERVER SVGA
+DRIVER nv
+
+NAME ** Rendition (generic)                [rendition]
+#CHIPSET rendition
+SERVER SVGA
+DRIVER rendition
+LINE # Option "sw_cursor"
+
+NAME ** S3 (not ViRGE or Savage) (generic) [s3]
+#CHIPSET s3
+SERVER SVGA
+DRIVER s3
+
+NAME ** S3 ViRGE (generic)                 [s3virge]
+#CHIPSET s3virge
+SERVER SVGA
+DRIVER s3virge
+LINE # Option "xaa_benchmark"
+LINE # Option "fifo_moderate"
+LINE # Option "pci_burst_on"
+LINE # Option "pci_retry"
+LINE # Option "lcd_center"
+LINE # Set_LCDClk  <pixel_clock_for_LCD>
+
+NAME ** S3 Savage (generic)                [savage]
+#CHIPSET savage
+SERVER SVGA
+DRIVER savage
+
+NAME ** Silicon Motion (generic)           [siliconmotion]
+#CHIPSET siliconmotion
+SERVER SVGA
+DRIVER siliconmotion
+
+NAME ** SiS (generic)                      [sis]
+#CHIPSET sis
+SERVER SVGA
+DRIVER sis
+LINE # Option "no_accel"
+LINE # Option "fifo_moderate"
+LINE # Option "fifo_conserv"
+LINE # Option "fifo_aggressive"
+LINE # Option "no_BitBlt"
+LINE # Option "fast_vram"
+LINE # Option "pci_burst_on"
+LINE # Option "xaa_benchmark"
+LINE # Option "ext_eng_queue"
+
+NAME ** 3Dfx (generic)                     [tdfx]
+#CHIPSET tdfx
+SERVER SVGA
+DRIVER tdfx
+
+NAME ** DEC TGA (generic)                  [tga]
+#CHIPSET tga
+SERVER SVGA
+DRIVER tga
+
+NAME ** Trident (generic)                  [trident]
+#CHIPSET trident
+SERVER SVGA
+DRIVER trident
+
+NAME ** Tseng Labs (generic)               [tseng]
+#CHIPSET tseng
+SERVER SVGA
+DRIVER tseng
+LINE # Option "linear"
+LINE # Option "noaccel"
+LINE # Option "power_saver"
+LINE # Option "fast_dram"
+LINE # Option "pci_retry"
+LINE # Option "hibit_high"
+LINE # Option "hibit_low"
+LINE # MemBase 0x3C00000
+
+NAME ** VMWare guest OS (generic)          [vmware]
+#CHIPSET vmware
+SERVER SVGA
+DRIVER vmware
+
+
+#Chips & Technologies
+
+#untested
+NAME Chips & Technologies CT65520
+CHIPSET ct65520
+SERVER SVGA
+DRIVER chips
+LINE # Device section for C&T cards.
+LINE # Option "suspend_hack"
+LINE # Option "STN"
+LINE # Option "no_stretch"
+LINE # Option "no_center"
+LINE # Option "use_modeline"
+LINE # Option "fix_panel_size"
+LINE # videoram 512
+
+NAME Chips & Technologies CT65525
+CHIPSET ct65525
+LINE # Option "nolinear"
+LINE # MemBase 0x03b00000
+SEE Chips & Technologies CT65520
+
+NAME Chips & Technologies CT65530
+CHIPSET ct65530
+SEE Chips & Technologies CT65525
+
+NAME Chips & Technologies CT65535
+CHIPSET ct65535
+NOCLOCKPROBE
+LINE # Option "hw_clocks"
+LINE # Textclockfreq 25.175
+SEE Chips & Technologies CT65530
+
+NAME Chips & Technologies CT65540
+CHIPSET ct65540
+NOCLOCKPROBE
+LINE # Option "use_18bit_bus"
+SEE Chips & Technologies CT65535
+
+NAME Chips & Technologies CT65545
+CHIPSET ct65545
+NOCLOCKPROBE
+LINE # Option "noaccel"
+LINE # Option "no_bitblt"
+LINE # Option "xaa_no_color_exp"
+LINE # Option "xaa_benchmark"
+LINE # Option "hw_cursor"
+LINE # Option "mmio"
+SEE Chips & Technologies CT65540
+
+NAME Chips & Technologies CT65546
+CHIPSET ct65546
+SEE Chips & Technologies CT65545
+
+NAME Chips & Technologies CT65548
+CHIPSET ct65548
+SEE Chips & Technologies CT65545
+
+NAME Chips & Technologies CT65550
+CHIPSET ct65550
+NOCLOCKPROBE
+LINE # Option "noaccel"
+LINE # Option "no_bitblt"
+LINE # Option "xaa_no_color_exp"
+LINE # Option "xaa_benchmark"
+LINE # Option "hw_cursor"
+LINE # Option "sync_on_green"
+LINE # Option "fast_dram"
+LINE # Option "use_vclk1"
+LINE # Textclockfreq 25.175
+SEE Chips & Technologies CT65530
+
+NAME Chips & Technologies CT65554
+CHIPSET ct65554
+SEE Chips & Technologies CT65550
+
+NAME Chips & Technologies CT65555
+CHIPSET ct65555
+SEE Chips & Technologies CT65550
+
+NAME Chips & Technologies CT68554
+CHIPSET ct68554
+SEE Chips & Technologies CT65550
+
+NAME Chips & Technologies CT69000
+CHIPSET ct69000
+SEE Chips & Technologies CT65550
+
+NAME Chips & Technologies CT69030
+CHIPSET ct69030
+SEE Chips & Technologies CT65550
+
+NAME Chips & Technologies CT64200
+CHIPSET ct64200
+SERVER SVGA
+DRIVER chips
+LINE # Device section for C&T cards.
+LINE # videoram 1024
+
+NAME Chips & Technologies CT64300
+CHIPSET ct64300
+SERVER SVGA
+DRIVER chips
+LINE # Option "noaccel"
+LINE # Option "no_bitblt"
+LINE # Option "xaa_no_color_exp"
+LINE # Option "xaa_benchmark"
+LINE # Option "hw_cursor"
+LINE # Option "nolinear"
+LINE # MemBase 0x03b00000
+LINE # Option "hw_clocks"
+LINE # Textclockfreq 25.175
+SEE Chips & Technologies CT64200
+
+# Cirrus Logic
+
+#tested
+NAME Cirrus Logic GD542x
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+LINE # Device section for Cirrus Logic GD5420/2/4/6/8/9-based cards.
+LINE     #MemBase 0x00e00000
+LINE     #MemBase 0x04e00000
+LINE     #Option "linear"
+
+#tested
+NAME Cirrus Logic GD543x
+CHIPSET CL-GD5430/5434/5436
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+LINE # Device section for Cirrus Logic GD5430/34-based cards.
+LINE     #MemBase 0x00e00000		# ISA card that maps to 14Mb
+LINE     #MemBase 0x04000000		# VLB card that maps to 64Mb
+LINE     #MemBase 0x80000000		# VLB card that maps to 2048Mb
+LINE     #MemBase 0x02000000		# VLB card that maps to 32Mb
+LINE     #Option "linear"
+
+NAME Cirrus Logic GD544x
+CHIPSET CL-GD544x
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+
+NAME Creative Labs Graphics Blaster MA201
+SEE Cirrus Logic GD544x
+
+NAME Creative Labs Graphics Blaster MA202
+SEE Cirrus Logic GD544x
+
+#tested
+NAME Cirrus Logic GD5462
+CHIPSET CL-GD5462
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+LINE #Option "fifo_conservative"
+
+#tested
+NAME Cirrus Logic GD5464
+CHIPSET CL-GD5464
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+LINE #Option "fifo_conservative"
+
+#tested
+NAME Cirrus Logic GD5465
+CHIPSET CL-GD5465
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+LINE #Option "fifo_conservative"
+
+NAME Creative Labs Graphics Blaster MA302
+CHIPSET CL-GD5462
+SEE Cirrus Logic GD5462
+
+NAME Creative Labs Graphics Blaster MA334
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+NAME Creative Labs Graphics Blaster 3D
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+#tested
+NAME Cirrus Logic GD5480
+CHIPSET CL-GD5480
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+
+#tested
+NAME Diamond SpeedStar 64
+CHIPSET CL-GD5434
+SEE Cirrus Logic GD543x
+
+NAME Diamond SpeedStar64 Graphics 2000/2200
+CHIPSET CL-GD5434
+SEE Cirrus Logic GD543x
+
+NAME Diamond SpeedStar Pro SE (CL-GD5430/5434)
+SEE Cirrus Logic GD543x
+
+NAME Diamond SpeedStar Pro 1100
+SEE Cirrus Logic GD542x
+
+NAME Orchid Kelvin 64 VLB Rev A
+CHIPSET CL-GD5434
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+LINE # Device section for Orchid Kelvin 64 VLB Rev A
+LINE # Linear framebuffer maps at 2048Mb. Some motherboards make linear addressing
+LINE # impossible. Some cards map at 32Mb.
+LINE     #MemBase 0x02000000		# VLB card that maps to 32Mb
+LINE     #MemBase 0x04000000		# VLB card that maps to 64Mb
+LINE     MemBase 0x80000000		# VLB card that maps to 2048Mb
+LINE     #Option "linear"
+
+NAME Orchid Kelvin 64 VLB Rev B
+CHIPSET CL-GD5434
+SERVER SVGA
+DRIVER cirrus
+NOCLOCKPROBE
+LINE # Device section for Orchid Kelvin 64 VLB Rev B
+LINE # Linear framebuffer maps at 32Mb. Some motherboards make linear addressing
+LINE # impossible. Some cards map at 2048Mb.
+LINE     MemBase 0x02000000		# VLB card that maps to 32Mb
+LINE     #MemBase 0x04000000		# VLB card that maps to 64Mb
+LINE     #MemBase 0x80000000		# VLB card that maps to 2048Mb
+LINE     #Option "linear"
+
+NAME Orchid Kelvin 64
+CHIPSET CL-GD5434
+SEE Cirrus Logic GD543x
+
+NAME Intel 5430
+CHIPSET CL-GD5430
+SEE Cirrus Logic GD543x
+
+NAME STB Nitro (64)
+CHIPSET CL-GD5434
+SEE Cirrus Logic GD543x
+
+NAME STB Nitro 64 Video
+CHIPSET CL-GD5446
+SEE Cirrus Logic GD544x
+
+NAME STB Horizon
+CHIPSET CL-GD5426/28
+SEE Cirrus Logic GD542x
+
+NAME STB Horizon Video
+CHIPSET CL-GD5440
+SEE Cirrus Logic GD544x
+
+NAME Genoa 8500VL(-28)
+CHIPSET CL-GD5426/28
+SEE Cirrus Logic GD542x
+
+NAME Diamond SpeedStar Pro (not SE)
+CHIPSET CL-GD5426/28
+SEE Cirrus Logic GD542x
+
+NAME ALG-5434(E)
+CHIPSET CL-GD5434
+SEE Cirrus Logic GD543x
+
+NAME Actix ProStar
+CHIPSET CL-GD5426/5428
+SEE Cirrus Logic GD542x
+
+NAME Actix ProStar 64
+CHIPSET CL-GD5434
+SEE Cirrus Logic GD543x
+
+#tested
+NAME Acumos AVGA3
+SEE Cirrus Logic GD542x
+
+NAME DFI-WG1000
+SEE Cirrus Logic GD542x
+
+NAME Spider VLB Plus
+CHIPSET CL-GD5428
+SEE Cirrus Logic GD542x
+
+NAME VI720
+CHIPSET CL-GD5434
+SEE Cirrus Logic GD543x
+
+NAME Cirrus Logic GD62xx (laptop)
+CHIPSET CL-GD6205/15/25/35
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Cirrus Logic GD64xx (laptop)
+CHIPSET CL-GD6420/6440
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Cirrus Logic GD754x (laptop)
+CHIPSET CL-GD7541/42/43/48
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Techworks Ultimate 3D
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+NAME VideoLogic GrafixStar 550
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+NAME Jaton Video-70P
+CHIPSET CL-GD5464
+SEE Cirrus Logic GD5464
+
+NAME PixelView Combo TV Pro (Prolink)
+CHIPSET CL-GD5480, 4MB
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # COMMENT on card TV Tuner
+NOCLOCKPROBE
+
+NAME PixelView Combo TV 3D AGP (Prolink)
+CHIPSET CL-GD5465, 4MB
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # COMMENT on card TV+FM Tuner
+NOCLOCKPROBE
+
+NAME Creative Labs Graphics Blaster Eclipse (OEM Model CT6510)
+SEE Cirrus Logic GD5465
+
+NAME VideoLogic GrafixStar 560 (PCI/AGP)
+SEE Cirrus Logic GD5465
+
+NAME Cirrus Logic GD5446 (noname card)
+CHIPSET CL-GD5446, 1MB (upgradable to 2MB).
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Octek VL-VGA-26
+CHIPSET CL-GD5426
+SEE Cirrus Logic GD542x
+
+NAME Octek VL-VGA-28
+CHIPSET CL-GD5428
+SEE Cirrus Logic GD542x
+
+NAME Octek Combo-26
+CHIPSET CL-GD5426
+SEE Cirrus Logic GD542x
+
+NAME Octek Combo-28
+CHIPSET CL-GD5428
+SEE Cirrus Logic GD542x
+
+NAME Octek AVGA-20
+SEE Cirrus Logic GD542x
+
+# S3 801/805
+
+NAME S3 801/805 (generic)
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+
+NAME S3 86C801 (generic)
+SEE S3 801/805 (generic)
+
+NAME S3 86C805 (generic)
+SEE S3 801/805 (generic)
+
+#tested
+NAME S3 801/805 with ATT20c490 RAMDAC
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c490
+LINE     #Option "dac_8_bit"		# Not supported by some 20c490 clones
+
+NAME S3 801/805 with SC1148{2,3,4} RAMDAC
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC sc11482
+
+NAME S3 801/805 with SC1148{5,7,9} RAMDAC
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC sc11485
+
+NAME S3 801/805 with S3 GenDAC
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC s3gendac
+CLOCKCHIP s3gendac
+
+NAME S3 801/805 with ATT20c490 RAMDAC and ICD2061A
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c490
+CLOCKCHIP icd2061a
+LINE     #Option "dac_8_bit"		# Not supported by some 20c490 clones
+
+NAME S3 801/805 with Chrontel 8391
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c490
+CLOCKCHIP ch8391
+LINE     Option "dac_8_bit"
+
+#tested
+NAME Actix GE32+ 2MB
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c490
+LINE     #Option "dac_8_bit"
+
+NAME Actix GE32i
+CHIPSET S3 805i
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+
+NAME Orchid Fahrenheit VA
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c490
+
+NAME Orchid Fahrenheit 1280
+CHIPSET S3 801
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Probable clocks:
+LINE     #Clocks 25.20 28.32 32.50 0.00 40.00 44.90 50.40 65.00
+LINE     #Clocks 78.00 56.70 63.10 75.10 80.00 89.90 100.90 31.50
+
+NAME Orchid Fahrenheit-1280+
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20C490
+LINE     Dacspeed   110
+LINE     Option     "dac_8_bit"
+LINE     #Option    "nolinear" # VLB card may require this
+LINE     #Probable clocks:
+LINE     #Clocks     25.20 28.32 40.0 0.0 50.10 77.0 36.10 45.0
+LINE     #Clocks     130.0 120.20 80.0 31.50 110.30 65.0 75.0 94.60
+
+NAME Diamond Stealth 24
+CHIPSET S3 801/805
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+LINE     #Option    "nolinear"
+LINE     #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp
+
+NAME Miro Crystal 8S
+SEE S3 801/805 (generic)
+
+NAME Miro Crystal 10SD with GenDAC
+SEE S3 801/805 with S3 GenDAC
+
+NAME Dell S3 805
+SEE S3 801/805 (generic)
+
+NAME STB Powergraph X-24
+SEE S3 801/805 with ATT20c490 RAMDAC and ICD2061A
+
+NAME JAX 8241
+SEE S3 801/805 with Chrontel 8391
+
+NAME VL-41
+SEE S3 801/805 with Chrontel 8391
+
+NAME SPEA Mirage
+SEE S3 801/805 with Chrontel 8391
+
+# S3 864/Trio64/Trio32/868
+
+NAME S3 864 (generic)
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+
+NAME S3 86C864 (generic)
+SEE S3 864 (generic)
+
+NAME S3 Vision864 (generic)
+SEE S3 864 (generic)
+
+NAME S3 864 with SDAC (86C716)
+CHIPSET S3 864
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC s3_sdac
+CLOCKCHIP s3_sdac
+NOCLOCKPROBE
+
+NAME S3 864 with ATT 20C498 or 21C498
+CHIPSET S3 864
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c498
+
+NAME S3 864 with STG1703
+CHIPSET S3 864
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC stg1703
+NOCLOCKPROBE
+
+NAME S3 868 (generic)
+CHIPSET S3 868
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+
+NAME S3 86C868 (generic)
+SEE S3 868 (generic)
+
+NAME S3 Vision868 (generic)
+SEE S3 868 (generic)
+
+NAME S3 868 with SDAC (86C716)
+CHIPSET S3 868
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME S3 868 with ATT 20C498 or 21C498
+CHIPSET S3 868
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c498
+
+NAME S3 868 with ATT 20C409
+CHIPSET S3 868
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c409
+NOCLOCKPROBE
+
+NAME Number Nine FX Motion 531
+CLOCKCHIP icd2061a
+SEE S3 868 with ATT 20C498 or 21C498
+
+NAME S3 Trio64 (generic)
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME S3 86C764 (generic)
+SEE S3 Trio64 (generic)
+
+NAME S3 Trio64V+ (generic)
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME S3 86C765 (generic)
+SEE S3 Trio64V+ (generic)
+
+NAME S3 Trio32 (generic)
+CHIPSET S3 Trio32
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Genoa Phantom 64i with S3 SDAC
+DACSPEED 135
+SEE S3 864 with SDAC (86C716)
+
+NAME Number Nine GXE64
+CHIPSET S3 864
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+LINE     Option "number_nine"
+
+NAME Number Nine GXE64 with S3 Trio64
+SEE S3 Trio64 (generic)
+
+NAME Diamond Stealth 64 DRAM with S3 SDAC
+DACSPEED 135
+SEE S3 864 with SDAC (86C716)
+
+NAME Diamond Stealth64 Graphics 2xx0 series (864 + SDAC)
+DACSPEED 135
+SEE S3 864 with SDAC (86C716)
+
+NAME Diamond Stealth 64 DRAM with S3 Trio64
+SEE S3 Trio64 (generic)
+
+NAME Diamond Stealth64 Graphics 2xx0 series (Trio64)
+SEE S3 Trio64 (generic)
+
+NAME Diamond Stealth 64 DRAM SE
+SEE S3 Trio32 (generic)
+
+NAME Diamond Stealth64 Video 2001 series (2121/2201)
+SEE S3 Trio64V+ (generic)
+
+NAME Actix GE64
+CLOCKCHIP icd2061a
+SEE S3 864 (generic)
+
+NAME ELSA Winner 1000PRO with S3 SDAC
+SEE S3 864 with SDAC (86C716)
+
+NAME ELSA Winner 1000PRO with STG1700 or AT&T RAMDAC
+CHIPSET S3 864
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+
+NAME ELSA Winner 1000PRO/X
+SEE S3 868 with SDAC (86C716)
+
+NAME ELSA Winner 1000ISA
+CHIPSET S3 805i
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+LINE     Option "dac_8_bit"
+LINE     # the following settings should be detected and set automatically by XF86_S3
+LINE     # if the serial number of the ELSA card is printed correctly:
+LINE     #ClockChip "icd2061a"
+
+NAME Cardex Trio64
+SEE S3 Trio64 (generic)
+
+NAME Cardex Trio64Pro
+SEE S3 Trio64 (generic)
+
+NAME Miro Crystal 12SD
+SEE S3 Trio32 (generic)
+
+NAME Miro Crystal 22SD
+SEE S3 Trio64 (generic)
+
+NAME Miro Crystal 20SD with ICS2494 (BIOS 1.xx)
+SEE S3 864 with ATT 20C498 or 21C498
+
+NAME Miro Crystal 20SD with ICD2061A (BIOS 2.xx)
+CLOCKCHIP icd2061a
+SEE S3 864 with ATT 20C498 or 21C498
+
+NAME Miro Crystal 20SD VLB with S3 SDAC (BIOS 3.xx)
+SEE S3 864 with SDAC (86C716)
+
+NAME Miro Crystal 20SD PCI with S3 SDAC
+SEE S3 868 with SDAC (86C716)
+
+NAME ELSA Winner 1000AVI (SDAC version)
+SEE S3 868 with SDAC (86C716)
+
+NAME ELSA Winner 1000AVI (AT&T 20C409 version)
+SEE S3 868 with ATT 20C409
+
+NAME Diamond Stealth Video DRAM
+SEE S3 868 with SDAC (86C716)
+
+NAME Diamond Stealth64 Video 2120/2200
+SEE S3 868 with SDAC (86C716)
+
+NAME SPEA/V7 Mirage P64
+CLOCKCHIP ics2595
+SEE S3 864 (generic)
+
+NAME SPEA/V7 Mirage P64 with S3 Trio64
+SEE S3 Trio64 (generic)
+
+NAME Number Nine FX Vision 330
+SEE S3 Trio64 (generic)
+
+NAME Number Nine FX Motion 331
+SEE S3 Trio64V+ (generic)
+
+NAME ASUS Video Magic PCI V864
+SEE S3 864 (generic)
+
+NAME ASUS Video Magic PCI VT64
+SEE S3 Trio64 (generic)
+
+NAME VidTech FastMax P20
+SEE S3 864 (generic)
+
+NAME VideoLogic GrafixStar 500
+SEE S3 868 with SDAC (86C716)
+
+NAME VideoLogic GrafixStar 400
+SEE S3 Trio64V+ (generic)
+
+NAME VideoLogic GrafixStar 300
+SEE S3 Trio64 (generic)
+
+NAME 2 the Max MAXColor S3 Trio64V+
+SEE S3 Trio64V+ (generic)
+
+NAME DataExpert DSV3365
+SEE S3 Trio64V+ (generic)
+
+NAME ExpertColor DSV3365
+SEE S3 Trio64V+ (generic)
+
+NAME DSV3326
+SEE S3 Trio64V+ (generic)
+
+# S3 Trio64V2
+
+NAME S3 Trio64V2 (generic)
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME S3 Trio64V2/DX (generic)
+SEE S3 Trio64V2 (generic)
+
+NAME S3 Trio64V2/GX (generic)
+SEE S3 Trio64V2 (generic)
+
+NAME S3 86C775 (generic)
+SEE S3 Trio64V2/DX (generic)
+
+NAME S3 86C785 (generic)
+SEE S3 Trio64V2/GX (generic)
+
+NAME ELSA WINNER 1000/T2D
+SEE S3 Trio64V2/DX (generic)
+
+
+# S3 Aurora64V+
+
+NAME S3 Aurora64V+ (generic)
+CHIPSET S3 Aurora64V+
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+LINE     # Option "lcd_center"
+LINE     # Set_LCDClk  <pixel_clock_for_LCD>
+
+NAME S3 86CM65
+SEE S3 Aurora64V+ (generic)
+
+NAME SHARP 9080
+SEE S3 Aurora64V+ (generic)
+
+NAME SHARP 9090
+SEE S3 Aurora64V+ (generic)
+
+NAME COMPAQ Armada 7730MT
+SEE S3 Aurora64V+ (generic)
+
+NAME COMPAQ Armada 7380DMT
+SEE S3 Aurora64V+ (generic)
+
+
+# S3 964/968
+
+NAME S3 964 (generic)
+CHIPSET S3 964
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME S3 86C964 (generic)
+SEE S3 964 (generic)
+
+NAME S3 Vision964 (generic)
+SEE S3 964 (generic)
+
+NAME S3 968 (generic)
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME S3 86C968 (generic)
+SEE S3 968 (generic)
+
+NAME S3 Vision968 (generic)
+SEE S3 968 (generic)
+
+NAME Number Nine GXE64 Pro
+CHIPSET S3 964
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC ti3025
+LINE     Option "number_nine"
+
+NAME Diamond Stealth 64 VRAM
+CLOCKCHIP icd2061a
+LINE    #Option "slow_vram"
+SEE S3 964 (generic)
+
+NAME Diamond Stealth64 Video 3200
+CHIPSET S3 968
+LINE    #Option "slow_vram"
+SEE S3 968 (generic)
+
+NAME Diamond Stealth 64 Video VRAM (TI RAMDAC)
+CHIPSET S3 968
+LINE    #Option "slow_vram"
+LINE    #DacSpeed 220
+SEE S3 968 (generic)
+
+NAME Diamond Stealth64 Video 3240/3400 (TI RAMDAC)
+CHIPSET S3 968
+LINE    #Option "slow_vram"
+LINE    #DacSpeed 220
+SEE S3 968 (generic)
+
+NAME Diamond Stealth64 Video 3240/3400 (IBM RAMDAC)
+CHIPSET S3 968
+LINE    #Option "slow_vram"
+RAMDAC ibm_rgb526
+LINE    DacSpeed 220
+SEE S3 968 (generic)
+
+NAME Genoa VideoBlitz III AV
+CHIPSET S3 968
+LINE    #s3RefClk  50
+LINE    #DACspeed 170
+SEE S3 968 (generic)
+
+NAME STB Velocity 64 Video
+CHIPSET S3 968
+LINE    #s3RefClk  24
+LINE    #DACspeed 220
+SEE S3 968 (generic)
+
+NAME STB Powergraph 64 Video
+SEE S3 Trio64V+ (generic)
+
+NAME STB Powergraph 64
+SEE S3 Trio64 (generic)
+
+NAME ELSA Winner 1000TRIO
+SEE S3 Trio64 (generic)
+
+NAME ELSA Winner 1000TRIO/V
+SEE S3 Trio64V+ (generic)
+
+NAME Hercules Graphite Terminator 64
+LINE     Option "slow_vram"
+LINE    #s3RefClk  50
+LINE    #DACspeed 170
+SEE S3 964 (generic)
+
+NAME Hercules Terminator 64/Video
+SEE S3 Trio64V+ (generic)
+
+NAME Hercules Graphite Terminator 64/DRAM
+SEE S3 Trio64 (generic)
+
+NAME Hercules Graphite Terminator Pro 64
+LINE    #s3RefClk  16
+LINE    #DACspeed 220
+SEE S3 968 (generic)
+
+NAME Number Nine FX Motion 771
+LINE    #s3RefClk  16
+SEE S3 968 (generic)
+
+NAME Spider Tarantula 64
+SEE S3 964 (generic)
+
+NAME Miro Crystal 20SV
+CHIPSET S3 964
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+
+NAME Miro Crystal 40SV
+CHIPSET S3 964
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP ti3025
+
+NAME Miro Crystal 80SV
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Miro Video 20SV
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c505
+LINE    #DacSpeed 150
+CLOCKCHIP ics9161a
+
+NAME SPEA Mercury 64
+CHIPSET S3 964
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP ics9161a
+LINE     #Option "spea_mercury"
+
+NAME ELSA Winner 2000PRO-2
+CHIPSET S3 964
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "ELSA_w2000pro"
+NOCLOCKPROBE
+
+NAME ELSA Winner 2000PRO-4
+CHIPSET S3 964
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "ELSA_w2000pro"
+NOCLOCKPROBE
+
+NAME ELSA Winner 2000PRO/X-2
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "sync_on_green"
+NOCLOCKPROBE
+
+NAME ELSA Winner 2000PRO/X-4
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "sync_on_green"
+NOCLOCKPROBE
+
+NAME ELSA Winner 2000PRO/X-8
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "sync_on_green"
+NOCLOCKPROBE
+
+NAME ELSA Winner 2000AVI
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "sync_on_green"
+NOCLOCKPROBE
+
+NAME ELSA Gloria-4
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "sync_on_green"
+NOCLOCKPROBE
+
+NAME ELSA Gloria-8
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Option "sync_on_green"
+NOCLOCKPROBE
+
+NAME VideoLogic GrafixStar 700
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME LeadTek WinFast S430
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME WinFast S430
+SEE LeadTek WinFast S430
+
+NAME LeadTek WinFast S510
+CHIPSET S3 968
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME WinFast S510
+SEE LeadTek WinFast S510
+
+# S3 928
+
+NAME S3 928 (generic)
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+
+NAME S3 86C928 (generic)
+SEE S3 928 (generic)
+
+NAME Actix Ultra
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c490
+LINE     #Option "dac_8_bit"
+
+NAME Diamond Stealth Pro
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+LINE     #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp
+LINE     #Option "no_linear" # Some VLB machines may require this
+
+NAME ELSA Winner 1000VL
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     # the following settings should be detected and set automatically by XF86_S3
+LINE     # if the serial number of the ELSA card is printed correctly:
+LINE     #ClockChip "icd2061a"
+LINE     #Membase 0xf8000000
+
+NAME ELSA Winner 1000TwinBus
+SEE ELSA Winner 1000VL
+
+NAME ELSA Winner 2000
+SEE S3 928 (generic)
+
+NAME Miro Crystal 16S
+SEE S3 928 (generic)
+
+NAME SPEA/V7 Mercury
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP sc11412
+LINE     Option "spea_mercury"
+
+NAME STB Pegasus
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+RAMDAC bt485
+CLOCKCHIP icd2061a
+LINE     Option "stb_pegasus"
+LINE     #Option "sync_on_green"
+
+NAME Number Nine GXE Level 14/16
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+DACSPEED 200
+CLOCKCHIP icd2061a
+LINE     Option "number_nine"
+LINE     #Option "nolinear"
+LINE     #Option "nomemaccess"
+
+NAME Number Nine GXE Level 10/11/12
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+LINE     Option "number_nine"
+
+NAME 928Movie
+CHIPSET S3 928
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2595
+RAMDAC bt485
+LINE     # pixel multiplexing not supported
+
+# S3 911/924
+
+NAME S3 911/924 (generic)
+CHIPSET S3 911/924
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+
+NAME S3 86C911 (generic)
+SEE S3 911/924 (generic)
+
+NAME S3 86C924 (generic)
+SEE S3 911/924 (generic)
+
+NAME Diamond Stealth VRAM
+CHIPSET S3 911/924
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+CLOCKCHIP icd2061a
+
+#NAME Orchid Fahrenheit 1280
+#SEE S3 911/924 (generic)
+
+NAME S3 924 with SC1148 DAC
+CHIPSET S3 924
+SERVER S3
+DRIVER vga
+UNSUPPORTED
+LINE     #Probable clocks:
+LINE     #Clocks 25.2 28.3 39.7 1.7 49.9 76.7 35.7 44
+LINE     #Clocks 130.2 119.5 79.4 31.2 110.0 65.2 74.9 71.3
+
+# S3 ViRGE,/DX,/GX and ViRGE/VX
+
+NAME S3 ViRGE (old S3V server)
+CHIPSET S3 ViRGE
+SERVER S3V
+DRIVER s3virge
+NOCLOCKPROBE
+
+NAME S3 ViRGE (generic)
+CHIPSET S3 ViRGE
+SERVER SVGA
+DRIVER s3virge
+NOCLOCKPROBE
+LINE      #Option "xaa_benchmark"
+LINE      #Option "fifo_moderate"
+LINE      #Option "pci_burst_on"
+LINE      #Option "pci_retry"
+
+NAME S3 ViRGE/DX (generic)
+CHIPSET S3 ViRGE/DX
+SERVER SVGA
+DRIVER s3virge
+NOCLOCKPROBE
+LINE      #Option "xaa_benchmark"
+LINE      #Option "fifo_moderate"
+LINE      #Option "pci_burst_on"
+LINE      #Option "pci_retry"
+
+NAME S3 ViRGE/GX (generic)
+CHIPSET S3 ViRGE/GX
+SERVER SVGA
+DRIVER s3virge
+NOCLOCKPROBE
+LINE      #Option "xaa_benchmark"
+LINE      #Option "fifo_moderate"
+LINE      #Option "pci_burst_on"
+LINE      #Option "pci_retry"
+
+
+NAME S3 ViRGE/GX2 (generic)
+CHIPSET S3 ViRGE/GX2
+SERVER SVGA
+DRIVER s3virge
+NOCLOCKPROBE
+LINE      #Option "xaa_benchmark"
+LINE      #Option "fifo_moderate"
+LINE      #Option "pci_burst_on"
+LINE      #Option "pci_retry"
+
+NAME S3 ViRGE/MX (generic)
+CHIPSET S3 ViRGE/MX
+SERVER SVGA
+DRIVER s3virge
+NOCLOCKPROBE
+LINE      #Option "lcd_center"
+LINE      #Set_LCDClk  <pixel_clock_for_LCD>
+LINE      #Option "xaa_benchmark"
+LINE      #Option "fifo_moderate"
+LINE      #Option "pci_burst_on"
+LINE      #Option "pci_retry"
+
+NAME S3 ViRGE/MX+ (generic)
+SEE S3 ViRGE/MX (generic)
+
+
+
+
+NAME S3 86C325 (generic)
+SEE S3 ViRGE (generic)
+
+NAME S3 86C375 (generic)
+SEE S3 ViRGE/DX (generic)
+
+NAME S3 86C385 (generic)
+SEE S3 ViRGE/GX (generic)
+
+NAME S3 86C357 (generic)
+SEE S3 ViRGE/GX2 (generic)
+
+NAME S3 86C260 (generic)
+SEE S3 ViRGE/MX (generic)
+
+NAME S3 86C280 (generic)
+SEE S3 ViRGE/MX+ (generic)
+
+
+NAME ELSA Victory 3D
+SEE S3 ViRGE (generic)
+
+NAME ELSA Victory 3DX
+SEE S3 ViRGE/DX (generic)
+
+NAME ELSA Winner 3000-S
+SEE S3 ViRGE (generic)
+
+NAME Number Nine Visual 9FX Reality 332
+SEE S3 ViRGE (generic)
+
+NAME Number Nine FX Motion 332
+SEE S3 ViRGE (generic)
+
+NAME Diamond Stealth 3D 2000
+SEE S3 ViRGE (generic)
+
+NAME Diamond Stealth 3D 2000 PRO
+SEE S3 ViRGE/DX (generic)
+
+NAME Diamond Multimedia Stealth 3D 2000
+SEE S3 ViRGE (generic)
+
+NAME Diamond Multimedia Stealth 3D 2000 PRO
+SEE S3 ViRGE/DX (generic)
+
+NAME Canopus Co. Power Window 3DV
+SEE S3 ViRGE (generic)
+
+NAME DataExpert DSV3325
+SEE S3 ViRGE (generic)
+
+NAME ExpertColor DSV3325
+SEE S3 ViRGE (generic)
+
+NAME DSV3325
+SEE S3 ViRGE (generic)
+
+NAME Hercules Terminator 64/3D
+SEE S3 ViRGE (generic)
+
+NAME Hercules Terminator 3D/DX
+SEE S3 ViRGE/DX (generic)
+
+NAME LeadTek WinFast 3D S600
+SEE S3 ViRGE (generic)
+
+NAME WinFast 3D S600
+SEE LeadTek WinFast 3D S600
+
+NAME LeadTek WinFast 3D S680
+SEE S3 ViRGE/GX2 (generic)
+
+NAME Miro MiroMedia 3D
+SEE S3 ViRGE (generic)
+
+NAME Orchid Technology Fahrenheit Video 3D
+SEE S3 ViRGE (generic)
+
+NAME STB Systems Powergraph 3D
+SEE S3 ViRGE (generic)
+
+NAME STB Nitro 3D
+CHIPSET S3 ViRGE/GX
+SEE S3 ViRGE/GX (generic)
+
+NAME MELCO WGP-VG4S
+LINE      #DACSpeed  191 162 111 83
+LINE      #SetMClck  75
+SEE S3 ViRGE (generic)
+
+
+
+NAME S3 ViRGE/VX (generic)
+CHIPSET S3 ViRGE/VX
+SERVER SVGA
+DRIVER s3virge
+NOCLOCKPROBE
+LINE      #Option "xaa_benchmark"
+LINE      #Option "fifo_moderate"
+LINE      #Option "pci_burst_on"
+LINE      #Option "pci_retry"
+
+
+NAME S3 86C988 (generic)
+SEE S3 ViRGE/VX (generic)
+
+NAME ELSA Winner 3000
+SEE S3 ViRGE/VX (generic)
+
+NAME ELSA Winner 3000-M-22
+SEE S3 ViRGE/VX (generic)
+
+NAME ELSA Winner 3000-L-42
+SEE S3 ViRGE/VX (generic)
+
+NAME ELSA Winner 2000AVI/3D
+SEE S3 ViRGE/VX (generic)
+
+NAME Diamond Stealth 3D 3000
+SEE S3 ViRGE/VX (generic)
+
+NAME STB Systems Velocity 3D
+SEE S3 ViRGE/VX (generic)
+
+NAME MELCO WGP-VX8
+SEE S3 ViRGE/VX (generic)
+
+NAME Diamond Stealth 3D 4000
+SEE S3 ViRGE/GX2 (generic)
+
+NAME Toshiba Tecra 750CDT
+SEE S3 ViRGE/MX (generic)
+
+NAME Toshiba Tecra 750DVD
+SEE S3 ViRGE/MX (generic)
+
+NAME Toshiba Tecra 540CDT
+SEE S3 ViRGE/MX (generic)
+
+NAME Toshiba Tecra 550CDT
+SEE S3 ViRGE/MX (generic)
+
+# currently unsupported S3
+
+NAME S3 86C365 (Trio3D)
+SEE * Unsupported VGA compatible
+
+NAME S3 86C391 (Savage3D)
+SEE * Unsupported VGA compatible
+
+NAME S3 Trio3D
+SEE * Unsupported VGA compatible
+
+NAME S3 Savage3D
+SEE * Unsupported VGA compatible
+
+NAME S3 Savage4
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+# ET4000/ET6000
+
+NAME ET3000 (generic)
+CHIPSET ET3000
+SERVER SVGA
+DRIVER tseng
+
+NAME Genoa 5400
+SEE ET3000 (generic)
+
+NAME ET4000 (generic)
+CHIPSET ET4000
+SERVER SVGA
+DRIVER tseng
+
+NAME ET4000/W32 (generic)
+CHIPSET ET4000/W32
+SERVER W32
+DRIVER tseng
+
+NAME ET4000 W32i, W32p (generic)
+CHIPSET ET4000/W32(i/p)
+SERVER SVGA
+DRIVER tseng
+LINE     #Option "linear"       # for linear mode at 8bpp
+LINE     #Option "noaccel"      # when problems with accelerator
+LINE     #Option "power_saver"  # enable VESA DPMS
+LINE     #Option "fast_dram"
+LINE     #Option "pci_retry"    # faster, but problematic for ISA DMA
+LINE     #Option "hibit_high"   # see README.tseng -- most cards need this
+LINE     #Option "hibit_low"    # see README.tseng -- mostly for older ET4000 cards
+LINE     #MemBase 0x3C00000     # when automatic MemBase detection doesn't work
+LINE         # -- see README.tseng for more (important) information on MemBase
+
+NAME ET6000 (generic)
+CHIPSET ET6000
+SERVER SVGA
+DRIVER tseng
+NOCLOCKPROBE
+LINE     #videoram 2304         # 2.25 MB, when memory probe is incorrect
+LINE     #Option "linear"       # for linear mode at 8bpp
+LINE     #Option "noaccel"      # when problems with accelerator
+LINE     #Option "power_saver"  # enable VESA DPMS
+LINE     #Option "pci_retry"    # faster, but problematic for ISA DMA
+LINE     #Option "hw_cursor"    # Use hardware cursor (see docs for limitations)
+LINE     #Option "xaa_no_color_exp"  # When text (or bitmap) is not rendered correctly
+
+NAME ET6100 (generic)
+CHIPSET ET6100
+SEE ET6000 (generic)
+
+NAME Diamond Stealth 32
+CLOCKCHIP icd2061a
+NOCLOCKPROBE
+SEE ET4000 W32i, W32p (generic)
+
+NAME Cardex Cobra
+SEE ET4000 W32i, W32p (generic)
+
+NAME Cardex Challenger (Pro)
+SEE ET4000 W32i, W32p (generic)
+
+NAME Colorgraphic Dual Lightning
+SEE ET4000 W32i, W32p (generic)
+
+NAME Dell onboard ET4000
+SEE ET4000 (generic)
+
+NAME DFI-WG5000
+SEE ET4000 W32i, W32p (generic)
+
+NAME Diamond SpeedStar (Plus)
+SEE ET4000 (generic)
+
+NAME Diamond SpeedStar 24
+SEE ET4000 (generic)
+
+NAME Diamond SpeedStar HiColor
+SEE ET4000 (generic)
+
+NAME Genoa 8900 Phantom 32i
+SEE ET4000 W32i, W32p (generic)
+
+NAME Hercules Dynamite
+SEE ET4000/W32 (generic)
+
+NAME Hercules Dynamite Power
+SEE ET4000 W32i, W32p (generic)
+
+NAME Hercules Dynamite Pro
+SEE ET4000 W32i, W32p (generic)
+
+NAME Integral FlashPoint
+SEE ET4000 W32i, W32p (generic)
+
+NAME LeadTek WinFast S200
+SEE ET4000 W32i, W32p (generic)
+
+NAME Matrox Comet
+SEE ET4000 W32i, W32p (generic)
+
+NAME Matrox Marvel II
+SEE ET4000 W32i, W32p (generic)
+
+NAME Miro MiroVideo 20TD
+SEE ET4000 W32i, W32p (generic)
+
+NAME WinFast S200
+SEE LeadTek WinFast S200
+
+NAME Sigma Concorde
+SEE ET4000/W32 (generic)
+
+NAME Sigma Legend
+SEE ET4000 (generic)
+
+NAME SPEA/V7 ShowTime Plus
+SEE ET4000 W32i, W32p (generic)
+
+NAME STB LightSpeed
+SEE ET4000 W32i, W32p (generic)
+
+NAME STB MVP-2
+SEE ET4000 (generic)
+
+NAME STB MVP-2 PCI
+SEE ET4000 W32i, W32p (generic)
+
+NAME STB MVP-2X
+SEE ET4000 W32i, W32p (generic)
+
+NAME STB MVP-4 PCI
+SEE ET4000 W32i, W32p (generic)
+
+NAME STB MVP-4X
+SEE ET4000 W32i, W32p (generic)
+
+NAME TechWorks Thunderbolt
+SEE ET4000/W32 (generic)
+
+NAME ViewTop PCI
+SEE ET4000 W32i, W32p (generic)
+
+NAME SNI PC5H W32
+CLOCKCHIP stg1703
+NOCLOCKPROBE
+SEE ET4000 W32i, W32p (generic)
+
+NAME SNI Scenic W32
+CLOCKCHIP stg1703
+NOCLOCKPROBE
+SEE ET4000 W32i, W32p (generic)
+
+NAME Hercules Dynamite 128/Video
+SEE ET6000 (generic)
+
+NAME STB LightSpeed 128
+SEE ET6000 (generic)
+
+NAME VideoLogic GrafixStar 600
+SEE ET6000 (generic)
+
+NAME Jazz Multimedia G-Force 128
+SEE ET6000 (generic)
+
+NAME Mirage Z-128
+SEE ET6000 (generic)
+
+NAME California Graphics SunTracer 6000
+SEE ET6000 (generic)
+
+NAME Binar Graphics AnyView
+SEE ET6000 (generic)
+
+NAME MediaVision Proaxcel 128
+SEE ET6000 (generic)
+
+NAME ATrend ATC-2165A
+SEE ET6000 (generic)
+
+NAME Interay PMC Viper
+SEE ET6000 (generic)
+
+NAME 2-the-Max MAXColor 6000
+SEE ET6000 (generic)
+
+NAME Gainward Challenger EV
+SEE ET6000 (generic)
+
+NAME MachSpeed VGA ET6000
+SEE ET6000 (generic)
+
+NAME KouTech KeyVision 128 EV
+SEE ET6000 (generic)
+
+NAME Jaton Video-58P
+SEE ET6000 (generic)
+
+# ATI
+
+NAME ATI Rage 128
+CHIPSET ati
+SERVER SVGA
+DRIVER ati
+
+NAME ATI 8514 Ultra (no VGA)
+CHIPSET ati
+SERVER Mach8
+DRIVER vga
+UNSUPPORTED
+
+NAME ATI Graphics Ultra
+CHIPSET ati
+SERVER Mach8
+DRIVER ati
+
+NAME ATI Graphics Ultra Pro
+CHIPSET ati
+SERVER Mach32
+DRIVER ati
+
+NAME ATI Wonder SVGA
+CHIPSET ati
+SERVER SVGA
+DRIVER ati
+
+NAME ATI Ultra Plus
+CHIPSET ati
+SERVER Mach32
+DRIVER ati
+
+NAME ATI Mach32
+CHIPSET ati
+SERVER Mach32
+DRIVER ati
+
+NAME ATI Mach64
+CHIPSET ati
+SERVER Mach64
+DRIVER ati
+NOCLOCKPROBE
+
+NAME ATI Mach64 CT (264CT)
+SEE ATI Mach64
+
+NAME ATI Mach64 VT (264VT)
+SEE ATI Mach64
+
+NAME ATI Mach64 GT (264GT), aka 3D RAGE
+SEE ATI Mach64
+
+NAME ATI Mach64 3D RAGE II
+SEE ATI Mach64
+
+NAME ATI Mach64 3D RAGE II+DVD
+SEE ATI Mach64
+
+NAME ATI Mach64 3D Rage IIC
+SEE ATI Mach64
+
+NAME ATI Mach64 3D Rage Pro
+SEE ATI Mach64
+
+NAME ATI 3D Pro Turbo
+SEE ATI Mach64
+
+NAME ATI 3D Pro Turbo PC2TV
+SEE ATI Mach64
+
+NAME ATI 3D Xpression
+SEE ATI Mach64
+
+NAME ATI 3D Xpression+
+SEE ATI Mach64
+
+NAME ATI 3D Xpression+ PC2TV
+SEE ATI Mach64
+
+NAME ATI All-in-Wonder
+SEE ATI Mach64
+
+NAME ATI All-in-Wonder Pro
+SEE ATI Mach64
+
+NAME ATI Graphics Pro Turbo
+SEE ATI Mach64
+
+NAME ATI Graphics Pro Turbo 1600
+SEE ATI Mach64
+
+NAME ATI Graphics Xpression
+SEE ATI Mach64
+
+NAME ATI Video Boost
+SEE ATI Mach64
+
+NAME ATI Video Charger
+SEE ATI Mach64
+
+NAME ATI Video Xpression
+SEE ATI Mach64
+
+NAME ATI Video Xpression+
+SEE ATI Mach64
+
+NAME ATI WinBoost
+SEE ATI Mach64
+
+NAME ATI WinCharger
+SEE ATI Mach64
+
+NAME ATI WinTurbo
+SEE ATI Mach64
+
+NAME ATI Xpert 98
+SEE ATI Mach64
+
+NAME ATI Xpert XL
+SEE ATI Mach64
+
+NAME ATI Xpert@Play
+SEE ATI Mach64
+
+NAME ATI Xpert@Play 98
+SEE ATI Mach64
+
+NAME ATI Xpert@Work
+SEE ATI Mach64
+
+NAME ATI integrated on Intel Maui MU440EX motherboard
+SEE ATI Mach64
+
+NAME ASUS PCI-V264CT
+SEE ATI Mach64
+
+NAME ASUS PCI-AV264CT
+SEE ATI Mach64
+
+# AGX
+
+NAME AGX (generic)
+CHIPSET AGX-014/15/16
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+
+NAME Boca Vortex (Sierra RAMDAC)
+CHIPSET AGX-015
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+RAMDAC sc15025
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Option "fifo_moderate"   # 2x bus bw - may result in random pixels
+
+NAME EIZO (VRAM)
+SEE AGX (generic)
+
+NAME Orchid Celsius (AT&T RAMDAC)
+CHIPSET AGX-015
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+RAMDAC att20c490
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Option "fifo_moderate"   # 2x bus bw - may result in random pixels
+
+NAME Orchid Celsius (Sierra RAMDAC)
+CHIPSET AGX-015
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+RAMDAC sc15025
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Option "fifo_moderate"   # 2x bus bw - may result in random pixels
+
+
+NAME Spider Black Widow
+CHIPSET AGX-015
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+RAMDAC sc15025
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Option "fifo_moderate"   # 2x bus bw - may result in random pixels
+
+
+NAME Spider Black Widow Plus
+CHIPSET AGX-016
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+RAMDAC sc15025
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Option "fifo_moderate"   # 2x bus bw - may result in random pixels
+LINE     #Option "fifo_aggressive" # 3x bus bw - may result in random pixels
+LINE	 #Probable clocks:
+LINE     #Clocks 25.2  28.3  39.9  72.2  50.0  76.9  36.1  44.8
+LINE     #Clocks 89.0  119.8 79.9  31.5 110.0  64.9  74.9  94.9
+
+NAME Hercules Graphite HG210
+CHIPSET AGX-014
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+RAMDAC bt482
+DACSPEED 85
+LINE     Chipset "AGX-014"
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Probable clocks:
+LINE     #Clocks 25.0  28.0  32.0  36.0  40.0  45.0  50.0  65.0
+LINE     #Clocks 70.0  75.0  80.0  85.0  90.0  95.0 100.0 110.0
+
+NAME Hercules Graphite Pro
+CHIPSET AGX-015
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+# Card specific DAC, doesn't appear in ramdac menu
+LINE     Ramdac "herc_dual_dac"
+LINE     Chipset "AGX-015"
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Option "fifo_moderate"   # 2x bus bw - may result in random pixels
+LINE     #Probable clocks:
+LINE     #Clocks 25.0  28.0  32.0  36.0  40.0  45.0  50.0  65.0
+LINE     #Clocks 70.0  75.0  80.0  85.0  90.0  95.0 100.0 110.0
+
+NAME Hercules Graphite Power
+CHIPSET AGX-016
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+# Card specific DAC, doesn't appear in ramdac menu
+#   The glue logic state machine for RAMDAC switching doesn't work as
+#   documented, for now we're stuck with the small RAMDAC
+LINE     Ramdac "herc_small_dac"
+LINE     Chipset "AGX-016"
+LINE     Option "dac_8_bit"
+LINE     Option "no_wait_state"
+LINE     #Option "fifo_moderate"   # 2x bus bw - may result in random pixels
+LINE     #Option "fifo_aggressive" # 3x bus bw - may result in random pixels
+LINE     #Probable clocks:
+LINE     #Clocks 25.0  28.0  32.0  36.0  40.0  45.0  50.0  65.0
+LINE     #Clocks 70.0  75.0  80.0  85.0  90.0  95.0 100.0 110.0
+
+NAME XGA-2  (ISA bus)
+CHIPSET XGA-2
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+LINE     #Instance  7           # XGA instance 0-7
+LINE     #COPbase   0xC8F00     # XGA memory-mapped register address
+LINE     #POSbase   0           # Disable probing if above are specified
+
+NAME XGA-1  (ISA bus)
+CHIPSET XGA-1
+SERVER AGX
+DRIVER vga
+UNSUPPORTED
+LINE     #Instance  7           # XGA instance 0-7
+LINE     #COPbase   0xC8F00     # XGA memory-mapped register address
+LINE     #POSbase   0           # Disable probing if above are specified
+
+# WD
+
+NAME Paradise/WD 90CXX
+CHIPSET WD90CXX
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME DFI-WG6000
+CHIPSET WD90C33
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Diamond SpeedStar 24X (not fully supported)
+CHIPSET WD90C31
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME WD 90C24 (laptop)
+CHIPSET WD90C24
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE     #Chipset "wd90c24"
+LINE     #Option "noaccel" # Use this if acceleration is causing problems
+LINE     #Clocks 25.175 28.322 65     36     # These are not programmable
+LINE     #Clocks 29.979 77.408 62.195 59.957 # These are programmable
+LINE     #Clocks 31.5   35.501 75.166 50.114 # These are not programmable
+LINE     #Clocks 39.822 72.038 44.744 80.092 # These are programmable
+LINE     #Clocks 44.297                      # Must match Mclk
+
+
+NAME WD 90C24A or 90C24A2 (laptop)
+CHIPSET WD90C24A
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE     #Chipset "wd90c24"
+LINE     #Clocks 25.175 28.322 65     36     # These are not programmable
+LINE     #Clocks 29.979 77.408 62.195 59.957 # These are programmable
+LINE     #Clocks 31.5   35.501 75.166 50.114 # These are not programmable
+LINE     #Clocks 39.822 72.038 44.744 80.092 # These are programmable
+LINE     #Clocks 44.297                      # Must match Mclk
+
+# Avance Logic
+
+NAME Avance Logic 2101
+CHIPSET Avance Logic
+LINE   #chipset "al2101"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Avance Logic 2228
+CHIPSET Avance Logic
+LINE   #chipset "ali2228"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Avance Logic 2301
+CHIPSET Avance Logic
+LINE   #chipset "ali2301"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Avance Logic 2302
+CHIPSET Avance Logic
+LINE   #chipset "ali2302"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Avance Logic 2308
+CHIPSET Avance Logic
+LINE   #chipset "ali2308"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Avance Logic 2401
+CHIPSET Avance Logic
+LINE   #chipset "ali2401"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Hercules Stingray
+CHIPSET ALG-2228/2301/2302
+LINE   #chipset "ali2228"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME SPEA/V7 Mirage VEGA Plus
+CHIPSET ALG-2228
+LINE   #chipset "ali2228"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+# ARK Logic
+
+NAME Ark Logic ARK1000PV (generic)
+CHIPSET ARK1000PV
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+# For now, treat the VL as a PV.  This may be changed later
+NAME Ark Logic ARK1000VL (generic)
+CHIPSET ARK1000VL
+LINE Chipset "ark1000pv"
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Ark Logic ARK2000PV (generic)
+CHIPSET ARK1000PV
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Ark Logic ARK2000MT (generic)
+CHIPSET ARK1000MT
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Hercules Stingray Pro
+SEE Ark Logic ARK1000PV (generic)
+
+NAME Hercules Stingray Pro/V
+SEE Ark Logic ARK1000PV (generic)
+
+NAME Ocean (octek) VL-VGA-1000
+RAMDAC att20c490
+SEE Ark Logic ARK1000VL (generic)
+
+NAME Hercules Stingray 64/V with ZoomDAC
+SEE Ark Logic ARK2000PV (generic)
+
+NAME Hercules Stingray 64/V with ICS5342
+CHIPSET ARK2000MT
+RAMDAC ics5342
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Diamond Stealth64 Graphics 2001 series
+CHIPSET ARK2000PV
+RAMDAC ics5342
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+# Oak
+
+NAME Oak ISA Card (generic)
+CHIPSET Oak OTI-067/77
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Oak 87 VLB (generic)
+CHIPSET Oak OTI-087
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE Option "fifo_aggressive" # Comment this if you experience streaks.
+LINE Option "no_wait"         # Comment this if you find problems.        
+LINE #Option "enable_bitblt"  # You may enable this and see if it works (see README.Oak file)
+
+NAME Oak 87 ISA (generic)
+CHIPSET Oak OTI-087
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE Option "noaccel"        # ISA cards seem to have Color Expansion support broken
+LINE #Option "enable_bitblt" # This should work on ISA, but lets not make it default just in case.
+
+NAME Paradise Accelerator Value
+SEE Oak 87 ISA (generic)
+
+# P9000
+
+NAME Diamond Viper VLB 2Mb
+CHIPSET Weitek 9000
+SERVER P9000
+DRIVER vga
+UNSUPPORTED
+LINE     #Clocks must match the mode clocks (XFree86 3.1 P9000 server)
+LINE     #Versions later than 3.1 do not require a clocks line
+LINE     Chipset "vipervlb" # Required for some cards which autodetect as PCI
+LINE     Videoram 2048      # Required
+LINE     Membase 0x80000000 # Optional (0x80000000 is default)
+NOCLOCKPROBE
+
+NAME Diamond Viper PCI 2Mb
+CHIPSET Weitek 9000
+SERVER P9000
+DRIVER vga
+UNSUPPORTED
+LINE     #Clocks must match the mode clocks (XFree86 3.1 P9000 server)
+LINE     #Versions later than 3.1 do not require a clocks line
+LINE     Videoram 2048      # Required
+LINE     #Membase 0x80000000 # Use scanpci to get the correct Membase
+NOCLOCKPROBE
+
+NAME Orchid P9000 VLB
+CHIPSET Weitek 9000
+SERVER P9000
+DRIVER vga
+UNSUPPORTED
+LINE     Chipset "orchid_p9000"
+LINE     Membase 0xE0000000
+NOCLOCKPROBE
+
+# P9100
+
+NAME Weitek P9100 (generic)
+CHIPSET Weitek P9100
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME Diamond Viper Pro Video
+SEE Weitek P9100 (generic)
+
+# Trident
+
+NAME Trident 8900/9000 (generic)
+CHIPSET TVGA8900/9000
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Trident 8900D (generic)
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Trident TVGA9200CXr (generic)
+CHIPSET TVGA9200CXr
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+NAME Trident TGUI9400CXi (generic)
+CHIPSET TGUI9400CXi
+SERVER SVGA
+DRIVER trident
+
+NAME Trident TGUI9420DGi (generic)
+CHIPSET TGUI9420DGi
+SERVER SVGA
+DRIVER trident
+
+NAME Trident TGUI9430DGi (generic)
+CHIPSET TGUI9430DGi
+SERVER SVGA
+DRIVER trident
+
+NAME Trident TGUI9420 (generic)
+CHIPSET TGUI9420
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident TGUI9440 (generic)
+CHIPSET TGUI9440
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident TGUI9660 (generic)
+CHIPSET TGUI9660
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident TGUI9680 (generic)
+CHIPSET TGUI9680
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident TGUI9682 (generic)
+CHIPSET TGUI9682
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident TGUI9685 (generic)
+CHIPSET TGUI9685
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9320 (generic)
+CHIPSET Cyber9320
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9382 (generic)
+CHIPSET Cyber9382
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9385 (generic)
+CHIPSET Cyber9385
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9388 (generic)
+CHIPSET Cyber9388
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 939a (generic)
+CHIPSET Cyber939a
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9397 (generic)
+CHIPSET Cyber9397
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Cyber 9520 (generic)
+CHIPSET Cyber9520
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident 3DImage975 (generic)
+CHIPSET 3dimage975
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident 3DImage975 AGP (generic)
+CHIPSET 3dimage975
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident 3DImage985 (generic)
+CHIPSET 3dimage985
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Providia 9682 (generic)
+CHIPSET Providia9682
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Providia 9685 (generic)
+CHIPSET Providia9685
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident TVGA 8800BR
+SEE * Generic VGA compatible
+
+NAME Trident TVGA 8800CS
+SEE * Generic VGA compatible
+
+NAME Trident CyberBlade (generic)
+CHIPSET CyberBlade
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+NAME Trident Blade3D (generic)
+CHIPSET Blade3D
+SERVER SVGA
+DRIVER trident
+NOCLOCKPROBE
+
+# SiS
+
+NAME SiS 530
+CHIPSET SIS530
+SERVER SVGA
+DRIVER sis
+
+NAME SiS 620
+CHIPSET SIS620
+SERVER SVGA
+DRIVER sis
+
+NAME SiS SG86C201
+CHIPSET SIS86C201
+SERVER SVGA
+DRIVER sis
+
+NAME SiS SG86C205
+CHIPSET SIS86C205
+SERVER SVGA
+DRIVER sis
+LINE     # Option "no_accel" # Use this if acceleration is causing problems
+LINE     # Option "fifo_moderate" 
+LINE     # Option "fifo_conserv" 
+LINE     # Option "fifo_aggressive" 
+NOCLOCKPROBE
+
+NAME SiS SG86C215
+CHIPSET SIS86C215 
+SERVER SVGA
+DRIVER sis
+LINE     # This is a cheap version of 86c205. I am not sure if acceleration works
+LINE     # Option "no_accel" # Use this if acceleration is causing problems
+LINE     # Option "no_BitBlt" # Use this if acceleration is causing problems
+LINE     # Option "fifo_moderate" 
+LINE     # Option "fifo_conserv" 
+LINE     # Option "fifo_aggressive" 
+NOCLOCKPROBE
+
+NAME SiS SG86C225
+CHIPSET SIS86C225
+SERVER SVGA
+DRIVER sis
+LINE     # Option "no_accel" # Use this if acceleration is causing problems
+LINE     # Option "fifo_moderate" 
+LINE     # Option "fifo_conserv" 
+LINE     # Option "fifo_aggressive" 
+NOCLOCKPROBE
+
+NAME SiS 5597
+CHIPSET SiS5597
+SERVER SVGA
+DRIVER sis
+LINE     # Option "no_accel" # Use this if acceleration is causing problems
+LINE     # Option "fifo_moderate" 
+LINE     # Option "fifo_conserv" 
+LINE     # Option "fifo_aggressive" 
+LINE     # Option "fast_vram"
+LINE     # Option "pci_burst_on"
+LINE     # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!!
+LINE     # Option "ext_eng_queue" # Turbo-queue. This can cause drawing
+LINE                              # errors, but gives some accel
+NOCLOCKPROBE
+
+NAME SiS 5598
+CHIPSET SIS5598
+SERVER SVGA
+DRIVER sis
+LINE     # Option "no_accel" # Use this if acceleration is causing problems
+LINE     # Option "fifo_moderate" 
+LINE     # Option "fifo_conserv" 
+LINE     # Option "fifo_aggressive" 
+LINE     # Option "fast_vram"
+LINE     # Option "pci_burst_on"
+LINE     # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!!
+LINE     # Option "ext_eng_queue" # Turbo-queue. This can cause drawing
+LINE                              # errors, but gives some accel
+NOCLOCKPROBE
+
+NAME SiS 6326
+CHIPSET SiS6326
+SERVER SVGA
+DRIVER sis
+LINE     # Option "no_accel" # Use this if acceleration is causing problems
+LINE     # Option "fifo_moderate" 
+LINE     # Option "fifo_conserv" 
+LINE     # Option "fifo_aggressive" 
+LINE     # Option "fast_vram"
+LINE     # Option "pci_burst_on"
+LINE     # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!!
+LINE     # Option "ext_eng_queue" # Turbo-queue. This can cause drawing 
+LINE                              # errors, but gives some accel
+NOCLOCKPROBE
+
+NAME MSI MS-4417
+SEE SiS 6326
+
+NAME SiS 3D PRO AGP
+SEE SiS 6326
+
+NAME Miro Crystal DVD
+SEE SiS 6326
+
+NAME PC-Chips M567 Mainboard
+SEE SiS 5597
+
+NAME Diamond SpeedStar A50
+SEE SiS 6326
+
+# Cyrix
+
+NAME MediaGX
+CHIPSET mediagx
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+# Alliance ProMotion
+
+NAME Alliance ProMotion 6422
+CHIPSET AP6422
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+
+# Number 9 I128
+
+NAME Number Nine Imagine I-128
+CHIPSET I128
+SERVER I128
+DRIVER i128
+NOCLOCKPROBE
+
+NAME Number Nine Imagine I-128 Series 2
+CHIPSET I128
+SERVER I128
+DRIVER i128
+NOCLOCKPROBE
+
+NAME Number Nine Revolution 3D (T2R)
+CHIPSET I128
+SERVER I128
+DRIVER i128
+NOCLOCKPROBE
+
+NAME Number Nine Imagine-128 Revolution IV (T2R4)
+CHIPSET I128
+SERVER I128
+DRIVER i128
+NOCLOCKPROBE
+
+# Matrox
+
+NAME Matrox Millennium 2MB
+CHIPSET mga2064w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 2048
+NOCLOCKPROBE
+
+NAME Matrox Millennium 4MB
+CHIPSET mga2064w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Millennium 8MB
+CHIPSET mga2064w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium II 4MB
+CHIPSET mga2164w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Millennium II 8MB
+CHIPSET mga2164w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium II 16MB
+CHIPSET mga2164w
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 4MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 8MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 16MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 SD 4MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+LINE # Option "mga_sdram"
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 SD 8MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+LINE # Option "mga_sdram"
+NOCLOCKPROBE
+
+NAME Matrox Millennium G200 SD 16MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+LINE # Option "mga_sdram"
+NOCLOCKPROBE
+
+NAME Matrox Mystique
+CHIPSET mga1064sg
+SERVER SVGA
+DRIVER mga
+NOCLOCKPROBE
+
+NAME Matrox Mystique G200 4MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Mystique G200 8MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+NAME Matrox Millennium G400
+CHIPSET mgag400
+SERVER SVGA
+DRIVER mga
+NOCLOCKPROBE
+
+NAME Matrox Mystique G200 16MB
+CHIPSET mgag200
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 16384
+NOCLOCKPROBE
+
+NAME Matrox Productiva G100 4MB
+CHIPSET mgag100
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 4096
+NOCLOCKPROBE
+
+NAME Matrox Productiva G100 8MB
+CHIPSET mgag100
+SERVER SVGA
+DRIVER mga
+LINE VideoRam 8192
+NOCLOCKPROBE
+
+# NVIDIA
+
+NAME Diamond Edge 3D
+CHIPSET nv1
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+NOCLOCKPROBE
+
+NAME RIVA128
+CHIPSET RIVA128
+SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
+NAME RIVA TNT
+CHIPSET RIVATNT
+SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
+NAME RIVA TNT2
+CHIPSET RIVATNT2
+SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
+NAME NVIDIA GeForce
+CHIPSET GeForce
+SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
+NAME ELSA VICTORY ERAZOR
+SEE RIVA128
+
+NAME ELSA Winner 1000 R3D
+SEE RIVA128
+
+NAME ELSA ERAZOR II
+SEE RIVA TNT
+
+NAME Diamond Viper 330
+SEE RIVA128
+
+NAME Diamond Viper 550
+SEE RIVA TNT
+
+NAME Diamond Viper 770
+SEE RIVA TNT2
+
+NAME STB Velocity 128
+SEE RIVA128
+
+NAME STB nvidia 128
+SEE RIVA128
+
+NAME STB Velocity 4400
+SEE RIVA TNT
+
+NAME ASUS 3Dexplorer
+SEE RIVA128
+
+NAME Guillemot Maxi Gamer Xentor
+SEE RIVA TNT2
+
+NAME Guillemot Maxi Gamer Xentor 32
+SEE RIVA TNT2
+
+NAME Creative Graphics Blaster TNT
+SEE RIVA TNT
+
+NAME Creative Graphics Blaster TNT2
+SEE RIVA TNT2
+
+# 3Dfx
+NAME Voodoo Banshee (generic)
+SERVER SVGA
+CHIPSET 3dfx Banshee
+DRIVER tdfx
+
+NAME Voodoo3 (generic)
+SERVER SVGA
+CHIPSET 3dfx Voodoo3
+DRIVER tdfx
+
+NAME Elsa Victory II
+SEE Voodoo Banshee (generic)
+
+NAME Diamond Monster Fusion
+SEE Voodoo Banshee (generic)
+
+NAME AOpen PA2010
+SEE Voodoo Banshee (generic)
+
+NAME Chaintech Desperado 3F10
+SEE Voodoo Banshee (generic)
+
+# 3DLabs
+
+NAME ELSA GLoria-L/MX
+CHIPSET GLINT MX
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME ELSA GLoria-L
+CHIPSET GLINT 500TX
+SERVER 3DLabs
+DRIVER glint
+NOCLOCKPROBE
+
+NAME ELSA GLoria-XL
+CHIPSET GLINT MX
+SERVER 3DLabs
+DRIVER glint
+NOCLOCKPROBE
+
+NAME Diamond Fire GL 3000
+CHIPSET GLINT 500TX
+SERVER 3DLabs
+DRIVER glint
+LINE Option "firegl_3000"
+NOCLOCKPROBE
+
+NAME ELSA GLoria-S
+CHIPSET PERMEDIA
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+LINE #VideoRam 8192
+NOCLOCKPROBE
+
+NAME Diamond Fire GL 1000
+CHIPSET PERMEDIA
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+LINE #VideoRam 8192
+NOCLOCKPROBE
+
+NAME ELSA GLoria Synergy
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME ELSA Winner 2000/Office
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Diamond Fire GL 1000 PRO
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Creative Blaster Exxtreme
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME AccelStar Permedia II AGP
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Leadtek WinFast 2300
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+NOCLOCKPROBE
+
+NAME 3DLabs Oxygen GMX
+CHIPSET PERMEDIA 2
+SERVER 3DLabs
+DRIVER glint
+LINE #Option "no_accel"
+NOCLOCKPROBE
+
+NAME Appian Jeronimo 2000
+CHIPSET PERMEDIA 3
+SERVER 3DLabs
+DRIVER glint
+NOCLOCKPROBE
+
+# Alliance Semiconductor
+
+NAME Diamond Stealth Video 2500
+CHIPSET Alliance AT24 
+SERVER SVGA
+DRIVER apm
+NOCLOCKPROBE
+
+NAME AT3D
+CHIPSET Alliance AT3D
+SERVER SVGA
+DRIVER apm
+NOCLOCKPROBE
+LINE #Option "no_accel"
+
+NAME AT25
+SEE AT3D
+
+NAME Hercules Stingray 128 3D
+SEE AT3D
+
+# NeoMagic
+
+NAME NeoMagic (laptop/notebook)
+CHIPSET MagicGraph 128 series
+SERVER SVGA
+DRIVER neomagic
+LINE #    Chipset    "NM2160"
+LINE #    IOBase     0xfea00000
+LINE #    MemBase    0xfd000000
+LINE #    VideoRam   2048
+LINE #    DacSpeed   90
+LINE #    Option     "linear"
+LINE #    Option     "nolinear"
+LINE #    Option     "sw_cursor"
+LINE #    Option     "hw_cursor"
+LINE #    Option     "no_accel"
+LINE #    Option     "intern_disp"
+LINE #    Option     "extern_disp"
+LINE #    Option     "mmio"
+LINE #    Option     "no_mmio"
+LINE #    Option     "lcd_center"
+LINE #    Option     "no_stretch"
+
+# Epson SPC8110
+
+NAME EPSON SPC8110 (CardPC)
+CHIPSET SPC8110
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE #    Chipset    "spc8110"
+LINE #    MemBase    0x03e00000
+LINE #    VideoRam   1024
+LINE #    Option     "nolinear"
+LINE #    Option     "sw_cursor"
+LINE #    Option     "noaccel"
+LINE #    Option     "fifo_moderate"
+LINE #    Option     "fifo_conservative"
+
+# Silicon Motion, Inc.
+
+NAME Silicon Motion Lynx family
+CHIPSET Lynx
+SERVER SVGA
+DRIVER siliconmotion
+NOCLOCKPROBE
+
+# Rendition
+
+NAME Rendition Verite 1000
+CHIPSET Verite 1000
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # Option "sw_cursor"
+
+NAME Rendition Verite 2x00
+CHIPSET Verite 2x00
+SERVER SVGA
+DRIVER vga
+UNSUPPORTED
+LINE # Option "sw_cursor"
+
+NAME Creative Labs 3D Blaster PCI (Verite 1000)
+SEE Rendition Verite 1000
+
+NAME Canopus Total-3D
+SEE Rendition Verite 1000
+
+NAME Sierra Screaming 3D
+SEE Rendition Verite 1000
+
+NAME Miro CRYSTAL VRX
+SEE Rendition Verite 1000
+
+NAME Diamond Stealth II S220
+CHIPSET Verite 2100
+SEE Rendition Verite 2x00
+
+NAME Hercules Thriller3D
+CHIPSET Verite 2200
+SEE Rendition Verite 2x00
+
+# Digital
+
+NAME Digital 8-plane TGA (UDB/Multia)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt485
+
+NAME Digital 8-plane TGA (ZLXp-E1)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt485
+
+NAME Digital 24-plane TGA (ZLXp-E2)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt463
+
+NAME Digital 24-plane+3D TGA (ZLXp-E3)
+CHIPSET TGA
+SERVER TGA
+DRIVER tga
+RAMDAC Bt463
+
+# i810
+
+NAME Intel 810
+SERVER SVGA
+DRIVER i810
+
+# i740
+
+NAME Intel 740 (generic)
+SERVER SVGA
+DRIVER i740
+
+# Misc
+
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-server -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,38 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localmacros 1.7     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L$(BUILDLIBDIR)
+
+LintTarget()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/xf86config/xorgconfig.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,3137 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c,v 3.69 2003/02/20 04:05:15 dawes Exp $ */
+
+/* Copyright 2005 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.
+ */
+
+/*
+ * This is a configuration program that will create a base XF86Config
+ * file based on menu choices. Its main feature is that clueless users
+ * may be less inclined to select crazy sync rates way over monitor spec,
+ * by presenting a menu with standard monitor types. Also some people
+ * don't read docs unless an executable that they can run tells them to.
+ *
+ * It assumes a 24-line or bigger text console.
+ *
+ * Revision history:
+ * 25Sep94 Initial version.
+ * 27Sep94 Fix hsync range of monitor types to match with best possible mode.
+ *         Remove 'const'.
+ *         Tweak descriptions.
+ * 28Sep94 Fixes from J"org Wunsch:
+ *           Don't use gets().
+ *           Add mouse device prompt.
+ *           Fix lines overrun for 24-line console.
+ *         Increase buffer size for probeonly output.
+ * 29Sep94 Fix bad bug with old XF86Config preserving during probeonly run.
+ *         Add note about vertical refresh in interlaced modes.
+ *         Name gets() replacement getstring().
+ *         Add warning about binary paths.
+ *         Fixes from David Dawes:
+ *           Don't use 'ln -sf'.
+ *           Omit man path reference in comment.
+ *           Generate only a generic 320x200 SVGA section for accel cards.
+ *	     Only allow writing to /usr/X11R6/lib/X11 if root, and use
+ *	       -xf86config for the -probeonly phase (root only).
+ *         Fix bug that forces screen type to accel in some cases.
+ * 30Sep94 Continue after clocks probe fails.
+ *         Note about programmable clocks.
+ *         Rename to 'xf86config'. Not to be confused with XF86Config
+ *           or the -xf86config option.
+ * 07Oct94 Correct hsync in standard mode timings comments, and include
+ *           the proper +/-h/vsync flags.
+ * 11Oct94 Skip 'numclocks:' and 'pixel clocks:' lines when probing for
+ * 	     clocks.
+ * 18Oct94 Add check for existence of /usr/X11R6.
+ *	   Add note about ctrl-alt-backspace.
+ * 06Nov94 Add comment above standard mode timings in XF86Config.
+ * 24Dec94 Add low-resolution modes using doublescan.
+ * 29Dec94 Add note in horizontal sync range selection.
+ *	   Ask about ClearDTR/RTS option for Mouse Systems mice.
+ *	   Ask about writing to /etc/XF86Config.
+ *	   Allow link to be set in /var/X11R6/bin.
+ *	   Note about X -probeonly crashing.
+ *	   Add keyboard Alt binding option for non-ASCII characters.
+ *	   Add card database selection.
+ *	   Write temporary XF86Config for clock probing in /tmp instead
+ *	     of /usr/X11R6/lib/X11.
+ *	   Add RAMDAC and Clockchip menu.
+ * 27Mar99 Modified for XFree86 4.0 config file format
+ * 06Sep02 Write comment block about 'DontVTSwitch'.
+ *
+ * Possible enhancements:
+ * - Add more standard mode timings (also applies to README.Config). Missing
+ *   are 1024x768 @ 72 Hz, 1152x900 modes, and 1280x1024 @ ~70 Hz.
+ *   I suspect there is a VESA standard for 1024x768 @ 72 Hz with 77 MHz dot
+ *   clock, and 1024x768 @ 75 Hz with 78.7 MHz dot clock. New types of
+ *   monitors probably work better with VESA 75 Hz timings.
+ * - Add option for creation of clear, minimal XF86Config.
+ * - The card database doesn't include most of the entries in previous
+ *   databases.
+ *
+ * Send comments to [email protected].
+ *
+ * Things to keep up-to-date:
+ * - Accelerated server names.
+ * - Ramdac and Clockchip settings.
+ * - The card database.
+ *
+ */
+/*  Oct2000
+ *  New 'Configuration of XKB' section.
+ *  Author: Ivan Pascal      The XFree86 Project.
+ */
+/*
+ *  Nov2002
+ *  Some enhancements:
+ *  - Add new PS/2 mouse protocol.
+ *    "IMPS/2","ExplorerPS/2","ThinkingMousePS/2","MouseManPlusPS/2",
+ *    "GlidePointPS/2","NetMousePS/2" and "NetScrollPS/2".
+ *  - Add mouse-speed setting for PS/2 mouse.
+ *  - Fix seg.fault problem on Solaris.
+ *  - Add modestring "1400x1050"(for ATI Mobile-Rage).
+ *  - Add videomemory 8192, 16384, 32768, 65536, 131072 and 262144.
+ *  - Load "speedo" module.
+ *  - Ready to DRI.
+ *  - Load xtt module instead of freetype module.
+ *  - Add font path "/TrueType/" and "/freefont/".
+ *  Chisato Yamauchi([email protected])
+ */
+/* $XConsortium: xf86config.c /main/21 1996/10/28 05:43:57 kaleb $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86config/xorgconfig.c,v 1.14 2005/05/28 00:08:03 alanc Exp $ */
+
+#ifdef HAVE_CONFIG_H
+# include "xorg-server.h"
+# include "xkb-config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* hv: fix a few EMX problems, will disappear with real UnixOS/2 */
+#ifdef __UNIXOS2__
+#define sync() /*nothing*/
+static int getuid() { return 0; }
+#endif
+
+#ifdef SUNSOFT  /* setuid support for running under RBAC */
+#ident "@(#)xorgconfig.c	1.15	06/03/28	SMI"
+#include <fcntl.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <time.h>
+static int euid_changed = 0;
+static uid_t saved_id = -1;
+static void configdir_check(void);
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBrules.h>
+#define MAX_XKBOPTIONS	5
+
+#include "cards.h"
+
+
+/*
+ * Define the following to 310 to remove references to XFree86 features that
+ * have been added since XFree86 3.1 (e.g. DoubleScan modes).
+ * or to 311 to remove certain new modelines
+ */
+#define XFREE86_VERSION 400
+
+/*
+ * Define this to have /etc/X11/XF86Config prompted for as the default
+ * location to write the XF86Config file to.
+ */
+#define PREFER_XF86CONFIG_IN_ETC
+
+/*
+ * Define this to force the user to go through XKB configuration section.
+ *
+ */
+#define FORCE_XKB_DIALOG
+
+/*
+ * Configuration variables.
+ */
+
+#define MAX_CLOCKS_LINES 16
+
+#define DUMBCONFIG2 "dumbconfig.2"
+#define DUMBCONFIG3 "dumbconfig.3"
+
+/* some more vars to make path names in texts more flexible. OS/2 users
+ * may be more irritated than Unix users
+ */
+#ifndef PROJECTROOT
+#define PROJECTROOT		"/usr/X11R6"
+#endif
+#define TREEROOT		PROJECTROOT
+#define TREEROOTLX		TREEROOT "/lib/X11"
+#define TREEROOTCFG		TREEROOT "/etc/X11"
+#ifdef XDOCDIR
+# define TREEROOTDOC		XDOCDIR
+#else
+# define TREEROOTDOC		TREEROOTLX "/doc"
+#endif
+#ifdef XFONTDIR
+# define TREEROOTFONT		XFONTDIR
+#else
+# define TREEROOTFONT		TREEROOTLX "/fonts"
+#endif
+#define MODULEPATH		TREEROOT "/lib/modules"
+
+#ifndef __UNIXOS2__
+#define XSERVERNAME_FOR_PROBE "X"
+#else
+#define XSERVERNAME_FOR_PROBE PROJECTROOT"/bin/"__XSERVERNAME__
+#endif
+
+#ifndef XCONFIGFILE
+#define XCONFIGFILE		"xorg.conf"
+#endif
+#define CONFIGNAME		XCONFIGFILE
+
+/*
+ * This is the filename of the temporary XF86Config file that is written
+ * when the program is told to probe clocks (which can only happen for
+ * root).
+ */
+#define TEMPORARY_XF86CONFIG_DIR_PREFIX "/tmp/."XCONFIGFILE
+#define TEMPORARY_XF86CONFIG_FILENAME XCONFIGFILE".tmp"
+
+#ifndef XF86_VERSION_MAJOR
+#ifdef XVERSION
+#if XVERSION > 40000000
+#define XF86_VERSION_MAJOR	(XVERSION / 10000000)
+#else
+#define XF86_VERSION_MAJOR	(XVERSION / 1000)
+#endif
+#else
+#define XF86_VERSION_MAJOR	4
+#endif
+#endif
+
+
+int config_mousetype;		/* Mouse. */
+int config_emulate3buttons;
+int config_chordmiddle;
+int config_cleardtrrts;
+char *config_pointerdevice;
+int config_altmeta;		/* Keyboard. */
+int config_monitortype;		/* Monitor. */
+char *config_hsyncrange;
+char *config_vsyncrange;
+char *config_monitoridentifier;
+int config_videomemory;		/* Video card. */
+int config_screentype;		/* mono, vga16, svga, accel */
+char *config_deviceidentifier;
+int config_numberofclockslines;
+char *config_clocksline[MAX_CLOCKS_LINES];
+char *config_modesline8bpp;
+char *config_modesline16bpp;
+char *config_modesline24bpp;
+int config_virtual;		/* 1 (yes) or 0 (no) */
+int config_virtualx8bpp, config_virtualy8bpp;
+int config_virtualx16bpp, config_virtualy16bpp;
+int config_virtualx24bpp, config_virtualy24bpp;
+char *config_ramdac;
+char *config_dacspeed;
+char *config_clockchip;
+#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+char *config_keyboard_dev = "/dev/wskbd0";
+#endif
+int config_xkbdisable = 0;
+char *config_xkbrules;
+char *config_xkbmodel = "pc105";
+char *config_xkblayout = "us";
+char *config_xkbvariant = (char *) 0;
+char *config_xkboptions = (char *) 0;
+char *config_depth;
+
+char *temp_dir = "";
+
+/*
+ * These are from the selected card definition. Parameters from the
+ * definition are offered during the questioning about the video card.
+ */
+
+int card_selected;	/* Card selected from database. */
+
+
+static int write_XF86Config(char *filename);
+
+
+/*
+ * This is the initial intro text that appears when the program is started.
+ */
+
+static char *intro_text =
+"\n"
+"This program will create a basic " CONFIGNAME " file, based on menu selections\n"
+"you make.  It will ask for a pathname when it is ready to write the file.\n"
+"\n"
+#ifdef SUNSOFT
+"The " CONFIGNAME " file usually resides in /etc/X11.  If\n"
+#else
+"The " CONFIGNAME " file usually resides in /etc/X11 or " TREEROOTCFG ".  If\n"
+#endif
+"no " CONFIGNAME " file is present there, " __XSERVERNAME__" will probe the system to\n"
+"autoconfigure itself.  You can run " __XSERVERNAME__ " -configure to generate a " CONFIGNAME "\n"
+"file based on the results of autoconfiguration, or let this program\n"
+"produce a base " CONFIGNAME " file for your configuration, and fine-tune it.\n"
+"A sample " CONFIGNAME " file is also supplied with "__XSERVERNAME__"; it is configured \n"
+"for a standard VGA card and monitor with 640x480 resolution.\n"
+"\n"
+"There are also many chipset and card-specific options and settings available,\n"
+"but this program does not know about these. On some configurations some of\n"
+"these settings must be specified. Refer to the X driver man pages and the\n"
+"chipset-specific READMEs in " TREEROOTDOC " for further details.\n"
+#if 0
+" Refer to " TREEROOTDOC "/README.Config\n"
+"for a detailed overview of the configuration process.\n"
+"\n"
+"(what should we change this section to?)\n"
+"For accelerated servers (including accelerated drivers in the SVGA server),\n"
+"there are many chipset and card-specific options and settings. This program\n"
+"does not know about these. On some configurations some of these settings must\n"
+"be specified. Refer to the server man pages and chipset-specific READMEs.\n"
+#endif
+"\n"
+"Before continuing with this program, make sure you know what video card\n"
+"you have, and preferably also the chipset it uses and the amount of video\n"
+"memory on your video card, as well as the specifications of your monitor.\n"
+"\n"
+;
+
+static char *finalcomment_text =
+"File has been written. Take a look at it before starting an X server. Note that\n"
+"the " CONFIGNAME " file must be in one of the directories searched by the server\n"
+"(e.g. /etc/X11) in order to be used. Within the server press\n"
+"ctrl, alt and '+' simultaneously to cycle video resolutions. Pressing ctrl,\n"
+"alt and backspace simultaneously immediately exits the server (use if\n"
+"the monitor doesn't sync for a particular mode).\n"
+"\n"
+"For further configuration, refer to the " XCONFIGFILE "(" FILEMANSUFFIX ") manual page.\n"
+"\n";
+
+static void *
+Malloc(int i) {
+       void *p;
+
+       p = malloc(i);
+       if (p == NULL) {
+               printf("Fatal malloc error\n");
+               exit(-1);
+       }
+       return p;
+}
+
+static char *
+Strdup(const char *s){
+	char *d;
+
+	d = Malloc(strlen(s) + 1);
+	strcpy(d, s);
+	return d;
+}
+
+static void 
+createtmpdir(void) {
+       /* length of prefix + 20 (digits in 2**64) + 1 (slash) + 1 */
+       temp_dir = Malloc(strlen(TEMPORARY_XF86CONFIG_DIR_PREFIX) + 22);
+       sprintf(temp_dir, "%s%ld", TEMPORARY_XF86CONFIG_DIR_PREFIX,
+	       (long)getpid());
+       if (mkdir(temp_dir, 0700) != 0) {
+               printf("Cannot create directory %s\n", temp_dir);
+               exit(-1);
+       }
+       /* append a slash */
+       strcat(temp_dir, "/");
+}
+
+
+void 
+keypress(void) {
+	printf("Press enter to continue, or ctrl-c to abort.");
+	getchar();
+	printf("\n");
+}
+
+static void 
+emptylines(void) {
+	int i;
+	for (i = 0; i < 50; i++)
+		printf("\n");
+}
+
+static int 
+answerisyes(char *s)
+{
+	if (s[0] == '\'')	/* For fools that type the ' literally. */
+		return tolower(s[1]) == 'y';
+	return tolower(s[0]) == 'y';
+}
+
+/*
+ * This is a replacement for gets(). Limit is 80 chars.
+ * The 386BSD descendants scream about using gets(), for good reason.
+ */
+
+static void 
+getstring(char *s)
+{
+	char *cp;
+	if (fgets(s, 80, stdin) == NULL)
+		exit(1);
+	cp = strchr(s, '\n');
+	if (cp)
+		*cp=0;
+}
+
+/*
+ * Mouse configuration.
+ *
+ * (hv) OS/2 (__UNIXOS2__) only has an OS supported mouse, so user has no options
+ * the server will enable a third button automatically if there is one
+ * We also do the same for QNX4, since we use the OS mouse drivers.
+ */
+
+int	M_OSMOUSE,	M_WSMOUSE,		M_AUTO,
+	M_SYSMOUSE,	M_MOUSESYSTEMS, 	M_PS2,
+	M_MICROSOFT,	M_BUSMOUSE,		M_IMPS2,
+	M_EXPLORER_PS2, M_GLIDEPOINT_PS2,	M_MOUSEMANPLUS_PS2,
+	M_NETMOUSE_PS2, M_NETSCROLL_PS2,	M_THINKINGMOUSE_PS2,
+	M_ACECAD,	M_GLIDEPOINT,		M_INTELLIMOUSE,
+	M_LOGITECH,	M_MMHITTAB,		M_MMSERIES,
+	M_MOUSEMAN,	M_THINKINGMOUSE,	M_VUID;
+
+struct {
+	char *name;
+	int *ident;
+	char *desc;
+} mouse_info[] = {
+#if defined(__UNIXOS2__) || defined(QNX4)
+#define DEF_PROTO_STRING	"OSMOUSE"
+	{"OSMOUSE",		&M_OSMOUSE,
+	 "OSMOUSE"
+	},
+#endif
+#ifdef WSCONS_SUPPORT
+#define WS_MOUSE_STRING		"wsmouse"
+#define DEF_PROTO_STRING	WS_MOUSE_STRING
+	{WS_MOUSE_STRING,	&M_WSMOUSE,
+	 "wsmouse protocol"
+	},
+#endif
+#ifndef DEF_PROTO_STRING
+#define DEF_PROTO_STRING	"Auto"
+#endif
+	{"Auto",		&M_AUTO,
+	 "Auto detect"
+	},
+#ifdef sun
+	{"VUID",		&M_VUID,
+	 "Solaris VUID protocol (SPARC, USB, or virtual mouse)"
+	},
+#endif
+	{"SysMouse",		&M_SYSMOUSE,
+	 "SysMouse"
+	},
+#define M_MOUSESYSTEMS_STRING	"MouseSystems"
+	{M_MOUSESYSTEMS_STRING,	&M_MOUSESYSTEMS,
+	 "Mouse Systems (3-button protocol)"
+	},
+	{"PS/2",		&M_PS2,
+	 "PS/2 Mouse"
+	},
+#define M_MICROSOFT_STRING	"Microsoft"
+	{M_MICROSOFT_STRING,	&M_MICROSOFT,
+	 "Microsoft compatible (2-button protocol)"
+	},
+	{"Busmouse",		&M_BUSMOUSE,
+	 "Bus Mouse"
+	},
+#ifndef __FreeBSD__
+	{"IMPS/2",		&M_IMPS2,
+	 "IntelliMouse PS/2"
+	},
+	{"ExplorerPS/2",	&M_EXPLORER_PS2,
+	 "Explorer PS/2"
+	},
+	{"GlidePointPS/2",	&M_GLIDEPOINT_PS2,
+	 "GlidePoint PS/2"
+	},
+	{"MouseManPlusPS/2",	&M_MOUSEMANPLUS_PS2,
+	 "MouseManPlus PS/2"
+	},
+	{"NetMousePS/2",	&M_NETMOUSE_PS2,
+	 "NetMouse PS/2"
+	},
+	{"NetScrollPS/2",	&M_NETSCROLL_PS2,
+	 "NetScroll PS/2"
+	},
+	{"ThinkingMousePS/2",	&M_THINKINGMOUSE_PS2,
+	 "ThinkingMouse PS/2"
+	},
+#endif
+	{"AceCad",		&M_ACECAD,
+	 "AceCad"
+	},
+	{"GlidePoint",		&M_GLIDEPOINT,
+	 "GlidePoint"
+	},
+	{"IntelliMouse",	&M_INTELLIMOUSE,
+	 "Microsoft IntelliMouse"
+	},
+	{"Logitech",		&M_LOGITECH,
+	 "Logitech Mouse (serial, old type, Logitech protocol)"
+	},
+	{"MMHitTab",		&M_MMHITTAB,
+	 "MM HitTablet"
+	},
+	{"MMSeries",		&M_MMSERIES,
+	 "MM Series"	/* XXXX These descriptions should be improved. */
+	},
+	{"MouseMan",		&M_MOUSEMAN,
+	 "Logitech MouseMan (Microsoft compatible)"
+	},
+	{"ThinkingMouse",	&M_THINKINGMOUSE,
+	 "ThinkingMouse"
+	},
+};
+
+#ifdef WSCONS_SUPPORT
+# define DEF_MOUSEDEV "/dev/wsmouse";
+#elif defined(__FreeBSD__)
+# define DEF_MOUSEDEV "/dev/sysmouse";
+#else
+# define DEF_MOUSEDEV "/dev/mouse";
+#endif
+
+#ifndef __UNIXOS2__
+static char *mouseintro_text =
+"First specify a mouse protocol type. Choose one from the following list:\n"
+"\n";
+
+static char *mousedev_text =
+"Now give the full device name that the mouse is connected to, for example\n"
+"/dev/tty00. Just pressing enter will use the default, %s.\n"
+"\n";
+
+static char *mousecomment_text =
+"The recommended protocol is " DEF_PROTO_STRING ". If you have a very old mouse\n"
+"or don't want OS support or auto detection, and you have a two-button\n"
+"or three-button serial mouse, it is most likely of type " M_MICROSOFT_STRING ".\n"
+#ifdef WSCONS_SUPPORT
+"\n"
+"If your system uses the wscons console driver, with a PS/2 type mouse,\n"
+"select " WS_MOUSE_STRING ".\n"
+#endif
+"\n";
+
+static char *twobuttonmousecomment_text =
+"You have selected a two-button mouse protocol. It is recommended that you\n"
+"enable Emulate3Buttons.\n";
+
+static char *threebuttonmousecomment_text =
+"You have selected a three-button mouse protocol. It is recommended that you\n"
+"do not enable Emulate3Buttons, unless the third button doesn't work.\n";
+
+static char *unknownbuttonsmousecomment_text =
+"If your mouse has only two buttons, it is recommended that you enable\n"
+"Emulate3Buttons.\n";
+
+static char *microsoftmousecomment_text =
+"You have selected a Microsoft protocol mouse. If your mouse was made by\n"
+"Logitech, you might want to enable ChordMiddle which could cause the\n"
+"third button to work.\n";
+
+static char *mousesystemscomment_text =
+"You have selected a Mouse Systems protocol mouse. If your mouse is normally\n"
+"in Microsoft-compatible mode, enabling the ClearDTR and ClearRTS options\n"
+"may cause it to switch to Mouse Systems mode when the server starts.\n";
+
+static char *logitechmousecomment_text =
+"You have selected a Logitech protocol mouse. This is only valid for old\n"
+"Logitech mice.\n";
+
+static char *mousemancomment_text =
+"You have selected a Logitech MouseMan type mouse. You might want to enable\n"
+"ChordMiddle which could cause the third button to work.\n";
+
+#endif /* !__UNIXOS2__ */
+
+static void 
+mouse_configuration(void) {
+
+#if !defined(__UNIXOS2__) && !defined(QNX4)
+	int i, j;
+	char s[80];
+	char *def_mousedev = DEF_MOUSEDEV;
+
+#define MOUSETYPE_COUNT sizeof(mouse_info)/sizeof(mouse_info[0])
+	for (i = 0; i < MOUSETYPE_COUNT; i++)
+		*(mouse_info[i].ident) = i;
+
+	for (i=0;;) {
+		emptylines();
+		printf("%s", mouseintro_text);
+		for (j = i; j < i + 14 && j < MOUSETYPE_COUNT; j++)
+			printf("%2d.  %s [%s]\n", j + 1,
+			       mouse_info[j].name, mouse_info[j].desc);
+		printf("\n");
+		printf("%s", mousecomment_text);
+		printf("Enter a protocol number: ");
+		getstring(s);
+		if (strlen(s) == 0) {
+			i += 14;
+			if (i >= MOUSETYPE_COUNT)
+				i = 0;
+			continue;
+		}
+		config_mousetype = atoi(s) - 1;
+		if (config_mousetype >= 0 && config_mousetype < MOUSETYPE_COUNT)
+			break;
+	}
+	printf("\n");
+
+	if (config_mousetype == M_LOGITECH) {
+		/* Logitech. */
+		printf("%s", logitechmousecomment_text);
+		printf("\n");
+		printf("Please answer the following question with either 'y' or 'n'.\n");
+		printf("Are you sure it's really not a Microsoft compatible one? ");
+		getstring(s);
+		if (!answerisyes(s))
+			config_mousetype = M_MICROSOFT;
+		printf("\n");
+	}
+
+	config_chordmiddle = 0;
+	if (config_mousetype == M_MICROSOFT || config_mousetype == M_MOUSEMAN) {
+		/* Microsoft or MouseMan. */
+		if (config_mousetype == M_MICROSOFT)
+			printf("%s", microsoftmousecomment_text);
+		else
+			printf("%s", mousemancomment_text);
+		printf("\n");
+		printf("Please answer the following question with either 'y' or 'n'.\n");
+		printf("Do you want to enable ChordMiddle? ");
+		getstring(s);
+		if (answerisyes(s))
+			config_chordmiddle = 1;
+		printf("\n");
+	}
+
+	config_cleardtrrts = 0;
+	if (config_mousetype == M_MOUSESYSTEMS) {
+		/* Mouse Systems. */
+		printf("%s", mousesystemscomment_text);
+		printf("\n");
+		printf("Please answer the following question with either 'y' or 'n'.\n");
+		printf("Do you want to enable ClearDTR and ClearRTS? ");
+		getstring(s);
+		if (answerisyes(s))
+			config_cleardtrrts = 1;
+		printf("\n");
+	}
+
+	if (config_mousetype == M_MICROSOFT) {
+		if (config_chordmiddle)
+			printf("%s", threebuttonmousecomment_text);
+		else
+			printf("%s", twobuttonmousecomment_text);
+	}
+	else if (config_mousetype == M_MOUSESYSTEMS ||
+		 config_mousetype == M_INTELLIMOUSE) {
+		printf("%s", threebuttonmousecomment_text);
+	}
+	else {
+		printf("%s", unknownbuttonsmousecomment_text);
+	}
+
+	printf("\n");
+
+	printf("Please answer the following question with either 'y' or 'n'.\n");
+	printf("Do you want to enable Emulate3Buttons? ");
+	getstring(s);
+	if (answerisyes(s))
+		config_emulate3buttons = 1;
+	else
+		config_emulate3buttons = 0;
+	printf("\n");
+
+#if (defined(sun) && (defined(__i386) || defined(__x86)))
+	/* SPARC & USB mice (VUID or AUTO protocols) default to /dev/mouse, 
+	   but PS/2 mice default to /dev/kdmouse */
+	if ((config_mousetype != M_AUTO) && (config_mousetype != M_VUID)) {
+	    def_mousedev = "/dev/kdmouse";
+	}
+#endif
+
+	printf(mousedev_text, def_mousedev);
+	printf("Mouse device: ");
+	getstring(s);
+	if (strlen(s) == 0) {
+		config_pointerdevice = def_mousedev;
+	} else {
+		config_pointerdevice = Malloc(strlen(s) + 1);
+		strcpy(config_pointerdevice, s);
+	}
+	printf("\n");
+
+#else /* __UNIXOS2__ */
+       	/* set some reasonable defaults for OS/2 */
+       	config_mousetype = M_OSMOUSE;
+	config_chordmiddle = 0;       
+	config_cleardtrrts = 0;
+	config_emulate3buttons = 0;
+#if !defined(QNX4)
+	config_pointerdevice = "OS2MOUSE";
+#else
+	config_pointerdevice = "QNXMOUSE";
+#endif
+#endif /* __UNIXOS2__ */
+}
+
+
+/*
+ * Keyboard configuration.
+ */
+
+/*
+ * Configuration of XKB 
+ */
+static char *xkbmodeltext = 
+"Please select one of the following keyboard types that is the better\n"
+"description of your keyboard. If nothing really matches,\n"
+"choose \"Generic 104-key PC\"\n\n";
+
+static char *xkblayouttext = 
+"Please select the layout corresponding to your keyboard\n";
+
+static char *xkbvarianttext =
+"Please enter a variant name for '%s' layout. Or just press enter\n"
+"for default variant\n\n";
+
+static char *xkboptionstext = 
+"Please answer the following question with either 'y' or 'n'.\n"
+"Do you want to select additional XKB options (group switcher,\n"
+"group indicator, etc.)? ";
+
+#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+static char *kbdevtext =
+"Please enter the device name for your keyboard or just press enter\n"
+"for the default of wskbd0\n\n";
+#endif
+
+static void 
+keyboard_configuration(void)
+{
+	int i, j;
+	char s[80];
+        char *rulesfile;
+	int number, options[MAX_XKBOPTIONS], num_options;
+        XkbRF_RulesPtr rules;
+
+#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+	printf(kbdevtext);
+	getstring(s);
+	if (strlen(s) != 0) {
+	    config_keyboard_dev = Malloc(strlen(s) + 1);
+	    strcpy(config_keyboard_dev, s);
+	}
+#endif
+
+#ifndef XKB_RULES_DIR
+# define XKB_RULES_DIR XKB_BASE_DIRECTORY "/rules"
+#endif
+	
+#ifdef XFREE98_XKB
+	config_xkbrules = "xfree98";	/* static */
+        rulesfile = XKB_RULES_DIR "/xfree98";
+#else
+	config_xkbrules = __XKBDEFRULES__;	/* static */
+        rulesfile = XKB_RULES_DIR "/" __XKBDEFRULES__;
+#endif
+
+        rules = XkbRF_Load(rulesfile, "", True, False);
+	emptylines();
+
+        if (!rules) {
+            printf("XKB rules file '%s' not found\n", rulesfile);
+            printf("Keyboard XKB options will be set to default values.\n");
+            keypress();
+            return;
+        }
+
+	number = -1;
+	for (i=0;;) {
+		emptylines();
+		printf(xkbmodeltext);
+		for (j = i; j < i + 16 && j < rules->models.num_desc; j++)
+		    printf("%3d  %-50s\n", j+1, rules->models.desc[j].desc);
+		printf("\nEnter a number to choose the keyboard.\n\n");
+		if (rules->models.num_desc >= 16)
+			printf("Press enter for the next page\n");
+		getstring(s);
+		if (strlen(s) == 0) {
+			i += 16;
+			if (i > rules->models.num_desc)
+				i = 0;
+			continue;
+		}
+		number = atoi(s) - 1;
+		if (number >= 0 && number < rules->models.num_desc)
+			break;
+	}
+
+	i = strlen(rules->models.desc[number].name) + 1;
+	config_xkbmodel = Malloc(i);
+	sprintf(config_xkbmodel,"%s", rules->models.desc[number].name);
+
+	emptylines();
+	printf(xkblayouttext);
+
+	number = -1;
+	for (i=0;;) {
+	    	emptylines();
+		for (j = i; j < i + 18 && j < rules->layouts.num_desc; j++)
+			printf("%3d  %-50s\n", j+1,
+				rules->layouts.desc[j].desc);
+		printf("\n");
+		printf("Enter a number to choose the country.\n");
+		if (rules->layouts.num_desc >= 18)
+			printf("Press enter for the next page\n");
+		printf("\n");
+		getstring(s);
+		if (strlen(s) == 0) {
+			i += 18;
+			if (i > rules->layouts.num_desc)
+				i = 0;
+			continue;
+		}
+		number = atoi(s) - 1;
+		if (number >= 0 && number < rules->layouts.num_desc)
+			break;
+	}
+	config_xkblayout = Malloc(strlen(rules->layouts.desc[number].name)+1);
+	sprintf(config_xkblayout,"%s", rules->layouts.desc[number].name);
+
+	emptylines();
+	printf(xkbvarianttext, config_xkblayout);
+	getstring(s);
+	if (strlen(s) != 0) {
+	    config_xkbvariant = Malloc(strlen(s) + 1);
+	    strcpy(config_xkbvariant, s);
+        }
+
+	emptylines();
+	printf(xkboptionstext);
+	getstring(s);
+	if (!answerisyes(s))
+            return;
+
+        num_options = 0;
+        for (j=0,i=0;;) {
+            if (!strchr(rules->options.desc[i].name, ':')) {
+	        emptylines();
+                printf("   %s\n\n", rules->options.desc[i].desc);
+                j = i;
+            } else {
+                printf("%3d  %-50s\n", i - j, rules->options.desc[i].desc);
+            }
+            i++;
+            if ( i == rules->options.num_desc ||
+                 !strchr(rules->options.desc[i].name, ':')) {
+                printf("\nPlease select the option or just press enter if none\n");
+	        getstring(s);
+	        if (strlen(s) != 0) {
+	            number = atoi(s);
+                    if (number && (num_options < MAX_XKBOPTIONS)) {
+                        options[num_options++] = number + j;
+                    }
+                }    
+            }
+            if (i == rules->options.num_desc)
+                break;
+        }
+
+        if (!num_options)
+            return;
+
+        for (j=0,i=0; i<num_options; i++) {
+            j += strlen(rules->options.desc[options[i]].name);
+        }
+	config_xkboptions = Malloc(j + num_options);
+        for (j=0,i=0; i<num_options; i++) {
+	    j += sprintf(config_xkboptions+j,"%s%s",
+                    i == 0 ? "": "," ,rules->options.desc[options[i]].name);
+        }
+	return;
+}
+
+
+
+/*
+ * Monitor configuration.
+ */
+
+static char *monitorintro_text =
+"Now we want to set the specifications of the monitor. The two critical\n"
+"parameters are the vertical refresh rate, which is the rate at which the\n"
+"the whole screen is refreshed, and most importantly the horizontal sync rate,\n"
+"which is the rate at which scanlines are displayed.\n"
+"\n"
+"The valid range for horizontal sync and vertical sync should be documented\n"
+"in the manual of your monitor.\n"
+"\n";
+
+static char *hsyncintro_text =
+"You must indicate the horizontal sync range of your monitor. You can either\n"
+"select one of the predefined ranges below that correspond to industry-\n"
+"standard monitor types, or give a specific range.\n"
+"\n"
+"It is VERY IMPORTANT that you do not specify a monitor type with a horizontal\n"
+"sync range that is beyond the capabilities of your monitor. If in doubt,\n"
+"choose a conservative setting.\n"
+"\n";
+
+static char *customhsync_text =
+"Please enter the horizontal sync range of your monitor, in the format used\n"
+"in the table of monitor types above. You can either specify one or more\n"
+"continuous ranges (e.g. 15-25, 30-50), or one or more fixed sync frequencies.\n"
+"\n";
+
+static char *vsyncintro_text =
+"You must indicate the vertical sync range of your monitor. You can either\n"
+"select one of the predefined ranges below that correspond to industry-\n"
+"standard monitor types, or give a specific range. For interlaced modes,\n"
+"the number that counts is the high one (e.g. 87 Hz rather than 43 Hz).\n"
+"\n"
+" 1  50-70\n"
+" 2  50-90\n"
+" 3  50-100\n"
+" 4  40-150\n"
+" 5  Enter your own vertical sync range\n";
+
+static char *monitordescintro_text =
+"You must now enter a few identification/description strings, namely an\n"
+"identifier, a vendor name, and a model name. Just pressing enter will fill\n"
+"in default names.\n"
+"\n";
+
+#define NU_MONITORTYPES 10
+
+static char *monitortype_range[NU_MONITORTYPES] = {
+	"31.5",
+	"31.5 - 35.1",
+	"31.5, 35.5",
+	"31.5, 35.15, 35.5",
+	"31.5 - 37.9",
+	"31.5 - 48.5",
+	"31.5 - 57.0",
+	"31.5 - 64.3",
+	"31.5 - 79.0",
+	"31.5 - 82.0"
+};
+
+static char *monitortype_name[NU_MONITORTYPES] = {
+	"Standard VGA, 640x480 @ 60 Hz",
+	"Super VGA, 800x600 @ 56 Hz",
+	"8514 Compatible, 1024x768 @ 87 Hz interlaced (no 800x600)",
+	"Super VGA, 1024x768 @ 87 Hz interlaced, 800x600 @ 56 Hz",
+	"Extended Super VGA, 800x600 @ 60 Hz, 640x480 @ 72 Hz",
+	"Non-Interlaced SVGA, 1024x768 @ 60 Hz, 800x600 @ 72 Hz",
+	"High Frequency SVGA, 1024x768 @ 70 Hz",
+	"Monitor that can do 1280x1024 @ 60 Hz",
+	"Monitor that can do 1280x1024 @ 74 Hz",
+	"Monitor that can do 1280x1024 @ 76 Hz"
+};
+
+static void 
+monitor_configuration(void) {
+	int i;
+	char s[80];
+	printf("%s", monitorintro_text);
+
+	keypress();
+	emptylines();
+
+	printf("%s", hsyncintro_text);
+
+	printf("    hsync in kHz; monitor type with characteristic modes\n");
+	for (i = 0; i < NU_MONITORTYPES; i++)
+		printf("%2d  %s; %s\n", i + 1, monitortype_range[i],
+			monitortype_name[i]);
+
+	printf("%2d  Enter your own horizontal sync range\n",
+		NU_MONITORTYPES + 1);
+	printf("\n");
+
+	printf("Enter your choice (1-%d): ", NU_MONITORTYPES + 1);
+	getstring(s);
+	config_monitortype = atoi(s) - 1;
+	if (config_monitortype < 0)
+		config_monitortype = 0;
+
+	printf("\n");
+
+	if (config_monitortype < NU_MONITORTYPES)
+		config_hsyncrange = monitortype_range[config_monitortype];
+	else {
+		/* Custom hsync range option selected. */
+		printf("%s", customhsync_text);
+		printf("Horizontal sync range: ");
+		getstring(s);
+		config_hsyncrange = Malloc(strlen(s) + 1);
+		strcpy(config_hsyncrange, s);
+		printf("\n");
+	}
+
+	printf("%s", vsyncintro_text);
+	printf("\n");
+
+	printf("Enter your choice: ");
+	getstring(s);
+	printf("\n");
+	switch (atoi(s)) {
+	case 0 :
+	case 1 :
+		config_vsyncrange = "50-70";
+		break;
+	case 2 :
+		config_vsyncrange = "50-90";
+		break;
+	case 3 :
+		config_vsyncrange = "50-100";
+		break;
+	case 4 :
+		config_vsyncrange = "40-150";
+		break;
+	case 5 :
+		/* Custom vsync range option selected. */
+		printf("Vertical sync range: ");
+		getstring(s);
+		config_vsyncrange = Malloc(strlen(s) + 1);
+		strcpy(config_vsyncrange, s);
+		printf("\n");
+		break;
+	}
+	printf("%s", monitordescintro_text);
+	printf("The strings are free-form, spaces are allowed.\n");
+	printf("Enter an identifier for your monitor definition: ");
+	getstring(s);
+	if (strlen(s) == 0)
+		config_monitoridentifier = "My Monitor";
+	else {
+		config_monitoridentifier = Malloc(strlen(s) + 1);
+		strcpy(config_monitoridentifier, s);
+	}
+}
+
+
+/*
+ * Card database.
+ */
+
+static char *cardintro_text =
+"Now we must configure video card specific settings. At this point you can\n"
+"choose to make a selection out of a database of video card definitions.\n"
+"Because there can be variation in Ramdacs and clock generators even\n"
+"between cards of the same model, it is not sensible to blindly copy\n"
+"the settings (e.g. a Device section). For this reason, after you make a\n"
+"selection, you will still be asked about the components of the card, with\n"
+"the settings from the chosen database entry presented as a strong hint.\n"
+"\n"
+"The database entries include information about the chipset, what driver to\n"
+"run, the Ramdac and ClockChip, and comments that will be included in the\n"
+"Device section. However, a lot of definitions only hint about what driver\n"
+"to run (based on the chipset the card uses) and are untested.\n"
+"\n"
+"If you can't find your card in the database, there's nothing to worry about.\n"
+"You should only choose a database entry that is exactly the same model as\n"
+"your card; choosing one that looks similar is just a bad idea (e.g. a\n"
+"GemStone Snail 64 may be as different from a GemStone Snail 64+ in terms of\n"
+"hardware as can be).\n"
+"\n";
+
+static char *cardunsupported_text =
+"This card is basically UNSUPPORTED. It may only work as a generic\n"
+"VGA-compatible card. If you have an "__XSERVERNAME__" version more recent than what\n"
+"this card definition was based on, there's a chance that it is now\n"
+"supported.\n";
+
+static void 
+carddb_configuration(void) {
+	int i;
+	char s[80];
+	card_selected = -1;
+	printf("%s", cardintro_text);
+	printf("Do you want to look at the card database? ");
+	getstring(s);
+	printf("\n");
+	if (!answerisyes(s))
+		return;
+
+	/*
+	 * Choose a database entry.
+	 */
+	if (parse_database()) {
+		printf("Couldn't read card database file %s.\n",
+			CARD_DATABASE_FILE);
+		keypress();
+		return;
+	}
+
+	i = 0;
+	for (;;) {
+		int j;
+		emptylines();
+		for (j = i; j < i + 18 && j <= lastcard; j++) {
+			char *name = card[j].name,
+			     *chipset = card[j].chipset;
+
+			printf("%3d  %-50s%s\n", j,
+				name ? name : "-",
+				chipset ? chipset : "-");
+		}
+		printf("\n");
+		printf("Enter a number to choose the corresponding card definition.\n");
+		printf("Press enter for the next page, q to continue configuration.\n");
+		printf("\n");
+		getstring(s);
+		if (s[0] == 'q')
+			break;
+		if (strlen(s) == 0) {
+			i += 18;
+			if (i > lastcard)
+				i = 0;
+			continue;
+		}
+		card_selected = atoi(s);
+		if (card_selected >= 0 && card_selected <= lastcard)
+			break;
+	}
+
+	/*
+	 * Look at the selected card.
+	 */
+	if (card_selected != -1) {
+		char *name = card[card_selected].name,
+		     *chipset = card[card_selected].chipset;
+
+		printf("\nYour selected card definition:\n\n");
+		printf("Identifier: %s\n", name ? name : "-");
+		printf("Chipset:    %s\n", chipset ? chipset : "-");
+		if (!card[card_selected].driver)
+			card[card_selected].driver = "unknown";
+		printf("Driver:     %s\n", card[card_selected].driver);
+
+		if (card[card_selected].ramdac != NULL)
+			printf("Ramdac:     %s\n", card[card_selected].ramdac);
+		if (card[card_selected].dacspeed != NULL)
+			printf("DacSpeed:     %s\n", card[card_selected].dacspeed);
+		if (card[card_selected].clockchip != NULL)
+			printf("Clockchip:  %s\n", card[card_selected].clockchip);
+		if (card[card_selected].flags & NOCLOCKPROBE)
+			printf("Do NOT probe clocks or use any Clocks line.\n");
+		if (card[card_selected].flags & UNSUPPORTED)
+			printf("%s", cardunsupported_text);
+#if 0	/* Might be confusing. */
+		if (strlen(card[card_selected].lines) > 0)
+			printf("Device section text:\n%s",
+				card[card_selected].lines);
+#endif
+		printf("\n");
+		keypress();
+	}
+}
+
+
+/*
+ * Screen/video card configuration.
+ */
+
+static char *deviceintro_text =
+"Now you must give information about your video card. This will be used for\n"
+"the \"Device\" section of your video card in " CONFIGNAME ".\n"
+"\n";
+
+static char *videomemoryintro_text =
+"It is probably a good idea to use the same approximate amount as that detected\n"
+"by the server you intend to use. If you encounter problems that are due to the\n"
+"used server not supporting the amount memory you have, specify the maximum\n"
+"amount supported by the server.\n"
+"\n"
+"How much video memory do you have on your video card:\n"
+"\n";
+
+static char *carddescintro_text =
+"You must now enter a few identification/description strings, namely an\n"
+"identifier, a vendor name, and a model name. Just pressing enter will fill\n"
+"in default names (possibly from a card definition).\n"
+"\n";
+
+#if 0
+static char *devicesettingscomment_text =
+"Especially for accelerated drivers, Ramdac, Dacspeed and ClockChip settings\n"
+"or special options may be required in the Device section.\n"
+"\n";
+
+static char *ramdaccomment_text =
+"The RAMDAC setting only applies to some drivers. Some RAMDAC's are\n"
+"auto-detected by the server. The detection of a RAMDAC is forced by using a\n"
+"Ramdac \"identifier\" line in the Device section. The identifiers are shown\n"
+"at the right of the following table of RAMDAC types:\n"
+"\n";
+
+#define NU_RAMDACS 24
+
+static char *ramdac_name[NU_RAMDACS] = {
+	"AT&T 20C490 (S3 and AGX servers, ARK driver)",
+	"AT&T 20C498/21C498/22C498 (S3, autodetected)",
+	"AT&T 20C409/20C499 (S3, autodetected)",
+	"AT&T 20C505 (S3)",
+	"BrookTree BT481 (AGX)",
+	"BrookTree BT482 (AGX)",
+	"BrookTree BT485/9485 (S3)",
+	"Sierra SC15025 (S3, AGX)",
+#if XFREE86_VERSION >= 311	
+	"S3 GenDAC (86C708) (autodetected)",
+	"S3 SDAC (86C716) (autodetected)",
+#else
+	"S3 GenDAC (86C708)",
+	"S3 SDAC (86C716)",
+#endif
+	"STG-1700 (S3, autodetected)",
+	"STG-1703 (S3, autodetected)",
+	"TI 3020 (S3, autodetected)",
+	"TI 3025 (S3, autodetected)",
+	"TI 3026 (S3, autodetected)",
+	"IBM RGB 514 (S3, autodetected)",
+	"IBM RGB 524 (S3, autodetected)",
+	"IBM RGB 525 (S3, autodetected)",
+	"IBM RGB 526 (S3)",
+	"IBM RGB 528 (S3, autodetected)",
+	"ICS5342 (S3, ARK)",
+	"ICS5341 (W32)",
+	"IC Works w30C516 ZoomDac (ARK)",
+	"Normal DAC"
+};
+
+static char *ramdac_id[NU_RAMDACS] = {
+	"att20c490", "att20c498", "att20c409", "att20c505", "bt481", "bt482",
+	"bt485", "sc15025", "s3gendac", "s3_sdac", "stg1700","stg1703",
+	"ti3020", "ti3025", "ti3026", "ibm_rgb514", "ibm_rgb524",
+	"ibm_rgb525", "ibm_rgb526", "ibm_rgb528", "ics5342", "ics5341",
+	"zoomdac", "normal"
+};
+
+static char *clockchipcomment_text =
+"A Clockchip line in the Device section forces the detection of a\n"
+"programmable clock device. With a clockchip enabled, any required\n"
+"clock can be programmed without requiring probing of clocks or a\n"
+"Clocks line. Most cards don't have a programmable clock chip.\n"
+"Choose from the following list:\n"
+"\n";
+
+#define NU_CLOCKCHIPS 12
+
+static char *clockchip_name[] = {
+	"Chrontel 8391",
+	"ICD2061A and compatibles (ICS9161A, DCS2824)",
+	"ICS2595",
+	"ICS5342 (similar to SDAC, but not completely compatible)",
+	"ICS5341",
+	"S3 GenDAC (86C708) and ICS5300 (autodetected)",
+	"S3 SDAC (86C716)",
+	"STG 1703 (autodetected)",
+	"Sierra SC11412",
+	"TI 3025 (autodetected)",
+	"TI 3026 (autodetected)",
+	"IBM RGB 51x/52x (autodetected)",
+};
+
+static char *clockchip_id[] = {
+	"ch8391", "icd2061a", "ics2595", "ics5342", "ics5341",
+	"s3gendac", "s3_sdac",
+	"stg1703", "sc11412", "ti3025", "ti3026", "ibm_rgb5xx",
+};
+
+static char *deviceclockscomment_text =
+"For most modern configurations, a Clocks line is neither required or\n"
+"desirable.  However for some older hardware it can be useful since it\n"
+"prevents the slow and nasty sounding clock probing at server start-up.\n"
+"Probed clocks are displayed at server startup, along with other server\n"
+"and hardware configuration info. You can save this information in a file\n"
+"by running 'X -probeonly 2>output_file'. Be warned that clock probing is\n"
+"inherently imprecise; some clocks may be slightly too high (varies per run).\n"
+"\n";
+
+static char *deviceclocksquestion_text =
+"At this point I can run X -probeonly, and try to extract the clock information\n"
+"from the output. It is recommended that you do this yourself and if a set of\n"
+"clocks is shown then you add a clocks line (note that the list of clocks may\n"
+"be split over multiple Clocks lines) to your Device section afterwards. Be\n"
+"aware that a clocks line is not appropriate for most modern hardware that\n"
+"has programmable clocks.\n"
+"\n"
+"You must be root to be able to run X -probeonly now.\n"
+"\n";
+
+static char *probeonlywarning_text =
+"It is possible that the hardware detection routines in the server will somehow\n"
+"cause the system to crash and the screen to remain blank. If this is the\n"
+"case, do not choose this option the next time. The server may need a\n"
+"Ramdac, ClockChip or special option (e.g. \"nolinear\" for S3) to probe\n"
+"and start-up correctly.\n"
+"\n";
+#endif
+
+static char *modesorderintro_text =
+"For each depth, a list of modes (resolutions) is defined. The default\n"
+"resolution that the server will start-up with will be the first listed\n"
+"mode that can be supported by the monitor and card.\n"
+"Currently it is set to:\n"
+"\n";
+
+static char *modesorder_text2 =
+"Modes that cannot be supported due to monitor or clock constraints will\n"
+"be automatically skipped by the server.\n"
+"\n"
+" 1  Change the modes for 8-bit (256 colors)\n"
+" 2  Change the modes for 16-bit (32K/64K colors)\n"
+" 3  Change the modes for 24-bit (24-bit color)\n"
+" 4  The modes are OK, continue.\n"
+"\n";
+
+static char *modeslist_text =
+"Please type the digits corresponding to the modes that you want to select.\n"
+"For example, 432 selects \"1024x768\" \"800x600\" \"640x480\", with a\n"
+"default mode of 1024x768.\n"
+"\n";
+
+static char *virtual_text =
+"You can have a virtual screen (desktop), which is screen area that is larger\n"
+"than the physical screen and which is panned by moving the mouse to the edge\n"
+"of the screen. If you don't want virtual desktop at a certain resolution,\n"
+"you cannot have modes listed that are larger. Each color depth can have a\n"
+"differently-sized virtual screen\n"
+"\n";
+
+static int videomemory[] = {
+	256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144
+};
+
+/* Is this required? */
+#if XFREE86_VERSION >= 400
+#define NU_MODESTRINGS 13
+#else
+#if XFREE86_VERSION >= 330
+#define NU_MODESTRINGS 12
+#else
+#if XFREE86_VERSION >= 311
+#define NU_MODESTRINGS 8
+#else
+#define NU_MODESTRINGS 5
+#endif
+#endif
+#endif
+
+static char *modestring[NU_MODESTRINGS] = {
+	"\"640x400\"",
+	"\"640x480\"",
+	"\"800x600\"",
+	"\"1024x768\"",
+	"\"1280x1024\"",
+#if XFREE86_VERSION >= 311
+	"\"320x200\"",
+	"\"320x240\"",
+	"\"400x300\""
+#endif
+#if XFREE86_VERSION >= 330
+	,"\"1152x864\"",
+	"\"1600x1200\"",
+	"\"1800x1400\"",
+	"\"512x384\""
+#endif
+#if XFREE86_VERSION >= 400
+	,"\"1400x1050\""
+#endif
+};
+
+#ifdef __EMX__
+/* yet another instance of this code, sigh! */
+char *
+__XOS2RedirRoot(char *path, char sep)
+{
+	static char pn[300];
+	char *root;
+	int i,l;
+	if ((isalpha(path[0]) && path[1]==':') || path[0] != '/')
+		return path;
+
+	root = getenv("X11ROOT");
+	if (!root) root = "";
+	sprintf(pn,"%s%s",root,path);
+	if (sep=='\\') {
+		l = strlen(pn);
+		for (i=0; i<l; i++) 
+			if (pn[i]=='/') pn[i]='\\';
+	}
+	return pn;
+}
+#endif
+
+/* (hv) to avoid the UNIXISM to try to open a dir to check for existance */
+static int exists_dir(char *name) {
+	struct stat sbuf;
+
+#ifdef __EMX__
+	name = __XOS2RedirRoot(name,'/');
+#endif
+	/* is it there ? */
+	if (stat(name,&sbuf) == -1)
+		return 0;
+
+	/* is there, but is it a dir? */
+	return S_ISDIR(sbuf.st_mode) ? 1 : 0;
+}
+
+static int 
+screen_configuration(void) {
+	int i, c/*, np*/;
+	char s[80];
+
+	/*
+	 * Configure the "Device" section for the video card.
+	 */
+
+	printf("%s", deviceintro_text);
+
+	printf("%s", videomemoryintro_text);
+
+	for (i = 0; i < sizeof(videomemory) / sizeof(videomemory[0]); i++)
+		printf("%2d  %dK\n", i + 1, videomemory[i]);
+	printf("%2d  Other\n\n", i + 1);
+
+	printf("Enter your choice: ");
+	getstring(s);
+	printf("\n");
+
+	c = atoi(s) - 1;
+	if (c >= 0 && c < sizeof(videomemory) / sizeof(videomemory[0]))
+		config_videomemory = videomemory[c];
+	else {
+		printf("Amount of video memory in Kbytes: ");
+		getstring(s);
+		config_videomemory = atoi(s);
+		printf("\n");
+	}
+
+	printf("%s", carddescintro_text);
+	if (card_selected != -1)
+		printf("Your card definition is %s.\n\n",
+			card[card_selected].name);
+	printf("The strings are free-form, spaces are allowed.\n");
+	printf("Enter an identifier for your video card definition: ");
+	getstring(s);
+	if (strlen(s) == 0)
+		if (card_selected != -1)
+			config_deviceidentifier = card[card_selected].name;
+		else
+			config_deviceidentifier = "My Video Card";
+	else {
+		config_deviceidentifier = Malloc(strlen(s) + 1);
+		strcpy(config_deviceidentifier, s);
+	}
+	printf("\n");
+
+	emptylines();
+
+	/*
+	 * Initialize screen mode variables for svga and accel
+	 * to default values.
+	 * XXXX Doesn't leave room for off-screen caching in 16/32bpp modes
+	 *      for the accelerated servers in some situations.
+	 */
+	config_modesline8bpp =
+	config_modesline16bpp =
+	config_modesline24bpp = "\"640x480\"";
+	config_virtualx8bpp = config_virtualx16bpp = config_virtualx24bpp =
+	config_virtualy8bpp = config_virtualy16bpp = config_virtualy24bpp = 0;
+	if (config_videomemory >= 4096) {
+		config_virtualx8bpp = 1600;
+		config_virtualy8bpp = 1280;
+		if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) {
+			/*
+			 * Allow room for font/pixmap cache for accel
+			 * servers.
+			 */
+			config_virtualx16bpp = 1280;
+			config_virtualy16bpp = 1024;
+		}
+		else {
+			config_virtualx16bpp = 1600;
+			config_virtualy16bpp = 1280;
+		}
+		if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) {
+			config_virtualx24bpp = 1152;
+			config_virtualy24bpp = 900;
+		}
+		else {
+			config_virtualx24bpp = 1280;
+			config_virtualy24bpp = 1024;
+		}
+		/* Add 1600x1280 */
+		config_modesline8bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\"";
+		config_modesline16bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\"";
+		config_modesline24bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\"";
+
+	}
+	else
+	if (config_videomemory >= 2048) {
+		if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) {
+			/*
+			 * Allow room for font/pixmap cache for accel
+			 * servers.
+			 * Also the mach32 is has a limited width.
+			 */
+			config_virtualx8bpp = 1280;
+			config_virtualy8bpp = 1024;
+		}
+		else {
+			config_virtualx8bpp = 1600;
+			config_virtualy8bpp = 1200;
+		}
+		if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) {
+			config_virtualx16bpp = 1024;
+			config_virtualy16bpp = 768;
+		}
+		else {
+			config_virtualx16bpp = 1152;
+			config_virtualy16bpp = 900;
+		}
+		config_virtualx24bpp = 800;
+		config_virtualy24bpp = 600;
+		if (config_videomemory >= 2048 + 256) {
+			config_virtualx24bpp = 1024;
+			config_virtualy24bpp = 768;
+		}
+		config_modesline8bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\"";
+		config_modesline16bpp = "\"1024x768\" \"800x600\" \"640x480\"";
+		if (config_videomemory >= 2048 + 256)
+			config_modesline24bpp = "\"1024x768\" \"800x600\" \"640x480\"";
+		else
+			config_modesline24bpp = "\"800x600\" \"640x480\"";
+	}
+	else
+	if (config_videomemory >= 1024) {
+		if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) {
+			/*
+			 * Allow room for font/pixmap cache for accel
+			 * servers.
+			 */
+			config_virtualx8bpp = 1024;
+			config_virtualy8bpp = 768;
+		}
+		else {
+			config_virtualx8bpp = 1152;
+			config_virtualy8bpp = 900;
+		}
+		config_virtualx16bpp = 800; /* Forget about cache space;  */
+		config_virtualy16bpp = 600; /* it's small enough as it is. */
+		config_virtualx24bpp = 640;
+		config_virtualy24bpp = 480;
+		config_modesline8bpp = "\"1024x768\" \"800x600\" \"640x480\"";
+		config_modesline16bpp = "\"800x600\" \"640x480\"";
+		config_modesline24bpp = "\"640x480\"";
+	}
+	else
+	if (config_videomemory >= 512) {
+		config_virtualx8bpp = 800;
+		config_virtualy8bpp = 600;
+		config_modesline8bpp = "\"800x600\" \"640x480\"";
+		config_modesline16bpp = "\"640x400\"";
+	}
+	else
+	if (config_videomemory >= 256) {
+		config_modesline8bpp = "\"640x400\"";
+		config_virtualx8bpp = 640;
+		config_virtualy8bpp = 400;
+	}
+	else {
+		printf("Invalid amount of video memory. Please try again\n");
+		return(1);
+	}
+
+#if 0
+	/*
+	 * Handle the Ramdac/Clockchip setting.
+	 */
+
+	printf("%s", devicesettingscomment_text);
+
+	if (card_selected == -1 || (card[card_selected].flags & UNSUPPORTED))
+		goto skipramdacselection;
+
+	printf("%s", ramdaccomment_text);
+
+	/* meanwhile there are so many RAMDACs that they do no longer fit on
+	 * on page
+	 */
+	for (np=12, i=0 ;;) {
+		int j;
+		for (j = i; j < i + np && j < NU_RAMDACS; j++)
+			printf("%3d  %-60s%s\n", j+1,
+				ramdac_name[j],
+				ramdac_id[j]);
+
+		printf("\n");
+		if (card_selected != -1)
+			if (card[card_selected].ramdac != NULL)
+				printf("The card definition has Ramdac \"%s\".\n\n",
+					card[card_selected].ramdac);
+		printf("\n");
+		printf("Enter a number to choose the corresponding RAMDAC.\n");
+		printf("Press enter for the next page, q to quit without selection of a RAMDAC.\n");
+		printf("\n");
+		getstring(s);
+
+		config_ramdac = NULL;
+		if (s[0] == 'q')
+			break;
+
+		if (strlen(s) > 0) {
+			c = atoi(s)-1;
+			if (c >= 0 && c < NU_RAMDACS) {
+				config_ramdac = ramdac_id[atoi(s)-1];
+				break;
+			}
+		}
+		
+		i += np;
+		if (np==12) np = 18; /* account intro lines only displayed 1st time */
+		if (i >= NU_RAMDACS)
+			i = 0;
+		emptylines();
+	}
+
+skipramdacselection:
+	emptylines();
+	printf("%s", clockchipcomment_text);
+
+	for (i = 0; i < NU_CLOCKCHIPS; i++)
+		printf("%2d  %-60s%s\n",
+			i + 1, clockchip_name[i], clockchip_id[i]);
+
+	printf("\n");
+
+	if (card_selected != -1)
+		if (card[card_selected].clockchip != NULL)
+			printf("The card definition has Clockchip \"%s\"\n\n",
+				card[card_selected].clockchip);
+
+	printf("Just press enter if you don't want a Clockchip setting.\n");
+	printf("What Clockchip setting do you want (1-%d)? ", NU_CLOCKCHIPS);
+
+	getstring(s);
+	config_clockchip = NULL;
+	if (strlen(s) > 0)
+		config_clockchip = clockchip_id[atoi(s) - 1];
+
+	emptylines();
+
+	/*
+	 * Optionally run X -probeonly to figure out the clocks.
+	 */
+
+	config_numberofclockslines = 0;
+
+	printf("%s", deviceclockscomment_text);
+
+	printf("%s", deviceclocksquestion_text);
+#endif
+
+#if 0
+	/*
+	 * XXX Change this to check for a CLOCKPROBE flag rather than an
+	 * NOCLOCKPROBE.
+	 */
+	if (card_selected != -1)
+		if (card[card_selected].flags & NOCLOCKPROBE)
+			printf("The card definition says to NOT probe clocks.\n");
+
+	if (config_clockchip != NULL) {
+		printf("Because you have enabled a Clockchip line, there's no need for clock\n"
+			"probing.\n");
+		keypress();
+		goto skipclockprobing;
+	}
+
+	printf("Do you want me to run 'X -probeonly' now? ");
+	getstring(s);
+	printf("\n");
+	if (answerisyes(s)) {
+		/*
+		 * Write temporary XF86Config and run X -probeonly.
+		 * Only allow when root.
+		 */
+		FILE *f;
+		char *buf;
+		char syscmdline[2*256+100]; /* enough */
+                char *fname = NULL;
+                char *d2name = NULL;
+                char *d3name = NULL;
+
+		if (getuid() != 0) {
+			printf("Sorry, you must be root to do this.\n\n");
+			goto endofprobeonly;
+		}
+		printf("%s", probeonlywarning_text);
+		keypress();
+		fname = Malloc(strlen(temp_dir) +
+                               strlen(TEMPORARY_XF86CONFIG_FILENAME) + 1);
+		sprintf(fname, "%s%s", temp_dir,
+                       TEMPORARY_XF86CONFIG_FILENAME);
+		d2name = Malloc(strlen(temp_dir) + strlen(DUMBCONFIG2) + 1);
+		sprintf(d2name, "%s%s", temp_dir, DUMBCONFIG2);
+		d3name = Malloc(strlen(temp_dir) + strlen(DUMBCONFIG3) + 1);
+		sprintf(d3name, "%s%s", temp_dir, DUMBCONFIG3);
+		printf("Running X -probeonly -pn -xf86config %s.\n", fname);
+		write_XF86Config(fname);
+#ifndef __EMX__
+		sync();
+#endif
+		/* compose a line with the real path */
+#ifndef __EMX__
+                sprintf(syscmdline, "X -probeonly -pn -xf86config %s 2> %s",
+                        fname, d2name);
+#else
+		/* OS/2 does not have symlinks, so "X" does not exist,
+		 * call the real X server
+		 */
+		sprintf(syscmdline,"%s/"__XSERVERNAME__" -probeonly -pn -xf86config "
+		       TEMPORARY_XF86CONFIG_FILENAME " 2>" DUMBCONFIG2,
+		       __XOS2RedirRoot("/"__XSERVERNAME__"/bin",'\\'),
+		       card[card_selected].server);
+#endif
+
+		if (system(syscmdline)) {
+			printf("X -probeonly call failed.\n");
+			printf("No Clocks line inserted.\n");
+			goto clocksprobefailed;
+		}
+		/* Look for 'clocks:' (case sensitive). */		
+                sprintf(syscmdline, "grep clocks\\: %s > %s", d2name, d3name);
+                if (system(syscmdline)) {
+			printf("grep failed.\n");
+			printf("Cannot find clocks in server output.\n");
+			goto clocksprobefailed;
+		}
+                f = fopen(d3name, "r");
+		buf = Malloc(8192);
+		/* Parse lines. */
+		while (fgets(buf, 8192, f) != NULL) {
+			char *clks;
+			clks = strstr(buf, "clocks: ") + 8;
+			if (clks >= buf + 3 && strcmp(clks - 11, "num") == 0)
+				/* Reject lines with 'numclocks:'. */
+				continue;
+			if (clks >= buf + 8 && strcpy(clks - 14, "pixel ") == 0)
+				/* Reject lines with 'pixel clocks:'. */
+				continue;
+			clks[strlen(clks) - 1] = '\0';	/* Remove '\n'. */
+			config_clocksline[config_numberofclockslines] =
+				Malloc(strlen(clks) + 1);
+			strcpy(config_clocksline[config_numberofclockslines],
+				clks);
+			printf("Clocks %s\n", clks);
+			config_numberofclockslines++;
+		}
+		fclose(f);
+clocksprobefailed:
+                unlink(d3name);
+                unlink(d2name);
+                unlink(fname);
+		printf("\n");
+
+endofprobeonly:
+		keypress();
+	}
+skipclockprobing:
+#endif
+
+	/*
+	 * For vga driver, no further configuration is required.
+	 */
+	if (card_selected == -1 || (card[card_selected].flags & UNSUPPORTED))
+		return (0);
+	
+	/*
+	 * Configure the modes order.
+	 */
+	config_virtual = 0;
+	for (;;) {
+	 	char modes[128];
+		int modes_space_left;
+
+		emptylines();
+
+		printf("%s", modesorderintro_text);
+		printf("%s for 8-bit\n", config_modesline8bpp);
+		printf("%s for 16-bit\n", config_modesline16bpp);
+		printf("%s for 24-bit\n", config_modesline24bpp);
+		printf("\n");
+		printf("%s", modesorder_text2);
+
+		printf("Enter your choice: ");
+		getstring(s);
+		printf("\n");
+
+		c = atoi(s) - 1;
+		if (c < 0 || c >= 3)
+			break;
+
+		printf("Select modes from the following list:\n\n");
+
+		for (i = 0; i < NU_MODESTRINGS; i++)
+                        printf(" %c  %s\n", i < 9 ? '1' + i :
+                                                    'a' + i - 9, 
+                                            modestring[i]);
+		printf("\n");
+
+		printf("%s", modeslist_text);
+
+		printf("Which modes? ");
+		getstring(s);
+		printf("\n");
+
+		modes[0] = '\0';
+		modes_space_left = sizeof(modes) - 1;
+		for (i = 0; i < strlen(s); i++) {
+			int choice = -1;
+			
+			if ((s[i] >= '1') && (s[i] <= '9')) {
+				choice = s[i] - '1';
+			} else if ((s[i] >= 'a') &&
+				   (s[i] <= ('a' + NU_MODESTRINGS - 10))) {
+				choice = s[i] - 'a' + 9;
+			} 
+			
+                        if ( (choice < 0) || (choice > NU_MODESTRINGS) ) {
+                                printf("Invalid mode %c skipped.\n", s[i]);
+                                continue;
+			}
+			if ((i > 0) && (modes_space_left > 1)) {
+				strcat(modes, " ");
+				modes_space_left--;
+			}
+			if (modes_space_left > strlen(modestring[choice])) {
+				modes_space_left -= strlen(modestring[choice]);
+				strcat(modes, modestring[choice]);
+			}
+		}
+		switch (c) {
+		case 0 :
+			config_modesline8bpp = Malloc(strlen(modes) + 1);
+			strcpy(config_modesline8bpp, modes);
+			break;
+		case 1 :
+			config_modesline16bpp = Malloc(strlen(modes) + 1);
+			strcpy(config_modesline16bpp, modes);
+			break;
+		case 2 :
+			config_modesline24bpp = Malloc(strlen(modes) + 1);
+			strcpy(config_modesline24bpp, modes);
+			break;
+		}
+
+		printf("%s", virtual_text);
+
+		printf("Please answer the following question with either 'y' or 'n'.\n");
+		printf("Do you want a virtual screen that is larger than the physical screen?");
+		getstring(s);
+		if (answerisyes(s))
+			config_virtual = 1;
+	}
+	return(0);
+}
+
+static char *defaultdepthtext = 
+"Please specify which color depth you want to use by default:\n"
+"\n";
+
+static struct depth_str {
+    char *name;
+    char *desc;
+} depth_list[] = {
+    { "1", "1 bit (monochrome)" },
+    { "4", "4 bits (16 colors)" },
+    { "8", "8 bits (256 colors)" },
+    { "16", "16 bits (65536 colors)" },
+    { "24", "24 bits (16 million colors)" }
+};
+
+static int ndepths = sizeof(depth_list)/sizeof(struct depth_str);
+
+static void
+depth_configuration(void)
+{
+	int i;
+	char s[80];
+	int depth;
+
+	printf(defaultdepthtext);
+	for (i=0; i<ndepths; i++) {
+	    printf("%3d  %-50s\n",i+1,depth_list[i].desc);
+	}
+	
+	printf("\nEnter a number to choose the default depth.\n\n");
+	getstring(s);
+	if (strlen(s) == 0)
+	    depth = 0;
+	else {
+	    i = atoi(s)-1;
+	    depth = (i < 0 || i > ndepths) ? 0 : i;
+	}
+	config_depth = depth_list[depth].name;
+}
+
+/*
+ * Create the XF86Config file.
+ */
+
+static char *XF86Config_firstchunk_text =
+"# File generated by xorgconfig.\n"
+"\n"
+"#\n"
+"# Copyright 2004 "XVENDORNAME"\n"
+"#\n"
+"# Permission is hereby granted, free of charge, to any person obtaining a\n"
+"# copy of this software and associated documentation files (the \"Software\"),\n"
+"# to deal in the Software without restriction, including without limitation\n"
+"# the rights to use, copy, modify, merge, publish, distribute, sublicense,\n"
+"# and/or sell copies of the Software, and to permit persons to whom the\n"
+"# Software is furnished to do so, subject to the following conditions:\n"
+"# \n"
+"# The above copyright notice and this permission notice shall be included in\n"
+"# all copies or substantial portions of the Software.\n"
+"# \n"
+"# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
+"# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
+"# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n"
+"# "XVENDORNAME" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n"
+"# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF\n"
+"# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n"
+"# SOFTWARE.\n"
+"# \n"
+"# Except as contained in this notice, the name of "XVENDORNAME" shall\n"
+"# not be used in advertising or otherwise to promote the sale, use or other\n"
+"# dealings in this Software without prior written authorization from\n"
+"# "XVENDORNAME".\n"
+"#\n"
+"\n"
+"# **********************************************************************\n"
+"# Refer to the " CONFIGNAME "(" FILEMANSUFFIX ") man page for details about the format of \n"
+"# this file.\n"
+"# **********************************************************************\n"
+"\n"
+"# **********************************************************************\n"
+"# Module section -- this  section  is used to specify\n"
+"# which dynamically loadable modules to load.\n"
+"# **********************************************************************\n"
+"#\n"
+"Section \"Module\"\n"
+"\n"
+"# This loads the DBE extension module.\n"
+"\n"
+"    Load        \"dbe\"  	# Double buffer extension\n"
+"\n"
+"# This loads the miscellaneous extensions module, and disables\n"
+"# initialisation of the XFree86-DGA extension within that module.\n"
+"    SubSection  \"extmod\"\n"
+"      Option    \"omit xfree86-dga\"   # don't initialise the DGA extension\n"
+"    EndSubSection\n"
+"\n"
+"# This loads the font modules\n"
+#ifdef SUNSOFT
+"    Load        \"bitstream\"\n"
+"    Load        \"type1\"\n"
+"#    Load        \"speedo\"\n"
+#else
+#ifdef HAS_TYPE1
+"    Load        \"type1\"\n"
+#else
+"#    Load        \"type1\"\n"
+#endif
+#ifdef HAS_SPEEDO
+"    Load        \"speedo\"\n"
+#else
+"#    Load        \"speedo\"\n"
+#endif
+"    Load        \"freetype\"\n"
+"#    Load        \"xtt\"\n"
+#endif
+"\n"
+#ifdef SUNSOFT
+"# This loads the SolarisIA module\n"
+"     Load       \"IA\"\n"
+"# This loads the GLX module\n"
+"     Load       \"glx\"\n"
+#else
+"# This loads the GLX module\n"
+"#    Load       \"glx\"\n"
+#endif
+"# This loads the DRI module\n"
+"#    Load       \"dri\"\n"
+"\n"
+"EndSection\n"
+"\n"
+"# **********************************************************************\n"
+"# Files section.  This allows default font and rgb paths to be set\n"
+"# **********************************************************************\n"
+"\n"
+"Section \"Files\"\n"
+"\n"
+"# The location of the RGB database.  Note, this is the name of the\n"
+"# file minus the extension (like \".txt\" or \".db\").  There is normally\n"
+"# no need to change the default.\n"
+"\n"
+"    RgbPath	\"" TREEROOTLX "/rgb\"\n"
+"\n"
+"# Multiple FontPath entries are allowed (which are concatenated together),\n"
+"# as well as specifying multiple comma-separated entries in one FontPath\n"
+"# command (or a combination of both methods)\n"
+"# \n"
+#if 0
+"# If you don't have a floating point coprocessor and emacs, Mosaic or other\n"
+"# programs take long to start up, try moving the Type1 and Speedo directory\n"
+"# to the end of this list (or comment them out).\n"
+#endif
+"# \n"
+"\n";
+
+static char *XF86Config_fontpaths[] = 
+{
+/*	"    FontPath	\"" TREEROOTFONT "/75dpi/\"\n"*/
+    "/local/",
+	"/misc/",
+	"/75dpi/:unscaled",
+	"/100dpi/:unscaled",
+	"/Speedo/",
+	"/Type1/",
+	"/TrueType/",
+	"/freefont/",
+	"/75dpi/",
+	"/100dpi/",
+	0 /* end of fontpaths */
+};
+
+static char *XF86Config_fontpathchunk_text =
+
+"\n"
+"# The module search path.  The default path is shown here.\n"
+"\n"
+"#    ModulePath \"" MODULEPATH "\"\n"
+"\n"
+"EndSection\n"
+"\n"
+"# **********************************************************************\n"
+"# Server flags section.\n"
+"# **********************************************************************\n"
+"\n"
+"Section \"ServerFlags\"\n"
+"\n"
+"# Uncomment this to cause a core dump at the spot where a signal is \n"
+"# received.  This may leave the console in an unusable state, but may\n"
+"# provide a better stack trace in the core dump to aid in debugging\n"
+"\n"
+"#    Option \"NoTrapSignals\"\n"
+"\n"
+"# Uncomment this to disable the <Ctrl><Alt><Fn> VT switch sequence\n"
+"# (where n is 1 through 12).  This allows clients to receive these key\n"
+"# events.\n"
+"\n"
+"#    Option \"DontVTSwitch\"\n"
+"\n"
+"# Uncomment this to disable the <Ctrl><Alt><BS> server abort sequence\n"
+"# This allows clients to receive this key event.\n"
+"\n"
+"#    Option \"DontZap\"\n"
+"\n"
+"# Uncomment this to disable the <Ctrl><Alt><KP_+>/<KP_-> mode switching\n"
+"# sequences.  This allows clients to receive these key events.\n"
+"\n"
+"#    Option \"Dont Zoom\"\n"
+"\n"
+"# Uncomment this to disable tuning with the xvidtune client. With\n"
+"# it the client can still run and fetch card and monitor attributes,\n"
+"# but it will not be allowed to change them. If it tries it will\n"
+"# receive a protocol error.\n"
+"\n"
+"#    Option \"DisableVidModeExtension\"\n"
+"\n"
+"# Uncomment this to enable the use of a non-local xvidtune client. \n"
+"\n"
+"#    Option \"AllowNonLocalXvidtune\"\n"
+"\n"
+"# Uncomment this to disable dynamically modifying the input device\n"
+"# (mouse and keyboard) settings. \n"
+"\n"
+"#    Option \"DisableModInDev\"\n"
+"\n"
+"# Uncomment this to enable the use of a non-local client to\n"
+"# change the keyboard or mouse settings (currently only xset).\n"
+"\n"
+"#    Option \"AllowNonLocalModInDev\"\n"
+"\n"
+"EndSection\n"
+"\n"
+"# **********************************************************************\n"
+"# Input devices\n"
+"# **********************************************************************\n"
+"\n"
+"# **********************************************************************\n"
+"# Core keyboard's InputDevice section\n"
+"# **********************************************************************\n"
+"\n"
+"Section \"InputDevice\"\n"
+"\n"
+"    Identifier	\"Keyboard1\"\n"
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+"    Driver	\"Keyboard\"\n"
+#else
+"    Driver	\"kbd\"\n"
+#endif
+"\n"
+"# For most OSs the protocol can be omitted (it defaults to \"Standard\").\n"
+"# When using XQUEUE (only for SVR3 and SVR4, but not Solaris),\n"
+"# uncomment the following line.\n"
+"\n"
+"#    Option     \"Protocol\"      \"Xqueue\"\n"
+"\n"
+"    Option \"AutoRepeat\" \"500 30\"\n"
+"\n"
+"# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))\n"
+"#    Option	\"Xleds\"      \"1 2 3\"\n"
+"\n";
+
+static char *keyboardchunk2_text =
+"\n";
+
+static char *keyboardchunk3_text =
+"# To customise the XKB settings to suit your keyboard, modify the\n"
+"# lines below (which are the defaults).  For example, for a non-U.S.\n"
+"# keyboard, you will probably want to use:\n"
+"#    Option \"XkbModel\"    \"pc105\"\n"
+"# If you have a US Microsoft Natural keyboard, you can use:\n"
+"#    Option \"XkbModel\"    \"microsoft\"\n"
+"#\n"
+"# Then to change the language, change the Layout setting.\n"
+"# For example, a german layout can be obtained with:\n"
+"#    Option \"XkbLayout\"   \"de\"\n"
+"# or:\n"
+"#    Option \"XkbLayout\"   \"de\"\n"
+"#    Option \"XkbVariant\"  \"nodeadkeys\"\n"
+"#\n"
+"# If you'd like to switch the positions of your capslock and\n"
+"# control keys, use:\n"
+"#    Option \"XkbOptions\"  \"ctrl:swapcaps\"\n"
+"\n"
+"# These are the default XKB settings for "__XSERVERNAME__"\n"
+"#    Option \"XkbRules\"    \""__XKBDEFRULES__"\"\n"
+"#    Option \"XkbModel\"    \"pc105\"\n"
+"#    Option \"XkbLayout\"   \"us\"\n"
+"#    Option \"XkbVariant\"  \"\"\n"
+"#    Option \"XkbOptions\"  \"\"\n"
+"\n";
+
+static char *keyboardlastchunk_text =
+"\n"
+"EndSection\n"
+"\n"
+"\n";
+
+static char *pointersection_text1 = 
+"# **********************************************************************\n"
+"# Core Pointer's InputDevice section\n"
+"# **********************************************************************\n"
+"\n"
+"Section \"InputDevice\"\n"
+"\n"
+"# Identifier and driver\n"
+"\n"
+"    Identifier	\"Mouse1\"\n"
+"    Driver	\"mouse\"\n"
+;
+
+static char *pointersection_text2 =
+"\n"
+"# When using XQUEUE, comment out the above two lines, and uncomment\n"
+"# the following line.\n"
+"\n"
+"#    Option \"Protocol\"	\"Xqueue\"\n"
+"\n"
+"# Mouse-speed setting for PS/2 mouse.\n"
+"\n"
+"#    Option \"Resolution\"	\"256\"\n"
+"\n"
+"# Baudrate and SampleRate are only for some Logitech mice. In\n"
+"# almost every case these lines should be omitted.\n"
+"\n"
+"#    Option \"BaudRate\"	\"9600\"\n"
+"#    Option \"SampleRate\"	\"150\"\n"
+"\n"
+"# Mouse wheel mapping.  Default is to map vertical wheel to buttons 4 & 5,\n"
+"# horizontal wheel to buttons 6 & 7.   Change if your mouse has more than\n"
+"# 3 buttons and you need to map the wheel to different button ids to avoid\n"
+"# conflicts.\n"
+"\n"
+"    Option \"ZAxisMapping\"   \"4 5 6 7\"\n"
+"\n"
+"# Emulate3Buttons is an option for 2-button mice\n"
+"# Emulate3Timeout is the timeout in milliseconds (default is 50ms)\n"
+"\n";
+
+
+static char *xinputsection_text =
+"# **********************************************************************\n"
+"# Other input device sections \n"
+"# this is optional and is required only if you\n"
+"# are using extended input devices.  This is for example only.  Refer\n"
+"# to the " CONFIGNAME " man page for a description of the options.\n"
+"# **********************************************************************\n"
+"#\n"
+"# Section \"InputDevice\" \n"
+"#    Identifier  \"Mouse2\"\n"
+"#    Driver      \"mouse\"\n"
+"#    Option      \"Protocol\"      \"MouseMan\"\n"
+"#    Option      \"Device\"        \"/dev/mouse2\"\n"
+"# EndSection\n"
+"#\n"
+"# Section \"InputDevice\"\n"
+"#    Identifier \"spaceball\"\n"
+"#    Driver     \"magellan\"\n"
+"#    Option     \"Device\"        \"/dev/cua0\"\n"
+"# EndSection\n"
+"#\n"
+"# Section \"InputDevice\"\n"
+"#    Identifier \"spaceball2\"\n"
+"#    Driver     \"spaceorb\"\n"
+"#    Option     \"Device\"        \"/dev/cua0\"\n"
+"# EndSection\n"
+"#\n"
+"# Section \"InputDevice\"\n"
+"#    Identifier \"touchscreen0\"\n"
+"#    Driver     \"microtouch\"\n"
+"#    Option     \"Device\"        \"/dev/ttyS0\"\n"
+"#    Option     \"MinX\"          \"1412\"\n"
+"#    Option     \"MaxX\"          \"15184\"\n"
+"#    Option     \"MinY\"          \"15372\"\n"
+"#    Option     \"MaxY\"          \"1230\"\n"
+"#    Option     \"ScreenNumber\"  \"0\"\n"
+"#    Option     \"ReportingMode\" \"Scaled\"\n"
+"#    Option     \"ButtonNumber\"  \"1\"\n"
+"#    Option     \"SendCoreEvents\"\n"
+"# EndSection\n"
+"#\n"
+"# Section \"InputDevice\"\n"
+"#    Identifier \"touchscreen1\"\n"
+"#    Driver     \"elo2300\"\n"
+"#    Option     \"Device\"        \"/dev/ttyS0\"\n"
+"#    Option     \"MinX\"          \"231\"\n"
+"#    Option     \"MaxX\"          \"3868\"\n"
+"#    Option     \"MinY\"          \"3858\"\n"
+"#    Option     \"MaxY\"          \"272\"\n"
+"#    Option     \"ScreenNumber\"  \"0\"\n"
+"#    Option     \"ReportingMode\" \"Scaled\"\n"
+"#    Option     \"ButtonThreshold\"       \"17\"\n"
+"#    Option     \"ButtonNumber\"  \"1\"\n"
+"#    Option     \"SendCoreEvents\"\n"
+"# EndSection\n"
+"\n";
+
+static char *monitorsection_text1 =
+"# **********************************************************************\n"
+"# Monitor section\n"
+"# **********************************************************************\n"
+"\n"
+"# Any number of monitor sections may be present\n"
+"\n"
+"Section \"Monitor\"\n"
+"\n";
+
+static char *monitorsection_text2 =
+"# HorizSync is in kHz unless units are specified.\n"
+"# HorizSync may be a comma separated list of discrete values, or a\n"
+"# comma separated list of ranges of values.\n"
+"# NOTE: THE VALUES HERE ARE EXAMPLES ONLY.  REFER TO YOUR MONITOR\'S\n"
+"# USER MANUAL FOR THE CORRECT NUMBERS.\n"
+"\n";
+
+static char *monitorsection_text3 =
+"#    HorizSync	30-64         # multisync\n"
+"#    HorizSync	31.5, 35.2    # multiple fixed sync frequencies\n"
+"#    HorizSync	15-25, 30-50  # multiple ranges of sync frequencies\n"
+"\n"
+"# VertRefresh is in Hz unless units are specified.\n"
+"# VertRefresh may be a comma separated list of discrete values, or a\n"
+"# comma separated list of ranges of values.\n"
+"# NOTE: THE VALUES HERE ARE EXAMPLES ONLY.  REFER TO YOUR MONITOR\'S\n"
+"# USER MANUAL FOR THE CORRECT NUMBERS.\n"
+"\n";
+
+#if 0
+static char *monitorsection_text4 =
+"# Modes can be specified in two formats.  A compact one-line format, or\n"
+"# a multi-line format.\n"
+"\n"
+"# These two are equivalent\n"
+"\n"
+"#    ModeLine \"1024x768i\" 45 1024 1048 1208 1264 768 776 784 817 Interlace\n"
+"\n"
+"#    Mode \"1024x768i\"\n"
+"#        DotClock	45\n"
+"#        HTimings	1024 1048 1208 1264\n"
+"#        VTimings	768 776 784 817\n"
+"#        Flags		\"Interlace\"\n"
+"#    EndMode\n"
+"\n";
+
+static char *modelines_text =
+"# This is a set of standard mode timings. Modes that are out of monitor spec\n"
+"# are automatically deleted by the server (provided the HorizSync and\n"
+"# VertRefresh lines are correct), so there's no immediate need to\n"
+"# delete mode timings (unless particular mode timings don't work on your\n"
+"# monitor). With these modes, the best standard mode that your monitor\n"
+"# and video card can support for a given resolution is automatically\n"
+"# used.\n"
+"\n"
+"# 640x400 @ 70 Hz, 31.5 kHz hsync\n"
+"Modeline \"640x400\"     25.175 640  664  760  800   400  409  411  450\n"
+"# 640x480 @ 60 Hz, 31.5 kHz hsync\n"
+"Modeline \"640x480\"     25.175 640  664  760  800   480  491  493  525\n"
+"# 800x600 @ 56 Hz, 35.15 kHz hsync\n"
+"ModeLine \"800x600\"     36     800  824  896 1024   600  601  603  625\n"
+"# 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync\n"
+"Modeline \"1024x768\"    44.9  1024 1048 1208 1264   768  776  784  817 Interlace\n"
+"\n"
+"# 640x400 @ 85 Hz, 37.86 kHz hsync\n"
+"Modeline \"640x400\"     31.5   640  672 736   832   400  401  404  445 -HSync +VSync\n"
+"# 640x480 @ 72 Hz, 36.5 kHz hsync\n"
+"Modeline \"640x480\"     31.5   640  680  720  864   480  488  491  521\n"
+"# 640x480 @ 75 Hz, 37.50 kHz hsync\n"
+"ModeLine  \"640x480\"    31.5   640  656  720  840   480  481  484  500 -HSync -VSync\n"
+"# 800x600 @ 60 Hz, 37.8 kHz hsync\n"
+"Modeline \"800x600\"     40     800  840  968 1056   600  601  605  628 +hsync +vsync\n"
+"\n"
+"# 640x480 @ 85 Hz, 43.27 kHz hsync\n"
+"Modeline \"640x480\"     36     640  696  752  832   480  481  484  509 -HSync -VSync\n"
+"# 1152x864 @ 89 Hz interlaced, 44 kHz hsync\n"
+"ModeLine \"1152x864\"    65    1152 1168 1384 1480   864  865  875  985 Interlace\n"
+"\n"
+"# 800x600 @ 72 Hz, 48.0 kHz hsync\n"
+"Modeline \"800x600\"     50     800  856  976 1040   600  637  643  666 +hsync +vsync\n"
+"# 1024x768 @ 60 Hz, 48.4 kHz hsync\n"
+"Modeline \"1024x768\"    65    1024 1032 1176 1344   768  771  777  806 -hsync -vsync\n"
+"\n"
+"# 640x480 @ 100 Hz, 53.01 kHz hsync\n"
+"Modeline \"640x480\"     45.8   640  672  768  864   480  488  494  530 -HSync -VSync\n"
+"# 1152x864 @ 60 Hz, 53.5 kHz hsync\n"
+"Modeline  \"1152x864\"   89.9  1152 1216 1472 1680   864  868  876  892 -HSync -VSync\n"
+"# 800x600 @ 85 Hz, 55.84 kHz hsync\n"
+"Modeline  \"800x600\"    60.75  800  864  928 1088   600  616  621  657 -HSync -VSync\n"
+"\n"
+"# 1024x768 @ 70 Hz, 56.5 kHz hsync\n"
+"Modeline \"1024x768\"    75    1024 1048 1184 1328   768  771  777  806 -hsync -vsync\n"
+"# 1280x1024 @ 87 Hz interlaced, 51 kHz hsync\n"
+"Modeline \"1280x1024\"   80    1280 1296 1512 1568  1024 1025 1037 1165 Interlace\n"
+"\n"
+"# 800x600 @ 100 Hz, 64.02 kHz hsync\n"
+"Modeline  \"800x600\"    69.65  800  864  928 1088   600  604  610  640 -HSync -VSync\n"
+"# 1024x768 @ 76 Hz, 62.5 kHz hsync\n"
+"Modeline \"1024x768\"    85    1024 1032 1152 1360   768  784  787  823\n"
+"# 1152x864 @ 70 Hz, 62.4 kHz hsync\n"
+"Modeline  \"1152x864\"   92    1152 1208 1368 1474   864  865  875  895\n"
+"# 1280x1024 @ 61 Hz, 64.2 kHz hsync\n"
+"Modeline \"1280x1024\"  110    1280 1328 1512 1712  1024 1025 1028 1054\n"
+"\n"
+"# 1024x768 @ 85 Hz, 70.24 kHz hsync\n"
+"Modeline \"1024x768\"   98.9  1024 1056 1216 1408   768 782 788 822 -HSync -VSync\n"
+"# 1152x864 @ 78 Hz, 70.8 kHz hsync\n"
+"Modeline \"1152x864\"   110   1152 1240 1324 1552   864  864  876  908\n"
+"\n"
+"# 1280x1024 @ 70 Hz, 74.59 kHz hsync\n"
+"Modeline \"1280x1024\"  126.5 1280 1312 1472 1696  1024 1032 1040 1068 -HSync -VSync\n"
+"# 1600x1200 @ 60Hz, 75.00 kHz hsync\n"
+"Modeline \"1600x1200\"  162   1600 1664 1856 2160  1200 1201 1204 1250 +HSync +VSync\n"
+"# 1152x864 @ 84 Hz, 76.0 kHz hsync\n"
+"Modeline \"1152x864\"   135    1152 1464 1592 1776   864  864  876  908\n"
+"\n"
+"# 1280x1024 @ 74 Hz, 78.85 kHz hsync\n"
+"Modeline \"1280x1024\"  135    1280 1312 1456 1712  1024 1027 1030 1064\n"
+"\n"
+"# 1024x768 @ 100Hz, 80.21 kHz hsync\n"
+"Modeline \"1024x768\"   115.5  1024 1056 1248 1440  768  771  781  802 -HSync -VSync\n"
+"# 1280x1024 @ 76 Hz, 81.13 kHz hsync\n"
+"Modeline \"1280x1024\"  135    1280 1312 1416 1664  1024 1027 1030 1064\n"
+"\n"
+"# 1600x1200 @ 70 Hz, 87.50 kHz hsync\n"
+"Modeline \"1600x1200\"  189    1600 1664 1856 2160  1200 1201 1204 1250 -HSync -VSync\n"
+"# 1152x864 @ 100 Hz, 89.62 kHz hsync\n"
+"Modeline \"1152x864\"   137.65 1152 1184 1312 1536   864  866  885  902 -HSync -VSync\n"
+"# 1280x1024 @ 85 Hz, 91.15 kHz hsync\n"
+"Modeline \"1280x1024\"  157.5  1280 1344 1504 1728  1024 1025 1028 1072 +HSync +VSync\n"
+"# 1600x1200 @ 75 Hz, 93.75 kHz hsync\n"
+"Modeline \"1600x1200\"  202.5  1600 1664 1856 2160  1200 1201 1204 1250 +HSync +VSync\n"
+"# 1600x1200 @ 85 Hz, 105.77 kHz hsync\n"
+"Modeline \"1600x1200\"  220    1600 1616 1808 2080  1200 1204 1207 1244 +HSync +VSync\n"
+"# 1280x1024 @ 100 Hz, 107.16 kHz hsync\n"
+"Modeline \"1280x1024\"  181.75 1280 1312 1440 1696  1024 1031 1046 1072 -HSync -VSync\n"
+"\n"
+"# 1800x1440 @ 64Hz, 96.15 kHz hsync \n"
+"ModeLine \"1800X1440\"  230    1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync\n"
+"# 1800x1440 @ 70Hz, 104.52 kHz hsync \n"
+"ModeLine \"1800X1440\"  250    1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync\n"
+"\n"
+"# 512x384 @ 78 Hz, 31.50 kHz hsync\n"
+"Modeline \"512x384\"    20.160 512  528  592  640   384  385  388  404 -HSync -VSync\n"
+"# 512x384 @ 85 Hz, 34.38 kHz hsync\n"
+"Modeline \"512x384\"    22     512  528  592  640   384  385  388  404 -HSync -VSync\n"
+"\n"
+#if XFREE86_VERSION >= 311
+"# Low-res Doublescan modes\n"
+"# If your chipset does not support doublescan, you get a 'squashed'\n"
+"# resolution like 320x400.\n"
+"\n"
+"# 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio\n"
+"Modeline \"320x200\"     12.588 320  336  384  400   200  204  205  225 Doublescan\n"
+"# 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio\n"
+"Modeline \"320x240\"     12.588 320  336  384  400   240  245  246  262 Doublescan\n"
+"# 320x240 @ 72 Hz, 36.5 kHz hsync\n"
+"Modeline \"320x240\"     15.750 320  336  384  400   240  244  246  262 Doublescan\n"
+"# 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio\n"
+"ModeLine \"400x300\"     18     400  416  448  512   300  301  302  312 Doublescan\n"
+"# 400x300 @ 60 Hz, 37.8 kHz hsync\n"
+"Modeline \"400x300\"     20     400  416  480  528   300  301  303  314 Doublescan\n"
+"# 400x300 @ 72 Hz, 48.0 kHz hsync\n"
+"Modeline \"400x300\"     25     400  424  488  520   300  319  322  333 Doublescan\n"
+"# 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio\n"
+"ModeLine \"480x300\"     21.656 480  496  536  616   300  301  302  312 Doublescan\n"
+"# 480x300 @ 60 Hz, 37.8 kHz hsync\n"
+"Modeline \"480x300\"     23.890 480  496  576  632   300  301  303  314 Doublescan\n"
+"# 480x300 @ 63 Hz, 39.6 kHz hsync\n"
+"Modeline \"480x300\"     25     480  496  576  632   300  301  303  314 Doublescan\n"
+"# 480x300 @ 72 Hz, 48.0 kHz hsync\n"
+"Modeline \"480x300\"     29.952 480  504  584  624   300  319  322  333 Doublescan\n"
+"\n"
+#endif
+;
+#endif
+
+static char *devicesection_text =
+"# **********************************************************************\n"
+"# Graphics device section\n"
+"# **********************************************************************\n"
+"\n"
+"# Any number of graphics device sections may be present\n"
+"\n"
+"# Standard VGA Device:\n"
+"\n"
+"Section \"Device\"\n"
+"    Identifier	\"Standard VGA\"\n"
+"    VendorName	\"Unknown\"\n"
+"    BoardName	\"Unknown\"\n"
+"\n"
+"# The chipset line is optional in most cases.  It can be used to override\n"
+"# the driver's chipset detection, and should not normally be specified.\n"
+"\n"
+"#    Chipset	\"generic\"\n"
+"\n"
+"# The Driver line must be present.  When using run-time loadable driver\n"
+"# modules, this line instructs the server to load the specified driver\n"
+"# module.  Even when not using loadable driver modules, this line\n"
+"# indicates which driver should interpret the information in this section.\n"
+"\n"
+"    Driver     \"vga\"\n"
+"# The BusID line is used to specify which of possibly multiple devices\n"
+"# this section is intended for.  When this line isn't present, a device\n"
+"# section can only match up with the primary video device.  For PCI\n"
+"# devices a line like the following could be used.  This line should not\n"
+"# normally be included unless there is more than one video device\n"
+"# intalled.\n"
+"\n"
+"#    BusID      \"PCI:0:10:0\"\n"
+"\n"
+"#    VideoRam	256\n"
+"\n"
+"#    Clocks	25.2 28.3\n"
+"\n"
+"EndSection\n"
+"\n"
+"# Device configured by xorgconfig:\n"
+"\n";
+
+static char *screensection_text1 =
+"# **********************************************************************\n"
+"# Screen sections\n"
+"# **********************************************************************\n"
+"\n"
+"# Any number of screen sections may be present.  Each describes\n"
+"# the configuration of a single screen.  A single specific screen section\n"
+"# may be specified from the X server command line with the \"-screen\"\n"
+"# option.\n";
+
+static char *serverlayout_section_text1 = 
+"# **********************************************************************\n"
+"# ServerLayout sections.\n"
+"# **********************************************************************\n"
+"\n"
+"# Any number of ServerLayout sections may be present.  Each describes\n"
+"# the way multiple screens are organised.  A specific ServerLayout\n"
+"# section may be specified from the X server command line with the\n"
+"# \"-layout\" option.  In the absence of this, the first section is used.\n"
+"# When now ServerLayout section is present, the first Screen section\n"
+"# is used alone.\n"
+"\n"
+"Section \"ServerLayout\"\n"
+"\n"
+"# The Identifier line must be present\n"
+"    Identifier  \"Simple Layout\"\n"
+"\n"
+"# Each Screen line specifies a Screen section name, and optionally\n"
+"# the relative position of other screens.  The four names after\n"
+"# primary screen name are the screens to the top, bottom, left and right\n"
+"# of the primary screen.  In this example, screen 2 is located to the\n"
+"# right of screen 1.\n"
+"\n";
+
+static char *serverlayout_section_text2 =
+"\n"
+"# Each InputDevice line specifies an InputDevice section name and\n"
+"# optionally some options to specify the way the device is to be\n"
+"# used.  Those options include \"CorePointer\", \"CoreKeyboard\" and\n"
+"# \"SendCoreEvents\".\n"
+"\n"
+"    InputDevice \"Mouse1\" \"CorePointer\"\n"
+"    InputDevice \"Keyboard1\" \"CoreKeyboard\"\n"
+"\n"
+"EndSection\n"
+"\n"
+"# Section \"DRI\"\n"
+"#    Mode 0666\n"
+"# EndSection\n"
+"\n";
+
+static void 
+write_fontpath_section(FILE *f)
+{
+	/* this will create the Fontpath lines, but only after checking,
+	 * that the corresponding dir exists (was THE absolute problem
+	 * users had with XFree86/OS2 3.1.2D !)
+	 */
+	int i;
+	char cur[256+20],*colon, *hash;
+
+#ifdef COMPILEDDEFAULTFONTPATH
+	static const char dfp[] = COMPILEDDEFAULTFONTPATH;
+	const char *thisdir;
+	const char *nextdir;
+	int len;
+
+	for (thisdir = dfp; thisdir != NULL; thisdir = nextdir) {
+	    nextdir = strchr(thisdir, ',');
+	    if (nextdir == NULL) {
+		len = strlen(thisdir);
+	    } else {
+		len = nextdir - thisdir;
+		nextdir++;
+	    }
+	    if (len > sizeof(cur))
+		continue;
+	    strncpy(cur, thisdir, len);
+	    cur[len] = '\0';
+	    colon = strchr(cur+2,':'); /* OS/2: C:/...:scaled */
+	    if (colon) *colon = 0;
+	    hash = exists_dir(cur) ? "" : "#";
+	    if (colon) *colon = ':';
+	    fprintf(f,"%s    FontPath   \"%s\"\n", hash, cur);
+	}
+#endif
+
+	for (i=0; XF86Config_fontpaths[i]; i++) {
+		strcpy(cur,TREEROOTFONT);
+		strcat(cur,XF86Config_fontpaths[i]);
+		/* remove a ':' */
+		colon = strchr(cur+2,':'); /* OS/2: C:/...:scaled */
+		if (colon) *colon = 0;
+#ifdef COMPILEDDEFAULTFONTPATH
+		/* skip if we already added it as part of the default font path */
+		if (strstr(dfp, cur) != NULL)
+		    continue;
+#endif
+		hash = exists_dir(cur) ? "" : "#";
+		fprintf(f,"%s    FontPath   \"%s%s\"\n",
+			hash,
+			TREEROOTFONT,
+			XF86Config_fontpaths[i]);
+	}
+}
+
+static int 
+write_XF86Config(char *filename)
+{
+	FILE *f = NULL;
+	int fd;
+
+
+	/*
+	 * Write the file.
+	 */
+
+#ifdef SUNSOFT
+	int need_uid_reset = 0;
+	if (euid_changed && (strcmp(filename, "/etc/X11/"XCONFIGFILE) == 0)) {
+		if (seteuid(saved_id) == 0) {
+			need_uid_reset = 1;
+		}
+	}
+	configdir_check();
+#endif
+
+#if defined(O_NOFOLLOW) && defined(O_NOLINKS)
+# define EXTRA_OPEN_FLAGS O_NOFOLLOW | O_NOLINKS
+#endif
+	fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | EXTRA_OPEN_FLAGS, 0644);
+
+#ifdef SUNSOFT
+	if (need_uid_reset) {
+		if (seteuid(getuid()) != 0) {
+			perror("xorgconfig: could not reset euid");
+			exit(-1);
+		}
+	}
+#endif
+	if (fd >= 0) {
+		f = fdopen(fd, "w");
+	}
+
+	if ((fd < 0) || (f == NULL)) {
+		printf("Failed to open filename for writing.\n");
+#ifndef __EMX__
+		if (getuid() != 0)
+			printf("Maybe you need to be root to write to the specified directory?\n");
+#endif
+		return(1);
+	}
+
+#ifdef SUNSOFT
+	{
+		char hostname[MAXHOSTNAMELEN] = "";
+		struct passwd *pwd = getpwuid(getuid());
+		char *username, *timestamp;
+		time_t now;
+
+		if (pwd == NULL) {
+			username = Malloc(32);
+			snprintf(username, 32, "uid %l", (long) getuid());
+		} else {
+			username = pwd->pw_name;
+		}
+
+		gethostname(hostname, sizeof(hostname));
+
+		time(&now);
+		timestamp = ctime(&now);
+
+		fprintf(f, "# Generated by %s on %s at %s\n",
+			username, hostname, timestamp);
+	}
+#endif
+	fprintf(f, "%s", XF86Config_firstchunk_text);
+	write_fontpath_section(f);
+	fprintf(f, "%s", XF86Config_fontpathchunk_text);
+
+	/*
+	 * Write keyboard section.
+	 */
+	if (config_altmeta) {
+		fprintf(f, "    Option \"LeftAlt\"     \"Meta\"\n");
+		fprintf(f, "    Option \"RightAlt\"    \"ModeShift\"\n");
+	}
+	else {
+		fprintf(f, "#    Option \"LeftAlt\"     \"Meta\"\n");
+		fprintf(f, "#    Option \"RightAlt\"    \"ModeShift\"\n");
+	}
+#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT)
+	/* wscons keyoards need a protocol line */
+	fprintf(f, "    Option \"Protocol\" \"wskbd\"\n");
+	fprintf(f, "    Option \"Device\" \"%s\"\n", config_keyboard_dev);
+	fprintf(f, "    Option \"XkbKeycodes\" \"wscons(ppc)\"\n");
+#endif
+	fprintf(f, "%s", keyboardchunk2_text);
+
+	fprintf(f, "%s", keyboardchunk3_text);
+	if (config_xkbdisable) {
+		fprintf(f, "    Option \"XkbDisable\"\n\n");
+	} else {
+		fprintf(f, "#    Option \"XkbDisable\"\n\n");
+	}
+	fprintf(f, "    Option \"XkbRules\"	\"%s\"\n",
+		config_xkbrules);
+	fprintf(f, "    Option \"XkbModel\"	\"%s\"\n",
+		config_xkbmodel);
+	fprintf(f, "    Option \"XkbLayout\"	\"%s\"\n",
+		config_xkblayout);
+        if (config_xkbvariant)
+	    fprintf(f, "    Option \"XkbVariant\"	\"%s\"\n",
+		    config_xkbvariant);
+        if (config_xkboptions)
+	    fprintf(f, "    Option \"XkbOptions\"	\"%s\"\n",
+		    config_xkboptions);
+
+	fprintf(f, "%s",keyboardlastchunk_text);
+
+	/*
+	 * Write pointer section.
+	 */
+	fprintf(f, "%s", pointersection_text1);
+	fprintf(f, "    Option \"Protocol\"    \"%s\"\t# %s\n",
+		mouse_info[config_mousetype].name,
+		mouse_info[config_mousetype].desc);
+#if !defined(__UNIXOS2__) && !defined(QNX4)
+	fprintf(f, "    Option \"Device\"      \"%s\"\n", config_pointerdevice);
+#endif
+	fprintf(f, "%s", pointersection_text2);
+	if (!config_emulate3buttons)
+		fprintf(f, "#");
+	fprintf(f, "    Option \"Emulate3Buttons\"\n");
+	fprintf(f, "#    Option \"Emulate3Timeout\"    \"50\"\n\n");
+	fprintf(f, "# ChordMiddle is an option for some 3-button Logitech mice\n\n");
+	if (!config_chordmiddle)
+		fprintf(f, "#");
+	fprintf(f, "    Option \"ChordMiddle\"\n\n");
+	if (config_cleardtrrts) {
+		fprintf(f, "    Option \"ClearDTR\"\n");
+		fprintf(f, "    Option \"ClearRTS\"\n\n");
+	}
+	fprintf(f, "EndSection\n\n\n");
+
+	/*
+	 * Write XInput sample section
+	 */
+	fprintf(f, "%s", xinputsection_text);
+
+	/*
+	 * Write monitor section.
+	 */
+	fprintf(f, "%s", monitorsection_text1);
+	fprintf(f, "    Identifier  \"%s\"\n", config_monitoridentifier);
+	fprintf(f, "\n");
+	fprintf(f, "%s", monitorsection_text2);
+	fprintf(f, "    HorizSync   %s\n", config_hsyncrange);
+	fprintf(f, "\n");
+	fprintf(f, "%s", monitorsection_text3);
+	fprintf(f, "    VertRefresh %s\n", config_vsyncrange);
+	fprintf(f, "\n");
+#if 0
+	fprintf(f, "%s", monitorsection_text4);
+	fprintf(f, "%s", modelines_text);
+#endif
+	fprintf(f, "EndSection\n\n\n");
+
+	/*
+	 * Write Device section.
+	 */
+
+	fprintf(f, "%s", devicesection_text);
+	fprintf(f, "Section \"Device\"\n");
+	fprintf(f, "    Identifier  \"%s\"\n", config_deviceidentifier);
+   	if (card_selected != -1) {
+	        fprintf(f, "    Driver      \"%s\"\n", card[card_selected].driver);
+	        if (card[card_selected].flags & UNSUPPORTED) {
+			fprintf(f, "	# unsupported card\n");
+		}
+	} else {
+	        fprintf(f, "    Driver      \"vga\"\n"
+			"	# unsupported card\n");
+	}
+	/* Rely on server to detect video memory. */
+	fprintf(f, "    #VideoRam    %d\n", config_videomemory);
+	if (card_selected != -1)
+		/* Add comment lines from card definition. */
+		fprintf(f, card[card_selected].lines);
+	if (config_ramdac != NULL)
+		fprintf(f, "    Ramdac      \"%s\"\n", config_ramdac);
+	if (card_selected != -1)
+		if (card[card_selected].dacspeed != NULL)
+			fprintf(f, "    Dacspeed    %s\n",
+				card[card_selected].dacspeed);
+	if (config_clockchip != NULL)
+		fprintf(f, "    Clockchip   \"%s\"\n", config_clockchip);
+	else
+	if (config_numberofclockslines == 0)
+		fprintf(f, "    # Insert Clocks lines here if appropriate\n");
+	else {
+		int i;
+		for (i = 0; i < config_numberofclockslines; i++)
+			fprintf(f, "    Clocks %s\n", config_clocksline[i]);
+	}
+	fprintf(f, "EndSection\n\n\n");	
+
+	/*
+	 * Write Screen sections.
+	 */
+
+	fprintf(f, "%s", screensection_text1);
+
+	fprintf(f, 
+		"Section \"Screen\"\n"
+		"    Identifier  \"Screen 1\"\n"
+		"    Device      \"%s\"\n"
+		"    Monitor     \"%s\"\n"
+		"    DefaultDepth %s\n"
+		"\n"
+		"    Subsection \"Display\"\n"
+		"        Depth       8\n"
+		"        Modes       %s\n"
+		"        ViewPort    0 0\n",
+		config_deviceidentifier,
+		config_monitoridentifier,
+		config_depth,
+		config_modesline8bpp);
+	if (config_virtual)
+		fprintf(f, "        Virtual     %d %d\n",
+			config_virtualx8bpp, config_virtualy8bpp);
+	fprintf(f, 
+		"    EndSubsection\n"
+		"    Subsection \"Display\"\n"
+		"        Depth       16\n"
+		"        Modes       %s\n"
+		"        ViewPort    0 0\n",
+		config_modesline16bpp);
+	if (config_virtual)
+		fprintf(f, "        Virtual     %d %d\n",
+			config_virtualx16bpp, config_virtualy16bpp);
+	fprintf(f, 
+		"    EndSubsection\n"
+		"    Subsection \"Display\"\n"
+		"        Depth       24\n"
+		"        Modes       %s\n"
+		"        ViewPort    0 0\n",
+		config_modesline24bpp);
+	if (config_virtual)
+		fprintf(f, "        Virtual     %d %d\n",
+			config_virtualx24bpp, config_virtualy24bpp);
+	fprintf(f, 
+		"    EndSubsection\n"
+		"EndSection\n"
+		"\n");
+
+        /*
+	 * ServerLayout section
+	 */
+   
+        fprintf(f, serverlayout_section_text1);
+	/* replace with  screen config */
+	fprintf(f, "    Screen \"Screen 1\"\n");
+
+	fprintf(f, serverlayout_section_text2);
+
+        fclose(f);
+	return(0);
+}
+
+static char *
+append_version(char *name)
+{
+#ifdef APPEND_VERSION_TO_CONFIG_NAME
+	char *ret = NULL;
+
+	if (XF86_VERSION_MAJOR > 9 || XF86_VERSION_MAJOR < 0)
+		return name;
+
+	ret = Malloc(strlen(name) + 2 + 1);
+	sprintf(ret, "%s-%d", name, XF86_VERSION_MAJOR);
+	free(name);
+	return ret;
+#else
+	return name;
+#endif
+}
+
+/*
+ * Ask where to write XF86Config to. Returns filename.
+ */
+
+static char *
+ask_XF86Config_location(void) {
+	char s[80];
+	char *filename = NULL;
+
+	printf(
+"I am going to write the " CONFIGNAME " file now. Make sure you don't accidently\n"
+"overwrite a previously configured one.\n\n");
+
+#ifndef __EMX__
+#ifdef SUNSOFT
+	if ((geteuid() == 0) || euid_changed) {
+#else
+	if (getuid() == 0) {
+#endif
+#ifdef PREFER_XF86CONFIG_IN_ETC
+		filename = Strdup("/etc/X11/" XCONFIGFILE);
+		filename = append_version(filename);
+		printf("Shall I write it to %s? ", filename);
+		getstring(s);
+		printf("\n");
+		if (answerisyes(s))
+			return filename;
+#endif
+
+#ifndef SUNSOFT
+		if (filename)
+			free(filename);
+		filename = Strdup(TREEROOTCFG "/" XCONFIGFILE);
+		filename = append_version(filename);
+		printf("Please answer the following question with either 'y' or 'n'.\n");
+		printf("Shall I write it to the default location, %s? ", filename);
+		getstring(s);
+		printf("\n");
+		if (answerisyes(s))
+			return filename;
+#endif
+
+#ifndef PREFER_XF86CONFIG_IN_ETC
+		if (filename)
+			free(filename);
+		filename = Strdup("/etc/X11/" XCONFIGFILE);
+		filename = append_version(filename);
+		printf("Shall I write it to %s? ", filename);
+		getstring(s);
+		printf("\n");
+		if (answerisyes(s))
+			return filename;
+#endif
+#else /* __EMX__ */
+	{
+		printf("Please answer the following question with either 'y' or 'n'.\n");
+		printf("Shall I write it to the default location, drive:/"__XSERVERNAME__"/lib/X11/XConfig? ");
+		getstring(s);
+		printf("\n");
+		if (answerisyes(s)) {
+			return __XOS2RedirRoot("/"__XSERVERNAME__"/lib/X11/XConfig",'/');
+		}
+#endif /* __EMX__ */
+	}
+
+	if (filename)
+		free(filename);
+	filename = Strdup(XCONFIGFILE);
+	filename = append_version(filename);
+	printf("Do you want it written to the current directory as '%s'? ", filename);
+	getstring(s);
+	printf("\n");
+	if (answerisyes(s)) {
+		return filename;
+	}
+
+	printf("Please give a filename to write to: ");
+	getstring(s);
+	printf("\n");
+	if (filename)
+		free(filename);
+	filename = Strdup(s);
+	return filename;
+}
+
+
+/*
+ * Check if an earlier version of XFree86 is installed; warn about proper
+ * search path order in that case.
+ */
+
+static char *notinstalled_text =
+"The directory " TREEROOT " does not exist. This probably means that you have\n"
+"not yet installed the version of "__XSERVERNAME__" that this program was built\n"
+"to configure. Please install "__XSERVERNAME__" "XVERSIONSTRING" before running this program,\n"
+"following the instructions in the INSTALL or README that comes with the\n"
+__XSERVERNAME__" distribution for your OS.\n"
+"For a minimal installation it is sufficient to only install base binaries,\n"
+"libraries, configuration files and a server that you want to use.\n"
+"\n";
+
+#ifndef __UNIXOS2__
+static char *oldxfree86_text =
+"The directory '/usr/X386/bin' exists. You probably have a very old version of\n"
+"XFree86 installed, but this program was built to configure "__XSERVERNAME__" "XVERSIONSTRING"\n"
+"installed in '" TREEROOT "' instead of '/usr/X386'.\n"
+"\n"
+"It is important that the directory '" TREEROOT "' is present in your\n"
+"search path, *before* any occurrence of '/usr/X386/bin'. If you have installed\n"
+"X program binaries that are not in the base "__XSERVERNAME__" distribution in\n"
+"'/usr/X386/bin', you can keep the directory in your path as long as it is\n"
+"after '" TREEROOT "'.\n"
+"\n";
+
+static char *pathnote_text =	
+"Note that the X binary directory in your path may be a symbolic link.\n"
+"In that case you could modify the symbolic link to point to the new binaries.\n"
+"Example: 'rm -f /usr/bin/X11; ln -s /usr/X11R6/bin /usr/bin/X11', if the\n"
+"link is '/usr/bin/X11'.\n"
+"\n"
+"Make sure the path is OK before continuing.\n";
+#endif
+
+static void 
+path_check(void) {
+	char s[80];
+	int ok;
+
+	ok = exists_dir(TREEROOT);
+	if (!ok) {
+		printf("%s", notinstalled_text);
+		printf("Do you want to continue? ");
+		getstring(s);
+		if (!answerisyes(s))
+			exit(-1);
+		printf("\n");
+	}
+
+#ifndef __UNIXOS2__
+	ok = exists_dir("/usr/X386/bin");
+	if (!ok)
+		return;
+
+	printf("%s", oldxfree86_text);
+	printf("Your PATH is currently set as follows:\n%s\n\n",
+		getenv("PATH"));
+	printf("%s", pathnote_text);
+	keypress();
+#endif
+}
+
+
+static void
+configdir_check(void)
+{
+	/* /etc/X11 may not exist on some systems */
+#ifdef SUNSOFT
+	if (geteuid() == 0) {
+#else
+	if (getuid() == 0) {
+#endif
+		struct stat buf;
+		if (stat("/etc/X11", &buf) == -1 && errno == ENOENT)
+			mkdir("/etc/X11", 0777);
+#ifndef SUNSOFT
+		if (stat(TREEROOTCFG, &buf) == -1 && errno == ENOENT)
+			mkdir(TREEROOTCFG, 0777);
+#endif
+	}
+}
+
+
+/*
+ * Program entry point.
+ */
+
+int 
+main(int argc, char *argv[]) {
+
+#ifdef SUNSOFT
+	/* Try to run more securely when being run seteuid via RBAC */
+	if (issetugid() || (geteuid() != getuid())) {
+		saved_id = geteuid();
+		if (seteuid(getuid()) == 0) {
+			euid_changed = 1;
+		} else {
+			perror("xorgconfig: could not reset euid");
+			exit(-1);
+		}
+	}
+#endif
+    
+	createtmpdir();
+
+	emptylines();
+
+	printf("%s", intro_text);
+
+	keypress();
+	emptylines();
+
+	path_check();
+
+	emptylines();
+
+#ifndef SUNSOFT /* Moved into write_XF86Config */
+	configdir_check();
+
+	emptylines();
+#endif
+
+	mouse_configuration();
+
+	emptylines();
+
+	keyboard_configuration();
+
+	emptylines();
+
+	monitor_configuration();
+
+	emptylines();
+
+	carddb_configuration();
+
+	emptylines();
+
+ 	while(screen_configuration()){};
+
+	emptylines();
+
+	depth_configuration();
+
+	emptylines();
+
+	while(write_XF86Config(ask_XF86Config_location())){};
+
+	printf("%s", finalcomment_text);
+
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/include/extnsionst.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,206 @@
+/* $Xorg: extnsionst.h,v 1.4 2001/02/09 02:05:15 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 2006 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.
+ */ 
+
+/* $XFree86: xc/programs/Xserver/include/extnsionst.h,v 3.8 2003/04/27 21:31:04 herrb Exp $ */
+
+#ifndef EXTENSIONSTRUCT_H
+#define EXTENSIONSTRUCT_H 
+
+#include "misc.h"
+#include "screenint.h"
+#include "extension.h"
+#include "gc.h"
+
+#ifdef TSOL
+#include "inputstr.h"
+#endif /* TSOL */
+
+typedef struct _ExtensionEntry {
+    int index;
+    void (* CloseDown)(	/* called at server shutdown */
+	struct _ExtensionEntry * /* extension */);
+    char *name;               /* extension name */
+    int base;                 /* base request number */
+    int eventBase;            
+    int eventLast;
+    int errorBase;
+    int errorLast;
+    int num_aliases;
+    char **aliases;
+    pointer extPrivate;
+    unsigned short (* MinorOpcode)(	/* called for errors */
+	ClientPtr /* client */);
+#ifdef XCSECURITY
+    Bool secure;		/* extension visible to untrusted clients? */
+#endif
+} ExtensionEntry;
+
+/* 
+ * The arguments may be different for extension event swapping functions.
+ * Deal with this by casting when initializing the event's EventSwapVector[]
+ * entries.
+ */
+typedef void (*EventSwapPtr) (xEvent *, xEvent *);
+
+extern EventSwapPtr EventSwapVector[128];
+
+extern void NotImplemented (	/* FIXME: this may move to another file... */
+	xEvent *,
+	xEvent *);
+
+typedef void (* ExtensionLookupProc)(
+#ifdef EXTENSION_PROC_ARGS
+    EXTENSION_PROC_ARGS
+#else
+    /* args no longer indeterminate */
+    char *name,
+    GCPtr pGC
+#endif
+);
+
+typedef struct _ProcEntry {
+    char *name;
+    ExtensionLookupProc proc;
+} ProcEntryRec, *ProcEntryPtr;
+
+typedef struct _ScreenProcEntry {
+    int num;
+    ProcEntryPtr procList;
+} ScreenProcEntry;
+
+#define    SetGCVector(pGC, VectorElement, NewRoutineAddress, Atom)    \
+    pGC->VectorElement = NewRoutineAddress;
+
+#define    GetGCValue(pGC, GCElement)    (pGC->GCElement)
+
+
+extern ExtensionEntry *AddExtension(
+    char* /*name*/,
+    int /*NumEvents*/,
+    int /*NumErrors*/,
+    int (* /*MainProc*/)(ClientPtr /*client*/),
+    int (* /*SwappedMainProc*/)(ClientPtr /*client*/),
+    void (* /*CloseDownProc*/)(ExtensionEntry * /*extension*/),
+    unsigned short (* /*MinorOpcodeProc*/)(ClientPtr /*client*/)
+);
+
+extern Bool AddExtensionAlias(
+    char* /*alias*/,
+    ExtensionEntry * /*extension*/);
+
+extern ExtensionEntry *CheckExtension(const char *extname);
+
+extern ExtensionLookupProc LookupProc(
+    char* /*name*/,
+    GCPtr /*pGC*/);
+
+extern Bool RegisterProc(
+    char* /*name*/,
+    GCPtr /*pGC*/,
+    ExtensionLookupProc /*proc*/);
+
+extern Bool RegisterScreenProc(
+    char* /*name*/,
+    ScreenPtr /*pScreen*/,
+    ExtensionLookupProc /*proc*/);
+
+extern void DeclareExtensionSecurity(
+    char * /*extname*/,
+    Bool /*secure*/);
+
+#ifdef TSOL
+typedef struct
+{
+   XID (*CheckAuthorization)(unsigned int, char *, unsigned int,
+        char *, ClientPtr , char **);
+    int (*InitWindow)(ClientPtr, WindowPtr);
+    int (*ChangeWindowProperty)(ClientPtr, WindowPtr, Atom, Atom, int, int,
+        unsigned long, pointer, Bool);
+    int (*DeleteProperty)(ClientPtr, WindowPtr, Atom);
+    char (*CheckPropertyAccess)(ClientPtr, WindowPtr, ATOM, Mask);
+    void (*ProcessKeyboard)(xEvent *, KeyClassPtr);
+    void (*DeleteClientFromAnySelections)(ClientPtr);
+    void (*DeleteWindowFromAnySelections)(WindowPtr);
+    void (*AuditStart)(ClientPtr);
+    void (*AuditEnd)(ClientPtr, int);
+} SecurityHook, *SecurityHookPtr;
+
+extern SecurityHookPtr pSecHook;
+
+#endif /* TSOL */
+
+#endif /* EXTENSIONSTRUCT_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/include/propertyst.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,108 @@
+/* $Xorg: propertyst.h,v 1.4 2001/02/09 02:05:15 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 2006 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.
+ */ 
+
+/* $XFree86: xc/programs/Xserver/include/propertyst.h,v 3.2 2001/01/17 22:36:57 dawes Exp $ */
+
+#ifndef PROPERTYSTRUCT_H
+#define PROPERTYSTRUCT_H 
+#include "misc.h"
+#include "property.h"
+/* 
+ *   PROPERTY -- property element
+ */
+
+typedef struct _Property {
+        struct _Property       *next;
+	ATOM 		propertyName;
+	ATOM		type;       /* ignored by server */
+	short		format;     /* format of data for swapping - 8,16,32 */
+	long		size;       /* size of data in (format/8) bytes */
+	pointer         data;       /* private to client */
+#if defined(LBX) || defined(LBX_COMPAT)
+	/*  If space is at a premium and binary compatibility is not
+	 *  an issue, you may want to put the owner_pid next to format
+	 *  so that the two shorts pack together without padding.
+	 */
+  	short		owner_pid;	/* proxy that has the data */
+  	XID		tag_id;
+#endif
+#ifdef TSOL
+	pointer		secPrivate;	/* Security information */
+#endif /* TSOL */
+} PropertyRec;
+
+#endif /* PROPERTYSTRUCT_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/include/selection.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,100 @@
+/* $Xorg: selection.h,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+
+#ifndef SELECTION_H
+#define SELECTION_H 1
+
+/***********************************************************
+
+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 2006 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.
+ */ 
+
+#include "dixstruct.h"
+/*
+ *
+ *  Selection data structures 
+ */
+
+typedef struct _Selection {
+    Atom selection;
+    TimeStamp lastTimeChanged;
+    Window window;
+    WindowPtr pWin;
+    ClientPtr client;
+#ifdef TSOL
+    pointer secPrivate;	/* Security Information */
+#endif /* TSOL */
+} Selection;
+
+#endif /* SELECTION_H */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/lbx/lbxprop.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,592 @@
+/* $Xorg: lbxprop.c,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+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 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.
+ *
+ */
+
+/* Copyright 2006 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.
+ */ 
+
+/* $XFree86: xc/programs/Xserver/lbx/lbxprop.c,v 1.4 2001/05/15 10:19:43 eich Exp $ */
+
+/* various bits of DIX-level mangling */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "servermd.h"
+#include "propertyst.h"
+#include "colormapst.h"
+#include "windowstr.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "lbxserve.h"
+#include "lbxtags.h"
+#include <X11/Xfuncproto.h>
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#include "swaprep.h"
+#include "extnsionst.h"
+
+void
+LbxStallPropRequest(ClientPtr   client,
+		    PropertyPtr pProp)
+{
+    xReq *req = (xReq *) client->requestBuffer;
+    register char n;
+
+    LbxQueryTagData(client, pProp->owner_pid,
+		    pProp->tag_id, LbxTagTypeProperty);
+
+    /*
+     * Before we reset the request, we must make sure
+     * it is in the client's byte order.
+     */
+
+    if (client->swapped) {
+	if (req->reqType == X_ChangeProperty) {
+	    xChangePropertyReq *stuff = (xChangePropertyReq *) req;
+	    swaps(&stuff->length, n);
+	    swapl(&stuff->window, n);
+	    swapl(&stuff->property, n);
+	    swapl(&stuff->type, n);
+	    swapl(&stuff->nUnits, n);
+	    switch ( stuff->format ) {
+	    case 16:
+		SwapRestS(stuff);
+		break;
+	    case 32:
+		SwapRestL(stuff);
+		break;
+	    }
+	} else if (req->reqType == X_GetProperty) {
+	    xGetPropertyReq *stuff = (xGetPropertyReq *) req;
+	    swaps(&stuff->length, n);
+	    swapl(&stuff->window, n);
+	    swapl(&stuff->property, n);
+	    swapl(&stuff->type, n);
+	    swapl(&stuff->longOffset, n);
+	    swapl(&stuff->longLength, n);
+	} else if (req->data == X_LbxChangeProperty) {
+	    xLbxChangePropertyReq *stuff = (xLbxChangePropertyReq *) req;
+	    swaps(&stuff->length, n);
+	    swapl(&stuff->window, n);
+	    swapl(&stuff->property, n);
+	    swapl(&stuff->type, n);
+	    swapl(&stuff->nUnits, n);
+	} else if (req->data == X_LbxGetProperty) {
+	    xLbxGetPropertyReq *stuff = (xLbxGetPropertyReq *) req;
+	    swaps(&stuff->length, n);
+	    swapl(&stuff->window, n);
+	    swapl(&stuff->property, n);
+	    swapl(&stuff->type, n);
+	    swapl(&stuff->longOffset, n);
+	    swapl(&stuff->longLength, n);
+	}
+    }
+    ResetCurrentRequest(client);
+    client->sequence--;
+    IgnoreClient(client);
+}
+
+int
+LbxChangeWindowProperty(ClientPtr   	client,
+			WindowPtr   	pWin,
+			Atom        	property,
+			Atom	    	type,
+			int         	format,
+			int	    	mode,
+			unsigned long	len,
+			Bool        	have_data,
+			pointer     	value,
+			Bool        	sendevent,
+			XID            *tag)
+{
+    PropertyPtr pProp;
+    xEvent      event;
+    int         sizeInBytes;
+    int         totalSize;
+    pointer     data;
+
+    sizeInBytes = format >> 3;
+    totalSize = len * sizeInBytes;
+
+    /* first see if property already exists */
+
+    pProp = wUserProps(pWin);
+    while (pProp) {
+	if (pProp->propertyName == property)
+	    break;
+	pProp = pProp->next;
+    }
+    if (!pProp) {		/* just add to list */
+	if (!pWin->optional && !MakeWindowOptional(pWin))
+	    return (BadAlloc);
+	pProp = (PropertyPtr) xalloc(sizeof(PropertyRec));
+	if (!pProp)
+	    return (BadAlloc);
+	data = (pointer) xalloc(totalSize);
+	if (!data && len) {
+	    xfree(pProp);
+	    return (BadAlloc);
+	}
+	pProp->propertyName = property;
+	pProp->type = type;
+	pProp->format = format;
+	pProp->data = data;
+#ifdef TSOL
+	pProp->secPrivate = (pointer)NULL;
+#endif
+	if (have_data) {
+	    if (len)
+		memmove((char *) data, (char *) value, totalSize);
+	    pProp->tag_id = 0;
+	    pProp->owner_pid = 0;
+	} else {
+	    if (!TagSaveTag(LbxTagTypeProperty, totalSize,
+			    (pointer)pProp, &pProp->tag_id)) {
+		xfree(pProp);
+		xfree(pProp->data);
+		return BadAlloc;
+	    }
+	    pProp->owner_pid = LbxProxyID(client);
+	    TagMarkProxy(pProp->tag_id, pProp->owner_pid);
+	}
+	pProp->size = len;
+	pProp->next = pWin->optional->userProps;
+	pWin->optional->userProps = pProp;
+    } else {
+	/*
+	 * To append or prepend to a property the request format and type must
+	 * match those of the already defined property.  The existing format
+	 * and type are irrelevant when using the mode "PropModeReplace" since
+	 * they will be written over.
+	 */
+
+	if ((format != pProp->format) && (mode != PropModeReplace))
+	    return (BadMatch);
+	if ((pProp->type != type) && (mode != PropModeReplace))
+	    return (BadMatch);
+
+	/*
+	 * if its a modify instead of replace, make sure we have the current
+	 * value
+	 */
+	if ((mode != PropModeReplace) && pProp->tag_id && pProp->owner_pid) {
+	    LbxStallPropRequest(client, pProp);
+	    return (client->noClientException);
+	}
+	/* make sure any old tag is flushed first */
+	if (pProp->tag_id)
+	    TagDeleteTag(pProp->tag_id);
+	if (mode == PropModeReplace) {
+	    if (totalSize != pProp->size * (pProp->format >> 3)) {
+		data = (pointer) xrealloc(pProp->data, totalSize);
+		if (!data && len)
+		    return (BadAlloc);
+		pProp->data = data;
+	    }
+	    if (have_data) {
+		if (len)
+		    memmove((char *) pProp->data, (char *) value, totalSize);
+	    } else {
+		if (!TagSaveTag(LbxTagTypeProperty, totalSize,
+				(pointer)pProp, &pProp->tag_id)) {
+		    xfree(pProp);
+		    xfree(pProp->data);
+		    return BadAlloc;
+		}
+		pProp->owner_pid = LbxProxyID(client);
+		TagMarkProxy(pProp->tag_id, pProp->owner_pid);
+	    }
+	    pProp->size = len;
+	    pProp->type = type;
+	    pProp->format = format;
+	} else if (len == 0) {
+	    /* do nothing */
+	} else if (mode == PropModeAppend) {
+	    data = (pointer) xrealloc(pProp->data,
+				      sizeInBytes * (len + pProp->size));
+	    if (!data)
+		return (BadAlloc);
+	    pProp->data = data;
+	    memmove(&((char *) data)[pProp->size * sizeInBytes],
+		    (char *) value,
+		    totalSize);
+	    pProp->size += len;
+	} else if (mode == PropModePrepend) {
+	    data = (pointer) xalloc(sizeInBytes * (len + pProp->size));
+	    if (!data)
+		return (BadAlloc);
+	    memmove(&((char *) data)[totalSize], (char *) pProp->data,
+		    (int) (pProp->size * sizeInBytes));
+	    memmove((char *) data, (char *) value, totalSize);
+	    xfree(pProp->data);
+	    pProp->data = data;
+	    pProp->size += len;
+	}
+    }
+    if (sendevent) {
+	event.u.u.type = PropertyNotify;
+	event.u.property.window = pWin->drawable.id;
+	event.u.property.state = PropertyNewValue;
+	event.u.property.atom = pProp->propertyName;
+	event.u.property.time = currentTime.milliseconds;
+	DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
+    }
+    if (pProp->tag_id)
+	*tag = pProp->tag_id;
+    return (Success);
+}
+
+int
+LbxChangeProperty(ClientPtr client)
+{
+    WindowPtr   pWin;
+    char        format,
+                mode;
+    unsigned long len;
+    int         err;
+    int         n;
+    XID         newtag;
+    char	action;
+    xLbxChangePropertyReply rep;
+    REQUEST(xLbxChangePropertyReq);
+
+    REQUEST_SIZE_MATCH(xLbxChangePropertyReq);
+    UpdateCurrentTime();
+    format = stuff->format;
+    mode = stuff->mode;
+    if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
+	    (mode != PropModePrepend)) {
+	client->errorValue = mode;
+	return BadValue;
+    }
+    if ((format != 8) && (format != 16) && (format != 32)) {
+	client->errorValue = format;
+	return BadValue;
+    }
+    len = stuff->nUnits;
+    if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
+	return BadLength;
+
+    pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
+					    SecurityWriteAccess);
+    if (!pWin)
+	return (BadWindow);
+    if (!ValidAtom(stuff->property)) {
+	client->errorValue = stuff->property;
+	return (BadAtom);
+    }
+    if (!ValidAtom(stuff->type)) {
+	client->errorValue = stuff->type;
+	return (BadAtom);
+    }
+
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.length = 0;
+    rep.pad = rep.pad0 = rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0;
+    if (client->swapped) {
+	swaps(&rep.sequenceNumber, n);
+    }
+
+#ifdef XCSECURITY
+#ifdef TSOL
+    if (pSecHook)
+        action = (*pSecHook->CheckPropertyAccess)(client, pWin, stuff->property,
+                SecurityWriteAccess);
+
+    else
+#endif
+
+    action = (SecurityCheckPropertyAccess(client, pWin, stuff->property,
+					SecurityWriteAccess));
+    switch (action)
+    {
+	case SecurityErrorOperation:
+	    client->errorValue = stuff->property;
+	    return BadAtom;
+	case SecurityIgnoreOperation:
+	    rep.tag = 0;
+	    WriteToClient(client, sizeof(xLbxChangePropertyReply), (char *)&rep);
+	    return client->noClientException;
+    }
+#endif
+
+    err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type,
+		   (int) format, (int) mode, len, FALSE, (pointer) &stuff[1],
+				  TRUE, &newtag);
+    if (err)
+	return err;
+
+    rep.tag = newtag;
+
+    if (client->swapped) {
+	swapl(&rep.tag, n);
+    }
+    WriteToClient(client, sizeof(xLbxChangePropertyReply), (char *)&rep);
+
+    return client->noClientException;
+}
+
+static void
+LbxWriteGetpropReply(ClientPtr   	   client,
+		     xLbxGetPropertyReply *rep)
+{
+    int         n;
+
+    if (client->swapped) {
+	swaps(&rep->sequenceNumber, n);
+	swapl(&rep->length, n);
+	swapl(&rep->propertyType, n);
+	swapl(&rep->bytesAfter, n);
+	swapl(&rep->nItems, n);
+	swapl(&rep->tag, n);
+    }
+    WriteToClient(client, sizeof(xLbxGetPropertyReply), (char *)rep);
+}
+
+int
+LbxGetProperty(ClientPtr client)
+{
+    PropertyPtr pProp,
+                prevProp;
+    unsigned long n,
+                len,
+                ind;
+    WindowPtr   pWin;
+    xLbxGetPropertyReply reply;
+    Bool        send_data = FALSE;
+
+    REQUEST(xLbxGetPropertyReq);
+
+    REQUEST_SIZE_MATCH(xLbxGetPropertyReq);
+
+    reply.pad1 = 0;
+    reply.pad2 = 0;
+
+    if (stuff->delete)
+	UpdateCurrentTime();
+    pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
+					    SecurityReadAccess);
+    if (!pWin)
+	return (BadWindow);
+
+    if (!ValidAtom(stuff->property)) {
+	client->errorValue = stuff->property;
+	return (BadAtom);
+    }
+    if ((stuff->delete != xTrue) && (stuff->delete != xFalse)) {
+	client->errorValue = stuff->delete;
+	return (BadValue);
+    }
+    if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
+    {
+	client->errorValue = stuff->type;
+	return(BadAtom);
+    }
+    pProp = wUserProps(pWin);
+    prevProp = (PropertyPtr) NULL;
+    while (pProp) {
+	if (pProp->propertyName == stuff->property)
+	    break;
+	prevProp = pProp;
+	pProp = pProp->next;
+    }
+    reply.type = X_Reply;
+    reply.sequenceNumber = client->sequence;
+    if (!pProp) {
+	reply.nItems = 0;
+	reply.length = 0;
+	reply.bytesAfter = 0;
+	reply.propertyType = None;
+	reply.format = 0;
+	reply.tag = 0;
+	LbxWriteGetpropReply(client, &reply);
+	return client->noClientException;
+    }
+    /*
+     * If the request type and actual type don't match. Return the
+     * property information, but not the data.
+     */
+    if ((stuff->type != pProp->type) &&
+	(stuff->type != AnyPropertyType)) {
+	reply.bytesAfter = pProp->size;
+	reply.format = pProp->format;
+	reply.length = 0;
+	reply.nItems = 0;
+	reply.propertyType = pProp->type;
+	reply.tag = 0;
+	LbxWriteGetpropReply(client, &reply);
+	return client->noClientException;
+    }
+    /*
+     * Return type, format, value to client
+     */
+    n = (pProp->format >> 3) * pProp->size;	/* size (bytes) of prop */
+    ind = stuff->longOffset << 2;
+
+    /*
+     * If longOffset is invalid such that it causes "len" to be
+     * negative, it's a value error.
+     */
+
+    if (n < ind) {
+	client->errorValue = stuff->longOffset;
+	return BadValue;
+    }
+
+    /* make sure we have the current value */
+    if (pProp->tag_id && pProp->owner_pid) {
+	LbxStallPropRequest(client, pProp);
+	return client->noClientException;
+    }
+
+    len = min(n - ind, stuff->longLength << 2);
+
+    reply.bytesAfter = n - (ind + len);
+    reply.format = pProp->format;
+    reply.propertyType = pProp->type;
+
+    if (!pProp->tag_id) {
+	if (n && (!stuff->delete || reply.bytesAfter)) {
+	    TagSaveTag(LbxTagTypeProperty, n, (pointer)pProp, &pProp->tag_id);
+	    pProp->owner_pid = 0;
+	}
+	send_data = TRUE;
+    } else
+	send_data = !TagProxyMarked(pProp->tag_id, LbxProxyID(client));
+    if (pProp->tag_id && send_data)
+	TagMarkProxy(pProp->tag_id, LbxProxyID(client));
+    reply.tag = pProp->tag_id;
+
+    if (!send_data)
+	len = 0;
+    else if (reply.tag) {
+	len = n;
+	ind = 0;
+    }
+    reply.nItems = len / (pProp->format >> 3);
+    reply.length = (len + 3) >> 2;
+
+    if (stuff->delete && (reply.bytesAfter == 0)) {
+	xEvent      event;
+
+	event.u.u.type = PropertyNotify;
+	event.u.property.window = pWin->drawable.id;
+	event.u.property.state = PropertyDelete;
+	event.u.property.atom = pProp->propertyName;
+	event.u.property.time = currentTime.milliseconds;
+	DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
+    }
+    LbxWriteGetpropReply(client, &reply);
+    if (len) {
+	switch (reply.format) {
+	case 32:
+	    client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write;
+	    break;
+	case 16:
+	    client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write;
+	    break;
+	default:
+	    client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
+	    break;
+	}
+	WriteSwappedDataToClient(client, len,
+				 (char *) pProp->data + ind);
+    }
+    if (stuff->delete && (reply.bytesAfter == 0)) {
+	if (pProp->tag_id)
+	    TagDeleteTag(pProp->tag_id);
+	if (prevProp == (PropertyPtr) NULL) {
+	    if (!(pWin->optional->userProps = pProp->next))
+		CheckWindowOptionalNeed(pWin);
+	} else
+	    prevProp->next = pProp->next;
+	xfree(pProp->data);
+	xfree(pProp);
+    }
+    return client->noClientException;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,51 @@
+XCOMM #########################################################################
+XCOMM
+XCOMM Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM #########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.6     06/03/28 SMI"
+XCOMM
+
+XCOMM Additional Sun-specific extensions & subdirectories
+
+
+	SUNEXTDIR = SunExt
+XCOMM Uncomment to link directly into the server if not building loadable modules
+XCOMM	SUNEXTS = $(SUNEXTDIR)/libsunext.a
+ 
+	SITEEXTDIRS = $(SUNEXTDIR)
+	SITEEXTS = $(SUNEXTS)
+
+/* Need libproject for Xserver/os/dtlogin.c */
+#define ServerExtraSysLibs -lproject
+
+#if !defined(__amd64) &&  !defined(AMD64Architecture)
+/* Need to get libXdmcp & libXau from /usr/openwin/lib for now */
+#define LdPreLib -L/usr/openwin/LibDirName -R/usr/openwin/LibDirName
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/os/auth.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,413 @@
+/* $Xorg: auth.c,v 1.5 2001/02/09 02:05:23 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: auth.c,v 1.13 2003/04/27 21:31:08 herrb Exp $ */
+
+/*
+ * authorization hooks for the server
+ * Author:  Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef K5AUTH
+# include   <krb5/krb5.h>
+#endif
+# include   <X11/X.h>
+# include   <X11/Xauth.h>
+# include   "misc.h"
+# include   "osdep.h"
+# include   "dixstruct.h"
+# include   <sys/types.h>
+# include   <sys/stat.h>
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+# include   <X11/extensions/security.h>
+#endif
+#ifdef WIN32
+#include    <X11/Xw32defs.h>
+#endif
+
+struct protocol {
+    unsigned short   name_length;
+    char    *name;
+    AuthAddCFunc	Add;	/* new authorization data */
+    AuthCheckFunc	Check;	/* verify client authorization data */
+    AuthRstCFunc	Reset;	/* delete all authorization data entries */
+    AuthToIDFunc	ToID;	/* convert cookie to ID */
+    AuthFromIDFunc	FromID;	/* convert ID to cookie */
+    AuthRemCFunc	Remove;	/* remove a specific cookie */
+#ifdef XCSECURITY
+    AuthGenCFunc	Generate;
+#endif
+};
+
+static struct protocol   protocols[] = {
+{   (unsigned short) 18,    "MIT-MAGIC-COOKIE-1",
+		MitAddCookie,	MitCheckCookie,	MitResetCookie,
+		MitToID,	MitFromID,	MitRemoveCookie,
+#ifdef XCSECURITY
+		MitGenerateCookie
+#endif
+},
+#ifdef HASXDMAUTH
+{   (unsigned short) 19,    "XDM-AUTHORIZATION-1",
+		XdmAddCookie,	XdmCheckCookie,	XdmResetCookie,
+		XdmToID,	XdmFromID,	XdmRemoveCookie,
+#ifdef XCSECURITY
+		NULL
+#endif
+},
+#endif
+#ifdef SECURE_RPC
+{   (unsigned short) 9,    "SUN-DES-1",
+		SecureRPCAdd,	SecureRPCCheck,	SecureRPCReset,
+		SecureRPCToID,	SecureRPCFromID,SecureRPCRemove,
+#ifdef XCSECURITY
+		NULL
+#endif
+},
+#endif
+#ifdef K5AUTH
+{   (unsigned short) 14, "MIT-KERBEROS-5",
+		K5Add, K5Check, K5Reset,
+		K5ToID, K5FromID, K5Remove,
+#ifdef XCSECURITY
+		NULL
+#endif
+},
+#endif
+#ifdef XCSECURITY
+{   (unsigned short) XSecurityAuthorizationNameLen,
+	XSecurityAuthorizationName,
+		NULL, AuthSecurityCheck, NULL,
+		NULL, NULL, NULL,
+		NULL
+},
+#endif
+};
+
+# define NUM_AUTHORIZATION  (sizeof (protocols) /\
+			     sizeof (struct protocol))
+
+/*
+ * Initialize all classes of authorization by reading the
+ * specified authorization file
+ */
+
+static char *authorization_file = (char *)NULL;
+
+static Bool ShouldLoadAuth = TRUE;
+
+void
+InitAuthorization (char *file_name)
+{
+    authorization_file = file_name;
+}
+
+static int
+LoadAuthorization (void)
+{
+    FILE    *f;
+    Xauth   *auth;
+    int	    i;
+    int	    count = 0;
+
+    ShouldLoadAuth = FALSE;
+    if (!authorization_file)
+	return 0;
+
+    f = Fopen (authorization_file, "r");
+    if (!f)
+	return -1;
+
+    while ((auth = XauReadAuth (f)) != 0) {
+	for (i = 0; i < NUM_AUTHORIZATION; i++) {
+	    if (protocols[i].name_length == auth->name_length &&
+		memcmp (protocols[i].name, auth->name, (int) auth->name_length) == 0 &&
+		protocols[i].Add)
+	    {
+		++count;
+		(*protocols[i].Add) (auth->data_length, auth->data,
+					 FakeClientID(0));
+	    }
+	}
+	XauDisposeAuth (auth);
+    }
+
+    Fclose (f);
+    return count;
+}
+
+#ifdef XDMCP
+/*
+ * XdmcpInit calls this function to discover all authorization
+ * schemes supported by the display
+ */
+void
+RegisterAuthorizations (void)
+{
+    int	    i;
+
+    for (i = 0; i < NUM_AUTHORIZATION; i++)
+	XdmcpRegisterAuthorization (protocols[i].name,
+				    (int)protocols[i].name_length);
+}
+#endif
+
+XID
+CheckAuthorization (
+    unsigned int name_length,
+    char	*name,
+    unsigned int data_length,
+    char	*data,
+    ClientPtr client,
+    char	**reason)	/* failure message.  NULL for default msg */
+{
+    int	i;
+    struct stat buf;
+    static time_t lastmod = 0;
+    static Bool loaded = FALSE;
+
+    if (!authorization_file || stat(authorization_file, &buf))
+    {
+	if (lastmod != 0) {
+	    lastmod = 0;
+	    ShouldLoadAuth = TRUE;	/* stat lost, so force reload */
+	}
+    }
+    else if (buf.st_mtime > lastmod)
+    {
+	lastmod = buf.st_mtime;
+	ShouldLoadAuth = TRUE;
+    }
+    if (ShouldLoadAuth)
+    {
+	int loadauth = LoadAuthorization();
+
+	/*
+	 * If the authorization file has at least one entry for this server,
+	 * disable local host access. (loadauth > 0)
+	 *
+	 * If there are zero entries (either initially or when the
+	 * authorization file is later reloaded), or if a valid
+	 * authorization file was never loaded, enable local host access.
+	 * (loadauth == 0 || !loaded)
+	 *
+	 * If the authorization file was loaded initially (with valid
+	 * entries for this server), and reloading it later fails, don't
+	 * change anything. (loadauth == -1 && loaded)
+	 */
+	
+	if (loadauth > 0)
+	{
+	    DisableLocalHost(); /* got at least one */
+	    loaded = TRUE;
+	}
+	else if (loadauth == 0 || !loaded)
+	    EnableLocalHost ();
+    }
+    if (name_length) {
+	for (i = 0; i < NUM_AUTHORIZATION; i++) {
+	    if (protocols[i].name_length == name_length &&
+		memcmp (protocols[i].name, name, (int) name_length) == 0)
+	    {
+		return (*protocols[i].Check) (data_length, data, client, reason);
+	    }
+	    *reason = "Protocol not supported by server\n";
+	}
+    } else *reason = "No protocol specified\n";
+    return (XID) ~0L;
+}
+
+void
+ResetAuthorization (void)
+{
+    int	i;
+
+    for (i = 0; i < NUM_AUTHORIZATION; i++)
+	if (protocols[i].Reset)
+	    (*protocols[i].Reset)();
+    ShouldLoadAuth = TRUE;
+}
+
+XID
+AuthorizationToID (
+	unsigned short	name_length,
+	char		*name,
+	unsigned short	data_length,
+	char		*data)
+{
+    int	i;
+
+    for (i = 0; i < NUM_AUTHORIZATION; i++) {
+    	if (protocols[i].name_length == name_length &&
+	    memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+	    protocols[i].ToID)
+    	{
+	    return (*protocols[i].ToID) (data_length, data);
+    	}
+    }
+    return (XID) ~0L;
+}
+
+int
+AuthorizationFromID (
+	XID 		id,
+	unsigned short	*name_lenp,
+	char		**namep,
+	unsigned short	*data_lenp,
+	char		**datap)
+{
+    int	i;
+
+    for (i = 0; i < NUM_AUTHORIZATION; i++) {
+	if (protocols[i].FromID &&
+	    (*protocols[i].FromID) (id, data_lenp, datap)) {
+	    *name_lenp = protocols[i].name_length;
+	    *namep = protocols[i].name;
+	    return 1;
+	}
+    }
+    return 0;
+}
+
+int
+RemoveAuthorization (
+	unsigned short	name_length,
+	char		*name,
+	unsigned short	data_length,
+	char		*data)
+{
+    int	i;
+
+    for (i = 0; i < NUM_AUTHORIZATION; i++) {
+    	if (protocols[i].name_length == name_length &&
+	    memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+	    protocols[i].Remove)
+    	{
+	    return (*protocols[i].Remove) (data_length, data);
+    	}
+    }
+    return 0;
+}
+
+int
+AddAuthorization (unsigned name_length, char *name, unsigned data_length, char *data)
+{
+    int	i;
+
+    for (i = 0; i < NUM_AUTHORIZATION; i++) {
+    	if (protocols[i].name_length == name_length &&
+	    memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+	    protocols[i].Add)
+    	{
+	    return (*protocols[i].Add) (data_length, data, FakeClientID(0));
+    	}
+    }
+    return 0;
+}
+
+#ifdef SUNSOFT
+/* This function is called from dtlogin.c 
+ * This is added to do "chmod authorization_file" since
+ * this file is owned by root and we need to change this
+ * to user logged on.  
+ */
+const char *
+GetAuthFilename(void)
+{
+    return (authorization_file);
+}
+#endif
+
+#ifdef XCSECURITY
+
+XID
+GenerateAuthorization(
+	unsigned name_length,
+	char	*name,
+	unsigned data_length,
+	char	*data,
+	unsigned *data_length_return,
+	char	**data_return)
+{
+    int	i;
+
+    for (i = 0; i < NUM_AUTHORIZATION; i++) {
+    	if (protocols[i].name_length == name_length &&
+	    memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+	    protocols[i].Generate)
+    	{
+	    return (*protocols[i].Generate) (data_length, data,
+			FakeClientID(0), data_length_return, data_return);
+    	}
+    }
+    return -1;
+}
+
+/* A random number generator that is more unpredictable
+   than that shipped with some systems.
+   This code is taken from the C standard. */
+
+static unsigned long int next = 1;
+
+static int
+xdm_rand(void)
+{
+    next = next * 1103515245 + 12345;
+    return (unsigned int)(next/65536) % 32768;
+}
+
+static void
+xdm_srand(unsigned int seed)
+{
+    next = seed;
+}
+
+void
+GenerateRandomData (int len, char *buf)
+{
+    static int seed;
+    int value;
+    int i;
+
+    seed += GetTimeInMillis();
+    xdm_srand (seed);
+    for (i = 0; i < len; i++)
+    {
+	value = xdm_rand ();
+	buf[i] ^= (value & 0xff00) >> 8;
+    }
+
+    /* XXX add getrusage, popen("ps -ale") */
+}
+
+#endif /* XCSECURITY */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/os/connection.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1434 @@
+/* $Xorg: connection.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 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 1987, 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 2006 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.
+ */ 
+
+/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.64 2003/10/07 22:50:42 herrb Exp $ */
+/*****************************************************************
+ *  Stuff to create connections --- OS dependent
+ *
+ *      EstablishNewConnections, CreateWellKnownSockets, ResetWellKnownSockets,
+ *      CloseDownConnection, CheckConnections, AddEnabledDevice,
+ *	RemoveEnabledDevice, OnlyListToOneClient,
+ *      ListenToAllClients,
+ *
+ *      (WaitForSomething is in its own file)
+ *
+ *      In this implementation, a client socket table is not kept.
+ *      Instead, what would be the index into the table is just the
+ *      file descriptor of the socket.  This won't work for if the
+ *      socket ids aren't small nums (0 - 2^8)
+ *
+ *****************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef WIN32
+#if defined(Lynx)
+#include <socket.h>
+#else
+#include <sys/socket.h>
+#endif
+
+#ifdef hpux
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#endif
+
+#if defined(DGUX)
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/param.h>
+#include <unistd.h>
+#endif
+
+
+#ifdef AIXV3
+#include <sys/ioctl.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+extern __const__ int _nfiles;
+#endif
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# if !defined(hpux)
+#  ifdef apollo
+#   ifndef NO_TCP_H
+#    include <netinet/tcp.h>
+#   endif
+#  else
+#   ifdef CSRG_BASED
+#    include <sys/param.h>
+#   endif
+#    ifndef __UNIXOS2__
+#     include <netinet/tcp.h>
+#    endif
+#  endif
+# endif
+# include <arpa/inet.h>
+#endif
+
+#if !defined(__UNIXOS2__)
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#endif
+#endif /* WIN32 */
+#include "misc.h"		/* for typedef of pointer */
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "opaque.h"
+#include "dixstruct.h"
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+#include "osdep.h"
+#endif
+
+#ifdef X_NOT_POSIX
+#define Pid_t int
+#else
+#define Pid_t pid_t
+#endif
+
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#endif /* DNETCONN */
+
+#ifdef SUNSOFT
+extern void DtloginInit(void);
+#endif /* SUNSOFT */
+
+int lastfdesc;			/* maximum file descriptor */
+
+fd_set WellKnownConnections;	/* Listener mask */
+fd_set EnabledDevices;		/* mask for input devices that are on */
+fd_set AllSockets;		/* select on this */
+fd_set AllClients;		/* available clients */
+fd_set LastSelectMask;		/* mask returned from last select call */
+fd_set ClientsWithInput;	/* clients with FULL requests in buffer */
+fd_set ClientsWriteBlocked;	/* clients who cannot receive output */
+fd_set OutputPending;		/* clients with reply/event data ready to go */
+int MaxClients = 0;
+Bool NewOutputPending;		/* not yet attempted to write some new output */
+Bool AnyClientsWriteBlocked;	/* true if some client blocked on write */
+
+Bool RunFromSmartParent;	/* send SIGUSR1 to parent process */
+Bool PartialNetwork;		/* continue even if unable to bind all addrs */
+static Pid_t ParentProcess;
+#ifdef __UNIXOS2__
+Pid_t GetPPID(Pid_t pid);
+#endif
+
+static Bool debug_conns = FALSE;
+
+fd_set IgnoredClientsWithInput;
+static fd_set GrabImperviousClients;
+static fd_set SavedAllClients;
+static fd_set SavedAllSockets;
+static fd_set SavedClientsWithInput;
+int GrabInProgress = 0;
+
+#if !defined(WIN32)
+int *ConnectionTranslation = NULL;
+#else
+/*
+ * On NT fds are not between 0 and MAXSOCKS, they are unrelated, and there is
+ * not even a known maximum value, so use something quite arbitrary for now.
+ * Do storage is a hash table of size 256. Collisions are handled in a linked
+ * list.
+ */
+
+#undef MAXSOCKS
+#define MAXSOCKS 500
+#undef MAXSELECT
+#define MAXSELECT 500
+#define MAXFD 500
+
+struct _ct_node {
+    struct _ct_node *next;
+    int key;
+    int value;
+};
+
+struct _ct_node *ct_head[256];
+
+void InitConnectionTranslation(void)
+{
+    bzero(ct_head, sizeof(ct_head));
+}
+
+int GetConnectionTranslation(int conn)
+{
+    struct _ct_node *node = ct_head[conn & 0xff];
+    while (node != NULL)
+    {
+        if (node->key == conn)
+            return node->value;
+        node = node->next;
+    }
+    return 0;
+}
+
+void SetConnectionTranslation(int conn, int client)
+{
+    struct _ct_node **node = ct_head + (conn & 0xff);
+    if (client == 0) /* remove entry */
+    {
+        while (*node != NULL)
+        {
+            if ((*node)->key == conn)
+            {
+                struct _ct_node *temp = *node;
+                *node = (*node)->next;
+                free(temp);
+                return;
+            }
+            node = &((*node)->next);
+        }
+        return;
+    } else 
+    {
+        while (*node != NULL)
+        {
+            if ((*node)->key == conn)
+            {
+                (*node)->value = client;
+                return;
+            }
+            node = &((*node)->next);
+        }
+        *node = (struct _ct_node*)xalloc(sizeof(struct _ct_node));
+        (*node)->next = NULL;
+        (*node)->key = conn;
+        (*node)->value = client;
+        return;
+    }
+}
+
+void ClearConnectionTranslation(void)
+{
+    unsigned i;
+    for (i = 0; i < 256; i++)
+    {
+        struct _ct_node *node = ct_head[i];
+        while (node != NULL)
+        {
+            struct _ct_node *temp = node;
+            node = node->next;
+            xfree(temp);
+        }
+    }
+}
+#endif
+
+XtransConnInfo 	*ListenTransConns = NULL;
+int	       	*ListenTransFds = NULL;
+int		ListenTransCount;
+
+static void ErrorConnMax(XtransConnInfo /* trans_conn */);
+
+#ifdef TSOL
+#include "extnsionst.h"
+extern SecurityHookPtr pSecHook;
+#endif /* TSOL */
+
+#ifndef LBX
+static
+void CloseDownFileDescriptor(
+    OsCommPtr /*oc*/
+);
+#endif
+
+
+static XtransConnInfo
+lookup_trans_conn (int fd)
+{
+    if (ListenTransFds)
+    {
+	int i;
+	for (i = 0; i < ListenTransCount; i++)
+	    if (ListenTransFds[i] == fd)
+		return ListenTransConns[i];
+    }
+
+    return (NULL);
+}
+
+/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
+
+void
+InitConnectionLimits(void)
+{
+    lastfdesc = -1;
+
+#ifndef __CYGWIN__
+
+#ifndef __UNIXOS2__
+
+#if !defined(XNO_SYSCONF) && defined(_SC_OPEN_MAX)
+    lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
+#endif
+
+#ifdef HAS_GETDTABLESIZE
+    if (lastfdesc < 0)
+	lastfdesc = getdtablesize() - 1;
+#endif
+
+#ifdef _NFILE
+    if (lastfdesc < 0)
+	lastfdesc = _NFILE - 1;
+#endif
+
+#else /* __UNIXOS2__ */
+    lastfdesc = _nfiles - 1;
+#endif
+
+#endif /* __CYGWIN__ */
+
+    /* This is the fallback */
+    if (lastfdesc < 0)
+	lastfdesc = MAXSOCKS;
+
+    if (lastfdesc > MAXSELECT)
+	lastfdesc = MAXSELECT;
+
+    if (lastfdesc > MAXCLIENTS)
+    {
+	lastfdesc = MAXCLIENTS;
+	if (debug_conns)
+	    ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
+    }
+    MaxClients = lastfdesc;
+
+#ifdef DEBUG
+    ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients);
+#endif
+
+#if !defined(WIN32)
+    ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
+#else
+    InitConnectionTranslation();
+#endif
+}
+
+
+/*****************
+ * CreateWellKnownSockets
+ *    At initialization, create the sockets to listen on for new clients.
+ *****************/
+
+void
+CreateWellKnownSockets(void)
+{
+    int		i;
+    int		partial;
+    char 	port[20];
+    OsSigHandlerPtr handler;
+
+    FD_ZERO(&AllSockets);
+    FD_ZERO(&AllClients);
+    FD_ZERO(&LastSelectMask);
+    FD_ZERO(&ClientsWithInput);
+
+#if !defined(WIN32)
+    for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
+#else
+    ClearConnectionTranslation();
+#endif
+
+    FD_ZERO (&WellKnownConnections);
+
+    sprintf (port, "%d", atoi (display));
+
+    if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
+	&ListenTransCount, &ListenTransConns) >= 0) &&
+	(ListenTransCount >= 1))
+    {
+	if (!PartialNetwork && partial)
+	{
+	    FatalError ("Failed to establish all listening sockets");
+	}
+	else
+	{
+	    ListenTransFds = (int *) xalloc (ListenTransCount * sizeof (int));
+
+	    for (i = 0; i < ListenTransCount; i++)
+	    {
+		int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+		
+		ListenTransFds[i] = fd;
+		FD_SET (fd, &WellKnownConnections);
+
+		if (!_XSERVTransIsLocal (ListenTransConns[i]))
+		{
+		    DefineSelf (fd);
+		}
+	    }
+	}
+    }
+
+    if (!XFD_ANYSET (&WellKnownConnections))
+        FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running");
+#if !defined(WIN32)
+    OsSignal (SIGPIPE, SIG_IGN);
+    OsSignal (SIGHUP, AutoResetServer);
+#endif
+    OsSignal (SIGINT, GiveUp);
+    OsSignal (SIGTERM, GiveUp);
+    XFD_COPYSET (&WellKnownConnections, &AllSockets);
+    ResetHosts(display);
+    /*
+     * Magic:  If SIGUSR1 was set to SIG_IGN when
+     * the server started, assume that either
+     *
+     *  a- The parent process is ignoring SIGUSR1
+     *
+     * or
+     *
+     *  b- The parent process is expecting a SIGUSR1
+     *     when the server is ready to accept connections
+     *
+     * In the first case, the signal will be harmless,
+     * in the second case, the signal will be quite
+     * useful
+     */
+#if !defined(WIN32)
+    handler = OsSignal (SIGUSR1, SIG_IGN);
+    if ( handler == SIG_IGN)
+	RunFromSmartParent = TRUE;
+    OsSignal(SIGUSR1, handler);
+    ParentProcess = getppid ();
+#ifdef __UNIXOS2__
+    /*
+     * fg030505: under OS/2, xinit is not the parent process but
+     * the "grant parent" process of the server because execvpe()
+     * presents us an additional process number;
+     * GetPPID(pid) is part of libemxfix
+     */
+    ParentProcess = GetPPID (ParentProcess);
+#endif /* __UNIXOS2__ */
+#ifdef SUNSOFT
+    /* Create pipe for dtlogin authentication info before we tell dtlogin 
+       we're done and ready for it to run. */
+    DtloginInit ();
+#endif
+    if (RunFromSmartParent) {
+	if (ParentProcess > 1) {
+	    kill (ParentProcess, SIGUSR1);
+	}
+    }
+#endif
+#ifdef XDMCP
+    XdmcpInit ();
+#endif
+}
+
+void
+ResetWellKnownSockets (void)
+{
+    int i;
+
+    ResetOsBuffers();
+
+    for (i = 0; i < ListenTransCount; i++)
+    {
+	int status = _XSERVTransResetListener (ListenTransConns[i]);
+
+	if (status != TRANS_RESET_NOOP)
+	{
+	    if (status == TRANS_RESET_FAILURE)
+	    {
+		/*
+		 * ListenTransConns[i] freed by xtrans.
+		 * Remove it from out list.
+		 */
+
+		FD_CLR (ListenTransFds[i], &WellKnownConnections);
+		ListenTransFds[i] = ListenTransFds[ListenTransCount - 1];
+		ListenTransConns[i] = ListenTransConns[ListenTransCount - 1];
+		ListenTransCount -= 1;
+		i -= 1;
+	    }
+	    else if (status == TRANS_RESET_NEW_FD)
+	    {
+		/*
+		 * A new file descriptor was allocated (the old one was closed)
+		 */
+
+		int newfd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+
+		FD_CLR (ListenTransFds[i], &WellKnownConnections);
+		ListenTransFds[i] = newfd;
+		FD_SET(newfd, &WellKnownConnections);
+	    }
+	}
+    }
+
+    ResetAuthorization ();
+    ResetHosts(display);
+    /*
+     * See above in CreateWellKnownSockets about SIGUSR1
+     */
+#if !defined(WIN32)
+    if (RunFromSmartParent) {
+	if (ParentProcess > 1) {
+	    kill (ParentProcess, SIGUSR1);
+	}
+    }
+#endif
+    /*
+     * restart XDMCP
+     */
+#ifdef XDMCP
+    XdmcpReset ();
+#endif
+}
+
+void
+CloseWellKnownConnections(void)
+{
+    int i;
+
+    for (i = 0; i < ListenTransCount; i++)
+	_XSERVTransClose (ListenTransConns[i]);
+}
+
+static void
+AuthAudit (ClientPtr client, Bool letin, 
+    struct sockaddr *saddr, int len, 
+    unsigned int proto_n, char *auth_proto, int auth_id)
+{
+    char addr[128];
+    char *out = addr;
+
+    if (!((OsCommPtr)client->osPrivate)->trans_conn) {
+	strcpy(addr, "LBX proxy at ");
+	out += strlen(addr);
+    }
+    if (!len)
+        strcpy(out, "local host");
+    else
+	switch (saddr->sa_family)
+	{
+	case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+	case AF_UNIX:
+#endif
+	    strcpy(out, "local host");
+	    break;
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+	case AF_INET:
+	    sprintf(out, "IP %s",
+		inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
+	    break;
+#if defined(IPv6) && defined(AF_INET6)
+	case AF_INET6: {
+	    char ipaddr[INET6_ADDRSTRLEN];
+	    inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr,
+	      ipaddr, sizeof(ipaddr));
+	    sprintf(out, "IP %s", ipaddr);
+	}
+	    break;
+#endif
+#endif
+#ifdef DNETCONN
+	case AF_DECnet:
+	    sprintf(out, "DN %s",
+		    dnet_ntoa(&((struct sockaddr_dn *) saddr)->sdn_add));
+	    break;
+#endif
+	default:
+	    strcpy(out, "unknown address");
+	}
+    
+    if (proto_n)
+	AuditF("client %d %s from %s\n  Auth name: %.*s ID: %d\n", 
+	       client->index, letin ? "connected" : "rejected", addr,
+	       (int)proto_n, auth_proto, auth_id);
+    else 
+	AuditF("client %d %s from %s\n", 
+	       client->index, letin ? "connected" : "rejected", addr);
+}
+
+XID
+AuthorizationIDOfClient(ClientPtr client)
+{
+    if (client->osPrivate)
+	return ((OsCommPtr)client->osPrivate)->auth_id;
+    else
+	return None;
+}
+
+
+/*****************************************************************
+ * ClientAuthorized
+ *
+ *    Sent by the client at connection setup:
+ *                typedef struct _xConnClientPrefix {
+ *                   CARD8	byteOrder;
+ *                   BYTE	pad;
+ *                   CARD16	majorVersion, minorVersion;
+ *                   CARD16	nbytesAuthProto;    
+ *                   CARD16	nbytesAuthString;   
+ *                 } xConnClientPrefix;
+ *
+ *     	It is hoped that eventually one protocol will be agreed upon.  In the
+ *        mean time, a server that implements a different protocol than the
+ *        client expects, or a server that only implements the host-based
+ *        mechanism, will simply ignore this information.
+ *
+ *****************************************************************/
+
+char * 
+ClientAuthorized(ClientPtr client, 
+    unsigned int proto_n, char *auth_proto, 
+    unsigned int string_n, char *auth_string)
+{
+    OsCommPtr 		priv;
+    Xtransaddr		*from = NULL;
+    int 		family;
+    int			fromlen;
+    XID	 		auth_id;
+    char	 	*reason = NULL;
+    XtransConnInfo	trans_conn;
+    int			restore_trans_conn = 0;
+    ClientPtr           lbxpc = NULL;
+
+    priv = (OsCommPtr)client->osPrivate;
+    trans_conn = priv->trans_conn;
+
+#ifdef LBX
+    if (!trans_conn) {
+	/*
+	 * Since trans_conn is NULL, this must be a proxy's client for
+	 * which we have NO address.  Therefore, we will temporarily
+	 * set the client's trans_conn to the proxy's trans_conn and
+	 * after CheckAuthorization the client's trans_conn will be
+	 * restored. 
+	 *
+	 * If XDM-AUTHORIZATION-1 is being used, CheckAuthorization
+	 * will eventually call XdmAuthorizationValidate and this
+	 * later function may use the client's trans_conn to get the 
+	 * client's address.  Since a XDM-AUTH-1 auth string includes 
+	 * the client's address, this address is compared to the address 
+	 * in the client's trans_conn.  If the proxy and client are 
+	 * on the same host, the comparison will fail; otherwise the
+	 * comparison will fail and the client will not be authorized
+	 * to connect to the server.
+	 *
+	 * The basis for this additional code is to prevent a
+	 * NULL pointer dereference of the client's trans_conn.
+	 * The fundamental problem - the fact that the client's
+	 * trans_conn is NULL - is because the NewClient
+	 * request in version 1.0 of the LBX protocol does not
+	 * send the client's address to the server.  When the
+	 * spec is changed and the client's address is sent to
+	 * server in the NewClient request, this additional code
+	 * should be removed.
+	 *
+	 * See defect number XWSog08218 for more information.
+	 */
+	lbxpc = LbxProxyClient(priv->proxy);
+	trans_conn = ((OsCommPtr)lbxpc->osPrivate)->trans_conn;
+        priv->trans_conn = trans_conn;
+	restore_trans_conn = 1;
+    }
+#endif
+
+#ifdef TSOL
+    if (pSecHook)
+	auth_id = (*pSecHook->CheckAuthorization) (proto_n, auth_proto,
+                                  string_n, auth_string, client, &reason);
+    else
+#endif /* TSOL */
+     	auth_id = CheckAuthorization (proto_n, auth_proto,
+                                  string_n, auth_string, client, &reason);
+
+#ifdef LBX
+    if (! priv->trans_conn) {
+	if (auth_id == (XID) ~0L && !GetAccessControl())
+	    auth_id = ((OsCommPtr)lbxpc->osPrivate)->auth_id;
+#ifdef XCSECURITY
+	else if (auth_id != (XID) ~0L && !SecuritySameLevel(lbxpc, auth_id)) {
+	    auth_id = (XID) ~0L;
+	    reason = "Client trust level differs from that of LBX Proxy";
+	}
+#endif
+    }
+#endif
+    if (auth_id == (XID) ~0L)
+    {
+	if (
+#ifdef XCSECURITY	    
+	    (proto_n == 0 ||
+	    strncmp (auth_proto, XSecurityAuthorizationName, proto_n) != 0) &&
+#endif
+	    _XSERVTransGetPeerAddr (trans_conn,
+	        &family, &fromlen, &from) != -1)
+	{
+	    if (
+#ifdef LBX
+		!trans_conn ||
+#endif
+		InvalidHost ((struct sockaddr *) from, fromlen, client))
+		AuthAudit(client, FALSE, (struct sockaddr *) from,
+			  fromlen, proto_n, auth_proto, auth_id);
+	    else
+	    {
+		auth_id = (XID) 0;
+		if (auditTrailLevel > 1)
+		    AuthAudit(client, TRUE,
+			(struct sockaddr *) from, fromlen,
+			proto_n, auth_proto, auth_id);
+	    }
+
+	    xfree ((char *) from);
+	}
+
+	if (auth_id == (XID) ~0L) {
+#ifdef LBX
+	  /*
+	   * Restore client's trans_conn state
+	   */
+	  if (restore_trans_conn) {
+		priv->trans_conn = NULL;
+	  }
+#endif
+	    if (reason)
+		return reason;
+	    else
+		return "Client is not authorized to connect to Server";
+	}
+    }
+    else if (auditTrailLevel > 1)
+    {
+	if (_XSERVTransGetPeerAddr (trans_conn,
+	    &family, &fromlen, &from) != -1)
+	{
+	    AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
+		      proto_n, auth_proto, auth_id);
+
+	    xfree ((char *) from);
+	}
+    }
+    priv->auth_id = auth_id;
+    priv->conn_time = 0;
+
+#ifdef XDMCP
+    /* indicate to Xdmcp protocol that we've opened new client */
+    XdmcpOpenDisplay(priv->fd);
+#endif /* XDMCP */
+#ifdef XAPPGROUP
+    if (ClientStateCallback)
+        XagCallClientStateChange (client);
+#endif
+    /* At this point, if the client is authorized to change the access control
+     * list, we should getpeername() information, and add the client to
+     * the selfhosts list.  It's not really the host machine, but the
+     * true purpose of the selfhosts list is to see who may change the
+     * access control list.
+     */
+#ifdef LBX
+     if (restore_trans_conn) {
+	priv->trans_conn = NULL;
+     }
+#endif
+    return((char *)NULL);
+}
+
+static ClientPtr
+#ifdef LBX
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time, 
+    int (*Flush)(
+        ClientPtr /*who*/, OsCommPtr /*oc*/,
+        char * /*extraBuf*/, int /*extraCount*/),
+    void (*Close)(
+        ClientPtr /*client*/),
+    LbxProxyPtr proxy)
+#else
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
+#endif
+{
+    OsCommPtr	oc;
+    ClientPtr	client;
+    
+    if (
+#ifdef LBX
+	trans_conn &&
+#endif
+#ifndef WIN32
+	fd >= lastfdesc
+#else
+	XFD_SETCOUNT(&AllClients) >= MaxClients
+#endif
+	)
+	return NullClient;
+    oc = (OsCommPtr)xalloc(sizeof(OsCommRec));
+    if (!oc)
+	return NullClient;
+    oc->trans_conn = trans_conn;
+    oc->fd = fd;
+    oc->input = (ConnectionInputPtr)NULL;
+    oc->output = (ConnectionOutputPtr)NULL;
+    oc->auth_id = None;
+    oc->conn_time = conn_time;
+#ifdef LBX
+    oc->proxy = proxy;
+    oc->Flush = Flush;
+    oc->Close = Close;
+    oc->largereq = (ConnectionInputPtr) NULL;
+#endif
+    if (!(client = NextAvailableClient((pointer)oc)))
+    {
+	xfree (oc);
+	return NullClient;
+    }
+#ifdef LBX
+    if (trans_conn)
+#endif
+    {
+#if !defined(WIN32)
+	ConnectionTranslation[fd] = client->index;
+#else
+	SetConnectionTranslation(fd, client->index);
+#endif
+	if (GrabInProgress)
+	{
+	    FD_SET(fd, &SavedAllClients);
+	    FD_SET(fd, &SavedAllSockets);
+	}
+	else
+	{
+	    FD_SET(fd, &AllClients);
+	    FD_SET(fd, &AllSockets);
+	}
+    }
+
+#ifdef DEBUG
+    ErrorF("AllocNewConnection: client index = %d, socket fd = %d\n",
+	   client->index, fd);
+#endif
+
+    return client;
+}
+
+#ifdef LBX
+
+int
+ClientConnectionNumber (ClientPtr client)
+{
+    OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+    return oc->fd;
+}
+
+ClientPtr
+AllocLbxClientConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+    OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+    return AllocNewConnection ((XtransConnInfo)NULL, oc->fd, GetTimeInMillis(),
+			       LbxFlushClient, LbxCloseClient, proxy);
+}
+
+void
+LbxProxyConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+    OsCommPtr	oc = (OsCommPtr) client->osPrivate;
+
+    FlushClient(client, oc, (char *)NULL, 0);
+    oc->proxy = proxy;
+    oc->Flush = LbxFlushClient;
+    oc->Close = LbxCloseClient;
+    LbxPrimeInput(client, proxy);
+}
+
+#endif
+
+/*****************
+ * EstablishNewConnections
+ *    If anyone is waiting on listened sockets, accept them.
+ *    Returns a mask with indices of new clients.  Updates AllClients
+ *    and AllSockets.
+ *****************/
+
+/*ARGSUSED*/
+Bool
+EstablishNewConnections(ClientPtr clientUnused, pointer closure)
+{
+    fd_set  readyconnections;     /* set of listeners that are ready */
+    int curconn;                  /* fd of listener that's ready */
+    register int newconn;         /* fd of new client */
+    CARD32 connect_time;
+    register int i;
+    register ClientPtr client;
+    register OsCommPtr oc;
+    fd_set tmask;
+
+    XFD_ANDSET (&tmask, (fd_set*)closure, &WellKnownConnections);
+    XFD_COPYSET(&tmask, &readyconnections);
+    if (!XFD_ANYSET(&readyconnections))
+	return TRUE;
+    connect_time = GetTimeInMillis();
+    /* kill off stragglers */
+    for (i=1; i<currentMaxClients; i++)
+    {
+	if ((client = clients[i]))
+	{
+	    oc = (OsCommPtr)(client->osPrivate);
+	    if ((oc && (oc->conn_time != 0) &&
+		(connect_time - oc->conn_time) >= TimeOutValue) || 
+		(client->noClientException != Success && !client->clientGone))
+		CloseDownClient(client);     
+	}
+    }
+#ifndef WIN32
+    for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++)
+    {
+      while (readyconnections.fds_bits[i])
+#else
+      for (i = 0; i < XFD_SETCOUNT(&readyconnections); i++) 
+#endif
+      {
+	XtransConnInfo trans_conn, new_trans_conn;
+	int status;
+
+#ifndef WIN32
+	curconn = ffs (readyconnections.fds_bits[i]) - 1;
+	readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
+	curconn += (i * (sizeof(fd_mask)*8));
+#else
+	curconn = XFD_FD(&readyconnections, i);
+#endif
+
+	if ((trans_conn = lookup_trans_conn (curconn)) == NULL)
+	    continue;
+
+	if ((new_trans_conn = _XSERVTransAccept (trans_conn, &status)) == NULL)
+	    continue;
+
+	newconn = _XSERVTransGetConnectionNumber (new_trans_conn);
+
+	if (newconn < lastfdesc)
+	{
+		int clientid;
+#if !defined(WIN32)
+  		clientid = ConnectionTranslation[newconn];
+#else
+  		clientid = GetConnectionTranslation(newconn);
+#endif
+		if(clientid && (client = clients[clientid]))
+ 			CloseDownClient(client);
+	}
+
+	_XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
+
+	if (!AllocNewConnection (new_trans_conn, newconn, connect_time
+#ifdef LBX
+				 , StandardFlushClient,
+				 CloseDownFileDescriptor, (LbxProxyPtr)NULL
+#endif
+				))
+	{
+	    ErrorConnMax(new_trans_conn);
+	    _XSERVTransClose(new_trans_conn);
+	}
+      }
+#ifndef WIN32
+    }
+#endif
+    return TRUE;
+}
+
+#define NOROOM "Maximum number of clients reached"
+
+/************
+ *   ErrorConnMax
+ *     Fail a connection due to lack of client or file descriptor space
+ ************/
+
+static void
+ErrorConnMax(XtransConnInfo trans_conn)
+{
+    int fd = _XSERVTransGetConnectionNumber (trans_conn);
+    xConnSetupPrefix csp;
+    char pad[3];
+    struct iovec iov[3];
+    char byteOrder = 0;
+    int whichbyte = 1;
+    struct timeval waittime;
+    fd_set mask;
+
+    /* if these seems like a lot of trouble to go to, it probably is */
+    waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND;
+    waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) *
+		       (1000000 / MILLI_PER_SECOND);
+    FD_ZERO(&mask);
+    FD_SET(fd, &mask);
+    (void)Select(fd + 1, &mask, NULL, NULL, &waittime);
+    /* try to read the byte-order of the connection */
+    (void)_XSERVTransRead(trans_conn, &byteOrder, 1);
+    if ((byteOrder == 'l') || (byteOrder == 'B'))
+    {
+	csp.success = xFalse;
+	csp.lengthReason = sizeof(NOROOM) - 1;
+	csp.length = (sizeof(NOROOM) + 2) >> 2;
+	csp.majorVersion = X_PROTOCOL;
+	csp.minorVersion = X_PROTOCOL_REVISION;
+	if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
+	    (!(*(char *) &whichbyte) && (byteOrder == 'l')))
+	{
+	    swaps(&csp.majorVersion, whichbyte);
+	    swaps(&csp.minorVersion, whichbyte);
+	    swaps(&csp.length, whichbyte);
+	}
+	iov[0].iov_len = sz_xConnSetupPrefix;
+	iov[0].iov_base = (char *) &csp;
+	iov[1].iov_len = csp.lengthReason;
+	iov[1].iov_base = NOROOM;
+	iov[2].iov_len = (4 - (csp.lengthReason & 3)) & 3;
+	iov[2].iov_base = pad;
+	(void)_XSERVTransWritev(trans_conn, iov, 3);
+    }
+}
+
+/************
+ *   CloseDownFileDescriptor:
+ *     Remove this file descriptor and it's I/O buffers, etc.
+ ************/
+
+#ifdef LBX
+void
+CloseDownFileDescriptor(ClientPtr client)
+#else
+static void
+CloseDownFileDescriptor(OsCommPtr oc)
+#endif
+{
+#ifdef LBX
+    OsCommPtr oc = (OsCommPtr) client->osPrivate;
+#endif
+    int connection = oc->fd;
+
+    if (oc->trans_conn) {
+	_XSERVTransDisconnect(oc->trans_conn);
+	_XSERVTransClose(oc->trans_conn);
+    }
+#ifndef LBX
+    FreeOsBuffers(oc);
+    xfree(oc);
+#endif
+#ifndef WIN32
+    ConnectionTranslation[connection] = 0;
+#else
+    SetConnectionTranslation(connection, 0);
+#endif    
+    FD_CLR(connection, &AllSockets);
+    FD_CLR(connection, &AllClients);
+    FD_CLR(connection, &ClientsWithInput);
+    FD_CLR(connection, &GrabImperviousClients);
+    if (GrabInProgress)
+    {
+	FD_CLR(connection, &SavedAllSockets);
+	FD_CLR(connection, &SavedAllClients);
+	FD_CLR(connection, &SavedClientsWithInput);
+    }
+    FD_CLR(connection, &ClientsWriteBlocked);
+    if (!XFD_ANYSET(&ClientsWriteBlocked))
+    	AnyClientsWriteBlocked = FALSE;
+    FD_CLR(connection, &OutputPending);
+}
+
+/*****************
+ * CheckConnections
+ *    Some connection has died, go find which one and shut it down 
+ *    The file descriptor has been closed, but is still in AllClients.
+ *    If would truly be wonderful if select() would put the bogus
+ *    file descriptors in the exception mask, but nooooo.  So we have
+ *    to check each and every socket individually.
+ *****************/
+
+void
+CheckConnections(void)
+{
+#ifndef WIN32
+    fd_mask		mask;
+#endif
+    fd_set		tmask; 
+    int			curclient, curoff;
+    int			i;
+    struct timeval	notime;
+    int r;
+#ifdef WIN32
+    fd_set savedAllClients;
+#endif
+
+    notime.tv_sec = 0;
+    notime.tv_usec = 0;
+
+#ifndef WIN32
+    for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
+    {
+	mask = AllClients.fds_bits[i];
+        while (mask)
+    	{
+	    curoff = ffs (mask) - 1;
+	    curclient = curoff + (i * (sizeof(fd_mask)*8));
+            FD_ZERO(&tmask);
+            FD_SET(curclient, &tmask);
+            r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+            if (r < 0)
+		CloseDownClient(clients[ConnectionTranslation[curclient]]);
+	    mask &= ~((fd_mask)1 << curoff);
+	}
+    }	
+#else
+    XFD_COPYSET(&AllClients, &savedAllClients);
+    for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++)
+    {
+	curclient = XFD_FD(&savedAllClients, i);
+	FD_ZERO(&tmask);
+	FD_SET(curclient, &tmask);
+	r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+	if (r < 0)
+	    CloseDownClient(clients[GetConnectionTranslation(curclient)]);
+    }	
+#endif
+}
+
+
+/*****************
+ * CloseDownConnection
+ *    Delete client from AllClients and free resources 
+ *****************/
+
+void
+CloseDownConnection(ClientPtr client)
+{
+    OsCommPtr oc = (OsCommPtr)client->osPrivate;
+
+    if (oc->output && oc->output->count)
+	FlushClient(client, oc, (char *)NULL, 0);
+#ifdef XDMCP
+    XdmcpCloseDisplay(oc->fd);
+#endif
+#ifndef LBX
+    CloseDownFileDescriptor(oc);
+#else
+    (*oc->Close) (client);
+    FreeOsBuffers(oc);
+    xfree(oc);
+#endif
+    client->osPrivate = (pointer)NULL;
+    if (auditTrailLevel > 1)
+	AuditF("client %d disconnected\n", client->index);
+}
+
+void
+AddEnabledDevice(int fd)
+{
+    FD_SET(fd, &EnabledDevices);
+    FD_SET(fd, &AllSockets);
+    if (GrabInProgress)
+	FD_SET(fd, &SavedAllSockets);
+}
+
+void
+RemoveEnabledDevice(int fd)
+{
+    FD_CLR(fd, &EnabledDevices);
+    FD_CLR(fd, &AllSockets);
+    if (GrabInProgress)
+	FD_CLR(fd, &SavedAllSockets);
+}
+
+/*****************
+ * OnlyListenToOneClient:
+ *    Only accept requests from  one client.  Continue to handle new
+ *    connections, but don't take any protocol requests from the new
+ *    ones.  Note that if GrabInProgress is set, EstablishNewConnections
+ *    needs to put new clients into SavedAllSockets and SavedAllClients.
+ *    Note also that there is no timeout for this in the protocol.
+ *    This routine is "undone" by ListenToAllClients()
+ *****************/
+
+void
+OnlyListenToOneClient(ClientPtr client)
+{
+    OsCommPtr oc = (OsCommPtr)client->osPrivate;
+    int connection = oc->fd;
+
+    if (! GrabInProgress)
+    {
+	XFD_COPYSET(&ClientsWithInput, &SavedClientsWithInput);
+	XFD_ANDSET(&ClientsWithInput,
+		       &ClientsWithInput, &GrabImperviousClients);
+	if (FD_ISSET(connection, &SavedClientsWithInput))
+	{
+	    FD_CLR(connection, &SavedClientsWithInput);
+	    FD_SET(connection, &ClientsWithInput);
+	}
+	XFD_UNSET(&SavedClientsWithInput, &GrabImperviousClients);
+	XFD_COPYSET(&AllSockets, &SavedAllSockets);
+	XFD_COPYSET(&AllClients, &SavedAllClients);
+	XFD_UNSET(&AllSockets, &AllClients);
+	XFD_ANDSET(&AllClients, &AllClients, &GrabImperviousClients);
+	FD_SET(connection, &AllClients);
+	XFD_ORSET(&AllSockets, &AllSockets, &AllClients);
+	GrabInProgress = client->index;
+    }
+}
+
+/****************
+ * ListenToAllClients:
+ *    Undoes OnlyListentToOneClient()
+ ****************/
+
+void
+ListenToAllClients(void)
+{
+    if (GrabInProgress)
+    {
+	XFD_ORSET(&AllSockets, &AllSockets, &SavedAllSockets);
+	XFD_ORSET(&AllClients, &AllClients, &SavedAllClients);
+	XFD_ORSET(&ClientsWithInput, &ClientsWithInput, &SavedClientsWithInput);
+	GrabInProgress = 0;
+    }	
+}
+
+/****************
+ * IgnoreClient
+ *    Removes one client from input masks.
+ *    Must have cooresponding call to AttendClient.
+ ****************/
+
+void
+IgnoreClient (ClientPtr client)
+{
+    OsCommPtr oc = (OsCommPtr)client->osPrivate;
+    int connection = oc->fd;
+#ifdef LBX
+    LbxClientPtr lbxClient = LbxClient(client);
+#endif
+
+    isItTimeToYield = TRUE;
+#ifdef LBX
+    if (lbxClient) {
+	lbxClient->ignored = TRUE;
+	return;
+    }
+#endif
+    if (!GrabInProgress || FD_ISSET(connection, &AllClients))
+    {
+    	if (FD_ISSET (connection, &ClientsWithInput))
+	    FD_SET(connection, &IgnoredClientsWithInput);
+    	else
+	    FD_CLR(connection, &IgnoredClientsWithInput);
+    	FD_CLR(connection, &ClientsWithInput);
+    	FD_CLR(connection, &AllSockets);
+    	FD_CLR(connection, &AllClients);
+	FD_CLR(connection, &LastSelectMask);
+    }
+    else
+    {
+    	if (FD_ISSET (connection, &SavedClientsWithInput))
+	    FD_SET(connection, &IgnoredClientsWithInput);
+    	else
+	    FD_CLR(connection, &IgnoredClientsWithInput);
+	FD_CLR(connection, &SavedClientsWithInput);
+	FD_CLR(connection, &SavedAllSockets);
+	FD_CLR(connection, &SavedAllClients);
+    }
+}
+
+/****************
+ * AttendClient
+ *    Adds one client back into the input masks.
+ ****************/
+
+void
+AttendClient (ClientPtr client)
+{
+    OsCommPtr oc = (OsCommPtr)client->osPrivate;
+    int connection = oc->fd;
+#ifdef LBX
+    LbxClientPtr lbxClient = LbxClient(client);
+
+    if (lbxClient) {
+	lbxClient->ignored = FALSE;
+	return;
+    }
+#endif
+    if (!GrabInProgress || GrabInProgress == client->index ||
+	FD_ISSET(connection, &GrabImperviousClients))
+    {
+    	FD_SET(connection, &AllClients);
+    	FD_SET(connection, &AllSockets);
+	FD_SET(connection, &LastSelectMask);
+    	if (FD_ISSET (connection, &IgnoredClientsWithInput))
+	    FD_SET(connection, &ClientsWithInput);
+    }
+    else
+    {
+	FD_SET(connection, &SavedAllClients);
+	FD_SET(connection, &SavedAllSockets);
+	if (FD_ISSET(connection, &IgnoredClientsWithInput))
+	    FD_SET(connection, &SavedClientsWithInput);
+    }
+}
+
+/* make client impervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabImpervious(ClientPtr client)
+{
+    OsCommPtr oc = (OsCommPtr)client->osPrivate;
+    int connection = oc->fd;
+
+    FD_SET(connection, &GrabImperviousClients);
+
+    if (ServerGrabCallback)
+    {
+	ServerGrabInfoRec grabinfo;
+	grabinfo.client = client;
+	grabinfo.grabstate  = CLIENT_IMPERVIOUS;
+	CallCallbacks(&ServerGrabCallback, &grabinfo);
+    }
+}
+
+/* make client pervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabPervious(ClientPtr client)
+{
+    OsCommPtr oc = (OsCommPtr)client->osPrivate;
+    int connection = oc->fd;
+
+    FD_CLR(connection, &GrabImperviousClients);
+    if (GrabInProgress && (GrabInProgress != client->index))
+    {
+	if (FD_ISSET(connection, &ClientsWithInput))
+	{
+	    FD_SET(connection, &SavedClientsWithInput);
+	    FD_CLR(connection, &ClientsWithInput);
+	}
+	FD_CLR(connection, &AllSockets);
+	FD_CLR(connection, &AllClients);
+	isItTimeToYield = TRUE;
+    }
+
+    if (ServerGrabCallback)
+    {
+	ServerGrabInfoRec grabinfo;
+	grabinfo.client = client;
+	grabinfo.grabstate  = CLIENT_PERVIOUS;
+	CallCallbacks(&ServerGrabCallback, &grabinfo);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/os/dtlogin.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,615 @@
+/* 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.
+ */
+
+#pragma ident "@(#)dtlogin.c	1.15	06/01/25   SMI" 
+
+/* Implementation of DTLogin to Xsun communication pipe.
+ * The Solaris Desktop Login process (dtlogin) will start 
+ * the X window server at system boot time before any user 
+ * has logged into the system.  The X server is by default 
+ * started as the root UID "0".
+ 
+ * At login time the Xserver local communication pipe is provided 
+ * by Xsun for user specific configuration data supplied 
+ * by DTLogin.  It notifies the Xserver it needs to change 
+ * over to the user's credentials (UID, GID, GID_LIST) and
+ * also switch CWD (current working directory) of to match 
+ * the user's CWD home.
+ * ASARC case 1995/390
+ */
+
+#include "Xos.h"
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "X.h"
+#include "Xmd.h"
+#include "misc.h"
+#include "Xpoll.h"
+#include "osdep.h"
+#include "input.h"
+#include "dixstruct.h"
+#include "dixfont.h"
+#include "opaque.h"
+#include <pwd.h>
+#include <project.h>
+#include <sys/task.h>
+#include <ctype.h>
+#include "scrnintstr.h"
+#ifndef XFree86Server
+#include "sunIo.h"
+#endif
+
+#define DTLOGIN_PATH "/var/dt/sdtlogin/"
+
+#define BUFLEN 1024
+
+uid_t	root_euid;
+
+extern char *display;
+
+/* in Xserver/os/auth.c */
+extern const char *GetAuthFilename(void);
+
+static int  dtloginSocket = -1;
+
+extern Bool noXkbExtension;
+extern int *argcGlobalP;
+extern char ***argvGlobalP;
+
+static void DtloginBlockHandler(pointer, struct timeval **, pointer);
+static void DtloginWakeupHandler(pointer, int, pointer);
+static int  dtlogin_create_pipe(int);
+static void dtlogin_receive_packet(void);
+static void dtlogin_close_pipe(void);
+
+#define DtloginError(str)	Error(str)
+#define DtloginFatal(str)	FatalError("%s\n", str)
+
+#ifdef XFree86Server
+# define DtloginInfo(fmt, arg)	LogMessageVerb(X_INFO, 5, fmt, arg)
+#elif defined(DEBUG)
+# define DtloginInfo(fmt, arg)	fprintf(stderr, fmt, arg)
+#else
+# define DtloginInfo(fmt, arg)	/* Do nothing */
+#endif
+
+/*
+ * initialize DTLOGIN: create pipe; set handlers.
+ * Called from CreateWellKnownSockets in os/connection.c
+ */
+
+void
+DtloginInit(void)
+{
+    int displayNumber = 0;
+
+    root_euid = geteuid();
+
+    if ( getuid() != 0 )  return;
+    displayNumber = atoi(display); /* Assigned in dix/main.c */
+
+    if (dtlogin_create_pipe(displayNumber)) 
+        RegisterBlockAndWakeupHandlers (DtloginBlockHandler, 
+            DtloginWakeupHandler, (pointer) 0);
+
+    return;
+}
+
+static void
+DtloginBlockHandler(data, wt, pReadmask)
+    pointer         data;   /* unused */
+    struct timeval  **wt;
+    pointer         pReadmask;
+{
+    fd_set *LastSelectMask = (fd_set*)pReadmask;
+
+    if ( dtloginSocket == -1 ) return;
+ 
+    FD_SET(dtloginSocket, LastSelectMask);
+}
+
+static void
+DtloginWakeupHandler(data, i, pReadmask)
+    pointer data;   /* unused */
+    int     i;
+    pointer pReadmask;
+{
+    fd_set* LastSelectMask = (fd_set*)pReadmask;
+
+    if ( dtloginSocket == -1 ) return;
+
+    if (i > 0)
+    {
+        if (FD_ISSET(dtloginSocket, LastSelectMask))
+        {
+            dtlogin_receive_packet();
+            FD_CLR(dtloginSocket, LastSelectMask);
+            dtlogin_close_pipe();
+        }
+    }
+}
+
+static int
+dtlogin_create_pipe( int port )
+{
+    struct stat statbuf;
+    char pipename[128];
+
+
+    if ( stat(DTLOGIN_PATH, &statbuf) < 0 ) /* No DTLOGIN_PATH */
+        return -1;
+
+    if ( (statbuf.st_mode & S_IFMT) != S_IFDIR )
+        return -1;  /* DTLOGIN_PATH is not a directory */
+
+    snprintf(pipename, sizeof(pipename), "%s%d", DTLOGIN_PATH, port );
+
+    if (mknod(pipename, S_IFIFO | S_IRUSR | S_IWUSR, 0 ) < 0 ) 
+        return -1;
+
+    /* To make sure root has rw permissions. */
+    (void) chmod(pipename, 0600);
+ 
+    if ((dtloginSocket = open(pipename, O_RDWR)) < 0 ) 
+        return -1;
+
+    return 1;
+}
+
+static void dtlogin_close_pipe(void)
+{
+    RemoveBlockAndWakeupHandlers (DtloginBlockHandler, 
+                     DtloginWakeupHandler,0);
+    close(dtloginSocket);
+    dtloginSocket = -1;
+}
+
+static void
+dtlogin_receive_packet(void)
+{
+    /* contains characters to be processed */
+    char *buf;
+
+    /* temporary vars */
+    char *s, *t, *tGID, *tUID, *tHOME, *tG_LIST_ID, *tEOF;
+    char *tXSERVERFLAGS;
+    int tokLen = 0;
+
+    int ctr = 0; int aposFlag = FALSE;
+    int testFlag = TRUE;
+    int testFlagUID, testFlagGID, testFlagHOME, testFlagEOF, testFlagG_LIST_ID;
+    int testFlagXSERVERFLAGS;
+
+    int uid, gid, gid_cnt = 0;
+    char *Home = NULL, *env_str = NULL;
+    const char *auth_file = NULL;
+    gid_t groupids[NGROUPS_UMAX];
+
+
+    int To = 0; int From = 0;
+
+    int notEvenOnce = TRUE;
+
+    buf = (char *) xalloc(BUFLEN);
+
+    while (1) {
+        if (s = (char *) strstr(buf, ";")) {
+            int l;
+
+            l = strlen(buf) - strlen(s);
+            
+            /* ; exists, get the token */
+            s = (char *) strtok(buf, ";");
+            t = (char *) strdup(s);
+
+            /* save stuff for next iteration */
+            strcpy(buf, buf + l + 1);
+        }
+        else {
+            t = (char *) NULL;
+        }
+
+        if (t) {
+            tokLen = strlen(t);  
+            testFlag = TRUE;
+            while (testFlag == TRUE) {
+                /* look for GID */
+                if (tGID = (char *) strstr(t, "GID=\"")) {
+    
+                    testFlagGID = TRUE;
+                    gid = atoi(tGID + 5);
+                    To = tokLen - strlen(tGID);
+    
+                    aposFlag = FALSE; ctr = 0;
+                    while (tGID[ctr]) {
+                        if (tGID[ctr] == '\"' && aposFlag == FALSE) {
+                            aposFlag = TRUE;
+                            ctr++;
+                            continue;
+                        }
+                        else if (tGID[ctr] == '\"' && aposFlag == TRUE) {
+                            ctr++;
+                            break;
+                        }
+                        ctr++;
+                    }
+                    /* printf("ctr=%d\n", ctr); */
+                    From = To + ctr;
+                    strcpy(t + To, t + From);
+    
+                    /* update tokLen */
+                    tokLen -= ctr;
+                }
+                else
+                    testFlagGID = FALSE;
+   
+                /* look for UID */
+                if (tUID = (char *) strstr(t, "UID=\"")) {
+                    testFlagUID = TRUE;
+                    uid =  atoi(tUID + 5);
+                    To = tokLen - strlen(tUID);
+    
+                    aposFlag = FALSE; ctr = 0;
+                    while (tUID[ctr]) {
+                        if (tUID[ctr] == '\"' && aposFlag == FALSE) {
+                            aposFlag = TRUE;
+                            ctr++;
+                            continue;
+                        }
+                        else if (tUID[ctr] == '\"' && aposFlag == TRUE) {
+                            ctr++;
+                            break;
+                        }
+                        ctr++;
+                    }
+                    /* printf("ctr=%d\n", ctr); */
+                    From = To + ctr;
+                    strcpy(t + To, t + From);
+  
+                    /* update tokLen */
+                    tokLen -= ctr;
+                }
+                else
+                    testFlagUID = FALSE;
+    
+                /* look for HOME */
+                if (tHOME = (char *) strstr(t, "HOME=\"")) {
+                    testFlagHOME = TRUE;
+                    Home = (char *) strdup(tHOME+6);
+                    To = tokLen - strlen(tHOME);
+    
+                    aposFlag = FALSE; ctr = 0;
+                    while (tHOME[ctr]) {
+                        if (tHOME[ctr] == '\"' && aposFlag == FALSE) {
+                            aposFlag = TRUE;
+                            ctr++;
+                            continue;
+                        }
+                        else if (tHOME[ctr] == '\"' && aposFlag == TRUE) {
+                            ctr++;
+                            break;
+                        }
+                        ctr++;
+                    }
+                    /* printf("ctr=%d\n", ctr); */
+                    Home[ctr-7] = '\0';
+                    From = To + ctr;
+                    strcpy(t + To, t + From);
+    
+                    /* update tokLen */
+                    tokLen -= ctr;
+                }
+                else
+                    testFlagHOME = FALSE;
+    
+                /* look for G_LIST_ID */
+                if (tG_LIST_ID = (char *) strstr(t, "G_LIST_ID=\"")) {
+                    testFlagG_LIST_ID = TRUE;
+                    groupids[gid_cnt++] = atoi(tG_LIST_ID + 11); 
+                    To = tokLen - strlen(tG_LIST_ID);
+    
+                    aposFlag = FALSE; ctr = 0;
+                    while (tG_LIST_ID[ctr]) {
+                        if (tG_LIST_ID[ctr] == '\"' && aposFlag == FALSE) {
+                            aposFlag = TRUE;
+                            ctr++;
+                            continue;
+                        }
+                        else if (tG_LIST_ID[ctr] == '\"' && aposFlag == TRUE) {
+                            ctr++;
+                            break;
+                        }
+                        ctr++;
+                    }
+                    /* printf("ctr=%d\n", ctr); */
+                        From = To + ctr;
+                        strcpy(t + To, t + From);
+    
+                        /* update tokLen */
+                        tokLen -= ctr;
+		}
+		else
+		    testFlagG_LIST_ID = FALSE;
+
+                /* look for XSERVERFLAGS */
+                if (tXSERVERFLAGS = (char *) strstr(t, "XSERVERFLAGS=\"")) {
+		    int spaces = 0, content = 0;
+                    testFlagXSERVERFLAGS = TRUE;
+
+                    To = tokLen - strlen(tXSERVERFLAGS);
+    
+                    aposFlag = FALSE; ctr = 0;
+                    while (tXSERVERFLAGS[ctr]) {
+                        if (tXSERVERFLAGS[ctr] == '\"' && aposFlag == FALSE) {
+                            aposFlag = TRUE;
+                            ctr++;
+                            continue;
+                        }
+                        else if (aposFlag == TRUE) {
+			    if (tXSERVERFLAGS[ctr] == '\"') {
+				ctr++;
+				break;
+			    }
+			    else if (isspace(tXSERVERFLAGS[ctr])) {
+				spaces++;
+			    } 
+			    else {
+				content++;
+			    }
+			}		      
+                        ctr++;
+                    }
+
+#if 0
+		    if (content > 0) {
+			char **newArgv = (char **) xalloc(sizeof(char *) * 
+			  (argcGlobal + spaces + 3));
+			int i, j, k, fpset, fpcount, fplength;
+			unsigned char *fpes;
+			char *fp, *curfp;
+			int needToRestart;
+
+			for (i = 0; i < argcGlobal; i++) {
+			    newArgv[i] = argvGlobal[i];
+			}
+			content = 0;
+			for (ctr = 14; tXSERVERFLAGS[ctr] != 0; ctr++) {
+			    if (isspace(tXSERVERFLAGS[ctr]) ||
+				tXSERVERFLAGS[ctr] == '\"') {
+				if (content != 0) {
+				    newArgv[i] 
+				      = (char *) xalloc(ctr-content+1);
+				    memcpy(newArgv[i], &tXSERVERFLAGS[content],
+				      ctr-content);
+				    newArgv[i][ctr-content] = 0;
+				    i++;
+				}
+				if (tXSERVERFLAGS[ctr] == '\"') {
+				    break;
+				}
+				content = 0;
+			    } else if (content == 0) {
+				content = ctr;
+			    }
+			}
+
+			/* Check through new arguments to see if we can skip
+			   resetting the server */
+			needToRestart = FALSE;
+			for (j = argcGlobal; 
+			     (j < i) && (needToRestart == FALSE); j++) {
+
+			    if ((strcmp(newArgv[j], "-defdepth") == 0) &&
+			        ((j + 1) < i) ) {
+				/* Don't need to restart if setting default
+				   depth to the current default depth. */
+				int newDepthArg = atoi(newArgv[++j]);
+
+				for (k=0; k < screenInfo.numScreens; k++) {
+				    ScreenPtr pScreen = screenInfo.screens[k];
+
+				    if (pScreen->rootDepth != newDepthArg) {
+					needToRestart = TRUE;
+				    }
+
+				}				    
+			    } else if (strcmp(newArgv[j], "+kb") == 0) {
+				if (noXkbExtension) {
+				    needToRestart = TRUE;
+				}
+			    } else if (strcmp(newArgv[j], "-kb") == 0) {
+				if (!noXkbExtension) {
+				    needToRestart = TRUE;
+				}
+			    } else {
+			    /* Unrecognized argument, assume restart needed */
+				needToRestart = TRUE;
+			    }
+			}
+
+			if (needToRestart == TRUE) {
+			    /* Make sure to preserve font path since locale
+			     * specific fonts have already been added and if
+			     * we don't preserve them, they are lost. (4809632)
+			     */
+			    fpes = GetFontPath(&fpcount,&fplength);
+			    fp = malloc(fplength + fpcount + 1);
+			    curfp = fp;
+			    for (j = 0; j < fpcount ; j++) {
+				unsigned int fpe_length = (unsigned int) *fpes;
+				memcpy(curfp, fpes + 1, fpe_length);
+				fpes += fpe_length + 1;
+				curfp += fpe_length;
+				*curfp++ = ',';
+			    }
+			    *(curfp - 1) = 0;
+			    for (j = 0, fpset = 0; (j < i - 1) && !fpset ; j++)
+			    {
+				if (strcmp(newArgv[j], "-fp") == 0) {
+				    newArgv[j+1] = fp;
+				    fpset = 1;
+				}
+			    }
+			    if (!fpset) {
+				newArgv[i++] = strdup("-fp");
+				newArgv[i++] = fp;
+			    }
+			    newArgv[i] = NULL;
+			    argvGlobal = *argvGlobalP = newArgv;
+			    argcGlobal = *argcGlobalP = i;
+			    dispatchException |= DE_RESET;
+			} else {
+			    for (j = argcGlobal; (j < i); j++) {
+				free(newArgv[j]);
+			    }
+			    free(newArgv);
+			}
+		    }
+#endif
+                    /* printf("ctr=%d\n", ctr); */
+                    From = To + ctr;
+                    strcpy(t + To, t + From);
+    
+                    /* update tokLen */
+                    tokLen -= ctr;
+
+                }
+                else
+                    testFlagXSERVERFLAGS = FALSE;
+
+    
+                    /* look for EOF */
+                    if (tEOF = (char *) strstr(t, "EOF=\"")) {
+			struct project proj;
+			char proj_buf[PROJECT_BUFSZ];
+                        struct passwd *ppasswd;
+
+                        testFlagEOF = TRUE;
+
+                        env_str = (char *) xalloc (strlen(Home)+strlen("HOME=") + 1);
+
+                        if ( !env_str )
+                            DtloginFatal("Not enough memory");  
+                                /* Memory error */
+ 
+                        auth_file = GetAuthFilename();
+
+                        if (auth_file)
+                            if (chown((const char*)auth_file, uid, gid) < 0)
+                                DtloginError("Error in changing owner");
+
+			/* This gid dance is necessary in order to make sure
+			   our "saved-set-gid" is 0 so that we can regain gid
+			   0 when necessary for priocntl & power management.
+			   The first step sets rgid to the user's gid and 
+			   makes the egid & saved-gid be 0.  The second then
+			   sets the egid to the users gid, but leaves the
+			   saved-gid as 0.  */
+
+			DtloginInfo("Setting gid to %d\n", gid);
+                        if ( setregid(gid,0) < 0 )
+                            DtloginError("Error in setting regid");
+
+                        if ( setegid(gid) < 0 )
+                            DtloginError("Error in setting egid");
+
+                        if ( setgroups(gid_cnt, groupids) < 0 )
+                            DtloginError("Error in setting groups");
+
+			/*
+			 * BUG: 4462531: Set project ID for Xserver
+			 *               Get user name and default project.
+			 *               Set before the uid value is set.
+			 */
+			ppasswd = getpwuid(uid);
+			if ( ppasswd == NULL)
+			    DtloginError("Error in getting user name");
+			if ( getdefaultproj(ppasswd->pw_name, &proj, 
+                                            (void *)&proj_buf, 
+                                            PROJECT_BUFSZ) == NULL)
+			    DtloginError("Error in getting project id");
+
+			DtloginInfo("Setting project to %s\n", proj.pj_name);
+                        if ( setproject(proj.pj_name, ppasswd->pw_name, 
+                                        TASK_NORMAL) == -1)
+			    DtloginError("Error in setting project");
+
+			DtloginInfo("Setting uid to %d\n", uid);
+                        if ( setreuid(uid,uid) < 0 )
+                            DtloginError("Error in setting uid");
+
+                        sprintf(env_str, "%s=%s", "HOME", Home);
+			DtloginInfo("Setting %s\n",env_str);
+
+                        if ( putenv(env_str) < 0 )
+                            DtloginError("Error in setting HOME");  
+
+                        if ( chdir(Home) < 0 )
+                            DtloginError("Error in changing working directory");  
+
+                        xfree(buf);
+                        return;
+			/* exit from program */
+                    }
+                    else
+                        testFlagEOF = FALSE;
+
+                    testFlag = testFlagGID | testFlagUID | testFlagHOME 
+                        | testFlagG_LIST_ID | testFlagEOF;
+                }
+            }
+        else {
+            /* We didn't find ;, so get more data! */
+            int bufLen, nbRead;
+            static int totalLen = BUFLEN;
+
+            bufLen = strlen(buf);
+            notEvenOnce = TRUE;
+
+
+	    /*
+	     * Realloc only if buf has filled up and we don't have a record
+             * delimiter yet. Keep track of alloced size.
+             */
+
+            if (bufLen > totalLen/2) {
+                buf = (char *) xrealloc(buf, bufLen + BUFLEN);
+                totalLen += BUFLEN;
+            }
+            memset(buf + bufLen, '\0', totalLen - bufLen);
+            nbRead = read(dtloginSocket, buf + bufLen, totalLen - bufLen);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/os/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/08 SMI"
+XCOMM
+
+XCOMM Add VENDOR_DEFINES so we get -DSUNSOFT and other Sun-specific definitions
+    EXTRA_DEFINES = $(VENDOR_DEFINES)
+
+/* Add dtlogin.c for dtlogin authentication information pipe */
+#define OtherSources dtlogin.c
+#define OtherObjects dtlogin.o
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/os/utils.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2255 @@
+/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.17 2005/06/09 02:29:42 ajax Exp $ */
+/* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 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,
+Copyright 1994 Quarterdeck Office Systems.
+
+                        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 and
+Quarterdeck not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+DIGITAL AND QUARTERDECK DISCLAIM 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/programs/Xserver/os/utils.c,v 3.96 2004/01/07 04:16:37 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef __CYGWIN__
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/Xos.h>
+#include <stdio.h>
+#include "misc.h"
+#include <X11/X.h>
+#include <X11/Xtrans/Xtrans.h>
+#include "input.h"
+#include "dixfont.h"
+#include "osdep.h"
+#ifdef X_POSIX_C_SOURCE
+#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+#include <signal.h>
+#undef _POSIX_C_SOURCE
+#else
+#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
+#include <signal.h>
+#else
+#define _POSIX_SOURCE
+#include <signal.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef WIN32
+#include <sys/wait.h>
+#endif
+#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4)
+#include <sys/resource.h>
+#endif
+#include <time.h>
+#include <sys/stat.h>
+#include <ctype.h>    /* for isspace */
+#include <stdarg.h>
+
+#if defined(DGUX)
+#include <sys/resource.h>
+#include <netdb.h>
+#endif
+
+#include <stdlib.h>	/* for malloc() */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# ifndef WIN32
+#  include <netdb.h>
+# endif
+#endif
+
+#include "opaque.h"
+
+#ifdef SMART_SCHEDULE
+#include "dixstruct.h"
+#endif
+
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+#ifdef RENDER
+#include "picture.h"
+#endif
+
+#ifdef XPRINT
+#include "DiPrint.h"
+#endif
+
+Bool noTestExtensions;
+#ifdef BIGREQS
+Bool noBigReqExtension = FALSE;
+#endif
+#ifdef COMPOSITE
+/* COMPOSITE is disabled by default for now until the
+ * interface is stable */
+Bool noCompositeExtension = TRUE;
+#endif
+#ifdef DAMAGE
+Bool noDamageExtension = FALSE;
+#endif
+#ifdef DBE
+Bool noDbeExtension = FALSE;
+#endif
+#ifdef DPSEXT
+Bool noDPSExtension = FALSE;
+#endif
+#ifdef DPMSExtension
+Bool noDPMSExtension = FALSE;
+#endif
+#ifdef EVI
+Bool noEVIExtension = FALSE;
+#endif
+#ifdef FONTCACHE
+Bool noFontCacheExtension = FALSE;
+#endif
+#ifdef GLXEXT
+Bool noGlxExtension = FALSE;
+#endif
+#ifdef LBX
+Bool noLbxExtension = FALSE;
+#endif
+#ifdef SCREENSAVER
+Bool noScreenSaverExtension = FALSE;
+#endif
+#ifdef MITSHM
+Bool noMITShmExtension = FALSE;
+#endif
+#ifdef MITMISC
+Bool noMITMiscExtension = FALSE;
+#endif
+#ifdef MULTIBUFFER
+Bool noMultibufferExtension = FALSE;
+#endif
+#ifdef RANDR
+Bool noRRExtension = FALSE;
+#endif
+#ifdef RENDER
+Bool noRenderExtension = FALSE;
+#endif
+#ifdef SHAPE
+Bool noShapeExtension = FALSE;
+#endif
+#ifdef XCSECURITY
+Bool noSecurityExtension = FALSE;
+#endif
+#ifdef XSYNC
+Bool noSyncExtension = FALSE;
+#endif
+#ifdef TOGCUP
+Bool noXcupExtension = FALSE;
+#endif
+#ifdef RES
+Bool noResExtension = FALSE;
+#endif
+#ifdef XAPPGROUP
+Bool noXagExtension = FALSE;
+#endif
+#ifdef XCMISC
+Bool noXCMiscExtension = FALSE;
+#endif
+#ifdef XEVIE
+# ifdef SUNSOFT
+/* Enable XEvIE by default on Solaris builds */
+Bool noXevieExtension = FALSE;
+# else
+/* Xevie is disabled by default for now until the
+ * interface is stable */
+Bool noXevieExtension = TRUE;
+# endif /* SUNSOFT */
+#endif
+#ifdef XF86BIGFONT
+Bool noXFree86BigfontExtension = FALSE;
+#endif
+#ifdef XFreeXDGA
+Bool noXFree86DGAExtension = FALSE;
+#endif
+#ifdef XF86DRI
+Bool noXFree86DRIExtension = FALSE;
+#endif
+#ifdef XF86MISC
+Bool noXFree86MiscExtension = FALSE;
+#endif
+#ifdef XF86VIDMODE
+Bool noXFree86VidModeExtension = FALSE;
+#endif
+#ifdef XFIXES
+Bool noXFixesExtension = FALSE;
+#endif
+/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
+#ifdef PANORAMIX
+/* Xinerama is disabled by default unless enabled via +xinerama */
+Bool noPanoramiXExtension = TRUE;
+#endif
+#ifdef XINPUT
+Bool noXInputExtension = FALSE;
+#endif
+#ifdef XIDLE
+Bool noXIdleExtension = FALSE;
+#endif
+#ifdef XV
+Bool noXvExtension = FALSE;
+#endif
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#include <errno.h>
+
+Bool CoreDump;
+
+#ifdef PANORAMIX
+Bool PanoramiXVisibilityNotifySent = FALSE;
+Bool PanoramiXMapped = FALSE;
+Bool PanoramiXWindowExposureSent = FALSE;
+Bool PanoramiXOneExposeRequest = FALSE;
+Bool PanoramiXExtensionDisabledHack = FALSE;
+#endif
+
+int auditTrailLevel = 1;
+
+Bool Must_have_memory = FALSE;
+
+#ifdef AIXV3
+int SyncOn  = 0;
+extern int SelectWaitTime;
+#endif
+
+#ifdef DEBUG
+#ifndef SPECIAL_MALLOC
+#define MEMBUG
+#endif
+#endif
+
+#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
+#define HAS_SAVED_IDS_AND_SETEUID
+#endif
+
+#ifdef MEMBUG
+#define MEM_FAIL_SCALE 100000
+long Memory_fail = 0;
+#include <stdlib.h>  /* for random() */
+#endif
+
+#ifdef sgi
+int userdefinedfontpath = 0;
+#endif /* sgi */
+
+char *dev_tty_from_init = NULL;		/* since we need to parse it anyway */
+
+extern char dispatchExceptionAtReset;
+
+/* Extension enable/disable in miinitext.c */
+extern Bool EnableDisableExtension(char *name, Bool enable);
+extern void EnableDisableExtensionError(char *name, Bool enable);
+
+OsSigHandlerPtr
+OsSignal(sig, handler)
+    int sig;
+    OsSigHandlerPtr handler;
+{
+#ifdef X_NOT_POSIX
+    return signal(sig, handler);
+#else
+    struct sigaction act, oact;
+
+    sigemptyset(&act.sa_mask);
+    if (handler != SIG_IGN)
+	sigaddset(&act.sa_mask, sig);
+    act.sa_flags = 0;
+    act.sa_handler = handler;
+    sigaction(sig, &act, &oact);
+    return oact.sa_handler;
+#endif
+}
+	
+#ifdef SERVER_LOCK
+/*
+ * Explicit support for a server lock file like the ones used for UUCP.
+ * For architectures with virtual terminals that can run more than one
+ * server at a time.  This keeps the servers from stomping on each other
+ * if the user forgets to give them different display numbers.
+ */
+#ifndef __UNIXOS2__
+#define LOCK_DIR "/tmp"
+#endif
+#define LOCK_TMP_PREFIX "/.tX"
+#define LOCK_PREFIX "/.X"
+#define LOCK_SUFFIX "-lock"
+
+#if defined(DGUX)
+#include <limits.h>
+#include <sys/param.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define link rename
+#endif
+
+#ifndef PATH_MAX
+#ifndef Lynx
+#include <sys/param.h>
+#else
+#include <param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+static Bool StillLocking = FALSE;
+static char LockFile[PATH_MAX];
+static Bool nolock = FALSE;
+
+/*
+ * LockServer --
+ *      Check if the server lock file exists.  If so, check if the PID
+ *      contained inside is valid.  If so, then die.  Otherwise, create
+ *      the lock file containing the PID.
+ */
+void
+LockServer(void)
+{
+  char tmp[PATH_MAX], pid_str[12];
+  int lfd, i, haslock, l_pid, t;
+  char *tmppath = NULL;
+  int len;
+  char port[20];
+
+  if (nolock) return;
+  /*
+   * Path names
+   */
+#ifndef __UNIXOS2__
+  tmppath = LOCK_DIR;
+#else
+  /* OS/2 uses TMP directory, must also prepare for 8.3 names */
+  tmppath = getenv("TMP");
+  if (!tmppath)
+    FatalError("No TMP dir found\n");
+#endif
+
+  sprintf(port, "%d", atoi(display));
+  len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
+						strlen(LOCK_TMP_PREFIX);
+  len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
+  if (len > sizeof(LockFile))
+    FatalError("Display name `%s' is too long\n", port);
+  (void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+  (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+
+  /*
+   * Create a temporary file containing our PID.  Attempt three times
+   * to create the file.
+   */
+  StillLocking = TRUE;
+  i = 0;
+  do {
+    i++;
+    lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+    if (lfd < 0)
+       sleep(2);
+    else
+       break;
+  } while (i < 3);
+  if (lfd < 0) {
+    unlink(tmp);
+    i = 0;
+    do {
+      i++;
+      lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+      if (lfd < 0)
+         sleep(2);
+      else
+         break;
+    } while (i < 3);
+  }
+  if (lfd < 0)
+    FatalError("Could not create lock file in %s\n", tmp);
+  (void) sprintf(pid_str, "%10ld\n", (long)getpid());
+  (void) write(lfd, pid_str, 11);
+#ifndef __UNIXOS2__
+#ifndef USE_CHMOD
+  (void) fchmod(lfd, 0444);
+#else
+  (void) chmod(tmp, 0444);
+#endif
+#endif
+  (void) close(lfd);
+
+  /*
+   * OK.  Now the tmp file exists.  Try three times to move it in place
+   * for the lock.
+   */
+  i = 0;
+  haslock = 0;
+  while ((!haslock) && (i++ < 3)) {
+    haslock = (link(tmp,LockFile) == 0);
+    if (haslock) {
+      /*
+       * We're done.
+       */
+      break;
+    }
+    else {
+      /*
+       * Read the pid from the existing file
+       */
+      lfd = open(LockFile, O_RDONLY);
+      if (lfd < 0) {
+        unlink(tmp);
+        FatalError("Can't read lock file %s\n", LockFile);
+      }
+      pid_str[0] = '\0';
+      if (read(lfd, pid_str, 11) != 11) {
+        /*
+         * Bogus lock file.
+         */
+        unlink(LockFile);
+        close(lfd);
+        continue;
+      }
+      pid_str[11] = '\0';
+      sscanf(pid_str, "%d", &l_pid);
+      close(lfd);
+
+      /*
+       * Now try to kill the PID to see if it exists.
+       */
+      errno = 0;
+      t = kill(l_pid, 0);
+      if ((t< 0) && (errno == ESRCH)) {
+        /*
+         * Stale lock file.
+         */
+        unlink(LockFile);
+        continue;
+      }
+      else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
+        /*
+         * Process is still active.
+         */
+        unlink(tmp);
+	FatalError("Server is already active for display %s\n%s %s\n%s\n",
+		   port, "\tIf this server is no longer running, remove",
+		   LockFile, "\tand start again.");
+      }
+    }
+  }
+  unlink(tmp);
+  if (!haslock)
+    FatalError("Could not create server lock file: %s\n", LockFile);
+  StillLocking = FALSE;
+}
+
+/*
+ * UnlockServer --
+ *      Remove the server lock file.
+ */
+void
+UnlockServer(void)
+{
+  if (nolock) return;
+
+  if (!StillLocking){
+
+#ifdef __UNIXOS2__
+  (void) chmod(LockFile,S_IREAD|S_IWRITE);
+#endif /* __UNIXOS2__ */
+  (void) unlink(LockFile);
+  }
+}
+#endif /* SERVER_LOCK */
+
+/* Force connections to close on SIGHUP from init */
+
+/*ARGSUSED*/
+SIGVAL
+AutoResetServer (int sig)
+{
+    int olderrno = errno;
+
+    dispatchException |= DE_RESET;
+    isItTimeToYield = TRUE;
+#ifdef GPROF
+    chdir ("/tmp");
+    exit (0);
+#endif
+#if defined(SYSV) && defined(X_NOT_POSIX)
+    OsSignal (SIGHUP, AutoResetServer);
+#endif
+    errno = olderrno;
+}
+
+/* Force connections to close and then exit on SIGTERM, SIGINT */
+
+/*ARGSUSED*/
+SIGVAL
+GiveUp(int sig)
+{
+    int olderrno = errno;
+
+    dispatchException |= DE_TERMINATE;
+    isItTimeToYield = TRUE;
+#if defined(SYSV) && defined(X_NOT_POSIX)
+    if (sig)
+	OsSignal(sig, SIG_IGN);
+#endif
+    errno = olderrno;
+}
+
+#ifndef DDXTIME
+CARD32
+GetTimeInMillis(void)
+{
+    struct timeval  tp;
+
+    X_GETTIMEOFDAY(&tp);
+    return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
+
+void
+AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
+{
+    static struct timeval   delay_val;
+    struct timeval	    **wt = (struct timeval **) waitTime;
+    unsigned long	    olddelay;
+
+    if (*wt == NULL)
+    {
+	delay_val.tv_sec = newdelay / 1000;
+	delay_val.tv_usec = 1000 * (newdelay % 1000);
+	*wt = &delay_val;
+    }
+    else
+    {
+	olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000;
+	if (newdelay < olddelay)
+	{
+	    (*wt)->tv_sec = newdelay / 1000;
+	    (*wt)->tv_usec = 1000 * (newdelay % 1000);
+	}
+    }
+}
+
+void UseMsg(void)
+{
+#if !defined(AIXrt) && !defined(AIX386)
+    ErrorF("use: X [:<display>] [option]\n");
+    ErrorF("-a #                   mouse acceleration (pixels)\n");
+    ErrorF("-ac                    disable access control restrictions\n");
+#ifdef MEMBUG
+    ErrorF("-alloc int             chance alloc should fail\n");
+#endif
+    ErrorF("-audit int             set audit trail level\n");	
+    ErrorF("-auth file             select authorization file\n");	
+    ErrorF("bc                     enable bug compatibility\n");
+    ErrorF("-br                    create root window with black background\n");
+    ErrorF("+bs                    enable any backing store support\n");
+    ErrorF("-bs                    disable any backing store support\n");
+    ErrorF("-c                     turns off key-click\n");
+    ErrorF("c #                    key-click volume (0-100)\n");
+    ErrorF("-cc int                default color visual class\n");
+    ErrorF("-co file               color database file\n");
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+    ErrorF("-config file           read options from file\n");
+#endif
+    ErrorF("-core                  generate core dump on fatal error\n");
+    ErrorF("-dpi int               screen resolution in dots per inch\n");
+#ifdef DPMSExtension
+    ErrorF("dpms                   enables VESA DPMS monitor control\n");
+    ErrorF("-dpms                  disables VESA DPMS monitor control\n");
+#endif
+    ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
+    ErrorF("-f #                   bell base (0-100)\n");
+    ErrorF("-fc string             cursor font\n");
+    ErrorF("-fn string             default font name\n");
+    ErrorF("-fp string             default font path\n");
+    ErrorF("-help                  prints message with these options\n");
+    ErrorF("-I                     ignore all remaining arguments\n");
+#ifdef RLIMIT_DATA
+    ErrorF("-ld int                limit data space to N Kb\n");
+#endif
+#ifdef RLIMIT_NOFILE
+    ErrorF("-lf int                limit number of open files to N\n");
+#endif
+#ifdef RLIMIT_STACK
+    ErrorF("-ls int                limit stack space to N Kb\n");
+#endif
+#ifndef SUNSOFT /* Not in Sun version as required by PSARC 2004/187 TCR */
+#ifdef SERVER_LOCK
+    ErrorF("-nolock                disable the locking mechanism\n");
+#endif
+#endif
+#ifndef NOLOGOHACK
+    ErrorF("-logo                  enable logo in screen saver\n");
+    ErrorF("nologo                 disable logo in screen saver\n");
+#endif
+    ErrorF("-nolisten string       don't listen on protocol\n");
+    ErrorF("-noreset               don't reset after last client exists\n");
+    ErrorF("-reset                 reset after last client exists\n");
+    ErrorF("-p #                   screen-saver pattern duration (minutes)\n");
+    ErrorF("-pn                    accept failure to listen on all ports\n");
+    ErrorF("-nopn                  reject failure to listen on all ports\n");
+    ErrorF("-r                     turns off auto-repeat\n");
+    ErrorF("r                      turns on auto-repeat \n");
+#ifdef RENDER
+    ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
+#endif
+    ErrorF("-s #                   screen-saver timeout (minutes)\n");
+#ifdef XCSECURITY
+    ErrorF("-sp file               security policy file\n");
+#endif
+#ifdef XPRINT
+    PrinterUseMsg();
+#endif
+    ErrorF("-su                    disable any save under support\n");
+    ErrorF("-t #                   mouse threshold (pixels)\n");
+    ErrorF("-terminate             terminate at server reset\n");
+    ErrorF("-to #                  connection time out\n");
+    ErrorF("-tst                   disable testing extensions\n");
+    ErrorF("ttyxx                  server started from init on /dev/ttyxx\n");
+    ErrorF("v                      video blanking for screen-saver\n");
+    ErrorF("-v                     screen-saver without video blanking\n");
+    ErrorF("-wm                    WhenMapped default backing-store\n");
+    ErrorF("-x string              loads named extension at init time \n");
+    ErrorF("-maxbigreqsize         set maximal bigrequest size \n");
+#ifdef PANORAMIX
+    ErrorF("+xinerama              Enable XINERAMA extension\n");
+    ErrorF("-xinerama              Disable XINERAMA extension\n");
+#endif
+#ifdef SMART_SCHEDULE
+    ErrorF("-dumbSched             Disable smart scheduling, enable old behavior\n");
+    ErrorF("-schedInterval int     Set scheduler interval in msec\n");
+#endif
+    ErrorF("+extension name        Enable extension\n");
+    ErrorF("-extension name        Disable extension\n");
+#ifdef XDMCP
+    XdmcpUseMsg();
+#endif
+#endif /* !AIXrt && ! AIX386 */
+#ifdef XKB
+    XkbUseMsg();
+#endif
+    ddxUseMsg();
+}
+
+/*  This function performs a rudimentary sanity check
+ *  on the display name passed in on the command-line,
+ *  since this string is used to generate filenames.
+ *  It is especially important that the display name
+ *  not contain a "/" and not start with a "-".
+ *                                            --kvajk
+ */
+static int 
+VerifyDisplayName(const char *d)
+{
+    if ( d == (char *)0 ) return( 0 );  /*  null  */
+    if ( *d == '\0' ) return( 0 );  /*  empty  */
+    if ( *d == '-' ) return( 0 );  /*  could be confused for an option  */
+    if ( *d == '.' ) return( 0 );  /*  must not equal "." or ".."  */
+    if ( strchr(d, '/') != (char *)0 ) return( 0 );  /*  very important!!!  */
+    return( 1 );
+}
+
+/*
+ * This function is responsible for doing initalisation of any global
+ * variables at an very early point of server startup (even before
+ * |ProcessCommandLine()|. 
+ */
+void InitGlobals(void)
+{
+    ddxInitGlobals();
+}
+
+
+/*
+ * This function parses the command line. Handles device-independent fields
+ * and allows ddx to handle additional fields.  It is not allowed to modify
+ * argc or any of the strings pointed to by argv.
+ */
+void
+ProcessCommandLine(int argc, char *argv[])
+{
+    int i, skip;
+
+    defaultKeyboardControl.autoRepeat = TRUE;
+
+#ifdef NO_PART_NET
+    PartialNetwork = FALSE;
+#else
+    PartialNetwork = TRUE;
+#endif
+
+    for ( i = 1; i < argc; i++ )
+    {
+	/* call ddx first, so it can peek/override if it wants */
+        if((skip = ddxProcessArgument(argc, argv, i)))
+	{
+	    i += (skip - 1);
+	}
+	else if(argv[i][0] ==  ':')  
+	{
+	    /* initialize display */
+	    display = argv[i];
+	    display++;
+            if( ! VerifyDisplayName( display ) ) {
+                ErrorF("Bad display name: %s\n", display);
+                UseMsg();
+		FatalError("Bad display name, exiting: %s\n", display);
+            }
+	}
+	else if ( strcmp( argv[i], "-a") == 0)
+	{
+	    if(++i < argc)
+	        defaultPointerControl.num = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-ac") == 0)
+	{
+	    defeatAccessControl = TRUE;
+	}
+#ifdef MEMBUG
+	else if ( strcmp( argv[i], "-alloc") == 0)
+	{
+	    if(++i < argc)
+	        Memory_fail = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+#endif
+	else if ( strcmp( argv[i], "-audit") == 0)
+	{
+	    if(++i < argc)
+	        auditTrailLevel = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-auth") == 0)
+	{
+	    if(++i < argc)
+	        InitAuthorization (argv[i]);
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "bc") == 0)
+	    permitOldBugs = TRUE;
+	else if ( strcmp( argv[i], "-br") == 0)
+	    blackRoot = TRUE;
+	else if ( strcmp( argv[i], "+bs") == 0)
+	    enableBackingStore = TRUE;
+	else if ( strcmp( argv[i], "-bs") == 0)
+	    disableBackingStore = TRUE;
+	else if ( strcmp( argv[i], "c") == 0)
+	{
+	    if(++i < argc)
+	        defaultKeyboardControl.click = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-c") == 0)
+	{
+	    defaultKeyboardControl.click = 0;
+	}
+	else if ( strcmp( argv[i], "-cc") == 0)
+	{
+	    if(++i < argc)
+	        defaultColorVisualClass = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-co") == 0)
+	{
+	    if(++i < argc)
+	        rgbPath = argv[i];
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-core") == 0)
+	    CoreDump = TRUE;
+	else if ( strcmp( argv[i], "-dpi") == 0)
+	{
+	    if(++i < argc)
+	        monitorResolution = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+#ifdef DPMSExtension
+	else if ( strcmp( argv[i], "dpms") == 0)
+	    DPMSEnabledSwitch = TRUE;
+	else if ( strcmp( argv[i], "-dpms") == 0)
+	    DPMSDisabledSwitch = TRUE;
+#endif
+	else if ( strcmp( argv[i], "-deferglyphs") == 0)
+	{
+	    if(++i >= argc || !ParseGlyphCachingMode(argv[i]))
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-f") == 0)
+	{
+	    if(++i < argc)
+	        defaultKeyboardControl.bell = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-fc") == 0)
+	{
+	    if(++i < argc)
+	        defaultCursorFont = argv[i];
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-fn") == 0)
+	{
+	    if(++i < argc)
+	        defaultTextFont = argv[i];
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-fp") == 0)
+	{
+	    if(++i < argc)
+	    {
+#ifdef sgi
+		userdefinedfontpath = 1;
+#endif /* sgi */
+	        defaultFontPath = argv[i];
+	    }
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-help") == 0)
+	{
+	    UseMsg();
+	    exit(0);
+	}
+#ifdef XKB
+        else if ( (skip=XkbProcessArguments(argc,argv,i))!=0 ) {
+	    if (skip>0)
+		 i+= skip-1;
+	    else UseMsg();
+	}
+#endif
+#ifdef RLIMIT_DATA
+	else if ( strcmp( argv[i], "-ld") == 0)
+	{
+	    if(++i < argc)
+	    {
+	        limitDataSpace = atoi(argv[i]);
+		if (limitDataSpace > 0)
+		    limitDataSpace *= 1024;
+	    }
+	    else
+		UseMsg();
+	}
+#endif
+#ifdef RLIMIT_NOFILE
+	else if ( strcmp( argv[i], "-lf") == 0)
+	{
+	    if(++i < argc)
+	        limitNoFile = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+#endif
+#ifdef RLIMIT_STACK
+	else if ( strcmp( argv[i], "-ls") == 0)
+	{
+	    if(++i < argc)
+	    {
+	        limitStackSpace = atoi(argv[i]);
+		if (limitStackSpace > 0)
+		    limitStackSpace *= 1024;
+	    }
+	    else
+		UseMsg();
+	}
+#endif
+#ifndef SUNSOFT /* Not in Sun version as required by PSARC 2004/187 TCR */
+#ifdef SERVER_LOCK
+	else if ( strcmp ( argv[i], "-nolock") == 0)
+	{
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+	  if (getuid() != 0)
+	    ErrorF("Warning: the -nolock option can only be used by root\n");
+	  else
+#endif
+	    nolock = TRUE;
+	}
+#endif
+#endif
+#ifdef SUNSOFT
+	else if ( strcmp( argv[i], "-nobanner") == 0)
+	{
+	  /* ignore - just maintaining compatibility with Xsun CLI */
+	}
+#endif
+#ifndef NOLOGOHACK
+	else if ( strcmp( argv[i], "-logo") == 0)
+	{
+	    logoScreenSaver = 1;
+	}
+	else if ( strcmp( argv[i], "nologo") == 0)
+	{
+	    logoScreenSaver = 0;
+	}
+#endif
+	else if ( strcmp( argv[i], "-nolisten") == 0)
+	{
+            if(++i < argc) {
+		if (_XSERVTransNoListen(argv[i])) 
+		    FatalError ("Failed to disable listen for %s transport",
+				argv[i]);
+	   } else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-noreset") == 0)
+	{
+	    dispatchExceptionAtReset = 0;
+	}
+	else if ( strcmp( argv[i], "-reset") == 0)
+	{
+	    dispatchExceptionAtReset = DE_RESET;
+	}
+	else if ( strcmp( argv[i], "-p") == 0)
+	{
+	    if(++i < argc)
+	        defaultScreenSaverInterval = ((CARD32)atoi(argv[i])) *
+					     MILLI_PER_MIN;
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-pn") == 0)
+	    PartialNetwork = TRUE;
+	else if ( strcmp( argv[i], "-nopn") == 0)
+	    PartialNetwork = FALSE;
+	else if ( strcmp( argv[i], "r") == 0)
+	    defaultKeyboardControl.autoRepeat = TRUE;
+	else if ( strcmp( argv[i], "-r") == 0)
+	    defaultKeyboardControl.autoRepeat = FALSE;
+	else if ( strcmp( argv[i], "-s") == 0)
+	{
+	    if(++i < argc)
+	        defaultScreenSaverTime = ((CARD32)atoi(argv[i])) *
+					 MILLI_PER_MIN;
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-su") == 0)
+	    disableSaveUnders = TRUE;
+	else if ( strcmp( argv[i], "-t") == 0)
+	{
+	    if(++i < argc)
+	        defaultPointerControl.threshold = atoi(argv[i]);
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-terminate") == 0)
+	{
+	    dispatchExceptionAtReset = DE_TERMINATE;
+	}
+	else if ( strcmp( argv[i], "-to") == 0)
+	{
+	    if(++i < argc)
+		TimeOutValue = ((CARD32)atoi(argv[i])) * MILLI_PER_SECOND;
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-tst") == 0)
+	{
+	    noTestExtensions = TRUE;
+	}
+	else if ( strcmp( argv[i], "v") == 0)
+	    defaultScreenSaverBlanking = PreferBlanking;
+	else if ( strcmp( argv[i], "-v") == 0)
+	    defaultScreenSaverBlanking = DontPreferBlanking;
+	else if ( strcmp( argv[i], "-wm") == 0)
+	    defaultBackingStore = WhenMapped;
+        else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
+             if(++i < argc) {
+                 long reqSizeArg = atol(argv[i]);
+
+                 /* Request size > 128MB does not make much sense... */
+                 if( reqSizeArg > 0L && reqSizeArg < 128L ) {
+                     maxBigRequestSize = (reqSizeArg * 1048576L) - 1L;
+                 }
+                 else
+                 {
+                     UseMsg();
+                 }
+             }
+             else
+             {
+                 UseMsg();
+             }
+         }
+#ifdef PANORAMIX
+	else if ( strcmp( argv[i], "+xinerama") == 0){
+	    noPanoramiXExtension = FALSE;
+	}
+	else if ( strcmp( argv[i], "-xinerama") == 0){
+	    noPanoramiXExtension = TRUE;
+	}
+	else if ( strcmp( argv[i], "-disablexineramaextension") == 0){
+	    PanoramiXExtensionDisabledHack = TRUE;
+	}
+#endif
+	else if ( strcmp( argv[i], "-x") == 0)
+	{
+	    if(++i >= argc)
+		UseMsg();
+	    /* For U**x, which doesn't support dynamic loading, there's nothing
+	     * to do when we see a -x.  Either the extension is linked in or
+	     * it isn't */
+	}
+	else if ( strcmp( argv[i], "-I") == 0)
+	{
+	    /* ignore all remaining arguments */
+	    break;
+	}
+	else if (strncmp (argv[i], "tty", 3) == 0)
+	{
+	    /* just in case any body is interested */
+	    dev_tty_from_init = argv[i];
+	}
+#ifdef XDMCP
+	else if ((skip = XdmcpOptions(argc, argv, i)) != i)
+	{
+	    i = skip - 1;
+	}
+#endif
+#ifdef XPRINT
+	else if ((skip = PrinterOptions(argc, argv, i)) != i)
+	{
+	    i = skip - 1;
+	}
+#endif
+#ifdef XCSECURITY
+	else if ((skip = XSecurityOptions(argc, argv, i)) != i)
+	{
+	    i = skip - 1;
+	}
+#endif
+#ifdef AIXV3
+        else if ( strcmp( argv[i], "-timeout") == 0)
+        {
+            if(++i < argc)
+                SelectWaitTime = atoi(argv[i]);
+            else
+                UseMsg();
+        }
+        else if ( strcmp( argv[i], "-sync") == 0)
+        {
+            SyncOn++;
+        }
+#endif
+#ifdef SMART_SCHEDULE
+	else if ( strcmp( argv[i], "-dumbSched") == 0)
+	{
+	    SmartScheduleDisable = TRUE;
+	}
+	else if ( strcmp( argv[i], "-schedInterval") == 0)
+	{
+	    if (++i < argc)
+	    {
+		SmartScheduleInterval = atoi(argv[i]);
+		SmartScheduleSlice = SmartScheduleInterval;
+	    }
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-schedMax") == 0)
+	{
+	    if (++i < argc)
+	    {
+		SmartScheduleMaxSlice = atoi(argv[i]);
+	    }
+	    else
+		UseMsg();
+	}
+#endif
+#ifdef RENDER
+	else if ( strcmp( argv[i], "-render" ) == 0)
+	{
+	    if (++i < argc)
+	    {
+		int policy = PictureParseCmapPolicy (argv[i]);
+
+		if (policy != PictureCmapPolicyInvalid)
+		    PictureCmapPolicy = policy;
+		else
+		    UseMsg ();
+	    }
+	    else
+		UseMsg ();
+	}
+#endif
+	else if ( strcmp( argv[i], "+extension") == 0)
+	{
+	    if (++i < argc)
+	    {
+		if (!EnableDisableExtension(argv[i], TRUE))
+		    EnableDisableExtensionError(argv[i], TRUE);
+	    }
+	    else
+		UseMsg();
+	}
+	else if ( strcmp( argv[i], "-extension") == 0)
+	{
+	    if (++i < argc)
+	    {
+		if (!EnableDisableExtension(argv[i], FALSE))
+		    EnableDisableExtensionError(argv[i], FALSE);
+	    }
+	    else
+		UseMsg();
+	}
+ 	else
+ 	{
+	    ErrorF("Unrecognized option: %s\n", argv[i]);
+	    UseMsg();
+	    FatalError("Unrecognized option: %s\n", argv[i]);
+        }
+    }
+}
+
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+static void
+InsertFileIntoCommandLine(
+    int *resargc, char ***resargv, 
+    int prefix_argc, char **prefix_argv,
+    char *filename, 
+    int suffix_argc, char **suffix_argv)
+{
+    struct stat     st;
+    FILE           *f;
+    char           *p;
+    char           *q;
+    int             insert_argc;
+    char           *buf;
+    int             len;
+    int             i;
+
+    f = fopen(filename, "r");
+    if (!f)
+	FatalError("Can't open option file %s\n", filename);
+
+    fstat(fileno(f), &st);
+
+    buf = (char *) xalloc((unsigned) st.st_size + 1);
+    if (!buf)
+	FatalError("Out of Memory\n");
+
+    len = fread(buf, 1, (unsigned) st.st_size, f);
+
+    fclose(f);
+
+    if (len < 0)
+	FatalError("Error reading option file %s\n", filename);
+
+    buf[len] = '\0';
+
+    p = buf;
+    q = buf;
+    insert_argc = 0;
+
+    while (*p)
+    {
+	while (isspace(*p))
+	    p++;
+	if (!*p)
+	    break;
+	if (*p == '#')
+	{
+	    while (*p && *p != '\n')
+		p++;
+	} else
+	{
+	    while (*p && !isspace(*p))
+		*q++ = *p++;
+	    /* Since p and q might still be pointing at the same place, we	 */
+	    /* need to step p over the whitespace now before we add the null.	 */
+	    if (*p)
+		p++;
+	    *q++ = '\0';
+	    insert_argc++;
+	}
+    }
+
+    buf = (char *) xrealloc(buf, q - buf);
+    if (!buf)
+	FatalError("Out of memory reallocing option buf\n");
+
+    *resargc = prefix_argc + insert_argc + suffix_argc;
+    *resargv = (char **) xalloc((*resargc + 1) * sizeof(char *));
+    if (!*resargv)
+	FatalError("Out of Memory\n");
+
+    memcpy(*resargv, prefix_argv, prefix_argc * sizeof(char *));
+
+    p = buf;
+    for (i = 0; i < insert_argc; i++)
+    {
+	(*resargv)[prefix_argc + i] = p;
+	p += strlen(p) + 1;
+    }
+
+    memcpy(*resargv + prefix_argc + insert_argc,
+	   suffix_argv, suffix_argc * sizeof(char *));
+
+    (*resargv)[*resargc] = NULL;
+} /* end InsertFileIntoCommandLine */
+
+
+void
+ExpandCommandLine(int *pargc, char ***pargv)
+{
+    int i;
+
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+    if (getuid() != geteuid())
+	return;
+#endif
+
+    for (i = 1; i < *pargc; i++)
+    {
+	if ( (0 == strcmp((*pargv)[i], "-config")) && (i < (*pargc - 1)) )
+	{
+	    InsertFileIntoCommandLine(pargc, pargv,
+					  i, *pargv,
+					  (*pargv)[i+1], /* filename */
+					  *pargc - i - 2, *pargv + i + 2);
+	    i--;
+	}
+    }
+} /* end ExpandCommandLine */
+#endif
+
+/* Implement a simple-minded font authorization scheme.  The authorization
+   name is "hp-hostname-1", the contents are simply the host name. */
+int
+set_font_authorizations(char **authorizations, int *authlen, pointer client)
+{
+#define AUTHORIZATION_NAME "hp-hostname-1"
+#if defined(TCPCONN) || defined(STREAMSCONN)
+    static char *result = NULL;
+    static char *p = NULL;
+
+    if (p == NULL)
+    {
+	char hname[1024], *hnameptr;
+	unsigned int len;
+#if defined(IPv6) && defined(AF_INET6)
+	struct addrinfo hints, *ai = NULL;
+#else
+	struct hostent *host;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+	_Xgethostbynameparams hparams;
+#endif
+#endif
+
+	gethostname(hname, 1024);
+#if defined(IPv6) && defined(AF_INET6)
+	bzero(&hints, sizeof(hints));
+	hints.ai_flags = AI_CANONNAME;
+	if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
+	    hnameptr = ai->ai_canonname;
+	} else {
+	    hnameptr = hname;
+	}
+#else
+	host = _XGethostbyname(hname, hparams);
+	if (host == NULL)
+	    hnameptr = hname;
+	else
+	    hnameptr = host->h_name;
+#endif
+
+	len = strlen(hnameptr) + 1;
+	result = xalloc(len + sizeof(AUTHORIZATION_NAME) + 4);
+
+	p = result;
+        *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
+        *p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
+        *p++ = (len) >> 8;
+        *p++ = (len & 0xff);
+
+	memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
+	p += sizeof(AUTHORIZATION_NAME);
+	memmove(p, hnameptr, len);
+	p += len;
+#if defined(IPv6) && defined(AF_INET6)
+	if (ai) {
+	    freeaddrinfo(ai);
+	}
+#endif
+    }
+    *authlen = p - result;
+    *authorizations = result;
+    return 1;
+#else /* TCPCONN */
+    return 0;
+#endif /* TCPCONN */
+}
+
+/* XALLOC -- X's internal memory allocator.  Why does it return unsigned
+ * long * instead of the more common char *?  Well, if you read K&R you'll
+ * see they say that alloc must return a pointer "suitable for conversion"
+ * to whatever type you really want.  In a full-blown generic allocator
+ * there's no way to solve the alignment problems without potentially
+ * wasting lots of space.  But we have a more limited problem. We know
+ * we're only ever returning pointers to structures which will have to
+ * be long word aligned.  So we are making a stronger guarantee.  It might
+ * have made sense to make Xalloc return char * to conform with people's
+ * expectations of malloc, but this makes lint happier.
+ */
+
+#ifndef INTERNAL_MALLOC
+
+void * 
+Xalloc(unsigned long amount)
+{
+    register pointer  ptr;
+	
+    if ((long)amount <= 0) {
+	return (unsigned long *)NULL;
+    }
+    /* aligned extra on long word boundary */
+    amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+#ifdef MEMBUG
+    if (!Must_have_memory && Memory_fail &&
+	((random() % MEM_FAIL_SCALE) < Memory_fail))
+	return (unsigned long *)NULL;
+#endif
+    if ((ptr = (pointer)malloc(amount))) {
+	return (unsigned long *)ptr;
+    }
+    if (Must_have_memory)
+	FatalError("Out of memory");
+    return (unsigned long *)NULL;
+}
+
+/*****************
+ * XNFalloc 
+ * "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFalloc(unsigned long amount)
+{
+    register pointer ptr;
+
+    if ((long)amount <= 0)
+    {
+        return (unsigned long *)NULL;
+    }
+    /* aligned extra on long word boundary */
+    amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+    ptr = (pointer)malloc(amount);
+    if (!ptr)
+    {
+        FatalError("Out of memory");
+    }
+    return ((unsigned long *)ptr);
+}
+
+/*****************
+ * Xcalloc
+ *****************/
+
+void *
+Xcalloc(unsigned long amount)
+{
+    unsigned long   *ret;
+
+    ret = Xalloc (amount);
+    if (ret)
+	bzero ((char *) ret, (int) amount);
+    return ret;
+}
+
+/*****************
+ * XNFcalloc
+ *****************/
+
+void *
+XNFcalloc(unsigned long amount)
+{
+    unsigned long   *ret;
+
+    ret = Xalloc (amount);
+    if (ret)
+	bzero ((char *) ret, (int) amount);
+    else if ((long)amount > 0)
+        FatalError("Out of memory");
+    return ret;
+}
+
+/*****************
+ * Xrealloc
+ *****************/
+
+void *
+Xrealloc(pointer ptr, unsigned long amount)
+{
+#ifdef MEMBUG
+    if (!Must_have_memory && Memory_fail &&
+	((random() % MEM_FAIL_SCALE) < Memory_fail))
+	return (unsigned long *)NULL;
+#endif
+    if ((long)amount <= 0)
+    {
+	if (ptr && !amount)
+	    free(ptr);
+	return (unsigned long *)NULL;
+    }
+    amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+    if (ptr)
+        ptr = (pointer)realloc((char *)ptr, amount);
+    else
+	ptr = (pointer)malloc(amount);
+    if (ptr)
+        return (unsigned long *)ptr;
+    if (Must_have_memory)
+	FatalError("Out of memory");
+    return (unsigned long *)NULL;
+}
+                    
+/*****************
+ * XNFrealloc 
+ * "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFrealloc(pointer ptr, unsigned long amount)
+{
+    if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL)
+    {
+	if ((long)amount > 0)
+            FatalError( "Out of memory" );
+    }
+    return ((unsigned long *)ptr);
+}
+
+/*****************
+ *  Xfree
+ *    calls free 
+ *****************/    
+
+void
+Xfree(pointer ptr)
+{
+    if (ptr)
+	free((char *)ptr); 
+}
+
+void
+OsInitAllocator (void)
+{
+#ifdef MEMBUG
+    static int	been_here;
+
+    /* Check the memory system after each generation */
+    if (been_here)
+	CheckMemory ();
+    else
+	been_here = 1;
+#endif
+}
+#endif /* !INTERNAL_MALLOC */
+
+
+char *
+Xstrdup(const char *s)
+{
+    char *sd;
+
+    if (s == NULL)
+	return NULL;
+
+    sd = (char *)Xalloc(strlen(s) + 1);
+    if (sd != NULL)
+	strcpy(sd, s);
+    return sd;
+}
+
+
+char *
+XNFstrdup(const char *s)
+{
+    char *sd;
+
+    if (s == NULL)
+	return NULL;
+
+    sd = (char *)XNFalloc(strlen(s) + 1);
+    strcpy(sd, s);
+    return sd;
+}
+
+#ifdef SMART_SCHEDULE
+
+unsigned long	SmartScheduleIdleCount;
+Bool		SmartScheduleIdle;
+Bool		SmartScheduleTimerStopped;
+
+#ifdef SIGVTALRM
+#define SMART_SCHEDULE_POSSIBLE
+#endif
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+#define SMART_SCHEDULE_SIGNAL		SIGALRM
+#define SMART_SCHEDULE_TIMER		ITIMER_REAL
+#endif
+
+static void
+SmartScheduleStopTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+    struct itimerval	timer;
+    
+    timer.it_interval.tv_sec = 0;
+    timer.it_interval.tv_usec = 0;
+    timer.it_value.tv_sec = 0;
+    timer.it_value.tv_usec = 0;
+    (void) setitimer (ITIMER_REAL, &timer, 0);
+    SmartScheduleTimerStopped = TRUE;
+#endif
+}
+
+Bool
+SmartScheduleStartTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+    struct itimerval	timer;
+    
+    SmartScheduleTimerStopped = FALSE;
+    timer.it_interval.tv_sec = 0;
+    timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
+    timer.it_value.tv_sec = 0;
+    timer.it_value.tv_usec = SmartScheduleInterval * 1000;
+    return setitimer (ITIMER_REAL, &timer, 0) >= 0;
+#endif
+    return FALSE;
+}
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+static void
+SmartScheduleTimer (int sig)
+{
+    int olderrno = errno;
+
+    SmartScheduleTime += SmartScheduleInterval;
+    if (SmartScheduleIdle)
+    {
+	SmartScheduleStopTimer ();
+    }
+    errno = olderrno;
+}
+#endif
+
+Bool
+SmartScheduleInit (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+    struct sigaction	act;
+
+    if (SmartScheduleDisable)
+	return TRUE;
+    
+    bzero ((char *) &act, sizeof(struct sigaction));
+
+    /* Set up the timer signal function */
+    act.sa_handler = SmartScheduleTimer;
+    sigemptyset (&act.sa_mask);
+    sigaddset (&act.sa_mask, SMART_SCHEDULE_SIGNAL);
+    if (sigaction (SMART_SCHEDULE_SIGNAL, &act, 0) < 0)
+    {
+	perror ("sigaction for smart scheduler");
+	return FALSE;
+    }
+    /* Set up the virtual timer */
+    if (!SmartScheduleStartTimer ())
+    {
+	perror ("scheduling timer");
+	return FALSE;
+    }
+    /* stop the timer and wait for WaitForSomething to start it */
+    SmartScheduleStopTimer ();
+    return TRUE;
+#else
+    return FALSE;
+#endif
+}
+#endif
+
+#ifdef SIG_BLOCK
+static sigset_t	PreviousSignalMask;
+static int	BlockedSignalCount;
+#endif
+
+void
+OsBlockSignals (void)
+{
+#ifdef SIG_BLOCK
+    if (BlockedSignalCount++ == 0)
+    {
+	sigset_t    set;
+	
+	sigemptyset (&set);
+#ifdef SIGALRM
+	sigaddset (&set, SIGALRM);
+#endif
+#ifdef SIGVTALRM
+	sigaddset (&set, SIGVTALRM);
+#endif
+#ifdef SIGWINCH
+	sigaddset (&set, SIGWINCH);
+#endif
+#ifdef SIGIO
+	sigaddset (&set, SIGIO);
+#endif
+#ifdef SIGTSTP
+	sigaddset (&set, SIGTSTP);
+#endif
+#ifdef SIGTTIN
+	sigaddset (&set, SIGTTIN);
+#endif
+#ifdef SIGTTOU
+	sigaddset (&set, SIGTTOU);
+#endif
+#ifdef SIGCHLD
+	sigaddset (&set, SIGCHLD);
+#endif
+	sigprocmask (SIG_BLOCK, &set, &PreviousSignalMask);
+    }
+#endif
+}
+
+void
+OsReleaseSignals (void)
+{
+#ifdef SIG_BLOCK
+    if (--BlockedSignalCount == 0)
+    {
+	sigprocmask (SIG_SETMASK, &PreviousSignalMask, 0);
+    }
+#endif
+}
+
+#if !defined(WIN32) && !defined(__UNIXOS2__)
+/*
+ * "safer" versions of system(3), popen(3) and pclose(3) which give up
+ * all privs before running a command.
+ *
+ * This is based on the code in FreeBSD 2.2 libc.
+ *
+ * XXX It'd be good to redirect stderr so that it ends up in the log file
+ * as well.  As it is now, xkbcomp messages don't end up in the log file.
+ */
+
+int
+System(char *command)
+{
+    int pid, p;
+#ifdef SIGCHLD
+    void (*csig)(int);
+#endif
+    int status;
+
+    if (!command)
+	return(1);
+
+#ifdef SIGCHLD
+    csig = signal(SIGCHLD, SIG_DFL);
+#endif
+
+#ifdef DEBUG
+    ErrorF("System: `%s'\n", command);
+#endif
+
+    switch (pid = fork()) {
+    case -1:	/* error */
+	p = -1;
+    case 0:	/* child */
+	setgid(getgid());
+	setuid(getuid());
+	execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+	_exit(127);
+    default:	/* parent */
+	do {
+	    p = waitpid(pid, &status, 0);
+	} while (p == -1 && errno == EINTR);
+	
+    }
+
+#ifdef SIGCHLD
+    signal(SIGCHLD, csig);
+#endif
+
+    return p == -1 ? -1 : status;
+}
+
+static struct pid {
+    struct pid *next;
+    FILE *fp;
+    int pid;
+} *pidlist;
+
+pointer
+Popen(char *command, char *type)
+{
+    struct pid *cur;
+    FILE *iop;
+    int pdes[2], pid;
+
+    if (command == NULL || type == NULL)
+	return NULL;
+
+    if ((*type != 'r' && *type != 'w') || type[1])
+	return NULL;
+
+    if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+	return NULL;
+
+    if (pipe(pdes) < 0) {
+	xfree(cur);
+	return NULL;
+    }
+
+    switch (pid = fork()) {
+    case -1: 	/* error */
+	close(pdes[0]);
+	close(pdes[1]);
+	xfree(cur);
+	return NULL;
+    case 0:	/* child */
+	setgid(getgid());
+	setuid(getuid());
+	if (*type == 'r') {
+	    if (pdes[1] != 1) {
+		/* stdout */
+		dup2(pdes[1], 1);
+		close(pdes[1]);
+	    }
+	    close(pdes[0]);
+	} else {
+	    if (pdes[0] != 0) {
+		/* stdin */
+		dup2(pdes[0], 0);
+		close(pdes[0]);
+	    }
+	    close(pdes[1]);
+	}
+	execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+	_exit(127);
+    }
+
+    /* Avoid EINTR during stdio calls */
+    OsBlockSignals ();
+    
+    /* parent */
+    if (*type == 'r') {
+	iop = fdopen(pdes[0], type);
+	close(pdes[1]);
+    } else {
+	iop = fdopen(pdes[1], type);
+	close(pdes[0]);
+    }
+
+    cur->fp = iop;
+    cur->pid = pid;
+    cur->next = pidlist;
+    pidlist = cur;
+
+#ifdef DEBUG
+    ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+    return iop;
+}
+
+/* fopen that drops privileges */
+pointer
+Fopen(char *file, char *type)
+{
+    FILE *iop;
+#ifndef HAS_SAVED_IDS_AND_SETEUID
+    struct pid *cur;
+    int pdes[2], pid;
+
+    if (file == NULL || type == NULL)
+	return NULL;
+
+    if ((*type != 'r' && *type != 'w') || type[1])
+	return NULL;
+
+    if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+	return NULL;
+
+    if (pipe(pdes) < 0) {
+	xfree(cur);
+	return NULL;
+    }
+
+    switch (pid = fork()) {
+    case -1: 	/* error */
+	close(pdes[0]);
+	close(pdes[1]);
+	xfree(cur);
+	return NULL;
+    case 0:	/* child */
+	setgid(getgid());
+	setuid(getuid());
+	if (*type == 'r') {
+	    if (pdes[1] != 1) {
+		/* stdout */
+		dup2(pdes[1], 1);
+		close(pdes[1]);
+	    }
+	    close(pdes[0]);
+	} else {
+	    if (pdes[0] != 0) {
+		/* stdin */
+		dup2(pdes[0], 0);
+		close(pdes[0]);
+	    }
+	    close(pdes[1]);
+	}
+	execl("/bin/cat", "cat", file, (char *)NULL);
+	_exit(127);
+    }
+
+    /* Avoid EINTR during stdio calls */
+    OsBlockSignals ();
+    
+    /* parent */
+    if (*type == 'r') {
+	iop = fdopen(pdes[0], type);
+	close(pdes[1]);
+    } else {
+	iop = fdopen(pdes[1], type);
+	close(pdes[0]);
+    }
+
+    cur->fp = iop;
+    cur->pid = pid;
+    cur->next = pidlist;
+    pidlist = cur;
+
+#ifdef DEBUG
+    ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+    return iop;
+#else
+    int ruid, euid;
+
+    ruid = getuid();
+    euid = geteuid();
+    
+    if (seteuid(ruid) == -1) {
+	    return NULL;
+    }
+    iop = fopen(file, type);
+
+    if (seteuid(euid) == -1) {
+	    fclose(iop);
+	    return NULL;
+    }
+    return iop;
+#endif /* HAS_SAVED_IDS_AND_SETEUID */
+}
+
+int
+Pclose(pointer iop)
+{
+    struct pid *cur, *last;
+    int pstat;
+    int pid;
+
+#ifdef DEBUG
+    ErrorF("Pclose: fp = %p\n", iop);
+#endif
+
+    fclose(iop);
+
+    for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
+	if (cur->fp == iop)
+	    break;
+    if (cur == NULL)
+	return -1;
+
+    do {
+	pid = waitpid(cur->pid, &pstat, 0);
+    } while (pid == -1 && errno == EINTR);
+
+    if (last == NULL)
+	pidlist = cur->next;
+    else
+	last->next = cur->next;
+    xfree(cur);
+
+    /* allow EINTR again */
+    OsReleaseSignals ();
+    
+    return pid == -1 ? -1 : pstat;
+}
+
+int 
+Fclose(pointer iop)
+{
+#ifdef HAS_SAVED_IDS_AND_SETEUID
+    return fclose(iop);
+#else
+    return Pclose(iop);
+#endif
+}
+
+#endif /* !WIN32 && !__UNIXOS2__ */
+
+
+/*
+ * CheckUserParameters: check for long command line arguments and long
+ * environment variables.  By default, these checks are only done when
+ * the server's euid != ruid.  In 3.3.x, these checks were done in an
+ * external wrapper utility.
+ */
+
+/* Consider LD* variables insecure? */
+#ifndef REMOVE_ENV_LD
+#define REMOVE_ENV_LD 1
+#endif
+
+/* Remove long environment variables? */
+#ifndef REMOVE_LONG_ENV
+#define REMOVE_LONG_ENV 1
+#endif
+
+/*
+ * Disallow stdout or stderr as pipes?  It's possible to block the X server
+ * when piping stdout+stderr to a pipe.
+ *
+ * Don't enable this because it looks like it's going to cause problems.
+ */
+#ifndef NO_OUTPUT_PIPES
+#define NO_OUTPUT_PIPES 0
+#endif
+
+
+/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
+#ifndef CHECK_EUID
+#ifndef WIN32
+#define CHECK_EUID 1
+#else
+#define CHECK_EUID 0
+#endif
+#endif
+
+/*
+ * Maybe the locale can be faked to make isprint(3) report that everything
+ * is printable?  Avoid it by default.
+ */
+#ifndef USE_ISPRINT
+#define USE_ISPRINT 0
+#endif
+
+#define MAX_ARG_LENGTH          128
+#define MAX_ENV_LENGTH          256
+#define MAX_ENV_PATH_LENGTH     2048	/* Limit for *PATH and TERMCAP */
+
+#if USE_ISPRINT
+#include <ctype.h>
+#define checkPrintable(c) isprint(c)
+#else
+#define checkPrintable(c) (((c) & 0x7f) >= 0x20 && ((c) & 0x7f) != 0x7f)
+#endif
+
+enum BadCode {
+    NotBad = 0,
+    UnsafeArg,
+    ArgTooLong,
+    UnprintableArg,
+    EnvTooLong,
+    OutputIsPipe,
+    InternalError
+};
+
+#if defined(VENDORSUPPORT)
+#define BUGADDRESS VENDORSUPPORT
+#elif defined(BUILDERADDR)
+#define BUGADDRESS BUILDERADDR
+#else
+#define BUGADDRESS "[email protected]"
+#endif
+
+#define ARGMSG \
+    "\nIf the arguments used are valid, and have been rejected incorrectly\n" \
+      "please send details of the arguments and why they are valid to\n" \
+      "%s.  In the meantime, you can start the Xserver as\n" \
+      "the \"super user\" (root).\n"   
+
+#define ENVMSG \
+    "\nIf the environment is valid, and have been rejected incorrectly\n" \
+      "please send details of the environment and why it is valid to\n" \
+      "%s.  In the meantime, you can start the Xserver as\n" \
+      "the \"super user\" (root).\n"
+
+void
+CheckUserParameters(int argc, char **argv, char **envp)
+{
+    enum BadCode bad = NotBad;
+    int i = 0, j;
+    char *a, *e = NULL;
+#if defined(__QNX__) && !defined(__QNXNTO__)
+    char cmd_name[64];
+#endif
+
+#if CHECK_EUID
+    if (geteuid() == 0 && getuid() != geteuid())
+#endif
+    {
+	/* Check each argv[] */
+	for (i = 1; i < argc; i++) {
+	    if (strcmp(argv[i], "-fp") == 0)
+	    {
+		i++; /* continue with next argument. skip the length check */
+		if (i >= argc)
+		    break;
+	    } else
+	    {
+		if (strlen(argv[i]) > MAX_ARG_LENGTH) {
+		    bad = ArgTooLong;
+		    break;
+		}
+	    }
+	    a = argv[i];
+	    while (*a) {
+		if (checkPrintable(*a) == 0) {
+		    bad = UnprintableArg;
+		    break;
+		}
+		a++;
+	    }
+	    if (bad)
+		break;
+	}
+	if (!bad) {
+	    /* Check each envp[] */
+	    for (i = 0; envp[i]; i++) {
+
+		/* Check for bad environment variables and values */
+#if REMOVE_ENV_LD
+		while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
+#ifdef ENVDEBUG
+		    ErrorF("CheckUserParameters: removing %s from the "
+			   "environment\n", strtok(envp[i], "="));
+#endif
+		    for (j = i; envp[j]; j++) {
+			envp[j] = envp[j+1];
+		    }
+		}
+#endif   
+		if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
+#if REMOVE_LONG_ENV
+#ifdef ENVDEBUG
+		    ErrorF("CheckUserParameters: removing %s from the "
+			   "environment\n", strtok(envp[i], "="));
+#endif
+		    for (j = i; envp[j]; j++) {
+			envp[j] = envp[j+1];
+		    }
+		    i--;
+#else
+		    char *eq;
+		    int len;
+
+		    eq = strchr(envp[i], '=');
+		    if (!eq)
+			continue;
+		    len = eq - envp[i];
+		    e = malloc(len + 1);
+		    if (!e) {
+			bad = InternalError;
+			break;
+		    }
+		    strncpy(e, envp[i], len);
+		    e[len] = 0;
+		    if (len >= 4 &&
+			(strcmp(e + len - 4, "PATH") == 0 ||
+			 strcmp(e, "TERMCAP") == 0)) {
+			if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
+			    bad = EnvTooLong;
+			    break;
+			} else {
+			    free(e);
+			}
+		    } else {
+			bad = EnvTooLong;
+			break;
+		    }
+#endif
+		}
+	    }
+	}
+#if NO_OUTPUT_PIPES
+	if (!bad) {
+	    struct stat buf;
+
+	    if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode))
+		bad = OutputIsPipe;
+	    if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode))
+		bad = OutputIsPipe;
+	}
+#endif
+    }
+    switch (bad) {
+    case NotBad:
+	return;
+    case UnsafeArg:
+	ErrorF("Command line argument number %d is unsafe\n", i);
+	ErrorF(ARGMSG, BUGADDRESS);
+	break;
+    case ArgTooLong:
+	ErrorF("Command line argument number %d is too long\n", i);
+	ErrorF(ARGMSG, BUGADDRESS);
+	break;
+    case UnprintableArg:
+	ErrorF("Command line argument number %d contains unprintable"
+		" characters\n", i);
+	ErrorF(ARGMSG, BUGADDRESS);
+	break;
+    case EnvTooLong:
+	ErrorF("Environment variable `%s' is too long\n", e);
+	ErrorF(ENVMSG, BUGADDRESS);
+	break;
+    case OutputIsPipe:
+	ErrorF("Stdout and/or stderr is a pipe\n");
+	break;
+    case InternalError:
+	ErrorF("Internal Error\n");
+	break;
+    default:
+	ErrorF("Unknown error\n");
+	ErrorF(ARGMSG, BUGADDRESS);
+	ErrorF(ENVMSG, BUGADDRESS);
+	break;
+    }
+    FatalError("X server aborted because of unsafe environment\n");
+}
+
+/*
+ * CheckUserAuthorization: check if the user is allowed to start the
+ * X server.  This usually means some sort of PAM checking, and it is
+ * usually only done for setuid servers (uid != euid).
+ */
+
+#ifdef USE_PAM
+#include <security/pam_appl.h>
+#include <security/pam_misc.h>
+#include <pwd.h>
+#endif /* USE_PAM */
+
+void
+CheckUserAuthorization(void)
+{
+#ifdef USE_PAM
+    static struct pam_conv conv = {
+	misc_conv,
+	NULL
+    };
+
+    pam_handle_t *pamh = NULL;
+    struct passwd *pw;
+    int retval;
+
+    if (getuid() != geteuid()) {
+	pw = getpwuid(getuid());
+	if (pw == NULL)
+	    FatalError("getpwuid() failed for uid %d\n", getuid());
+
+	retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
+	if (retval != PAM_SUCCESS)
+	    FatalError("pam_start() failed.\n"
+			"\tMissing or mangled PAM config file or module?\n");
+
+	retval = pam_authenticate(pamh, 0);
+	if (retval != PAM_SUCCESS) {
+	    pam_end(pamh, retval);
+	    FatalError("PAM authentication failed, cannot start X server.\n"
+			"\tPerhaps you do not have console ownership?\n");
+	}
+
+	retval = pam_acct_mgmt(pamh, 0);
+	if (retval != PAM_SUCCESS) {
+	    pam_end(pamh, retval);
+	    FatalError("PAM authentication failed, cannot start X server.\n"
+			"\tPerhaps you do not have console ownership?\n");
+	}
+
+	/* this is not a session, so do not do session management */
+	pam_end(pamh, PAM_SUCCESS);
+    }
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,51 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM 
+XCOMM ########################################################################
+XCOMM 
+XCOMM ident	"@(#)Imakefile 1.2	06/03/07 SMI"
+XCOMM
+
+#if DoLoadableServer
+#define IHaveSubdirs
+#endif
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+    SUBDIRS = module
+#endif
+
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/TrustedExtensionsPolicy	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,180 @@
+#
+# Copyright 2004 Sun Microsystems, Inc.	 All rights reserved.
+# Use is subject to license terms.
+#
+
+# ident	"@(#)TrustedExtensionsPolicy 1.1	04/08/03 SMI"
+
+# TrustedSolarisPolicy
+# Syntax: <atom|property|selection|extension|privilege> name
+#
+# property and selection can take a regular expression for name.
+# name must start with / for regular expresssions.
+#
+
+atom CAP_HEIGHT
+atom CLIPBOARD
+atom COPYRIGHT
+atom END_SPACE
+atom FAMILY_NAME
+atom FONT
+atom FONT_NAME
+atom FULL_NAME
+atom ITALIC_ANGLE
+atom LENGTH
+atom LIST_LENGTH
+atom MAX_SPACE
+atom MIN_SPACE
+atom MULTIPLE
+atom NORM_SPACE
+atom NOTICE
+atom POINT_SIZE
+atom PRIMARY
+atom QUAD_WIDTH
+atom RESOLUTION
+atom RESOURCE_MANAGER
+atom RGB_BEST_MAP
+atom RGB_BLUE_MAP
+atom RGB_COLOR_MAP
+atom RGB_DEFAULT_MAP
+atom RGB_GRAY_MAP
+atom RGB_GREEN_MAP
+atom RGB_RED_MAP
+atom SECONDARY
+atom STRIKEOUT_ASCENT
+atom STRIKEOUT_DESCENT
+atom SUBSCRIPT_X
+atom SUBSCRIPT_Y
+atom SUPERSCRIPT_X
+atom SUPERSCRIPT_Y
+atom TARGETS
+atom TIMESTAMP
+atom UNDERLINE_POSITION
+atom UNDERLINE_THICKNESS
+atom WEIGHT
+atom WM_CHANGE_STATE
+atom WM_CLASS
+atom WM_CLIENT_MACHINE
+atom WM_COLORMAP_WINDOWS
+atom WM_COMMAND
+atom WM_DELETE_WINDOW
+atom WM_HINTS
+atom WM_ICON_NAME
+atom WM_ICON_SIZE
+atom WM_NAME
+atom WM_NORMAL_HINTS
+atom WM_PROTOCOLS
+atom WM_SAVE_YOURSELF
+atom WM_SIZE_HINTS
+atom WM_STATE
+atom WM_TAKE_FOCUS
+atom WM_TRANSIENT_FOR
+atom WM_ZOOM_HINTS
+atom XV_DO_DRAG_COPY
+atom XV_DO_DRAG_LOAD
+atom XV_DO_DRAG_MOVE
+atom X_HEIGHT
+atom _DT_WORKSPACE_CURRENT
+atom _DT_WORKSPACE_PRESENCE
+atom _DT_WORKSPACE_INFO_ws0
+atom _DT_WORKSPACE_INFO_ws1
+atom _DT_WORKSPACE_INFO_ws2
+atom _DT_WORKSPACE_INFO_ws3
+atom _DT_WORKSPACE_INFO_ws4
+atom _DT_WORKSPACE_INFO_ws5
+atom _DT_WORKSPACE_INFO_ws6
+atom _DT_WORKSPACE_INFO_ws7
+atom _DT_WORKSPACE_INFO_ws8
+atom _DT_WORKSPACE_INFO_ws9
+atom _DT_WORKSPACE_LIST
+atom _OLWM_TIMESTAMP
+atom _OL_DECOR_ADD
+atom _OL_DECOR_CLOSE
+atom _OL_DECOR_DEL
+atom _OL_DECOR_FOOTER
+atom _OL_DECOR_HEADER
+atom _OL_DECOR_PIN
+atom _OL_DECOR_RESIZE
+atom _OL_DFLT_BTN
+atom _OL_MENU_FULL
+atom _OL_MENU_LIMITED
+atom _OL_NONE
+atom _OL_PIN_IN
+atom _OL_PIN_OUT
+atom _OL_PIN_STATE
+atom _OL_PROPS_APPLY
+atom _OL_PROPS_RESET
+atom _OL_SHOW_PROPS
+atom _OL_WINMSG_ERROR
+atom _OL_WINMSG_STATE
+atom _OL_WIN_ATTR
+atom _OL_WIN_BUSY
+atom _OL_WT_BASE
+atom _OL_WT_CMD
+atom _OL_WT_HELP
+atom _OL_WT_NOTICE
+atom _OL_WT_OTHER
+atom _OL_WT_PROP
+atom _SUN_DRAGDROP_ACK
+atom _SUN_DRAGDROP_DONE
+atom _SUN_DRAGDROP_DSDM
+atom _SUN_DRAGDROP_INTEREST
+atom _SUN_DRAGDROP_PREVIEW
+atom _SUN_DRAGDROP_TRIGGER
+atom _SUN_QUICK_SELECTION_KEY_STATE
+atom _SUN_SELN_CARET
+atom _SUN_SELN_END_REQUEST
+atom _SUN_SELN_FIRST
+atom _SUN_SELN_FUNC_KEY_STATE
+atom _SUN_SELN_IS_READONLY
+atom _SUN_SELN_LAST
+atom _SUN_SELN_YIELD
+atom _SUN_SELN_YIELD
+atom _SUN_SUNVIEW_ENV
+atom ws0
+atom ws1
+atom ws2
+atom ws3
+atom ws4
+atom ws5
+atom ws6
+atom ws7
+atom ws8
+atom ws9
+
+
+property WM_ICON_SIZE
+property RESOURCE_MANAGER
+property RGB_DEFAULT_MAP
+property _SUN_DESKSET_COLORS
+property _SUN_LED_MAP
+property _MOTIF_WM_INFO
+property _DT_RESTORE_MODE
+property _DT_SAVE_MODE
+property _DT_SM_WINDOW_INFO
+property _MOTIF_ATOM_0
+property _MOTIF_ATOM_1
+property _MOTIF_ATOM_2
+property _MOTIF_ATOM_3
+property _MOTIF_DRAG_RECEIVER_INFO
+property _SUN_CORONA_SESSION
+property _SUN_SUNRAY_SESSION
+property _SUN_SUNRAY_CONN_INFO
+property _SUN_SUNRAY_SESSION_GEOMETRY
+
+
+selection Dtfile
+selection Dtpad
+selection _Frame_RPC
+selection _MOTIF_CLIP_LOCK
+selection /^_XIMP_/
+selection /^_HTT_/
+
+
+extension SYNC
+
+privilege win_colormap
+privilege win_config
+privilege win_dga
+privilege win_devices
+privilege win_fontpath
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/module/Imakefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,86 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM 
+XCOMM ########################################################################
+XCOMM 
+XCOMM ident	"@(#)Imakefile 1.6	06/03/07 SMI"
+XCOMM
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+      MSRCS = tsolmodule.c
+      MOBJS = tsolmodule.o
+#endif
+
+       SRCS = tsolpolicy.c tsolutils.c tsolextension.c tsolprotocol.c $(MSRCS)
+       OBJS = tsolpolicy.o tsolutils.o tsolextension.o tsolprotocol.o $(MOBJS)
+
+#ifdef XBuildIncDir
+X11_INCLUDES= -I$(XBUILDINCDIR)
+#else
+X11_INCLUDES= -I$(BUILDINCDIR)
+#endif
+
+INCLUDES = -I.. -I$(SERVERSRC)/include $(X11_INCLUDES) $(X11_INCLUDES)/extensions \
+	-I$(TOP)/onproto/usr/include -I$(TOP)/tsolproto/usr/include \
+	 -I$(TOP)/include/extensions
+
+ SERVERCONFIGDIR = ServerConfigDir
+TSOLPOLICYFILEDEF = -DTSOLPOLICYFILE=\"$(SERVERCONFIGDIR)/TrustedExtensionsPolicy\"
+
+
+   LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln
+SHLIBGLOBALSFLAGS = -L$(TOP)/onproto/usr/lib -ltsol -ltsnet \
+	-L$(TOP)/tsolproto/usr/lib  -ltlc -lsecdb -lbsm
+
+LinkSourceFile(tsolmodule.c,..)
+LinkSourceFile(tsolpolicy.c,..)
+LinkSourceFile(tsolutils.c,..)
+LinkSourceFile(tsolextension.c,..)
+LinkSourceFile(tsolprotocol.c,..)
+LinkSourceFile(TrustedExtensionsPolicy,..)
+
+ModuleObjectRule()
+
+SpecialCObjectRule(tsolutils,$(ICONFIGFILES),$(TSOLPOLICYFILEDEF))
+
+LibraryModuleTarget(xtsol,$(OBJS))
+
+LintLibraryTarget(xtsol,$(SRCS))
+NormalLintTarget($(SRCS))
+
+InstallNonExecFile(TrustedExtensionsPolicy,$(SERVERCONFIGDIR))
+
+InstallLibraryModule(xtsol,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(xtsol,$(DRIVERSDKMODULEDIR),extensions)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsol.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,58 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)tsol.h 1.3     06/03/07 SMI"
+
+/*
+ * tsol.h server side extension
+ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define _XTSOL_SERVER
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "input.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "propertyst.h"
+#include "validate.h"
+#include "Xtsol.h"
+#include "Xtsolproto.h"
+
+#include "tsolinfo.h"
+
+extern int tsolWindowPrivateIndex;  /* declared in tsol.c */
+extern int tsolPixmapPrivateIndex; 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolextension.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1932 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)tsolextension.c 1.11     06/03/07 SMI"
+
+#include <stdio.h>
+#include <bsm/auditwrite.h>
+#include <bsm/libbsm.h>
+#include <bsm/audit_uevents.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <ucred.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/tsol/tndb.h>
+#include <strings.h>
+#include <string.h>
+#include <pwd.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <rpc/rpc.h>
+#include <zone.h>
+
+
+#define NEED_REPLIES
+
+
+#include "misc.h"
+#include "osdep.h"
+#include "Xauth.h"
+#include "tsol.h"
+#include "inputstr.h"
+#include "extnsionst.h"
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include "security.h"
+#endif
+#include "tsolpolicy.h"
+
+#define  BadCmapCookie      0
+#define  Tsolextension      0x0080    /* Tsol extensions begin at 128 */
+#define  MAX_SCREENS        3         /* screens allowed */
+#define EXTNSIZE 128
+
+extern Bool il_enabled;
+
+extern bslabel_t *lookupSL();
+extern void (*ReplySwapVector[]) ();
+extern TsolInfoPtr GetClientTsolInfo();
+extern char *NameForAtom(Atom atom);
+
+static int ProcTsolDispatch(ClientPtr);
+static int ProcSetPolyInstInfo(ClientPtr);
+static int ProcSetPropLabel(ClientPtr);
+static int ProcSetPropUID(ClientPtr);
+static int ProcSetResLabel(ClientPtr);
+static int ProcSetResUID(ClientPtr);
+static int ProcGetClientAttributes(ClientPtr);
+static int ProcGetClientLabel(ClientPtr);
+static int ProcGetPropAttributes(ClientPtr);
+static int ProcGetResAttributes(ClientPtr);
+static int ProcMakeTPWindow(ClientPtr);
+static int ProcMakeTrustedWindow(ClientPtr);
+static int ProcMakeUntrustedWindow(ClientPtr);
+
+static int SProcTsolDispatch(ClientPtr);
+static int SProcSetPolyInstInfo(ClientPtr);
+static int SProcSetPropLabel(ClientPtr);
+static int SProcSetPropUID(ClientPtr);
+static int SProcSetResLabel(ClientPtr);
+static int SProcSetResUID(ClientPtr);
+static int SProcGetClientAttributes(ClientPtr);
+static int SProcGetClientLabel(ClientPtr);
+static int SProcGetPropAttributes(ClientPtr);
+static int SProcGetResAttributes(ClientPtr);
+static int SProcMakeTPWindow(ClientPtr);
+static int SProcMakeTrustedWindow(ClientPtr);
+static int SProcMakeUntrustedWindow(ClientPtr);
+
+static void TsolReset();
+static void BreakAllGrabs(ClientPtr client);
+
+extern void init_xtsol();
+extern int DoScreenStripeHeight(int screen_num);
+extern int AddUID(int *userid);
+
+static unsigned char TsolReqCode = 0;
+static int tsolEventBase = -1;
+extern unsigned int StripeHeight;
+int ScreenStripeHeight[MAX_SCREENS - 1] = {0, 0};
+
+extern int tsolClientPrivateIndex;
+extern int tsolWindowPrivateIndex;
+extern int tsolPixmapPrivateIndex;
+
+static HotKeyRec hotkey = {FALSE, 0, 0, 0, 0};
+
+int OwnerUIDint;
+extern uid_t OwnerUID;
+uid_t PublicObjUID = 0;
+extern WindowPtr tpwin;
+extern bclear_t SessionHI;        /* HI Clearance */
+extern bclear_t SessionLO;        /* LO Clearance */
+extern TsolPolyInstInfoRec tsolpolyinstinfo;
+
+extern void LoadTsolConfig();
+extern void MakeTSOLAtoms();
+extern void UpdateTsolNode();
+/*
+ * Protocol handling vectors
+ */
+extern int (*ProcVector[])();
+extern int (*SwappedProcVector[])();
+
+int (*TsolSavedProcVector[PROCVECTORSIZE])(ClientPtr client);
+int (*TsolSavedSwappedProcVector[PROCVECTORSIZE])(ClientPtr client);
+
+extern SecurityHookPtr pSecHook;
+SecurityHook tsolSecHook;
+
+XID TsolCheckAuthorization (unsigned int name_length,
+	char *name, unsigned int data_length, 
+	char *data, ClientPtr client, char **reason);
+void TsolDeleteClientFromAnySelections(ClientPtr);
+void TsolDeleteWindowFromAnySelections(WindowPtr);
+
+extern int TsolChangeWindowProperty(ClientPtr, WindowPtr, Atom, Atom, int, int,
+	unsigned long, pointer, Bool);
+extern int TsolDeleteProperty(ClientPtr, WindowPtr, Atom);
+extern int TsolInitWindow(ClientPtr, WindowPtr);
+extern void TsolAuditStart(ClientPtr);
+extern void TsolAuditEnd(ClientPtr, int);
+
+static void TsolClientStateCallback(CallbackListPtr *pcbl,
+	pointer nulldata, pointer calldata);
+static void TsolSetClientInfo(ClientPtr client);
+static void TsolProcessKeyboard(xEvent *, KeyClassPtr);
+static char TsolCheckPropertyAccess(ClientPtr client, WindowPtr pWin, ATOM propertyName,
+	Mask access_mode);
+
+extern int ProcTsolInternAtom(ClientPtr client);
+extern int ProcTsolSetSelectionOwner(ClientPtr client);
+extern int ProcTsolGetSelectionOwner(ClientPtr client);
+extern int ProcTsolConvertSelection(ClientPtr client);
+extern int ProcTsolGetProperty(ClientPtr client);
+extern int ProcTsolListProperties(ClientPtr client);
+extern int ProcTsolChangeKeyboardMapping(ClientPtr client);
+extern int ProcTsolSetPointerMapping(ClientPtr client);
+extern int ProcTsolChangeKeyboardControl(ClientPtr client);
+extern int ProcTsolBell(ClientPtr client);
+extern int ProcTsolChangePointerControl(ClientPtr client);
+extern int ProcTsolSetModifierMapping(ClientPtr client);
+
+extern int ProcTsolCreateWindow(ClientPtr client);
+extern int ProcTsolChangeWindowAttributes(ClientPtr client);
+extern int ProcTsolConfigureWindow(ClientPtr client);
+extern int ProcTsolCirculateWindow(ClientPtr client);
+extern int ProcTsolReparentWindow(ClientPtr client);
+extern int ProcTsolSetInputFocus(ClientPtr client);
+extern int ProcTsolGetInputFocus(ClientPtr client);
+extern int ProcTsolSendEvent(ClientPtr client);
+extern int ProcTsolSetInputFocus(ClientPtr client);
+extern int ProcTsolGetInputFocus(ClientPtr client);
+extern int ProcTsolGetGeometry(ClientPtr client);
+extern int ProcTsolGrabServer(ClientPtr client);
+extern int ProcTsolUngrabServer(ClientPtr client);
+extern int ProcTsolCreatePixmap(ClientPtr client);
+extern int ProcTsolSetScreenSaver(ClientPtr client);
+extern int ProcTsolChangeHosts(ClientPtr client);
+extern int ProcTsolChangeAccessControl(ClientPtr client);
+extern int ProcTsolKillClient(ClientPtr client);
+extern int ProcTsolSetFontPath(ClientPtr client);
+extern int ProcTsolChangeCloseDownMode(ClientPtr client);
+extern int ProcTsolListInstalledColormaps(ClientPtr client);
+extern int ProcTsolGetImage(ClientPtr client);
+extern int ProcTsolQueryTree(ClientPtr client);
+extern int ProcTsolQueryPointer(ClientPtr client);
+
+/*
+ * Initialize the extension. Main entry point for this loadable
+ * module.
+ */
+
+void
+TsolExtensionInit()
+{
+	ExtensionEntry *extEntry;
+	ScreenPtr pScreen;
+	int i;
+	priv_set_t	*pset;
+
+	/* sleep(20); */
+
+	/* Extension can be loaded on a Trusted Solaris system only */
+	if (!is_system_labeled()) {
+		ErrorF("TsolExtensionInit: cannot load X Trusted Extensions\n");
+		ErrorF("Trusted Extensions is not enabled/installed on your system\n");
+		return;
+	}
+
+	(void) setpflags(PRIV_AWARE, 1);
+
+	init_xtsol();
+
+	extEntry = AddExtension(TSOLNAME, TSOL_NUM_EVENTS, TSOL_NUM_ERRORS,
+		ProcTsolDispatch, SProcTsolDispatch, TsolReset, 
+		StandardMinorOpcode);
+
+	if (extEntry == NULL) {
+		ErrorF("TsolExtensionInit: AddExtension failed for X Trusted Extensions\n");
+		return;
+	}
+
+        TsolReqCode = (unsigned char) extEntry->base;
+        tsolEventBase = extEntry->eventBase;
+
+	if (!AddCallback(&ClientStateCallback, TsolClientStateCallback, NULL))
+		return;
+
+	/* Allocate the client private index */
+	tsolClientPrivateIndex = AllocateClientPrivateIndex();
+	if (!AllocateClientPrivate(tsolClientPrivateIndex,
+		   sizeof (TsolInfoRec))) {
+		ErrorF("TsolExtensionInit: Cannot allocate client private.\n");
+		return;
+	}
+
+	/* Allocate per screen window/pixmap private index */
+	tsolWindowPrivateIndex = AllocateWindowPrivateIndex();
+	tsolPixmapPrivateIndex = AllocatePixmapPrivateIndex();
+
+	for (i = 0; i < screenInfo.numScreens; i++) {
+		pScreen = screenInfo.screens[i];
+		if (!AllocateWindowPrivate(pScreen, tsolWindowPrivateIndex,
+			   sizeof (TsolResRec))) {
+			ErrorF("TsolExtensionInit: Cannot allocate window private.\n");
+            		return;
+		}
+
+		if (!AllocatePixmapPrivate(pScreen, tsolPixmapPrivateIndex,
+                                   sizeof (TsolResRec))) {
+			ErrorF("TsolExtensionInit: Cannot allocate pixmap private.\n");
+			return;
+		}
+	}
+
+	LoadTsolConfig();
+
+	MakeTSOLAtoms();
+	UpdateTsolNode();
+
+	/* Save original Proc vectors */
+	for (i = 0; i < PROCVECTORSIZE; i++) {
+		TsolSavedProcVector[i] = ProcVector[i];
+		TsolSavedSwappedProcVector[i] = SwappedProcVector[i];
+	}
+
+	/* Initialize security hooks */
+	tsolSecHook.CheckAuthorization = TsolCheckAuthorization;
+	tsolSecHook.ChangeWindowProperty = TsolChangeWindowProperty;
+	tsolSecHook.CheckPropertyAccess = TsolCheckPropertyAccess;
+	tsolSecHook.DeleteProperty = TsolDeleteProperty;
+	tsolSecHook.InitWindow = TsolInitWindow;
+	tsolSecHook.ProcessKeyboard = TsolProcessKeyboard;
+	tsolSecHook.DeleteClientFromAnySelections = TsolDeleteClientFromAnySelections;
+	tsolSecHook.DeleteWindowFromAnySelections = TsolDeleteWindowFromAnySelections;
+	tsolSecHook.AuditStart = TsolAuditStart;
+	tsolSecHook.AuditEnd = TsolAuditEnd;
+	pSecHook = &tsolSecHook;
+
+	/* Replace some of the original Proc vectors with our own TBD */
+	ProcVector[X_InternAtom] = ProcTsolInternAtom;
+	ProcVector[X_SetSelectionOwner] = ProcTsolSetSelectionOwner;
+	ProcVector[X_GetSelectionOwner] = ProcTsolGetSelectionOwner;
+	ProcVector[X_ConvertSelection] = ProcTsolConvertSelection;
+	ProcVector[X_GetProperty] = ProcTsolGetProperty;
+	ProcVector[X_ListProperties] = ProcTsolListProperties;
+	ProcVector[X_ChangeKeyboardMapping] = ProcTsolChangeKeyboardMapping;
+	ProcVector[X_SetPointerMapping] = ProcTsolSetPointerMapping;
+	ProcVector[X_ChangeKeyboardControl] = ProcTsolChangeKeyboardControl;
+	ProcVector[X_Bell] = ProcTsolBell;
+	ProcVector[X_ChangePointerControl] = ProcTsolChangePointerControl;
+	ProcVector[X_SetModifierMapping] = ProcTsolSetModifierMapping;
+
+	ProcVector[X_CreateWindow] = ProcTsolCreateWindow;
+	ProcVector[X_ChangeWindowAttributes] = ProcTsolChangeWindowAttributes;
+	ProcVector[X_ConfigureWindow] = ProcTsolConfigureWindow;
+	ProcVector[X_CirculateWindow] = ProcTsolCirculateWindow;
+	ProcVector[X_ReparentWindow] = ProcTsolReparentWindow;
+	ProcVector[X_SetInputFocus] = ProcTsolSetInputFocus;
+	ProcVector[X_GetInputFocus] = ProcTsolGetInputFocus;
+	ProcVector[X_SendEvent] = ProcTsolSendEvent;
+	ProcVector[X_SetInputFocus] = ProcTsolSetInputFocus;
+	ProcVector[X_GetInputFocus] = ProcTsolGetInputFocus;
+	ProcVector[X_GetGeometry] = ProcTsolGetGeometry;
+	ProcVector[X_GrabServer] = ProcTsolGrabServer;
+	ProcVector[X_UngrabServer] = ProcTsolUngrabServer;
+	ProcVector[X_CreatePixmap] = ProcTsolCreatePixmap;
+	ProcVector[X_SetScreenSaver] = ProcTsolSetScreenSaver;
+	ProcVector[X_ChangeHosts] = ProcTsolChangeHosts;
+	ProcVector[X_SetAccessControl] = ProcTsolChangeAccessControl;
+	ProcVector[X_KillClient] = ProcTsolKillClient;
+	ProcVector[X_SetFontPath] = ProcTsolSetFontPath;
+	ProcVector[X_SetCloseDownMode] = ProcTsolChangeCloseDownMode;
+	ProcVector[X_ListInstalledColormaps] = ProcTsolListInstalledColormaps;
+	ProcVector[X_GetImage] = ProcTsolGetImage;
+	ProcVector[X_QueryTree] = ProcTsolQueryTree;
+	ProcVector[X_QueryPointer] = ProcTsolQueryPointer;
+
+}
+
+static pointer
+TsolCheckResourceIDAccess(
+    ClientPtr client,
+    XID id,
+    RESTYPE rtype,
+    Mask access_mode,
+    pointer rval)
+{
+    int cid = CLIENT_ID(id);
+    int reqtype = ((xReq *)client->requestBuffer)->reqType;  /* protocol */
+    pointer retval;
+    char msgbuf[1024];
+
+
+    retval = rval;
+
+    switch (rtype) {
+	case RT_GC:
+		switch (access_mode) {
+		case SecurityReadAccess:
+		    if (xtsol_policy(TSOL_RES_GC, TSOL_READ, (void *)id,
+			client, TSOL_ALL, (void *)MAJOROP))
+				retval = NULL;
+		    break;
+
+		case SecurityWriteAccess:
+		    if (xtsol_policy(TSOL_RES_GC, TSOL_MODIFY, (void *)id,
+			client, TSOL_ALL, (void *)MAJOROP))
+				retval = NULL;
+		    break;
+
+		case SecurityDestroyAccess:
+		    if (xtsol_policy(TSOL_RES_GC, TSOL_DESTROY, (void *)id,
+			client, TSOL_ALL, (void *)MAJOROP))
+				retval = NULL;
+		    break;
+		}
+		break;
+
+	case RT_WINDOW:		/* Drawables */
+	case RT_PIXMAP:
+	    /* Drawing operations use pixel access policy */
+	    switch (reqtype) {
+		case X_PolyPoint:
+		case X_PolyLine:
+		case X_PolySegment:
+		case X_PolyRectangle:
+		case X_PolyArc:
+		case X_FillPoly:
+		case X_PolyFillRectangle:
+		case X_PolyFillArc:
+		case X_PutImage:
+		case X_GetImage:
+		case X_PolyText8:
+		case X_PolyText16:
+		case X_ImageText8:
+		case X_ImageText16:
+		switch (access_mode) {
+		case SecurityReadAccess:
+		    if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, (void *)rval,
+			client, TSOL_ALL, (void *)MAJOROP))
+				retval = NULL;
+		    break;
+
+		case SecurityWriteAccess:
+		    if (xtsol_policy(TSOL_RES_PIXEL, TSOL_MODIFY, (void *)rval,
+			client, TSOL_ALL, (void *)MAJOROP))
+				retval = NULL;
+		    break;
+    		}
+		break;
+
+		/* Property protocols */
+		case X_ChangeProperty:
+		case X_DeleteProperty:
+		case X_GetProperty:
+		case X_ListProperties:
+		case X_RotateProperties:
+		switch (access_mode) {
+		case SecurityReadAccess:
+		    if (xtsol_policy(TSOL_RES_PROPWIN, TSOL_READ, (void *)rval,
+			client, TSOL_ALL, (void *)MAJOROP))
+				retval = NULL;
+		    break;
+
+		case SecurityWriteAccess:
+		    if (xtsol_policy(TSOL_RES_PROPWIN, TSOL_MODIFY, (void *)rval,
+			client, TSOL_ALL, (void *)MAJOROP))
+				retval = NULL;
+		    break;
+    		}
+		break;
+		}
+		break;
+    }
+
+    if (retval == NULL) {
+    	TsolInfoPtr tsolinfo, res_tsolinfo;
+    	tsolinfo = GetClientTsolInfo(client);
+
+	snprintf(msgbuf, sizeof (msgbuf), 
+	    "Access failed: cid = %d, rtype=%X, access=%d, xid=%X, proto = %d, pid = %d\n",
+		cid, rtype, access_mode, id, reqtype, tsolinfo->pid);
+	ErrorF(msgbuf);
+    }
+
+    return retval;
+}
+
+static void
+TsolClientStateCallback(CallbackListPtr *pcbl,
+	pointer nulldata,
+	pointer calldata)
+{
+ 	NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+	ClientPtr client = pci->client;
+	TsolInfoPtr tsolinfo = (TsolInfoPtr)
+		(client->devPrivates[tsolClientPrivateIndex].ptr);
+
+	switch (client->clientState) {
+
+	case ClientStateInitial:
+		/* Got a new connection */
+		TsolSetClientInfo(client);
+		client->CheckAccess = TsolCheckResourceIDAccess;
+		break;
+
+	case ClientStateRunning:
+		break;
+
+	case ClientStateRetained:	/* client disconnected */
+		break;
+	case ClientStateGone:
+		if (tpwin && wClient(tpwin) == client)
+		    tpwin = NULL; /* reset tpwin */
+
+		if (tsolinfo != NULL && tsolinfo->privs != NULL) {
+			priv_freeset(tsolinfo->privs);
+		}
+		break;
+	default:
+                break;
+	}
+
+}
+
+/*
+ * Reset routine. Don't know what to put here yet
+ */
+static void
+TsolReset()
+{
+}
+
+/*
+ * Dispatch routine
+ *
+ */
+static int
+ProcTsolDispatch(client)
+register ClientPtr client;
+{
+    int retval;
+
+    REQUEST(xReq);
+
+    switch (stuff->data)
+    {
+        case X_SetPolyInstInfo:
+            retval =  ProcSetPolyInstInfo(client);
+            break;
+        case X_SetPropLabel:
+            retval =  ProcSetPropLabel(client);
+            break;
+        case X_SetPropUID:
+            retval =  ProcSetPropUID(client);
+            break;
+        case X_SetResLabel:
+            retval =  ProcSetResLabel(client);
+            break;
+        case X_SetResUID:
+            retval =  ProcSetResUID(client);
+            break;
+        case X_GetClientAttributes:
+            retval =  ProcGetClientAttributes(client);
+            break;
+        case X_GetClientLabel:
+            retval = ProcGetClientLabel(client);
+            break;
+        case X_GetPropAttributes:
+            retval =  ProcGetPropAttributes(client);
+            break;            
+        case X_GetResAttributes:
+            retval =  ProcGetResAttributes(client);
+            break;
+        case X_MakeTPWindow:
+            retval =  ProcMakeTPWindow(client);
+            break;
+        case X_MakeTrustedWindow:
+            retval =  ProcMakeTrustedWindow(client);
+            break;
+        case X_MakeUntrustedWindow:
+            retval =  ProcMakeUntrustedWindow(client);
+            break;
+        default:
+            SendErrorToClient(client, TsolReqCode, stuff->data, 0, BadRequest);
+            retval = BadRequest;
+    }
+    return (retval);
+}
+
+
+static int
+SProcTsolDispatch(client)
+register ClientPtr client;
+{
+    int n;
+    int retval;
+
+    REQUEST(xReq);
+
+    swaps(&stuff->length, n);
+    switch (stuff->data)
+    {
+        case X_SetPolyInstInfo:
+            retval =  SProcSetPolyInstInfo(client);
+            break;
+        case X_SetPropLabel:
+            retval =  SProcSetPropLabel(client);
+            break;
+        case X_SetPropUID:
+            retval =  SProcSetPropUID(client);
+            break;
+        case X_SetResLabel:
+            retval =  SProcSetResLabel(client);
+            break;
+        case X_SetResUID:
+            retval =  SProcSetResUID(client);
+            break;
+        case X_GetClientAttributes:
+            retval =  SProcGetClientAttributes(client);
+            break;
+        case X_GetClientLabel:
+            retval = SProcGetClientLabel(client);
+            break;
+        case X_GetPropAttributes:
+            retval =  SProcGetPropAttributes(client);
+            break;            
+        case X_GetResAttributes:
+            retval =  SProcGetResAttributes(client);
+            break;
+        case X_MakeTPWindow:
+            retval =  SProcMakeTPWindow(client);
+            break;
+        case X_MakeTrustedWindow:
+            retval =  SProcMakeTrustedWindow(client);
+            break;
+        case X_MakeUntrustedWindow:
+            retval =  SProcMakeUntrustedWindow(client);
+            break;
+        default:
+            SendErrorToClient(client, TsolReqCode, stuff->data, 0, BadRequest);
+            retval = BadRequest;
+    }
+    return (retval);
+}
+
+
+/*
+ * Individual routines
+ */
+
+static int
+SProcSetPolyInstInfo(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xSetPolyInstInfoReq);
+    swapl(&stuff->uid, n);
+    swapl(&stuff->enabled, n);
+    swaps(&stuff->sllength, n);
+
+    return (ProcSetPolyInstInfo(client));
+}
+
+static int
+SProcSetPropLabel(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xSetPropLabelReq);
+    swapl(&stuff->id, n);
+    swapl(&stuff->atom, n);
+    swaps(&stuff->labelType, n);
+    swaps(&stuff->sllength, n);
+    swaps(&stuff->illength, n);
+
+    return (ProcSetPropLabel(client));
+}
+
+static int
+SProcSetPropUID(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xSetPropUIDReq);
+    swapl(&stuff->id, n);
+    swapl(&stuff->atom, n);
+    swapl(&stuff->uid, n);
+
+    return (ProcSetPropUID(client));
+}
+
+static int
+SProcSetResLabel(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xSetResLabelReq);
+    swapl(&stuff->id, n);
+    swaps(&stuff->resourceType, n);
+    swaps(&stuff->labelType, n);
+    swaps(&stuff->sllength, n);
+    swaps(&stuff->illength, n);
+
+    return (ProcSetResLabel(client));
+}
+
+static int
+SProcSetResUID(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xSetResUIDReq);
+    swapl(&stuff->id, n);
+    swaps(&stuff->resourceType, n);
+    swapl(&stuff->uid, n);
+
+    return (ProcSetResUID(client));
+}
+
+static int
+SProcGetClientAttributes(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xGetClientAttributesReq);
+    swapl(&stuff->id, n);
+
+    return (ProcGetClientAttributes(client));
+}
+
+static int
+SProcGetClientLabel(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xGetClientLabelReq);
+    swapl(&stuff->id, n);
+    swaps(&stuff->mask, n);
+
+    return (ProcGetClientLabel(client));
+}
+
+static int
+SProcGetPropAttributes(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xGetPropAttributesReq);
+    swapl(&stuff->id, n);
+    swapl(&stuff->atom, n);
+    swaps(&stuff->mask, n);
+
+    return (ProcGetPropAttributes(client));
+}
+
+static int
+SProcGetResAttributes(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xGetResAttributesReq);
+    swapl(&stuff->id, n);
+    swaps(&stuff->resourceType, n);
+    swaps(&stuff->mask, n);
+
+    return (ProcGetResAttributes(client));
+}
+
+static int
+SProcMakeTPWindow(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xMakeTPWindowReq);
+    swapl(&stuff->id, n);
+
+    return (ProcMakeTPWindow(client));
+}
+
+static int
+SProcMakeTrustedWindow(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xMakeTrustedWindowReq);
+    swapl(&stuff->id, n);
+
+    return (ProcMakeTrustedWindow(client));
+}
+
+static int
+SProcMakeUntrustedWindow(ClientPtr client)
+{
+    int n;
+
+    REQUEST(xMakeUntrustedWindowReq);
+    swapl(&stuff->id, n);
+
+    return (ProcMakeUntrustedWindow(client));
+}
+
+/*
+ * Set PolyInstantiation Info. 
+ * Normally a get(prop) will
+ * get the prop. that has match sl, uid of the client. Setting
+ * enabled to true will get only the prop. corresponding to
+ * sl, uid specified instead of that of client. This is used
+ * by dtwm/dtfile in special motif lib. 
+ */
+static int
+ProcSetPolyInstInfo(ClientPtr client)
+{
+    bslabel_t *sl;
+    int        err_code;
+
+    REQUEST(xSetPolyInstInfoReq);
+    REQUEST_AT_LEAST_SIZE(xSetPolyInstInfoReq);
+
+    /*
+     * Check for policy here
+     */
+    if (err_code = xtsol_policy(TSOL_RES_POLYINFO, TSOL_MODIFY, NULL,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    sl = (bslabel_t *)(stuff + 1);
+
+    tsolpolyinstinfo.enabled = stuff->enabled;
+    tsolpolyinstinfo.uid = (uid_t) stuff->uid;
+    tsolpolyinstinfo.sl = lookupSL(sl);
+
+    return (client->noClientException);
+}
+
+static int
+ProcSetPropLabel(ClientPtr client)
+{
+    bslabel_t   *sl;
+    WindowPtr    pWin;
+    TsolPropPtr  tsolprop;
+    PropertyPtr  pProp;
+    int          err_code;
+    
+    REQUEST(xSetPropLabelReq);
+
+    REQUEST_AT_LEAST_SIZE(xSetPropLabelReq);
+
+
+    pWin = LookupWindow(stuff->id, client);
+    if (!pWin)
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_WINDOW, TSOL_MODIFY, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    if (!ValidAtom(stuff->atom))
+    {
+        client->errorValue = stuff->atom;
+        return (BadAtom);
+    }
+
+    /* first see if property already exists */
+    pProp = wUserProps (pWin);
+    while (pProp)
+    {
+        if (pProp->propertyName == stuff->atom)
+            break;
+        pProp = pProp->next;
+    }
+
+    if (!pProp)
+    {
+        /* property does not exist */
+        client->errorValue = stuff->atom;
+        return (BadAtom);
+    }
+    tsolprop = (TsolPropPtr)(pProp->secPrivate);
+
+    sl = (bslabel_t *)(stuff + 1);
+
+    if (!blequal(tsolprop->sl, sl))
+    {
+	if (err_code = xtsol_policy(TSOL_RES_SL, TSOL_MODIFY, sl,
+				    client, TSOL_ALL, tsolprop->sl))
+	{
+	    return (err_code);
+	}
+	tsolprop->sl = lookupSL(sl);
+    }
+    
+    return (client->noClientException);
+}
+
+static int
+ProcSetPropUID(ClientPtr client)
+{
+    WindowPtr   pWin;
+    TsolPropPtr tsolprop;
+    PropertyPtr pProp;
+    int         err_code;
+
+    REQUEST(xSetPropUIDReq);
+
+    REQUEST_SIZE_MATCH(xSetPropUIDReq);
+    
+    pWin = LookupWindow(stuff->id, client);
+    if (!pWin)
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_WINDOW, TSOL_MODIFY, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    if (!ValidAtom(stuff->atom))
+    {
+        client->errorValue = stuff->atom;
+        return (BadAtom);
+    }
+
+    /* first see if property already exists */
+    pProp = wUserProps (pWin);
+    while (pProp)
+    {
+        if (pProp->propertyName == stuff->atom)
+            break;
+        pProp = pProp->next;
+    }
+
+    if (!pProp)
+    {
+        /* property does not exist */
+        client->errorValue = stuff->atom;
+        return (BadAtom);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_UID, TSOL_MODIFY, NULL,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    tsolprop = (TsolPropPtr)(pProp->secPrivate);
+    tsolprop->uid = stuff->uid;
+
+    return (client->noClientException);
+}
+
+static int
+ProcSetResLabel(ClientPtr client)
+{
+    bslabel_t  *sl;
+    PixmapPtr   pMap;
+    WindowPtr   pWin;
+    xEvent      message;
+    TsolResPtr  tsolres;
+    DrawablePtr pDraw;
+    int         err_code;
+    
+    REQUEST(xSetResLabelReq);
+
+    REQUEST_AT_LEAST_SIZE(xSetResLabelReq);
+
+    sl = (bslabel_t *)(stuff + 1);
+    switch (stuff->resourceType)
+    {
+        case SESSIONHI: /* set server session HI */
+            if (err_code = xtsol_policy(TSOL_RES_SL, TSOL_MODIFY, sl,
+                                        client, TSOL_ALL, (void *)NULL))
+            {
+                return (err_code);
+            }
+            memcpy(&SessionHI, sl, SL_SIZE);
+            return (client->noClientException);
+        case SESSIONLO: /* set server session LO */
+            if (err_code = xtsol_policy(TSOL_RES_SL, TSOL_MODIFY, sl,
+                                        client, TSOL_ALL, (void *)NULL))
+            {
+                return (err_code);
+            }
+            memcpy(&SessionLO, sl, SL_SIZE);
+            return (client->noClientException);
+        case IsWindow:
+            pWin = LookupWindow(stuff->id, client);
+            if (pWin)
+            {
+                tsolres =
+                    (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+            }
+            else
+            {
+                client->errorValue = stuff->id;
+                return (BadWindow);
+            }
+            if (err_code = xtsol_policy(TSOL_RES_WINDOW, TSOL_MODIFY, pWin,
+                                        client, TSOL_ALL, (void *)MAJOROP))
+            {
+                return (err_code);
+            }
+            break;
+        case IsPixmap:
+            pMap = (PixmapPtr)LookupIDByType(stuff->id, RT_PIXMAP);
+            if (pMap)
+            {
+                tsolres =
+                    (TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+            }
+            else
+            {
+                client->errorValue = stuff->id;
+                return (BadPixmap);
+            }
+            if (err_code = xtsol_policy(TSOL_RES_PIXMAP, TSOL_MODIFY, pMap,
+                                        client, TSOL_ALL, (void *)MAJOROP))
+            {
+                return (err_code);
+            }
+            break;
+    }
+
+    if (!blequal(tsolres->sl, sl))
+    {
+	if (err_code = xtsol_policy(TSOL_RES_SL, TSOL_MODIFY, sl,
+				    client, TSOL_ALL, tsolres->sl))
+	{
+	    return (err_code);
+	}
+	tsolres->sl = lookupSL(sl);
+    }
+
+    /* generate the notify event for windows */
+
+    if (stuff->resourceType == IsWindow)
+    {
+        pWin = LookupWindow(stuff->id, client);
+        message.u.u.type = ClientMessage; /* 33 */
+        message.u.u.detail = 32;
+        message.u.clientMessage.window = RootOf(pWin);
+        message.u.clientMessage.u.l.type =
+            MakeAtom("_TSOL_CMWLABEL_CHANGE", 21, 1);
+        message.u.clientMessage.u.l.longs0 = RootOfClient(pWin);
+        message.u.clientMessage.u.l.longs1 = stuff->id;
+        DeliverEventsToWindow(pWin, &message, 1,
+                              SubstructureRedirectMask, NullGrab, 0);
+
+    }
+    return (client->noClientException);
+}
+
+static int
+ProcSetResUID(ClientPtr client)
+{
+    int       ScreenNumber;
+    PixmapPtr pMap;
+    WindowPtr pWin;
+    TsolResPtr tsolres;
+    int        err_code;
+
+    REQUEST(xSetResUIDReq);
+
+    REQUEST_SIZE_MATCH(xSetResUIDReq);
+
+    switch (stuff->resourceType)
+    {
+        case STRIPEHEIGHT:
+            if (err_code = xtsol_policy(TSOL_RES_STRIPE, TSOL_MODIFY, NULL,
+                                        client, TSOL_ALL, (void *)MAJOROP))
+            {
+                return (err_code);
+            }
+            StripeHeight = stuff->uid;
+            ScreenNumber = stuff->id;
+
+        /* set Screen Stripe Size  */
+        DoScreenStripeHeight(ScreenNumber);
+        ScreenStripeHeight [ScreenNumber] = StripeHeight;
+
+        return (client->noClientException);
+        case RES_OUID:
+            if (err_code = xtsol_policy(TSOL_RES_WOWNER, TSOL_MODIFY, NULL,
+                                        client, TSOL_ALL, (void *)MAJOROP))
+            {
+                return (err_code);
+            }
+            OwnerUID = stuff->uid;
+            OwnerUIDint = OwnerUID;
+            AddUID(&OwnerUIDint);
+            return (client->noClientException);
+        case IsWindow:
+            pWin = LookupWindow(stuff->id, client);
+            if (pWin)
+            {
+                tsolres =
+                    (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+            }
+            else
+            {
+                client->errorValue = stuff->id;
+                return (BadWindow);
+            }
+            if (err_code = xtsol_policy(TSOL_RES_WINDOW, TSOL_MODIFY, pWin,
+                                        client, TSOL_ALL, (void *)MAJOROP))
+            {
+                return (err_code);
+            }
+            break;
+        case IsPixmap:
+            pMap = (PixmapPtr)LookupIDByType(stuff->id, RT_PIXMAP);
+            if (pMap)
+            {
+                tsolres =
+                    (TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+            }
+            else
+            {
+                client->errorValue = stuff->id;
+                return (BadPixmap);
+            }
+            if (err_code = xtsol_policy(TSOL_RES_PIXMAP, TSOL_MODIFY, pMap,
+                                        client, TSOL_ALL, (void *)MAJOROP))
+            {
+                return (err_code);
+            }
+            break;
+        default:
+            return (BadValue);
+    }
+    
+    if (err_code = xtsol_policy(TSOL_RES_UID, TSOL_MODIFY, NULL,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    tsolres->uid = stuff->uid;
+
+    return (client->noClientException);
+}
+
+static int
+ProcGetClientAttributes(ClientPtr client)
+{
+    int         n;
+    int         err_code;
+    ClientPtr   res_client; /* resource owner client */
+    TsolInfoPtr tsolinfo, res_tsolinfo;
+    WindowPtr	pWin;
+
+    xGetClientAttributesReply rep;
+    
+    REQUEST(xGetClientAttributesReq);
+    REQUEST_SIZE_MATCH(xGetClientAttributesReq);
+
+    /* Valid window check */
+    /* Valid window check */
+    if ((pWin = LookupWindow(stuff->id, client)) == NULL)
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+
+    if (!(res_client = clients[CLIENT_ID(stuff->id)]))
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_CLIENT, TSOL_READ, (void *)stuff->id,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    tsolinfo = GetClientTsolInfo(client);
+    res_tsolinfo = GetClientTsolInfo(res_client);
+
+    /* Transfer the client info to reply rec */
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.trustflag = (res_tsolinfo->forced_trust == 1 
+	|| res_tsolinfo->trusted_path) ? (BYTE)1 : (BYTE)0;
+    rep.uid = (CARD32) res_tsolinfo->uid;
+    rep.pid = (CARD32) res_tsolinfo->pid;
+    rep.gid = (CARD32) res_tsolinfo->gid;
+    rep.auditid = (CARD32) res_tsolinfo->auid;
+    rep.sessionid = (CARD32) res_tsolinfo->sid;
+    rep.iaddr = (CARD32) res_tsolinfo->iaddr;
+    rep.length = (CARD32) 0;
+
+    if (client->swapped)
+    {
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+        swapl(&rep.uid, n);
+        swapl(&rep.pid, n);
+        swapl(&rep.gid, n);
+        swapl(&rep.auditid, n);
+        swapl(&rep.sessionid, n);
+        swapl(&rep.iaddr, n);
+    }
+
+    WriteToClient(client, sizeof(xGetClientAttributesReply), (char *)&rep);
+
+    return (client->noClientException);
+}
+
+static int
+ProcGetClientLabel(ClientPtr client)
+{
+    int         n;
+    int         reply_length;
+    int         err_code;
+    Bool        write_to_client = 0;
+    bslabel_t   *sl;
+    ClientPtr   res_client; /* resource owner client */
+    TsolInfoPtr tsolinfo, res_tsolinfo;
+    WindowPtr	pWin;
+
+    xGenericReply rep;
+
+    REQUEST(xGetClientLabelReq);
+    REQUEST_SIZE_MATCH(xGetClientLabelReq);
+
+    /* Valid window check */
+    if ((pWin = LookupWindow(stuff->id, client)) == NULL)
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+
+    if (!(res_client = clients[CLIENT_ID(stuff->id)]))
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_CLIENT, TSOL_READ, (void *)stuff->id,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    tsolinfo = GetClientTsolInfo(client);
+    res_tsolinfo = GetClientTsolInfo(res_client);
+
+    /* Transfer the client info to reply rec */
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+
+    /* allocate temp storage for labels */
+    sl = (bslabel_t *)(ALLOCATE_LOCAL(SL_SIZE));
+    rep.data00 = rep.data01 = 0;
+    if (sl == NULL)
+        return (BadAlloc);
+    
+    /* fill the fields as per request mask */
+    if (stuff->mask & RES_SL)
+    {
+        memcpy(sl, res_tsolinfo->sl, SL_SIZE);
+        rep.data00 = SL_SIZE;
+    }
+    
+    rep.length = (CARD32)(rep.data00)/4;
+
+    if (rep.length > 0)
+    {
+        reply_length = rep.length*4;
+        write_to_client = 1;
+    }
+    if (client->swapped)
+    {
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+        swapl(&rep.data00, n);
+        swapl(&rep.data01, n);
+    }
+
+    WriteToClient(client, sizeof(xGenericReply), (char *)&rep);
+
+    if (write_to_client == 1)
+    {
+        WriteToClient(client, reply_length, (char *)sl);
+    }
+    DEALLOCATE_LOCAL(sl);
+
+    return (client->noClientException);
+}
+
+static int
+ProcGetPropAttributes(ClientPtr client)
+{
+    int          n;
+    int          reply_length;
+    int          extralen;
+    int          err_code;
+    Bool         write_to_client = 0;
+    PropertyPtr  pProp;
+    bslabel_t   *sl;
+    WindowPtr    pWin;
+    TsolPropPtr  tsolprop, tmp_prop;
+    TsolInfoPtr  tsolinfo = GetClientTsolInfo(client);
+
+    xGetPropAttributesReply rep;
+
+    REQUEST(xGetPropAttributesReq);
+
+    REQUEST_SIZE_MATCH(xGetPropAttributesReq);
+
+    pWin = LookupWindow(stuff->id, client);
+    if (pWin)
+    {
+        tsolprop = (TsolPropPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+    }
+    else
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    if (!ValidAtom(stuff->atom))
+    {
+        client->errorValue = stuff->atom;
+        return (BadAtom);
+    }
+
+    /* first see if property already exists */
+    pProp = wUserProps (pWin);
+    while (pProp)
+    {
+        if (pProp->propertyName == stuff->atom)
+            break;
+        pProp = pProp->next;
+    }
+
+    if (!pProp)
+    {
+        /* property does not exist */
+        client->errorValue = stuff->atom;
+        return (BadAtom);
+    }
+    tsolprop = (TsolPropPtr)(pProp->secPrivate);
+    tmp_prop = tsolprop;
+    while (tmp_prop)
+    {
+        if (tsolpolyinstinfo.enabled)
+        {
+            if (tmp_prop->uid == tsolpolyinstinfo.uid &&
+                tmp_prop->sl == tsolpolyinstinfo.sl)
+            {
+                tsolprop = tmp_prop;
+                break;
+            }
+        }
+        else
+        {
+            if (tmp_prop->uid == tsolinfo->uid &&
+                tmp_prop->sl == tsolinfo->sl)
+            {
+                tsolprop = tmp_prop;
+                break;
+            }
+        }
+        tmp_prop = tmp_prop->next;
+    }
+    if (!tsolprop)
+    {
+        return (client->noClientException);
+    }
+    if (stuff->mask & RES_UID)
+    {
+        rep.uid = tsolprop->uid;
+    }
+
+    /* allocate temp storage for labels */
+    sl = (bslabel_t *)(ALLOCATE_LOCAL(SL_SIZE));
+    rep.sllength = rep.illength = 0;
+    if (sl == NULL)
+        return (BadAlloc);
+    
+    /* fill the fields as per request mask */
+    if (stuff->mask & RES_SL)
+    {
+        memcpy(sl, tsolprop->sl, SL_SIZE);
+        rep.sllength = SL_SIZE;
+    }
+
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.length = (CARD32) (rep.sllength)/4;
+
+    if (rep.length > 0)
+    {
+        reply_length = rep.length*4;
+        write_to_client = 1;
+    }
+    if (client->swapped)
+    {
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+        swapl(&rep.uid, n);
+        swaps(&rep.sllength, n);
+        swaps(&rep.illength, n);
+    }
+
+    WriteToClient(client, sizeof(xGetPropAttributesReply), (char *)&rep);
+
+    if (write_to_client == 1)
+    {
+        WriteToClient(client, reply_length, (char *)sl);
+    }
+    DEALLOCATE_LOCAL(sl);
+
+    return (client->noClientException);
+}
+
+static int
+ProcGetResAttributes(ClientPtr client)
+{
+    int         n;
+    int         reply_length;
+    int         extralen;
+    int         err_code;
+    Bool        write_to_client = 0;
+    bslabel_t  *sl;
+    PixmapPtr   pMap;
+    WindowPtr   pWin;
+    TsolResPtr  tsolres;
+
+    xGetResAttributesReply rep;
+
+    REQUEST(xGetResAttributesReq);
+
+    REQUEST_SIZE_MATCH(xGetResAttributesReq);
+
+    if (stuff->mask & RES_STRIPE)
+    {
+        rep.uid = ScreenStripeHeight[stuff->id];
+    }
+    if (stuff->mask & RES_OUID)
+    {
+        rep.owneruid = OwnerUID;
+    }
+    if (stuff->resourceType == IsWindow && 
+        (stuff->mask & (RES_UID | RES_SL )))
+    {
+        pWin = LookupWindow(stuff->id, client);
+        if (pWin)
+        {
+            tsolres = (TsolResPtr)
+                (pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+        }
+        else
+        {
+            client->errorValue = stuff->id;
+            return (BadWindow);
+        }
+        if (err_code = xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pWin,
+                                    client, TSOL_ALL, (void *)MAJOROP))
+        {
+            return (err_code);
+        }
+    }
+    if (stuff->resourceType == IsPixmap && 
+        (stuff->mask & (RES_UID | RES_SL )))
+    {
+        pMap = (PixmapPtr)LookupIDByType(stuff->id, RT_PIXMAP);
+        if (pMap)
+        {
+            tsolres = (TsolResPtr)
+                (pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+        }
+        else
+        {
+            client->errorValue = stuff->id;
+            return (BadPixmap);
+        }
+        if (err_code = xtsol_policy(TSOL_RES_PIXMAP, TSOL_READ, pMap,
+                                    client, TSOL_ALL, (void *)MAJOROP))
+        {
+            return (err_code);
+        }
+    }
+
+    if (stuff->mask & RES_UID)
+    {
+        rep.uid = tsolres->uid;
+    }
+
+    /* allocate temp storage for labels */
+    sl = (bslabel_t *)(ALLOCATE_LOCAL(SL_SIZE));
+    rep.sllength = rep.illength = rep.iillength = 0;
+    if (sl == NULL)
+        return (BadAlloc);
+    
+    /* fill the fields as per request mask */
+    if (stuff->mask & RES_SL)
+    {
+        memcpy(sl, tsolres->sl, SL_SIZE);
+        rep.sllength = SL_SIZE;
+    }
+
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.length = (CARD32) (rep.sllength)/4;
+
+    if (rep.length > 0)
+    {
+        reply_length = rep.length*4;
+        write_to_client = 1;
+    }
+    if (client->swapped)
+    {
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+        swapl(&rep.uid, n);
+        swapl(&rep.owneruid, n);
+        swaps(&rep.sllength, n);
+        swaps(&rep.illength, n);
+        swaps(&rep.iillength, n);
+    }
+
+    WriteToClient(client, sizeof(xGetResAttributesReply), (char *)&rep);
+
+    if (write_to_client == 1)
+    {
+            WriteToClient(client, reply_length, (char *)sl);
+    }
+    DEALLOCATE_LOCAL(sl);
+
+    return (client->noClientException);
+}
+
+int
+ProcMakeTPWindow(ClientPtr client)
+{
+    WindowPtr pWin, pParent;
+    int       err_code;
+    extern void ReflectStackChange(WindowPtr, WindowPtr, VTKind);
+
+
+    REQUEST(xMakeTPWindowReq);
+    REQUEST_SIZE_MATCH(xMakeTPWindowReq);
+
+    pWin = LookupWindow(stuff->id, client);
+
+    /* window should not be root but child of root */
+    if (!pWin || (!pWin->parent))
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_TPWIN, TSOL_MODIFY, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+
+    pParent = pWin->parent;
+    if (pParent->firstChild != pWin)
+    {
+        tpwin = (WindowPtr)NULL;
+        ReflectStackChange(pWin, pParent->firstChild, VTStack);
+    }
+    tpwin = pWin;
+
+    /*
+     * Force kbd & ptr ungrab. This will cause
+     * screen to lock even when kbd/ptr grabbed by
+     * a client
+     */
+    BreakAllGrabs(client);
+    return (client->noClientException);
+}
+
+/*
+ * Turn on window's Trusted bit
+ */
+static int
+ProcMakeTrustedWindow(ClientPtr client)
+{
+    WindowPtr    pWin;
+    int          err_code;
+    TsolInfoPtr  tsolinfo;
+
+    REQUEST(xMakeTrustedWindowReq);
+    REQUEST_SIZE_MATCH(xMakeTrustedWindowReq);
+
+    pWin = LookupWindow(stuff->id, client);
+
+    /* window should not be root but child of root */
+    if (!pWin || (!pWin->parent))
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_TPWIN, TSOL_MODIFY, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    tsolinfo = GetClientTsolInfo(client);    
+    /* Turn on Trusted bit of the window */
+    tsolinfo->forced_trust = 1;
+    return (client->noClientException);
+}
+
+/*
+ * Turn off window's Trusted bit
+ */
+static int
+ProcMakeUntrustedWindow(ClientPtr client)
+{
+    WindowPtr    pWin;
+    int          err_code;
+    TsolInfoPtr  tsolinfo;
+
+    REQUEST(xMakeUntrustedWindowReq);
+    REQUEST_SIZE_MATCH(xMakeUntrustedWindowReq);
+
+    pWin = LookupWindow(stuff->id, client);
+
+    /* window should not be root but child of root */
+    if (!pWin || (!pWin->parent))
+    {
+        client->errorValue = stuff->id;
+        return (BadWindow);
+    }
+    if (err_code = xtsol_policy(TSOL_RES_TPWIN, TSOL_MODIFY, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (err_code);
+    }
+    tsolinfo = GetClientTsolInfo(client);    
+    tsolinfo->forced_trust = 0;
+    tsolinfo->trusted_path = FALSE;
+    
+    return (client->noClientException);
+}
+
+/*
+ * Break keyboard & ptr grabs of clients other than
+ * the requesting client.
+ * Called from ProcMakeTPWindow.
+ */
+static void
+BreakAllGrabs(ClientPtr client)
+{
+    ClientPtr	    grabclient;
+    DeviceIntPtr    keybd = inputInfo.keyboard;
+    GrabPtr         kbdgrab = keybd->grab;
+    DeviceIntPtr    mouse = inputInfo.pointer;
+    GrabPtr         ptrgrab = mouse->grab;
+
+	if (kbdgrab) {
+	    	grabclient = clients[CLIENT_ID(kbdgrab->resource)];
+		if (client->index != grabclient->index)
+			(*keybd->DeactivateGrab)(keybd);
+	}
+
+	if (ptrgrab) {
+	    	grabclient = clients[CLIENT_ID(ptrgrab->resource)];
+		if (client->index != grabclient->index)
+			(*mouse->DeactivateGrab)(mouse);
+        }
+}
+
+/*
+ * Trusted Network interface module. Uses tsix API
+ */
+
+static void
+TsolSetClientInfo(ClientPtr client)
+{
+	bslabel_t *sl;
+	bslabel_t admin_low;
+	priv_set_t *privs;
+	const au_tid64_addr_t *tid64;
+	const au_mask_t *amask;
+	OsCommPtr oc = (OsCommPtr)client->osPrivate;
+	register ConnectionInputPtr oci = oc->input;
+	int fd = oc->fd;
+	ucred_t *uc = NULL;
+	extern  au_id_t ucred_getauid(const ucred_t *uc);
+	extern  au_asid_t ucred_getasid(const ucred_t *uc);
+	extern  const au_mask_t *ucred_getamask(const ucred_t *uc);
+	extern  const au_tid64_addr_t *ucred_getatid(const ucred_t *uc);
+
+	TsolInfoPtr tsolinfo = (TsolInfoPtr)
+		(client->devPrivates[tsolClientPrivateIndex].ptr);
+
+	/* Get client attributes from the socket */
+	if (getpeerucred(fd, &uc) == -1) {
+		tsolinfo->uid = (uid_t)(-1);
+		tsolinfo->sl = NULL;
+		perror("getpeerucred failed\n");
+		ErrorF("SUN_TSOL: Cannot get client attributes\n");
+		return;
+	}
+
+	/* Extract individual fields from the cred structure */
+	tsolinfo->zid = ucred_getzoneid(uc);
+	tsolinfo->uid = ucred_getruid(uc);
+	tsolinfo->euid = ucred_geteuid(uc);
+	tsolinfo->gid = ucred_getrgid(uc);
+	tsolinfo->egid = ucred_getegid(uc);
+	tsolinfo->pid = ucred_getpid(uc);
+	sl = ucred_getlabel(uc);
+	tsolinfo->sl = (bslabel_t *)lookupSL(sl);
+
+	/* Set privileges */
+        privs = (priv_set_t *)ucred_getprivset(uc, PRIV_EFFECTIVE);
+	if ((tsolinfo->privs = priv_allocset()) != NULL) {
+		if (privs == NULL) {
+			priv_emptyset(tsolinfo->privs);
+		} else {
+			priv_copyset(privs, tsolinfo->privs);
+		}
+	}
+
+	/* Set audit info */
+	tsolinfo->auinfo.ai_auid = ucred_getauid(uc);
+	tsolinfo->auinfo.ai_asid = ucred_getasid(uc);
+	if ((amask = ucred_getamask(uc)) != NULL) {
+	    tsolinfo->auinfo.ai_mask = *amask;
+	}
+	if ((tid64 = ucred_getatid(uc)) != NULL) {
+#ifdef	_LP64
+	    tsolinfo->auinfo.ai_termid = *tid64;
+#else
+	    tsolinfo->auinfo.ai_termid.at_type = tid64->at_type;
+	    tsolinfo->auinfo.ai_termid.at_port = (tid64->at_port.at_major & MAXMIN32);
+	    tsolinfo->auinfo.ai_termid.at_port |= (tid64->at_port.at_major & MAXMAJ32) <<
+                NBITSMINOR32;
+	    tsolinfo->auinfo.ai_termid.at_addr[0] = *(tid64->at_addr);
+#endif
+	}
+	ucred_free(uc);
+
+	tsolinfo->priv_debug = FALSE;
+
+
+	/* 
+	 * For remote hosts, the uid is determined during access control
+	 * using Secure RPC
+	 */
+	if (tsolinfo->zid == (zoneid_t)-1) {
+		tsolinfo->client_type = CLIENT_REMOTE;
+	} else {
+		tsolinfo->client_type = CLIENT_LOCAL;
+	}
+
+	
+	/* Set Trusted Path for local clients */
+	if (tsolinfo->zid == GLOBAL_ZONEID) {
+		tsolinfo->trusted_path = TRUE;
+		client->trustLevel = XSecurityClientTrusted;
+	}else {
+		tsolinfo->trusted_path = FALSE;
+		client->trustLevel = XSecurityClientUntrusted;
+	}
+
+        tsolinfo->forced_trust = 0;
+        tsolinfo->iaddr = 0;
+
+	bsllow(&admin_low);
+	/* Set reasonable defaults for remote clients */
+	if (tsolinfo->client_type == CLIENT_REMOTE) {
+		struct sockaddr sname;
+		socklen_t namelen;
+		char *rhost;
+		tsol_host_type_t host_type; 
+		struct sockaddr_in *so = (struct sockaddr_in *)&sname;
+		extern tsol_host_type_t tsol_getrhtype(char *);
+
+		namelen = sizeof (sname);
+		if (getpeername(fd, &sname, &namelen) == 0) {
+			tsolinfo->iaddr = so->sin_addr.s_addr;
+			rhost = inet_ntoa(so->sin_addr);
+			host_type = tsol_getrhtype(rhost);
+			if ((host_type == SUN_CIPSO) && 
+					blequal(tsolinfo->sl, &admin_low)) {
+				tsolinfo->trusted_path = TRUE;
+				client->trustLevel = XSecurityClientTrusted;
+				priv_fillset(tsolinfo->privs);
+			}
+		}
+	}
+	/* TBD: Initialize audit context here */
+	{
+		au_mask_t mask;
+		struct passwd *pw = getpwuid(getuid());
+		if ((pw != NULL) && (!au_user_mask(pw->pw_name, &mask))) {
+	if (!getaudit(&tsolinfo->aw_auinfo)) {
+			tsolinfo->aw_auinfo.ai_mask.am_success = mask.am_success;
+			tsolinfo->aw_auinfo.ai_mask.am_failure = mask.am_failure;
+                    }
+	 }
+		tsolinfo->sid = 0;
+	}
+}
+
+static Bool
+CheckNetName (addr, len, closure)
+    unsigned char    *addr;
+    short            len;
+    pointer         closure;
+{
+    return (len == strlen ((char *) closure) &&
+            strncmp ((char *) addr, (char *) closure, len) == 0);
+}
+
+
+XID
+TsolCheckAuthorization(unsigned int name_length, char *name, unsigned int data_length, 
+	char *data, ClientPtr client, char **reason)
+{
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	char	domainname[128];
+	char	netname[128];
+
+	 
+	/* Workstation Owner not set */
+	if (OwnerUID == (uid_t )(-1)) {
+		if (HasTrustedPath(tsolinfo)) {
+			return (CheckAuthorization(name_length, name, data_length,
+				data, client, reason));
+		}
+	} else {
+		/* Reject all invalid SLs or invalid uids for local hosts */
+		if (tsolinfo->sl == NULL || !bslvalid(tsolinfo->sl) || 
+			(tsolinfo->client_type == CLIENT_LOCAL && 
+				tsolinfo->uid == (uid_t)-1)) {
+			return ((XID)-1);
+		}
+
+		/* uid needs to be retrieved from Secure RPC */
+		if (tsolinfo->uid == -1) {
+			/* Temporary kludge */
+			tsolinfo->uid = OwnerUID;
+		}
+
+		/* 
+		 * Workstation Owner set, client must be within label
+		 * range or have trusted path
+		 */
+		if (tsolinfo->uid == OwnerUID) {
+			if ((bldominates(tsolinfo->sl, &SessionLO) &&
+				bldominates(&SessionHI, tsolinfo->sl)) ||
+				(HasTrustedPath(tsolinfo))) {
+				return ((XID)(tsolinfo->uid));
+			}
+		} else {
+			if (tsolinfo->uid != 0) {
+				/* Access check based on uid */
+				getdomainname(domainname, sizeof(domainname));
+				if (!user2netname(netname, tsolinfo->uid, domainname)) {
+					return ((XID)-1);
+				}
+				if (ForEachHostInFamily (FamilyNetname, CheckNetName,
+						(pointer) netname)) {
+					return ((XID)(tsolinfo->uid));
+				} else {
+					return (CheckAuthorization(name_length, name, data_length,
+						data, client, reason));
+				}
+			} else
+				/* Allow all connections from global zones for now */
+				if (HasTrustedPath(tsolinfo)) {
+					return ((XID)(tsolinfo->uid));
+			}
+		}
+	}
+}
+
+static void
+TsolProcessKeyboard(xEvent *xE, KeyClassPtr keyc)
+{
+    extern void InitHotKey(HotKeyPtr hk);
+    extern void HandleHotKey();
+
+    if (xE->u.u.type == KeyPress)
+    {
+	if (!hotkey.initialized)
+	    InitHotKey(&hotkey);
+
+        if (((xE->u.u.detail == hotkey.key) &&
+		(keyc->state != 0 && keyc->state == hotkey.shift)) ||
+            ((xE->u.u.detail == hotkey.altkey) &&
+		(keyc->state != 0 && keyc->state == hotkey.altshift)))
+            		HandleHotKey();
+    }
+}
+
+static char
+TsolCheckPropertyAccess(ClientPtr client, WindowPtr pWin, ATOM propertyName,
+	Mask access_mode)
+{
+	char	action;
+	PropertyPtr pProp;
+
+        pProp = wUserProps (pWin);
+        while (pProp)
+        {
+            if (pProp->propertyName == propertyName)
+		break;
+	    pProp = pProp->next;
+        }
+
+	if (pProp == NULL)
+		return SecurityAllowOperation;
+
+	if (access_mode & SecurityReadAccess) {
+		if (!PolyProperty(propertyName, pWin) &&
+		    xtsol_policy(TSOL_RES_PROPERTY, TSOL_READ,
+			pProp, client, TSOL_ALL, (void *)MAJOROP))
+		   return SecurityIgnoreOperation;
+		else
+		   return SecurityAllowOperation;
+	}
+
+	if (access_mode & SecurityWriteAccess) {
+		if (!PolyProperty(propertyName, pWin) &&
+		    xtsol_policy(TSOL_RES_PROPERTY, TSOL_MODIFY,
+			pProp, client, TSOL_ALL, (void *)MAJOROP))
+		   return SecurityIgnoreOperation;
+		else
+		   return SecurityAllowOperation;
+	}
+
+	if (access_mode & SecurityDestroyAccess) {
+		if (!PolyProperty(propertyName, pWin) &&
+		    xtsol_policy(TSOL_RES_PROPERTY, TSOL_DESTROY,
+			pProp, client, TSOL_ALL, (void *)MAJOROP))
+		   return SecurityIgnoreOperation;
+		else
+		   return SecurityAllowOperation;
+	}
+
+	return SecurityAllowOperation;
+}
+
+/*
+ * Return TRUE if host is cipso
+ */
+int
+host_is_cipso(int fd)
+{
+	struct sockaddr sname;
+	socklen_t namelen;
+	char *rhost;
+	tsol_host_type_t host_type; 
+	struct sockaddr_in *so = (struct sockaddr_in *)&sname;
+	extern tsol_host_type_t tsol_getrhtype(char *);
+
+	namelen = sizeof (sname);
+	if (getpeername(fd, &sname, &namelen) == -1) {
+		perror("getsockname: failed\n");
+		return FALSE;
+	}
+
+	rhost = inet_ntoa(so->sin_addr);
+	host_type = tsol_getrhtype(rhost);
+	if (host_type == SUN_CIPSO) {
+		return TRUE;
+	}
+
+	return FALSE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolinfo.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,384 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)tsolinfo.h 1.11     06/03/07 SMI"
+
+
+#ifndef    _TSOL_INFO_H
+#define    _TSOL_INFO_H
+
+#ifdef    __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+
+#include <tsol/label.h>
+#include <sys/tsol/tndb.h>
+#include <bsm/audit.h>
+#include <sys/mkdev.h>
+#include <ucred.h>
+#include "tsolpriv.h"
+#include "misc.h"
+#include "dixstruct.h"
+#include "keysym.h"
+
+/*********************************
+ *
+ * DEBUG INFO
+ *
+ *********************************/
+
+
+#ifdef DEBUG
+extern unsigned long tsoldebug;           /* in tsolutils.c */
+extern char *pidtopname(pid_t pid);       /* converts pid to process name */
+/*
+ * Various debug flags, set to tsoldebug
+ */
+#define TSOLD_SELECTION    0x00000001
+#define TSOLD_POLICY       0x00000002
+#define TSOLD_EVENT        0x00000004
+#define TSOLD_PROTO        0x00000008
+#define TSOLD_ILFLOAT      0x00000010
+#define TSOLD_XAUDIT       0x00000020
+#define MAXNAME            16             /* 15 chars of process name stored */
+#endif /* DEBUG */
+
+
+/*********************************
+ *
+ * CONSTANTS
+ *
+ *********************************/
+
+
+/*
+ * X audit events start from 9101 in audit_uevents.h. The first 2 events
+ * are non-protocol ones viz. ClientConnect, mapped to 9101 and
+ * ClientDisconnect, mapped to 9102.
+ * The protocol events are mapped from 9103 onwards in the serial order
+ * of their respective protocol opcode, for eg, the protocol UngrabPointer
+ * which is has a protocol opcode 27 is mapped to 9129 (9102 + 27).
+ * All extension protocols are mapped to a single audit event AUE_XExtension
+ * as opcodes are assigined dynamically to these protocols. We set the
+ * extension protocol opcode to be 128, one more than the last standard opcode.
+ */
+#define XAUDIT_Q_SIZE     1024          /* audit queue size for x server */
+#define XAUDIT_OFFSET     9102
+#define XAUDIT_EXTENSION  128
+#define XTSOL_HOME        "/usr/openwin/server/tsol"
+#define MAX_CLIENT        16
+#define MAX_SLS           16            /* used in atom */
+#define MAX_POLYPROPS     128           /* used in property */
+#define DEF_UID           (uid_t)0      /* uid used for default objects */
+#define INVALID_UID       (uid_t)0xFFFF /* invalid uid */
+/*
+ * Various flags for TsolInfoRec, TsolResRec
+ */
+#define TSOL_IIL           0x0000001    /* iil changed for window */
+#define TSOL_DOXAUDIT      0x0000002    /* write X audit rec if set */
+#define TSOL_AUDITEVENT    0x0000004    /* this event mask selected for audit */
+#define CONFIG_AUDITED     0x0000008    /* this priv has been asserted for */
+#define DAC_READ_AUDITED   0x0000010    /* the same object before */
+#define DAC_WRITE_AUDITED  0x0000020
+#define MAC_READ_AUDITED   0x0000040
+#define MAC_WRITE_AUDITED  0x0000080
+#define TRUSTED_MASK	   0x0000100	/* Window has Trusted Path */
+
+/*
+ * Polyinstantiated property/selections
+ */
+#define POLY_SIZE          16           /* increase the list 16 at a time */
+#define CONFIG_PRIV_FILE   "config.privs"
+#define CONFIG_EXTENSION_FILE "config.extensions"
+
+#define PROCVECTORSIZE (256)
+
+enum tsolconfig_types {
+	TSOL_ATOM = 0,
+	TSOL_PROPERTY,
+	TSOL_SELECTION,
+	TSOL_EXTENSION,
+	TSOL_PRIVILEGE
+};
+
+typedef enum tsolconfig_types tsolconfig_t;
+
+/*
+ * Masks corresponding  various types
+ */
+#define TSOLM_ATOM	1
+#define TSOLM_PROPERTY	(1 << 1)
+#define TSOLM_SELECTION	(1 << 2)
+
+#define SL_SIZE blabel_size()
+
+/*********************************
+ *
+ * MACROS
+ *
+ *********************************/
+
+
+#define WindowIsRoot(pWin) (pWin && (pWin->parent == NullWindow))
+#define DrawableIsRoot(pDraw)\
+	(pDraw && (pDraw->id == WindowTable[pDraw->pScreen->myNum]->drawable.id))
+
+/*
+ * True if client is part of TrustedPath
+ */
+#define HasTrustedPath(tsolinfo)\
+	(tsolinfo->trusted_path ||\
+	(tsolinfo->forced_trust == 1))
+
+#define XTSOLTrusted(pWin)\
+	(((TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr))->flags & TRUSTED_MASK)
+
+/*
+ * win_selection can be  a process attribute or  a priv
+ */
+#define HasWinSelection(tsolinfo)\
+	(priv_test((tsolinfo->privs), PRIV_WIN_SELECTION))
+
+
+/*********************************
+ *
+ * DATA STRUCTURES
+ *
+ *********************************/
+enum client_types {
+	CLIENT_LOCAL,
+	CLIENT_REMOTE
+};
+
+typedef enum client_types client_type_t;
+
+/*
+ * Extended attributes for each client.
+ * Most of the information comes from getpeerucred()
+ */
+typedef struct _TsolInfo {
+    uid_t               uid;            /* real user id */
+    uid_t               euid;           /* effective user id */
+    gid_t               gid;            /* real group id */
+    gid_t               egid;           /* effective group id */
+    pid_t               pid;            /* process id */
+    zoneid_t		zid;		/* zone id */
+    priv_set_t          *privs;         /* privileges */
+    bslabel_t		*sl;            /* sensitivity label */
+    u_long              sid;            /* session id */
+    u_long              iaddr;          /* internet addr */
+    Bool		trusted_path;	/* has trusted path */
+    Bool		priv_debug;	/* do privilege debugging */
+    u_long              flags;          /* various flags */
+    int                 forced_trust;   /* client masked as trusted */
+    struct auditinfo_addr	auinfo; /* audit addr */
+    au_id_t		auid;		/* audit id */
+    au_tid_addr_t	tid;		/* terminal  id */
+    auditinfo_t		aw_auinfo;		/* audit info */
+    client_type_t    	client_type;    /* Local or Remote client */
+} TsolInfoRec, *TsolInfoPtr;
+
+/*
+ * per resource info
+ */
+typedef struct _TsolRes {
+    bslabel_t  *sl;                     /* sensitivity label */
+    uid_t       uid;                    /* user id */
+    u_long      flags;                  /* various flags */
+    pid_t       pid;                    /* who created it */
+} TsolResRec, *TsolResPtr;
+
+/*
+ * per property info. useful for polyprops
+ */
+typedef struct _TsolProp {
+    bslabel_t         *sl;              /* sensitivity label */
+    uid_t              uid;             /* user id */
+    long               size;            /* size of data in (format/8) bytes */
+    unsigned char     *data;            /* value */
+    struct _TsolProp  *next;            /* points to next struct */
+    struct _TsolProp  *head;            /* head of poly'd prop list */
+    pid_t              pid;             /* who created it */
+} TsolPropRec, *TsolPropPtr;
+
+/*
+ * per selection info. useful for polyinstantiated selns
+ */
+typedef struct _TsolSeln {
+    bslabel_t  *sl;                     /* sensitivity label */
+    uid_t       uid;                    /* user id */
+    TimeStamp   lastTimeChanged;
+    Window      window;                 /* owner of seln */
+    WindowPtr   pWin;                   /* corresponds to the owner win */
+    ClientPtr   client;                 /* client that owns the window */
+    struct _TsolSeln *next;             /* points to next struct */
+    pid_t       pid;                    /* who created it */
+} TsolSelnRec, *TsolSelnPtr;
+
+#if 0
+/* 
+ * NodeRec struct defined here is used instead of the
+ * one defined in atom.c. This is used in policy functions
+ */
+typedef struct _Node {
+    struct _Node  *left,   *right;
+    Atom           a;
+    unsigned int   fingerPrint;
+    char          *string;
+#ifdef TSOL
+    int            slsize;              /* size of the sl array below */
+    int            clientCount;         /* actual no. of clients */
+    int            IsSpecial;           /* special atoms for polyprops */
+    bslabel_t    **sl;                  /* an array of sl's. */
+#endif /* TSOL */
+} NodeRec, *NodePtr;
+
+#endif
+
+#define NODE_SLSIZE	16	/* increase sl array by this amount */
+typedef struct _TsolNodeRec {
+	unsigned int flags;
+	int slcount; 		/* no. of SLs referenced */
+	int slsize;		/* size of the sl array */
+	int IsSpecial;
+	bslabel_t **sl;
+
+} TsolNodeRec, *TsolNodePtr;
+
+/*
+ * if polyinst true, the name list is polyinstantiated
+ * if false, the everything except the list is polyinstantiated
+ * NOTE: Default for seln: polyinstantiate the list
+ *       Default for prop: polyinstantiate everything except the list
+ */
+typedef struct _TsolPolyAtom {
+    int     polyinst;
+    int     size;                       /* max size of the list */
+    int     count;                      /* how many are actually valid */
+    char  **name;
+} TsolPolyAtomRec, *TsolPolyAtomPtr;
+
+/*
+ * PolyInstInfo represents if a get request will match the
+ * client's sl,uid for this or it will use the polyinstinfo
+ * information to retrieve values for prop/selection
+ */
+typedef struct _TsolPolyInstInfo {
+    int        enabled;                 /* if true use following sl, uid */
+    uid_t      uid;
+    bslabel_t  *sl;
+} TsolPolyInstInfoRec, *TsolPolyInstInfoPtr;
+
+
+/*
+ *  Disable flags for extensions
+ */
+typedef struct _extensionFlag {
+    Bool disableACCESSX;          
+    Bool disableDPS;
+    Bool disableDBE;
+    Bool disableDPMS;
+    Bool disableEVI;
+    Bool disableFBPM;
+    Bool disableLBX;
+    Bool disableSCREENSAVER;  
+    Bool disableMITSHM;
+    Bool disableMITMISC;
+    Bool disableMULTIBUFFER;
+    Bool disableSECURITY;
+    Bool disableSHAPE;
+    Bool disableALLPLANES;
+    Bool disableDGA;
+    Bool disableOVL;
+    Bool disableRECORD;
+    Bool disableSYNC;
+    Bool disableIA;
+    Bool disableCUP;
+    Bool disableAPPGROUP;
+    Bool disableXCMISC;
+    Bool disableXIE;               
+    Bool disableXINPUT;
+    Bool disableXINERAMA;
+    Bool disableXTEST;
+} ExtensionFlag;
+
+
+/*
+ * Hot Key structure
+ * caches keycode/mask for
+ * a primary & alternate
+ * Hot Keys
+ */
+typedef struct _HotKeyRec {
+	int      initialized;
+	KeyCode  key;	/* Primary key */
+	unsigned shift;	/* Primary modifier/shift */
+	KeyCode	 altkey;	/* Alternate key */
+	unsigned altshift;	/* Alternate modifier/shift */
+} HotKeyRec, *HotKeyPtr;
+
+/*********************************
+ *
+ * EXTERNS
+ *
+ *********************************/
+
+
+extern  WindowPtr *WindowTable;
+extern  TsolPolyAtomRec tsolpolyprop;
+extern  TsolPolyAtomRec tsolpolyseln;
+extern  int PolyProperty(Atom atom, WindowPtr pWin);
+extern  int PolySelection(Atom atom);
+extern  TsolPolyInstInfoRec tsolpolyinstinfo;
+extern  int tsolWindowPrivateIndex;
+extern  int tsolPixmapPrivateIndex;
+extern  uid_t OwnerUID;                 /* Workstation owner uid */
+
+
+/*********************************
+ *
+ * FUNCTION PROTOTYPES
+ *
+ *********************************/
+
+
+void  TsolReadPolyAtoms(char *filename, TsolPolyAtomPtr polyatomptr);
+extern WindowPtr TopClientWin(WindowPtr pWin);
+extern WindowPtr RootWin(WindowPtr pWin);
+extern WindowPtr XYToWin(int x, int y); /* Defined in events.c */
+extern Window RootOf(WindowPtr pWin);
+extern Window RootOfClient(WindowPtr pWin);
+
+
+#ifdef    __cplusplus
+}
+#endif
+
+#endif    /* _TSOL_INFO_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolmodule.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,74 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)tsolmodule.c 1.3     06/03/07 SMI"
+
+/*
+ * X Trusted Extension module for X.org X server 
+ */
+
+#include "xf86Module.h"
+
+static MODULESETUPPROTO(xtsolSetup);
+extern void TsolExtensionInit(INITARGS);
+
+ExtensionModule xtsolExt = {
+    TsolExtensionInit,
+    "SUN_TSOL",
+    NULL,
+    NULL,
+    NULL
+};
+
+static XF86ModuleVersionInfo VersRec =
+{
+	"xtsol",
+	MODULEVENDORSTRING,
+	MODINFOSTRING1,
+	MODINFOSTRING2,
+	XORG_VERSION_CURRENT,
+	1, 0, 0,
+	ABI_CLASS_EXTENSION,
+	ABI_EXTENSION_VERSION,
+	MOD_CLASS_EXTENSION,
+	{0,0,0,0}
+};
+
+/*
+ * Data for the loader
+ */
+XF86ModuleData xtsolModuleData = { &VersRec, xtsolSetup, NULL };
+
+static pointer
+xtsolSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    LoadExtension(&xtsolExt, FALSE);
+
+    /* Need a non-NULL return value to indicate success */
+    return (pointer)1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolpolicy.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,3496 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)tsolpolicy.c 1.9     06/03/07 SMI"
+
+#include "X.h"
+#define		NEED_REPLIES
+#define		NEED_EVENTS
+#include <stdio.h>
+#include <bsm/auditwrite.h>
+#include <bsm/audit_kevents.h>
+#include <bsm/audit_uevents.h>
+#include "Xproto.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "input.h"
+#include "inputstr.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "selection.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include <syslog.h>
+#include "tsolinfo.h"
+#include "tsolpolicy.h"
+
+extern TsolInfoPtr GetClientTsolInfo();
+extern int tsolWindowPrivateIndex;
+extern int tsolPixmapPrivateIndex;
+extern WindowPtr TsolPointerWindow();
+extern char *NameForAtom(Atom atom);
+extern char *xsltos(bslabel_t *sl);
+extern char *ProtoNames[];
+extern InputInfo inputInfo;
+
+extern unsigned long tsoldebug;  /* from tsolutils.c */
+extern Bool priv_win_colormap;
+extern Bool priv_win_config;
+extern Bool priv_win_devices;
+extern Bool priv_win_dga;
+extern Bool priv_win_fontpath;
+
+#define SAMECLIENT(client, xid) ((client)->index == CLIENT_ID(xid))
+
+#ifdef DEBUG
+struct optimization_stats {
+	unsigned long pixel_count;
+	unsigned long window_count;
+};
+struct optimization_stats opt_stats = {0, 0};
+
+int	xtsol_debug = XTSOL_FAIL;	/* set it to 0 if no logging is required */
+void XTsolErr(char *err_type, int protocol, bslabel_t *osl,
+              uid_t ouid, pid_t opid, char *opname,
+              bslabel_t *ssl, uid_t suid, pid_t spid,
+              char *spname, char *method, int isstring, void *xid);
+
+#define XTSOLERR(err_type, protocol, osl, ouid, opid, opname,\
+                 ssl, suid, spid, spname, method, xid)\
+                 (void) XTsolErr(err_type, protocol, osl, ouid, opid,\
+                                 opname, ssl, suid, spid, spname, method,\
+                                 0, (void *) xid)
+#define SXTSOLERR(err_type, protocol, osl, ouid, opid, opname,\
+                  ssl, suid, spid, spname, method, xid)\
+                  (void) XTsolErr(err_type, protocol, osl, ouid, opid,\
+                                  opname, ssl, suid, spid, spname,\
+                                  method, 1, (void *) xid)
+#else  /* !DEBUG */
+#define XTSOLERR(err_type, protocol, osl, ouid, opid, opname,\
+                 ssl, suid, spid, spname, method, xid)
+#define SXTSOLERR(err_type, protocol, osl, ouid, opid, opname,\
+                  ssl, suid, spid, spname, method, xid)
+#endif /* DEBUG */
+
+int object_float(TsolInfoPtr, WindowPtr);
+
+static void
+set_audit_flags(TsolInfoPtr tsolinfo)
+{
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        tsolinfo->flags &= ~TSOL_AUDITEVENT;
+    if (!(tsolinfo->flags & TSOL_DOXAUDIT))
+        tsolinfo->flags |= TSOL_DOXAUDIT;
+    
+}
+
+static void
+unset_audit_flags(TsolInfoPtr tsolinfo)
+{
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        tsolinfo->flags &= ~TSOL_AUDITEVENT;
+    if (tsolinfo->flags & TSOL_DOXAUDIT)
+        tsolinfo->flags &= ~TSOL_DOXAUDIT;
+    
+}
+
+/*
+ * return 1 for success and 0 for failure
+ * this routine contains the privd debugging for the system
+ * as well as auditing the success or failure of use of priv.
+ * Priv debugging will be done later TBD
+ */
+
+int
+xpriv_policy(priv_set_t *set, priv_t priv, xresource_t res,
+			 xmethod_t method, void *subject, Bool do_audit)
+{
+	int	i;
+	static int logopened = FALSE;
+	int	status = 0;
+	int audit_status = 0;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	if (priv_test(set, priv))
+	{
+		status = 1;
+		audit_status = 1;
+	}
+	else
+	{
+		audit_status = 0;        
+		if (!logopened)
+		{
+			/* LOG_USER doesn't work */
+			openlog("xsun", 0, LOG_LOCAL0);
+			logopened = TRUE;
+		}
+		/* if priv debugging is on, allow this priv to succeed */
+		if (tsolinfo->priv_debug)
+		{
+#ifdef DEBUG
+			ErrorF("%s:Allowed priv %ld\n", tsolinfo->pname, priv);
+#endif /* DEBUG */
+			syslog(LOG_DEBUG|LOG_LOCAL0, 
+                   "DEBUG: %s pid %ld lacking privilege %d to %d %d",
+                   "xclient", tsolinfo->pid, priv, method, res);
+			status = 1;
+            audit_status = 1;
+		}
+	}
+	if (do_audit)
+		auditwrite(AW_USEOFPRIV, audit_status, priv, AW_APPEND, AW_END);
+	return (status);
+}	/* xpriv_policy */
+
+
+/*
+ * The read/modify window policy are for window attributes & not
+ * for window contents. read/modify pixel handle the contents policy
+ */
+/*
+ * read_window
+ */
+int
+read_window(xresource_t res, xmethod_t method, void *resource,
+			void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	ClientPtr ownerclient;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolInfoPtr tsolownerinfo;	/*client who owns the window */
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+	ownerclient = clients[CLIENT_ID(pWin->drawable.id)];
+	tsolownerinfo = GetClientTsolInfo(ownerclient);
+	/*
+	 * Anyone can read RootWindow attributes
+	 */
+	if (WindowIsRoot(pWin))
+	{
+		return (PASSED);
+	}
+	/* optimization based on client id */
+	if (SAMECLIENT(client, pWin->drawable.id))
+	{
+#ifdef DEBUG
+		opt_stats.window_count++;
+#endif /* DEBUG */
+		return PASSED;
+	}
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!(blequal(tsolinfo->sl, tsolres->sl)))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+							 res, method, client, do_audit) ||
+				(tsolownerinfo && HasWinSelection(tsolownerinfo))) 
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+			    XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read window", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		/* uid == DEF_UID means public window, shared read */
+		if (!(XTSOLTrusted(pWin) ||
+			tsolres->uid == DEF_UID ||
+			tsolinfo->uid == tsolres->uid))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read window", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}	/* read_window */
+
+/*
+ * modify_window
+ */
+int
+modify_window(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+	/* optimization based on client id */
+	if (SAMECLIENT(client, pWin->drawable.id))
+	{
+#ifdef DEBUG
+		opt_stats.window_count++;
+#endif /* DEBUG */
+		return PASSED;
+	}
+	/*
+	 * Trusted Path Windows require Trusted Path attrib
+	 */
+	if (XTSOLTrusted(pWin) && !HasTrustedPath(tsolinfo))
+    {
+        XTSOLERR("tp", (int) misc, tsolres->sl,
+                 tsolres->uid, tsolres->pid, tsolres->pname,
+                 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+                 tsolinfo->pname, "modify window", pWin->drawable.id);
+        ret_stat = err_code;
+	}    
+	/*
+	 * MAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify window", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify window", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+
+	if (do_audit)
+        {
+            set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+        }
+	return (ret_stat);
+}	/* modify_window */
+
+/*
+ * create_window
+ */
+int
+create_window(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;	/* parent window */
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr  tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+	/*
+	 * Anyone can create a child of root window
+	 */
+	if (WindowIsRoot(pWin))
+	{
+		return (PASSED);
+	}
+	/*
+	 * Trusted Path Windows required Trusted Path attrib
+	 */
+	if (XTSOLTrusted(pWin))
+	{
+		if (!HasTrustedPath(tsolinfo))
+		{
+			/*
+			XTSOLERR("tp", (int) misc, tsolres->sl,
+					 tsolres->uid, tsolres->pid, tsolres->pname,
+					 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "create window", pWin->drawable.id); */
+			return (err_code);
+		}
+	}
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+			if (!SAMECLIENT(client, pWin->parent->drawable.id) &&
+                (tsolinfo->flags & TSOL_AUDITEVENT))
+            {
+				do_audit = TRUE;
+            }
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "create window", pWin->drawable.id); 
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+			if (!SAMECLIENT(client, pWin->parent->drawable.id) &&
+                (tsolinfo->flags & TSOL_AUDITEVENT))
+            {
+				do_audit = TRUE;
+            }
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "create window", pWin->drawable.id); 
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_SLABEL, tsolres->sl,
+				   AW_APPEND, AW_END);
+    }
+
+	return (ret_stat);
+}	/* create_window */
+
+/*
+ * destroy_window
+ */
+int
+destroy_window(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr  tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+	/*
+	 * Trusted Path Windows required Trusted Path attrib
+	 */
+	if (XTSOLTrusted(pWin))
+	{
+		if (!HasTrustedPath(tsolinfo))
+		{
+			XTSOLERR("tp", (int) misc, tsolres->sl,
+					 tsolres->uid, tsolres->pid, tsolres->pname,
+					 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "destroy window", pWin->drawable.id);
+			return (err_code);
+		}
+	}
+	/*
+	 * MAC Check
+	 */
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "destroy window", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid ||
+			!same_client(client, pWin->drawable.id))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "destroy window", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}	/* destroy_window */
+
+/*
+ * read_pixel: used for reading contents of drawable like GetImage
+ */
+int
+read_pixel(xresource_t res, xmethod_t method, void *resource,
+		   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadDrawable;
+	int obj_code = 0;
+	XID obj_id = (XID)NULL;
+	DrawablePtr pDraw = resource;
+	ClientPtr client = subject;
+	PixmapPtr pMap = NullPixmap;
+	WindowPtr pWin = NullWindow;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres;
+
+	/*
+	 * Public/default objects check here
+	 */
+
+	if (pDraw->type == DRAWABLE_WINDOW)
+	{
+		pWin = (WindowPtr)LookupWindow(pDraw->id, client);
+		if (pWin == NULL)
+			return (PASSED); /* server will handle bad params */
+		tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+		obj_code = AW_XWINDOW;
+		obj_id = pWin->drawable.id;
+	}
+	else if (pDraw->type == DRAWABLE_PIXMAP)
+	{
+		pMap = (PixmapPtr)LookupIDByType(pDraw->id, RT_PIXMAP);
+		if (pMap == NULL)
+			return (PASSED); /* server will handle bad params */
+		tsolres = (TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+		obj_code = AW_XPIXMAP;
+		obj_id = pMap->drawable.id;
+	}
+	else
+		return (PASSED); /* UNDRAWABLE_WINDOW */
+
+	/* based on client id bypass MAC/DAC */
+	if (!SAMECLIENT(client, pDraw->id))
+	{
+	    /*
+	     * Trusted Path Windows require Trusted Path attrib when a 
+             * client doesn't have the PRIV_WIN_DGA privilege.
+	     */
+	    if ((pDraw->type == DRAWABLE_WINDOW) &&
+            XTSOLTrusted(pWin) &&
+            !HasTrustedPath(tsolinfo) &&
+            !priv_win_dga)
+		{
+		    XTSOLERR("tp", (int) misc, tsolres->sl,
+					 tsolres->uid, tsolres->pid, tsolres->pname,
+					 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "read pixel", pWin->drawable.id);
+			return (err_code);
+	    }
+		/*
+	 	 * MAC Check
+		 */
+		if (policy_flags & TSOL_MAC)
+		{
+			if (!bldominates(tsolinfo->sl, tsolres->sl))
+			{
+                if (!(tsolinfo->flags & MAC_READ_AUDITED) &&
+                    (tsolinfo->flags & TSOL_AUDITEVENT))
+                {
+                    do_audit = TRUE;
+                    tsolinfo->flags |= MAC_READ_AUDITED;
+                }
+				/* PRIV override? */
+				if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+								 res, method, client, do_audit))
+				{
+					ret_stat = PASSED;
+				}
+				else
+				{
+					XTSOLERR("mac", (int) misc, tsolres->sl,
+							 tsolres->uid, tsolres->pid, tsolres->pname,
+							 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+							 tsolinfo->pname, "read pixel", pDraw->id);
+					ret_stat = err_code;
+				}
+			}
+		}
+		/*
+	 	 * DAC Check
+	 	 */
+		if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+		{
+			if (tsolinfo->uid != tsolres->uid)
+			{
+                if (!(tsolinfo->flags & DAC_READ_AUDITED) &&
+                    (tsolinfo->flags & TSOL_AUDITEVENT))
+                {
+                    do_audit = TRUE;
+                    tsolinfo->flags |= DAC_READ_AUDITED;
+                }
+				if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_READ,
+								 res, method, client, do_audit))
+				{
+					ret_stat = PASSED;
+				}
+				else
+				{
+					XTSOLERR("mac", (int) misc, tsolres->sl,
+							 tsolres->uid, tsolres->pid, tsolres->pname,
+							 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+							 tsolinfo->pname, "read pixel", pDraw->id);
+					ret_stat = err_code;
+				}
+			}
+		}
+	}  /* end if !SAMECLIENT */
+	else
+	{
+#ifdef DEBUG
+		opt_stats.pixel_count++;
+#endif /* DEBUG */
+	}
+
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(obj_code, obj_id, tsolres->uid, AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* read_pixel */
+
+/*
+ * modify_pixel
+ */
+int
+modify_pixel(xresource_t res, xmethod_t method, void *resource,
+			 void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadDrawable;
+	int obj_code = 0;
+	XID obj_id = (XID)NULL;
+	DrawablePtr pDraw = resource;
+	ClientPtr client = subject;
+	PixmapPtr pMap = NullPixmap;
+	WindowPtr pWin = NullWindow;
+	TsolInfoPtr tsolinfo;
+	TsolResPtr tsolres;
+	
+	/*
+	 * Trusted Path Windows required Trusted Path attrib
+	 */
+	tsolinfo = GetClientTsolInfo(client);
+
+	if (pDraw->type == DRAWABLE_WINDOW)
+	{
+		pWin = (WindowPtr)LookupWindow(pDraw->id, client);
+		if (pWin == NULL)
+			return (PASSED);
+		tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+		obj_code = AW_XWINDOW;
+		obj_id = pWin->drawable.id;
+	}
+	else if (pDraw->type == DRAWABLE_PIXMAP)
+	{
+		pMap = (PixmapPtr)LookupIDByType(pDraw->id, RT_PIXMAP);
+		if (pMap == NULL)
+			return (PASSED);
+		tsolres = (TsolResPtr) (pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+		obj_code = AW_XPIXMAP;
+		obj_id = pMap->drawable.id;
+	}
+	else
+		return (PASSED); /* UNDRAWABLE_WINDOW */
+
+	/* optimization based on client id */
+	if (!SAMECLIENT(client, pDraw->id))
+	{
+	    /*
+	     * Trusted Path Windows require Trusted Path attrib
+	     */
+	    if ((pDraw->type == DRAWABLE_WINDOW) &&
+            XTSOLTrusted(pWin) &&
+            !HasTrustedPath(tsolinfo))
+		{
+		    XTSOLERR("tp", (int) misc, tsolres->sl,
+					 tsolres->uid, tsolres->pid, tsolres->pname,
+					 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "modify pixel", pWin->drawable.id);
+			return (err_code);
+	    }
+		/*
+	 	 * You need  win_config priv to write to root window
+	 	 */
+		if (!priv_win_config && (pWin && WindowIsRoot(pWin)))
+		{
+            if (!(tsolinfo->flags & CONFIG_AUDITED) &&
+                (tsolinfo->flags & TSOL_AUDITEVENT))
+            {
+                do_audit = TRUE;
+                tsolinfo->flags |= CONFIG_AUDITED;
+            }
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_CONFIG,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify pixel", pDraw->id);
+				ret_stat = err_code;
+			}
+		}
+		/*
+		 * MAC Check
+		 */
+		if ((ret_stat == PASSED) && policy_flags & TSOL_MAC)
+		{
+			if (!blequal(tsolinfo->sl, tsolres->sl))
+			{
+                if (!(tsolinfo->flags & MAC_WRITE_AUDITED) &&
+                    (tsolinfo->flags & TSOL_AUDITEVENT))
+                {
+                    do_audit = TRUE;
+                    tsolinfo->flags |= MAC_WRITE_AUDITED;
+                }
+				if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+								 res, method, client, do_audit))
+				{
+					ret_stat = PASSED;
+				}
+				else
+				{
+					XTSOLERR("mac", (int) misc, tsolres->sl,
+							 tsolres->uid, tsolres->pid, tsolres->pname,
+							 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+							 tsolinfo->pname, "modify pixel", pDraw->id);
+					ret_stat = err_code;
+				}
+			}
+		}
+		/*
+	 	 * DAC Check
+	 	 */
+		if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+		{
+			if (tsolinfo->uid != tsolres->uid)
+			{
+                if (!(tsolinfo->flags & DAC_WRITE_AUDITED) &&
+                    (tsolinfo->flags & TSOL_AUDITEVENT))
+                {
+                    do_audit = TRUE;
+                    tsolinfo->flags |= DAC_WRITE_AUDITED;
+                }
+				if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+								 res, method, client, do_audit))
+				{
+					ret_stat = PASSED;
+				}
+				else
+				{
+					XTSOLERR("dac", (int) misc, tsolres->sl,
+							 tsolres->uid, tsolres->pid, tsolres->pname,
+							 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+							 tsolinfo->pname, "modify pixel", pDraw->id);
+					ret_stat = err_code;
+				}
+			}
+		}
+	}  /* end if SAMECLIENT */
+	else
+	{
+#ifdef DEBUG
+		opt_stats.pixel_count++;
+#endif /* DEBUG */
+	}
+
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(obj_code, obj_id, tsolres->uid, AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_pixel */
+
+/*
+ * read_pixmap
+ */
+int
+read_pixmap(xresource_t res, xmethod_t method, void *resource,
+			void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadPixmap;
+	PixmapPtr pMap = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr  tsolres =
+		(TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!bldominates(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read pixmap", pMap->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read pixmap", pMap->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XPIXMAP, pMap->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* read_pixmap */
+
+/*
+ * modify_pixmap
+ */
+int
+modify_pixmap(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadPixmap;
+	PixmapPtr pMap = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr  tsolres =
+		(TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify pixmap", pMap->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify pixmap", pMap->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XPIXMAP, pMap->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_pixmap */
+
+/*
+ * destroy_pixmap
+ */
+int
+destroy_pixmap(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadPixmap;
+	PixmapPtr pMap = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr  tsolres =
+		(TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+
+	/*
+	 * MAC Check
+	 */
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "destroy pixmap", pMap->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "destroy pixmap", pMap->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XPIXMAP, pMap->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* destroy_pixmap */
+
+/*
+ * read_client
+ */
+int
+read_client(xresource_t res, xmethod_t method, void *resource,
+			void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	ClientPtr res_client;
+	int	err_code = BadAccess;
+    Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr res_tsolinfo;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	if (!(res_client = clients[CLIENT_ID((XID)resource)]))
+	{
+		return (BadValue);
+	}
+	res_tsolinfo = GetClientTsolInfo(res_client);
+
+	/*
+	 * MAC Check
+	 */
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, res_tsolinfo->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, res_tsolinfo->sl,
+						 res_tsolinfo->uid, res_tsolinfo->pid,
+						 res_tsolinfo->pname, tsolinfo->sl,
+						 tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read client", resource);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != res_tsolinfo->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, res_tsolinfo->sl,
+						 res_tsolinfo->uid, res_tsolinfo->pid,
+						 res_tsolinfo->pname, tsolinfo->sl,
+						 tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read client", resource);
+				ret_stat = ret_stat;
+			}
+		}
+	}
+	/*
+	 * Trusted Path Windows required Trusted Path attrib
+	 */
+	if ((ret_stat == PASSED) && HasTrustedPath(res_tsolinfo))
+	{
+		if (!HasTrustedPath(tsolinfo))
+		{
+			XTSOLERR("tp", (int) misc, res_tsolinfo->sl,
+					 res_tsolinfo->uid, res_tsolinfo->pid,
+					 res_tsolinfo->pname, tsolinfo->sl,
+					 tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "read client", resource);
+			ret_stat = err_code;
+		}
+	}
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCLIENT, res_client->index, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}	/* read client */
+
+/*
+ * modify_client
+ * Special win_config priv used for ChangeSaveSet, SetCloseDownMode
+ */
+int
+modify_client(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadValue;
+    Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	if (priv_win_config)
+		return (PASSED);
+
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        do_audit = TRUE;
+	/*
+	 * Needs win_config priv
+	 */
+	if (xpriv_policy(tsolinfo->privs, PRIV_WIN_CONFIG,
+					 res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+	}
+	else
+	{
+		ret_stat = err_code;
+	}
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCLIENT, client->index, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}	/* modify_client */
+
+/*
+ * destroy_client
+ */
+int
+destroy_client(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	ClientPtr res_client;
+	int	err_code = BadValue;
+	Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr res_tsolinfo;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	if (!(res_client = clients[CLIENT_ID((XID)resource)]))
+	{
+		return (BadValue);
+	}
+
+	res_tsolinfo = GetClientTsolInfo(res_client);
+
+	/* Server a special client */
+	if (res_client == serverClient || res_tsolinfo == NULL)
+	{
+		if (client != serverClient)
+			return (BadValue);
+		else
+			return (PASSED); /* internal request */
+	}
+
+
+	/*
+	 * MAC Check
+	 */
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, res_tsolinfo->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, res_tsolinfo->sl,
+						 res_tsolinfo->uid, res_tsolinfo->pid,
+						 res_tsolinfo->pname, tsolinfo->sl,
+						 tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "destroy client", resource);
+				ret_stat = ret_stat;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != res_tsolinfo->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, res_tsolinfo->sl,
+						 res_tsolinfo->uid, res_tsolinfo->pid,
+						 res_tsolinfo->pname, tsolinfo->sl,
+						 tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "destroy client", resource);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * Trusted Path Windows required Trusted Path attrib
+	 */
+	if ((ret_stat == PASSED) && HasTrustedPath(res_tsolinfo))
+	{
+		if (!HasTrustedPath(tsolinfo))
+		{
+			XTSOLERR("tp", (int) misc, res_tsolinfo->sl,
+					 res_tsolinfo->uid, res_tsolinfo->pid,
+					 res_tsolinfo->pname, tsolinfo->sl,
+					 tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "destroy client", resource);
+			ret_stat = err_code;
+		}
+	}
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCLIENT, res_client->index, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}	/* destroy_client */
+
+/*
+ * read_gc
+ */
+int
+read_gc(xresource_t res, xmethod_t method, void *resource,
+		void *subject, xpolicy_t policy_flags, void *misc)
+{
+	return (access_xid(res, method, resource, subject, policy_flags,
+					   misc, RT_GC, PRIV_WIN_DAC_READ));
+}
+
+/*
+ * modify_gc
+ */
+int
+modify_gc(xresource_t res, xmethod_t method, void *resource,
+		  void *subject, xpolicy_t policy_flags, void *misc)
+{
+    unsigned int protocol = (unsigned int)misc;
+
+    return (access_xid(res, method, resource, subject, policy_flags,
+                       misc, RT_GC, PRIV_WIN_DAC_WRITE));    
+}
+
+/*
+ * read_font
+ */
+int
+read_font(xresource_t res, xmethod_t method, void *resource,
+		  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	return (access_xid(res, method, resource, subject, policy_flags,
+			misc, RT_FONT, PRIV_WIN_DAC_READ));
+}
+
+/*
+ * modify_font
+ */
+int
+modify_font(xresource_t res, xmethod_t method, void *resource,
+			void *subject, xpolicy_t policy_flags, void *misc)
+{
+	return (access_xid(res, method, resource, subject, policy_flags,
+					   misc,RT_FONT, PRIV_WIN_DAC_WRITE));
+}
+
+/*
+ * modify_cursor
+ */
+int
+modify_cursor(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	return (access_xid(res, method, resource, subject, policy_flags,
+					   misc, RT_CURSOR, PRIV_WIN_DAC_WRITE));
+}
+
+/*
+ * access_ccell: access policy for color cells. 
+ */
+int
+access_ccell(xresource_t res, xmethod_t method, void *resource, void *subject,
+             xpolicy_t policy_flags, void *misc)
+{
+#if TBD
+    int ret_stat = PASSED;
+    Bool do_audit = FALSE;
+    priv_t priv;
+    XID cmap_id = (XID)misc;
+    EntrySecAttrPtr  pentp = (EntrySecAttrPtr)resource;
+    ClientPtr client = (ClientPtr)subject;
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    /*
+     * MAC check
+     */
+    if (policy_flags & TSOL_MAC)
+    {
+        if (!blequal(tsolinfo->sl, pentp->sl))
+        {
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+            priv =
+                (method == TSOL_READ) ? PRIV_WIN_MAC_READ : PRIV_WIN_MAC_WRITE;
+            /*
+             * any colorcell owned by root is readable by all
+             */
+            if ((priv == PRIV_WIN_MAC_READ) && (pentp->uid == 0))
+                ret_stat = PASSED;
+            else if (xpriv_policy(tsolinfo->privs, priv,
+                                  res, method, client, do_audit))
+            {
+                ret_stat = PASSED;
+            }
+            else
+            {
+                XTSOLERR("clientid mac", (int)NULL, tsolinfo->sl,
+                         tsolinfo->uid, tsolinfo->pid, tsolinfo->pname,
+                         tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+                         tsolinfo->pname, "access ccell", cmap_id);
+                ret_stat = BadAccess;
+            }
+        }
+    }
+    /*
+     * DAC check
+     */
+    if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+    {
+        if (tsolinfo->uid != pentp->uid)
+        {
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+            priv = (method == TSOL_READ) ?
+                PRIV_WIN_DAC_READ : PRIV_WIN_DAC_WRITE;
+            /*
+             * any colorcell owned by root is readable by all
+             */
+            if ((priv == PRIV_WIN_DAC_READ) && (pentp->uid == 0))
+                ret_stat = PASSED;
+            else if (xpriv_policy(tsolinfo->privs, priv,
+                                  res, method, client, do_audit))
+            {
+                ret_stat = PASSED;
+            }
+            else
+            {
+                XTSOLERR("clientid dac", (int)NULL, tsolinfo->sl,
+                         tsolinfo->uid, tsolinfo->pid, tsolinfo->pname,
+                         tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+                         tsolinfo->pname, "access ccell", cmap_id);
+                ret_stat = BadAccess;                
+            }
+        }
+    }
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCOLORMAP, (u_long)cmap_id, tsolinfo->uid,
+                   AW_APPEND, AW_END);
+    }
+
+    return (ret_stat);
+#endif
+   return (PASSED);
+}
+
+/*
+ * read_ccell
+ */
+int
+read_ccell(xresource_t res, xmethod_t method, void *resource,
+           void *subject, xpolicy_t policy_flags, void *misc)
+{
+    if (priv_win_colormap)
+        return (PASSED);
+    else
+        return (access_ccell(res, method, resource, subject,
+                             policy_flags, misc));
+}
+
+/*
+ * modify_ccell
+ */
+int
+modify_ccell(xresource_t res, xmethod_t method, void *resource,
+             void *subject, xpolicy_t policy_flags, void *misc)
+{
+    if (priv_win_colormap)
+        return (PASSED);
+    else
+        return (access_ccell(res, method, resource, subject,
+                             policy_flags, misc));
+}
+
+/*
+ * destroy_ccell
+ */
+int
+destroy_ccell(xresource_t res, xmethod_t method, void *resource,
+             void *subject, xpolicy_t policy_flags, void *misc)
+{
+#ifdef TBD
+    EntrySecAttrPtr  pentp = (EntrySecAttrPtr)resource;
+    
+    if (priv_win_colormap)
+        return (PASSED);
+    else if ( pentp->sl == NULL) /* The cell is allocated by server */
+        return (PASSED);
+    else
+        return (access_ccell(res, method, resource, subject,
+                             policy_flags, misc));
+#endif 
+   return (PASSED);
+}
+
+/*
+ * read_cmap
+ */
+int
+read_cmap(xresource_t res, xmethod_t method, void *resource,
+		  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	ColormapPtr	pcmp = (ColormapPtr ) resource;
+
+	/* handle default colormap */
+	if (pcmp->flags & IsDefault)
+		return (PASSED);
+
+	return (access_xid(res, method, (void *)(pcmp->mid), subject, policy_flags,
+					   misc, RT_COLORMAP, PRIV_WIN_DAC_READ));
+}
+
+/*
+ * modify_cmap: resource passed is ColormapPtr & not an XID
+ */
+int
+modify_cmap(xresource_t res, xmethod_t method, void *resource,
+			void *subject, xpolicy_t policy_flags, void *misc)
+{
+	ColormapPtr	pcmp = (ColormapPtr ) resource;
+
+	/* modify default colormap ok */
+	if (pcmp->flags & IsDefault)
+		return (PASSED);
+
+	return (access_xid(res, method,(void *)(pcmp->mid) , subject, policy_flags,
+			misc, RT_COLORMAP, PRIV_WIN_DAC_WRITE));
+}
+
+/*
+ * install_cmap: both install/uninstall
+ */
+int
+install_cmap(xresource_t res, xmethod_t method, void *resource,
+			 void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+    Bool do_audit = FALSE;
+	ColormapPtr	pcmp = (ColormapPtr ) resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	int	err_code = BadColor;
+
+	/* handle default colormap */
+	if (pcmp->flags & IsDefault)
+		return (PASSED);
+
+    if (priv_win_colormap)
+        return (PASSED);
+
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        do_audit = TRUE;
+
+	/*
+	 * check only win_colormap priv
+	 */
+	if (xpriv_policy(tsolinfo->privs, PRIV_WIN_COLORMAP,
+					 res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+	}
+	else
+	{
+		XTSOLERR("install_cmap", (int) misc, tsolinfo->sl,
+				 tsolinfo->uid, tsolinfo->pid, tsolinfo->pname,
+				 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+				 tsolinfo->pname, "install_cmap", pcmp->mid);
+		ret_stat = err_code;
+	}
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCOLORMAP, pcmp->mid, tsolinfo->uid, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}
+
+/*
+ * access_xid: access policy for XIDs 
+ */
+int
+access_xid(xresource_t res, xmethod_t method, void *resource,
+		   void *subject, xpolicy_t policy_flags, void *misc, 
+		   RESTYPE res_type, priv_t which_priv)
+{
+	int ret_stat = PASSED;
+	int object_code = 0;
+	int	err_code; /* depends on type of XID */
+    Bool do_audit = FALSE;
+	XID object = (XID) resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = (TsolInfoPtr)NULL;
+
+	if (res_type == RT_NONE)
+		res_type = RES_TYPE(object);
+	/*
+	 * assign appropriate error code
+	 */
+	switch (res_type) {
+        case RT_PIXMAP:
+            err_code = BadPixmap;
+            object_code = AW_XPIXMAP;
+            break;
+		case RT_FONT:
+			err_code = BadFont;
+			object_code = AW_XFONT;
+			break;
+		case RT_GC:
+			err_code = BadGC;
+			object_code = AW_XGC;
+			break;
+		case RT_CURSOR:
+			err_code = BadCursor;
+			object_code = AW_XCURSOR;
+			break;
+		case RT_COLORMAP:
+			err_code = BadColor;
+			object_code = AW_XCOLORMAP;
+			break;
+		default:
+			err_code = BadValue;
+			break;
+	}
+	/*
+	 * DAC check is based on client isolation.
+	 */
+	if (policy_flags & TSOL_DAC)
+	{
+		if (!client_private(client, object))
+		{
+            tsolinfo = GetClientTsolInfo(client);
+            if (!tsolinfo)
+                return (err_code);
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			/* PRIV override? */
+			if (xpriv_policy(tsolinfo->privs, which_priv, res,
+							 method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("clientid", (int) misc, tsolinfo->sl,
+						 tsolinfo->uid, tsolinfo->pid, tsolinfo->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "access xid", object);
+				ret_stat = err_code;
+			}
+            if (do_audit)
+            {
+                set_audit_flags(tsolinfo);
+                auditwrite(object_code, (u_long)object, tsolinfo->uid,
+                           AW_APPEND, AW_END);
+            }
+		}
+	}
+	return (ret_stat);
+}	/* access_xid */
+
+/*
+ * modify_fontpath: requires win_fontpath priv
+ */
+int
+modify_fontpath(xresource_t res, xmethod_t method, void *resource,
+				void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadFont;
+    Bool do_audit = FALSE;
+	XID object = (XID)resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    if (priv_win_fontpath)
+        return (PASSED);
+
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        do_audit = TRUE;
+    
+	/*
+	 * No MAC & DAC. Check win_fontpath priv only
+	 */
+	if (xpriv_policy(tsolinfo->privs, PRIV_WIN_FONTPATH,
+					 res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+	}
+	else
+	{
+		ret_stat = err_code;
+	}
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XFONT, (u_long)object, tsolinfo->uid, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}
+
+/*
+ * read_devices: All kbd/ptr ctrl/mapping related access.
+ * requires win_devices priv
+ * BadAccess is not a valid error code for many protocols
+ * and does not work especially for SetPointerModifierMapping etc
+ */
+int
+read_devices(xresource_t res, xmethod_t method, void *resource,
+			 void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadValue;
+    Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    if (priv_win_devices)
+        return (PASSED);
+
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        do_audit = TRUE;
+    
+	/*
+	 * No MAC/DAC check. Needs win_devices priv
+	 */
+	if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DEVICES,
+					 res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+	}
+	else
+	{
+		ret_stat = err_code;
+	}
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCLIENT, client->index, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}
+
+/*
+ * modify_devices: All kbd/ptr ctrl/mapping related access.
+ * requires win_devices priv
+ */
+int
+modify_devices(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadAccess;
+    Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    if (priv_win_devices)
+        return (PASSED);
+
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        do_audit = TRUE;
+    
+	/*
+	 * No MAC/DAC check. Needs win_devices priv
+	 */
+	if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DEVICES,
+					 res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+	}
+	else
+	{
+		ret_stat = err_code;
+	}
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCLIENT, client->index, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}
+
+/*
+ * modify_acl
+ */
+int
+modify_acl(xresource_t res, xmethod_t method, void *resource,
+		   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadValue;
+    Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	if (priv_win_config)
+		return (PASSED);
+
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        do_audit = TRUE;
+    
+	/*
+	 * Needs win_config priv
+	 */
+    if (tsolinfo->uid != OwnerUID)
+    {
+	    if (xpriv_policy(tsolinfo->privs, PRIV_WIN_CONFIG, res,
+                         method, client, do_audit))
+	    {
+		    ret_stat = PASSED;
+	    }
+	    else
+	    {
+		    ret_stat = err_code;
+	    }
+    }
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCLIENT, client->index, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}
+
+/*
+ * read_atom
+ */
+int
+read_atom(xresource_t res, xmethod_t method, void *resource,
+		  void *subject, xpolicy_t policy_flags, void *misc)
+{
+
+	return PASSED;
+#if 0
+	int ret_stat = PASSED;
+	int	err_code = BadAtom;
+    Bool do_audit = FALSE;
+	NodePtr node = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	int	i, status;
+	int	protocol = (int)(misc);
+
+	/*
+	 * MAC Check is slightly different. We do a series of
+	 * MAC checks for all SLs in the table before we
+	 * apply privs
+	 */
+	status = FAILED;
+	if (policy_flags & TSOL_MAC)
+	{
+		for ( i = 0; i < node->clientCount; i++)
+		{
+			if (bldominates(tsolinfo->sl, node->sl[i]))
+			{
+				status = PASSED;
+				break;
+			}
+		}
+		if (status == FAILED)
+		{
+#ifdef DEBUG
+            if (xtsol_debug >= XTSOL_FAIL)
+		    {
+				ErrorF("\nmac failed:%s,subj(%s,%d,%d,%s),",
+					   ProtoNames[protocol], xsltos(tsolinfo->sl),
+					   tsolinfo->uid, tsolinfo->pid, tsolinfo->pname);
+				ErrorF("read atom, xid %s\n", NameForAtom(node->a));
+		    }
+#endif /* DEBUG */
+			/* PRIV override? */
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+							 res, method, client, do_audit))
+			{
+				status = PASSED;
+				ret_stat = PASSED;
+			}
+			else
+			{
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * No DAC check
+	 */
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XATOM, NameForAtom(node->a), AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+#endif
+
+}	/* read_atom */
+
+/*
+ * The read/modify window policy are for window attributes & not
+ * for window contents. read/modify pixel handle the contents policy
+ */
+/*
+ * read_property
+ */
+int
+read_property(xresource_t res, xmethod_t method, void *resource,
+	void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadAtom;
+	PropertyPtr pProp = resource;
+	ClientPtr client = subject;
+	TsolPropPtr tsolprop = (TsolPropPtr)(pProp->secPrivate);
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	/* Initialize property created internally by server */
+	if (tsolprop == NULL)
+	{
+            tsolprop = AllocTsolProp();
+            if (tsolprop == NULL)
+                return(BadAlloc);
+
+	    tsolprop->uid = getuid();
+	    tsolprop->sl = (bslabel_t *)lookupSL_low();
+            pProp->secPrivate = (pointer)tsolprop;
+	}
+
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!bldominates(tsolinfo->sl, tsolprop->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("mac", (int) misc, tsolprop->sl,
+						  tsolprop->uid, tsolprop->pid, tsolprop->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "read property",
+						  NameForAtom(pProp->propertyName));
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		/* uid == DEF_UID means public property, shared read */
+		if (!(tsolprop->uid == DEF_UID || tsolinfo->uid == tsolprop->uid))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("dac", (int) misc, tsolprop->sl,
+						  tsolprop->uid, tsolprop->pid, tsolprop->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "read property",
+						  NameForAtom(pProp->propertyName));
+				ret_stat = err_code;
+			}
+		}
+	}
+
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XPROPERTY, tsolinfo->uid, tsolprop->uid,
+				   NameForAtom(pProp->propertyName), AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* read_property */
+
+/*
+ * modify_property
+ */
+int
+modify_property(xresource_t res, xmethod_t method, void *resource,
+				void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadAtom;
+	PropertyPtr pProp = resource;
+	ClientPtr client = subject;
+	TsolPropPtr tsolprop = (TsolPropPtr)(pProp->secPrivate);
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	/* Initialize property created internally by server */
+	if (tsolprop == NULL)
+	{
+            tsolprop = AllocTsolProp();
+            if (tsolprop == NULL)
+                return(BadAlloc);
+
+	    tsolprop->uid = getuid();
+	    tsolprop->sl = (bslabel_t *)lookupSL_low();
+            pProp->secPrivate = (pointer)tsolprop;
+	}
+
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolprop->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("mac", (int) misc, tsolprop->sl,
+						  tsolprop->uid, tsolprop->pid, tsolprop->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "modify property",
+						  NameForAtom(pProp->propertyName));
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolprop->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("dac", (int) misc, tsolprop->sl,
+						  tsolprop->uid, tsolprop->pid, tsolprop->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "modify property",
+						  NameForAtom(pProp->propertyName));
+				ret_stat = err_code;
+			}
+		}
+	}
+
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XPROPERTY, tsolinfo->uid, tsolprop->uid,
+				   NameForAtom(pProp->propertyName), AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_property */
+
+/*
+ * destroy_property
+ */
+int
+destroy_property(xresource_t res, xmethod_t method, void *resource,
+				 void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadAtom;
+	PropertyPtr pProp = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolPropPtr tsolprop = (TsolPropPtr)(pProp->secPrivate);
+
+	/*
+	 * MAC Check
+	 */
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolprop->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("mac", (int) misc, tsolprop->sl,
+						  tsolprop->uid, tsolprop->pid, tsolprop->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "destroy property",
+						  NameForAtom(pProp->propertyName));
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolprop->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("dac", (int) misc, tsolprop->sl,
+						  tsolprop->uid, tsolprop->pid, tsolprop->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "destroy property",
+						  NameForAtom(pProp->propertyName));
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XPROPERTY, tsolinfo->uid, tsolprop->uid,
+				   NameForAtom(pProp->propertyName), AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* destroy_property */
+
+/*
+ * modify_grabwin
+ */
+int
+modify_grabwin(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadWindow;
+	Bool do_audit = FALSE;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres;
+
+	/*
+	 * Allow pointer grab on root window, as long as
+	 * pointer is currently in a window owned by
+	 * requesting client.
+	 */
+
+	if (WindowIsRoot(pWin))
+	{
+		pWin = TsolPointerWindow();
+		if (WindowIsRoot(pWin))
+			return (PASSED);
+	}
+	tsolres = (TsolResPtr) (pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read grabwin", pWin->drawable.id);
+                do_audit = FALSE;  /* don't audit this */
+                unset_audit_flags(tsolinfo);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid /* && tsolres->uid != 0 */)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read grabwin", pWin->drawable.id);
+                do_audit = FALSE;  /* don't audit this */
+                unset_audit_flags(tsolinfo);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/* Grab on trusted window requires TP */
+	if ((ret_stat == PASSED) && XTSOLTrusted(pWin))
+	{
+		if (!HasTrustedPath(tsolinfo))
+			ret_stat = err_code;
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_grabwin */
+
+/*
+ * modify_confwin - ConfineTo window access
+ */
+int
+modify_confwin(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+        /*if (priv_win_devices)
+        return (PASSED);*/
+
+	/*
+	 * confine window can be None. Root window is OK
+	 */
+
+	if (pWin == NullWindow || WindowIsRoot(pWin))
+	{
+		return (PASSED);
+	}
+	/*
+	 * MAC Check
+	 */
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read grabwin", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid /* && tsolres->uid != 0 */)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read grabwin", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/* Trusted window requires TP */
+	if ((ret_stat == PASSED) && XTSOLTrusted(pWin))
+	{
+		if (!HasTrustedPath(tsolinfo))
+			ret_stat = err_code;
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_confwin */
+
+/*
+ * create_srvgrab: GrabServer requires a priv
+ */
+int
+create_srvgrab(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+    if (priv_win_config)
+	{
+        return (PASSED);
+	}
+    else
+	{
+		return (check_priv(res, method, resource, subject, policy_flags, 
+						   misc, PRIV_WIN_CONFIG));
+	}
+}
+
+/*
+ * destroy_srvgrab: GrabServer requires a priv
+ */
+int
+destroy_srvgrab(xresource_t res, xmethod_t method, void *resource,
+				void *subject, xpolicy_t policy_flags, void *misc)
+{
+    if (priv_win_config)
+    {
+        return (PASSED);
+    }
+    else
+    {
+		return (check_priv(res, method, resource, subject, policy_flags, 
+						   misc, PRIV_WIN_CONFIG));
+	}
+}
+
+/*
+ * check_priv: Use this for all policies that require 
+ * no MAC/DAC, but a priv
+ */
+int
+check_priv(xresource_t res, xmethod_t method, void *resource,
+		   void *subject, xpolicy_t policy_flags, void *misc, priv_t priv)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadValue;
+    Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	/*
+	 * No MAC/DAC check.
+	 */
+    if (tsolinfo->flags & CONFIG_AUDITED)
+    {
+        do_audit = FALSE;
+    }
+    else if (tsolinfo->flags & TSOL_AUDITEVENT)
+    {
+        do_audit = TRUE;
+        tsolinfo->flags |= CONFIG_AUDITED;
+    }    
+	if (xpriv_policy(tsolinfo->privs, priv, res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+	}
+	else
+	{
+		ret_stat = err_code;
+	}
+    if (do_audit)
+    {
+        set_audit_flags(tsolinfo);
+        auditwrite(AW_XCLIENT, client->index, AW_APPEND, AW_END);
+    }
+	return (ret_stat);
+}
+
+/*
+ * Converts SL to string
+ */
+char *
+xsltos(bslabel_t *sl)
+{
+	char *slstring = NULL;
+
+	if (bsltos(sl, &slstring, 0, 
+		VIEW_INTERNAL|SHORT_CLASSIFICATION | LONG_WORDS | ALL_ENTRIES) <= 0)
+		return (NULL);
+	else
+		return slstring;
+}
+
+/*
+ * read_selection
+ */
+int
+read_selection(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadAtom;
+	Selection *selection = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolSelnPtr tsolseln = (TsolSelnPtr)(selection->secPrivate);
+
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!bldominates(tsolinfo->sl, tsolseln->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("mac", (int) misc, tsolseln->sl,
+						  tsolseln->uid, tsolseln->pid, tsolseln->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "read selection",
+						  NameForAtom(selection->selection));
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		/* uid == DEF_UID means public window, shared read */
+		if (!(tsolseln->uid == DEF_UID || tsolinfo->uid == tsolseln->uid))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				SXTSOLERR("dac", (int) misc, tsolseln->sl,
+						  tsolseln->uid, tsolseln->pid, tsolseln->pname,
+						  tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						  tsolinfo->pname, "read selection",
+						  NameForAtom(selection->selection));
+				ret_stat = err_code;
+			}
+		}
+	}
+
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XATOM, NameForAtom(selection->selection),
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* read_selection */
+
+/*
+ * modify_propwin. This is slightly different from modify_window in that
+ * Anyone can create/change properties on root.
+ */
+int
+modify_propwin(xresource_t res, xmethod_t method, void *resource,
+			   void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow; 
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+	/*
+	 * Anyone can modify properties on  RootWindow  subjected to
+	 * property policies.
+	 */
+	if (WindowIsRoot(pWin))
+	{
+		return (PASSED);
+	}
+/*
+	if (XTSOLTrusted(pWin))
+	{
+		if (!HasTrustedPath(tsolinfo))
+		{
+			XTSOLERR("tp", (int) misc, tsolres->sl,
+					 tsolres->uid, tsolres->pid, tsolres->pname,
+					 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "modify propwin", pWin->drawable.id);
+			return (err_code);
+		}
+	}
+*/
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify propwin", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify propwin", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_propwin */
+
+/*
+ * modify_focuswin - Focus Window policy
+ * Focus window can be None is checked outside of this func
+ */
+int
+modify_focuswin(xresource_t res, xmethod_t method, void *resource,
+				void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+	GrabPtr grab;
+
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify focuswin", pWin->drawable.id);
+                do_audit = FALSE;  /* don't audit this */
+                unset_audit_flags(tsolinfo);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify focuswin", pWin->drawable.id);
+                do_audit = FALSE;  /* don't audit this */
+                unset_audit_flags(tsolinfo);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * Trusted Path Windows require Trusted Path attrib
+	 */
+	if ((ret_stat == PASSED) && XTSOLTrusted(pWin))
+	{
+		if (!HasTrustedPath(tsolinfo))
+		{
+			XTSOLERR("tp", (int) misc, tsolres->sl,
+					 tsolres->uid, tsolres->pid, tsolres->pname,
+					 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "modify focuswin", pWin->drawable.id);
+			ret_stat = err_code;
+		}
+	}
+#if 0
+	/*
+	 * This causes problems when dragging cmdtool
+	 * TBD later
+	 * If ptr/kbd is grabbed, then this client must be 
+	 * the grabbing client
+	 */
+	grab = inputInfo.pointer->grab;
+	if (grab == NULL)
+		grab = inputInfo.keyboard->grab;
+	if (grab)
+	{
+		if (!SameClient(grab, client))
+		{
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DEVICES,
+				res, method, client))
+			{
+				/* audit? */
+			}
+			else
+			{
+				XTSOLERR("tp", (int) misc, 
+			    tsolres->sl, tsolres->uid, tsolres->pid, tsolres->pname, \
+			    tsolinfo->sl, tsolinfo->uid, tsolinfo->pid, tsolinfo->pname, \
+			    "modify focuswin", pWin->drawable.id);
+				return (err_code);
+			}
+		}
+	}
+#endif	
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_focuswin */
+
+/*
+ * read_focuswin
+ */
+int
+read_focuswin(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+	/*
+	 * Anyone can read RootWindow attributes
+	 */
+	if (WindowIsRoot(pWin))
+	{
+		return (PASSED);
+	}
+	/*
+	 * MAC Check
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!(bldominates(tsolinfo->sl, tsolres->sl)))
+		{
+            if (!(tsolinfo->flags & MAC_READ_AUDITED) &&
+                (tsolinfo->flags & TSOL_AUDITEVENT))
+            {
+                do_audit = TRUE;
+                tsolinfo->flags |= MAC_READ_AUDITED;
+            }
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+			    XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read focuswin", pWin->drawable.id);
+                do_audit = FALSE;  /* don't audit this */
+                unset_audit_flags(tsolinfo);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if ((tsolinfo->uid != tsolres->uid) && (tsolres->uid != 0))
+		{
+            if (!(tsolinfo->flags & DAC_READ_AUDITED) &&
+                (tsolinfo->flags & TSOL_AUDITEVENT))
+            {
+                do_audit = TRUE;
+                tsolinfo->flags |= DAC_READ_AUDITED;
+            }
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_READ,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "read focuswin", pWin->drawable.id);
+                do_audit = FALSE;  /* don't audit */
+                unset_audit_flags(tsolinfo);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* read_focuswin */
+
+#ifdef DEBUG
+/*
+ * XTsolErr : used for debugging. 
+ * WARNING: ErrorF can take upto 10 args & no more
+ */
+void
+XTsolErr(char *err_type, int protocol, bslabel_t *osl, uid_t ouid, pid_t opid,
+		 char *opname, bslabel_t *ssl, uid_t suid, pid_t spid, char *spname,
+		 char *method, int isstring, void *xid)
+{
+	if (xtsol_debug < XTSOL_FAIL)
+		return;
+	if (protocol == X_QueryTree || protocol == X_GetInputFocus)
+		return;
+	/* range check of protocol */
+	if (protocol > X_NoOperation)
+		protocol = 0; /* unknown or extension */
+	ErrorF("\n%s failed:%s,obj(%s,%d,%d,%s), subj(%s,%d,%d,%s),", 
+		   err_type, ProtoNames[protocol], xsltos(osl), ouid,
+		   opid, opname, xsltos(ssl), suid, spid, spname);
+	if (isstring)
+	{
+		ErrorF("%s, xid=%s\n", method, (char *) xid); /* for atom/prop names */
+	}
+	else
+	{
+		ErrorF("%s, xid=%X\n", method, (long) xid); /* for window/pixmaps */
+	}
+}
+#endif /* DEBUG */
+
+/*
+ * read_extn
+ */
+int
+read_extn(xresource_t res, xmethod_t method, void *resource,
+		  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int	err_code = BadAccess;
+	char *extn_name = (char *)resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	/*
+	 * No policy for this
+	 */
+
+	/*
+	if (extn_name != NULL & *extn_name != '\0')
+		ErrorF("Access to %s extension allowed\n", extn_name);
+	*/
+	return (PASSED);
+}
+
+/*
+ * modify_window
+ */
+int
+modify_tpwin(xresource_t res, xmethod_t method, void *resource,
+			 void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+	/*
+	 * MAC Check
+	 */
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!blequal(tsolinfo->sl, tsolres->sl))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify tpwin", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		if (tsolinfo->uid != tsolres->uid)
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify tpwin", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	/*
+	 * Trusted Path Windows require Trusted Path attrib
+	 */
+	if ((ret_stat == PASSED) && XTSOLTrusted(pWin))
+	{
+		if (!HasTrustedPath(tsolinfo))
+		{
+			XTSOLERR("tp", (int) misc, tsolres->sl,
+					 tsolres->uid, tsolres->pid, tsolres->pname,
+					 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+					 tsolinfo->pname, "modify tpwin", pWin->drawable.id);
+			ret_stat = err_code;
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_tpwin */
+
+/*
+ * modify_sl
+ * requires win_upgrade/downgrade_sl privs
+ * misc parameter is actually sl of resource & not the protocol no.
+ * misc == NULL means we are trying to set session hi/lo clearance
+ */
+int
+modify_sl(xresource_t res, xmethod_t method, void *resource,
+		  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadAccess;
+	bslabel_t *sl = (bslabel_t *)resource;	/* sl to be set */
+	bslabel_t *res_sl = (bslabel_t *)misc;	/* resource sl */
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	/*
+	 * Are we trying to check for session hi/lo clearance
+	 */
+	if (misc == NULL)
+	{
+        if (priv_win_config)
+            return (ret_stat);
+        
+        if (tsolinfo->flags & TSOL_AUDITEVENT)
+            do_audit = TRUE;
+		if (xpriv_policy(tsolinfo->privs, PRIV_WIN_CONFIG,
+                         res, method, client, do_audit))
+		{
+			ret_stat = PASSED;
+		}
+		else
+		{
+#ifdef DEBUG
+			ErrorF("modify_sl: failed for %s\n", tsolinfo->pname);
+#endif /* DEBUG */
+			ret_stat = err_code;
+		}
+        if (do_audit)
+        {
+            set_audit_flags(tsolinfo);
+            auditwrite(AW_SLABEL, sl, AW_APPEND, AW_END);
+        }
+        return (ret_stat);
+	}
+	/*
+	 * No MAC/DAC Check. Check only for upgrade/downgrade priv
+	 */
+	if (bldominates(sl, res_sl))
+	{
+        if (tsolinfo->flags & TSOL_AUDITEVENT)
+            do_audit = TRUE;
+		if (xpriv_policy(tsolinfo->privs, PRIV_WIN_UPGRADE_SL,
+						 res, method, client, do_audit))
+		{
+			ret_stat = PASSED;
+		}
+		else
+		{
+#ifdef DEBUG
+			ErrorF("modify_sl: failed for %s\n", tsolinfo->pname);
+#endif /* DEBUG */
+			ret_stat = err_code;
+		}
+	}
+	else
+	{
+        if (tsolinfo->flags & TSOL_AUDITEVENT)
+            do_audit = TRUE;
+		if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DOWNGRADE_SL,
+						 res, method, client, do_audit))
+		{
+			ret_stat = PASSED;
+		}
+		else
+		{
+#ifdef DEBUG
+			ErrorF("modify_sl: failed for %s\n", tsolinfo->pname);
+#endif /* DEBUG */
+			ret_stat = err_code;
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_SLABEL, sl, AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_sl */
+
+
+/*
+ * modify_eventwin
+ */
+int
+modify_eventwin(xresource_t res, xmethod_t method, void *resource,
+				void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	Bool do_audit = FALSE;
+	int	err_code = BadWindow;
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+	TsolResPtr tsolres =
+		(TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+	TsolInfoPtr tsolownerinfo;	/*client who owns the window */
+	ClientPtr	ownerclient;
+
+	ownerclient = clients[CLIENT_ID(pWin->drawable.id)];
+	tsolownerinfo = GetClientTsolInfo(ownerclient);
+
+	/*
+	 * Anyone can send event to root win
+	 */
+	if (WindowIsRoot(pWin) || XTSOLTrusted(pWin))
+	{
+		return (PASSED);
+	}
+	/*
+	 * MAC Check
+	 * NOTE: window sl must dominate the client's sl for send event
+	*/
+	if (policy_flags & TSOL_MAC)
+	{
+		if (!bldominates(tsolres->sl, tsolinfo->sl))
+		{
+			/*
+			 * event sends to windows owned by client with priv_win_seln
+			 * particularly front panel whose sl is admin_low
+			 */
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+							 res, method, client, do_audit) ||
+				(tsolownerinfo && HasWinSelection(tsolownerinfo)))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("mac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify eventwin", pWin->drawable.id);
+				ret_stat = ret_stat;
+			}
+		}
+	}
+	/*
+	 * DAC Check
+	 */
+	if ((ret_stat == PASSED) && policy_flags & TSOL_DAC)
+	{
+		/* uid == DEF_UID means public window */
+		if (!(XTSOLTrusted(pWin) ||
+			tsolres->uid == DEF_UID ||
+			tsolinfo->uid == tsolres->uid))
+		{
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                do_audit = TRUE;
+			if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+							 res, method, client, do_audit))
+			{
+				ret_stat = PASSED;
+			}
+			else
+			{
+				XTSOLERR("dac", (int) misc, tsolres->sl,
+						 tsolres->uid, tsolres->pid, tsolres->pname,
+						 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+						 tsolinfo->pname, "modify eventwin", pWin->drawable.id);
+				ret_stat = err_code;
+			}
+		}
+	}
+	if (do_audit)
+	{
+        set_audit_flags(tsolinfo);
+		auditwrite(AW_XWINDOW, pWin->drawable.id, tsolres->uid,
+				   AW_APPEND, AW_END);
+	}
+	return (ret_stat);
+}	/* modify_eventwin */
+
+/*
+ * modify_stripe
+ * Trusted stripe requires only trusted path attrib
+ */
+int
+modify_stripe(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int	err_code = BadAccess;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	if (!HasTrustedPath(tsolinfo))
+	{
+		XTSOLERR("tp", (int) misc, tsolinfo->sl,
+				 tsolinfo->uid, tsolinfo->pid, tsolinfo->pname,
+				 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+				 tsolinfo->pname, "modify stripe", 0);
+		return (err_code);
+	}
+	return (PASSED);
+}
+
+/*
+ * modify_wowner
+ * set workstation owner
+ */
+int
+modify_wowner(xresource_t res, xmethod_t method, void *resource,
+			  void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int	err_code = BadAccess;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+	if (!HasTrustedPath(tsolinfo))
+	{
+		XTSOLERR("tp", (int) misc, tsolinfo->sl,
+				 tsolinfo->uid, tsolinfo->pid, tsolinfo->pname,
+				 tsolinfo->sl, tsolinfo->uid, tsolinfo->pid,
+				 tsolinfo->pname, "modify tpwin", 0);
+		return (err_code);
+	}
+	return (PASSED);
+}
+
+/*
+ * modify_uid
+ * Set UID for resource
+ */
+int
+modify_uid(xresource_t res, xmethod_t method, void *resource,
+	void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadAccess;
+    Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    if (tsolinfo->flags & TSOL_AUDITEVENT)
+        do_audit = TRUE;
+	if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+                     res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+	}
+	else
+	{
+#ifdef DEBUG
+		ErrorF("modify_uid: failed for %s\n", tsolinfo->pname);
+#endif /* DEBUG */
+		ret_stat = err_code;
+	}
+    if (do_audit)
+        set_audit_flags(tsolinfo);
+	return (ret_stat);
+}
+
+/*
+ * modify_polyinfo
+ * Modify polyinstantiation info(sl, uid) 
+ */
+int
+modify_polyinfo(xresource_t res, xmethod_t method, void *resource,
+				void *subject, xpolicy_t policy_flags, void *misc)
+{
+	int ret_stat = PASSED;
+	int	err_code = BadAccess;
+        Bool do_audit = FALSE;
+	ClientPtr client = subject;
+	TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+        if (tsolinfo->flags & TSOL_AUDITEVENT)
+            do_audit = TRUE;
+	if (xpriv_policy(tsolinfo->privs, PRIV_WIN_MAC_WRITE,
+                     res, method, client, do_audit))
+	{
+		ret_stat = PASSED;
+		if (xpriv_policy(tsolinfo->privs, PRIV_WIN_DAC_WRITE,
+						 res, method, client, do_audit))
+		{
+			ret_stat = PASSED;
+		}
+		else
+			ret_stat = err_code;
+	}
+	else
+		ret_stat = err_code;
+#ifdef DEBUG
+	ErrorF("modify_polyinfo: failed for %s\n", tsolinfo->pname);
+#endif /* DEBUG */
+    if (do_audit)
+        set_audit_flags(tsolinfo);
+	return (ret_stat);
+}
+
+/* 
+ * access_dbe - check whether the buffer is client-private
+ */
+int
+access_dbe(xresource_t res, xmethod_t method, void *resource,
+	   void *subject, xpolicy_t policy_flags, void *misc)
+{
+    ClientPtr client = subject;
+    XID object = (XID) resource;
+
+    if (client_private(client, object))
+       return (PASSED);
+    else 
+       return BadAccess;
+}
+
+/* 
+ * swap_dbe - check if the window is created by the client
+ */
+int
+swap_dbe(xresource_t res, xmethod_t method, void *resource,
+	 void *subject, xpolicy_t policy_flags, void *misc)
+{
+	WindowPtr pWin = resource;
+	ClientPtr client = subject;
+
+	if (SAMECLIENT(client, pWin->drawable.id))
+            return PASSED;
+        else 
+            return BadAccess;   
+}
+
+int
+priv_test(priv_set_t *set, priv_t priv)
+{
+	return (PRIV_ISASSERT(set, priv));
+}
+
+/*
+ * Return value of 0 success,	errcode for failure
+ *
+ * Dummy function.
+ */
+static int
+no_policy(xresource_t res, xmethod_t method, void *resource,
+	void *subject, xpolicy_t policy_flags, void *misc)
+{
+#ifdef DEBUG
+	ErrorF("policy not implemented for res=%d, method=%d\n",
+		res, method);
+#endif /* DEBUG */
+	return (PASSED);
+}
+
+/*
+ * X POLICY FUNCTION TABLE. One row per resource.
+ *
+ * TSOL_RES_NAME            READ                MODIFY              CREATE\
+ *                          DESTROY             SPECIAL
+ */
+static int (*XTSOL_policy_table[TSOL_MAX_XRES_TYPES][TSOL_MAX_XMETHODS])() = {
+/* TSOL_RES_ACL */          no_policy,          modify_acl,         no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_ATOM */         read_atom,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_BELL */         no_policy,          modify_devices,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_BTNGRAB */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_CCELL */        read_ccell,         modify_ccell,       no_policy,\
+                            destroy_ccell,      no_policy,
+/* TSOL_RES_CLIENT */       read_client,        modify_client,      no_policy,\
+                            destroy_client,     no_policy,
+/* TSOL_RES_CMAP */         read_cmap,          modify_cmap,        no_policy,\
+                            modify_cmap,        install_cmap,
+/* TSOL_RES_CONFWIN */      no_policy,          modify_confwin,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_CURSOR */       no_policy,          modify_cursor,      no_policy,\
+                            modify_cursor,      no_policy,
+/* TSOL_RES_EVENTWIN */     no_policy,          modify_eventwin,    no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_EXTN */         read_extn,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_FOCUSWIN */     read_focuswin,      modify_focuswin,    no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_FONT */         read_font,          modify_font,        no_policy,\
+                            modify_font,        no_policy,
+/* TSOL_RES_FONTLIST */     no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_FONTPATH */     no_policy,          modify_fontpath,    no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_GC */           read_gc,            modify_gc,          no_policy,\
+                            modify_gc,          no_policy,
+/* TSOL_RES_GRABWIN */      no_policy,          modify_grabwin,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_HOSTLIST */     no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_IL */           no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_KBDCTL */       no_policy,          modify_devices,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_KBDGRAB */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_KEYGRAB */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_KEYMAP */       read_devices,       modify_devices,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_MODMAP */       no_policy,          modify_devices,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PIXEL */        read_pixel,         modify_pixel,       no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PIXMAP */       read_pixmap,        modify_pixmap,      no_policy,\
+                            destroy_pixmap,     no_policy,
+/* TSOL_RES_POLYINFO */     no_policy,          modify_polyinfo,    no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PROPERTY */     read_property,      modify_property,    no_policy,\
+                            destroy_property,   no_policy,
+/* TSOL_RES_PROPWIN */      read_window,        modify_propwin,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_IIL */          no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PROP_SL */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PROP_UID */     no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PTRCTL */       no_policy,          modify_devices,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PTRGRAB */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PTRLOC */       no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PTRMAP */       no_policy,          modify_devices,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_PTRMOTION */    no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_SCRSAVER */     no_policy,          modify_devices,     no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_SELECTION */    read_selection,     no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_SELNWIN */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_SENDEVENT */    no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_SL */           no_policy,          modify_sl,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_SRVGRAB */      no_policy,          no_policy,      create_srvgrab,\
+                            destroy_srvgrab,    no_policy,
+/* TSOL_RES_STRIPE */       no_policy,          modify_stripe,      no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_TPWIN */        no_policy,          modify_tpwin,       no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_UID */          no_policy,          modify_uid,         no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_VISUAL */       no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_WINATTR */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_WINDOW */       read_window,        modify_window,   create_window,\
+                            destroy_window,     no_policy,
+/* TSOL_RES_WINLOC */       no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_WINMAP */       no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_WINSIZE */      no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_WINSTACK */     no_policy,          no_policy,          no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_WOWNER */       no_policy,          modify_wowner,      no_policy,\
+                            no_policy,          no_policy,
+/* TSOL_RES_DBE */          no_policy,          no_policy,         access_dbe,
+                            access_dbe,         swap_dbe
+};
+
+struct xpolicy_cache {
+	xresource_t res;
+	xmethod_t method;
+	void *resource;
+	void *subject;      
+	xpolicy_t policy_flags;
+	int	ret_value;
+	int	count;
+};
+static struct xpolicy_cache policy_cache;
+
+/*
+ * main xtsol_policy. External interface to dix layer of X server
+ */
+int
+xtsol_policy(xresource_t res,	xmethod_t method,	void *resource,
+    void *subject,	xpolicy_t policy_flags,	void *misc)
+{
+	int	res_type;
+	int	ret_value;
+
+	assert(res >= TSOL_START_XRES && res < TSOL_MAX_XRES_TYPES);
+	assert(method >= 0 && method < TSOL_MAX_XMETHODS);
+	assert(policy_flags != 0);
+	res_type = (int)(res - TSOL_START_XRES);
+
+	if (policy_cache.subject == subject &&
+		policy_cache.res == res  && 
+		policy_cache.method == method &&
+		policy_cache.resource == resource  && 
+		policy_cache.policy_flags == policy_flags) 
+	{
+
+		policy_cache.count++;
+		return policy_cache.ret_value;
+	} else {
+		policy_cache.res = res;
+		policy_cache.method = method;
+		policy_cache.resource = resource;
+		policy_cache.subject = subject;
+		policy_cache.policy_flags = policy_flags;
+
+		ret_value = ((XTSOL_policy_table[res_type][method]) (res,	
+			method,	resource, subject,	policy_flags,	misc));
+		policy_cache.ret_value = ret_value;
+
+		return ret_value;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolpolicy.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,290 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident	"@(#)tsolpolicy.h	1.4	06/03/07 SMI"
+
+
+#ifndef	_TSOL_POLICY_H
+#define	_TSOL_POLICY_H
+
+#pragma ident	"@(#)xpolicy.h	5.10	97/03/04 SMI; TSOL 2.x"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#include "tsolpriv.h"
+#include <assert.h>
+
+#define	PASSED		0	/* success code 0 */
+#ifndef FAILED
+#define	FAILED		1	/* failed is non-zero (could be error no) */
+#endif /* FAILED */
+
+/*
+ * Policy checking flags
+ */
+
+enum xpolicy_flags {
+	TSOL_MAC   = 0x00000001,	/* MAC policy */
+	TSOL_DAC   = 0x00000002,	/* DAC floating */
+	TSOL_FLOAT = 0x00000004,	/* float ILs */
+	TSOL_AUDIT = 0x00000008,	/* perform auditing */
+	TSOL_PRIV  = 0x00000010,	/* privilege check */
+	TSOL_ALL   = 0x0fffffff		/* do them all */
+};
+
+typedef enum xpolicy_flags xpolicy_t;
+/*
+ * Access Methods. Special access methods include:
+ *	Not known yet.
+ */
+
+enum xaccess_methods {
+	TSOL_READ = 0,
+	TSOL_MODIFY,
+	TSOL_CREATE,
+	TSOL_DESTROY,
+	TSOL_SPECIAL,
+	TSOL_MAX_XMETHODS	/* Keep this as the last item */
+};
+
+typedef enum xaccess_methods xmethod_t;
+
+/*
+ * Resource Objects
+ */
+#define TSOL_START_XRES		1000	/* start with large no. */
+enum xresource_types {
+	TSOL_RES_ACL	=	TSOL_START_XRES,
+	TSOL_RES_ATOM,
+	TSOL_RES_BELL,
+	TSOL_RES_BTNGRAB,
+	TSOL_RES_CCELL,
+	TSOL_RES_CLIENT,
+	TSOL_RES_CMAP,
+	TSOL_RES_CONFWIN,
+	TSOL_RES_CURSOR,
+	TSOL_RES_EVENTWIN,
+	TSOL_RES_EXTN,
+	TSOL_RES_FOCUSWIN,
+	TSOL_RES_FONT,
+	TSOL_RES_FONTLIST,
+	TSOL_RES_FONTPATH,
+	TSOL_RES_GC,
+	TSOL_RES_GRABWIN,
+	TSOL_RES_HOSTLIST,
+	TSOL_RES_IL,
+	TSOL_RES_KBDCTL,
+	TSOL_RES_KBDGRAB,
+	TSOL_RES_KEYGRAB,
+	TSOL_RES_KEYMAP,
+	TSOL_RES_MODMAP,
+	TSOL_RES_PIXEL,
+	TSOL_RES_PIXMAP,
+	TSOL_RES_POLYINFO,
+	TSOL_RES_PROPERTY,
+	TSOL_RES_PROPWIN,
+	TSOL_RES_IIL,
+	TSOL_RES_PROP_SL,
+	TSOL_RES_PROP_UID,
+	TSOL_RES_PTRCTL,
+	TSOL_RES_PTRGRAB,
+	TSOL_RES_PTRLOC,
+	TSOL_RES_PTRMAP,
+	TSOL_RES_PTRMOTION,
+	TSOL_RES_SCRSAVER,
+	TSOL_RES_SELECTION,
+	TSOL_RES_SELNWIN,
+	TSOL_RES_SENDEVENT,
+	TSOL_RES_SL,
+	TSOL_RES_SRVGRAB,
+	TSOL_RES_STRIPE,
+	TSOL_RES_TPWIN,
+	TSOL_RES_UID,
+	TSOL_RES_VISUAL,
+	TSOL_RES_WINATTR,
+	TSOL_RES_WINDOW,
+	TSOL_RES_WINLOC,
+	TSOL_RES_WINMAP,
+	TSOL_RES_WINSIZE,
+	TSOL_RES_WINSTACK,
+	TSOL_RES_WOWNER,
+        TSOL_RES_DBE,
+	TSOL_MAX_XRES_TYPES
+};
+
+typedef enum xresource_types xresource_t;
+/*
+ * NOTE: IF YOU ADD ANY NEW RESOURCE TYPES YOU MUST ADD A NEW ROW IN THE
+ * XTSOL_policy_table in xpolicy_tables.c!!!
+ */
+
+
+int xtsol_policy(xresource_t res_type, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+
+#ifdef DEBUG	/* define this in tsolinfo.h if you want debug */
+/* 
+ * For priv debugging messages.
+ * XTSOL_FAIL : logs all failures that cause a err code to be returned
+ * 		in protocol
+ * XTSOL_ALLOW:	logs all privs that the client is lacking, but is allowed
+ * XTSOL_IGNORE	logs all failures whose err code is not returned in protocol
+ * 
+ * The higher no. always includes the lower no. log
+ */
+extern int xtsol_debug; 	/* defined xres_policy.c */
+#define	XTSOL_FAIL	1
+#define	XTSOL_ALLOW	2
+#define	XTSOL_IGNORE	3
+#endif /* DEBUG */
+
+#ifndef	MAJOROP
+#define	MAJOROP ((xReq *)client->requestBuffer)->reqType
+#endif	/* MAJOROP */
+#define	RES_TYPE(xid)	((xid) & (0x8000000F))
+
+
+/*
+ * Function prototypes
+ */
+int modify_acl(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_devices(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_devices(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_client(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_client(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int destroy_client(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_atom(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_font(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int destroy_font(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_fontpath(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_gc(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_gc(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_font(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_font(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_cursor(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_ccell(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_ccell(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int destroy_ccell(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_cmap(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_cmap(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int install_cmap(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_window(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_window(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int create_window(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int destroy_window(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_pixmap(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_pixmap(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int create_pixmap(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int destroy_pixmap(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_property(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_property(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int destroy_property(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int create_srvgrab(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int destroy_srvgrab(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_confwin(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_grabwin(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_focuswin(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_focuswin(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_selection(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_propwin(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_pixel(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_pixel(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_extn(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_sl(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_il(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_tpwin(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_eventwin(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_stripe(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_wowner(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_uid(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int modify_polyinfo(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int read_iil(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int access_dbe(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+int swap_dbe(xresource_t res, xmethod_t method,
+    void *resource, void *subject, xpolicy_t policy_flags, void *misc);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* _TSOL_POLICY_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolpriv.h	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,119 @@
+/* Copyright 2006 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.
+ */ 
+ 
+#pragma ident   "@(#)tsolpriv.h 1.2     06/03/07 SMI"
+
+#ifndef	_SYS_TSOL_PRIV_H
+#define	_SYS_TSOL_PRIV_H
+
+
+#include <sys/priv.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+typedef enum priv_ftype {
+	PRIV_ALLOWED,
+	PRIV_FORCED
+} priv_ftype_t;
+
+/*
+ * Privilege macros.
+ */
+
+/*
+ * PRIV_ASSERT(a, b) setst.privilege "b" in privilege set "a".
+ */
+#define	PRIV_ASSERT(a, b) (priv_addset(a, b))
+
+/*
+ * PRIV_CLEAR(a,b) clearst.privilege "b" in privilege set "a".
+ */
+#define	PRIV_CLEAR(a, b) (priv_delset(a, b))
+
+/*
+ * PRIV_EQUAL(set_a, set_b) is true if set_a and set_b are identical.
+ */
+#define	PRIV_EQUAL(a, b) (priv_isequalset(a, b))
+#define	PRIV_EMPTY(a) (priv_emptyset(a))
+#define	PRIV_FILL(a) (priv_fillset(a))
+
+/*
+ * PRIV_ISASSERT tests if privilege 'b' is asserted in privilege set 'a'.
+ */
+#define	PRIV_ISASSERT(a, b) (priv_ismember(a, b))
+#define	PRIV_ISEMPTY(a) (priv_isemptyset(a))
+#define	PRIV_ISFULL(a) (priv_isfullset(a))
+
+/*
+ * This macro returns 1 if all privileges asserted in privilege set "a"
+ * are also asserted in privilege set "b" (i.e. if a is a subset of b)
+ */
+#define	PRIV_ISSUBSET(a, b) (priv_issubset(a, b))
+
+/*
+ * Takes intersection of "a" and "b" and stores in "b".
+ */
+#define	PRIV_INTERSECT(a, b) (priv_intersect(a, b))
+
+/*
+ * Replaces "a" with inverse of "a".
+ */
+#define	PRIV_INVERSE(a)  (priv_inverse(a))
+
+/*
+ * Takes union of "a" and "b" and stores in "b".
+ */
+#define	PRIV_UNION(a, b) (priv_union(a, b))
+
+
+#define	PRIV_PROC_AUDIT_TCB	((const char *)"proc_audit")
+#define	PRIV_PROC_AUDIT_APPL	((const char *)"proc_audit")
+#
+#define	PRIV_NET_REPLY_EQUAL	((const char *)"net_reply_equal")
+#
+#define	PRIV_SYS_TRANS_LABEL	((const char *)"sys_trans_label")
+#define	PRIV_WIN_COLORMAP	((const char *)"win_colormap")
+#define	PRIV_WIN_CONFIG		((const char *)"win_config")
+#define	PRIV_WIN_DAC_READ	((const char *)"win_dac_read")
+#define	PRIV_WIN_DAC_WRITE	((const char *)"win_dac_write")
+#define	PRIV_WIN_DGA		((const char *)"win_dga")
+#define	PRIV_WIN_DEVICES	((const char *)"win_devices")
+#define	PRIV_WIN_DOWNGRADE_SL	((const char *)"win_downgrade_sl")
+#define	PRIV_WIN_FONTPATH	((const char *)"win_fontpath")
+#define	PRIV_WIN_MAC_READ	((const char *)"win_mac_read")
+#define	PRIV_WIN_MAC_WRITE	((const char *)"win_mac_write")
+#define	PRIV_WIN_SELECTION	((const char *)"win_selection")
+#define	PRIV_WIN_UPGRADE_SL	((const char *)"win_upgrade_sl")
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* _SYS_TSOL_PRIV_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolprotocol.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2661 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident	"@(#)tsolprotocol.c 1.8	06/03/07 SMI"
+
+#include <sys/param.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <ucred.h>
+#include <pwd.h>
+#include <strings.h>
+#include <sys/wait.h>
+#include <bsm/auditwrite.h>
+#include <bsm/libbsm.h>
+#include <bsm/audit_uevents.h>
+#include "tsol.h"
+
+#include "inputstr.h"
+
+#define NEED_REPLIES
+
+#include "selection.h"
+#include "osdep.h"
+#include "tsolpolicy.h"
+#include "swaprep.h"
+#include "swapreq.h"
+#include "servermd.h"
+#ifdef PANORAMIX
+#include "../Xext/panoramiXsrv.h"
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include "security.h"
+#endif
+
+/*
+ * The event # here match those in /usr/include/bsm/audit_uevents.h.
+ * Changes in one should go with corresponding changes in another.
+ */
+
+#define MAX_AUDIT_EVENTS 100
+
+int audit_eventsid[100][2] = {
+    X_CreateWindow, 9103,
+    X_ChangeWindowAttributes, 9104,
+    X_GetWindowAttributes, 9105,
+    X_DestroyWindow, 9106,
+    X_DestroySubwindows, 9107,
+    X_ChangeSaveSet, 9108,
+    X_ReparentWindow, 9109,
+    X_MapWindow, 9110,
+    X_MapSubwindows, 9111,
+    X_UnmapWindow, 9112, 
+    X_UnmapSubwindows, 9113,
+    X_ConfigureWindow, 9114,
+    X_CirculateWindow, 9115,
+    X_GetGeometry, 9116,
+    X_QueryTree, 9117,
+    X_InternAtom, 9118,
+    X_GetAtomName, 9119,
+    X_ChangeProperty, 9120,
+    X_DeleteProperty, 9121,
+    X_GetProperty, 9122,
+    X_ListProperties, 9123,
+    X_SetSelectionOwner, 9124,
+    X_GetSelectionOwner, 9125,
+    X_ConvertSelection, 9126,
+    X_SendEvent, 9127,
+    X_GrabPointer, 9128,
+    X_UngrabPointer, 9129,
+    X_GrabButton, 9130,
+    X_UngrabButton, 9131,
+    X_ChangeActivePointerGrab, 9132,
+    X_GrabKeyboard, 9133,
+    X_UngrabKeyboard, 9134,
+    X_GrabKey, 9135,
+    X_UngrabKey, 9136,
+    X_GrabServer, 9137,
+    X_UngrabServer, 9138,
+    X_QueryPointer, 9139,
+    X_GetMotionEvents, 9140,
+    X_TranslateCoords, 9141,
+    X_WarpPointer, 9142,
+    X_SetInputFocus, 9143,
+    X_GetInputFocus, 9144,
+    X_QueryKeymap, 9145,
+    X_SetFontPath, 9146,
+    X_FreePixmap, 9147,
+    X_ChangeGC, 9148,
+    X_CopyGC, 9149,
+    X_SetDashes, 9150,
+    X_SetClipRectangles, 9151,
+    X_FreeGC, 9152,
+    X_ClearArea, 9153,
+    X_CopyArea, 9154,
+    X_CopyPlane, 9155,
+    X_PolyPoint, 9156,
+    X_PolyLine, 9157,
+    X_PolySegment, 9158,
+    X_PolyRectangle, 9159,
+    X_PolyArc, 9160,
+    X_FillPoly, 9161,
+    X_PolyFillRectangle, 9162,
+    X_PolyFillArc, 9163,
+    X_PutImage, 9164,
+    X_GetImage, 9165,
+    X_PolyText8, 9166,
+    X_PolyText16, 9167,
+    X_ImageText8, 9168,
+    X_ImageText16, 9169,
+    X_CreateColormap, 9170,
+    X_FreeColormap, 9171,
+    X_CopyColormapAndFree, 9172,
+    X_InstallColormap, 9173,
+    X_UninstallColormap, 9174,
+    X_ListInstalledColormaps, 9175,
+    X_AllocColor, 9176,
+    X_AllocNamedColor, 9177,
+    X_AllocColorCells, 9178,
+    X_AllocColorPlanes, 9179,
+    X_FreeColors, 9180,
+    X_StoreColors, 9181,
+    X_StoreNamedColor, 9182,
+    X_QueryColors, 9183,
+    X_LookupColor, 9184,
+    X_CreateCursor, 9185,
+    X_CreateGlyphCursor, 9186,
+    X_FreeCursor, 9187,
+    X_RecolorCursor, 9188,
+    X_ChangeKeyboardMapping, 9189,
+    X_ChangeKeyboardControl, 9190,
+    X_Bell, 9191,
+    X_ChangePointerControl, 9192,
+    X_SetScreenSaver, 9193,
+    X_ChangeHosts, 9194,
+    X_SetAccessControl, 9195,
+    X_SetCloseDownMode, 9196,
+    X_KillClient, 9197,
+    X_RotateProperties, 9198,
+    X_ForceScreenSaver, 9199,
+    X_SetPointerMapping, 9200,
+    X_SetModifierMapping, 9201,
+    X_NoOperation, 9202
+};
+extern void Swap32Write();
+extern int (*TsolSavedProcVector[PROCVECTORSIZE])(ClientPtr /*client*/);
+extern int (*TsolSavedSwappedProcVector[PROCVECTORSIZE])(ClientPtr /*client*/);
+
+
+Atom MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit);
+
+#define INITIAL_TSOL_NODELENGTH 1500
+
+extern Atom tsol_lastAtom;
+extern int tsol_nodelength;
+extern TsolNodePtr tsol_node;
+extern int NumCurrentSelections;
+extern Selection *CurrentSelections;
+extern WindowPtr tpwin;
+
+static int tsol_sel_agnt = -1; /* index this to CurrentSelection to get seln */
+
+/*
+ * Get number of atoms defined in the system
+ */
+static Atom
+GetLastAtom()
+{
+	Atom a = (Atom) 1; /* atoms start at 1 */
+
+	while (ValidAtom(a)) {
+		a++;
+	}
+
+	return (--a);
+}
+
+/*
+ * Update Tsol info for atoms. This function gets
+ * called typically during initialization. But, it could also get
+ * called if some atoms are created internally by server.
+ */
+void
+UpdateTsolNode()
+{
+	Atom lastAtom = GetLastAtom();
+	Atom ia;
+
+	/* Update may not be needed */
+	if (lastAtom == None || lastAtom == tsol_lastAtom)
+		return;
+	
+	if (tsol_node == NULL) {
+		int newsize = (lastAtom > INITIAL_TSOL_NODELENGTH ? lastAtom : INITIAL_TSOL_NODELENGTH);
+
+		/* Initialize */
+		tsol_node = (TsolNodePtr )xalloc((newsize + 1) * sizeof(TsolNodeRec));
+		tsol_nodelength = newsize;
+
+		if (tsol_node != NULL) {
+			/* Atom id 0 is invalid */
+			tsol_lastAtom = 0;
+			tsol_node[0].flags = 0;
+			tsol_node[0].slcount = 0;
+			tsol_node[0].sl = NULL;
+			tsol_node[0].slsize = 0;
+			tsol_node[0].IsSpecial = 0;
+		}
+	}
+
+	if (tsol_nodelength <= lastAtom) {
+		tsol_node = (TsolNodePtr )xrealloc(tsol_node, (lastAtom + 1) * sizeof(TsolNodeRec));
+		tsol_nodelength = lastAtom + 1;
+	}
+
+	if (tsol_node == NULL) {
+		ErrorF("Cannot allocate memory for Tsol node\n");
+		return;
+	}
+
+	/* 
+	 * Initialize the tsol node for each atom
+	 */
+	for (ia = tsol_lastAtom + 1; ia <= lastAtom; ia++) {
+		char *atomname = NameForAtom(ia);
+
+		tsol_node[ia].slcount = 0;
+		tsol_node[ia].sl = NULL;
+		tsol_node[ia].slsize= 0;
+		tsol_node[ia].flags = MatchTsolConfig(atomname, strlen(atomname));
+		tsol_node[ia].IsSpecial = SpecialName(atomname, strlen(atomname));
+
+	}
+	tsol_lastAtom = lastAtom;
+}
+
+int
+ProcTsolInternAtom(client)
+    register ClientPtr client;
+{
+    Atom atom;
+    char *tchar;
+    REQUEST(xInternAtomReq);
+
+    REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes);
+    if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse))
+    {
+	client->errorValue = stuff->onlyIfExists;
+        return(BadValue);
+    }
+    tchar = (char *) &stuff[1];
+    atom = MakeTSOLAtom(client, tchar, stuff->nbytes, !stuff->onlyIfExists);
+    if (atom != BAD_RESOURCE)
+    {
+	xInternAtomReply reply;
+	reply.type = X_Reply;
+	reply.length = 0;
+	reply.sequenceNumber = client->sequence;
+	reply.atom = atom;
+	WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
+	return(client->noClientException);
+    }
+    else
+	return (BadAlloc);
+}
+
+int
+ProcTsolGetAtomName(client)
+    register ClientPtr client;
+{
+    char *str;
+    xGetAtomNameReply reply;
+    int len;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    /* TBD: NameForTSOLAtom */
+    if ( (str = NameForAtom(stuff->id)) )
+    {
+	len = strlen(str);
+	reply.type = X_Reply;
+	reply.length = (len + 3) >> 2;
+	reply.sequenceNumber = client->sequence;
+	reply.nameLength = len;
+	WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
+	(void)WriteToClient(client, len, str);
+	return(client->noClientException);
+    }
+    else 
+    { 
+	client->errorValue = stuff->id;
+	return (BadAtom);
+    }
+}
+
+Atom
+MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit)
+{
+	TsolNodePtr tndp;
+	int count;
+	int k;
+	int newsize;
+	Atom lastAtom;
+	Atom newAtom;
+	bslabel_t **newsl;
+
+	TsolInfoPtr tsolinfo;
+	bslabel_t *sl;
+
+
+	/* Make the atom as usual */
+	newAtom = MakeAtom(string, len, makeit);
+	if (newAtom == None || newAtom == BAD_RESOURCE) {
+		return (newAtom);
+	}
+
+	tsolinfo = GetClientTsolInfo(client);
+
+
+	/* tsol node info already present? */
+	if (newAtom <= tsol_lastAtom) {
+		tndp = &(tsol_node[newAtom]);
+
+		/* public atoms have null sl */
+		if (tndp->sl == NULL) {
+			return newAtom;
+		}
+
+		/* private atoms must have a matching sl */
+		for (k = 0; k < tndp->slcount; k++) {
+			if (tsolinfo->sl == tndp->sl[k]) {
+				return newAtom; /* found one */
+			}
+		}
+
+	} else {
+		/* tsol node table not big enough, expand it */
+		UpdateTsolNode();
+		tndp = &(tsol_node[newAtom]);
+	}
+
+	/* Allocate storage for sl if needed */
+	if (tndp->sl == NULL) {
+		tndp->sl = (bslabel_t **)xalloc(NODE_SLSIZE * (sizeof(bslabel_t *)));
+		tndp->slcount = 0;
+		tndp->slsize = NODE_SLSIZE;
+	}
+
+	/* Expand storage space for sl if needed */
+	if (tndp->slsize < tndp->slcount) {
+		newsize = tndp->slsize + NODE_SLSIZE;
+		tndp->sl = (bslabel_t **)xrealloc(tndp->sl, newsize * (sizeof(bslabel_t *)));
+		tndp->slsize = newsize;
+	}
+
+	if (tndp->sl == NULL) {
+		ErrorF("Not enough memory for atoms\n");
+		return (Atom)None;
+	}
+
+	/* Store client's sl */
+	tndp->sl[tndp->slcount] = tsolinfo->sl;
+	tndp->slcount++;
+
+	return newAtom;
+}
+
+
+int
+ProcTsolSetSelectionOwner(client)
+    register ClientPtr client;
+{
+    WindowPtr pWin;
+    TimeStamp time;
+    REQUEST(xSetSelectionOwnerReq);
+
+#ifdef TSOL
+    TsolSelnPtr tsolseln = NULL;
+    TsolSelnPtr prevtsolseln = NULL;
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+#endif /* TSOL */
+
+    REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+    UpdateCurrentTime();
+    time = ClientTimeToServerTime(stuff->time);
+
+    /* If the client's time stamp is in the future relative to the server's
+	time stamp, do not set the selection, just return success. */
+    if (CompareTimeStamps(time, currentTime) == LATER)
+    	return Success;
+    if (stuff->window != None)
+    {
+        pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					       SecurityReadAccess);
+        if (!pWin)
+            return(BadWindow);
+    }
+    else
+        pWin = (WindowPtr)None;
+    if (ValidAtom(stuff->selection))
+    {
+	int i = 0;
+
+	/*
+	 * First, see if the selection is already set... 
+	 */
+	while ((i < NumCurrentSelections) && 
+	       CurrentSelections[i].selection != stuff->selection) 
+            i++;
+
+#ifdef TSOL
+	/* 
+	 * special processing for selection agent. Just note
+	 * the owner of this special selection
+	 */
+	if (stuff->selection == MakeAtom("_TSOL_SEL_AGNT", 14, 1))
+	{
+	    if (HasWinSelection(tsolinfo))
+	    {
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+               auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION,
+                          AW_APPEND, AW_END);
+            tsol_sel_agnt = i; /* owner of this seln */
+	    }
+	    else
+	    {
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+               auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION,
+                          AW_APPEND, AW_END);
+            client->errorValue = stuff->selection;
+            return(BadAtom);
+	    }
+	}	
+#endif /* TSOL */
+
+        if (i < NumCurrentSelections)
+        {        
+	    xEvent event;
+
+	  #ifdef TSOL
+	    /* for poly-selections, search further to see if sl,uid match */
+	    tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate;
+	    if (PolySelection(CurrentSelections[i].selection))
+	    {
+	        prevtsolseln = tsolseln;
+            while (tsolseln)
+            {
+                if (tsolseln->uid == tsolinfo->uid &&
+                    tsolseln->sl == tsolinfo->sl)
+		            break; /* match found */
+                prevtsolseln = tsolseln;
+                tsolseln = tsolseln->next;
+            }
+	    }	    
+	    if (PolySelection(CurrentSelections[i].selection) && tsolseln)
+	    {
+            if (CompareTimeStamps(time, tsolseln->lastTimeChanged) == EARLIER)
+                return Success;
+	        if (tsolseln->client && (!pWin || (tsolseln->client != client)))
+	        {
+                event.u.u.type = SelectionClear;
+                event.u.selectionClear.time = time.milliseconds;
+                event.u.selectionClear.window = tsolseln->window;
+                event.u.selectionClear.atom = CurrentSelections[i].selection;
+                (void)TryClientEvents (tsolseln->client,
+                                       &event,
+                                       1,
+                                       NoEventMask,
+                                       NoEventMask /* CantBeFiltered */,
+                                       NullGrab);
+	        }
+	    }
+	    else if (tsolseln)
+	    {
+            /* we use the existing code. So we left it unindented */
+#endif /* TSOL */
+
+            /* If the timestamp in client's request is in the past relative
+		to the time stamp indicating the last time the owner of the
+		selection was set, do not set the selection, just return 
+		success. */
+            if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged)
+		== EARLIER)
+		return Success;
+	    if (CurrentSelections[i].client &&
+		(!pWin || (CurrentSelections[i].client != client)))
+	    {
+		event.u.u.type = SelectionClear;
+		event.u.selectionClear.time = time.milliseconds;
+		event.u.selectionClear.window = CurrentSelections[i].window;
+		event.u.selectionClear.atom = CurrentSelections[i].selection;
+		(void) TryClientEvents (CurrentSelections[i].client, &event, 1,
+				NoEventMask, NoEventMask /* CantBeFiltered */,
+				NullGrab);
+	    }
+#ifdef TSOL
+	    }
+#endif /* TSOL */
+	}
+	else
+	{
+	    /*
+	     * It doesn't exist, so add it...
+	     */
+	    Selection *newsels;
+
+	    if (i == 0)
+		newsels = (Selection *)xalloc(sizeof(Selection));
+	    else
+		newsels = (Selection *)xrealloc(CurrentSelections,
+			    (NumCurrentSelections + 1) * sizeof(Selection));
+	    if (!newsels)
+		return BadAlloc;
+	    NumCurrentSelections++;
+	    CurrentSelections = newsels;
+	    CurrentSelections[i].selection = stuff->selection;
+	}
+#ifdef TSOL
+	/* 
+	 * tsolseln == NULL, either seln does not exist, 
+	 * or there is no sl,uid match
+	 */
+	if (!tsolseln)
+	{
+	    /* create one & put  it in place */
+	    tsolseln = (TsolSelnPtr)xalloc(sizeof(TsolSelnRec));
+	    if (!tsolseln)
+            return BadAlloc;
+	    tsolseln->next = (TsolSelnPtr)NULL;
+
+	    /* if necessary put at the end of the list */
+	    if (prevtsolseln)
+            prevtsolseln->next = tsolseln;
+	    else
+	        CurrentSelections[i].secPrivate = (pointer)tsolseln;
+	}
+	/* fill it in */
+    tsolseln->sl = tsolinfo->sl;
+    tsolseln->uid = tsolinfo->uid;
+    tsolseln->lastTimeChanged = time;
+	tsolseln->window = stuff->window;
+	tsolseln->pWin = pWin;
+	tsolseln->client = (pWin ? client : NullClient);
+	if (!PolySelection(CurrentSelections[i].selection))
+	{
+        /* no change to existing code. left as it is */
+#endif /* TSOL */
+
+        CurrentSelections[i].lastTimeChanged = time;
+	CurrentSelections[i].window = stuff->window;
+	CurrentSelections[i].pWin = pWin;
+	CurrentSelections[i].client = (pWin ? client : NullClient);
+	if (SelectionCallback)
+	{
+	    SelectionInfoRec	info;
+
+	    info.selection = &CurrentSelections[i];
+	    info.kind= SelectionSetOwner;
+	    CallCallbacks(&SelectionCallback, &info);
+	}
+#ifdef TSOL 
+	}
+#endif /* TSOL */
+
+	return (client->noClientException);
+    }
+    else 
+    {
+	client->errorValue = stuff->selection;
+        return (BadAtom);
+    }
+}
+
+int
+ProcTsolGetSelectionOwner(client)
+    register ClientPtr client;
+{
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    if (ValidAtom(stuff->id))
+    {
+	int i;
+        xGetSelectionOwnerReply reply;
+
+	i = 0;
+        while ((i < NumCurrentSelections) && 
+	       CurrentSelections[i].selection != stuff->id) i++;
+        reply.type = X_Reply;
+	reply.length = 0;
+	reply.sequenceNumber = client->sequence;
+        if (i < NumCurrentSelections)
+#ifdef TSOL 
+	{
+	    TsolSelnPtr tsolseln;
+	    TsolInfoPtr tsolinfo; /* tsol client info */
+	    tsolinfo = GetClientTsolInfo(client);
+
+	    /* find matching sl,uid in case of poly selns */
+	    tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate;
+	    if (PolySelection(CurrentSelections[i].selection))
+	    {
+            while (tsolseln)
+            {
+                if (tsolseln->uid == tsolinfo->uid &&
+                    tsolseln->sl == tsolinfo->sl)
+                    break; /* match found */
+                tsolseln = tsolseln->next;
+            }
+            if (tsolseln)
+                reply.owner = tsolseln->window;
+            else
+                reply.owner = None;
+	    }
+	    else
+        {
+            reply.owner = CurrentSelections[i].window;
+	    }
+	    /* 
+	     * Selection Agent processing. Override the owner
+	     */
+        if (!HasWinSelection(tsolinfo) &&
+            client->index != CLIENT_ID(reply.owner) &&
+            reply.owner != None &&
+            tsol_sel_agnt != -1 &&
+            CurrentSelections[tsol_sel_agnt].client)
+        {
+            WindowPtr pWin;
+            pWin = (WindowPtr)LookupWindow(reply.owner, client);
+            if (tsolinfo->flags & TSOL_AUDITEVENT)
+                auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION,
+                           AW_APPEND, AW_END);
+	     }
+	     else if (HasWinSelection(tsolinfo) &&
+                  tsolinfo->flags & TSOL_AUDITEVENT)
+	     {
+             auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION,
+                        AW_APPEND, AW_END);             
+	     }
+	     /* end seln agent processing */
+	}
+#else /* TSOL */
+            reply.owner = CurrentSelections[i].window;
+#endif /* TSOL */
+        else
+            reply.owner = None;
+        WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
+        return(client->noClientException);
+    }
+    else            
+    {
+	client->errorValue = stuff->id;
+        return (BadAtom); 
+    }
+}
+
+int
+ProcTsolConvertSelection(client)
+    register ClientPtr client;
+{
+    Bool paramsOkay;
+    xEvent event;
+    WindowPtr pWin;
+    REQUEST(xConvertSelectionReq);
+
+    REQUEST_SIZE_MATCH(xConvertSelectionReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+
+    paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target));
+    if (stuff->property != None)
+	paramsOkay &= ValidAtom(stuff->property);
+    if (paramsOkay)
+    {
+	int i;
+
+	i = 0;
+	while ((i < NumCurrentSelections) && 
+	       CurrentSelections[i].selection != stuff->selection) i++;
+#ifdef TSOL 
+	if (i < NumCurrentSelections)
+	{
+	    TsolSelnPtr tsolseln;
+	    TsolInfoPtr tsolinfo; /* tsol client info */
+	    Window twin;          /* temporary win */
+	    ClientPtr tclient;    /* temporary client */
+
+	    tsolinfo = GetClientTsolInfo(client);
+
+	    /* find matching sl,uid in case of poly selns */
+	    tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate;
+	    if (PolySelection(CurrentSelections[i].selection))
+	    {
+            while (tsolseln)
+            {
+                if (tsolseln->uid == tsolinfo->uid &&
+                    tsolseln->sl == tsolinfo->sl)
+                    break; /* match found */
+                tsolseln = tsolseln->next;
+            }
+            if (!tsolseln)
+            {
+                client->errorValue = stuff->property;
+                return (BadAtom);
+            }
+            twin = tsolseln->window;
+            tclient = tsolseln->client;
+	    }
+	    else
+	    {
+            twin = CurrentSelections[i].window;
+            tclient = CurrentSelections[i].client;
+	    }
+	    /*
+	     * Special case for seln agent.
+	     * SelectionRequest event is redirected to selection
+	     * agent for unpirvileged clients and who do not own
+	     * the selection
+	     */	    
+	    if (tsol_sel_agnt != -1 && CurrentSelections[tsol_sel_agnt].client)
+	    {
+            /* Redirect only if client other than owner & does not have priv */
+	        if (!HasWinSelection(tsolinfo) && (client != tclient))
+            {
+                tclient = CurrentSelections[tsol_sel_agnt].client;
+                twin = CurrentSelections[tsol_sel_agnt].window;
+                if (tsolinfo->flags & TSOL_AUDITEVENT)
+                    auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION,
+                               AW_APPEND, AW_END);
+	        }
+            else if (HasWinSelection(tsolinfo) &&
+                     tsolinfo->flags & TSOL_AUDITEVENT)
+            {
+                auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION,
+                           AW_APPEND, AW_END);
+            }
+	    }
+	    /* end of special case seln handling */
+
+	    if (twin != None)
+	    {
+            event.u.u.type = SelectionRequest;
+            event.u.selectionRequest.time = stuff->time;
+            event.u.selectionRequest.owner = twin;
+            event.u.selectionRequest.requestor = stuff->requestor;
+            event.u.selectionRequest.selection = stuff->selection;
+            event.u.selectionRequest.target = stuff->target;
+            event.u.selectionRequest.property = stuff->property;
+            if (TryClientEvents(tclient, &event, 1,
+                                NoEventMask, NoEventMask /* CantBeFiltered */,
+                                NullGrab))
+                return (client->noClientException);
+	    }
+	}
+#else /* TSOL */
+	if ((i < NumCurrentSelections) && 
+	    (CurrentSelections[i].window != None)
+#ifdef XCSECURITY
+	    && (!client->CheckAccess ||
+		(* client->CheckAccess)(client, CurrentSelections[i].window,
+					RT_WINDOW, SecurityReadAccess,
+					CurrentSelections[i].pWin))
+#endif
+	    )
+	{        
+	    event.u.u.type = SelectionRequest;
+	    event.u.selectionRequest.time = stuff->time;
+	    event.u.selectionRequest.owner = 
+			CurrentSelections[i].window;
+	    event.u.selectionRequest.requestor = stuff->requestor;
+	    event.u.selectionRequest.selection = stuff->selection;
+	    event.u.selectionRequest.target = stuff->target;
+	    event.u.selectionRequest.property = stuff->property;
+	    if (TryClientEvents(
+		CurrentSelections[i].client, &event, 1, NoEventMask,
+		NoEventMask /* CantBeFiltered */, NullGrab))
+		return (client->noClientException);
+	}
+#endif /* TSOL */
+
+	event.u.u.type = SelectionNotify;
+	event.u.selectionNotify.time = stuff->time;
+	event.u.selectionNotify.requestor = stuff->requestor;
+	event.u.selectionNotify.selection = stuff->selection;
+	event.u.selectionNotify.target = stuff->target;
+	event.u.selectionNotify.property = None;
+	(void) TryClientEvents(client, &event, 1, NoEventMask,
+			       NoEventMask /* CantBeFiltered */, NullGrab);
+	return (client->noClientException);
+    }
+    else 
+    {
+	client->errorValue = stuff->property;
+        return (BadAtom);
+    }
+}
+
+/* Allocate and initialize a tsolprop */
+
+TsolPropPtr
+AllocTsolProp()
+{
+    TsolPropPtr tsolprop;
+
+    tsolprop = (TsolPropPtr)Xcalloc(sizeof(TsolPropRec));
+
+    if (tsolprop)
+    {
+	tsolprop->size = 0;
+	tsolprop->data = NULL;
+        tsolprop->next = NULL;
+    }
+
+    return tsolprop;
+}
+
+/*
+ * property data/len is stored in pProp for single
+ * instantiated properties. Polyinstanticated property
+ * data/len stored in the tsolprop structure
+ */
+
+int
+TsolChangeWindowProperty(client, pWin, property, type,
+                         format, mode, len, value, sendevent)
+    ClientPtr	client;
+    WindowPtr	pWin;
+    Atom	property, type;
+    int		format, mode;
+    unsigned long len;
+    pointer	value;
+    Bool	sendevent;
+{
+    PropertyPtr pProp;
+    xEvent event;
+    int sizeInBytes;
+    int totalSize;
+    pointer data;
+    TsolPropPtr tsolprop;
+    TsolInfoPtr tsolinfo;
+    TsolResPtr tsolres;
+    int result;
+    int polyprop = PolyProperty(property, pWin);
+
+
+    if (!polyprop)
+    {
+        result = ChangeWindowProperty(pWin, property, type,
+				      format, mode, len, value, sendevent);
+	if (result != Success)
+	    return (result);
+    }
+
+    sizeInBytes = format>>3;
+    totalSize = len * sizeInBytes;
+
+    /* first see if property already exists */
+
+    pProp = wUserProps (pWin);
+    while (pProp )
+    {
+        if (pProp->propertyName == property)
+            break;
+        pProp = pProp->next;
+    }
+
+    tsolinfo = GetClientTsolInfo(client);
+    tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+    /* Initialize secPrviate if property is not polyinstantiated */
+    if (!polyprop && pProp)
+    {
+	/* Initialize for internally created properties */
+	if (!pProp->secPrivate)
+            pProp->secPrivate = (pointer)AllocTsolProp();
+
+        if (!pProp->secPrivate)
+            return(BadAlloc);
+
+        tsolprop = (TsolPropPtr)(pProp->secPrivate);
+        if (WindowIsRoot(pWin))
+        {
+            tsolprop->sl = tsolinfo->sl;	/* use client's sl/uid */
+            tsolprop->uid = tsolinfo->uid;
+        }
+        else
+        {
+            tsolprop->sl = tsolres->sl;		/* use window's sl/uid */
+            tsolprop->uid = tsolres->uid;
+        }
+
+	return (result);
+    }
+
+    /* Handle polyinstantiated property */
+    if (!pProp)   /* just add to list */
+    {
+        if (!pWin->optional && !MakeWindowOptional (pWin))
+            return(BadAlloc);
+        pProp = (PropertyPtr)xalloc(sizeof(PropertyRec));
+        if (!pProp)
+            return(BadAlloc);
+        pProp->secPrivate = (pointer)Xcalloc(sizeof(TsolPropRec));
+        if (!pProp->secPrivate)
+            return(BadAlloc);
+        data = (pointer)xalloc(totalSize);
+        if (!data && len)
+        {
+            xfree(pProp->secPrivate);
+            xfree(pProp);
+            return(BadAlloc);
+        }
+        pProp->propertyName = property;
+        pProp->type = type;
+        pProp->format = format;
+        pProp->data = data;
+        if (len)
+            bcopy((char *)value, (char *)data, totalSize);
+        pProp->size = len;
+        tsolprop = (TsolPropPtr)(pProp->secPrivate);
+        if (WindowIsRoot(pWin))
+        {
+            tsolprop->sl = tsolinfo->sl;
+            tsolprop->uid = tsolinfo->uid;
+        }
+        else
+        {
+            tsolprop->sl = tsolres->sl;
+            tsolprop->uid = tsolres->uid;
+        }
+        tsolprop->data = data;
+        tsolprop->size = len;
+        tsolprop->next = (TsolPropPtr)NULL;
+        pProp->next = pWin->optional->userProps;
+        pWin->optional->userProps = pProp;
+    }  /* end if !prop */
+    else
+    {
+        /* To append or prepend to a property the request format and type
+         * must match those of the already defined property.  The
+         * existing format and type are irrelevant when using the mode
+         * "PropModeReplace" since they will be written over.
+         */
+        if ((format != pProp->format) && (mode != PropModeReplace))
+            return(BadMatch);
+        if ((pProp->type != type) && (mode != PropModeReplace))
+            return(BadMatch);
+
+        tsolprop = (TsolPropPtr)(pProp->secPrivate);
+        /* search for a matching (sl, uid) pair */
+        while (tsolprop)
+        {
+            if (tsolprop->uid == tsolinfo->uid && tsolprop->sl == tsolinfo->sl)
+                    break; /* match found */
+            tsolprop = tsolprop->next;
+        }
+
+        if (!tsolprop)
+        {
+	    /* no match found. Create one */
+	    TsolPropPtr newtsol = (TsolPropPtr)Xcalloc(sizeof(TsolPropRec));
+	    if (!newtsol)
+	        return(BadAlloc);
+	    data = (pointer)Xcalloc(totalSize);
+	    if (!data && totalSize)
+	    {
+	        xfree(newtsol);
+	        return(BadAlloc);
+	    }
+	    if (len)
+	        memcpy((char *)data, (char *)value, totalSize);
+	    
+	    newtsol->sl = tsolinfo->sl;
+	    newtsol->uid = tsolinfo->uid;
+	    newtsol->data = data;
+	    newtsol->size = len;
+            newtsol->next = (TsolPropPtr)(pProp->secPrivate);
+            pProp->secPrivate = (pointer)newtsol;
+        }
+        else
+        {
+            switch (mode)
+            {
+                case PropModeReplace:                    
+                    if (totalSize != tsolprop->size * (pProp->format >> 3))
+                    {
+                        data = (pointer)xrealloc(tsolprop->data, totalSize);
+                        if (!data && len)
+                            return(BadAlloc);
+                        tsolprop->data = data;
+                    }
+                    if (len)
+                        bcopy((char *)value, (char *)tsolprop->data, totalSize);
+                    tsolprop->size = len;
+                    pProp->type = type;
+                    pProp->format = format;
+                    break;
+                    
+                case PropModeAppend:
+                    if (len)
+                    {
+                        data =
+                            (pointer)xrealloc(tsolprop->data,
+                                              sizeInBytes*(len+tsolprop->size));
+                        if (!data)
+                            return(BadAlloc);
+                        tsolprop->data = data;
+                        bcopy((char *)value,
+                              &((char *)data)[tsolprop->size * sizeInBytes],
+                              totalSize);
+                        tsolprop->size += len;
+                    }
+                    break;
+                    
+                case PropModePrepend:
+                    if (len)
+                    {
+                        data =
+                            (pointer)xalloc(sizeInBytes*(len + tsolprop->size));
+                        if (!data)
+                            return(BadAlloc);
+                        bcopy((char *)tsolprop->data,
+                              &((char *)data)[totalSize],
+                              (int)(tsolprop->size * sizeInBytes));
+                        bcopy((char *)value, (char *)data, totalSize);
+                        xfree(tsolprop->data);
+                        tsolprop->data = data;
+                        tsolprop->size += len;
+                    }
+                    break;
+            }
+        }
+    }  /* end else if !prop */
+
+    event.u.u.type = PropertyNotify;
+    event.u.property.window = pWin->drawable.id;
+    event.u.property.state = PropertyNewValue;
+    event.u.property.atom = pProp->propertyName;
+    event.u.property.time = currentTime.milliseconds;
+    DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+
+    return(Success);
+}
+
+int
+TsolInitWindow(client, pWin)
+    ClientPtr client;
+    WindowPtr pWin;
+{
+    TsolInfoPtr tsolinfo;
+    TsolResPtr  tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+    if (client == serverClient)
+    {
+	tsolres->uid = 0;
+	tsolres->sl = (bslabel_t *)lookupSL_low();
+    }
+    else
+    {
+        tsolinfo = GetClientTsolInfo(client);
+	tsolres->uid = tsolinfo->uid;
+	tsolres->sl = tsolinfo->sl;
+    }
+}
+
+int
+TsolDeleteProperty(client, pWin, propName)
+    ClientPtr client;
+    WindowPtr pWin;
+    Atom propName;
+{
+    PropertyPtr pProp, prevProp;
+    xEvent event;
+    TsolPropPtr tsolprop, tail_prop, prevtsolprop;
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    if (!(pProp = wUserProps (pWin)))
+        return(Success);
+
+    if (!PolyProperty(propName, pWin))
+	return (DeleteProperty(pWin, propName));
+
+    prevProp = (PropertyPtr)NULL;
+    while (pProp)
+    {
+        if (pProp->propertyName == propName)
+        {
+    	    tsolprop = (TsolPropPtr)(pProp->secPrivate);
+            /* Found a matching name. Further match for SL,UID */
+            prevtsolprop = (TsolPropPtr)NULL;
+            tail_prop = tsolprop;
+            while (tsolprop)
+            {
+                if (tsolpolyinstinfo.enabled)
+                {
+                    if (tsolprop->uid == tsolpolyinstinfo.uid &&
+                        tsolprop->sl == tsolpolyinstinfo.sl)
+                    {
+                        break;
+                    }
+                }
+                else
+                {
+                    if (tsolprop->uid == tsolinfo->uid &&
+                        tsolprop->sl == tsolinfo->sl)
+                    {
+                        break;
+                    }
+                }
+                prevtsolprop = tsolprop;
+                tsolprop = tsolprop->next;
+	    }
+	    break;
+        }
+        prevProp = pProp;
+        pProp = pProp->next;
+    }
+
+    if (pProp) 
+    {		    
+        event.u.u.type = PropertyNotify;
+        event.u.property.window = pWin->drawable.id;
+        event.u.property.state = PropertyDelete;
+        event.u.property.atom = pProp->propertyName;
+        event.u.property.time = currentTime.milliseconds;
+        DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+
+        if (tsolprop)
+        {
+	    if ((TsolPropPtr)(pProp->secPrivate) == tsolprop)
+		pProp->secPrivate = (pointer)(tsolprop->next);
+
+            if (prevtsolprop)
+            {
+                prevtsolprop->next = tsolprop->next;
+            }
+            xfree(tsolprop->data);
+            xfree(tsolprop);
+
+        }
+    }
+    return(Success);
+}
+
+int
+ProcTsolListProperties(client)
+    ClientPtr client;
+{
+    Atom *pAtoms, *temppAtoms;
+    xListPropertiesReply xlpr;
+    int	numProps = 0;
+    WindowPtr pWin;
+    PropertyPtr pProp;
+    REQUEST(xResourceReq);
+    int err_code;
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+
+    /* policy check for window  */
+    if (err_code = xtsol_policy(TSOL_RES_PROPWIN, TSOL_READ, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        client->errorValue = stuff->id;
+        return (err_code);
+    }
+
+    pProp = wUserProps (pWin);
+    while (pProp)
+    {        
+        if (PolyProperty(pProp->propertyName, pWin))
+        {
+            if (PolyPropReadable(pProp, client))
+                numProps++;
+        }
+        else
+        {
+            /* error ignored */
+            if (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_READ, pProp,
+                              client, TSOL_ALL, (void *)MAJOROP))
+                numProps++;
+        }
+        pProp = pProp->next;
+    }
+
+    if (numProps)
+        if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom))))
+            return(BadAlloc);
+
+    xlpr.type = X_Reply;
+    xlpr.nProperties = numProps;
+    xlpr.length = (numProps * sizeof(Atom)) >> 2;
+    xlpr.sequenceNumber = client->sequence;
+    pProp = wUserProps (pWin);
+    temppAtoms = pAtoms;
+    while (pProp)
+    {
+        if (PolyProperty(pProp->propertyName, pWin))
+        {
+            if (PolyPropReadable(pProp, client))
+                *temppAtoms++ = pProp->propertyName;
+        }
+        else
+        {
+            /* error ignored */
+            if (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_READ, pProp,
+                              client, TSOL_ALL, (void *)MAJOROP))
+                *temppAtoms++ = pProp->propertyName;
+        }
+	pProp = pProp->next;
+    }
+    WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
+    if (numProps)
+    {
+    	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+        WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
+        DEALLOCATE_LOCAL(pAtoms);
+    }
+    return(client->noClientException);
+}
+
+int
+ProcTsolGetProperty(client)
+    ClientPtr client;
+{
+    PropertyPtr pProp, prevProp;
+    unsigned long n, len, ind;
+    WindowPtr pWin;
+    xGetPropertyReply reply;
+    TsolPropPtr tsolprop;
+    TsolPropPtr prevtsolprop;
+    int err_code;
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+    REQUEST(xGetPropertyReq);
+
+    REQUEST_SIZE_MATCH(xGetPropertyReq);
+    if (stuff->delete)
+	UpdateCurrentTime();
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+
+    if (!ValidAtom(stuff->property))
+    {
+	client->errorValue = stuff->property;
+	return(BadAtom);
+    }
+    if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
+    {
+	client->errorValue = stuff->delete;
+	return(BadValue);
+    }
+
+    if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
+    {
+	client->errorValue = stuff->type;
+	return(BadAtom);
+    }
+
+
+    /* policy check for window  */
+    if (err_code = xtsol_policy(TSOL_RES_PROPWIN, TSOL_READ, pWin,
+                                client, TSOL_ALL, (void *)MAJOROP))
+    {
+        client->errorValue = stuff->window;
+        return (err_code);
+    }
+
+    if (!PolyProperty(stuff->property, pWin))
+    {
+	return (*TsolSavedProcVector[X_GetProperty])(client);
+    }
+
+    pProp = wUserProps (pWin);
+    prevProp = (PropertyPtr)NULL;
+
+    while (pProp)
+    {
+        if (pProp->propertyName == stuff->property)
+	{
+            tsolprop = (TsolPropPtr)(pProp->secPrivate);
+	    prevtsolprop = tsolprop;
+            while (tsolprop)
+            {
+                if (tsolpolyinstinfo.enabled)
+                {
+                    if (tsolprop->uid == tsolpolyinstinfo.uid &&
+                        tsolprop->sl == tsolpolyinstinfo.sl)
+                        break;
+                }
+                else
+                {
+                    if (tsolprop->uid == tsolinfo->uid &&
+                        tsolprop->sl == tsolinfo->sl)
+                        break; /* match found */
+                }
+                prevtsolprop = tsolprop;
+                tsolprop = tsolprop->next;
+	    }
+            break;
+	}
+	prevProp = pProp;
+	pProp = pProp->next;
+    }
+
+    reply.type = X_Reply;
+    reply.sequenceNumber = client->sequence;
+
+    if ( (!pProp) || (!tsolprop) || err_code)
+    {
+        reply.nItems = 0;
+        reply.length = 0;
+        reply.bytesAfter = 0;
+        reply.propertyType = None;
+        reply.format = 0;
+        WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+    }
+    else
+    {
+        /* If the request type and actual type don't match. Return the
+           property information, but not the data. */
+
+        if (((stuff->type != pProp->type) &&
+	     (stuff->type != AnyPropertyType)))
+        {
+	    reply.bytesAfter = tsolprop->size;
+	    reply.format = pProp->format;
+	    reply.length = 0;
+	    reply.nItems = 0;
+	    reply.propertyType = pProp->type;
+	    WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+	    return(Success);
+        }
+
+	/*
+         *  Return type, format, value to client
+         */
+        n = (pProp->format/8) * tsolprop->size; 
+
+	ind = stuff->longOffset << 2;        
+
+        /* If longOffset is invalid such that it causes "len" to
+           be negative, it's a value error. */
+
+	if (n < ind)
+	{
+	    client->errorValue = stuff->longOffset;
+	    return BadValue;
+	}
+
+	len = min(n - ind, 4 * stuff->longLength);
+
+	reply.bytesAfter = n - (ind + len);
+	reply.format = pProp->format;
+	reply.length = (len + 3) >> 2;
+	reply.nItems = len / (pProp->format / 8 );
+	reply.propertyType = pProp->type;
+
+        /* policy check for delete error ignored */
+        if (stuff->delete && (reply.bytesAfter == 0) &&
+            (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_DESTROY, pProp,
+                           client, TSOL_ALL, (void *)MAJOROP)))
+        { /* send the event */
+	    xEvent event;
+		
+	    event.u.u.type = PropertyNotify;
+	    event.u.property.window = pWin->drawable.id;
+	    event.u.property.state = PropertyDelete;
+	    event.u.property.atom = pProp->propertyName;
+	    event.u.property.time = currentTime.milliseconds;
+	    DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+	}
+
+	WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+	if (len)
+	{
+	    switch (reply.format) {
+	    case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break;
+	    case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break;
+	    default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
+	    }
+	    WriteSwappedDataToClient(client, len, (char *)tsolprop->data + ind);
+	}
+
+        if (stuff->delete && (reply.bytesAfter == 0))
+        { /* delete the Property */
+            if (prevProp == (PropertyPtr)NULL) /* takes care of head */
+	    {
+		if (!(pWin->optional->userProps = pProp->next))
+		    CheckWindowOptionalNeed (pWin);
+	    }
+	    else
+		prevProp->next = pProp->next;
+
+	    /* remove the tsol struct */
+            prevtsolprop->next = tsolprop->next;
+            xfree(tsolprop->data);
+            xfree(tsolprop);
+            /* delete the prop for last reference */
+            if (tsolprop == prevtsolprop)
+                xfree(pProp);
+	}
+    }
+    return (client->noClientException);
+}
+
+int
+ProcTsolChangeKeyboardMapping(client)
+    ClientPtr client;
+{
+    int err_code;
+
+    if (err_code = xtsol_policy(TSOL_RES_KEYMAP, TSOL_MODIFY, 
+	NULL, client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* Ignore error */
+	return client->noClientException;
+    }
+    else
+    {
+	return (*TsolSavedProcVector[X_ChangeKeyboardMapping])(client);
+    }
+}
+
+int
+ProcTsolSetPointerMapping(client)
+    ClientPtr client;
+{
+    int err_code;
+
+    if (err_code = xtsol_policy(TSOL_RES_PTRMAP, TSOL_MODIFY, 
+	NULL, client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* Ignore error */
+	return Success;
+    }
+    else
+    {
+	return (*TsolSavedProcVector[X_SetPointerMapping])(client);
+    }
+}
+
+int
+ProcTsolChangeKeyboardControl(client)
+    ClientPtr client;
+{
+    int err_code;
+
+    if (err_code = xtsol_policy(TSOL_RES_KBDCTL, TSOL_MODIFY, 
+	NULL, client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* Ignore error */
+	return Success;
+    }
+    else
+    {
+	return (*TsolSavedProcVector[X_ChangeKeyboardControl])(client);
+    }
+}
+
+int
+ProcTsolBell(client)
+    ClientPtr client;
+{
+    int err_code;
+
+    if (err_code = xtsol_policy(TSOL_RES_BELL, TSOL_MODIFY, 
+	NULL, client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* Ignore error */
+	return Success;
+    }
+    else
+    {
+	return (*TsolSavedProcVector[X_Bell])(client);
+    }
+}
+
+int
+ProcTsolChangePointerControl(client)
+    ClientPtr client;
+{
+    int err_code;
+
+    if (err_code = xtsol_policy(TSOL_RES_PTRCTL, TSOL_MODIFY, 
+	NULL, client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* Ignore error */
+	return Success;
+    }
+    else
+    {
+	return (*TsolSavedProcVector[X_ChangePointerControl])(client);
+    }
+}
+
+int 
+ProcTsolSetModifierMapping(client)
+    ClientPtr client;
+{
+    xSetModifierMappingReply rep;
+    REQUEST(xSetModifierMappingReq);
+    KeyCode *inputMap;
+    int inputMapLen;
+    register int i;
+    int err_code;
+    DeviceIntPtr keybd = inputInfo.keyboard;
+    register KeyClassPtr keyc = keybd->key;
+    
+    REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
+
+    if (client->req_len != ((stuff->numKeyPerModifier<<1) +
+			    (sizeof (xSetModifierMappingReq)>>2)))
+	return BadLength;
+
+    inputMapLen = 8*stuff->numKeyPerModifier;
+    inputMap = (KeyCode *)&stuff[1];
+
+    /*
+     *	Now enforce the restriction that "all of the non-zero keycodes must be
+     *	in the range specified by min-keycode and max-keycode in the
+     *	connection setup (else a Value error)"
+     */
+    i = inputMapLen;
+    while (i--)
+    {
+	if (inputMap[i]
+	    && (inputMap[i] < keyc->curKeySyms.minKeyCode
+		|| inputMap[i] > keyc->curKeySyms.maxKeyCode))
+	{
+	    client->errorValue = inputMap[i];
+	    return BadValue;
+	}
+    }
+
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.success = MappingSuccess;
+
+
+    if (err_code = xtsol_policy(TSOL_RES_MODMAP, TSOL_MODIFY, 
+	NULL, client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* 
+	 * silently ignore the request. xview apps 
+	 * complain if we return error code. If we don't
+	 * send the map notify event application hangs
+	 */
+         SendMappingNotify(MappingModifier, 0, 0,client);
+	 WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
+	 return(client->noClientException);
+    }
+    else
+    {
+	return (*TsolSavedProcVector[X_SetModifierMapping])(client);
+    }
+}
+
+void
+RemoveStripeWindow()
+{
+    WindowPtr pParent;
+    WindowPtr pHead;
+
+    if (!tpwin)
+	return;
+
+    pParent = tpwin->parent;
+    pHead = pParent->firstChild;
+    if (tpwin == pHead) {
+	pHead = tpwin->nextSib;
+	tpwin->nextSib->prevSib = tpwin->prevSib;
+    }
+
+    if (tpwin == pParent->lastChild) {
+	pParent->lastChild = tpwin->nextSib;
+    }
+}
+
+void
+ResetStripeWindow()
+{
+    WindowPtr pParent;
+
+    /* Ignore if stripe is not set */
+    if (!tpwin)
+	return;
+
+    pParent = tpwin->parent;
+    /* stripe is already at head, nothing to do */
+    if (!pParent || pParent->firstChild == tpwin)
+	return;
+
+     ReflectStackChange(tpwin, pParent->firstChild, VTStack);
+}
+
+int
+ProcTsolCreateWindow(client)
+    ClientPtr client;
+{
+    int result;
+    WindowPtr pParent;
+    WindowPtr pWin;
+    bslabel_t admin_low;
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+    TsolResPtr  tsolres;
+
+    REQUEST(xCreateWindowReq);
+
+    REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
+    
+    LEGAL_NEW_RESOURCE(stuff->wid, client);
+    if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
+						    SecurityWriteAccess)))
+        return BadWindow;
+
+
+    if (result = xtsol_policy(TSOL_RES_WINDOW, TSOL_CREATE, pParent,
+		client, TSOL_ALL, (void *)MAJOROP))
+	return (result);
+
+    /* Initialize tsol security attributes */
+    result = (*TsolSavedProcVector[X_CreateWindow])(client);
+    pWin = pParent->firstChild;
+    tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+    /* stuff tsol info into window from client */
+    if (tsolinfo == NULL || client == serverClient) {
+	/* Client is Server itself */
+	tsolres->uid = 0;
+	tsolres->sl = (bslabel_t *)lookupSL_low();
+    }
+    else
+    {
+	tsolres->uid = tsolinfo->uid;
+	tsolres->sl = tsolinfo->sl;
+    }
+
+    bsllow(&admin_low);
+    if (blequal(tsolres->sl, &admin_low))
+        tsolres->flags = TRUSTED_MASK;
+    else
+        tsolres->flags = 0;
+
+    ResetStripeWindow();
+
+    return result;
+}
+
+int
+ProcTsolChangeWindowAttributes(client)
+    register ClientPtr client;
+{
+    register WindowPtr pWin;
+    REQUEST(xChangeWindowAttributesReq);
+    int result;
+
+    REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+					   SecurityWriteAccess);
+    if (!pWin)
+        return(BadWindow);
+
+    if (result = xtsol_policy(TSOL_RES_WINDOW, TSOL_MODIFY, pWin,
+    	client, TSOL_ALL, (void *)MAJOROP))
+    {
+        if (!WindowIsRoot(pWin))
+            return (result);
+    }
+
+    result = (*TsolSavedProcVector[X_ChangeWindowAttributes])(client);
+    ResetStripeWindow();
+
+    return result;
+}
+
+int
+ProcTsolConfigureWindow(client)
+    register ClientPtr client;
+{
+    int result;
+
+    result = (*TsolSavedProcVector[X_ConfigureWindow])(client);
+    ResetStripeWindow();
+
+    return result;
+}
+
+int
+ProcTsolCirculateWindow(client)
+    register ClientPtr client;
+{
+    int result;
+
+    result = (*TsolSavedProcVector[X_CirculateWindow])(client);
+    ResetStripeWindow();
+
+    return result;
+}
+
+int
+ProcTsolReparentWindow(client)
+    register ClientPtr client;
+{
+    int result;
+
+    result = (*TsolSavedProcVector[X_ReparentWindow])(client);
+    ResetStripeWindow();
+
+    return result;
+}
+
+int
+ProcTsolSendEvent(client)
+    register ClientPtr client;
+{
+    WindowPtr pWin;
+    REQUEST(xSendEventReq);
+
+    REQUEST_SIZE_MATCH(xSendEventReq);
+
+    pWin = LookupWindow(stuff->destination, client);
+
+    if (!pWin)
+	return BadWindow;
+
+    if (xtsol_policy(TSOL_RES_EVENTWIN, TSOL_MODIFY,
+		pWin, client, TSOL_ALL, (void *)MAJOROP))
+	return Success; /* ignore error */
+
+    return (*TsolSavedProcVector[X_SendEvent])(client);
+}
+
+
+/*
+ * HandleHotKey - 
+ * HotKey is Meta(Diamond)+ Stop Key
+ * Breaks untusted Ptr and Kbd grabs.
+ * Trusted Grabs are NOT broken 
+ * Warps pointer to the Trusted Stripe if not Trusted grabs in force.
+ */
+void
+HandleHotKey()
+{
+    extern unsigned int StripeHeight;
+    int	            x, y;
+    Bool            trusted_grab = FALSE;
+    ClientPtr       client;
+    DeviceIntPtr    mouse = inputInfo.pointer;
+    DeviceIntPtr    keybd = inputInfo.keyboard;
+    TsolInfoPtr	    tsolinfo;    
+    GrabPtr         ptrgrab = mouse->grab;
+    GrabPtr         kbdgrab = keybd->grab;
+    ScreenPtr       pScreen;
+
+    if (kbdgrab)
+    {
+	client = clients[CLIENT_ID(kbdgrab->resource)];
+	tsolinfo = GetClientTsolInfo(client);
+
+        if (tsolinfo)
+        {
+            if (HasTrustedPath(tsolinfo))
+                trusted_grab = TRUE;
+            else
+	        (*keybd->DeactivateGrab)(keybd);
+	}
+
+	if (ptrgrab)
+	{
+	    client = clients[CLIENT_ID(ptrgrab->resource)];
+	    tsolinfo = GetClientTsolInfo(client);
+
+            if (tsolinfo)
+            {
+                if (HasTrustedPath(tsolinfo))
+                    trusted_grab = TRUE;
+                else
+	            (*mouse->DeactivateGrab)(mouse);
+	    }
+        }
+    }
+
+    if (!trusted_grab)
+    {
+        /*
+         * Warp the pointer to the Trusted Stripe
+         */
+	    pScreen = screenInfo.screens[0];
+	    x = pScreen->width/2;
+	    y = pScreen->height - StripeHeight/2;
+        (*pScreen->SetCursorPosition)(pScreen, x, y, TRUE);
+    }
+}
+
+int
+ProcTsolSetInputFocus(client)
+    ClientPtr client;
+{
+
+    REQUEST(xSetInputFocusReq);
+
+    REQUEST_SIZE_MATCH(xSetInputFocusReq);
+
+    if (stuff->focus != None)
+    {
+        WindowPtr focuswin;
+
+	focuswin = LookupWindow(stuff->focus, client);
+	if ((focuswin != NullWindow) &&
+	    xtsol_policy(TSOL_RES_FOCUSWIN, TSOL_MODIFY, focuswin,
+		client, TSOL_ALL, (void *)MAJOROP))
+	{
+	    return (client->noClientException);
+	}
+    }
+    return (*TsolSavedProcVector[X_SetInputFocus])(client);
+}
+
+int
+ProcTsolGetInputFocus(client)
+    ClientPtr client;
+{
+    xGetInputFocusReply rep;
+    REQUEST(xReq);
+    FocusClassPtr focus = inputInfo.keyboard->focus;
+
+    REQUEST_SIZE_MATCH(xReq);
+#ifdef PANORAMIX
+    if ( !noPanoramiXExtension )
+        return PanoramiXGetInputFocus(client);
+#endif
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    if (focus->win == NoneWin)
+	rep.focus = None;
+    else if (focus->win == PointerRootWin)
+	rep.focus = PointerRoot;
+    else if (xtsol_policy(TSOL_RES_FOCUSWIN, TSOL_READ,
+	    focus->win, client, TSOL_ALL, (void *)MAJOROP))
+	rep.focus = RootOf(focus->win); /* root window on access failure */
+    else rep.focus = focus->win->drawable.id;
+    rep.revertTo = focus->revert;
+    WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
+    return Success;
+}
+
+void
+PrintSiblings(p1)
+    WindowPtr p1;
+{
+    WindowPtr p2;
+
+    if (p1 == NULL || p1->parent == NULL) return;
+
+    p2 = p1->parent->firstChild;
+    while (p2)
+    {
+	ErrorF( "(%x, %d, %d, %x)\n", p2, p2->drawable.width, 
+	    p2->drawable.height, p2->prevSib);
+	p2 = p2->nextSib;
+    }
+}
+
+/*
+ * Checks that tpwin & its siblings have same
+ * parents. Returns 0 if OK, a # indicating which
+ * Sibling has a bad parent
+ */
+int
+CheckTPWin()
+{
+	WindowPtr pWin;
+	int count = 1;
+
+	pWin = tpwin->nextSib;
+	while (pWin)
+	{
+		if (pWin->parent->parent)
+			return count;
+		pWin = pWin->nextSib;
+		++count;
+	}
+	return 0;
+}
+
+/* NEW */
+
+int
+ProcTsolGetGeometry(client)
+    register ClientPtr client;
+{
+    xGetGeometryReply rep;
+    int status;
+
+    REQUEST(xResourceReq);
+
+    if ((status = GetGeometry(client, &rep)) != Success)
+	return status;
+
+    /* Reduce root window height = stripe height */
+    if (stuff->id == rep.root)
+    {
+        extern unsigned int StripeHeight;
+        rep.height -= StripeHeight;
+    }
+
+    WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
+    return(client->noClientException);
+}
+
+int
+ProcTsolGrabServer(client)
+    register ClientPtr client;
+{
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    REQUEST(xResourceReq);
+    REQUEST_SIZE_MATCH(xReq);
+
+    if (xtsol_policy(TSOL_RES_SRVGRAB, TSOL_CREATE, NULL,
+        	client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* turn off auditing because operation ignored */
+        tsolinfo->flags &= ~TSOL_DOXAUDIT;
+        tsolinfo->flags &= ~TSOL_AUDITEVENT;
+
+        return(client->noClientException);
+    }
+
+    return (*TsolSavedProcVector[X_GrabServer])(client);
+}
+
+int
+ProcTsolUngrabServer(client)
+    register ClientPtr client;
+{
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    REQUEST(xResourceReq);
+    REQUEST_SIZE_MATCH(xReq);
+
+    if (xtsol_policy(TSOL_RES_SRVGRAB, TSOL_DESTROY, NULL,
+        	client, TSOL_ALL, (void *)MAJOROP))
+    {
+	/* turn off auditing because operation ignored */
+        tsolinfo->flags &= ~TSOL_DOXAUDIT;
+        tsolinfo->flags &= ~TSOL_AUDITEVENT;
+
+        return(client->noClientException);
+    }
+
+    return (*TsolSavedProcVector[X_UngrabServer])(client);
+}
+
+int
+ProcTsolCreatePixmap(client)
+    register ClientPtr client;
+{
+    PixmapPtr pMap;
+    int result;
+
+    REQUEST(xCreatePixmapReq);
+
+    REQUEST_SIZE_MATCH(xCreatePixmapReq);
+
+    result = (*TsolSavedProcVector[X_CreatePixmap])(client);
+
+    pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->pid, RT_PIXMAP,
+					     SecurityDestroyAccess);
+    if (pMap) 
+    {
+	/* Initialize security info */
+        TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+        TsolResPtr tsolres =
+            (TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr);
+
+        if (tsolinfo == NULL || client == serverClient)
+	{
+	    /* Client is Server itself */
+	    tsolres->uid = 0;
+	    tsolres->sl = (bslabel_t *)lookupSL_low();
+        }
+        else
+        {
+	    tsolres->uid = tsolinfo->uid;
+	    tsolres->sl = tsolinfo->sl;
+        }
+        tsolres->flags = 0;
+    }
+
+    return result;
+}
+int
+ProcTsolSetScreenSaver(client)
+    register ClientPtr client;
+{
+    int result;
+
+    REQUEST(xSetScreenSaverReq);
+
+    REQUEST_SIZE_MATCH(xSetScreenSaverReq);
+
+    if (result = xtsol_policy(TSOL_RES_SCRSAVER, TSOL_MODIFY, NULL,
+             client, TSOL_ALL, (void *)MAJOROP))
+        return (result);
+
+    return (*TsolSavedProcVector[X_SetScreenSaver])(client);
+}
+
+int
+ProcTsolChangeHosts(client)
+    register ClientPtr client;
+{
+    int result;
+
+    REQUEST(xChangeHostsReq);
+
+    REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength);
+
+    if (result = xtsol_policy(TSOL_RES_ACL, TSOL_MODIFY, NULL,
+             client, TSOL_ALL, (void *)MAJOROP))
+        return (result);
+
+    return (*TsolSavedProcVector[X_ChangeHosts])(client);
+}
+
+int
+ProcTsolChangeAccessControl(client)
+    register ClientPtr client;
+{
+    int result;
+
+    REQUEST(xSetAccessControlReq);
+
+    REQUEST_SIZE_MATCH(xSetAccessControlReq);
+
+    if (result = xtsol_policy(TSOL_RES_ACL, TSOL_MODIFY,
+		(void *)stuff->mode, client, TSOL_ALL, (void *)MAJOROP))
+    {
+        client->errorValue = stuff->mode;
+        return (result);
+    }
+
+    return (*TsolSavedProcVector[X_SetAccessControl])(client);
+}
+
+int
+ProcTsolKillClient(client)
+    register ClientPtr client;
+{
+    int result;
+
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+
+    if (result = xtsol_policy(TSOL_RES_CLIENT, TSOL_DESTROY,
+		(void *)stuff->id, client, TSOL_ALL, (void *)MAJOROP))
+    {
+        client->errorValue = stuff->id;
+        return (result);
+    }
+
+    return (*TsolSavedProcVector[X_KillClient])(client);
+}
+
+int
+ProcTsolSetFontPath(client)
+    register ClientPtr client;
+{
+    REQUEST(xSetFontPathReq);
+    
+    REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
+    
+    if (xtsol_policy(TSOL_RES_FONTPATH, TSOL_MODIFY, NULL,
+                     client, TSOL_ALL, (void *)MAJOROP))
+    {
+        return (BadValue);
+    }
+
+    return (*TsolSavedProcVector[X_SetFontPath])(client);
+}
+
+int
+ProcTsolChangeCloseDownMode(client)
+    register ClientPtr client;
+{
+    REQUEST(xSetCloseDownModeReq);
+
+    REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
+
+    if (xtsol_policy(TSOL_RES_CLIENT, TSOL_MODIFY, NULL,
+		client, TSOL_ALL, (void *)MAJOROP))
+        return (client->noClientException); /* Ignore error */
+
+    return (*TsolSavedProcVector[X_SetCloseDownMode])(client);
+}
+
+int ProcTsolForceScreenSaver(client)
+    register ClientPtr client;
+{    
+    int result;
+
+    REQUEST(xForceScreenSaverReq);
+
+    REQUEST_SIZE_MATCH(xForceScreenSaverReq);
+    
+
+    if (result = xtsol_policy(TSOL_RES_SCRSAVER, TSOL_MODIFY, NULL,
+             client, TSOL_ALL, (void *)MAJOROP))
+        return (result);
+
+    return (*TsolSavedProcVector[X_ForceScreenSaver])(client);
+}
+
+void
+TsolDeleteWindowFromAnySelections(pWin)
+    WindowPtr pWin;
+{
+    register int i;
+    TsolSelnPtr tsolseln = NULL;
+    TsolSelnPtr prevtsolseln = NULL;
+
+    for (i = 0; i< NumCurrentSelections; i++)
+    {
+        if (PolySelection(CurrentSelections[i].selection))
+        {
+            tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate;
+            prevtsolseln = tsolseln;
+            while (tsolseln)
+            {
+                if (tsolseln->pWin == pWin)
+		    break; /* match found */
+                prevtsolseln = tsolseln;
+                tsolseln = tsolseln->next;
+            }
+
+            if (tsolseln)
+            {
+	        if (SelectionCallback)
+	        {
+		    SelectionInfoRec    info;
+
+		    info.selection = &CurrentSelections[i];
+		    info.kind = SelectionClientClose;
+		    CallCallbacks(&SelectionCallback, &info);
+	        }
+
+                /* first on the list */
+                if (prevtsolseln == tsolseln)
+                    CurrentSelections[i].secPrivate = (pointer)tsolseln->next;
+                else
+                    prevtsolseln->next = tsolseln->next;
+                xfree(tsolseln);
+
+		/* handle the last reference */
+                if (CurrentSelections[i].secPrivate == NULL)
+                {
+                    CurrentSelections[i].pWin = (WindowPtr)NULL;
+                    CurrentSelections[i].window = None;
+                    CurrentSelections[i].client = NullClient;
+                }
+            }
+        }
+        else
+        {
+            if (CurrentSelections[i].pWin == pWin)
+            {
+                CurrentSelections[i].pWin = (WindowPtr)NULL;
+                CurrentSelections[i].window = None;
+                CurrentSelections[i].client = NullClient;
+            }
+        }
+   }
+}
+
+void
+TsolDeleteClientFromAnySelections(client)
+    ClientPtr client;
+{
+    register int i;
+    TsolSelnPtr tsolseln = NULL;
+    TsolSelnPtr prevtsolseln = NULL;
+
+    for (i = 0; i< NumCurrentSelections; i++)
+    {
+        if (PolySelection(CurrentSelections[i].selection))
+        {
+            tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate;
+            prevtsolseln = tsolseln;
+            while (tsolseln)
+            {
+                if (tsolseln->client == client)
+		    break; /* match found */
+                prevtsolseln = tsolseln;
+                tsolseln = tsolseln->next;
+            }
+
+            if (tsolseln)
+            {
+	        if (SelectionCallback)
+	        {
+		    SelectionInfoRec    info;
+
+		    info.selection = &CurrentSelections[i];
+		    info.kind = SelectionClientClose;
+		    CallCallbacks(&SelectionCallback, &info);
+	        }
+
+                /* first on the list */
+                if (prevtsolseln == tsolseln)
+                    CurrentSelections[i].secPrivate = (pointer)tsolseln->next;
+                else
+                    prevtsolseln->next = tsolseln->next;
+                xfree(tsolseln);
+
+		/* handle the last reference */
+                if (CurrentSelections[i].secPrivate == NULL)
+                {
+                    CurrentSelections[i].pWin = (WindowPtr)NULL;
+                    CurrentSelections[i].window = None;
+                    CurrentSelections[i].client = NullClient;
+                }
+            }
+        }
+        else
+        {
+            if (CurrentSelections[i].client == client)
+            {
+                CurrentSelections[i].pWin = (WindowPtr)NULL;
+                CurrentSelections[i].window = None;
+                CurrentSelections[i].client = NullClient;
+            }
+        }
+   }
+}
+
+int
+ProcTsolListInstalledColormaps(client)
+    register ClientPtr client;
+{
+    xListInstalledColormapsReply *preply; 
+    int nummaps;
+    WindowPtr pWin;
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+
+    if (!pWin)
+        return(BadWindow);
+
+    preply = (xListInstalledColormapsReply *) 
+		ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
+		     pWin->drawable.pScreen->maxInstalledCmaps *
+		     sizeof(Colormap));
+    if(!preply)
+        return(BadAlloc);
+
+    preply->type = X_Reply;
+    preply->sequenceNumber = client->sequence;
+    nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
+        (pWin->drawable.pScreen, (Colormap *)&preply[1]);
+    preply->nColormaps = nummaps;
+    preply->length = nummaps;
+#ifdef TSOL
+    {
+        int err_code, i;
+        Colormap *pcmap = (Colormap *)&preply[1];
+        ColormapPtr pcmp;
+
+	    /*
+         * check every colormap id for access. return default colormap
+	     * id in case of failure
+	     */
+        for (i = 0; i < nummaps; i++, pcmap++)
+        {
+            pcmp = (ColormapPtr )LookupIDByType(*pcmap, RT_COLORMAP);
+            if (err_code = xtsol_policy(TSOL_RES_CMAP, TSOL_READ, pcmp,
+                                        client, TSOL_ALL, (void *)MAJOROP))
+            {
+                *pcmap = pWin->drawable.pScreen->defColormap;
+            }
+        }
+    }
+#endif /* TSOL */
+    WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply);
+    client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+    WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
+    DEALLOCATE_LOCAL(preply);
+    return(client->noClientException);
+}
+
+int
+ProcTsolGetImage(client)
+    register ClientPtr	client;
+{
+    REQUEST(xGetImageReq);
+
+    REQUEST_SIZE_MATCH(xGetImageReq);
+
+    return DoGetImage(client, stuff->format, stuff->drawable,
+		      stuff->x, stuff->y,
+		      (int)stuff->width, (int)stuff->height,
+		      stuff->planeMask, (xGetImageReply **)NULL);
+}
+
+int
+ProcTsolQueryTree(client)
+    register ClientPtr client;
+{
+    xQueryTreeReply reply;
+    int numChildren = 0;
+    register WindowPtr pChild, pWin, pHead;
+    Window  *childIDs = (Window *)NULL;
+#if defined(PANORAMIX) && !defined(IN_MODULE)
+    PanoramiXWindow     *pPanoramiXWin = PanoramiXWinRoot;
+    int         j, thisScreen;
+#endif
+
+#ifdef TSOL
+    TsolInfoPtr  tsolinfo = GetClientTsolInfo(client);
+#endif  /* TSOL */
+
+    REQUEST(xResourceReq);
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+					   SecurityReadAccess);
+    if (!pWin)
+        return(BadWindow);
+
+#ifdef TSOL
+    if (xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pWin,
+                     client, TSOL_ALL, (void *)MAJOROP))
+    {
+	    return(BadWindow);
+    }
+    /*
+     * Because of its recursive nature, QuerryTree can leave a huge trail
+     * of audit records which could make deciphering the audit log for
+     * critical records difficult. So we turn off any more auditing of
+     * this protocol.
+     */
+    tsolinfo->flags &= ~TSOL_DOXAUDIT;
+    tsolinfo->flags &= ~TSOL_AUDITEVENT;
+#endif /* TSOL */
+
+    reply.type = X_Reply;
+    reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+    reply.sequenceNumber = client->sequence;
+    if (pWin->parent)
+	reply.parent = pWin->parent->drawable.id;
+    else
+        reply.parent = (Window)None;
+#if defined(SUNSOFT) && defined(PANORAMIX) && !defined(IN_MODULE)
+    if ( !noPanoramiXExtension ) {
+        thisScreen = 0;
+        for (j = 0; j <= PanoramiXNumScreens - 1; j++) {
+          if ( pWin->winSize.extents.x1 <  (panoramiXdataPtr[j].x  + 
+					    panoramiXdataPtr[j].width)) {
+             thisScreen = j;
+             break;
+          }
+        }
+    }
+    if ( !noPanoramiXExtension  && thisScreen ) {
+        PANORAMIXFIND_ID(pPanoramiXWin, pWin->drawable.id);
+        IF_RETURN(!pPanoramiXWin, BadWindow);
+        pWin = 
+	(WindowPtr)SecurityLookupWindow(pPanoramiXWin->info[thisScreen].id,
+		   client,
+                   SecurityReadAccess);
+        if (!pWin)
+            return(BadWindow);
+        pHead = RealChildHead(pWin);
+        for(pChild = pWin->lastChild;pChild != pHead; pChild = pChild->prevSib)
+             numChildren++;
+        if (numChildren)
+        {
+          int curChild = 0;
+          childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
+          if (!childIDs)
+              return BadAlloc;
+          for (pChild = pWin->lastChild; pChild != pHead; 
+		                       pChild = pChild->prevSib) {
+              pPanoramiXWin = PanoramiXWinRoot;
+              PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, pChild->drawable.id, 
+				         thisScreen);
+              IF_RETURN(!pPanoramiXWin, BadWindow);
+              childIDs[curChild++] = pPanoramiXWin->info[0].id;
+          }
+        } /* numChildren */
+    }else { /* otherwise its screen 0, and nothing changes */
+      pHead = RealChildHead(pWin);
+      for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+#ifdef TSOL
+      {
+		/* error ignored */
+		if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild,
+						  client, TSOL_ALL, (void *)MAJOROP))
+		{
+			numChildren++;
+		}
+      }
+#else /* !TSOL */
+	  numChildren++;
+#endif /* TSOL */
+      if (numChildren)
+      {
+        int curChild = 0;
+
+        childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
+        if (!childIDs)
+            return BadAlloc;
+        for (pChild = pWin->lastChild; pChild != pHead; 
+			pChild = pChild->prevSib)
+#ifdef TSOL
+	{
+
+	    /* error ignored */
+	    if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild,
+                          client, TSOL_ALL, (void *)MAJOROP))
+        {
+	        childIDs[curChild++] = pChild->drawable.id;
+        }
+	}
+#else /* !TSOL */
+	    childIDs[curChild++] = pChild->drawable.id;
+#endif /* TSOL */
+      }
+    }
+#else
+    pHead = RealChildHead(pWin);
+    for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+#ifdef TSOL
+    {
+		/* error ignored */
+		if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild,
+						  client, TSOL_ALL, (void *)MAJOROP))
+		{
+			numChildren++;
+		}
+    }
+#else /* !TSOL */
+	numChildren++;
+#endif /* TSOL */
+    if (numChildren)
+    {
+	int curChild = 0;
+
+	childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
+	if (!childIDs)
+	    return BadAlloc;
+	for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+#ifdef TSOL
+	{
+
+	    /* error ignored */
+	    if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild,
+                          client, TSOL_ALL, (void *)MAJOROP))
+        {
+	        childIDs[curChild++] = pChild->drawable.id;
+        }
+	}
+#else /* !TSOL */
+	    childIDs[curChild++] = pChild->drawable.id;
+#endif /* TSOL */
+    }
+#endif
+    
+    reply.nChildren = numChildren;
+    reply.length = (numChildren * sizeof(Window)) >> 2;
+    
+    WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
+    if (numChildren)
+    {
+    	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+	WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
+	DEALLOCATE_LOCAL(childIDs);
+    }
+
+    return(client->noClientException);
+}
+
+void
+TsolAuditStart(ClientPtr client)
+{
+    extern Bool system_audit_on;
+    unsigned int protocol;
+    int xevent_num;
+    int count = 0;
+    int status = 0;
+    Bool do_x_audit = FALSE;
+    Bool audit_event = FALSE;
+    char audit_ret = (char)NULL;
+    TsolInfoPtr tsolinfo = (TsolInfoPtr)NULL;
+    tsolinfo = GetClientTsolInfo(client);
+    if (system_audit_on &&
+    (tsolinfo->aw_auinfo.ai_mask.am_success ||
+    tsolinfo->aw_auinfo.ai_mask.am_failure))
+    {
+        do_x_audit = TRUE;
+        auditwrite(AW_PRESELECT, &(tsolinfo->aw_auinfo.ai_mask), AW_END);
+    }
+    return;
+            /*
+             * X audit events start from 9101 in audit_uevents.h. The first two
+             * events are non-protocol ones viz. ClientConnect, mapped to 9101
+             * and ClientDisconnect, mapped to 9102.
+             * The protocol events are mapped from 9103 onwards in the serial
+             * order of their respective protocol opcode, for eg, the protocol
+             * UngrabPointer which is has a protocol opcode 27 is mapped to
+             * 9129 (9102 + 27).
+             * All extension protocols are mapped to a single audit event
+             * AUE_XExtension as opcodes are assigined dynamically to these
+             * protocols. We set the extension protocol opcode to be 128, one
+             * more than the last standard opcode.
+             */
+            protocol = (unsigned int)MAJOROP;
+            if (protocol > X_NoOperation)
+            {
+                xevent_num = audit_eventsid[MAX_AUDIT_EVENTS - 1][1];
+                audit_event = TRUE;
+            }
+            else
+            {
+                for (count = 0; count < MAX_AUDIT_EVENTS; count++)
+                {
+                    if (protocol == audit_eventsid[count][0])
+                    {
+                        xevent_num = audit_eventsid[count][1];
+                        audit_event = TRUE;
+                        break;
+                    }
+                }
+            }
+            if (audit_event &&
+                do_x_audit &&
+                (au_preselect(xevent_num,
+                              &(tsolinfo->aw_auinfo.ai_mask),
+                              AU_PRS_BOTH,
+                              AU_PRS_USECACHE) == 1))
+            {
+                tsolinfo->flags |= TSOL_AUDITEVENT;
+                status = auditwrite(AW_EVENTNUM, xevent_num, AW_APPEND, AW_END);
+
+            }
+            else
+            {
+                tsolinfo->flags &= ~TSOL_AUDITEVENT;
+                tsolinfo->flags &= ~TSOL_DOXAUDIT;
+            }
+}
+
+void
+TsolAuditEnd(ClientPtr client, int result)
+{
+    extern Bool system_audit_on;
+    unsigned int protocol;
+    int xevent_num;
+    int count = 0;
+    int status = 0;
+    Bool do_x_audit = FALSE;
+    Bool audit_event = FALSE;
+    char audit_ret = (char)NULL;
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    if (tsolinfo->flags & TSOL_DOXAUDIT)
+    {
+                tsolinfo->flags &= ~TSOL_DOXAUDIT;
+                if (tsolinfo->flags & TSOL_AUDITEVENT)
+                    tsolinfo->flags &= ~TSOL_AUDITEVENT;
+                if (result != Success)
+                    audit_ret = -1;
+                else
+                    audit_ret = 0;
+                auditwrite(AW_RETURN, audit_ret, (u_int)result,
+                           AW_WRITE, AW_END);
+    }
+    else if (tsolinfo->flags & TSOL_AUDITEVENT)
+    {
+        tsolinfo->flags &= ~TSOL_AUDITEVENT;
+        auditwrite(AW_DISCARDRD, -1, AW_END);
+    }
+}
+
+int
+ProcTsolQueryPointer(client)
+    ClientPtr client;
+{
+    xQueryPointerReply rep;
+    WindowPtr pWin, t, ptrWin;
+    REQUEST(xResourceReq);
+    DeviceIntPtr mouse = inputInfo.pointer;
+
+    REQUEST_SIZE_MATCH(xResourceReq);
+    pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess);
+    if (!pWin)
+	return BadWindow;
+
+    ptrWin = TsolPointerWindow();
+    if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, ptrWin,
+	    client, TSOL_ALL, (void *)MAJOROP))
+    	return (*TsolSavedProcVector[X_QueryPointer])(client);
+
+    if (mouse->valuator->motionHintWindow)
+	MaybeStopHint(mouse, client);
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.mask = mouse->button->state | inputInfo.keyboard->key->state;
+    rep.length = 0;
+    rep.root = RootOf(pWin);
+    rep.rootX = 0;
+    rep.rootY = 0;
+    rep.child = None;
+    rep.sameScreen = xTrue;
+    rep.winX = 0;
+    rep.winY = 0;
+
+    WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
+
+    return(Success);    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolutils.c	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,948 @@
+/* Copyright 2006 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.
+ */ 
+
+#pragma ident   "@(#)tsolutils.c 1.9     06/03/07 SMI"
+
+
+#define NEED_EVENTS
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xprotostr.h>
+#include <bsm/auditwrite.h>
+#include <bsm/audit_uevents.h>
+#include <regex.h>
+#include "tsolpriv.h"
+#include "Xproto.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include  "tsolinfo.h"
+#include  "keysym.h"
+#include  "misc.h"
+#include  "inputstr.h"
+#include  "propertyst.h"
+
+#define	MAX_SL_ENTRY	256
+#define	MAX_UID_ENTRY	64
+#define	ALLOCATED	1
+#define	EMPTIED		0
+#define	FamilyTSOL	5
+#define	TSOLUIDlength	4
+
+#define BOXES_OVERLAP(b1, b2) \
+      (!( ((b1)->x2 <= (b2)->x1)  || \
+	( ((b1)->x1 >= (b2)->x2)) || \
+	( ((b1)->y2 <= (b2)->y1)) || \
+	( ((b1)->y1 >= (b2)->y2)) ) )
+
+Bool system_audit_on = FALSE;
+Bool priv_win_colormap = FALSE;
+Bool priv_win_config = FALSE;
+Bool priv_win_devices = FALSE;
+Bool priv_win_dga = FALSE;
+Bool priv_win_fontpath = FALSE;
+TsolInfoPtr dying_tsolinfo = (TsolInfoPtr)NULL;
+ExtensionFlag  extflag = { FALSE, FALSE, FALSE, FALSE, FALSE,
+                           FALSE, FALSE, FALSE, FALSE, FALSE,
+                           FALSE, FALSE, FALSE, FALSE, FALSE,
+                           FALSE, FALSE, FALSE, FALSE, FALSE,
+                           FALSE, FALSE, FALSE, FALSE, FALSE,
+                           FALSE };
+
+/*
+ * The following need to be moved to tsolextension.c
+ * after all references in Xsun is pulled out
+ */
+WindowPtr tpwin = NULL;	   /* only one trusted path window at a time */
+TsolPolyInstInfoRec tsolpolyinstinfo;
+#define TsolMaxPolyNameSize 80
+/*
+ * Use the NodeRec struct in tsolinfo.h. This is referenced
+ * in policy routines. So we had to move it there
+ */
+TsolPolyAtomRec tsolpolyprop = {FALSE, 0, 0, NULL};
+TsolPolyAtomRec tsolpolyseln = {TRUE, 0, 0, NULL};
+
+
+/*
+ * Private indices
+ */
+int tsolClientPrivateIndex = -1;
+int tsolWindowPrivateIndex = -1;
+int tsolPixmapPrivateIndex = -1;
+
+bclear_t SessionHI;	   /* HI Clearance */
+bclear_t SessionLO;	   /* LO Clearance */
+unsigned int StripeHeight = 0;
+uid_t OwnerUID = (uid_t)(-1);
+bslabel_t PublicObjSL;
+
+Atom tsol_lastAtom = None;
+int tsol_nodelength  = 0;
+TsolNodePtr tsol_node = NULL;
+
+/* This structure is used for protocol request ListHosts */
+struct xUIDreply
+{
+	unsigned char	family;
+	unsigned char	pad;
+	unsigned short	length;
+	int		uid;		/* uid type */
+};
+
+struct slentry
+{
+	bslabel_t	senlabel;
+	char		allocated;
+};
+
+static struct slentry sltable[MAX_SL_ENTRY];
+
+/* This table contains list of users who can connect to the server */
+struct uidentry
+{
+	int		userid;		/* uid type */
+	char		allocated;
+};
+
+static struct uidentry uidtable[MAX_UID_ENTRY];
+
+/* Index must match with keywords */
+static char *tsolconfig_keywords[] = {"atom", "property", "selection",
+	"extension", "privilege"};
+
+#define KEYWORDCOUNT sizeof(tsolconfig_keywords)/sizeof(char *)
+
+typedef struct _TsolConfig
+{
+	int count;
+	char **list;
+} TsolConfigRec;
+
+TsolConfigRec tsolconfig[KEYWORDCOUNT] = {
+	{0, NULL},
+	{0, NULL},
+	{0, NULL},
+	{0, NULL},
+	{0, NULL}
+};
+
+#define TSOL_ATOMCOUNT 4
+static char *tsolatomnames[TSOL_ATOMCOUNT] = {
+	"_TSOL_CMWLABEL_CHANGE",
+	"_TSOL_GRABNOTIFY",
+	"_TSOL_CLIENT_TERM",
+	"_TSOL_SEL_AGNT"
+};
+
+#ifdef DEBUG
+/*
+ * selectively enable debugging. upto 32 levels of debugging supported
+ * flags are defined in tsolinfo.h
+ */
+#define	TSOL_ERR_FILE "/tmp/Xsun.err"	/* error log file */
+unsigned long tsoldebug = 0; /* TSOLD_SELECTION; */
+#endif /* DEBUG */
+
+void
+init_TSOL_cached_SL()
+{
+	sltable[0].allocated = ALLOCATED;
+	bsllow (&(sltable[0].senlabel));
+
+	sltable[1].allocated = ALLOCATED;
+	bslhigh(&(sltable[1].senlabel));
+
+}
+
+/* Initialize UID table, this table should at least contains owner UID */
+void
+init_TSOL_uid_table()
+{
+	uidtable[0].allocated = ALLOCATED;
+	uidtable[0].userid    = 0;
+}
+
+/*  Count how many valid entried in the uid table */
+int
+count_uid_table()
+{
+	int i, count = 0;
+
+	/* Search entire table */
+	for (i = 0; i < MAX_UID_ENTRY; i++)
+	{
+		if (uidtable[i].allocated == ALLOCATED)
+			count++;
+	}
+	return (count);
+}
+
+/* return (1); if userid is in the table */
+int
+lookupUID(userid)
+	int userid;
+{
+	int i;
+	for (i = 0; i < MAX_UID_ENTRY; i++)
+	{
+		if (uidtable[i].allocated == ALLOCATED &&
+			uidtable[i].userid == userid)
+		{
+			return (1); /* yes, found it */
+		}
+	}
+	return (0); /* not found */
+}
+
+/* Passed into a pointer to a storage which is used to store UID */
+/* and nUid represents how many UID in the table(returned by count_uid_table) */
+int
+ListUID(uidaddr, nUid)
+	struct xUIDreply 	* uidaddr;
+	int			nUid;
+{
+	int i, j = 0;
+
+	for (i = 0; i < MAX_UID_ENTRY; i++)
+	{
+		if (uidtable[i].allocated == ALLOCATED)
+		{
+			uidaddr[j].family = FamilyTSOL;
+			uidaddr[j].length = TSOLUIDlength;
+			uidaddr[j].uid    = uidtable[i].userid;
+			j++;
+		}
+	}
+	if (nUid != j)
+	{
+		ErrorF("Invalid no. of uid entries? \n");
+		return (0);
+	}
+
+	return (1);
+}
+
+/* add userid into UIDtable  */
+int
+AddUID(userid)
+	int *userid;
+{
+
+	int i = 0;
+
+	/*
+	 * Search entire uidtable, to prevent duplicate uid
+	 * entry in the table
+	 */
+	while (i < MAX_UID_ENTRY)
+	{
+		if ((uidtable[i].allocated == ALLOCATED) &&
+			(uidtable[i].userid == *userid))
+		{
+			/* this uid entry is already in the table; no-op */
+			return (1); /* Success, uid in the table */
+		}
+		i++;
+	}
+
+	i = 0;
+	/*
+	 * If we can find an empty entry, then add this uid
+	 * into the table
+	 */
+	while (i < MAX_UID_ENTRY)
+	{
+		if (uidtable[i].allocated != ALLOCATED)
+		{
+			uidtable[i].allocated = ALLOCATED;
+			uidtable[i].userid = *userid;
+			return (1); /* Success, uid in the table */
+		}
+		i++;
+	}
+
+	/* uidtable overflow */
+	ErrorF("Server problem: Please enlarge the table size of uidtable \n");
+	return (0);
+}
+
+
+/* remove userid from UIDtable */
+int
+RemoveUID(userid)
+	int *userid;
+{
+	int i = 0;
+
+	if (*userid == 0)
+	{
+		ErrorF("\n UID 0 can not be removed from server UID list");
+		return (0);
+	}
+
+	while (i < MAX_UID_ENTRY)
+	{
+		if ((uidtable[i].allocated == ALLOCATED) &&
+			(uidtable[i].userid == *userid))
+		{
+			/* delete this entry in the table */
+			uidtable[i].allocated = EMPTIED;
+			return (1); /* Success, uid in the table */
+
+		}
+		i++;
+	}
+
+	/* no such entry in the table, why delete it? no-op */
+	return (0);
+}
+
+
+
+
+bslabel_t *
+lookupSL_low()
+{
+	return (&(sltable[0].senlabel));
+}
+
+
+bslabel_t *
+lookupSL(slptr)
+bslabel_t *slptr;
+{
+	int i = 0;
+
+	if (slptr == NULL)
+		return (slptr);
+
+	while ((i < MAX_SL_ENTRY) && sltable[i].allocated == ALLOCATED)
+	{
+		if (blequal(slptr, &(sltable[i].senlabel)))
+		{
+			/* found a matching sensitivity label in sltable */
+			return (&(sltable[i].senlabel));
+		}
+		i++;
+	}
+
+	if (i < MAX_SL_ENTRY)
+	{
+		/*
+		 * can't find a matching entry in sltable,
+		 * however, we have empty entry to store this
+		 * new sensitivity label; store it.
+		 */
+		sltable[i].allocated = ALLOCATED;
+		memcpy (&(sltable[i].senlabel), slptr, sizeof (bslabel_t));
+		return (&(sltable[i].senlabel));
+	}
+
+	/*
+	 * no matching entry in sltable, and no room to
+	 * store this new sensitivity label,
+	 * the server needs to recomplie with a larger slabel
+	 */
+
+	ErrorF("Server problem: Please enlarge the table size of sltable \n");
+	return (0);
+}
+
+int
+DoScreenStripeHeight(screen_num)
+	int screen_num;
+{
+	extern char 	*ConnectionInfo;
+	extern int	connBlockScreenStart;
+	int 		i, j;
+	xWindowRoot 	*root;
+	register xDepth *pDepth;
+	ScreenPtr	pScreen;
+
+	root = (xWindowRoot *)(ConnectionInfo + connBlockScreenStart);
+	for (i = 0; i < screen_num; i++)
+	{
+		pDepth = (xDepth *)(root + 1);
+		for (j = 0; j < (int)root->nDepths; j++)
+		{
+			pDepth = (xDepth *)(((char *)(pDepth + 1)) +
+				pDepth->nVisuals * sizeof (xVisualType));
+		}
+		root = (xWindowRoot *) pDepth;
+
+	}
+
+	pScreen = screenInfo.screens[screen_num];
+	root->pixHeight = pScreen->height - StripeHeight;
+
+	/* compute new millimeter height */
+
+	root->mmHeight = (pScreen->mmHeight * root->pixHeight +
+			((int)(pScreen->height)/2))/(int)(pScreen->height);
+
+	return (0);
+}
+void
+init_xtsol()
+{
+    extern Bool system_audit_on;      /* from main.c */
+	extern bslabel_t	PublicObjSL;
+	extern bclear_t SessionHI;	/* HI Clearance */
+	extern bclear_t SessionLO;	/* LO Clearance */
+    int cant_audit = 0;
+
+	bclearhigh(&SessionHI);
+	bclearlow(&SessionLO);
+	bsllow(&PublicObjSL);
+	init_TSOL_cached_SL();
+	init_TSOL_uid_table();
+	set_effective_priv(PRIV_OFF, 1, PRIV_NET_REPLY_EQUAL);
+
+    /* cant_audit = cannot_audit(1); */
+    cant_audit = TRUE;
+
+    if (cant_audit)
+        system_audit_on = FALSE;
+    else
+        system_audit_on = TRUE;
+	auditwrite(AW_QUEUE, XAUDIT_Q_SIZE, AW_END);
+#ifdef DEBUG
+	ErrorF("---------NEW LOG BEGINS HERE----------\n"); /* init the err log file */ 
+#endif /* DEBUG */
+}
+
+/*
+ * Converts keycode to keysym, helper function.
+ * Modelled after Xlib code
+ */
+static KeySym
+KeycodetoKeysym(KeyCode keycode, int col)
+{
+    KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
+    int per = curKeySyms->mapWidth;
+    KeySym *syms = curKeySyms->map;
+    KeySym lsym, usym;
+
+    if ((col < 0) || ((col >= per) && (col > 3)) ||
+	((int)keycode < curKeySyms->minKeyCode) || 
+        ((int)keycode > curKeySyms->maxKeyCode))
+      return NoSymbol;
+
+    syms = &curKeySyms->map[(keycode - curKeySyms->minKeyCode) * 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)) {
+	    if (!(col & 1))
+		return lsym;
+	    else if (usym == lsym)
+		return NoSymbol;
+	    else
+		return usym;
+	}
+    }
+    return syms[col];
+}
+
+/*
+ * Converts keysym to a keycode
+ * Modelled after Xlib code
+ */
+static KeyCode
+KeysymToKeycode(KeySym ks)
+{
+    int i, j;
+    KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
+
+    for (j = 0; j < curKeySyms->mapWidth; j++) {
+	for (i = curKeySyms->minKeyCode; i <= curKeySyms->maxKeyCode; i++) {
+	    if (KeycodetoKeysym((KeyCode) i, j) == ks)
+		return i;
+	}
+    }
+    return 0;
+}
+
+/*
+ * converts a keysym to modifier equivalent mask
+ * Modelled after Xlib
+ */
+static unsigned
+KeysymToModifier(KeySym ks)
+{
+    CARD8 code, mods;
+    KeySym *kmax;
+    KeySym *k;
+    KeySymsPtr keysyms = &inputInfo.keyboard->key->curKeySyms;
+    KeyClassPtr key = inputInfo.keyboard->key;
+
+    kmax = keysyms->map + (keysyms->maxKeyCode - keysyms->minKeyCode + 1) *
+	keysyms->mapWidth;
+    k = keysyms->map;
+    mods = 0;
+    while (k < kmax) {
+        if (*k == ks ) {
+            int j = key->maxKeysPerModifier << 3;
+
+            code = (((k - keysyms->map) / keysyms->mapWidth) + keysyms->minKeyCode);
+
+            while (--j >= 0) {
+                if (code == key->modifierKeyMap[j])
+                    mods |= (1 << (j / key->maxKeysPerModifier));
+            }
+        }
+        k++;
+    }
+    return mods;
+}
+
+/*
+ * Initialize Hot Key keys. On A Sun type 5/6 keyboard
+ * It's Meta(Diamond) + Stop. On a non-Sun keyboard, it's
+ * Alt + Break(Pause) key. Hold down the meta or alt key
+ * press stop or break key.
+ *
+ * NOTE:
+ * Both Left & Right keys for (Meta or Alt) return the
+ * same modifier mask
+ */
+void
+InitHotKey(HotKeyPtr hk)
+{
+	/* Meta + Stop */
+	hk->shift = KeysymToModifier(XK_Meta_L);
+	hk->key = KeysymToKeycode(XK_L1);
+
+	/* Alt + Break/Pause */
+	hk->altshift = KeysymToModifier(XK_Alt_L);
+	hk->altkey = KeysymToKeycode(XK_Break);
+
+	hk->initialized = TRUE;
+}
+void
+UpdateTsolConfig(char *keyword, char *value)
+{
+	int i;
+	int count;
+	char **newlist;
+
+	if (keyword == NULL || value == NULL)
+		return; /* ignore incomplete entries */
+
+	/* find a matching keyword */
+	for (i = 0; i < KEYWORDCOUNT; i++) {
+		if (strcmp(keyword, tsolconfig_keywords[i]) == 0) {
+			break;
+		}
+	}
+
+	/* Invalid keyword */
+	if (i >= KEYWORDCOUNT) {
+		ErrorF("Invalid keyword : %s\n", keyword);
+		return;
+	}
+
+	count = tsolconfig[i].count;
+	newlist = (char **)Xrealloc(tsolconfig[i].list, (count + 1) * sizeof(char **));
+	if (newlist == NULL) {
+		ErrorF("Not enough memory for %s %s\n", keyword, value);
+		return;
+	}
+
+	newlist[count] = strdup(value);
+	tsolconfig[i].list = newlist;
+	tsolconfig[i].count++;
+}
+
+void
+InitPrivileges()
+{
+	int i;
+	int count;
+	char **list;
+
+	count = tsolconfig[TSOL_PRIVILEGE].count;
+	list = tsolconfig[TSOL_PRIVILEGE].list;
+
+	for (i = 0; i < count; i++) {
+		if (strcmp(list[i], PRIV_WIN_COLORMAP) == 0)
+			priv_win_colormap = TRUE;
+		else if (strcmp(list[i], PRIV_WIN_CONFIG) == 0)
+			priv_win_config = TRUE;
+		else if (strcmp(list[i], PRIV_WIN_DEVICES) == 0)
+			priv_win_devices = TRUE;
+		else if (strcmp(list[i], PRIV_WIN_FONTPATH) == 0)
+			priv_win_fontpath = TRUE;
+		else if (strcmp(list[i], PRIV_WIN_DGA) == 0)
+			priv_win_dga = TRUE;
+	}
+}
+
+/*
+ * Load Trusted Solaris configuration file
+ * TBD: Process extension keywords
+ */
+void
+LoadTsolConfig()
+{
+	FILE *fp;
+	char buf[BUFSIZ];
+	char *keyword;
+	char *value;
+
+	/* open the file from /etc first followed by /usr */
+	if ((fp = fopen(TSOLPOLICYFILE, "r")) == NULL) {
+		ErrorF("Cannot load %s. Some desktop applications may not\n"
+			"work correctly\n", TSOLPOLICYFILE);
+			return;
+	}
+
+	/* Read and parse the config file */
+	while (fgets(buf, sizeof (buf), fp) != NULL) {
+
+		/* ignore all comments, lines starting with white space */
+		if (buf[0] == '#' || isspace((int)buf[0]))
+			continue;
+
+		keyword = strtok(buf, " \t");
+		value = strtok(NULL, " \t\n");
+		UpdateTsolConfig(keyword, value);
+	}
+
+	InitPrivileges();
+}
+
+
+/*
+ *	It does not really tell if this atom is to be polyinstantiated
+ *	or not. Further check should be done to determine this.
+ */
+int
+SpecialName(char *string, int len)
+{
+
+	return (MatchTsolConfig(string, len));
+}
+
+
+void
+MakeTSOLAtoms()
+{
+	int i;
+	char *atomname;
+	Atom a;
+
+	/* Create new TSOL atoms */
+	for (i = 0; i < TSOL_ATOMCOUNT; i++) {
+		if (MakeAtom(tsolatomnames[i], strlen(tsolatomnames[i]), TRUE) == None)
+			AtomError();
+	}
+
+	/* Create atoms defined in config file */
+	for (i = 0; i < tsolconfig[TSOL_ATOM].count; i++) {
+		atomname = tsolconfig[TSOL_ATOM].list[i];
+		if (MakeAtom(atomname, strlen(atomname), TRUE) == None) {
+			AtomError();
+		}
+	}
+}
+
+/*
+ *	Names starting with a slash in selection.atoms and property.atoms
+ *	are treated as regular expressions to be matched against the 
+ *	selection and property names.  They may optionally end with a slash.
+ */
+int
+regexcompare(char *string, int len, char *regexp)
+{
+	int	status;
+	regex_t	compiledregexp;
+	char	*regexpstrp;
+	int	regexpstrlen;
+	char	buffer[BUFSIZ];
+
+	if (regexp[0] == '/' && len < BUFSIZ) {
+		/* Extract regular expression from between slashes */
+		regexpstrp = regexp + 1;
+		regexpstrlen = strlen(regexpstrp);
+		if (regexpstrp[regexpstrlen - 1] == '/')
+			regexpstrp[regexpstrlen - 1] = '\0';
+		/* Compile the regular expression */
+		status = regcomp(&compiledregexp, regexpstrp,
+		    REG_EXTENDED | REG_NOSUB);
+		if (status == 0) {
+			/* Make null-terminated copy of string */
+			memcpy(buffer, string, len);
+			buffer[len] = '\0';
+			/* Compare string to regular expression */
+			status = regexec(&compiledregexp,
+			    buffer, (size_t) 0, NULL, 0);
+			regfree(&compiledregexp);
+
+			if (status == 0)
+				return (TRUE);
+			else
+				return (FALSE);
+		}
+	} else if (strncmp(string, regexp, len) == 0) {
+		return (TRUE);
+	}
+
+	return (FALSE);
+}
+
+int
+MatchTsolConfig(char *name, int len)
+{
+	int i;
+	int count;
+	char **list;
+	unsigned int flags = 0;
+
+	count = tsolconfig[TSOL_PROPERTY].count;
+	list = tsolconfig[TSOL_PROPERTY].list;
+	for (i = 0; i < count; i++) {
+		if (regexcompare(name, len, list[i])) {
+			flags |= TSOLM_PROPERTY;
+			break;
+		}
+	}
+
+	count = tsolconfig[TSOL_SELECTION].count;
+	list = tsolconfig[TSOL_SELECTION].list;
+	for (i = 0; i < count; i++) {
+		if (regexcompare(name, len, list[i])) {
+			flags |= TSOLM_SELECTION;
+			break;
+		}
+	}
+
+	return (flags);
+}
+
+TsolInfoPtr
+GetClientTsolInfo(client)
+    ClientPtr client;
+{
+	return	(TsolInfoPtr)(client->devPrivates[tsolClientPrivateIndex].ptr);
+}
+
+/* Property is polyinstantiated only on root window */
+int
+PolyProperty(Atom atom, WindowPtr pWin)
+{
+	if (WindowIsRoot(pWin) && 
+		((!tsolpolyprop.polyinst && !(tsol_node[atom].IsSpecial & TSOLM_PROPERTY)) || 
+		(tsolpolyprop.polyinst && (tsol_node[atom].IsSpecial & TSOLM_PROPERTY))))
+		return TRUE;
+	return FALSE;
+}
+
+int
+PolySelection(Atom atom)
+{
+	if ((tsolpolyseln.polyinst && (tsol_node[atom].IsSpecial & TSOLM_SELECTION)) || 
+		(!tsolpolyseln.polyinst && !(tsol_node[atom].IsSpecial & TSOLM_SELECTION)))
+		return TRUE;
+	return FALSE;
+}
+
+/*
+ * Returns true if  a matching sl.uid pair found. Must be applied
+ * only to polyprops.
+ */
+int
+PolyPropReadable(PropertyPtr pProp, ClientPtr client)
+{
+    TsolPropPtr tsolprop = (TsolPropPtr)(pProp->secPrivate);
+    TsolInfoPtr tsolinfo = GetClientTsolInfo(client);
+
+    while (tsolprop)
+    {
+        if (tsolpolyinstinfo.enabled)
+        {
+           if (tsolprop->uid == tsolpolyinstinfo.uid &&
+               tsolprop->sl == tsolpolyinstinfo.sl)
+               return TRUE;
+        }
+        else
+        {
+            if (tsolprop->uid == tsolinfo->uid &&
+                tsolprop->sl == tsolinfo->sl)
+                return TRUE;
+        }
+        tsolprop = tsolprop->next;
+    }
+    return FALSE;
+}
+
+/*
+ * client_private returns true if xid is owned/created by
+ * client or is a default server xid
+ */
+int  
+client_private (ClientPtr client, XID xid)
+{
+	if (same_client(client, xid) || (xid & SERVER_BIT))
+		return TRUE;
+	else
+		return FALSE;
+}
+/*
+ * Same as TopClientWin()
+ * except that it returns a Window ID
+ * and not a ptr
+ */
+Window
+RootOfClient(WindowPtr pWin)
+{
+    if (pWin)
+    {
+	return (TopClientWin(pWin)->drawable.id);
+    }
+    return (NULL);
+}
+/*
+ * Return root window of pWin
+ */
+WindowPtr
+RootWin(WindowPtr pWin)
+{
+    if (pWin)
+    {
+        while (pWin->parent)
+            pWin = pWin->parent;
+    }
+    return (pWin);
+}
+Window
+RootOf(WindowPtr pWin)
+{
+    if (pWin)
+    {
+        while (pWin->parent)
+            pWin = pWin->parent;
+        return (pWin->drawable.id);
+    }
+    return (NULL);
+}
+	
+#define SameClient(xid,client) \
+	(CLIENT_BITS(xid) == (client)->clientAsMask)
+
+/*
+ * same_client returns true if xid is owned/created by
+ * client
+ */
+int  
+same_client (ClientPtr client, XID xid)
+{
+	TsolInfoPtr tsolinfo_client;
+	TsolInfoPtr tsolinfo_xid;
+	ClientPtr   xid_client;
+
+	if (CLIENT_ID(xid) == 0 || (clients[CLIENT_ID(xid)] == NULL))
+		return FALSE;
+
+	if((SERVER_BIT & xid) == 0)
+	{
+		if (client->index == CLIENT_ID(xid))
+			return TRUE;
+		xid_client = clients[CLIENT_ID(xid)];
+		tsolinfo_client = GetClientTsolInfo(client);
+		tsolinfo_xid = GetClientTsolInfo(xid_client);
+		if (tsolinfo_client && tsolinfo_xid && tsolinfo_client->pid > 0)
+		{
+			if (tsolinfo_client->pid == tsolinfo_xid->pid)
+				return TRUE;
+		}
+	}
+        return FALSE;
+}
+WindowPtr
+AnyWindowOverlapsJustMe(pWin, pHead, box)
+    WindowPtr pWin, pHead;
+    register BoxPtr box;
+{
+    register WindowPtr pSib;
+    BoxRec sboxrec;
+    register BoxPtr sbox;
+    TsolResPtr win_res =
+        (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr);
+
+    for (pSib = pWin->prevSib; (pSib != NULL && pSib != pHead); pSib = pSib->prevSib)
+    {
+        TsolResPtr sib_res =
+            (TsolResPtr)(pSib->devPrivates[tsolWindowPrivateIndex].ptr);
+        if (pSib->mapped && !bldominates(win_res->sl, sib_res->sl))
+        {
+            sbox = WindowExtents(pSib, &sboxrec);
+            if (BOXES_OVERLAP(sbox, box)
+#ifdef SHAPE
+                && ShapeOverlap (pWin, box, pSib, sbox)
+#endif
+                )
+                return(pSib);
+        }
+    }
+    return((WindowPtr)NULL);
+}
+/*
+ * Return Top level client window of pWin
+ */
+WindowPtr
+TopClientWin(WindowPtr pWin)
+{
+    ClientPtr client;
+
+    if (pWin)
+    {
+	client = wClient(pWin);
+        while (pWin->parent)
+	{
+	    if (client != wClient(pWin->parent))
+		break;
+            pWin = pWin->parent;
+        }
+    }
+    return (pWin);
+}
+/*
+ * returns the window under pointer. This is function because
+ * sprite is static & TsolPointerWindow is called in policy functions.
+ */
+WindowPtr
+TsolPointerWindow()
+{
+	return (GetSpriteWindow());	/* Window currently under mouse */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/glxgears/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,48 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/openwin/lib -L$(BUILDLIBDIR) -R/usr/X11/lib
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-mesa -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
+/* Lie and say we built GL libraries on SPARC, even though we didn't	*/
+/* since Sun OpenGL provides them 					*/
+#ifdef sparc
+# define BuildGLXLibrary YES
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/glxinfo/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/openwin/lib -L$(BUILDLIBDIR) -R/usr/X11/lib
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-mesa -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
+/* Lie and say we built libGL & libGLU on SPARC, even though we didn't	*/
+/* since Sun OpenGL provides them 					*/
+#ifdef sparc
+# define BuildGLXLibrary YES
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,44 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.3     05/11/08 SMI"
+XCOMM
+
+/* Lie and say we built GL libraries on SPARC, even though we didn't	*/
+/* since Sun OpenGL provides them, so that glxgears & glxinfo build	*/
+#ifdef sparc
+# define BuildGLXLibrary YES
+#endif
+
+#ifdef __sparcv9
+XCOMM Make sure we always have at least one SUBDIR to build
+XSSRCDIR = x11perf
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xgamma/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,42 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/openwin/lib -L$(BUILDLIBDIR) -R/usr/X11/lib
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-client-programs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/compat/japan	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+// $Xorg: japan,v 1.3 2000/08/17 19:54:34 cpqbld Exp $
+
+// Japanese keyboards need Eisu and Kana shift and 
+// lock keys, which are typically bound to the
+// second shift level for some other modifier key.
+// These interpretations disable the default
+// interpretation (which would have these keys set
+// the same modifier as the level one symbol).
+
+default partial xkb_compatibility "japan"  {
+
+    interpret.repeat= False;
+
+    interpret Eisu_Shift+Lock {
+	action= NoAction();
+    };
+
+    interpret Eisu_toggle+Lock {
+	action= NoAction();
+    };
+
+    interpret Kana_Shift+Lock {
+	action= NoAction();
+    };
+
+    interpret Kana_Lock+Lock {
+	action= NoAction();
+    };
+};
+
+// Some Japanese keyboards have an explict Kana Lock key & matching LED
+
+partial xkb_compatibility "kana_lock"  {
+
+    virtual_modifiers Kana_Lock;
+
+    interpret Kana_Lock+AnyOfOrNone(all) {
+        virtualModifier= Kana_Lock;
+        useModMapMods=level1;
+        action= LockGroup(group=+1);
+    };
+
+    indicator "Kana" {
+        !allowExplicit;
+	groups= All-Group1;
+    };
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/compat/mousekeys	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,205 @@
+
+// $Xorg: mousekeys,v 1.3 2000/08/17 19:54:34 cpqbld Exp $
+
+// Interpretations for arrow keys and a bunch of other 
+// common keysyms which make it possible to bind "mouse" 
+// keys using xmodmap and activate or deactivate them 
+// from the keyboard.
+
+default partial xkb_compatibility "mousekeys" {
+
+    // Keypad actions.
+    //
+    interpret.repeat= True;
+
+    interpret KP_1 { 
+	action = MovePtr(x=-1,y= +1); 
+    };
+    interpret KP_End { 
+	action = MovePtr(x=-1,y= +1); 
+    };
+
+    interpret KP_2 { 
+	action = MovePtr(x=+0,y= +1); 
+    };
+    interpret KP_Down { 
+	action = MovePtr(x=+0,y= +1); 
+    };
+
+    interpret KP_3 { 
+	action = MovePtr(x=+1,y=+1); 
+    };
+    interpret KP_Next { 
+ 	action = MovePtr(x=+1,y=+1); 
+    };
+
+    interpret KP_4 { 
+	action = MovePtr(x=-1,y=+0); 
+    };
+    interpret KP_Left { 
+	action = MovePtr(x=-1,y=+0); 
+    };
+
+    interpret KP_6 { 
+	action = MovePtr(x=+1,y=+0); 
+    };
+    interpret KP_Right { 
+ 	action = MovePtr(x=+1,y=+0); 
+    };
+
+    interpret KP_7 { 
+	action = MovePtr(x=-1,y=-1); 
+    };
+    interpret KP_Home { 
+	action = MovePtr(x=-1,y=-1); 
+    };
+
+    interpret KP_8 { 
+	action = MovePtr(x=+0,y=-1); 
+    };
+    interpret KP_Up { 
+	action = MovePtr(x=+0,y=-1); 
+    };
+
+    interpret KP_9 { 
+	action = MovePtr(x=+1,y=-1); 
+    };
+    interpret KP_Prior { 
+	action = MovePtr(x=+1,y=-1); 
+    };
+
+    interpret KP_5 { 
+	action = PointerButton(button=default); 
+    };
+    interpret KP_Begin { 
+	action = PointerButton(button=default); 
+    };
+
+    interpret KP_F2 { 
+	action = SetPtrDflt(affect=defaultButton,button=1); 
+    };
+    interpret KP_Divide { 
+	action = SetPtrDflt(affect=defaultButton,button=1); 
+    };
+
+    interpret KP_F3 { 
+	action = SetPtrDflt(affect=defaultButton,button=2); 
+    };
+    interpret KP_Multiply { 
+	action = SetPtrDflt(affect=defaultButton,button=2); 
+    };
+
+    interpret KP_F4 { 
+	action = SetPtrDflt(affect=defaultButton,button=3); 
+    };
+    interpret KP_Subtract { 
+	action = SetPtrDflt(affect=defaultButton,button=3); 
+    };
+
+    interpret KP_Separator { 
+	action = PointerButton(button=default,count=2); 
+    };
+    interpret KP_Add { 
+	action = PointerButton(button=default,count=2);
+    };
+
+    interpret KP_0 { 
+	action = LockPointerButton(button=default,affect=lock); 
+    };
+    interpret KP_Insert { 
+	action = LockPointerButton(button=default,affect=lock); 
+    };
+
+    interpret KP_Decimal { 
+	action = LockPointerButton(button=default,affect=unlock); 
+    };
+    interpret KP_Delete { 
+	action = LockPointerButton(button=default,affect=unlock); 
+    };
+
+    // Additional mappings for Solaris keypad compatibility
+    interpret F25 { // aka KP_Divide
+	action = SetPtrDflt(affect=defaultButton,button=1); 
+    };
+    interpret F26 { // aka KP_Multiply
+	action = SetPtrDflt(affect=defaultButton,button=2); 
+    };
+    interpret F27 { // aka KP_Home
+	action = MovePtr(x=-1,y=-1); 
+    };
+    interpret F29 { // aka KP_Prior
+	action = MovePtr(x=+1,y=-1); 
+    };
+    interpret F31 { // aka KP_Begin
+	action = PointerButton(button=default); 
+    };
+    interpret F33 { // aka KP_End
+	action = MovePtr(x=-1,y= +1); 
+    };
+    interpret F35 { // aka KP_Next
+ 	action = MovePtr(x=+1,y=+1); 
+    };
+
+    interpret.repeat= False;
+
+
+    // New Keysym Actions.
+    //
+    interpret Pointer_Button_Dflt {
+	action= PointerButton(button=default);
+    };
+    interpret Pointer_Button1 {
+	action= PointerButton(button=1);
+    };
+    interpret Pointer_Button2 {
+	action= PointerButton(button=2);
+    };
+    interpret Pointer_Button3 {
+	action= PointerButton(button=3);
+    };
+    interpret Pointer_DblClick_Dflt {
+	action= PointerButton(button=default,count=2);
+    };
+    interpret Pointer_DblClick1 {
+	action= PointerButton(button=1,count=2);
+    };
+    interpret Pointer_DblClick2 {
+	action= PointerButton(button=2,count=2);
+    };
+    interpret Pointer_DblClick3 {
+	action= PointerButton(button=3,count=2);
+    };
+    interpret Pointer_Drag_Dflt	{
+	action= LockPointerButton(button=default);
+    };
+    interpret Pointer_Drag1 {
+	action= LockPointerButton(button=1);
+    };
+    interpret Pointer_Drag2 {
+	action= LockPointerButton(button=2);
+    };
+    interpret Pointer_Drag3 {
+	action= LockPointerButton(button=3);
+    };
+
+    interpret Pointer_EnableKeys {
+	action= LockControls(controls=MouseKeys);
+    };
+    interpret Pointer_Accelerate {
+	action= LockControls(controls=MouseKeysAccel);
+    };
+    interpret Pointer_DfltBtnNext {
+	action= SetPtrDflt(affect=defaultButton,button= +1);
+    };
+    interpret Pointer_DfltBtnPrev {
+	action= SetPtrDflt(affect=defaultButton,button= -1);
+    };
+
+
+    // Allow an indicator for MouseKeys.
+    indicator "Mouse Keys" {
+//	!allowExplicit;
+	indicatorDrivesKeyboard;
+	controls= MouseKeys;
+    };
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/geometry/sun	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,3056 @@
+// $Xorg: sun,v 1.4 2001/02/09 02:05:51 xorgcvs Exp $
+// $XdotOrg: $
+//
+//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 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.
+//
+// ---------------------------------------------------------------------------
+//
+// $XFree86: xc/programs/xkbcomp/geometry/sun,v 1.7 2003/08/09 14:30:47 pascal Exp $
+//
+xkb_geometry "type4" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type4 US
+    // keyboard.  
+
+    description= "Sun Type4 keyboard";
+
+    width= 452;
+    height= 185;
+
+    shape "EDGE" { cornerRadius= 2, { [ 452, 185 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "DELE" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "RTRN" { 
+	    approx = { [ 0, 0], [28,37] },
+	    { [ 0, 0], [28, 0], [28,37],
+	      [ 5,37], [ 5,19], [ 0,19] },
+	    { [ 1, 1], [26, 1], [26,36],
+	      [ 7,36], [ 7,18], [ 1,18] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 41,18] }, { [2,1], [39,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [170,18] }, { [2,1], [168,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 17;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+
+    section "Alpha" {
+	top= 58;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <FK01>, 9 }, <FK02>, <FK03>, <FK04>,
+		   <FK05>, <FK06>, <FK07>, <FK08>,
+		   <FK09>, <FK10>, <FK11>, <FK12>,
+		   <BKSL>, { <DELE>, "DELE" },
+		 { <PAUS>, 9 }, <PRSC>, <SCLK>, <NMLK>
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <ESC>, 9 }, 
+		   <AE01>, <AE02>, <AE03>, <AE04>, <AE05>, 
+		   <AE06>, <AE07>, <AE08>, <AE09>, <AE10>, 
+		   <AE11>, <AE12>,
+		 { <BKSP>, "BKSP" },
+		 { <KPEQ>, 9 }, <KPDV>, <KPMU>, <KPSU> 
+
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, 
+		 { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>, { <RTRN>, "RTRN" },
+		 { <KP7>, 9 }, <KP8>, <KP9>, { <KPAD>, "KPAD" } 
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, 
+		 { <LCTL>, 9, shape="LCTL" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <TLDE>,
+		 { <KP4>, 33 }, <KP5>, <KP6>
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, 
+		 { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH" }, <LNFD>,
+		 { <KP1>, 9} , <KP2>, <KP3>, { <KPEN>, "KPAD" }
+	    };
+	};
+	row {
+	    top= 96;
+	    keys { { <HELP>, "HELP" }, { <CAPS>, 9 },
+		   <LALT>, <LMTA>, { <SPCE>, "SPCE" },
+		   <RMTA>, <COMP>, <ALGR>,
+		 { <KP0>, 9, shape="KP0" }, <KPDL>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 0, { [  7,  4 ] } };
+    solid "LedPanel" {
+	shape= "LEDS";
+	top=  28;
+	left= 358;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 43;
+    indicator.shape= "LED";
+    indicator "Caps Lock"	{ left= 364; };
+    indicator "Compose"		{ left= 383; };
+    indicator "Scroll Lock"	{ left= 402; };
+    indicator "Num Lock"	{ left= 421; };
+    text.top= 34;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 364; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 380; text="Compose"; };
+    text "ScrollLockLabel"	{ left= 402; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 421; text="Num\nLock"; };
+};
+
+xkb_geometry "type4tuv" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type4 TUV
+    // (European) keyboard with an extra key between the Shift_L
+    // and the Z keys, and two keys above the Bksp key, instead
+    // of a large delete key.
+
+    description= "Sun Type4tuv keyboard";
+
+    width= 452;
+    height= 185;
+
+    shape "EDGE" { cornerRadius= 2, { [ 452, 185 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+
+    shape "RTRN" { 
+	    approx = { [ 0, 0], [28,37] },
+	    { [ 0, 0], [28, 0], [28,37],
+	      [ 5,37], [ 5,19], [ 0,19] },
+	    { [ 1, 1], [26, 1], [26,36],
+	      [ 7,36], [ 7,18], [ 1,18] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [170,18] }, { [2,1], [168,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 17;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+
+    section "Alpha" {
+	top= 58;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <FK01>, 9 }, <FK02>, <FK03>, <FK04>,
+		   <FK05>, <FK06>, <FK07>, <FK08>,
+		   <FK09>, <FK10>, <FK11>, <FK12>,
+		   <BKSL>, <BRCR>,<DELE>,
+		 { <PAUS>, 9 }, <PRSC>, <SCLK>, <NMLK>
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <ESC>, 9 }, 
+		   <AE01>, <AE02>, <AE03>, <AE04>, <AE05>, 
+		   <AE06>, <AE07>, <AE08>, <AE09>, <AE10>, 
+		   <AE11>, <AE12>,
+		 { <BKSP>, "BKSP" },
+		 { <KPEQ>, 9 }, <KPDV>, <KPMU>, <KPSU> 
+
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, 
+		 { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>, { <RTRN>, "RTRN" },
+		 { <KP7>, 9 }, <KP8>, <KP9>, { <KPAD>, "KPAD" } 
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, 
+		 { <LCTL>, 9, shape="LCTL" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <TLDE>,
+		 { <KP4>, 33 }, <KP5>, <KP6>
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, 
+		 { <LFSH>, 9 }, <LSGT>,
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH" }, <LNFD>,
+		 { <KP1>, 9} , <KP2>, <KP3>, { <KPEN>, "KPAD" }
+	    };
+	};
+	row {
+	    top= 96;
+	    keys { { <HELP>, "HELP" }, { <CAPS>, 9 },
+		   <LALT>, <LMTA>, { <SPCE>, "SPCE" },
+		   <RMTA>, <COMP>, <ALGR>,
+		 { <KP0>, 9, shape="KP0" }, <KPDL>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 0, { [  7,  4 ] } };
+    solid "LedPanel" {
+	shape= "LEDS";
+	top=  28;
+	left= 358;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 43;
+    indicator.shape= "LED";
+    indicator "CapsLock"	{ left= 364; };
+    indicator "Compose"	{ left= 383; };
+    indicator "ScrollLock"	{ left= 402; };
+    indicator "NumLock"	{ left= 421; };
+    text.top= 34;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 364; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 380; text="Compose"; };
+    text "ScrollLockLabel"	{ left= 402; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 421; text="Num\nLock"; };
+};
+
+xkb_geometry "type4_ca" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type4
+    // Canadian and British keyboard with an extra key between
+    // the Shift_L 
+    // and the Z keys.
+
+    description= "Sun Type4_uk keyboard";
+
+    width= 452;
+    height= 185;
+
+    shape "EDGE" { cornerRadius= 2, { [ 452, 185 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "DELE" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "RTRN" { 
+            approx = { [ 0, 0], [28,37] },
+            { [ 0, 0], [28, 0], [28,37],
+              [ 5,37], [ 5,19], [ 0,19] },
+            { [ 1, 1], [26, 1], [26,36],
+              [ 7,36], [ 7,18], [ 1,18] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [170,18] }, { [2,1], [168,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+
+    outline "Edges" {
+        top= 0;
+        left= 0;
+        shape= "EDGE";
+    };
+
+    section.left= 17;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+
+    section "Alpha" {
+        top= 58;
+        row {
+            top= 1;
+            keys { <STOP>, <AGAI>,
+                 { <FK01>, 9 }, <FK02>, <FK03>, <FK04>,
+                   <FK05>, <FK06>, <FK07>, <FK08>,
+                   <FK09>, <FK10>, <FK11>, <FK12>,
+                   <BKSL>, { <DELE>, "DELE" },
+                 { <PAUS>, 9 }, <PRSC>, <SCLK>, <NMLK>
+            };
+        };
+        row {
+            top= 20;
+            keys { <PROP>, <UNDO>, { <ESC>, 9 }, 
+                   <AE01>, <AE02>, <AE03>, <AE04>, <AE05>,
+                   <AE06>, <AE07>, <AE08>, <AE09>, <AE10>, 
+                   <AE11>, <AE12>,
+                 { <BKSP>, "BKSP" },
+                 { <KPEQ>, 9 }, <KPDV>, <KPMU>, <KPSU> 
+
+            };
+        };
+        row {
+            top= 39;
+            keys { <FRNT>, <COPY>, 
+                 { <TAB>, 9, shape="TABK" },
+                   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+                   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+                   <AD11>, <AD12>, { <RTRN>, "RTRN" },
+                 { <KP7>, 9 }, <KP8>, <KP9>, { <KPAD>, "KPAD" } 
+            };
+        };
+        row {
+            top= 58;
+            keys { <OPEN>, <PAST>, 
+                 { <LCTL>, 9, shape="LCTL" },
+                   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+                   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+                   <AC11>, <TLDE>,
+                 { <KP4>, 33 }, <KP5>, <KP6>
+            };
+        };
+        row {
+            top= 77;
+            keys { <FIND>, <CUT>, 
+                 { <LFSH>, 9 }, <LSGT>,
+                   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+                   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+                 { <RTSH>, "RTSH" }, <LNFD>,
+                 { <KP1>, 9} , <KP2>, <KP3>, { <KPEN>, "KPAD" }
+            };
+        };
+        row {
+            top= 96;
+            keys { { <HELP>, "HELP" }, { <CAPS>, 9 },
+                   <LALT>, <LMTA>, { <SPCE>, "SPCE" },
+                   <RMTA>, <COMP>, <ALGR>,
+                 { <KP0>, 9, shape="KP0" }, <KPDL>
+            };
+        };
+    }; // End of "Alpha" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 0, { [  7,  4 ] } };
+    solid "LedPanel" {
+        shape= "LEDS";
+        top=  28;
+        left= 358;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 43;
+    indicator.shape= "LED";
+    indicator "CapsLock"        { left= 364; };
+    indicator "Compose" { left= 383; };
+    indicator "ScrollLock"      { left= 402; };
+    indicator "NumLock" { left= 421; };
+    text.top= 34;
+    text.color= "black";
+    text "CapsLockLabel"        { left= 364; text="Caps\nLock"; };
+    text "ComposeLabel"         { left= 380; text="Compose"; };
+    text "ScrollLockLabel"      { left= 402; text="Scroll\nLock"; }
+;
+    text "NumLockLabel"         { left= 421; text="Num\nLock"; };
+};
+
+xkb_geometry "type4jp" {
+
+    // This is an approximate layout for a Japanese Sun Type4
+    // keyboard, based on the European TUV keyboard.  It has two keys
+    // above the Bksp key, instead of a large delete key, but lacks
+    // the extra key between Shift_L and Z.
+
+    description= "Sun Japanese Type4 keyboard";
+
+    width= 452;
+    height= 185;
+
+    shape "EDGE" { cornerRadius= 2, { [ 452, 185 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+
+    shape "RTRN" { 
+	    approx = { [ 0, 0], [28,37] },
+	    { [ 0, 0], [28, 0], [28,37],
+	      [ 5,37], [ 5,19], [ 0,19] },
+	    { [ 1, 1], [26, 1], [26,36],
+	      [ 7,36], [ 7,18], [ 1,18] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [ 97,18] }, { [2,1], [95,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LFSH" { { [ 41,18] }, { [2,1], [39,17] } };
+    shape "KANJ" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "EXEC" { { [ 27,18] }, { [2,1], [25,17] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 17;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+
+    section "Alpha" {
+	top= 58;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <FK01>, 9 }, <FK02>, <FK03>, <FK04>,
+		   <FK05>, <FK06>, <FK07>, <FK08>,
+		   <FK09>, <FK10>, <FK11>, <FK12>,
+		   <BKSL>, <BRCR>,<DELE>,
+		 { <PAUS>, 9 }, <PRSC>, <SCLK>, <NMLK>
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <ESC>, 9 }, 
+		   <AE01>, <AE02>, <AE03>, <AE04>, <AE05>, 
+		   <AE06>, <AE07>, <AE08>, <AE09>, <AE10>, 
+		   <AE11>, <AE12>,
+		 { <BKSP>, "BKSP" },
+		 { <KPEQ>, 9 }, <KPDV>, <KPMU>, <KPSU> 
+
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, 
+		 { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>, { <RTRN>, "RTRN" },
+		 { <KP7>, 9 }, <KP8>, <KP9>, { <KPAD>, "KPAD" } 
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, 
+		 { <LCTL>, 9, shape="LCTL" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <TLDE>,
+		 { <KP4>, 33 }, <KP5>, <KP6>
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, 
+		 { <LFSH>, 9, shape="LFSH" },
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		   <LNFD>, { <RTSH>, "RTSH" },
+		 { <KP1>, 9} , <KP2>, <KP3>, { <KPEN>, "KPAD" }
+	    };
+	};
+	row {
+	    top= 96;
+	    keys { { <HELP>, "HELP" }, { <CAPS>, 9 },
+		   <LALT>, <LMTA>, { <EXEC>, "EXEC"} , { <SPCE>, "SPCE" },
+		   { <KANJ>, "KANJ" }, <HENK>, <RMTA>, <COMP>, <ALGR>,
+		 { <KP0>, 9, shape="KP0" }, <KPDL>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 0, { [  7,  4 ] } };
+    solid "LedPanel" {
+	shape= "LEDS";
+	top=  28;
+	left= 358;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 43;
+    indicator.shape= "LED";
+    indicator "CapsLock"	{ left= 364; };
+    indicator "Compose"	{ left= 383; };
+    indicator "ScrollLock"	{ left= 402; };
+    indicator "NumLock"	{ left= 421; };
+    text.top= 34;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 364; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 380; text="Compose"; };
+    text "ScrollLockLabel"	{ left= 402; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 421; text="Num\nLock"; };
+};
+
+xkb_geometry "t5" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type5
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "BKSL" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 51,18] }, { [2,1], [49,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [156,18] }, { [2,1], [154,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <BKSL>, "BKSL" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>,
+		 { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
+		   <LALT>, <LMTA>,
+		 { <SPCE>, "SPCE" },
+		   <RMTA>, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+};
+
+xkb_geometry "t5tuv" {
+
+    // This is an approximate layout for a TUV/European Sun Type5 keyboard.  
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { 
+        approx = { [ 0, 0], [28,37] },
+        { [ 0, 0], [28, 0], [28,37],
+          [ 5,37], [ 5,18], [ 0,18] },
+        { [ 1, 1], [26, 1], [26,36],
+          [ 7,36], [ 7,17], [ 1,17] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 24,18] }, { [2,1], [22,17] } };
+    shape "RTSH" { { [ 51,18] }, { [2,1], [49,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [157,18] }, { [2,1], [155,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <BKSL>
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, <LSGT>, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
+		   <LALT>, <LMTA>,
+		 { <SPCE>, "SPCE" },
+		   <RMTA>, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+};
+
+
+xkb_geometry "t5jp" {
+
+    // This is an approximate layout for a Japanese Sun Type5 keyboard.
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "KANJ" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "EXEC" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { 
+        approx = { [ 0, 0], [28,37] },
+        { [ 0, 0], [28, 0], [28,37],
+          [ 5,37], [ 5,18], [ 0,18] },
+        { [ 1, 1], [26, 1], [26,36],
+          [ 7,36], [ 7,17], [ 1,17] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [ 97,18] }, { [2,1], [95,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>, 
+		   { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <BKSL>
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, <UNDR>,
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9 },
+		   <LALT>, <LMTA>, { <EXEC>, "EXEC" },
+		 { <SPCE>, "SPCE" }, { <KANJ>, "KANJ" }, <HENK>,
+		   <RMTA>, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+};
+
+xkb_geometry "t5unix" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type5
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "BKSL" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 51,18] }, { [2,1], [49,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [157,18] }, { [2,1], [155,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+    top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <NONE>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <ESC>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		   <BKSL>, <TLDE>
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <BKSP>, "BKSP" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <LCTL>, 9, shape="LCTL" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>,
+		 { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <CAPS>, 9, shape="CAPS" },
+		   <LALT>, <LMTA>,
+		 { <SPCE>, "SPCE" },
+		   <RMTA>, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+};
+
+xkb_geometry "t5hobo" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type5
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+    //
+    // I modified this to look like the hobo keyboard.
+
+    width= 425;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 425, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "FKEY" { { [ 15,18] }, { [0.5,0.5], [14.5, 17.5] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "BKSL" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "RTRN" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [156,18] }, { [2,1], [154,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+    
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "FKEY";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 4 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 4 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 4 }, <FK10>, <FK11>, <FK12>,
+		   { <MUTE>, 4 }, <VOL->, <VOL+>, <POWR>, 
+		   { <PRSC>,  9, "NORM" }, {<SCLK>, "NORM"}, {<PAUS>, "NORM"}
+	    };
+	};
+    }; // End of "Function" section
+
+    key.shape= "NORM";
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <BKSL>, "BKSL" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>,
+		 { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }, <ALGR>
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
+		   <LALT>, <LMTA>,
+		 { <SPCE>, "SPCE" },
+		   <RMTA>, <COMP>, <NMLK>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+};
+
+xkb_geometry "t5tuvhobo" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type5
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+    //
+    // I modified this to look like the hobo keyboard.
+
+    width= 425;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 425, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "FKEY" { { [ 15,18] }, { [0.5,0.5], [14.5, 17.5] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "BKSL" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "RTRN" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 24,18] }, { [2,1], [22,17] } };
+    shape "RTSH" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [156,18] }, { [2,1], [154,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+    
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "FKEY";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 4 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 4 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 4 }, <FK10>, <FK11>, <FK12>,
+		   { <MUTE>, 4 }, <VOL->, <VOL+>, <POWR>, 
+		   { <PRSC>,  9, "NORM" }, {<SCLK>, "NORM"}, {<PAUS>, "NORM"}
+	    };
+	};
+    }; // End of "Function" section
+
+    key.shape= "NORM";
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <BKSL>, "BKSL" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>,
+		 { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, <LSGT>,
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }, <ALGR>
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
+		   <LALT>, <LMTA>,
+		 { <SPCE>, "SPCE" },
+		   <RMTA>, <COMP>, <NMLK>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+};
+
+xkb_geometry "t5jphobo" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type5
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+
+    width= 425;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 425, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "FKEY" { { [ 15,18] }, { [0.5,0.5], [14.5, 17.5] } };
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "KANJ" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "EXEC" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { 
+        approx = { [ 0, 0], [28,37] },
+        { [ 0, 0], [28, 0], [28,37],
+          [ 5,37], [ 5,18], [ 0,18] },
+        { [ 1, 1], [26, 1], [26,36],
+          [ 7,36], [ 7,17], [ 1,17] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [ 97,18] }, { [2,1], [95,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "FKEY";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 4 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 4 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 4 }, <FK10>, <FK11>, <FK12>,
+		   { <MUTE>, 4 }, <VOL->, <VOL+>, <POWR>, 
+		   { <PRSC>,  9, "NORM" }, {<SCLK>, "NORM"}, {<PAUS>, "NORM"}
+	    };
+	};
+    }; // End of "Function" section
+
+    key.shape= "NORM";
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>, 
+		   { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <BKSL>
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, <UNDR>,
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9 },
+		   <LALT>, <LMTA>, { <EXEC>, "EXEC" },
+		 { <SPCE>, "SPCE" }, { <KANJ>, "KANJ" }, <HENK>,
+		   <RMTA>, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+};
+
+xkb_geometry "type5_se" {
+
+    // kbd: type = 4, layout = 43
+
+    description= "Sun Type5 keyboard (Sweden)";
+
+    width=       510;
+    height=      170;
+
+    baseColor=   "grey";
+    labelColor=  "black";
+
+    shape.cornerRadius=	1;
+
+    shape "EDGE" { cornerRadius= 2, { [ 510, 170 ] } };
+    shape "LOGO" { cornerRadius= 2,
+      { [ 0, 8], [ 8, 16], [ 16, 8], [ 8, 0] }
+    };
+
+    shape "NORM" { { [ 18, 18] }, { [ 2, 1], [ 16, 17] } };
+    shape "BKSP" { { [ 38, 18] }, { [ 2, 1], [ 36, 17] } };
+    shape "TABK" { { [ 27, 18] }, { [ 2, 1], [ 25, 17] } };
+    shape "RTRN" { 
+      {	[ 0, 0], [ 29, 0], [ 29, 37], [ 5, 37], [ 5, 18], [ 0, 18] },
+      { [ 2, 1], [ 27, 1], [ 27, 36], [ 7, 36], [ 7, 17], [ 2, 17] }
+    };
+    shape "CAPS" { { [ 32, 18] }, { [ 2, 1], [ 30, 17 ] } };
+    shape "LFSH" { { [ 24, 18] }, { [ 2, 1], [ 22, 17 ] } };
+    shape "RTSH" { { [ 51, 18] }, { [ 2, 1], [ 49, 17 ] } };
+    shape "LCTL" { { [ 32, 18] }, { [ 2, 1], [ 30, 17 ] } };
+    shape "MODK" { { [ 28, 18] }, { [ 2, 1], [ 26, 17 ] } };
+    shape "SPCE" { { [157, 18] }, { [ 2, 1], [155, 17 ] } };
+    shape "KP0"  { { [ 37, 18] }, { [ 2, 1], [ 35, 17 ] } };
+    shape "KPAD" { { [ 18, 37] }, { [ 2, 1], [ 16, 36 ] } };
+    shape "HELP" { { [ 37, 18] }, { [ 2, 1], [ 35, 17 ] } };
+
+    section "Function" {
+        key.color= "grey10";
+        priority=  1;
+        top=       24;
+        left=      14;
+        width=     481;
+        height=    19;
+        row {
+            top=  1;
+            left= 1;
+            keys {
+                { <HELP>, "HELP",   1 }, {  <ESC>, "NORM",   9 },
+                { <FK01>, "NORM",  19 }, { <FK02>, "NORM",   1 },
+                { <FK03>, "NORM",   1 }, { <FK04>, "NORM",   1 },
+                { <FK05>, "NORM",  11 }, { <FK06>, "NORM",   1 },
+                { <FK07>, "NORM",   1 }, { <FK08>, "NORM",   1 },
+                { <FK09>, "NORM",  11 }, { <FK10>, "NORM",   1 },
+                { <FK11>, "NORM",   1 }, { <FK12>, "NORM",   1 },
+                { <PRSC>, "NORM",   9 }, { <SCLK>, "NORM",   1 },
+                { <PAUS>, "NORM",   1 }, { <MUTE>, "NORM",  11 },
+                { <VOL->, "NORM",   1 }, { <VOL+>, "NORM",   1 },
+		{ <POWR>, "NORM",   1, color= "white" }
+            };
+        };
+    }; // End of "Function" section
+
+    section "Alpha" {
+        key.color= "white";
+        priority=  2;
+        top=       61;
+        left=      14;
+        width=     333;
+        height=    95;
+        row {
+            top=  1;
+            left= 1;
+            keys {
+                { <STOP>, "NORM",   1, color= "grey10" },
+		{ <AGAI>, "NORM",   1, color= "grey10" },
+                { <TLDE>, "NORM",   9 }, { <AE01>, "NORM",   1 },
+                { <AE02>, "NORM",   1 }, { <AE03>, "NORM",   1 },
+                { <AE04>, "NORM",   1 }, { <AE05>, "NORM",   1 },
+                { <AE06>, "NORM",   1 }, { <AE07>, "NORM",   1 },
+                { <AE08>, "NORM",   1 }, { <AE09>, "NORM",   1 },
+                { <AE10>, "NORM",   1 }, { <AE11>, "NORM",   1 },
+                { <AE12>, "NORM",   1 },
+                { <BKSP>, "BKSP",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  20;
+            left= 1;
+            keys {
+                { <PROP>, "NORM",   1, color= "grey10" },
+		{ <UNDO>, "NORM",   1, color= "grey10" },
+                {  <TAB>, "TABK",   9, color= "grey10" },
+		{ <AD01>, "NORM",   1 },
+                { <AD02>, "NORM",   1 }, { <AD03>, "NORM",   1 },
+                { <AD04>, "NORM",   1 }, { <AD05>, "NORM",   1 },
+                { <AD06>, "NORM",   1 }, { <AD07>, "NORM",   1 },
+                { <AD08>, "NORM",   1 }, { <AD09>, "NORM",   1 },
+                { <AD10>, "NORM",   1 }, { <AD11>, "NORM",   1 },
+                { <AD12>, "NORM",   1 },
+		{ <RTRN>, "RTRN",   1, color= "grey10" }
+            };
+        };
+        row {
+            top=  39;
+            left= 1;
+            keys {
+                { <FRNT>, "NORM",   1, color= "grey10" },
+		{ <COPY>, "NORM",   1, color= "grey10" },
+                { <CAPS>, "CAPS",   9, color= "grey10" }, 
+	        { <AC01>, "NORM",   1 },
+                { <AC02>, "NORM",   1 }, { <AC03>, "NORM",   1 },
+                { <AC04>, "NORM",   1 }, { <AC05>, "NORM",   1 },
+                { <AC06>, "NORM",   1 }, { <AC07>, "NORM",   1 },
+                { <AC08>, "NORM",   1 }, { <AC09>, "NORM",   1 },
+                { <AC10>, "NORM",   1 }, { <AC11>, "NORM",   1 },
+		{ <AC12>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  58;
+            left= 1;
+            keys {
+                { <OPEN>, "NORM",   1, color= "grey10" },
+		{ <PAST>, "NORM",   1, color= "grey10" },
+		{ <LFSH>, "LFSH",   9, color= "grey10" },
+		{ <AB00>, "NORM",   1 }, { <AB01>, "NORM",   1 },
+                { <AB02>, "NORM",   1 }, { <AB03>, "NORM",   1 },
+                { <AB04>, "NORM",   1 }, { <AB05>, "NORM",   1 },
+                { <AB06>, "NORM",   1 }, { <AB07>, "NORM",   1 },
+                { <AB08>, "NORM",   1 }, { <AB09>, "NORM",   1 },
+                { <AB10>, "NORM",   1 },
+                { <RTSH>, "RTSH",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  77;
+            left= 1;
+	    key.color= "grey10";
+            keys {
+                { <FIND>, "NORM",   1 }, {  <CUT>, "NORM",   1 },
+                { <LCTL>, "LCTL",   9 }, { <LALT>, "NORM",   1 },
+                { <LMTA>, "NORM",   1 },
+		{ <SPCE>, "SPCE",   1, color= "white" },
+                { <RMTA>, "NORM",   1 }, { <COMP>, "NORM",   1 },
+                { <ALGR>, "NORM",   1 }
+            };
+        };
+    }; // End of "Alpha" section
+
+    section "Editing" {
+        key.color= "grey10";
+        priority=  3;
+        top=       61;
+        left=      352;
+        width=     58;
+        height=    95;
+        row {
+            top=  1;
+            left= 1;
+            keys {
+                {  <INS>, "NORM",   1 }, { <HOME>, "NORM",   1 },
+                { <PGUP>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  20;
+            left= 1;
+            keys {
+                { <DELE>, "NORM",   1 }, {  <END>, "NORM",   1 },
+                { <PGDN>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  58;
+            left= 20;
+            keys {
+                {   <UP>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  77;
+            left= 1;
+            keys {
+                { <LEFT>, "NORM",   1 }, { <DOWN>, "NORM",   1 },
+                { <RGHT>, "NORM",   1 }
+            };
+        };
+    }; // End of "Editing" section
+
+    section "Keypad" {
+        key.color= "white";
+        priority=  4;
+        top=       61;
+        left=      420;
+        width=     77;
+        height=    95;
+        row {
+            top=  1;
+            left= 1;
+	    key.color= "grey10";
+            keys {
+                { <NMLK>, "NORM",   1 }, { <KPDV>, "NORM",   1 },
+                { <KPMU>, "NORM",   1 }, { <KPSU>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  20;
+            left= 1;
+            keys {
+                {  <KP7>, "NORM",   1 }, {  <KP8>, "NORM",   1 },
+                {  <KP9>, "NORM",   1 },
+                { <KPAD>, "KPAD",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  39;
+            left= 1;
+            keys {
+                {  <KP4>, "NORM",   1 }, {  <KP5>, "NORM",   1 },
+                {  <KP6>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  58;
+            left= 1;
+            keys {
+                {  <KP1>, "NORM",   1 }, {  <KP2>, "NORM",   1 },
+                {  <KP3>, "NORM",   1 },
+                { <KPEN>, "KPAD",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  77;
+            left= 1;
+            keys {
+                {  <KP0>, "KP0",   1 }, { <KPDL>, "NORM",   1 }
+            };
+        };
+    }; // End of "Keypad" section
+
+    outline "Edges" {
+        top=      0;
+        left=     0;
+        priority= 0;
+        shape= "EDGE";
+    };
+
+    solid "Logos" {
+      color= "blue";
+      top=	5;
+      left=	25;
+      priority=	0;
+      shape= "LOGO";
+    };
+    
+    logo "SUNLogoImage" {
+      top=	5;
+      left=	25;
+      name= "SUN";
+      priority=	1;
+      shape= "LOGO";
+    };
+
+    shape "LED" { cornerRadius= 1,
+      { [ 0, 1.5], [ 1.5, 3], [ 3, 1.5], [ 1.5, 0] }
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.shape= "LED";
+    indicator "Caps Lock" { left= 75; top= 103; priority= 5; };
+    indicator "Compose"	  { left= 314; top= 142; priority= 5; };
+    indicator "Scroll Lock" { left= 378; top= 29; };
+    indicator "Num Lock"  { left= 426; top= 66; };
+};
+
+xkb_geometry "type5c_se" {
+
+    // kbd: type = 4, layout = 43
+
+    description= "Sun Type5c keyboard (Sweden)";
+
+    width=       510;
+    height=      170;
+
+    baseColor=   "grey";
+    labelColor=  "black";
+
+    shape.cornerRadius=	1;
+
+    shape "EDGE" { cornerRadius= 2, { [ 510, 170 ] } };
+    shape "LOGO" { cornerRadius= 2,
+      { [ 0, 8], [ 8, 16], [ 16, 8], [ 8, 0] }
+    };
+
+    shape "NORM" { { [ 18, 18] }, { [ 2, 1], [ 16, 17] } };
+    shape "BKSP" { { [ 38, 18] }, { [ 2, 1], [ 36, 17] } };
+    shape "TABK" { { [ 27, 18] }, { [ 2, 1], [ 25, 17] } };
+    shape "META" { { [ 27, 18] }, { [ 2, 1], [ 25, 17] } };
+    shape "RTRN" { 
+      {	[ 0, 0], [ 29, 0], [ 29, 37], [ 5, 37], [ 5, 18], [ 0, 18] },
+      { [ 2, 1], [ 27, 1], [ 27, 36], [ 7, 36], [ 7, 17], [ 2, 17] }
+    };
+    shape "CAPS" { { [ 32, 18] }, { [ 2, 1], [ 30, 17 ] } };
+    shape "LFSH" { { [ 24, 18] }, { [ 2, 1], [ 22, 17 ] } };
+    shape "RTSH" { { [ 51, 18] }, { [ 2, 1], [ 49, 17 ] } };
+    shape "LCTL" { { [ 32, 18] }, { [ 2, 1], [ 30, 17 ] } };
+    shape "MODK" { { [ 28, 18] }, { [ 2, 1], [ 26, 17 ] } };
+    shape "SPCE" { { [139, 18] }, { [ 2, 1], [137, 17 ] } };
+    shape "KP0"  { { [ 37, 18] }, { [ 2, 1], [ 35, 17 ] } };
+    shape "KPAD" { { [ 18, 37] }, { [ 2, 1], [ 16, 36 ] } };
+    shape "HELP" { { [ 37, 18] }, { [ 2, 1], [ 35, 17 ] } };
+
+    section "Function" {
+        key.color= "grey10";
+        priority=  1;
+        top=       24;
+        left=      14;
+        width=     481;
+        height=    19;
+        row {
+            top=  1;
+            left= 1;
+            keys {
+                { <HELP>, "HELP",   1 }, {  <ESC>, "NORM",   9 },
+                { <FK01>, "NORM",  19 }, { <FK02>, "NORM",   1 },
+                { <FK03>, "NORM",   1 }, { <FK04>, "NORM",   1 },
+                { <FK05>, "NORM",  11 }, { <FK06>, "NORM",   1 },
+                { <FK07>, "NORM",   1 }, { <FK08>, "NORM",   1 },
+                { <FK09>, "NORM",  11 }, { <FK10>, "NORM",   1 },
+                { <FK11>, "NORM",   1 }, { <FK12>, "NORM",   1 },
+                { <PRSC>, "NORM",   9 }, { <SCLK>, "NORM",   1 },
+                { <PAUS>, "NORM",   1 }, { <MUTE>, "NORM",  11 },
+                { <VOL->, "NORM",   1 }, { <VOL+>, "NORM",   1 },
+		{ <POWR>, "NORM",   1, color= "white" }
+            };
+        };
+    }; // End of "Function" section
+
+    section "Alpha" {
+        key.color= "white";
+        priority=  2;
+        top=       61;
+        left=      14;
+        width=     333;
+        height=    95;
+        row {
+            top=  1;
+            left= 1;
+            keys {
+                { <STOP>, "NORM",   1, color= "grey10" },
+		{ <AGAI>, "NORM",   1, color= "grey10" },
+                { <TLDE>, "NORM",   9 }, { <AE01>, "NORM",   1 },
+                { <AE02>, "NORM",   1 }, { <AE03>, "NORM",   1 },
+                { <AE04>, "NORM",   1 }, { <AE05>, "NORM",   1 },
+                { <AE06>, "NORM",   1 }, { <AE07>, "NORM",   1 },
+                { <AE08>, "NORM",   1 }, { <AE09>, "NORM",   1 },
+                { <AE10>, "NORM",   1 }, { <AE11>, "NORM",   1 },
+                { <AE12>, "NORM",   1 },
+                { <BKSP>, "BKSP",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  20;
+            left= 1;
+            keys {
+                { <PROP>, "NORM",   1, color= "grey10" },
+		{ <UNDO>, "NORM",   1, color= "grey10" },
+                {  <TAB>, "TABK",   9, color= "grey10" },
+		{ <AD01>, "NORM",   1 },
+                { <AD02>, "NORM",   1 }, { <AD03>, "NORM",   1 },
+                { <AD04>, "NORM",   1 }, { <AD05>, "NORM",   1 },
+                { <AD06>, "NORM",   1 }, { <AD07>, "NORM",   1 },
+                { <AD08>, "NORM",   1 }, { <AD09>, "NORM",   1 },
+                { <AD10>, "NORM",   1 }, { <AD11>, "NORM",   1 },
+                { <AD12>, "NORM",   1 },
+		{ <RTRN>, "RTRN",   1, color= "grey10" }
+            };
+        };
+        row {
+            top=  39;
+            left= 1;
+            keys {
+                { <FRNT>, "NORM",   1, color= "grey10" },
+		{ <COPY>, "NORM",   1, color= "grey10" },
+                { <CAPS>, "CAPS",   9, color= "grey10" }, 
+	        { <AC01>, "NORM",   1 },
+                { <AC02>, "NORM",   1 }, { <AC03>, "NORM",   1 },
+                { <AC04>, "NORM",   1 }, { <AC05>, "NORM",   1 },
+                { <AC06>, "NORM",   1 }, { <AC07>, "NORM",   1 },
+                { <AC08>, "NORM",   1 }, { <AC09>, "NORM",   1 },
+                { <AC10>, "NORM",   1 }, { <AC11>, "NORM",   1 },
+		{ <AC12>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  58;
+            left= 1;
+            keys {
+                { <OPEN>, "NORM",   1, color= "grey10" },
+		{ <PAST>, "NORM",   1, color= "grey10" },
+		{ <LFSH>, "LFSH",   9, color= "grey10" },
+		{ <AB00>, "NORM",   1 }, { <AB01>, "NORM",   1 },
+                { <AB02>, "NORM",   1 }, { <AB03>, "NORM",   1 },
+                { <AB04>, "NORM",   1 }, { <AB05>, "NORM",   1 },
+                { <AB06>, "NORM",   1 }, { <AB07>, "NORM",   1 },
+                { <AB08>, "NORM",   1 }, { <AB09>, "NORM",   1 },
+                { <AB10>, "NORM",   1 },
+                { <RTSH>, "RTSH",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  77;
+            left= 1;
+	    key.color= "grey10";
+            keys {
+                { <FIND>, "NORM",   1 }, {  <CUT>, "NORM",   1 },
+                { <LCTL>, "LCTL",   9 }, { <LALT>, "NORM",   1 },
+                { <LMTA>, "META",   1 },
+		{ <SPCE>, "SPCE",   1, color= "white" },
+                { <RMTA>, "META",   1 }, { <COMP>, "NORM",   1 },
+                { <ALGR>, "NORM",   1 }
+            };
+        };
+    }; // End of "Alpha" section
+
+    section "Editing" {
+        key.color= "grey10";
+        priority=  3;
+        top=       61;
+        left=      352;
+        width=     58;
+        height=    95;
+        row {
+            top=  1;
+            left= 1;
+            keys {
+                {  <INS>, "NORM",   1 }, { <HOME>, "NORM",   1 },
+                { <PGUP>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  20;
+            left= 1;
+            keys {
+                { <DELE>, "NORM",   1 }, {  <END>, "NORM",   1 },
+                { <PGDN>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  58;
+            left= 20;
+            keys {
+                {   <UP>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  77;
+            left= 1;
+            keys {
+                { <LEFT>, "NORM",   1 }, { <DOWN>, "NORM",   1 },
+                { <RGHT>, "NORM",   1 }
+            };
+        };
+    }; // End of "Editing" section
+
+    section "Keypad" {
+        key.color= "white";
+        priority=  4;
+        top=       61;
+        left=      420;
+        width=     77;
+        height=    95;
+        row {
+            top=  1;
+            left= 1;
+	    key.color= "grey10";
+            keys {
+                { <NMLK>, "NORM",   1 }, { <KPDV>, "NORM",   1 },
+                { <KPMU>, "NORM",   1 }, { <KPSU>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  20;
+            left= 1;
+            keys {
+                {  <KP7>, "NORM",   1 }, {  <KP8>, "NORM",   1 },
+                {  <KP9>, "NORM",   1 },
+                { <KPAD>, "KPAD",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  39;
+            left= 1;
+            keys {
+                {  <KP4>, "NORM",   1 }, {  <KP5>, "NORM",   1 },
+                {  <KP6>, "NORM",   1 }
+            };
+        };
+        row {
+            top=  58;
+            left= 1;
+            keys {
+                {  <KP1>, "NORM",   1 }, {  <KP2>, "NORM",   1 },
+                {  <KP3>, "NORM",   1 },
+                { <KPEN>, "KPAD",   1, color="grey10" }
+            };
+        };
+        row {
+            top=  77;
+            left= 1;
+            keys {
+                {  <KP0>, "KP0",   1 }, { <KPDL>, "NORM",   1 }
+            };
+        };
+    }; // End of "Keypad" section
+
+    outline "Edges" {
+        top=      0;
+        left=     0;
+        priority= 0;
+        shape= "EDGE";
+    };
+
+    solid "Logos" {
+      color= "blue";
+      top=	5;
+      left=	15;
+      priority=	0;
+      shape= "LOGO";
+    };
+    
+    logo "SUNLogoImage" {
+      top=	5;
+      left=	15;
+      name= "SUN";
+      priority=	1;
+      shape= "LOGO";
+    };
+
+    text.font= "charter";
+    text.weight= "medium";
+    text.slant= "i";
+    text.fontSize= 40;
+    text "SunLogoText" {
+      top=	5;
+      left=    32;
+      color= "blue";
+      text= "Sun";
+    };
+
+    shape "LED" { cornerRadius= 1,
+      { [ 0, 1.5], [ 1.5, 3], [ 3, 1.5], [ 1.5, 0] }
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.shape= "LED";
+    indicator "Caps Lock"   { left= 75; top= 103; priority= 5; };
+    indicator "Compose"     { left= 314; top= 142; priority= 5; };
+    indicator "Scroll Lock" { left= 378; top= 29; };
+    indicator "Num Lock"    { left= 426; top= 66; };
+};
+
+xkb_geometry "type4_se" {
+
+    // kbd: type = 4, layout = 11
+
+    description= "Sun Type4 keyboard (Sweden)";
+    
+
+    width=       453;
+    height=      183;
+
+    baseColor=   "grey";
+    labelColor=  "black";
+
+    shape "EDGE" { cornerRadius= 2, { [ 452, 185 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "DELE" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "RTRN" { 
+	    approx = { [ 0, 0], [28,37] },
+	    { [ 0, 0], [28, 0], [28,37],
+	      [ 5,37], [ 5,19], [ 0,19] },
+	    { [ 1, 1], [26, 1], [26,36],
+	      [ 7,36], [ 7,18], [ 1,18] }
+    };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 22,18] }, { [2,1], [20,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [170,18] }, { [2,1], [168,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 17;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+
+    section "Alpha" {
+	top= 58;
+	row {
+	    top= 1;
+	    key.color=	"grey10";
+	    keys { <STOP>, <AGAI>, { <FK01>, 9 },
+		   <FK02>, <FK03>, <FK04>,
+		   <FK05>, <FK06>, <FK07>, <FK08>,
+		   <FK09>, <FK10>, <FK11>, <FK12>,
+		 { <AF13>, 	color=	"white"},
+		 { <AF14>, 	color=	"white"},
+		   <DELE>, { <PAUS>, 9 },
+		   <PRSC>, <SCLK>, <NMLK>
+	    };
+	};
+	row {
+	    top= 20;
+	    key.color=	"white";
+	    keys {
+		 { <PROP>,	color=	"grey10" },
+		 { <UNDO>,	color=	"grey10" },
+		 {  <ESC>, 9,	color=	"grey10" }, 
+		   <AE01>, <AE02>, <AE03>, <AE04>, <AE05>, 
+		   <AE06>, <AE07>, <AE08>, <AE09>, <AE10>, 
+		   <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", 	color=	"grey10" },
+		 { <KPEQ>, 9, 	color=	"grey10" },
+		 { <KPDV>, 	color=	"grey10" },
+		 { <KPMU>, 	color=	"grey10" },
+		 { <KPSU>, 	color=	"grey10" }
+	    };
+	};
+	row {
+	    top= 39;
+	    key.color=	"white";
+	    keys {
+		 { <FRNT>, 	color=	"grey10" },
+		 { <COPY>,	color=	"grey10" },
+		 {  <TAB>, 9, 	"TABK",	color=	"grey10" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <RTRN>,	"RTRN",	color=	"grey10" },
+		 {  <KP7>, 9, 	color=	"grey10" },
+		 {  <KP8>,  	color=	"grey10" },
+		 {  <KP9>,  	color=	"grey10" },
+		 { <KPAD>,	"KPAD",	color=	"grey10" } 
+	    };
+	};
+	row {
+	    top= 58;
+	    key.color=	"white";
+	    keys {
+		 { <OPEN>, 	color=	"grey10" },
+		 { <PAST>, 	color=	"grey10" },
+		 { <CAPS>, 9,	"LCTL",	color=	"grey10" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <AC12>,
+		 {  <KP4>, 33,	color=	"grey10" },
+		 {  <KP5>,  	color=	"grey10" },
+		 {  <KP6>,  	color=	"grey10" }
+	    };
+	};
+	row {
+	    top= 77;
+	    key.color=	"white";
+	    keys { 
+		 { <FIND>, 	color=	"grey10" },
+		 {  <CUT>, 	color=	"grey10" },
+		 { <LFSH>, 9 ,	"LFSH",	color=	"grey10" },
+		   <AB00>, <AB01>, <AB02>, <AB03>,
+		   <AB04>, <AB05>, <AB06>, <AB07>,
+		   <AB08>, <AB09>, <AB10>,
+		 { <RTSH>, 	"RTSH",	color=	"grey10" },
+		 { <LNFD>,	color=	"grey10" },
+		 {  <KP1>, 9, 	color=	"grey10" },
+		 {  <KP2>,  	color=	"grey10" },
+		 {  <KP3>,  	color=	"grey10" },
+		 { <KPEN>,	"KPAD",	color=	"grey10" }
+	    };
+	};
+	row {
+	    top= 96;
+	    key.color=	"grey10";
+	    keys {
+		 { <HELP>, "HELP" }, { <LCTL>, 9 },
+		   <LALT>, <LMTA>,
+		 { <SPCE>, 	"SPCE",	color=	"white" },
+		   <RMTA>, <COMP>, <ALGR>,
+		 { <KP0>, 9, 	"KP0" }, <KPDL>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    shape "RIDGE" { cornerRadius= 1, { [  0, 1], [  1, 0 ],
+				       [330, 0], [331, 1],
+				       [330, 2], [  1, 2] } };
+    solid "Ridge" {
+	shape=	"RIDGE";
+	top=	48;
+	left=	18;
+    };
+
+    shape "LEDS" { cornerRadius= 1, { [ 75 ,21 ] } };
+    shape "LED"  { cornerRadius= 0, { [  7,  4 ] } };
+    outline "LedPanel" {
+	shape= "LEDS";
+	top=  28;
+	left= 358;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 43;
+    indicator.shape= "LED";
+    indicator "Caps Lock"	{ left= 364; };
+    indicator "Compose"		{ left= 383; };
+    indicator "Scroll Lock"	{ left= 402; };
+    indicator "Num Lock"	{ left= 421; };
+    text.top= 32;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 364; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 380; text="\nCompose"; };
+    text "ScrollLockLabel"	{ left= 402; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 421; text="Num\nLock"; };
+};
+
+xkb_geometry "t6" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type6
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "BKSL" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 51,18] }, { [2,1], [49,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [136,18] }, { [2,1], [134,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "RMTA" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "LMTA" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <BKSL>, "BKSL" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>,
+		 { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
+		   <LALT>, { <LMTA>, "LMTA" },
+		 { <SPCE>, "SPCE" },
+		 { <RMTA>, "RMTA" }, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 2, { [  3,  6 ] } };
+    solid "LedPanel" {
+	shape= "LEDS";
+	top=  1;
+	left= 218;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 10;
+    indicator.shape= "LED";
+    indicator "CapsLock"	{ left= 243; };
+    indicator "Compose"	{ left= 281; };
+    indicator "ScrollLock"	{ left= 262; };
+    indicator "NumLock"	{ left= 224; };
+    text.top= 1;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 243; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 281; text="Compose"; };
+    text "ScrollLockLabel"	{ left= 262; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 224; text="Num\nLock"; };
+
+
+};
+
+xkb_geometry "t6tuv" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type6
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } }; 
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { 
+        approx = { [ 0, 0], [28,37] },
+        { [ 0, 0], [28, 0], [28,37],
+          [ 5,37], [ 5,18], [ 0,18] },
+        { [ 1, 1], [26, 1], [26,36],
+          [ 7,36], [ 7,17], [ 1,17] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 24,18] }, { [2,1], [22,17] } };
+    shape "RTSH" { { [ 51,18] }, { [2,1], [49,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [137,18] }, { [2,1], [135,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "RMTA" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "LMTA" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>, 
+		   { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <BKSL>
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, <LSGT>, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
+		   <LALT>, { <LMTA>, "LMTA" },
+		 { <SPCE>, "SPCE" },
+		 { <RMTA>, "RMTA" }, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 2, { [  3,  6 ] } };
+    solid "LedPanel" {
+	shape= "LEDS";
+	top=  1;
+	left= 218;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 10;
+    indicator.shape= "LED";
+    indicator "CapsLock"	{ left= 243; };
+    indicator "Compose"	{ left= 281; };
+    indicator "ScrollLock"	{ left= 262; };
+    indicator "NumLock"	{ left= 224; };
+    text.top= 1;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 243; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 281; text="Compose"; };
+    text "ScrollLockLabel"	{ left= 262; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 224; text="Num\nLock"; };
+
+};
+
+xkb_geometry "t6jp" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type6
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "KANJ" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "EXEC" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { 
+        approx = { [ 0, 0], [28,37] },
+        { [ 0, 0], [28, 0], [28,37],
+          [ 5,37], [ 5,18], [ 0,18] },
+        { [ 1, 1], [26, 1], [26,36],
+          [ 7,36], [ 7,17], [ 1,17] }
+    };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 33,18] }, { [2,1], [31,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [ 96,18] }, { [2,1], [94,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <ESC>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>, 
+		   { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>, <BKSL>
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, <UNDR>,
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9 },
+		   <LALT>, <LMTA>, { <EXEC>, "EXEC" },
+		 { <SPCE>, "SPCE" }, { <KANJ>, "KANJ" }, <HENK>,
+		   <RMTA>, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 2, { [  3,  6 ] } };
+    solid "LedPanel" {
+	shape= "LEDS";
+	top=  1;
+	left= 218;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 10;
+    indicator.shape= "LED";
+    indicator "CapsLock"	{ left= 243; };
+    indicator "Compose"	{ left= 281; };
+    indicator "ScrollLock"	{ left= 262; };
+    indicator "NumLock"	{ left= 224; };
+    text.top= 1;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 243; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 281; text="Compose"; };
+    text "ScrollLockLabel"	{ left= 262; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 224; text="Num\nLock"; };
+
+};
+
+xkb_geometry "t6unix" {
+
+    // This is an approximate layout for a (US/ASCII) Sun Type6
+    // keyboard.  I just took a similar layout (101 key PC keyboard)
+    // and adjusted the sizes.
+
+    width= 515;
+    height= 170;
+
+    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
+    shape.cornerRadius= 1;
+    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
+    shape "BKSP" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
+    shape "RTRN" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
+    shape "RTSH" { { [ 51,18] }, { [2,1], [49,17] } };
+    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
+    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "SPCE" { { [136,18] }, { [2,1], [134,17] } };
+    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
+    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
+    shape "RMTA" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "LMTA" { { [ 28,18] }, { [2,1], [26,17] } };
+    shape "LOGO" { { [ 16,16] } };
+
+    outline "Edges" {
+	top= 0;
+	left= 0;
+	shape= "EDGE";
+    };
+
+    section.left= 14;
+    row.left= 1;
+    key.shape= "NORM";
+    key.gap=  1;
+    section "Function" {
+	top= 24;
+	row {
+	    top= 1;
+	    keys { { <HELP>, "HELP" }, { <NONE>, 9 },
+		   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
+		   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
+		   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
+		   { <PRSC>,  9 }, <SCLK>, <PAUS>,
+		   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
+	    };
+	};
+    }; // End of "Function" section
+
+    section "Alpha" {
+	top= 61;
+	row {
+	    top= 1;
+	    keys { <STOP>, <AGAI>,
+		 { <ESC>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
+		   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+		   <AE10>, <AE11>, <AE12>,
+		   <BKSL>, <TLDE>
+	    };
+	};
+	row {
+	    top= 20;
+	    keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
+		   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
+		   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
+		   <AD11>, <AD12>,
+		 { <BKSP>, "BKSP", color="grey20" }
+	    };
+	};
+	row {
+	    top= 39;
+	    keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
+		   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
+		   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
+		   <AC11>,
+		 { <RTRN>, "RTRN" }
+	    };
+	};
+	row {
+	    top= 58;
+	    keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
+		   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
+		   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
+		 { <RTSH>, "RTSH", color="grey20" }
+	    };
+	};
+	row {
+	    top= 77;
+	    keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
+		   <LALT>, {<LMTA>, "LMTA"},
+		 { <SPCE>, "SPCE" },
+		   {<RMTA>, "RMTA"}, <COMP>, <ALGR>
+	    };
+	};
+    }; // End of "Alpha" section
+
+    section "Editing" {
+	top= 61;
+	left= 352;
+	row {
+	    top= 1;
+	    keys { <INS>, <HOME>, <PGUP> };
+	};
+	row {
+	    top= 20;
+	    keys { <DELE>, <END>, <PGDN> };
+	};
+	row {
+	    top= 58;
+	    left= 20;
+	    keys { <UP> };
+	};
+	row {
+	    top= 77;
+	    keys { <LEFT>, <DOWN>, <RGHT> };
+	};
+    }; // End of "Editing" section
+
+    section "Keypad" {
+	top= 61;
+	left= 420;
+	row {
+	    top= 1;
+	    keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
+	};
+	row {
+	    top= 20;
+	    keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 39;
+	    keys { <KP4>, <KP5>, <KP6> };
+	};
+	row {
+	    top= 58;
+	    keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
+	};
+	row {
+	    top= 77;
+	    keys { { <KP0>, "KP0" }, <KPDL> };
+	};
+    }; // End of "Keypad" section
+
+    shape "LEDS" { cornerRadius= 0, { [ 78 ,21 ] } };
+    shape "LED"  { cornerRadius= 2, { [  3,  6 ] } };
+    solid "LedPanel" {
+	shape= "LEDS";
+	top=  1;
+	left= 218;
+    };
+    indicator.onColor= "green";
+    indicator.offColor= "green30";
+    indicator.top= 10;
+    indicator.shape= "LED";
+    indicator "CapsLock"	{ left= 243; };
+    indicator "Compose"	{ left= 281; };
+    indicator "ScrollLock"	{ left= 262; };
+    indicator "NumLock"	{ left= 224; };
+    text.top= 1;
+    text.color= "black";
+    text "CapsLockLabel"	{ left= 243; text="Caps\nLock"; };
+    text "ComposeLabel"		{ left= 281; text="Compose"; };
+    text "ScrollLockLabel"	{ left= 262; text="Scroll\nLock"; };
+    text "NumLockLabel"		{ left= 224; text="Num\nLock"; };
+};
+
+xkb_geometry "type5" {
+    include "sun(t5)"
+    description= "Sun Type5 keyboard";
+};
+
+xkb_geometry "type5jp" {
+    include "sun(t5jp)"
+    description= "Sun Type5 Japanese keyboard";
+};
+
+xkb_geometry "type5tuv" {
+    include "sun(t5tuv)"
+    description= "Sun Type5 keyboard";
+};
+
+xkb_geometry "type5euro" {
+    include "sun(t5tuv)"
+    description= "Sun Type5 keyboard";
+};
+
+xkb_geometry "type5unix" {
+    include "sun(t5unix)"
+    description= "Sun Type5 Unix keyboard";
+};
+
+xkb_geometry "type5hobo" {
+    include "sun(t5hobo)"
+    description= "Sun Type5 Hobo keyboard";
+};
+
+xkb_geometry "type5tuvhobo" {
+    include "sun(t5tuvhobo)"
+    description= "Sun Type5 Hobo keyboard";
+};
+
+xkb_geometry "type5jphobo" {
+    include "sun(t5jphobo)"
+    description= "Sun Type5 Japanese Hobo keyboard";
+};
+
+default xkb_geometry "type6" {
+    include "sun(t6)"
+    description= "Sun Type6 keyboard (US, Korea, Taiwan)";
+};
+
+xkb_geometry "type6jp" {
+    include "sun(t6jp)"
+    description= "Sun Type6 Japanese keyboard";
+};
+
+xkb_geometry "type6tuv" {
+    include "sun(t6tuv)"
+    description= "Sun Type6 TUV keyboard";
+};
+
+xkb_geometry "type6unix" {
+    include "sun(t6unix)"
+    description= "Sun Type6 Unix keyboard";
+};
+
+xkb_geometry "x86" {
+    include "pc(pc101)"
+    description= "x86 Style Keyboard";
+};
+
+xkb_geometry "MS_x86" {
+    include "pc(pc104)"
+    description= "x86 104 Key Keyboard";
+};
+
+xkb_geometry "x86tuv" {
+    include "pc(pc102)"
+    description= "x86 European Style Keyboard";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/keycodes/sun	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,931 @@
+// $XdotOrg: $
+// $Xorg: sun,v 1.4 2001/02/09 02:05:52 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 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.
+//
+// ---------------------------------------------------------------------------
+//
+// $XFree86: xc/programs/xkbcomp/keycodes/sun,v 3.6 2003/08/09 14:30:48 pascal Exp $
+//
+
+default xkb_keycodes "type4" {
+
+    minimum= 8;
+    maximum= 132;
+
+    <ESC>  = 36;
+    <AE01> = 37;
+    <AE02> = 38;
+    <AE03> = 39;
+    <AE04> = 40;
+    <AE05> = 41;
+    <AE06> = 42;
+    <AE07> = 43;
+    <AE08> = 44;
+    <AE09> = 45;
+    <AE10> = 46;
+    <AE11> = 47;
+    <AE12> = 48;
+    <TLDE> = 49;
+    <BKSP> = 50;
+
+    <TAB>  = 60;
+    <AD01> = 61;
+    <AD02> = 62;
+    <AD03> = 63;
+    <AD04> = 64;
+    <AD05> = 65;
+    <AD06> = 66;
+    <AD07> = 67;
+    <AD08> = 68;
+    <AD09> = 69;
+    <AD10> = 70;
+    <AD11> = 71;
+    <AD12> = 72;
+    <DELE> = 73;
+
+    <LCTL> = 83;
+    <AC01> = 84;
+    <AC02> = 85;
+    <AC03> = 86;
+    <AC04> = 87;
+    <AC05> = 88;
+    <AC06> = 89;
+    <AC07> = 90;
+    <AC08> = 91;
+    <AC09> = 92;
+    <AC10> = 93;
+    <AC11> = 94;
+    <BKSL> = 95;
+    <RTRN> = 96;
+
+    <LFSH> = 106;
+    <AB01> = 107;
+    <AB02> = 108;
+    <AB03> = 109;
+    <AB04> = 110;
+    <AB05> = 111;
+    <AB06> = 112;
+    <AB07> = 113;
+    <AB08> = 114;
+    <AB09> = 115;
+    <AB10> = 116;
+    <RTSH> = 117;
+    <LNFD> = 118;
+
+    <HELP> = 125;
+    <CAPS> = 126;
+    <LALT> = 26;
+    <LMTA> = 127;
+    <SPCE> = 128;
+    <RMTA> = 129;
+    <COMP> = 74;
+    <ALGR> = 20;
+    alias <RALT> = <ALGR>;
+
+    <FK01> = 12;
+    <FK02> = 13;
+    <FK03> = 15;
+    <FK04> = 17;
+    <FK05> = 19;
+    <FK06> = 21;
+    <FK07> = 23;
+    <FK08> = 24;
+    <FK09> = 25;
+    <FK10> = 14;
+    <FK11> = 16;
+    <FK12> = 18;
+
+    <STOP> = 8;
+    <AGAI> = 10;
+    <PROP> = 32;
+    <UNDO> = 33;
+    <FRNT> = 56;
+    <COPY> = 58;
+    <OPEN> = 79;
+    <PAST> = 80;
+    <FIND> = 102;
+    <CUT>  = 104;
+
+    <PRSC> = 29;
+    <SCLK> = 30;
+    <PAUS> = 28;
+
+    <NMLK> = 105;
+    <KPEQ> = 52;
+    <KPDV> = 53;
+    <KPMU> = 54;
+    <KPSU> = 78;
+
+    <KP7>  = 75;
+    <KP8>  = 76;
+    <KP9>  = 77;
+    <KPAD> = 132;
+
+    <KP4>  = 98;
+    <KP5>  = 99;
+    <KP6>  = 100;
+
+    <KP1>  = 119;
+    <KP2>  = 120;
+    <KP3>  = 121;
+    <KPEN> = 97;
+
+    <KP0>  = 101;
+    <KPDL> = 57;
+    indicator 4 = "Caps Lock";
+    indicator 3 = "Compose";
+    indicator 2 = "Scroll Lock";
+    indicator 1 = "Num Lock";
+};
+
+xkb_keycodes "type5" {
+
+    minimum= 8;
+    maximum= 132;
+
+    <ESC>  = 36;
+    <AE01> = 37;
+    <AE02> = 38;
+    <AE03> = 39;
+    <AE04> = 40;
+    <AE05> = 41;
+    <AE06> = 42;
+    <AE07> = 43;
+    <AE08> = 44;
+    <AE09> = 45;
+    <AE10> = 46;
+    <AE11> = 47;
+    <AE12> = 48;
+    <TLDE> = 49;
+    <BKSP> = 50;
+
+    <TAB>  = 60;
+    <AD01> = 61;
+    <AD02> = 62;
+    <AD03> = 63;
+    <AD04> = 64;
+    <AD05> = 65;
+    <AD06> = 66;
+    <AD07> = 67;
+    <AD08> = 68;
+    <AD09> = 69;
+    <AD10> = 70;
+    <AD11> = 71;
+    <AD12> = 72;
+    <DELE> = 73;
+    <COMP> = 74;
+    <ALGR> = 20;
+    alias <RALT> = <ALGR>;
+
+    <LCTL> = 83;
+    <AC01> = 84;
+    <AC02> = 85;
+    <AC03> = 86;
+    <AC04> = 87;
+    <AC05> = 88;
+    <AC06> = 89;
+    <AC07> = 90;
+    <AC08> = 91;
+    <AC09> = 92;
+    <AC10> = 93;
+    <AC11> = 94;
+    <BKSL> = 95;
+    <RTRN> = 96;
+
+    <LFSH> = 106;
+    <AB01> = 107;
+    <AB02> = 108;
+    <AB03> = 109;
+    <AB04> = 110;
+    <AB05> = 111;
+    <AB06> = 112;
+    <AB07> = 113;
+    <AB08> = 114;
+    <AB09> = 115;
+    <AB10> = 116;
+    <RTSH> = 117;
+
+    <LALT> = 26;
+    <CAPS> = 126;
+    <LMTA> = 127;
+    <SPCE> = 128;
+    <RMTA> = 129;
+
+    <FK01> = 12;
+    <FK02> = 13;
+    <FK03> = 15;
+    <FK04> = 17;
+    <FK05> = 19;
+    <FK06> = 21;
+    <FK07> = 23;
+    <FK08> = 24;
+    <FK09> = 25;
+    <FK10> = 14;
+    <FK11> = 16;
+    <FK12> = 18;
+    <STOP> = 8;
+    <AGAI> = 10;
+    <PROP> = 32;
+    <UNDO> = 33;
+    <FRNT> = 56;
+    <COPY> = 58;
+    <OPEN> = 79;
+    <PAST> = 80;
+    <FIND> = 102;
+    <CUT>  = 104;
+
+    <PRSC> = 29;
+    <SCLK> = 30;
+    <PAUS> = 28;
+
+    <NMLK> = 105;
+    <KPDV> = 53;
+    <KPMU> = 54;
+    <KPSU> = 78;
+
+    <KP7>  = 75;
+    <KP8>  = 76;
+    <KP9>  = 77;
+    <KPAD> = 132;
+
+    <KP4>  = 98;
+    <KP5>  = 99;
+    <KP6>  = 100;
+
+    <KP1>  = 119;
+    <KP2>  = 120;
+    <KP3>  = 121;
+    <KPEN> = 97;
+
+    <KP0>  = 101;
+    <KPDL> = 57;
+
+    <UP>   = 27;
+    <LEFT> = 31;
+    <DOWN> = 34;
+    <RGHT> = 35;
+
+    <INS>  = 51;
+    <HOME> = 59;
+    <END>  = 81;
+    <PGUP> = 103;
+    <PGDN> = 130;
+    <HELP> = 125;
+
+    <MUTE> = 52;
+    <VOL-> = 9;
+    <VOL+> = 11;
+    <POWR> = 55;
+    indicator 4 = "Caps Lock";
+    indicator 3 = "Compose";
+    indicator 2 = "Scroll Lock";
+    indicator 1 = "Num Lock";
+};
+
+xkb_keycodes "type4tuv" {
+    include "sun(type4)"
+    <LSGT> = 131;
+    <BRCR> = 22;
+};
+
+xkb_keycodes "type4_ca" {
+    include "sun(type4)"
+    <LSGT> = 131;
+};
+
+xkb_keycodes "type4_jp" {
+    include "sun(type4)"
+    <EXEC> = 122;
+    <KANJ> = 123;
+    <HENK> = 124;
+    <BRCR> = 22;
+    alias <UNDR> = <LNFD>;
+};
+
+xkb_keycodes "type4_euro" {
+    include "sun(type4)"
+    <LSGT> = 131;
+};
+
+xkb_keycodes "type5tuv" {
+    include "sun(type5)"
+    <LSGT> = 131;
+};
+
+xkb_keycodes "type5_jp" {
+    include "sun(type5)"
+    <EXEC> = 122;
+    <KANJ> = 123;
+    <HENK> = 124;
+    <UNDR> = 118;
+};
+
+xkb_keycodes "type5_euro" {
+    include "sun(type5)"
+    <LSGT> = 131;
+};
+
+xkb_keycodes "type5hobo" {
+
+    minimum= 8;
+    maximum= 132;
+
+    <ESC>  = 36;
+    <AE01> = 37;
+    <AE02> = 38;
+    <AE03> = 39;
+    <AE04> = 40;
+    <AE05> = 41;
+    <AE06> = 42;
+    <AE07> = 43;
+    <AE08> = 44;
+    <AE09> = 45;
+    <AE10> = 46;
+    <AE11> = 47;
+    <AE12> = 48;
+    <TLDE> = 49;
+    <BKSP> = 50;
+
+    <TAB>  = 60;
+    <AD01> = 61;
+    <AD02> = 62;
+    <AD03> = 63;
+    <AD04> = 64;
+    <AD05> = 65;
+    <AD06> = 66;
+    <AD07> = 67;
+    <AD08> = 68;
+    <AD09> = 69;
+    <AD10> = 70;
+    <AD11> = 71;
+    <AD12> = 72;
+    <DELE> = 73;
+    <COMP> = 74;
+    <ALGR> = 20;
+    alias <RALT> = <ALGR>;
+
+    <LCTL> = 83;
+    <AC01> = 84;
+    <AC02> = 85;
+    <AC03> = 86;
+    <AC04> = 87;
+    <AC05> = 88;
+    <AC06> = 89;
+    <AC07> = 90;
+    <AC08> = 91;
+    <AC09> = 92;
+    <AC10> = 93;
+    <AC11> = 94;
+    <BKSL> = 95;
+    <RTRN> = 96;
+
+    <LFSH> = 106;
+    <AB01> = 107;
+    <AB02> = 108;
+    <AB03> = 109;
+    <AB04> = 110;
+    <AB05> = 111;
+    <AB06> = 112;
+    <AB07> = 113;
+    <AB08> = 114;
+    <AB09> = 115;
+    <AB10> = 116;
+    <RTSH> = 117;
+
+    <LALT> = 26;
+    <CAPS> = 126;
+    <LMTA> = 127;
+    <SPCE> = 128;
+    <RMTA> = 129;
+
+    <FK01> = 12;
+    <FK02> = 13;
+    <FK03> = 15;
+    <FK04> = 17;
+    <FK05> = 19;
+    <FK06> = 21;
+    <FK07> = 23;
+    <FK08> = 24;
+    <FK09> = 25;
+    <FK10> = 14;
+    <FK11> = 16;
+    <FK12> = 18;
+    <STOP> = 8;
+    <AGAI> = 10;
+    <PROP> = 32;
+    <UNDO> = 33;
+    <FRNT> = 56;
+    <COPY> = 58;
+    <OPEN> = 79;
+    <PAST> = 80;
+    <FIND> = 102;
+    <CUT>  = 104;
+
+    <PRSC> = 29;
+    <SCLK> = 30;
+    <PAUS> = 28;
+
+    <NMLK> = 105;
+//     <KPDV> = 53;
+//     <KPMU> = 54;
+//     <KPSU> = 78;
+
+//     <KP7>  = 75;
+//     <KP8>  = 76;
+//     <KP9>  = 77;
+//     <KPAD> = 132;
+
+//     <KP4>  = 98;
+//     <KP5>  = 99;
+//     <KP6>  = 100;
+
+//     <KP1>  = 119;
+//     <KP2>  = 120;
+//     <KP3>  = 121;
+//     <KPEN> = 97;
+
+//     <KP0>  = 101;
+//     <KPDL> = 57;
+
+    <UP>   = 27;
+    <LEFT> = 31;
+    <DOWN> = 34;
+    <RGHT> = 35;
+
+    <INS>  = 51;
+    <HOME> = 59;
+    <END>  = 81;
+    <PGUP> = 103;
+    <PGDN> = 130;
+    <HELP> = 125;
+
+    <MUTE> = 52;
+    <VOL-> = 9;
+    <VOL+> = 11;
+    <POWR> = 55;
+    indicator 4 = "Caps Lock";
+    indicator 3 = "Compose";
+    indicator 2 = "Scroll Lock";
+    indicator 1 = "Num Lock";
+};
+
+xkb_keycodes "type5tuvhobo" {
+    include "sun(type5hobo)"
+    <LSGT> = 131;
+
+};
+
+xkb_keycodes "type5_jphobo" {
+    include "sun(type5hobo)"
+    <EXEC> = 122;
+    <KANJ> = 123;
+    <HENK> = 124;
+    <UNDR> = 118;
+};
+
+xkb_keycodes "type6" {
+    include "sun(type5)"
+};
+
+xkb_keycodes "type6tuv" {
+    include "sun(type5tuv)"
+};
+
+xkb_keycodes "type6unix" {
+    include "sun(type5)"
+};
+
+xkb_keycodes "type6_jp" {
+    include "sun(type5_jp)"
+};
+
+xkb_keycodes "type6_euro" {
+    include "sun(type5_euro)"
+};
+
+xkb_keycodes "type6_usb" {
+    include "xfree86"
+    indicator 4 = "Compose";
+};
+
+xkb_keycodes "type6tuv_usb" {
+    include "sun(type6_usb)"
+//    <LSGT> = 94;
+//    <BKSL> = 51;
+};
+
+xkb_keycodes "type6_jp_usb" {
+    include "sun(type6_usb)"
+    alias <UNDR> = <KPDC>;  // 123
+    alias <EXEC> = <I0B>;   // 139 
+    alias <KANJ> = <I0A>;   // 138
+    alias <HENK> = <XFER>;  // 129
+    indicator 5 = "Kana";
+};
+
+xkb_keycodes "type5_se" {
+
+    minimum= 8;
+    maximum= 132;
+
+    // Row G
+    <HELP> = 125;
+    //
+    <ESC>  = 36;
+    //
+    <FK01> = 12;
+    <FK02> = 13;
+    <FK03> = 15;
+    <FK04> = 17;
+    //
+    <FK05> = 19;
+    <FK06> = 21;
+    <FK07> = 23;
+    <FK08> = 24;
+    //
+    <FK09> = 25;
+    <FK10> = 14;
+    <FK11> = 16;
+    <FK12> = 18;
+    //
+    <PRSC> = 29;
+    <SCLK> = 30;
+    <PAUS> = 28;
+    //
+    <MUTE> = 52;
+    <VOL-> = 9;
+    <VOL+> = 11;
+    <POWR> = 55;
+    // End Row G
+
+    // Row F
+    //
+    // End Row F
+
+    // Row E
+    <STOP> = 8;
+    <AGAI> = 10;
+    //
+    <AE00> = 49;
+    alias <TLDE> = <AE00>;
+    <AE01> = 37;
+    <AE02> = 38;
+    <AE03> = 39;
+    <AE04> = 40;
+    <AE05> = 41;
+    <AE06> = 42;
+    <AE07> = 43;
+    <AE08> = 44;
+    <AE09> = 45;
+    <AE10> = 46;
+    <AE11> = 47;
+    <AE12> = 48;
+    <BKSP> = 50;
+    //
+    <INS>  = 51;
+    <HOME> = 59;
+    <PGUP> = 103;
+    //
+    <NMLK> = 105;
+    <KPDV> = 53;
+    <KPMU> = 54;
+    <KPSU> = 78;
+    //End Row E
+
+    // Row D
+    <PROP> = 32;
+    <UNDO> = 33;
+    //
+    <AD00> = 60;
+    alias <TAB> = <AD00>;
+    <AD01> = 61;
+    <AD02> = 62;
+    <AD03> = 63;
+    <AD04> = 64;
+    <AD05> = 65;
+    <AD06> = 66;
+    <AD07> = 67;
+    <AD08> = 68;
+    <AD09> = 69;
+    <AD10> = 70;
+    <AD11> = 71;
+    <AD12> = 72;
+    //
+    <DELE> = 73;
+    <END>  = 81;
+    <PGDN> = 130;
+    //
+    <KP7>  = 75;
+    <KP8>  = 76;
+    <KP9>  = 77;
+    <KPAD> = 132;
+    // End Row D
+
+    // Row C
+    <FRNT> = 56;
+    <COPY> = 58;
+    //
+    <AC00> = 126;
+    alias <CAPS> = <AC00>;
+    <AC01> = 84;
+    <AC02> = 85;
+    <AC03> = 86;
+    <AC04> = 87;
+    <AC05> = 88;
+    <AC06> = 89;
+    <AC07> = 90;
+    <AC08> = 91;
+    <AC09> = 92;
+    <AC10> = 93;
+    <AC11> = 94;
+    <AC12> = 95;
+    alias <BKSL> = <AC12>;
+    <RTRN> = 96;
+    //
+    <KP4>  = 98;
+    <KP5>  = 99;
+    <KP6>  = 100;
+    // End Row C
+
+    // Row B
+    <OPEN> = 79;
+    <PAST> = 80;
+    //
+    <LFSH> = 106;
+    <AB00> = 131;
+    alias <LSGT> = <AB00>;
+    <AB01> = 107;
+    <AB02> = 108;
+    <AB03> = 109;
+    <AB04> = 110;
+    <AB05> = 111;
+    <AB06> = 112;
+    <AB07> = 113;
+    <AB08> = 114;
+    <AB09> = 115;
+    <AB10> = 116;
+    <RTSH> = 117;
+    //
+    <UP>   = 27;
+    //
+    <KP1>  = 119;
+    <KP2>  = 120;
+    <KP3>  = 121;
+    <KPEN> = 97;
+    // End Row B
+
+    // Row A
+    <FIND> = 102;
+    <CUT>  = 104;
+    //
+    <LCTL> = 83;
+    <LALT> = 26;
+    <LMTA> = 127;
+    <SPCE> = 128;
+    <RMTA> = 129;
+    <COMP> = 74;
+    <ALGR> = 20;
+    alias <RALT> = <ALGR>;
+    //
+    <LEFT> = 31;
+    <DOWN> = 34;
+    <RGHT> = 35;
+    //
+    <KP0>  = 101;
+    <KPDL> = 57;
+    // End Row A
+
+    indicator 4 = "Caps Lock";
+    indicator 3 = "Compose";
+    indicator 2 = "Scroll Lock";
+    indicator 1 = "Num Lock";
+};
+
+xkb_keycodes "type5c_se" {
+    include "sun(type5_se)"
+};
+
+xkb_keycodes "type4__se" {
+
+    minimum= 8;
+    maximum= 132;
+
+    // Row F
+    <STOP> = 8;
+    <AGAI> = 10;
+    //
+    <FK01> = 12;
+    <FK02> = 13;
+    <FK03> = 15;
+    <FK04> = 17;
+    <FK05> = 19;
+    <FK06> = 21;
+    <FK07> = 23;
+    <FK08> = 24;
+    <FK09> = 25;
+    <FK10> = 14;
+    <FK11> = 16;
+    <FK12> = 18;
+    <AF13> = 95;
+    alias <TLDE> = <AF13>;
+    <AF14> = 22;
+    <DELE> = 73;
+    //
+    <PAUS> = 28;
+    <PRSC> = 29;
+    <SCLK> = 30;
+    <NMLK> = 105;
+    // End Row F
+
+    // Row E
+    <PROP> = 32;
+    <UNDO> = 33;
+    //
+    <AE00> = 36;
+    alias <ESC> = <AE00>;
+    <AE01> = 37;
+    <AE02> = 38;
+    <AE03> = 39;
+    <AE04> = 40;
+    <AE05> = 41;
+    <AE06> = 42;
+    <AE07> = 43;
+    <AE08> = 44;
+    <AE09> = 45;
+    <AE10> = 46;
+    <AE11> = 47;
+    <AE12> = 48;
+    <BKSP> = 50;
+    //
+    <KPEQ> = 52;
+    <KPDV> = 53;
+    <KPMU> = 54;
+    <KPSU> = 78;
+    // End Row E
+
+    // Row D
+    <FRNT> = 56;
+    <COPY> = 58;
+    //
+    <AD00> = 60;
+    alias <TAB> = <AD00>;
+    <AD01> = 61;
+    <AD02> = 62;
+    <AD03> = 63;
+    <AD04> = 64;
+    <AD05> = 65;
+    <AD06> = 66;
+    <AD07> = 67;
+    <AD08> = 68;
+    <AD09> = 69;
+    <AD10> = 70;
+    <AD11> = 71;
+    <AD12> = 72;
+    //
+    <KP7>  = 75;
+    <KP8>  = 76;
+    <KP9>  = 77;
+    <KPAD> = 132;
+    // End Row D
+
+    // Row C
+    <OPEN> = 79;
+    <PAST> = 80;
+    //
+    <AC00> = 83;
+    //    alias <CAPS> = <AC00>;
+    <AC01> = 84;
+    <AC02> = 85;
+    <AC03> = 86;
+    <AC04> = 87;
+    <AC05> = 88;
+    <AC06> = 89;
+    <AC07> = 90;
+    <AC08> = 91;
+    <AC09> = 92;
+    <AC10> = 93;
+    <AC11> = 94;
+    <AC12> = 49;
+    alias <BKSL> = <AC12>;
+    <RTRN> = 96;
+    //
+    <KP4>  = 98;
+    <KP5>  = 99;
+    <KP6>  = 100;
+    // End Row C
+
+    // Row B
+    <FIND> = 102;
+    <CUT>  = 104;
+    //
+    <LFSH> = 106;
+    <AB00> = 131;
+    alias <LSGT> = <AB00>;
+    <AB01> = 107;
+    <AB02> = 108;
+    <AB03> = 109;
+    <AB04> = 110;
+    <AB05> = 111;
+    <AB06> = 112;
+    <AB07> = 113;
+    <AB08> = 114;
+    <AB09> = 115;
+    <AB10> = 116;
+    <RTSH> = 117;
+    <LNFD> = 118;
+    //
+    <KP1>  = 119;
+    <KP2>  = 120;
+    <KP3>  = 121;
+    <KPEN> = 97;
+    // End Row B
+
+    // Row A
+    <HELP> = 125;
+    //
+    <AA00> = 126;
+    //    alias <LCTL> = <AA00>;
+    <LALT> = 26;
+    <LMTA> = 127;
+    <SPCE> = 128;
+    <RMTA> = 129;
+    <COMP> = 74;
+    <ALGR> = 20;
+    alias <RALT> = <ALGR>;
+    //
+    <KP0>  = 101;
+    <KPDL> = 57;
+    // End Row A
+
+    indicator 4 = "Caps Lock";
+    indicator 3 = "Compose";
+    indicator 2 = "Scroll Lock";
+    indicator 1 = "Num Lock";
+};
+
+xkb_keycodes "type4_se" {
+
+    include "sun(type4__se)"
+
+    alias <LCTL> = <AA00>;
+    alias <CAPS> = <AC00>;
+};
+
+xkb_keycodes "type4_se_swapctl" {
+
+    include "sun(type4__se)"
+
+    alias <LCTL> = <AC00>;
+    alias <CAPS> = <AA00>;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/keymap/sun/all	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1092 @@
+//  x86 KEYBOARDS
+// 
+//  Generally, x86 keyboards fall into either pc101 (101-key) or pc102
+//  (102-key European) categories.  Symbol tables are typically formed by
+//  augmenting sun/us(pc101) or sun/us(pc102) with the "extra" symbols
+//  from the type5 definition.  Geometries and keycodes for many of
+//  these fall under sun(x86) or sun(x86tuv).
+// 
+//  USB KEYBOARDS
+//  
+//  Only the keycodes (scancodes) change in the Universal Serial Bus
+//  keyboard definitions.  Symbols are kept the same as in the type5
+//  case.  The USB HID spec is confusing on this point, but the
+//  scancodes described in it relate to physical keys, not symbols, as
+//  it might lead one to believe.
+//
+//  HOBO KEYBOARDS
+//
+//  Hobo keyboards are derived from type5 keyboards, which in turn,
+//  are all derived from the type5 US keyboard.  Use the
+//  appropriate set of keycodes and geometry (either type5hobo or
+//  type5tuvhobo) and select the symbol set sun/us(type5hobo) to
+//  replace sun/us(type5).  For example, Sweden5_Hobo:
+// 
+// xkb_keymap "Sweden5_Hobo" {
+//     xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+//     xkb_types		{ include "default"		};
+//     xkb_compatibility	{ include "default"		};
+//     xkb_symbols		{ include "sun/us(type5hobo)+sun/se(type5)"};
+//     xkb_geometry	{ include "sun(type5tuvhobo)"	};
+// };
+// 
+//  Doing it this way allows all the symbol changes for a particular
+//  type5 keyboard to hold for a Hobo keyboard; both keyboards, in
+//  this case, would use sun/se(type5) to augment the symbols in the
+//  US keboard definition.
+
+xkb_keymap "Belgian6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+be"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Belgian6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+be"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Canada4" {
+    xkb_keycodes	{ include "sun(type4_ca)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/ca(type4)"	};
+    xkb_geometry	{ include "sun(type4_ca)"	};
+};
+
+xkb_keymap "Canada_Fr5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ca(type5)"};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Canada_Fr5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/ca(type5)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Canada_Fr5_TBITS5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ca(type5tbits5)"};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Canada_Fr_x86" {
+    xkb_keycodes	{ include "sun(x86ca)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc101)+sun/ca(x86)"};
+    xkb_geometry	{ include "sun(x86ca)"		};
+};
+
+xkb_keymap "Switzer_Fr4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/sw(type4fr)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Switzer_Fr5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/sw(type5fr)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Switzer_Fr5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/sw(type5fr)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Switzer_Fr6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/sw(type5fr)"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Switzer_Fr6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/sw(type5fr)"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Switzer_Fr_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/sw(type5fr)"};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Switzer_Ge4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/sw(type4de)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Switzer_Ge5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/sw(type5de)"};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Switzer_Ge5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/sw(type5de)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Switzer_Ge6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/sw(type5de)"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Switzer_Ge6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/sw(type5de)"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Switzer_Ge_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/sw(type5de)"};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Czech5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/cz(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+
+xkb_keymap "Germany4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/de(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Germany5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+de"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Germany5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+de"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Germany6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+de"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Germany6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+de"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Germany_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+de"};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Denmark4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/dk(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Denmark5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/dk(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Denmark5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/dk(type5)"	};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Denmark6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/dk(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Denmark6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/dk(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Denmark_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/dk(type5)"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "SpainLatAm4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/es(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Spain5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/es(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Spain5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/es(type5)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Spain6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/es(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Spain6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/es(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Spain_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/es(type5)"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+
+xkb_keymap "Finnish6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/fi"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Finnish6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/fi"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+
+xkb_keymap "FranceBelg4" {
+    xkb_keycodes	{ include "sun(type4tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/fr(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "France5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/fr(type5)" };
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "France5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/fr(type5)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "France6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/fr(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "France6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/fr(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "France_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/fr(type5)"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Greece5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/gr(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+
+xkb_keymap "Hungary5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5basic)+sun/hu(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+
+xkb_keymap "Italy4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/it(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Italy5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/it(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Italy5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/it(type5)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Italy6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/it(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Italy6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/it(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Italy_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/it(type5)"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Japan4" {
+    xkb_keycodes	{ include "sun(type4_jp)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/jp(type4)"	};
+    xkb_geometry	{ include "sun(type4jp)"	};
+};
+
+xkb_keymap "Japan5" {
+    xkb_keycodes	{ include "sun(type5_jp)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/jp(type5)"	};
+    xkb_geometry	{ include "sun(type5jp)"	};
+};
+
+xkb_keymap "Japan5_Hobo" {
+    xkb_keycodes	{ include "sun(type5_jphobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/jp(type5hobo)"	};
+    xkb_geometry	{ include "sun(type5jphobo)"	};
+};
+
+xkb_keymap "Japan6" {
+    xkb_keycodes	{ include "sun(type6_jp)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default+japan(kana_lock)"	};
+    xkb_symbols		{ include "sun/jp(type6)"	};
+    xkb_geometry	{ include "sun(type6jp)"	};
+};
+
+xkb_keymap "Japan6_usb" {
+    xkb_keycodes	{ include "sun(type6_jp_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default+japan(kana_lock)"	};
+    xkb_symbols		{ include "sun/jp(type6)"	};
+    xkb_geometry	{ include "sun(type6jp)"	};
+};
+
+xkb_keymap "Japan_x86" {
+    xkb_keycodes	{ include "sun(x86jp)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/jp(x86)"		};
+    xkb_geometry	{ include "sun(x86jp)"		};
+};
+
+xkb_keymap "J3100" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/jp(J3100)"		};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Japan_Muhenkan_x86" {
+    xkb_keycodes	{ include "sun(x86jp)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/jp(Muhenkan_x86)"		};
+    xkb_geometry	{ include "sun(x86jp)"		};
+};
+
+xkb_keymap "Korea4" {
+    xkb_keycodes	{ include "sun(type4)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/ko(type4)"	};
+    xkb_geometry	{ include "sun(type4)"		};
+};
+
+xkb_keymap "Korea5" {
+    xkb_keycodes	{ include "sun(type5)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ko(type5)"	};
+    xkb_geometry	{ include "sun(type5)"		};
+};
+
+xkb_keymap "Korea5_Hobo" {
+    xkb_keycodes	{ include "sun(type5hobo)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/ko(type5)"};
+    xkb_geometry	{ include "sun(type5hobo)"		};
+};
+
+xkb_keymap "Korea6" {
+    xkb_keycodes	{ include "sun(type6)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ko(type5)"	};
+    xkb_geometry	{ include "sun(type6)"		};
+};
+
+xkb_keymap "Korea6_usb" {
+    xkb_keycodes	{ include "sun(type6_usb)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ko(type5)"	};
+    xkb_geometry	{ include "sun(type6)"		};
+};
+
+xkb_keymap "Korea_x86" {
+    xkb_keycodes	{ include "sun(x86ko)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc101)+sun/ko(type5)"	};
+    xkb_geometry	{ include "sun(x86ko)"		};
+};
+
+xkb_keymap "Lithuania5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5basic)+sun/lt(type5)" };
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+
+xkb_keymap "Latvia5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5basic)+sun/lv(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "MS_US101A_x86" {
+    xkb_keycodes	{ include "sun(MS_x86)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc104)"		};
+    xkb_geometry	{ include "sun(MS_x86)"		};
+};
+
+xkb_keymap "Netherland4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/nl(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Netherland5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+nl"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Netherland5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+nl"	};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Netherland6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+nl"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Netherland6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+nl"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Netherland_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+nl"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Norway4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/no(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Norway5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/no(type5)"};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Norway5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/no(type5)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Norway6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/no(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Norway6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/no(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Norway_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/no(type5)"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Poland5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/pl"		};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Portugal4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/pt(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Portugal5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/pt(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Portugal5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/pt(type5)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Portugal6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/pt(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Portugal6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/pt(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Portugal_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/pt(type5)"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+// xkb_keymap "Russia4" {
+//     xkb_keycodes	{ include "sun(type4)"		};
+//     xkb_types		{ include "default"		};
+//     xkb_compatibility	{ include "default"		};
+//     xkb_symbols		{ include "sun/ru"		};
+//     xkb_geometry	{ include "sun(type4)"		};
+// };
+
+xkb_keymap "Russia5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ru"};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Russia6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ru"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Russia6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/ru"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "SwedenFin4" {
+    xkb_keycodes	{ include "sun(type4tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/se(type4)"	};
+    xkb_geometry	{ include "sun(type4tuv)"	};
+};
+
+xkb_keymap "Sweden5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/se(type5)"};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Sweden5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/se(type5)"};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "Sweden6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/se(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Sweden6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/se(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Sweden_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+sun/se(type5)"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "Turkey5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tr"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "Turkey6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tr"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "Turkey6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tr"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "TurkeyQ6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tr(type6Q)"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "TurkeyQ6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tr(type6Q)"};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "TurkeyF6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tr(type6F)"};
+    xkb_geometry	{ include "sun(type6)"	};
+};
+
+xkb_keymap "TurkeyF6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tr(type6F)"};
+    xkb_geometry	{ include "sun(type6)"	};
+};
+
+xkb_keymap "Taiwan4" {
+    xkb_keycodes	{ include "sun(type4)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/tw(type4)"	};
+    xkb_geometry	{ include "sun(type4)"	};
+};
+
+xkb_keymap "Taiwan5" {
+    xkb_keycodes	{ include "sun(type5)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tw(type5)"	};
+    xkb_geometry	{ include "sun(type5)"	};
+};
+
+xkb_keymap "Taiwan5_Hobo" {
+    xkb_keycodes	{ include "sun(type5hobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/tw(type5)"	};
+    xkb_geometry	{ include "sun(type5hobo)"	};
+};
+
+xkb_keymap "Taiwan6" {
+    xkb_keycodes	{ include "sun(type6)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tw(type5)"	};
+    xkb_geometry	{ include "sun(type6)"	};
+};
+
+xkb_keymap "Taiwan6_usb" {
+    xkb_keycodes	{ include "sun(type6_usb)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/tw(type5)"	};
+    xkb_geometry	{ include "sun(type6)"	};
+};
+
+xkb_keymap "Taiwan_x86" {
+    xkb_keycodes	{ include "sun(x86)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "us(pc101)"	};
+    xkb_geometry	{ include "sun(x86)"		};
+};
+
+xkb_keymap "UK4" {
+    xkb_keycodes	{ include "sun(type4)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/gb(type4)"	};
+    xkb_geometry	{ include "sun(type4)"		};
+};
+
+xkb_keymap "UK5" {
+    xkb_keycodes	{ include "sun(type5tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5)+sun/gb(type5)"	};
+    xkb_geometry	{ include "sun(type5tuv)"	};
+};
+
+xkb_keymap "UK5_Hobo" {
+    xkb_keycodes	{ include "sun(type5tuvhobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type5hobo)+sun/gb(type5)"	};
+    xkb_geometry	{ include "sun(type5tuvhobo)"	};
+};
+
+xkb_keymap "UK6" {
+    xkb_keycodes	{ include "sun(type6tuv)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type6)+sun/gb(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "UK6_usb" {
+    xkb_keycodes	{ include "sun(type6tuv_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(type6)+sun/gb(type5)"	};
+    xkb_geometry	{ include "sun(type6tuv)"	};
+};
+
+xkb_keymap "UK_x86" {
+    xkb_keycodes	{ include "sun(x86tuv)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc102)+gb"	};
+    xkb_geometry	{ include "sun(x86tuv)"		};
+};
+
+xkb_keymap "US101A_PC" {
+    xkb_keycodes	{ include "sun(type5x86)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc101)+sun/us(pc101currency)"};
+    xkb_geometry	{ include "sun(x86)"		};
+};
+
+xkb_keymap "US101A_Sun" {
+    xkb_keycodes	{ include "sun(type5x86)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "sun/us(pc101)+sun/us(US101A_Sun)"	};
+    xkb_geometry	{ include "sun(x86)"		};
+};
+
+xkb_keymap "US101A_x86" {
+    xkb_keycodes	{ include "sun(x86)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "us(pc101)"		};
+    xkb_geometry	{ include "sun(x86)"		};
+};
+
+xkb_keymap "US4" {
+    xkb_keycodes	{ include "sun(type4)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type4)"	};
+    xkb_geometry	{ include "sun(type4)"		};
+};
+
+xkb_keymap "US5" {
+    xkb_keycodes	{ include "sun(type5)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type5)"	};
+    xkb_geometry	{ include "sun(type5)"		};
+};
+
+xkb_keymap "US5_Hobo" {
+    xkb_keycodes	{ include "sun(type5hobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type5hobo)"	};
+    xkb_geometry	{ include "sun(type5hobo)"	};
+};
+
+xkb_keymap "US_UNIX5" {
+    xkb_keycodes	{ include "sun(type5)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type5)"	};
+    xkb_geometry	{ include "sun(type5unix)"	};
+};
+
+xkb_keymap "US_UNIX5_Hobo" {
+    // Same as US5_Hobo
+    xkb_keycodes	{ include "sun(type5hobo)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type5hobo)"	};
+    xkb_geometry	{ include "sun(type5hobo)"	};
+};
+
+xkb_keymap "US6" {
+    xkb_keycodes	{ include "sun(type6)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type6)"	};
+    xkb_geometry	{ include "sun(type6)"		};
+};
+
+xkb_keymap "US6_usb" {
+    xkb_keycodes	{ include "sun(type6_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type6)"	};
+    xkb_geometry	{ include "sun(type6)"		};
+};
+
+xkb_keymap "US_UNIX6" {
+    xkb_keycodes	{ include "sun(type6)"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type6)"	};
+    xkb_geometry	{ include "sun(type6unix)"	};
+};
+
+xkb_keymap "US_UNIX6_usb" {
+    xkb_keycodes	{ include "sun(type6_usb)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(type6)"	};
+    xkb_geometry	{ include "sun(type6unix)"	};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/keymap/sun/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,37 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localmacros 1.2     05/11/08 SMI"
+XCOMM
+
+EXTRADATAFILES = all
+
+InstallMultiple($(EXTRADATAFILES),$(LIBDIR)/xkb/keymap/sun)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/rules/xorg	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,1063 @@
+// $XdotOrg$
+
+//
+//  Rules for resolving XKB components for use with X
+//  Copyright 1996 by Joseph Moss
+//
+//  2002 Modifier: Ivan Pascal      The XFree86 Project
+//
+//  $XFree86: xc/programs/xkbcomp/rules/xfree86,v 3.79 2004/01/09 00:16:01 dawes Exp $
+//
+// If you want non-latin layouts implicitly include the en_US layout
+// uncomment lines below
+//! $nonlatin = am ara bg by dev el ge il \
+//              ir iu kan lo mk mm ml ori ru sr syr th \
+//              tj ua
+
+// Sun keyboards
+! model			=    keycodes			geometry
+  sun_type4		=    sun(type4)			sun(type4)
+  sun_type4_ca		=    sun(type4_ca)		sun(type4_ca)
+  sun_type4_jp		=    sun(type4_jp)		sun(type4jp)
+  sun_type4_euro	=    sun(type4tuv)		sun(type4tuv)
+  sun_type5		=    sun(type5)			sun(type5)
+  sun_type5_euro	=    sun(type5tuv)		sun(type5tuv)
+  sun_type5_jp		=    sun(type5_jp)		sun(type5jp)
+  sun_type5_unix	=    sun(type5)			sun(type5unix)
+  sun_type5_hobo	=    sun(type5hobo)		sun(type5hobo)
+  sun_type5_euro_hobo	=    sun(type5tuvhobo)		sun(type5tuvhobo)
+  sun_type5_jp_hobo	=    sun(type5_jphobo)		sun(type5jphobo)
+  sun_type5_unix_hobo	=    sun(type5hobo)		sun(type5hobo)
+  sun_type6		=    sun(type6)                 sun(type6)
+  sun_type6_euro	=    sun(type6tuv)	        sun(type6tuv)
+  sun_type6_jp		=    sun(type6_jp)		sun(type6jp)
+  sun_type6_unix	=    sun(type6unix)		sun(type6unix)
+  sun_type6_usb		=    sun(type6_usb)		sun(type6)
+  sun_type6_euro_usb	=    sun(type6tuv_usb)	        sun(type6tuv)
+  sun_type6_jp_usb	=    sun(type6_jp_usb)		sun(type6jp)
+  sun_type6_unix_usb	=    sun(type6_usb)		sun(type6unix)
+  sun_type7_jp_usb	=    sun(type6_jp_usb)		sun(type6jp)
+
+! $sun = sun_type4 sun_type4_ca sun_type4_jp sun_type4_euro sun_type5 sun_type5_euro sun_type5_jp sun_type5_unix sun_type5_hobo sun_type5_euro_hobo sun_type5_jp_hobo sun_type5_unix_hobo sun_type6 sun_type6_euro sun_type6_jp sun_type6_unix sun_type6_usb sun_type6_euro_usb sun_type6_jp_usb sun_type6_unix_usb sun_type7_jp_usb
+! $sun_type4 = sun_type4 sun_type4_ca sun_type4_jp sun_type4_euro 
+| $sun_type5 = sun_type5 sun_type5_euro sun_type5_jp sun_type5_unix 
+| $sun_hobo = sun_type5_hobo sun_type5_euro_hobo sun_type5_jp_hobo sun_type5_unix_hobo 
+! $sun_type6 = sun_type6 sun_type6_euro sun_type6_jp sun_type6_unix sun_type6_usb sun_type6_euro_usb sun_type6_jp_usb sun_type6_unix_usb
+! $sun_type7 = sun_type7_jp_usb
+// Sun Type 6 keyboards with custom/non-standard layouts
+! $sun_t6_custom = es gb it ko jp pt ru tw
+! $sun_jp = sun_type4_jp sun_type5_jp sun_type6_jp sun_type6_jp_usb sun_type7_jp_usb
+
+
+! $pcmodels = pc101 pc102 pc104 pc105
+! $maclaptop = ibook powerbook
+! $mac = macintosh macintosh_old ibook powerbook
+
+! $azerty = be fr
+! $qwertz = al cz de hr hu ro si sk 
+
+! $inetkbds = a4techKB21 a4techKBS8 acer_tm_800 acpi airkey azonaRF2300 \
+              brother \
+              btc5113rf btc5126t btc9000 btc9000a btc9001ah btc5090\
+              cherryblue cherrybluea cherryblueb \
+              chicony chicony9885 \
+              compaqeak8 compaqik7 compaqik13 compaqik18 cymotionlinux \
+              armada presario ipaq \
+              dell inspiron dtk2000 \
+              dexxa diamond genius geniuscomfy2 \
+              ennyah_dkb1008 gyration \
+              hpi6 hp2501 hp2505 hp5181 hpxe3gc hpxe3gf hpxe4xxx hpzt11xx \
+              hp500fa hp5xx hp5185 \
+              honeywell_euroboard \
+              rapidaccess rapidaccess2 rapidaccess2a \
+              ltcd logiaccess logicdp logicdpa logicdit logicink logiciink \
+              logiinkse logiinkseusb logiitc logiik itouch logiultrax \
+              mx1998 mx2500 mx2750 \
+              microsoftinet microsoftpro microsoftprousb microsoftprooem microsoftprose \
+              microsoftoffice microsoftmult \
+              oretec \
+              propeller scorpius \
+              qtronix \
+              samsung4500 samsung4510 \
+              sk1300 sk2500 sk6200 sk7100 sp_inet \
+              sven symplon toshiba_s3000 trust trustda yahoo
+
+! model		=	keycodes
+  macintosh_old	=	macintosh
+  powerpcps2	=	powerpcps2
+  pc98		=	xfree98(pc98)
+  abnt2		=	xfree86(abnt2)
+  jp106		=	sun(type6_jp_usb)
+  *		=	xfree86
+
+! layout[1]	=	keycodes
+  $azerty       =       +aliases(azerty)
+  $qwertz       =       +aliases(qwertz)
+  *             =       +aliases(qwerty)
+
+! layout	=	keycodes
+  $azerty       =       +aliases(azerty)
+  $qwertz       =       +aliases(qwertz)
+  *             =       +aliases(qwerty)
+
+! model		=	geometry
+  microsoft	=	microsoft(natural)
+  microsoftpro	=	microsoft(natural)
+  microsoftprousb =	microsoft(natural)
+  microsoftprose =	microsoft(natural)
+  dell101	=	dell(dell101)
+  flexpro	=	keytronic(FlexPro)
+  hp6000	=	hp(omnibook)
+  omnikey101	=	northgate(omnikey101)
+  thinkpad	=	ibm/thinkpad(common)
+ $pcmodels	=	pc(%m)
+  jp106		=	pc(jp106)
+  everex	=	everex(STEPnote)
+  winbook	=	winbook(XP5)
+  pc98		=	nec(pc98)
+  abnt2		=	pc(abnt2)
+ $mac		=	macintosh(macintosh)
+  *		=       pc(pc104)
+
+! model		layout		variant		=	symbols
+  $pcmodels	ben		basic		=	pc/pc(%m)+pc/in(ben)
+  *		ben		basic		=	pc/pc(pc105)+pc/in(ben)
+  $pcmodels	ben		probhat		=	pc/pc(%m)+pc/in(ben_probhat)
+  *		ben		probhat		=	pc/pc(pc105)+pc/in(ben_probhat)
+  $pcmodels	dev		basic		=	pc/pc(%m)+pc/in(deva)
+  *		dev		basic		=	pc/pc(pc105)+pc/in(deva)
+  $pcmodels	dvorak		gb		=	pc/pc(%m)+pc/gb(dvorak)
+  *		dvorak		gb		=	pc/pc(pc105)+pc/gb(dvorak)
+  $pcmodels	dvorak		fr		=	pc/pc(%m)+pc/fr(dvorak)
+  *		dvorak		fr		=	pc/pc(pc105)+pc/fr(dvorak)
+  $pcmodels	dvorak		no		=	pc/pc(%m)+pc/no(dvorak)
+  *		dvorak		no		=	pc/pc(pc105)+pc/no(dvorak)
+  $pcmodels	dvorak		se		=	pc/pc(%m)+pc/se(dvorak)
+  *		dvorak		se		=	pc/pc(pc105)+pc/se(dvorak)
+  $pcmodels	dvorak		basic		=	pc/pc(%m)+pc/us(dvorak)
+  *		dvorak		basic		=	pc/pc(pc105)+pc/us(dvorak)
+  $pcmodels	dvorak		pl_basic	=	pc/pc(%m)+pc/pl(dvorak)
+  *		dvorak		pl_basic	=	pc/pc(pc105)+pc/pl(dvorak)
+  $pcmodels	dvorak		pl		=	pc/pc(%m)+pc/pl(dvorak_quotes)
+  *		dvorak		pl		=	pc/pc(pc105)+pc/pl(dvorak_quotes)
+  $pcmodels	dvorak		pl_altquotes	=	pc/pc(%m)+pc/pl(dvorak_altquotes)
+  *		dvorak		pl_altquotes	=	pc/pc(pc105)+pc/pl(dvorak_altquotes)
+  $pcmodels	dz		basic		=	pc/pc(%m)+pc/bt(basic)
+  *		dz		basic		=	pc/pc(pc105)+pc/bt(basic)
+  $pcmodels	guj		basic		=	pc/pc(%m)+pc/in(guj)
+  *		guj		basic		=	pc/pc(pc105)+pc/in(guj)
+  $pcmodels	gur		basic		=	pc/pc(%m)+pc/in(guru)
+  *		gur		basic		=	pc/pc(pc105)+pc/in(guru)
+  $pcmodels	ie		laptop		=	pc/pc(%m)+pc/ie(basic)
+  *		ie		laptop		=	pc/pc(pc105)+pc/ie(basic)
+  $pcmodels	ie		CloGaelachLaptop		=	pc/pc(%m)+pc/ie(CloGaelach)
+  *		ie		CloGaelachLaptop		=	pc/pc(pc105)+pc/ie(CloGaelach)
+  $pcmodels	iu		basic		=	pc/pc(%m)+pc/ca(ike)
+  *		iu		basic		=	pc/pc(pc105)+pc/ca(ike)
+  $pcmodels	lo		basic		=	pc/pc(%m)+pc/la(basic)
+  *		lo		basic		=	pc/pc(pc105)+pc/la(basic)
+  $pcmodels	kan		basic		=	pc/pc(%m)+pc/in(kan)
+  *		kan		basic		=	pc/pc(pc105)+pc/in(kan)
+  $pcmodels	mal		basic		=	pc/pc(%m)+pc/in(mal)
+  *		mal		basic		=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	mal		mlplusnum	=	pc/pc(%m)+pc/in(mal)
+  *		mal		mlplusnum	=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	ogham		basic		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham		basic		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham		laptop		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham		laptop		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham		is434		=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham		is434		=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ogham		is434laptop	=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham		is434laptop	=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ori		basic		=	pc/pc(%m)+pc/in(ori)
+  *		ori		basic		=	pc/pc(pc105)+pc/in(ori)
+  $pcmodels	sapmi		basic		=	pc/pc(%m)+pc/no(smi)
+  *		sapmi		basic		=	pc/pc(pc105)+pc/no(smi)
+  $pcmodels	sapmi		nodeadkeys	=	pc/pc(%m)+pc/no(smi_nodeadkeys)
+  *		sapmi		nodeadkeys	=	pc/pc(pc105)+pc/no(smi_nodeadkeys)
+  $pcmodels	sapmi		sefi		=	pc/pc(%m)+pc/fi(smi)
+  *		sapmi		sefi		=	pc/pc(pc105)+pc/fi(smi)
+  $pcmodels	sin		phonetic-static	=	pc/pc(%m)+pc/in(sin_phonetic)
+  *		sin		phonetic-static	=	pc/pc(pc105)+pc/in(sin_phonetic)
+  $pcmodels	syr		basic		=	pc/pc(%m)+pc/sy(syc)
+  *		syr		basic		=	pc/pc(pc105)+pc/sy(syc)
+  $pcmodels	syr		phonetic	=	pc/pc(%m)+pc/sy(syc_phonetic)
+  *		syr		phonetic	=	pc/pc(pc105)+pc/sy(syc_phonetic)
+  $pcmodels	tam		INSCRIPT	=	pc/pc(%m)+pc/in(tam)
+  *		tam		INSCRIPT	=	pc/pc(pc105)+pc/in(tam)
+  $pcmodels	tam		UNI		=	pc/pc(%m)+pc/in(tam_unicode)
+  *		tam		UNI		=	pc/pc(pc105)+pc/in(tam_unicode)
+  $pcmodels	tam		TAB		=	pc/pc(%m)+pc/in(tam_TAB)
+  *		tam		TAB		=	pc/pc(pc105)+pc/in(tam_TAB)
+  $pcmodels	tam		TSCII		=	pc/pc(%m)+pc/in(tam_TSCII)
+  *		tam		TSCII		=	pc/pc(pc105)+pc/in(tam_TSCII)
+  $pcmodels	tel		basic		=	pc/pc(%m)+pc/in(tel)
+  *		tel		basic		=	pc/pc(pc105)+pc/in(tel)
+  $pcmodels	yu		basic		=	pc/pc(%m)+pc/srp(latin)
+  *		yu		basic		=	pc/pc(pc105)+pc/srp(latin)
+  $pcmodels	yu		unicode		=	pc/pc(%m)+pc/srp(latinunicode)
+  *		yu		unicode		=	pc/pc(pc105)+pc/srp(latinunicode)
+  $pcmodels	yu		yz		=	pc/pc(%m)+pc/srp(latinyz)
+  *		yu		yz		=	pc/pc(pc105)+pc/srp(latinyz)
+  $pcmodels	yu		unicodeyz	=	pc/pc(%m)+pc/srp(latinunicodeyz)
+  *		yu		unicodeyz	=	pc/pc(pc105)+pc/srp(latinunicodeyz)
+ $maclaptop	*		nodeadkeys	=	macintosh/us(extended)+macintosh/%l%(v)+apple(laptop_bad_switch)
+ $mac		*		nodeadkeys	=	macintosh/us(extended)+macintosh/%l%(v)
+
+! model		layout				=	symbols
+  $sun_type4	*	=	sun/us(type4)+sun/%l(type4)
+  $sun_type5	*	=	sun/us(type5)+sun/%l(type5)
+  $sun_hobo	*	=	sun/us(type5hobo)+sun/%l(type5hobo)
+  $sun_type6	us	=	sun/us(type6)+sun/solaris(defaults)
+  $sun_type6	jp	=	sun/us(type6)+sun/jp(type6)
+  $sun_type7	jp	=	sun/us(type6)+sun/jp(type7)
+  jp106		jp	=	sun/us(type6)+sun/jp(type7)
+  $sun_type6	$sun_t6_custom	=	sun/us(type6)+sun/%l(type6)
+  $sun_type6	*	=	sun/us(type6)+%l(sundeadkeys)
+  $pcmodels	ar			=	pc/pc(%m)+pc/ara
+  *		ar			=	pc/pc(pc105)+pc/ara
+  $pcmodels	ben			=	pc/pc(%m)+pc/in(ben)
+  *		ben			=	pc/pc(pc105)+pc/in(ben)
+  $pcmodels	bs			=	pc/pc(%m)+pc/ba
+  *		bs			=	pc/pc(pc105)+pc/ba
+  $pcmodels	dev			=	pc/pc(%m)+pc/in(deva)
+  *		dev			=	pc/pc(pc105)+pc/in(deva)
+  $pcmodels	dvorak			=	pc/pc(%m)+pc/us(dvorak)
+  *		dvorak			=	pc/pc(pc105)+pc/us(dvorak)
+  $pcmodels	dz			=	pc/pc(%m)+pc/bt
+  *		dz			=	pc/pc(pc105)+pc/bt
+  $pcmodels	el			=	pc/pc(%m)+pc/gr
+  *		el			=	pc/pc(pc105)+pc/gr
+  $pcmodels	ge_la			=	pc/pc(%m)+pc/ge
+  *		ge_la			=	pc/pc(pc105)+pc/ge
+  $pcmodels	ge_ru			=	pc/pc(%m)+pc/ge(ru)
+  *		ge_ru			=	pc/pc(pc105)+pc/ge(ru)
+  $pcmodels	guj			=	pc/pc(%m)+pc/in(guj)
+  *		guj			=	pc/pc(pc105)+pc/in(guj)
+  $pcmodels	gur			=	pc/pc(%m)+pc/in(guru)
+  *		gur			=	pc/pc(pc105)+pc/in(guru)
+  $pcmodels	iu			=	pc/pc(%m)+pc/ca(ike)
+  *		iu			=	pc/pc(pc105)+pc/ca(ike)
+  $pcmodels	lo			=	pc/pc(%m)+pc/la
+  *		lo			=	pc/pc(pc105)+pc/la
+  $pcmodels	kan			=	pc/pc(%m)+pc/in(kan)
+  *		kan			=	pc/pc(pc105)+pc/in(kan)
+  $pcmodels	mi			=	pc/pc(%m)+pc/mao
+  *		mi			=	pc/pc(pc105)+pc/mao
+  $pcmodels	mk			=	pc/pc(%m)+pc/mkd
+  *		mk			=	pc/pc(pc105)+pc/mkd
+  $pcmodels	ml			=	pc/pc(%m)+pc/in(mal)
+  *		ml			=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	ogham			=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham			=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ori			=	pc/pc(%m)+pc/ie(ori)
+  *		ori			=	pc/pc(pc105)+pc/ie(ori)
+  $pcmodels	sapmi			=	pc/pc(%m)+pc/no(smi)
+  *		sapmi			=	pc/pc(pc105)+pc/no(smi)
+  $pcmodels	sr			=	pc/pc(%m)+pc/srp
+  *		sr			=	pc/pc(pc105)+pc/srp
+  $pcmodels	syr			=	pc/pc(%m)+pc/sy(syc)
+  *		syr			=	pc/pc(pc105)+pc/sy(syc)
+  $pcmodels	tel			=	pc/pc(%m)+pc/in(tel)
+  *		tel			=	pc/pc(pc105)+pc/in(tel)
+  $pcmodels	tml			=	pc/pc(%m)+pc/in(tam)
+  *		tml			=	pc/pc(pc105)+pc/in(tam)
+  $pcmodels	yu			=	pc/pc(%m)+pc/srp
+  *		yu			=	pc/pc(pc105)+pc/srp
+  $pcmodels	ben(basic)		=	pc/pc(%m)+pc/in(ben)
+  *		ben(basic)		=	pc/pc(pc105)+pc/in(ben)
+  $pcmodels	ben(probhat)		=	pc/pc(%m)+pc/in(ben_probhat)
+  *		ben(probhat)		=	pc/pc(pc105)+pc/in(ben_probhat)
+  $pcmodels	dev(basic)		=	pc/pc(%m)+pc/in(deva)
+  *		dev(basic)		=	pc/pc(pc105)+pc/in(deva)
+  $pcmodels	dvorak(gb)		=	pc/pc(%m)+pc/gb(dvorak)
+  *		dvorak(gb)		=	pc/pc(pc105)+pc/gb(dvorak)
+  $pcmodels	dvorak(fr)		=	pc/pc(%m)+pc/fr(dvorak)
+  *		dvorak(fr)		=	pc/pc(pc105)+pc/fr(dvorak)
+  $pcmodels	dvorak(no)		=	pc/pc(%m)+pc/no(dvorak)
+  *		dvorak(no)		=	pc/pc(pc105)+pc/no(dvorak)
+  $pcmodels	dvorak(se)		=	pc/pc(%m)+pc/se(dvorak)
+  *		dvorak(se)		=	pc/pc(pc105)+pc/se(dvorak)
+  $pcmodels	dvorak(basic)		=	pc/pc(%m)+pc/us(dvorak)
+  *		dvorak(basic)		=	pc/pc(pc105)+pc/us(dvorak)
+  $pcmodels	dvorak(pl_basic)	=	pc/pc(%m)+pc/pl(dvorak)
+  *		dvorak(pl_basic)	=	pc/pc(pc105)+pc/pl(dvorak)
+  $pcmodels	dvorak(pl)		=	pc/pc(%m)+pc/pl(dvorak_quotes)
+  *		dvorak(pl)		=	pc/pc(pc105)+pc/pl(dvorak_quotes)
+  $pcmodels	dvorak(pl_altquotes)	=	pc/pc(%m)+pc/pl(dvorak_altquotes)
+  *		dvorak(pl_altquotes)	=	pc/pc(pc105)+pc/pl(dvorak_altquotes)
+  $pcmodels	dz(basic)		=	pc/pc(%m)+pc/bt(basic)
+  *		dz(basic)		=	pc/pc(pc105)+pc/bt(basic)
+  $pcmodels	guj(basic)		=	pc/pc(%m)+pc/in(guj)
+  *		guj(basic)		=	pc/pc(pc105)+pc/in(guj)
+  $pcmodels	gur(basic)		=	pc/pc(%m)+pc/in(guru)
+  *		gur(basic)		=	pc/pc(pc105)+pc/in(guru)
+  $pcmodels	ie(laptop)		=	pc/pc(%m)+pc/ie(basic)
+  *		ie(laptop)		=	pc/pc(pc105)+pc/ie(basic)
+  $pcmodels	ie(CloGaelachLaptop)	=	pc/pc(%m)+pc/ie(CloGaelach)
+  *		ie(CloGaelachLaptop)	=	pc/pc(pc105)+pc/ie(CloGaelach)
+  $pcmodels	iu(basic)		=	pc/pc(%m)+pc/ca(ike)
+  *		iu(basic)		=	pc/pc(pc105)+pc/ca(ike)
+  $pcmodels	lo(basic)		=	pc/pc(%m)+pc/la(basic)
+  *		lo(basic)		=	pc/pc(pc105)+pc/la(basic)
+  $pcmodels	kan(basic)		=	pc/pc(%m)+pc/in(kan)
+  *		kan(basic)		=	pc/pc(pc105)+pc/in(kan)
+  $pcmodels	mal(basic)		=	pc/pc(%m)+pc/in(mal)
+  *		mal(basic)		=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	mal(mlplusnum)		=	pc/pc(%m)+pc/in(mal)
+  *		mal(mlplusnum)		=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	ogham(basic)		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham(basic)		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham(laptop)		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham(laptop)		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham(is434)		=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham(is434)		=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ogham(is434laptop)	=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham(is434laptop)	=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ori(basic)		=	pc/pc(%m)+pc/in(ori)
+  *		ori(basic)		=	pc/pc(pc105)+pc/in(ori)
+  $pcmodels	sapmi(basic)		=	pc/pc(%m)+pc/no(smi)
+  *		sapmi(basic)		=	pc/pc(pc105)+pc/no(smi)
+  $pcmodels	sapmi(nodeadkeys)	=	pc/pc(%m)+pc/no(smi_nodeadkeys)
+  *		sapmi(nodeadkeys)	=	pc/pc(pc105)+pc/no(smi_nodeadkeys)
+  $pcmodels	sapmi(sefi)		=	pc/pc(%m)+pc/fi(smi)
+  *		sapmi(sefi)		=	pc/pc(pc105)+pc/fi(smi)
+  $pcmodels	sin(phonetic-static)	=	pc/pc(%m)+pc/in(sin_phonetic)
+  *		sin(phonetic-static)	=	pc/pc(pc105)+pc/in(sin_phonetic)
+  $pcmodels	syr(basic)		=	pc/pc(%m)+pc/sy(syc)
+  *		syr(basic)		=	pc/pc(pc105)+pc/sy(syc)
+  $pcmodels	syr(phonetic)		=	pc/pc(%m)+pc/sy(syc_phonetic)
+  *		syr(phonetic)		=	pc/pc(pc105)+pc/sy(syc_phonetic)
+  $pcmodels	tam(INSCRIPT)		=	pc/pc(%m)+pc/in(tam)
+  *		tam(INSCRIPT)		=	pc/pc(pc105)+pc/in(tam)
+  $pcmodels	tam(UNI)		=	pc/pc(%m)+pc/in(tam_unicode)
+  *		tam(UNI)		=	pc/pc(pc105)+pc/in(tam_unicode)
+  $pcmodels	tam(TAB)		=	pc/pc(%m)+pc/in(tam_TAB)
+  *		tam(TAB)		=	pc/pc(pc105)+pc/in(tam_TAB)
+  $pcmodels	tam(TSCII)		=	pc/pc(%m)+pc/in(tam_TSCII)
+  *		tam(TSCII)		=	pc/pc(pc105)+pc/in(tam_TSCII)
+  $pcmodels	tel(basic)		=	pc/pc(%m)+pc/in(tel)
+  *		tel(basic)		=	pc/pc(pc105)+pc/in(tel)
+  $pcmodels	yu(basic)		=	pc/pc(%m)+pc/srp(latin)
+  *		yu(basic)		=	pc/pc(pc105)+pc/srp(latin)
+  $pcmodels	yu(unicode)		=	pc/pc(%m)+pc/srp(latinunicode)
+  *		yu(unicode)		=	pc/pc(pc105)+pc/srp(latinunicode)
+  $pcmodels	yu(yz)			=	pc/pc(%m)+pc/srp(latinyz)
+  *		yu(yz)			=	pc/pc(pc105)+pc/srp(latinyz)
+  $pcmodels	yu(unicodeyz)		=	pc/pc(%m)+pc/srp(latinunicodeyz)
+  *		yu(unicodeyz)		=	pc/pc(pc105)+pc/srp(latinunicodeyz)
+  pc98		nec/jp			=	nec/jp(pc98)
+  abnt2		br			=	pc/pc(pc104)+pc/br
+ $maclaptop	us			=	macintosh/us(extended)+apple(laptop_bad_switch)
+ $maclaptop	en_US			=	macintosh/us(extended)+apple(laptop_bad_switch)
+ $maclaptop	*			=	macintosh/us(extended)+apple(laptop_bad_switch)+macintosh/%l%(v)
+ $mac		us			=	macintosh/us(extended)
+ $mac		en_US			=	macintosh/us(extended)
+ $mac		*			=	macintosh/us(extended)+macintosh/%l%(v)
+ $pcmodels      intl   			=       us(%mcompose)
+  *		intl			=	us(pc104compose)
+  *		jp			=	pc/pc(pc102)+pc/jp(latin)+pc/jp:2
+ $pcmodels      ca     			=       pc/pc(%m)+pc/ca(multi)+pc/ca(multi-2gr):2+group(rctrl_switch)
+  *             ca     			=       pc/pc(pc105)+pc/ca(multi)+pc/ca(multi-2gr):2+group(rctrl_switch)
+ $pcmodels $nonlatin			=	pc/pc(%m)+pc/us+pc/%l%(v):2
+ $pcmodels	*			=	pc/pc(%m)+pc/%l%(v)
+  *	   $nonlatin			=	pc/pc(pc105)+pc/us+pc/%l%(v):2
+  *		*			=	pc/pc(pc105)+pc/%l%(v)
+
+! model		layout[1]			=	symbols
+  $pcmodels	ar			=	pc/pc(%m)+pc/ara%(v[1])
+  *		ar			=	pc/pc(pc105)+pc/ara%(v[1])
+  $pcmodels	ben			=	pc/pc(%m)+pc/in(ben)%(v[1])
+  *		ben			=	pc/pc(pc105)+pc/in(ben)%(v[1])
+  $pcmodels	bs			=	pc/pc(%m)+pc/ba%(v[1])
+  *		bs			=	pc/pc(pc105)+pc/ba%(v[1])
+  $pcmodels	dev			=	pc/pc(%m)+pc/in(deva)%(v[1])
+  *		dev			=	pc/pc(pc105)+pc/in(deva)%(v[1])
+  $pcmodels	dvorak			=	pc/pc(%m)+pc/us(dvorak)%(v[1])
+  *		dvorak			=	pc/pc(pc105)+pc/us(dvorak)%(v[1])
+  $pcmodels	dz			=	pc/pc(%m)+pc/bt%(v[1])
+  *		dz			=	pc/pc(pc105)+pc/bt%(v[1])
+  $pcmodels	el			=	pc/pc(%m)+pc/gr%(v[1])
+  *		el			=	pc/pc(pc105)+pc/gr%(v[1])
+  $pcmodels	ge_la			=	pc/pc(%m)+pc/ge%(v[1])
+  *		ge_la			=	pc/pc(pc105)+pc/ge%(v[1])
+  $pcmodels	ge_ru			=	pc/pc(%m)+pc/ge(ru)%(v[1])
+  *		ge_ru			=	pc/pc(pc105)+pc/ge(ru)%(v[1])
+  $pcmodels	guj			=	pc/pc(%m)+pc/in(guj)%(v[1])
+  *		guj			=	pc/pc(pc105)+pc/in(guj)%(v[1])
+  $pcmodels	gur			=	pc/pc(%m)+pc/in(guru)%(v[1])
+  *		gur			=	pc/pc(pc105)+pc/in(guru)%(v[1])
+  $pcmodels	iu			=	pc/pc(%m)+pc/ca(ike)%(v[1])
+  *		iu			=	pc/pc(pc105)+pc/ca(ike)%(v[1])
+  $pcmodels	lo			=	pc/pc(%m)+pc/la%(v[1])
+  *		lo			=	pc/pc(pc105)+pc/la%(v[1])
+  $pcmodels	kan			=	pc/pc(%m)+pc/in(kan)%(v[1])
+  *		kan			=	pc/pc(pc105)+pc/in(kan)%(v[1])
+  $pcmodels	mi			=	pc/pc(%m)+pc/mao%(v[1])
+  *		mi			=	pc/pc(pc105)+pc/mao%(v[1])
+  $pcmodels	mk			=	pc/pc(%m)+pc/mkd%(v[1])
+  *		mk			=	pc/pc(pc105)+pc/mkd%(v[1])
+  $pcmodels	ml			=	pc/pc(%m)+pc/in(mal)%(v[1])
+  *		ml			=	pc/pc(pc105)+pc/in(mal)%(v[1])
+  $pcmodels	ogham			=	pc/pc(%m)+pc/ie(ogam)%(v[1])
+  *		ogham			=	pc/pc(pc105)+pc/ie(ogam)%(v[1])
+  $pcmodels	ori			=	pc/pc(%m)+pc/ie(ori)%(v[1])
+  *		ori			=	pc/pc(pc105)+pc/ie(ori)%(v[1])
+  $pcmodels	sapmi			=	pc/pc(%m)+pc/no(smi)%(v[1])
+  *		sapmi			=	pc/pc(pc105)+pc/no(smi)%(v[1])
+  $pcmodels	sr			=	pc/pc(%m)+pc/srp%(v[1])
+  *		sr			=	pc/pc(pc105)+pc/srp%(v[1])
+  $pcmodels	syr			=	pc/pc(%m)+pc/sy(syc)%(v[1])
+  *		syr			=	pc/pc(pc105)+pc/sy(syc)%(v[1])
+  $pcmodels	tel			=	pc/pc(%m)+pc/in(tel)%(v[1])
+  *		tel			=	pc/pc(pc105)+pc/in(tel)%(v[1])
+  $pcmodels	tml			=	pc/pc(%m)+pc/in(tam)%(v[1])
+  *		tml			=	pc/pc(pc105)+pc/in(tam)%(v[1])
+  $pcmodels	yu			=	pc/pc(%m)+pc/srp%(v[1])
+  *		yu			=	pc/pc(pc105)+pc/srp%(v[1])
+  $pcmodels	ben(basic)		=	pc/pc(%m)+pc/in(ben)
+  *		ben(basic)		=	pc/pc(pc105)+pc/in(ben)
+  $pcmodels	ben(probhat)		=	pc/pc(%m)+pc/in(ben_probhat)
+  *		ben(probhat)		=	pc/pc(pc105)+pc/in(ben_probhat)
+  $pcmodels	dev(basic)		=	pc/pc(%m)+pc/in(deva)
+  *		dev(basic)		=	pc/pc(pc105)+pc/in(deva)
+  $pcmodels	dvorak(gb)		=	pc/pc(%m)+pc/gb(dvorak)
+  *		dvorak(gb)		=	pc/pc(pc105)+pc/gb(dvorak)
+  $pcmodels	dvorak(fr)		=	pc/pc(%m)+pc/fr(dvorak)
+  *		dvorak(fr)		=	pc/pc(pc105)+pc/fr(dvorak)
+  $pcmodels	dvorak(no)		=	pc/pc(%m)+pc/no(dvorak)
+  *		dvorak(no)		=	pc/pc(pc105)+pc/no(dvorak)
+  $pcmodels	dvorak(se)		=	pc/pc(%m)+pc/se(dvorak)
+  *		dvorak(se)		=	pc/pc(pc105)+pc/se(dvorak)
+  $pcmodels	dvorak(basic)		=	pc/pc(%m)+pc/us(dvorak)
+  *		dvorak(basic)		=	pc/pc(pc105)+pc/us(dvorak)
+  $pcmodels	dvorak(pl_basic)	=	pc/pc(%m)+pc/pl(dvorak)
+  *		dvorak(pl_basic)	=	pc/pc(pc105)+pc/pl(dvorak)
+  $pcmodels	dvorak(pl)		=	pc/pc(%m)+pc/pl(dvorak_quotes)
+  *		dvorak(pl)		=	pc/pc(pc105)+pc/pl(dvorak_quotes)
+  $pcmodels	dvorak(pl_altquotes)	=	pc/pc(%m)+pc/pl(dvorak_altquotes)
+  *		dvorak(pl_altquotes)	=	pc/pc(pc105)+pc/pl(dvorak_altquotes)
+  $pcmodels	dz(basic)		=	pc/pc(%m)+pc/bt(basic)
+  *		dz(basic)		=	pc/pc(pc105)+pc/bt(basic)
+  $pcmodels	guj(basic)		=	pc/pc(%m)+pc/in(guj)
+  *		guj(basic)		=	pc/pc(pc105)+pc/in(guj)
+  $pcmodels	gur(basic)		=	pc/pc(%m)+pc/in(guru)
+  *		gur(basic)		=	pc/pc(pc105)+pc/in(guru)
+  $pcmodels	ie(laptop)		=	pc/pc(%m)+pc/ie(basic)
+  *		ie(laptop)		=	pc/pc(pc105)+pc/ie(basic)
+  $pcmodels	ie(CloGaelachLaptop)	=	pc/pc(%m)+pc/ie(CloGaelach)
+  *		ie(CloGaelachLaptop)	=	pc/pc(pc105)+pc/ie(CloGaelach)
+  $pcmodels	iu(basic)		=	pc/pc(%m)+pc/ca(ike)
+  *		iu(basic)		=	pc/pc(pc105)+pc/ca(ike)
+  $pcmodels	lo(basic)		=	pc/pc(%m)+pc/la(basic)
+  *		lo(basic)		=	pc/pc(pc105)+pc/la(basic)
+  $pcmodels	kan(basic)		=	pc/pc(%m)+pc/in(kan)
+  *		kan(basic)		=	pc/pc(pc105)+pc/in(kan)
+  $pcmodels	mal(basic)		=	pc/pc(%m)+pc/in(mal)
+  *		mal(basic)		=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	mal(mlplusnum)		=	pc/pc(%m)+pc/in(mal)
+  *		mal(mlplusnum)		=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	ogham(basic)		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham(basic)		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham(laptop)		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham(laptop)		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham(is434)		=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham(is434)		=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ogham(is434laptop)	=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham(is434laptop)	=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ori(basic)		=	pc/pc(%m)+pc/in(ori)
+  *		ori(basic)		=	pc/pc(pc105)+pc/in(ori)
+  $pcmodels	sapmi(basic)		=	pc/pc(%m)+pc/no(smi)
+  *		sapmi(basic)		=	pc/pc(pc105)+pc/no(smi)
+  $pcmodels	sapmi(nodeadkeys)	=	pc/pc(%m)+pc/no(smi_nodeadkeys)
+  *		sapmi(nodeadkeys)	=	pc/pc(pc105)+pc/no(smi_nodeadkeys)
+  $pcmodels	sapmi(sefi)		=	pc/pc(%m)+pc/fi(smi)
+  *		sapmi(sefi)		=	pc/pc(pc105)+pc/fi(smi)
+  $pcmodels	sin(phonetic-static)	=	pc/pc(%m)+pc/in(sin_phonetic)
+  *		sin(phonetic-static)	=	pc/pc(pc105)+pc/in(sin_phonetic)
+  $pcmodels	syr(basic)		=	pc/pc(%m)+pc/sy(syc)
+  *		syr(basic)		=	pc/pc(pc105)+pc/sy(syc)
+  $pcmodels	syr(phonetic)		=	pc/pc(%m)+pc/sy(syc_phonetic)
+  *		syr(phonetic)		=	pc/pc(pc105)+pc/sy(syc_phonetic)
+  $pcmodels	tam(INSCRIPT)		=	pc/pc(%m)+pc/in(tam)
+  *		tam(INSCRIPT)		=	pc/pc(pc105)+pc/in(tam)
+  $pcmodels	tam(UNI)		=	pc/pc(%m)+pc/in(tam_unicode)
+  *		tam(UNI)		=	pc/pc(pc105)+pc/in(tam_unicode)
+  $pcmodels	tam(TAB)		=	pc/pc(%m)+pc/in(tam_TAB)
+  *		tam(TAB)		=	pc/pc(pc105)+pc/in(tam_TAB)
+  $pcmodels	tam(TSCII)		=	pc/pc(%m)+pc/in(tam_TSCII)
+  *		tam(TSCII)		=	pc/pc(pc105)+pc/in(tam_TSCII)
+  $pcmodels	tel(basic)		=	pc/pc(%m)+pc/in(tel)
+  *		tel(basic)		=	pc/pc(pc105)+pc/in(tel)
+  $pcmodels	yu(basic)		=	pc/pc(%m)+pc/srp(latin)
+  *		yu(basic)		=	pc/pc(pc105)+pc/srp(latin)
+  $pcmodels	yu(unicode)		=	pc/pc(%m)+pc/srp(latinunicode)
+  *		yu(unicode)		=	pc/pc(pc105)+pc/srp(latinunicode)
+  $pcmodels	yu(yz)			=	pc/pc(%m)+pc/srp(latinyz)
+  *		yu(yz)			=	pc/pc(pc105)+pc/srp(latinyz)
+  $pcmodels	yu(unicodeyz)		=	pc/pc(%m)+pc/srp(latinunicodeyz)
+  *		yu(unicodeyz)		=	pc/pc(pc105)+pc/srp(latinunicodeyz)
+ $pcmodels	*			=	pc/pc(%m)+pc/%l[1]%(v[1])
+  *		*			=	pc/pc(pc105)+pc/%l[1]%(v[1])
+
+! model		layout[1]	variant[1]	=	symbols
+  $pcmodels	ben		basic		=	pc/pc(%m)+pc/in(ben)
+  *		ben		basic		=	pc/pc(pc105)+pc/in(ben)
+  $pcmodels	ben		probhat		=	pc/pc(%m)+pc/in(ben_probhat)
+  *		ben		probhat		=	pc/pc(pc105)+pc/in(ben_probhat)
+  $pcmodels	dev		basic		=	pc/pc(%m)+pc/in(deva)
+  *		dev		basic		=	pc/pc(pc105)+pc/in(deva)
+  $pcmodels	dvorak		gb		=	pc/pc(%m)+pc/gb(dvorak)
+  *		dvorak		gb		=	pc/pc(pc105)+pc/gb(dvorak)
+  $pcmodels	dvorak		fr		=	pc/pc(%m)+pc/fr(dvorak)
+  *		dvorak		fr		=	pc/pc(pc105)+pc/fr(dvorak)
+  $pcmodels	dvorak		no		=	pc/pc(%m)+pc/no(dvorak)
+  *		dvorak		no		=	pc/pc(pc105)+pc/no(dvorak)
+  $pcmodels	dvorak		se		=	pc/pc(%m)+pc/se(dvorak)
+  *		dvorak		se		=	pc/pc(pc105)+pc/se(dvorak)
+  $pcmodels	dvorak		basic		=	pc/pc(%m)+pc/us(dvorak)
+  *		dvorak		basic		=	pc/pc(pc105)+pc/us(dvorak)
+  $pcmodels	dvorak		pl_basic	=	pc/pc(%m)+pc/pl(dvorak)
+  *		dvorak		pl_basic	=	pc/pc(pc105)+pc/pl(dvorak)
+  $pcmodels	dvorak		pl		=	pc/pc(%m)+pc/pl(dvorak_quotes)
+  *		dvorak		pl		=	pc/pc(pc105)+pc/pl(dvorak_quotes)
+  $pcmodels	dvorak		pl_altquotes	=	pc/pc(%m)+pc/pl(dvorak_altquotes)
+  *		dvorak		pl_altquotes	=	pc/pc(pc105)+pc/pl(dvorak_altquotes)
+  $pcmodels	dz		basic		=	pc/pc(%m)+pc/bt(basic)
+  *		dz		basic		=	pc/pc(pc105)+pc/bt(basic)
+  $pcmodels	guj		basic		=	pc/pc(%m)+pc/in(guj)
+  *		guj		basic		=	pc/pc(pc105)+pc/in(guj)
+  $pcmodels	gur		basic		=	pc/pc(%m)+pc/in(guru)
+  *		gur		basic		=	pc/pc(pc105)+pc/in(guru)
+  $pcmodels	ie		laptop		=	pc/pc(%m)+pc/ie(basic)
+  *		ie		laptop		=	pc/pc(pc105)+pc/ie(basic)
+  $pcmodels	ie		CloGaelachLaptop		=	pc/pc(%m)+pc/ie(CloGaelach)
+  *		ie		CloGaelachLaptop		=	pc/pc(pc105)+pc/ie(CloGaelach)
+  $pcmodels	iu		basic		=	pc/pc(%m)+pc/ca(ike)
+  *		iu		basic		=	pc/pc(pc105)+pc/ca(ike)
+  $pcmodels	lo		basic		=	pc/pc(%m)+pc/la(basic)
+  *		lo		basic		=	pc/pc(pc105)+pc/la(basic)
+  $pcmodels	kan		basic		=	pc/pc(%m)+pc/in(kan)
+  *		kan		basic		=	pc/pc(pc105)+pc/in(kan)
+  $pcmodels	mal		basic		=	pc/pc(%m)+pc/in(mal)
+  *		mal		basic		=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	mal		mlplusnum	=	pc/pc(%m)+pc/in(mal)
+  *		mal		mlplusnum	=	pc/pc(pc105)+pc/in(mal)
+  $pcmodels	ogham		basic		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham		basic		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham		laptop		=	pc/pc(%m)+pc/ie(ogam)
+  *		ogham		laptop		=	pc/pc(pc105)+pc/ie(ogam)
+  $pcmodels	ogham		is434		=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham		is434		=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ogham		is434laptop	=	pc/pc(%m)+pc/ie(ogam_is434)
+  *		ogham		is434laptop	=	pc/pc(pc105)+pc/ie(ogam_is434)
+  $pcmodels	ori		basic		=	pc/pc(%m)+pc/in(ori)
+  *		ori		basic		=	pc/pc(pc105)+pc/in(ori)
+  $pcmodels	sapmi		basic		=	pc/pc(%m)+pc/no(smi)
+  *		sapmi		basic		=	pc/pc(pc105)+pc/no(smi)
+  $pcmodels	sapmi		nodeadkeys	=	pc/pc(%m)+pc/no(smi_nodeadkeys)
+  *		sapmi		nodeadkeys	=	pc/pc(pc105)+pc/no(smi_nodeadkeys)
+  $pcmodels	sapmi		sefi		=	pc/pc(%m)+pc/fi(smi)
+  *		sapmi		sefi		=	pc/pc(pc105)+pc/fi(smi)
+  $pcmodels	sin		phonetic-static	=	pc/pc(%m)+pc/in(sin_phonetic)
+  *		sin		phonetic-static	=	pc/pc(pc105)+pc/in(sin_phonetic)
+  $pcmodels	syr		basic		=	pc/pc(%m)+pc/sy(syc)
+  *		syr		basic		=	pc/pc(pc105)+pc/sy(syc)
+  $pcmodels	syr		phonetic	=	pc/pc(%m)+pc/sy(syc_phonetic)
+  *		syr		phonetic	=	pc/pc(pc105)+pc/sy(syc_phonetic)
+  $pcmodels	tam		INSCRIPT	=	pc/pc(%m)+pc/in(tam)
+  *		tam		INSCRIPT	=	pc/pc(pc105)+pc/in(tam)
+  $pcmodels	tam		UNI		=	pc/pc(%m)+pc/in(tam_unicode)
+  *		tam		UNI		=	pc/pc(pc105)+pc/in(tam_unicode)
+  $pcmodels	tam		TAB		=	pc/pc(%m)+pc/in(tam_TAB)
+  *		tam		TAB		=	pc/pc(pc105)+pc/in(tam_TAB)
+  $pcmodels	tam		TSCII		=	pc/pc(%m)+pc/in(tam_TSCII)
+  *		tam		TSCII		=	pc/pc(pc105)+pc/in(tam_TSCII)
+  $pcmodels	tel		basic		=	pc/pc(%m)+pc/in(tel)
+  *		tel		basic		=	pc/pc(pc105)+pc/in(tel)
+  $pcmodels	yu		basic		=	pc/pc(%m)+pc/srp(latin)
+  *		yu		basic		=	pc/pc(pc105)+pc/srp(latin)
+  $pcmodels	yu		unicode		=	pc/pc(%m)+pc/srp(latinunicode)
+  *		yu		unicode		=	pc/pc(pc105)+pc/srp(latinunicode)
+  $pcmodels	yu		yz		=	pc/pc(%m)+pc/srp(latinyz)
+  *		yu		yz		=	pc/pc(pc105)+pc/srp(latinyz)
+  $pcmodels	yu		unicodeyz	=	pc/pc(%m)+pc/srp(latinunicodeyz)
+  *		yu		unicodeyz	=	pc/pc(pc105)+pc/srp(latinunicodeyz)
+
+! layout[2]		=	symbols
+  ar			=	+pc/ara%(v[2]):2
+  ben			=	+pc/in(ben):2
+  bs			=	+pc/ba%(v[2]):2
+  dev			=	+pc/in(deva):2
+  dvorak		=	+pc/us(dvorak):2
+  dz			=	+pc/bt%(v[2]):2
+  el			=	+pc/gr%(v[2]):2
+  ge_la			=	+pc/ge%(v[2]):2
+  ge_ru			=	+pc/ge(ru):2
+  guj			=	+pc/in(guj):2
+  gur			=	+pc/in(guru):2
+  iu			=	+pc/ca(ike):2
+  lo			=	+pc/la%(v[2]):2
+  kan			=	+pc/in(kan):2
+  mi			=	+pc/mao%(v[2]):2
+  mk			=	+pc/mkd%(v[2]):2
+  ml			=	+pc/in(mal):2
+  ogham			=	+pc/ie(ogam):2
+  ori			=	+pc/ie(ori):2
+  sapmi			=	+pc/no(smi):2
+  sr			=	+pc/srp%(v[2]):2
+  syr			=	+pc/sy(syc):2
+  tel			=	+pc/in(tel):2
+  tml			=	+pc/in(tam):2
+  yu			=	+pc/srp%(v[2]):2
+  ben(basic)		=	+pc/in(ben):2
+  ben(probhat)		=	+pc/in(ben_probhat):2
+  dev(basic)		=	+pc/in(deva):2
+  dvorak(gb)		=	+pc/gb(dvorak):2
+  dvorak(fr)		=	+pc/fr(dvorak):2
+  dvorak(no)		=	+pc/no(dvorak):2
+  dvorak(se)		=	+pc/se(dvorak):2
+  dvorak(basic)		=	+pc/us(dvorak):2
+  dvorak(pl_basic)	=	+pc/pl(dvorak):2
+  dvorak(pl)		=	+pc/pl(dvorak_quotes):2
+  dvorak(pl_altquotes)	=	+pc/pl(dvorak_altquotes):2
+  dz(basic)		=	+pc/bt(basic):2
+  guj(basic)		=	+pc/in(guj):2
+  gur(basic)		=	+pc/in(guru):2
+  ie(laptop)		=	+pc/ie(basic):2
+  ie(CloGaelachLaptop)	=	+pc/ie(CloGaelach):2
+  iu(basic)		=	+pc/ca(ike):2
+  lo(basic)		=	+pc/la(basic):2
+  kan(basic)		=	+pc/in(kan):2
+  mal(basic)		=	+pc/in(mal):2
+  mal(mlplusnum)	=	+pc/in(mal):2
+  ogham(basic)		=	+pc/ie(ogam):2
+  ogham(laptop)		=	+pc/ie(ogam):2
+  ogham(is434)		=	+pc/ie(ogam_is434):2
+  ogham(is434laptop)	=	+pc/ie(ogam_is434):2
+  ori(basic)		=	+pc/in(ori):2
+  sapmi(basic)		=	+pc/no(smi):2
+  sapmi(nodeadkeys)	=	+pc/no(smi_nodeadkeys):2
+  sapmi(sefi)		=	+pc/fi(smi):2
+  sin(phonetic-static)	=	+pc/in(sin_phonetic):2
+  syr(basic)		=	+pc/sy(syc):2
+  syr(phonetic)		=	+pc/sy(syc_phonetic):2
+  tam(INSCRIPT)		=	+pc/in(tam):2
+  tam(UNI)		=	+pc/in(tam_unicode):2
+  tam(TAB)		=	+pc/in(tam_TAB):2
+  tam(TSCII)		=	+pc/in(tam_TSCII):2
+  tel(basic)		=	+pc/in(tel):2
+  yu(basic)		=	+pc/srp(latin):2
+  yu(unicode)		=	+pc/srp(latinunicode):2
+  yu(yz)		=	+pc/srp(latinyz):2
+  yu(unicodeyz)		=	+pc/srp(latinunicodeyz):2
+  *			=	+pc/%l[2]%(v[2]):2
+
+! layout[3]		=	symbols
+  ar			=	+pc/ara%(v[3]):3
+  ben			=	+pc/in(ben)%(v[3]):3
+  bs			=	+pc/ba%(v[3]):3
+  dev			=	+pc/in(deva)%(v[3]):3
+  dvorak		=	+pc/us(dvorak)%(v[3]):3
+  dz			=	+pc/bt%(v[3]):3
+  el			=	+pc/gr%(v[3]):3
+  ge_la			=	+pc/ge%(v[3]):3
+  ge_ru			=	+pc/ge(ru)%(v[3]):3
+  guj			=	+pc/in(guj)%(v[3]):3
+  gur			=	+pc/in(guru)%(v[3]):3
+  iu			=	+pc/ca(ike)%(v[3]):3
+  lo			=	+pc/la%(v[3]):3
+  kan			=	+pc/in(kan)%(v[3]):3
+  mi			=	+pc/mao%(v[3]):3
+  mk			=	+pc/mkd%(v[3]):3
+  ml			=	+pc/in(mal)%(v[3]):3
+  ogham			=	+pc/ie(ogam)%(v[3]):3
+  ori			=	+pc/ie(ori)%(v[3]):3
+  sapmi			=	+pc/no(smi)%(v[3]):3
+  sr			=	+pc/srp%(v[3]):3
+  syr			=	+pc/sy(syc)%(v[3]):3
+  tel			=	+pc/in(tel)%(v[3]):3
+  tml			=	+pc/in(tam)%(v[3]):3
+  yu			=	+pc/srp%(v[3]):3
+  ben(basic)		=	+pc/in(ben):3
+  ben(probhat)		=	+pc/in(ben_probhat):3
+  dev(basic)		=	+pc/in(deva):3
+  dvorak(gb)		=	+pc/gb(dvorak):3
+  dvorak(fr)		=	+pc/fr(dvorak):3
+  dvorak(no)		=	+pc/no(dvorak):3
+  dvorak(se)		=	+pc/se(dvorak):3
+  dvorak(basic)		=	+pc/us(dvorak):3
+  dvorak(pl_basic)	=	+pc/pl(dvorak):3
+  dvorak(pl)		=	+pc/pl(dvorak_quotes):3
+  dvorak(pl_altquotes)	=	+pc/pl(dvorak_altquotes):3
+  dz(basic)		=	+pc/bt(basic):3
+  guj(basic)		=	+pc/in(guj):3
+  gur(basic)		=	+pc/in(guru):3
+  ie(laptop)		=	+pc/ie(basic):3
+  ie(CloGaelachLaptop)	=	+pc/ie(CloGaelach):3
+  iu(basic)		=	+pc/ca(ike):3
+  lo(basic)		=	+pc/la(basic):3
+  kan(basic)		=	+pc/in(kan):3
+  mal(basic)		=	+pc/in(mal):3
+  mal(mlplusnum)	=	+pc/in(mal):3
+  ogham(basic)		=	+pc/ie(ogam):3
+  ogham(laptop)		=	+pc/ie(ogam):3
+  ogham(is434)		=	+pc/ie(ogam_is434):3
+  ogham(is434laptop)	=	+pc/ie(ogam_is434):3
+  ori(basic)		=	+pc/in(ori):3
+  sapmi(basic)		=	+pc/no(smi):3
+  sapmi(nodeadkeys)	=	+pc/no(smi_nodeadkeys):3
+  sapmi(sefi)		=	+pc/fi(smi):3
+  sin(phonetic-static)	=	+pc/in(sin_phonetic):3
+  syr(basic)		=	+pc/sy(syc):3
+  syr(phonetic)		=	+pc/sy(syc_phonetic):3
+  tam(INSCRIPT)		=	+pc/in(tam):3
+  tam(UNI)		=	+pc/in(tam_unicode):3
+  tam(TAB)		=	+pc/in(tam_TAB):3
+  tam(TSCII)		=	+pc/in(tam_TSCII):3
+  tel(basic)		=	+pc/in(tel):3
+  yu(basic)		=	+pc/srp(latin):3
+  yu(unicode)		=	+pc/srp(latinunicode):3
+  yu(yz)		=	+pc/srp(latinyz):3
+  yu(unicodeyz)		=	+pc/srp(latinunicodeyz):3
+  *			=	+pc/%l[3]%(v[3]):3
+
+! layout[4]		=	symbols
+  ar			=	+pc/ara%(v[4]):4
+  ben			=	+pc/in(ben)%(v[4]):4
+  bs			=	+pc/ba%(v[4]):4
+  dev			=	+pc/in(deva)%(v[4]):4
+  dvorak		=	+pc/us(dvorak)%(v[4]):4
+  dz			=	+pc/bt%(v[4]):4
+  el			=	+pc/gr%(v[4]):4
+  ge_la			=	+pc/ge%(v[4]):4
+  ge_ru			=	+pc/ge(ru)%(v[4]):4
+  guj			=	+pc/in(guj)%(v[4]):4
+  gur			=	+pc/in(guru)%(v[4]):4
+  iu			=	+pc/ca(ike)%(v[4]):4
+  lo			=	+pc/la%(v[4]):4
+  kan			=	+pc/in(kan)%(v[4]):4
+  mi			=	+pc/mao%(v[4]):4
+  mk			=	+pc/mkd%(v[4]):4
+  ml			=	+pc/in(mal)%(v[4]):4
+  ogham			=	+pc/ie(ogam)%(v[4]):4
+  ori			=	+pc/ie(ori)%(v[4]):4
+  sapmi			=	+pc/no(smi)%(v[4]):4
+  sr			=	+pc/srp%(v[4]):4
+  syr			=	+pc/sy(syc)%(v[4]):4
+  tel			=	+pc/in(tel)%(v[4]):4
+  tml			=	+pc/in(tam)%(v[4]):4
+  yu			=	+pc/srp%(v[4]):4
+  ben(basic)		=	+pc/in(ben):4
+  ben(probhat)		=	+pc/in(ben_probhat):4
+  dev(basic)		=	+pc/in(deva):4
+  dvorak(gb)		=	+pc/gb(dvorak):4
+  dvorak(fr)		=	+pc/fr(dvorak):4
+  dvorak(no)		=	+pc/no(dvorak):4
+  dvorak(se)		=	+pc/se(dvorak):4
+  dvorak(basic)		=	+pc/us(dvorak):4
+  dvorak(pl_basic)	=	+pc/pl(dvorak):4
+  dvorak(pl)		=	+pc/pl(dvorak_quotes):4
+  dvorak(pl_altquotes)	=	+pc/pl(dvorak_altquotes):4
+  dz(basic)		=	+pc/bt(basic):4
+  guj(basic)		=	+pc/in(guj):4
+  gur(basic)		=	+pc/in(guru):4
+  ie(laptop)		=	+pc/ie(basic):4
+  ie(CloGaelachLaptop)	=	+pc/ie(CloGaelach):4
+  iu(basic)		=	+pc/ca(ike):4
+  lo(basic)		=	+pc/la(basic):4
+  kan(basic)		=	+pc/in(kan):4
+  mal(basic)		=	+pc/in(mal):4
+  mal(mlplusnum)	=	+pc/in(mal):4
+  ogham(basic)		=	+pc/ie(ogam):4
+  ogham(laptop)		=	+pc/ie(ogam):4
+  ogham(is434)		=	+pc/ie(ogam_is434):4
+  ogham(is434laptop)	=	+pc/ie(ogam_is434):4
+  ori(basic)		=	+pc/in(ori):4
+  sapmi(basic)		=	+pc/no(smi):4
+  sapmi(nodeadkeys)	=	+pc/no(smi_nodeadkeys):4
+  sapmi(sefi)		=	+pc/fi(smi):4
+  sin(phonetic-static)	=	+pc/in(sin_phonetic):4
+  syr(basic)		=	+pc/sy(syc):4
+  syr(phonetic)		=	+pc/sy(syc_phonetic):4
+  tam(INSCRIPT)		=	+pc/in(tam):4
+  tam(UNI)		=	+pc/in(tam_unicode):4
+  tam(TAB)		=	+pc/in(tam_TAB):4
+  tam(TSCII)		=	+pc/in(tam_TSCII):4
+  tel(basic)		=	+pc/in(tel):4
+  yu(basic)		=	+pc/srp(latin):4
+  yu(unicode)		=	+pc/srp(latinunicode):4
+  yu(yz)		=	+pc/srp(latinyz):4
+  yu(unicodeyz)		=	+pc/srp(latinunicodeyz):4
+  *			=	+pc/%l[4]%(v[4]):4
+
+! layout[2]	variant[2]	=	symbols
+  ben		basic		=	+pc/in(ben):2
+  ben		probhat		=	+pc/in(ben_probhat):2
+  dev		basic		=	+pc/in(deva):2
+  dvorak	gb		=	+pc/gb(dvorak):2
+  dvorak	fr		=	+pc/fr(dvorak):2
+  dvorak	no		=	+pc/no(dvorak):2
+  dvorak	se		=	+pc/se(dvorak):2
+  dvorak	basic		=	+pc/us(dvorak):2
+  dvorak	pl_basic	=	+pc/pl(dvorak):2
+  dvorak	pl		=	+pc/pl(dvorak_quotes):2
+  dvorak	pl_altquotes	=	+pc/pl(dvorak_altquotes):2
+  dz		basic		=	+pc/bt(basic):2
+  guj		basic		=	+pc/in(guj):2
+  gur		basic		=	+pc/in(guru):2
+  ie		laptop		=	+pc/ie(basic):2
+  ie		CloGaelachLaptop	=	+pc/ie(CloGaelach):2
+  iu		basic		=	+pc/ca(ike):2
+  lo		basic		=	+pc/la(basic):2
+  kan		basic		=	+pc/in(kan):2
+  mal		basic		=	+pc/in(mal):2
+  mal		mlplusnum	=	+pc/in(mal):2
+  ogham		basic		=	+pc/ie(ogam):2
+  ogham		laptop		=	+pc/ie(ogam):2
+  ogham		is434		=	+pc/ie(ogam_is434):2
+  ogham		is434laptop	=	+pc/ie(ogam_is434):2
+  ori		basic		=	+pc/in(ori):2
+  sapmi		basic		=	+pc/no(smi):2
+  sapmi		nodeadkeys	=	+pc/no(smi_nodeadkeys):2
+  sapmi		sefi		=	+pc/fi(smi):2
+  sin		phonetic-static	=	+pc/in(sin_phonetic):2
+  syr		basic		=	+pc/sy(syc):2
+  syr		phonetic	=	+pc/sy(syc_phonetic):2
+  tam		INSCRIPT	=	+pc/in(tam):2
+  tam		UNI		=	+pc/in(tam_unicode):2
+  tam		TAB		=	+pc/in(tam_TAB):2
+  tam		TSCII		=	+pc/in(tam_TSCII):2
+  tel		basic		=	+pc/in(tel):2
+  yu		basic		=	+pc/srp(latin):2
+  yu		unicode		=	+pc/srp(latinunicode):2
+  yu		yz		=	+pc/srp(latinyz):2
+  yu		unicodeyz	=	+pc/srp(latinunicodeyz):2
+
+! layout[3]	variant[3]	=	symbols
+  ben		basic		=	+pc/in(ben):3
+  ben		probhat		=	+pc/in(ben_probhat):3
+  dev		basic		=	+pc/in(deva):3
+  dvorak	gb		=	+pc/gb(dvorak):3
+  dvorak	fr		=	+pc/fr(dvorak):3
+  dvorak	no		=	+pc/no(dvorak):3
+  dvorak	se		=	+pc/se(dvorak):3
+  dvorak	basic		=	+pc/us(dvorak):3
+  dvorak	pl_basic	=	+pc/pl(dvorak):3
+  dvorak	pl		=	+pc/pl(dvorak_quotes):3
+  dvorak	pl_altquotes	=	+pc/pl(dvorak_altquotes):3
+  dz		basic		=	+pc/bt(basic):3
+  guj		basic		=	+pc/in(guj):3
+  gur		basic		=	+pc/in(guru):3
+  ie		laptop		=	+pc/ie(basic):3
+  ie		CloGaelachLaptop	=	+pc/ie(CloGaelach):3
+  iu		basic		=	+pc/ca(ike):3
+  lo		basic		=	+pc/la(basic):3
+  kan		basic		=	+pc/in(kan):3
+  mal		basic		=	+pc/in(mal):3
+  mal		mlplusnum	=	+pc/in(mal):3
+  ogham		basic		=	+pc/ie(ogam):3
+  ogham		laptop		=	+pc/ie(ogam):3
+  ogham		is434		=	+pc/ie(ogam_is434):3
+  ogham		is434laptop	=	+pc/ie(ogam_is434):3
+  ori		basic		=	+pc/in(ori):3
+  sapmi		basic		=	+pc/no(smi):3
+  sapmi		nodeadkeys	=	+pc/no(smi_nodeadkeys):3
+  sapmi		sefi		=	+pc/fi(smi):3
+  sin		phonetic-static	=	+pc/in(sin_phonetic):3
+  syr		basic		=	+pc/sy(syc):3
+  syr		phonetic	=	+pc/sy(syc_phonetic):3
+  tam		INSCRIPT	=	+pc/in(tam):3
+  tam		UNI		=	+pc/in(tam_unicode):3
+  tam		TAB		=	+pc/in(tam_TAB):3
+  tam		TSCII		=	+pc/in(tam_TSCII):3
+  tel		basic		=	+pc/in(tel):3
+  yu		basic		=	+pc/srp(latin):3
+  yu		unicode		=	+pc/srp(latinunicode):3
+  yu		yz		=	+pc/srp(latinyz):3
+  yu		unicodeyz	=	+pc/srp(latinunicodeyz):3
+
+! layout[4]	variant[4]	=	symbols
+  ben		basic		=	+pc/in(ben):4
+  ben		probhat		=	+pc/in(ben_probhat):4
+  dev		basic		=	+pc/in(deva):4
+  dvorak	gb		=	+pc/gb(dvorak):4
+  dvorak	fr		=	+pc/fr(dvorak):4
+  dvorak	no		=	+pc/no(dvorak):4
+  dvorak	se		=	+pc/se(dvorak):4
+  dvorak	basic		=	+pc/us(dvorak):4
+  dvorak	pl_basic	=	+pc/pl(dvorak):4
+  dvorak	pl		=	+pc/pl(dvorak_quotes):4
+  dvorak	pl_altquotes	=	+pc/pl(dvorak_altquotes):4
+  dz		basic		=	+pc/bt(basic):4
+  guj		basic		=	+pc/in(guj):4
+  gur		basic		=	+pc/in(guru):4
+  ie		laptop		=	+pc/ie(basic):4
+  ie		CloGaelachLaptop	=	+pc/ie(CloGaelach):4
+  iu		basic		=	+pc/ca(ike):4
+  lo		basic		=	+pc/la(basic):4
+  kan		basic		=	+pc/in(kan):4
+  mal		basic		=	+pc/in(mal):4
+  mal		mlplusnum	=	+pc/in(mal):4
+  ogham		basic		=	+pc/ie(ogam):4
+  ogham		laptop		=	+pc/ie(ogam):4
+  ogham		is434		=	+pc/ie(ogam_is434):4
+  ogham		is434laptop	=	+pc/ie(ogam_is434):4
+  ori		basic		=	+pc/in(ori):4
+  sapmi		basic		=	+pc/no(smi):4
+  sapmi		nodeadkeys	=	+pc/no(smi_nodeadkeys):4
+  sapmi		sefi		=	+pc/fi(smi):4
+  sin		phonetic-static	=	+pc/in(sin_phonetic):4
+  syr		basic		=	+pc/sy(syc):4
+  syr		phonetic	=	+pc/sy(syc_phonetic):4
+  tam		INSCRIPT	=	+pc/in(tam):4
+  tam		UNI		=	+pc/in(tam_unicode):4
+  tam		TAB		=	+pc/in(tam_TAB):4
+  tam		TSCII		=	+pc/in(tam_TSCII):4
+  tel		basic		=	+pc/in(tel):4
+  yu		basic		=	+pc/srp(latin):4
+  yu		unicode		=	+pc/srp(latinunicode):4
+  yu		yz		=	+pc/srp(latinyz):4
+  yu		unicodeyz	=	+pc/srp(latinunicodeyz):4
+
+! model		=	symbols
+  $inetkbds     =       +inet(%m)
+  *	        =       +sun/solaris(defaults)
+
+! model		layout		=	compat
+  $sun_jp	jp		=	+japan(kana_lock)
+  jp106		jp		=	+japan(kana_lock)
+  pc98		nec/jp		=	pc98(basic)
+  *		*		=	complete
+
+! model		layout[1]	=	compat
+  *		*		=	complete
+
+! model		=	types
+  *		=	complete
+
+! option	=	symbols
+  grp:switch		=	+group(switch)
+  grp:lswitch		=	+group(lswitch)
+  grp:win_switch	=	+group(win_switch)
+  grp:lwin_switch	=	+group(lwin_switch)
+  grp:rwin_switch	=	+group(rwin_switch)
+  grp:toggle		=	+group(toggle)
+  grp:shift_toggle	=	+group(shift_toggle)
+  grp:shifts_toggle	=	+group(shifts_toggle)
+  grp:ctrls_toggle	=	+group(ctrls_toggle)
+  grp:alts_toggle	=	+group(alts_toggle)
+  grp:ctrl_shift_toggle	=	+group(ctrl_shift_toggle)
+  grp:caps_toggle	=	+group(caps_toggle)
+  grp:shift_caps_toggle	=	+group(shift_caps_toggle)
+  grp:ctrl_alt_toggle	=	+group(ctrl_alt_toggle)
+  grp:alt_shift_toggle	=	+group(alt_shift_toggle)
+  grp:menu_toggle	=	+group(menu_toggle)
+  grp:lwin_toggle	=	+group(lwin_toggle)
+  grp:rwin_toggle	=	+group(rwin_toggle)
+  grp:lshift_toggle	=	+group(lshift_toggle)
+  grp:rshift_toggle	=	+group(rshift_toggle)
+  grp:lctrl_toggle	=	+group(lctrl_toggle)
+  grp:rctrl_toggle	=	+group(rctrl_toggle)
+  grp:lalt_toggle	=	+group(lalt_toggle)
+  lv3:switch		=	+level3(switch)
+  lv3:ralt_switch	=	+level3(ralt_switch)
+  lv3:lalt_switch	=	+level3(lalt_switch)
+  lv3:alt_switch	=	+level3(alt_switch)
+  lv3:menu_switch	=	+level3(menu_switch)
+  lv3:win_switch	=	+level3(win_switch)
+  lv3:lwin_switch	=	+level3(lwin_switch)
+  lv3:rwin_switch	=	+level3(rwin_switch)
+  caps:capslock		=	+capslock(capslock)
+  caps:shiftlock	=	+capslock(shiftlock)
+  caps:grouplock	=	+capslock(grouplock)
+  ctrl:nocaps		=	+ctrl(nocaps)
+  ctrl:swapcaps		=	+ctrl(swapcaps)
+  ctrl:ctrl_ac		=	+ctrl(ctrl_ac)
+  ctrl:ctrl_aa		=	+ctrl(ctrl_aa)
+  ctrl:ctrl_ra		=	+ctrl(ctrl_ra)
+  altwin:menu		=	+altwin(menu)
+  altwin:meta_alt	=	+altwin(meta_alt)
+  altwin:meta_win	=	+altwin(meta_win)
+  altwin:left_meta_win	=	+altwin(left_meta_win)
+  altwin:super_win	=	+altwin(super_win)
+  altwin:hyper_win	=	+altwin(hyper_win)
+  altwin:alt_super_win	=	+altwin(alt_super_win)
+  compose:ralt		=	+compose(ralt)
+  compose:rwin		=	+compose(rwin)
+  compose:menu		=	+compose(menu)
+  compose:rctrl		=	+compose(rctrl)
+  srvrkeys:none		=	+srvr_ctrl(no_srvr_keys)
+  eurosign:e		=	+eurosign(e)
+  eurosign:5		=	+eurosign(5)
+  eurosign:2		=	+eurosign(2)
+  grp:switch		=	+group(switch)
+  grp:lswitch		=	+group(lswitch)
+  grp:win_switch	=	+group(win_switch)
+  grp:lwin_switch	=	+group(lwin_switch)
+  grp:rwin_switch	=	+group(rwin_switch)
+  grp:toggle		=	+group(toggle)
+  grp:shifts_toggle	=	+group(shifts_toggle)
+  grp:ctrls_toggle	=	+group(ctrls_toggle)
+  grp:alts_toggle	=	+group(alts_toggle)
+  grp:ctrl_shift_toggle	=	+group(ctrl_shift_toggle)
+  grp:caps_toggle	=	+group(caps_toggle)
+  grp:shift_caps_toggle	=	+group(shift_caps_toggle)
+  grp:ctrl_alt_toggle	=	+group(ctrl_alt_toggle)
+  grp:alt_shift_toggle	=	+group(alt_shift_toggle)
+  grp:menu_toggle	=	+group(menu_toggle)
+  grp:lwin_toggle	=	+group(lwin_toggle)
+  grp:rwin_toggle	=	+group(rwin_toggle)
+  grp:lshift_toggle	=	+group(lshift_toggle)
+  grp:rshift_toggle	=	+group(rshift_toggle)
+  grp:lctrl_toggle	=	+group(lctrl_toggle)
+  grp:rctrl_toggle	=	+group(rctrl_toggle)
+  grp:lalt_toggle	=	+group(lalt_toggle)
+  lv3:switch		=	+level3(switch)
+  lv3:ralt_switch	=	+level3(ralt_switch)
+  lv3:lalt_switch	=	+level3(lalt_switch)
+  lv3:alt_switch	=	+level3(alt_switch)
+  lv3:menu_switch	=	+level3(menu_switch)
+  lv3:win_switch	=	+level3(win_switch)
+  lv3:lwin_switch	=	+level3(lwin_switch)
+  lv3:rwin_switch	=	+level3(rwin_switch)
+  caps:capslock		=	+capslock(capslock)
+  caps:shiftlock	=	+capslock(shiftlock)
+  caps:grouplock	=	+capslock(grouplock)
+  ctrl:nocaps		=	+ctrl(nocaps)
+  ctrl:swapcaps		=	+ctrl(swapcaps)
+  ctrl:ctrl_ac		=	+ctrl(ctrl_ac)
+  ctrl:ctrl_aa		=	+ctrl(ctrl_aa)
+  ctrl:ctrl_ra		=	+ctrl(ctrl_ra)
+  altwin:menu		=	+altwin(menu)
+  altwin:meta_alt	=	+altwin(meta_alt)
+  altwin:meta_win	=	+altwin(meta_win)
+  altwin:left_meta_win	=	+altwin(left_meta_win)
+  altwin:super_win	=	+altwin(super_win)
+  altwin:hyper_win	=	+altwin(hyper_win)
+  altwin:alt_super_win	=	+altwin(alt_super_win)
+  compose:ralt		=	+compose(ralt)
+  compose:rwin		=	+compose(rwin)
+  compose:menu		=	+compose(menu)
+  compose:rctrl		=	+compose(rctrl)
+  srvrkeys:none		=	+srvr_ctrl(no_srvr_keys)
+  eurosign:e		=	+eurosign(e)
+  eurosign:5		=	+eurosign(5)
+  eurosign:2		=	+eurosign(2)
+  solaris:defaults	=	+sun/solaris(defaults)
+  solaris:keynames	=	+sun/solaris(keynames)
+  solaris:xf86keynames	=	+sun/solaris(xf86keynames)
+
+! option	=	compat
+  grp_led:num		=	+lednum(group_lock)
+  grp_led:caps		=	+ledcaps(group_lock)
+  grp_led:scroll	=	+ledscroll(group_lock)
+  grp:caps_toggle	=	+ledcaps(group_lock)
+
+! option	=	types
+  caps:internal			=	+caps(internal)
+  caps:internal_nocancel	=	+caps(internal_nocancel)
+  caps:shift			=	+caps(shift)
+  caps:shift_nocancel		=	+caps(shift_nocancel)
+  numpad:microsoft		=	+numpad(microsoft)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/rules/xorg.lst	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,431 @@
+// $XdotOrg: xc/programs/xkbcomp/rules/xorg.lst,v 1.2 2004/04/23 19:54:52 eich Exp $
+// $Xorg: xfree86.lst,v 1.3 2000/08/17 19:54:42 cpqbld Exp $
+
+! model
+  sun_type6_usb		Sun Type 6 or 7 USB
+  sun_type6_euro_usb	Sun Type 6 or 7 USB (European layout)
+  sun_type6_unix_usb	Sun Type 6 or 7 USB (Unix layout)
+  sun_type6_jp_usb	Sun Type 6 USB (Japanese layout)
+  sun_type7_jp_usb	Sun Type 7 USB (Japanese layout) / Japanese 106-key
+  pc101           Generic 101-key PC
+  pc102           Generic 102-key (Intl) PC
+  pc104           Generic 104-key PC
+  pc105           Generic 105-key (Intl) PC
+  sun_type4		Sun Type 4
+  sun_type4_ca		Sun Type 4 (Canadian  layout)
+  sun_type4_jp		Sun Type 4 (Japanese layout)
+  sun_type4_euro	Sun Type 4 (European layout)
+  sun_type5		Sun Type 5
+  sun_type5_euro	Sun Type 5 (European layout)
+  sun_type5_jp		Sun Type 5 (Japanese layout)
+  sun_type5_unix	Sun Type 5 (Unix layout)
+  sun_type5_hobo	Sun Type 5 Compact 
+  sun_type5_euro_hobo	Sun Type 5 Compact (European layout)
+  sun_type5_jp_hobo	Sun Type 5 Compact (Japanese layout)
+  sun_type6             Sun Type 6
+  sun_type6_euro        Sun Type 6 (European layout)
+  sun_type6_jp		Sun Type 6 (Japanese layout)
+  sun_type6_unix	Sun Type 6 (Unix layout)
+  dell101         Dell 101-key PC
+  everex          Everex STEPnote
+  flexpro         Keytronic FlexPro
+  microsoft       Microsoft Natural
+  omnikey101      Northgate OmniKey 101
+  winbook         Winbook Model XP5
+  jp106           Japanese 106-key
+  pc98            PC-98xx Series
+  a4techKB21      A4Tech KB-21
+  a4techKBS8      A4Tech KBS-8
+  abnt2           Brazilian ABNT2
+  airkey          Acer AirKey V
+  acpi            ACPI Standard
+  azonaRF2300     Azona RF2300 wireless Internet Keyboard
+  scorpius        Advance Scorpius KI
+  brother         Brother Internet Keyboard
+  btc5113rf       BTC 5113RF Multimedia
+  btc5126t        BTC 5126T
+  btc9000         BTC 9000
+  btc9000a        BTC 9000A
+  btc9001ah       BTC 9001AH
+  btc5090         BTC 5090
+  cherryblue      Cherry Blue Line CyBo@rd
+  cherryblueb     Cherry CyMotion Master XPress
+  cherrybluea     Cherry Blue Line CyBo@rd (alternate option)
+  chicony         Chicony Internet Keyboard
+  chicony9885     Chicony KB-9885
+  compaqeak8      Compaq Easy Access Keyboard
+  compaqik7       Compaq Internet Keyboard (7 keys)
+  compaqik13      Compaq Internet Keyboard (13 keys)
+  compaqik18      Compaq Internet Keyboard (18 keys)
+  cymotionlinux   Cherry CyMotion Master Linux
+  armada          Laptop/notebook Compaq (eg. Armada) Laptop Keyboard
+  presario        Laptop/notebook Compaq (eg. Presario) Internet Keyboard
+  ipaq            Compaq iPaq Keyboard
+  dell            Dell
+  inspiron        Laptop/notebook Dell Inspiron 8xxx
+  dexxa           Dexxa Wireless Desktop Keyboard
+  diamond         Diamond 9801 / 9802 series
+  dtk2000         DTK2000
+  ennyah_dkb1008  Ennyah DKB-1008
+  genius          Genius Comfy KB-16M / Genius MM Keyboard KWD-910
+  geniuscomfy2    Genius Comfy KB-21e-Scroll
+  gyration        Gyration
+  hpi6            Hewlett-Packard Internet Keyboard
+  hp2501          Hewlett-Packard SK-2501 Multimedia Keyboard
+  hp2505          Hewlett-Packard SK-2505 Internet Keyboard
+  hpxe3gc         Hewlett-Packard Omnibook XE3 GC
+  hpxe3gf         Hewlett-Packard Omnibook XE3 GF
+  hpxt1000        Hewlett-Packard Omnibook XT1000
+  hpzt11xx        Hewlett-Packard Pavilion ZT11xx
+  hp500fa         Hewlett-Packard Omnibook 500 FA
+  hp5xx           Hewlett-Packard Omnibook 5xx
+  hp6000          Hewlett-Packard Omnibook 6000/6100
+  honeywell_euroboard Honeywell Euroboard
+  rapidaccess     IBM Rapid Access
+  rapidaccess2    IBM Rapid Access II
+  rapidaccess2a   IBM Rapid Access II (alternate option)
+  thinkpad        IBM ThinkPad 560Z/600/600E/A22E
+  logiaccess      Logitech Access Keyboard
+  ltcd            Logitech Cordless Desktop
+  logicdit        Logitech Cordless Desktop iTouch
+  logicdp         Logitech Cordless Desktop Pro
+  logicdpa        Logitech Cordless Desktop Pro (alternate option)
+  logicdpa2       Logitech Cordless Desktop Pro (alternate option2)
+  logicdo         Logitech Cordless Desktop Optical
+  logicfn         Logitech Cordless Freedom/Desktop Navigator
+  logicdn         Logitech Cordless Desktop Navigator
+  logidak         Logitech Deluxe Access Keyboard
+  logiitc         Logitech iTouch Cordless Keyboard (model Y-RB6)
+  logiik          Logitech Internet Keyboard
+  itouch          Logitech iTouch
+  logiitc         Logitech iTouch Cordless Keyboard (model Y-RB6)
+  logiik          Logitech Internet Keyboard
+  logiink         Logitech Internet Navigator Keyboard
+  itouchin        Logitech iTouch keyboard Internet Navigator
+  logiultrax      Logitech Ultra-X Keyboard
+  mx1998          Memorex MX1998
+  mx2500          Memorex MX2500 EZ-Access Keyboard
+  mx2750          Memorex MX2750
+  microsoftinet   Microsoft Internet Keyboard
+  microsoftpro    Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro
+  microsoftprousb Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro
+  microsoftprooem Microsoft Natural Keyboard Pro OEM
+  microsoftprose  Microsoft Internet Keyboard Pro, Swedish
+  microsoftoffice Microsoft Office Keyboard
+  microsoftmult   Microsoft Wireless Multimedia Keyboard 1.0A
+  oretec          Oretec MCK-800 MM/Internet keyboard
+  propeller       Propeller Voyager (KTEZ-1000)
+  qtronix         QTronix Scorpius 98N+
+  samsung4500     Samsung SDM 4500P
+  samsung4510     Samsung SDM 4510P
+  sk1300          SK-1300
+  sk2500          SK-2500
+  sk6200          SK-6200
+  sk7100          SK-7100
+  sp_inet         Super Power Multimedia Keyboard
+  sven            SVEN Ergonomic 2500
+  symplon         Symplon PaceBook (tablet PC)
+  toshiba_s3000   Toshiba Satellite S3000
+  trust           Trust Wireless Keyboard Classic
+  trustda         Trust Direct Access Keyboard
+  yahoo           Yahoo! Internet Keyboard
+  macintosh       Macintosh
+  macintosh_old   Macintosh Old
+  powerpcps2      PowerPC PS/2
+  acer_tm_800     Acer TravelMate 800
+
+! layout
+  us              U.S. English
+  ara             Arabic
+  al              Albania
+  am              Armenia
+  az              Azerbaijan
+  by              Belarus
+  be              Belgium
+  bd              Bangladesh
+  in              India
+  ba              Bosnia and Herzegovina
+  br              Brazil
+  bg              Bulgaria
+  mm              Myanmar
+  ca              Canada
+  hr              Croatia
+  cz              Czechia
+  dk              Denmark
+  nl              Netherlands
+  bt              Bhutan
+  ee              Estonia
+  ir              Iran
+  fo              Faroe Islands
+  fi              Finland
+  fr              France
+  ge              Georgia
+  de              Germany
+  gr              Greece
+  hu              Hungary
+  is              Iceland
+  il              Israel
+  it              Italy
+  jp              Japan
+  kg              Kyrgyzstan
+  la              Laos
+  latam           Latin American
+  lt              Lithuania
+  lv              Latvia
+  mao             Maori
+  mkd             Macedonian
+  mt              Malta
+  mn              Mongolia
+  no              Norway
+  pl              Poland
+  pt              Portugal
+  ro              Romania
+  ru              Russia
+  srp             Serbian
+  si              Slovenia
+  sk              Slovakia
+  es              Spain
+  se              Sweden
+  ch              Switzerland
+  sy              Syria
+  tj              Tajikistan
+  lk              Sri Lanka
+  th              Thailand
+  tr              Turkish 
+  ua              Ukraine
+  gb              United Kingdom
+  uz              Uzbekistan
+  vn              Vietnam
+  nec_vndr/jp     PC-98xx Series
+  ie              Ireland
+  pk              Pakistan
+
+! variant
+  intl            us: International (with dead keys)
+  alt-intl        us: Alternative international (former us_intl)
+  dvorak          us: Dvorak
+  rus             us: Russian phonetic
+  azerty          ara: azerty
+  azerty_digits   ara: azerty/digits
+  digits          ara: digits
+  qwerty          ara: qwerty
+  qwerty_digits   ara: qwerty/digits
+  phonetic        am: Phonetic
+  cyrillic        az: Cyrillic
+  winkeys         by: Winkeys
+  iso-alternate   be: ISO Alternate
+  nodeadkeys      be: Eliminate dead keys
+  sundeadkeys     be: Sun dead keys
+  probhat         bd: Probhat
+  ben             in: Bengali
+  ben_probhat     in: Bengali Probhat
+  guj             in: Gujarati
+  guru            in: Gurmukhi
+  kan             in: Kannada
+  mal             in: Malayalam
+  ori             in: Oriya
+  tam_unicode     in: Tamil Unicode
+  tam_TAB         in: Tamil TAB Typewriter
+  tam_TSCII       in: Tamil TSCII Typewriter
+  tam             in: Tamil
+  tel             in: Telugu
+  urd             in: Urdu
+  nodeadkeys      br: Eliminate dead keys
+  phonetic        bg: Phonetic
+  fr-dvorak       ca: French Dvorak
+  fr-legacy       ca: French (legacy)
+  multi           ca: Multilingual
+  multi-2gr       ca: Multilingual, second part
+  ike             ca: Inuktitut
+  us              hr: US keyboard with Croatian letters
+  bksl            cz: With &lt;\|&gt; key
+  qwerty          cz: qwerty
+  qwerty_bksl     cz: qwerty, extended Backslash
+  nodeadkeys      dk: Eliminate dead keys
+  nodeadkeys      ee: Eliminate dead keys
+  nodeadkeys      fo: Eliminate dead keys
+  nodeadkeys      fi: Eliminate dead keys
+  smi             fi: Northern Saami
+  nodeadkeys      fr: Eliminate dead keys
+  sundeadkeys     fr: Sun dead keys
+  latin9          fr: Alternative
+  latin9_nodeadkeys fr: Alternative, eliminate dead keys
+  latin9_sundeadkeys fr: Alternative, Sun dead keys
+  dvorak          fr: Dvorak
+  ru              ge: Russian
+  deadacute       de: Dead acute
+  deadgraveacute  de: Dead grave acute
+  nodeadkeys      de: Eliminate dead keys
+  ro              de: Romanian keyboard with German letters
+  ro_nodeadkeys   de: Romanian keyboard with German letters, eliminate dead keys
+  dvorak          de: Dvorak
+  extended        gr: Extended
+  nodeadkeys      gr: Eliminate dead keys
+  polytonic       gr: Polytonic
+  standard        hu: Standard
+  nodeadkeys      hu: Eliminate dead keys
+  qwerty          hu: qwerty
+  101_qwertz_comma_dead hu: 101/qwertz/comma/Dead keys
+  101_qwertz_comma_nodead hu: 101/qwertz/comma/Eliminate dead keys
+  101_qwertz_dot_dead hu: 101/qwertz/dot/Dead keys
+  101_qwertz_dot_nodead hu: 101/qwertz/dot/Eliminate dead keys
+  101_qwerty_comma_dead hu: 101/qwerty/comma/Dead keys
+  101_qwerty_comma_nodead hu: 101/qwerty/comma/Eliminate dead keys
+  101_qwerty_dot_dead hu: 101/qwerty/dot/Dead keys
+  101_qwerty_dot_nodead hu: 101/qwerty/dot/Eliminate dead keys
+  102_qwertz_comma_dead hu: 102/qwertz/comma/Dead keys
+  102_qwertz_comma_nodead hu: 102/qwertz/comma/Eliminate dead keys
+  102_qwertz_dot_dead hu: 102/qwertz/dot/Dead keys
+  102_qwertz_dot_nodead hu: 102/qwertz/dot/Eliminate dead keys
+  102_qwerty_comma_dead hu: 102/qwerty/comma/Dead keys
+  102_qwerty_comma_nodead hu: 102/qwerty/comma/Eliminate dead keys
+  102_qwerty_dot_dead hu: 102/qwerty/dot/Dead keys
+  102_qwerty_dot_nodead hu: 102/qwerty/dot/Eliminate dead keys
+  Sundeadkeys     is: Sun dead keys
+  nodeadkeys      is: Eliminate dead keys
+  lyx             il: lyx
+  si1452          il: si1452
+  phonetic        il: Phonetic
+  nodeadkeys      it: Eliminate dead keys
+  nodeadkeys      latam: Eliminate dead keys
+  sundeadkeys     latam: Sun dead keys
+  std             lt: "Standard"
+  us              lt: US keyboard with Lithuanian letters
+  apostrophe      lv: Apostrophe (') variant
+  tilde           lv: Tilde (~) variant
+  fkey            lv: F-letter (F) variant
+  nodeadkeys      mkd: Eliminate dead keys
+  us              mt: US keyboard with Maltian letters
+  nodeadkeys      no: Eliminate dead keys
+  dvorak          no: Dvorak
+  smi             no: Northern Saami
+  smi_nodeadkeys  no: Northern Saami, eliminate dead keys
+  qwertz          pl: qwertz
+  dvorak          pl: Dvorak
+  dvorak_quotes   pl: Dvorak, Polish quotes on quotemark key
+  dvorak_altquotes pl: Dvorak, Polish quotes on key "1/!"
+  nodeadkeys      pt: Eliminate dead keys
+  sundeadkeys     pt: Sun dead keys
+  us              ro: US keyboard with Romanian letters
+  de              ro: Romanian keyboard with German letters
+  phonetic        ru: Phonetic
+  typewriter      ru: Typewriter
+  winkeys         ru: Winkeys
+  yz              srp: Z and ZHE swapped
+  latin           srp: Latin
+  latinunicode    srp: Latin Unicode
+  latinyz         srp: Latin qwerty
+  latinunicodeyz  srp: Latin Unicode qwerty
+  alternatequotes srp: With guillemots
+  latinalternatequotes srp: Latin with guillemots
+  bksl            sk: Extended Backslash
+  qwerty          sk: qwerty
+  qwerty_bksl     sk: qwerty, extended Backslash
+  nodeadkeys      es: Eliminate dead keys
+  sundeadkeys     es: Sun dead keys
+  dvorak          es: Dvorak
+  nodeadkeys      se: Eliminate dead keys
+  dvorak          se: Dvorak
+  rus             se: Russian phonetic
+  rus_nodeadkeys  se: Russian phonetic, eliminate dead keys
+  smi             se: Northern Saami
+  de_nodeadkeys   ch: German, eliminate dead keys
+  de_sundeadkeys  ch: German, Sun dead keys
+  fr              ch: French
+  fr_nodeadkeys   ch: French, eliminate dead keys
+  fr_sundeadkeys  ch: French, Sun dead keys
+  syc             sy: Syriac
+  syc_phonetic    sy: Syriac phonetic
+  tam_unicode     lk: Tamil Unicode
+  tam_TAB         lk: Tamil TAB Typewriter
+  tam_TSCII       lk: Tamil TSCII Typewriter
+  sin_phonetic    lk: Sinhala phonetic
+  tis             th: TIS-820.2538
+  pat             th: Pattachote
+  f               tr: (F)
+  alt             tr: Alt-Q
+  phonetic        ua: Phonetic
+  typewriter      ua: Typewriter
+  winkeys         ua: Winkeys
+  rstu            ua: Standard RSTU
+  rstu_ru         ua: Standard RSTU on Russian layout
+  intl            gb: International (with dead keys)
+  dvorak          gb: Dvorak
+  CloGaelach      ie: CloGaelach
+  UnicodeExpert   ie: UnicodeExpert
+  ogam            ie: Ogham
+  ogam_is434      ie: Ogham IS434
+
+! option
+  grp                  Group Shift/Lock behavior
+  grp:switch           R-Alt switches group while pressed.
+  grp:lswitch          Left Alt key switches group while pressed.
+  grp:lwin_switch      Left Win-key switches group while pressed.
+  grp:rwin_switch      Right Win-key switches group while pressed.
+  grp:win_switch       Both Win-keys switch group while pressed.
+  grp:rctrl_switch     Right Ctrl key switches group while pressed.
+  grp:toggle           Right Alt key changes group.
+  grp:lalt_toggle      Left Alt key changes group.
+  grp:caps_toggle      CapsLock key changes group.
+  grp:shift_caps_toggle Shift+CapsLock changes group.
+  grp:shifts_toggle    Both Shift keys together change group.
+  grp:alts_toggle      Both Alt keys together change group.
+  grp:ctrls_toggle     Both Ctrl keys together change group.
+  grp:ctrl_shift_toggle Control+Shift changes group.
+  grp:ctrl_alt_toggle  Alt+Control changes group.
+  grp:alt_shift_toggle Alt+Shift changes group.
+  grp:menu_toggle      Menu key changes group.
+  grp:lwin_toggle      Left Win-key changes group.
+  grp:rwin_toggle      Right Win-key changes group.
+  grp:lshift_toggle    Left Shift key changes group.
+  grp:rshift_toggle    Right Shift key changes group.
+  grp:lctrl_toggle     Left Ctrl key changes group.
+  grp:rctrl_toggle     Right Ctrl key changes group.
+  lv3                  Third level choosers
+  lv3:switch           Press Right Control to choose 3rd level.
+  lv3:menu_switch      Press Menu key to choose 3rd level.
+  lv3:win_switch       Press any of Win-keys to choose 3rd level.
+  lv3:lwin_switch      Press Left Win-key to choose 3rd level.
+  lv3:rwin_switch      Press Right Win-key to choose 3rd level.
+  lv3:alt_switch       Press any of Alt keys to choose 3rd level.
+  lv3:lalt_switch      Press Left Alt key to choose 3rd level.
+  lv3:ralt_switch      Press Right Alt key to choose 3rd level.
+  ctrl                 Control key position
+  ctrl:nocaps          Make CapsLock an additional Control.
+  ctrl:swapcaps        Swap Control and CapsLock.
+  ctrl:ctrl_ac         Control key at left of 'A'
+  ctrl:ctrl_aa         Control key at bottom left
+  ctrl:ctrl_ra         Right Control key works as Right Alt.
+  grp_led              Use keyboard LED to show alternative group.
+  grp_led:num          NumLock LED shows alternative group.
+  grp_led:caps         CapsLock LED shows alternative group.
+  grp_led:scroll       ScrollLock LED shows alternative group.
+  caps                 CapsLock key behavior
+  caps:internal        CapsLock uses internal capitalization. Shift cancels CapsLock.
+  caps:internal_nocancel CapsLock uses internal capitalization. Shift doesn't cancel CapsLock.
+  caps:shift           CapsLock acts as Shift with locking. Shift cancels CapsLock.
+  caps:shift_nocancel  CapsLock acts as Shift with locking. Shift doesn't cancel CapsLock.
+  caps:shift_lock      CapsLock just locks the Shift modifier.
+  caps:capslock        CapsLock toggles normal capitalization of alphabetic characters.
+  caps:shiftlock       CapsLock toggles Shift so all keys are affected.
+  altwin               Alt/Win key behavior
+  altwin:menu          Add the standard behavior to Menu key.
+  altwin:meta_alt      Alt and Meta are on the Alt keys (default).
+  altwin:meta_win      Meta is mapped to the Win-keys.
+  altwin:left_meta_win Meta is mapped to the left Win-key.
+  altwin:super_win     Super is mapped to the Win-keys (default).
+  altwin:hyper_win     Hyper is mapped to the Win-keys.
+  altwin:alt_super_win Alt is mapped to the right Win-key and Super to Menu.
+  Compose key          Compose key position
+  compose:ralt         Right Alt is Compose.
+  compose:rwin         Right Win-key is Compose.
+  compose:menu         Menu is Compose.
+  compose:rctrl        Right Ctrl is Compose.
+  compat               Miscellaneous compatibility options
+  japan:kana_lock      Kana Lock key is locking
+  numpad:microsoft     Shift with numpad keys works as in MS Windows.
+  srvrkeys:none        Special keys (Ctrl+Alt+&lt;key&gt;) handled in a server.
+  eurosign             Adding the EuroSign to certain keys
+  eurosign:e           Add the EuroSign to the E key.
+  eurosign:5           Add the EuroSign to the 5 key.
+  eurosign:2           Add the EuroSign to the 2 key.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/rules/xorg.xml	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,8052 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
+<xkbConfigRegistry>
+  <modelList>
+    <model>
+      <configItem>
+        <name>sun_type4</name>
+        <description>Sun Microsystems Type 4</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type4_ca</name>
+        <description>Sun Microsystems Type 4 (Canadian)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type4_jp</name>
+        <description>Sun Microsystems Type 4 (Japanese)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type4_euro</name>
+        <description>Sun Microsystems Type 4 (European)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5</name>
+        <description>Sun Microsystems Type 5</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5_euro</name>
+        <description>Sun Microsystems Type 5 (European)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5_jp</name>
+        <description>Sun Microsystems Type 5 (Japanese)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5_unix</name>
+        <description>Sun Microsystems Type 5 (Unix)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5_hobo</name>
+        <description>Sun Microsystems Type 5 Hobo</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5_euro_hobo</name>
+        <description>Sun Microsystems Type 5 Hobo (European)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5_jp_hobo</name>
+        <description>Sun Microsystems Type 5 Hobo (Japanese)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type5_unix_hobo</name>
+        <description>Sun Microsystems Type 5 Hobo (Unix)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6</name>
+        <description>Sun Microsystems Type 6</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6_euro</name>
+        <description>Sun Microsystems Type 6 (European)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6_jp</name>
+        <description>Sun Microsystems Type 6 (Japanese)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6_unix</name>
+        <description>Sun Microsystems Type 6 (Unix)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6_usb</name>
+        <description>Sun Microsystems Type 6 or 7 USB</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6_euro_usb</name>
+        <description>Sun Microsystems Type 6 or 7 USB (European)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6_jp_usb</name>
+        <description>Sun Microsystems Type 6 USB (Japanese)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type7_jp_usb</name>
+        <description>Sun Microsystems Type 7 USB (Japanese)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sun_type6_unix_usb</name>
+        <description>Sun Microsystems Type 6 or 7 USB (Unix)</description>
+      </configItem>
+    </model>
+
+    <model>
+      <configItem>
+        <name>pc101</name>
+        <description>Generic 101-key PC</description>
+        <description xml:lang="af">Generies 101-sleutel PC</description>
+        <description xml:lang="az">Generic 101-key PC</description>
+        <description xml:lang="bg">Стандартна 101 клавишна PC клавиатура</description>
+        <description xml:lang="cs">Obecné PC 101 kláves</description>
+        <description xml:lang="da">Generisk 101-taster PC</description>
+        <description xml:lang="el">Τυπικός Ηλεκ. Υπολογιστής 101-πλήκτρων</description>
+        <description xml:lang="en_GB">Generic 101-key PC</description>
+        <description xml:lang="fr">clavier Generic 101-key PC</description>
+        <description xml:lang="hu">általános 101 gombos PC</description>
+        <description xml:lang="nl">Algemeen 101-toetsen PC</description>
+        <description xml:lang="ru">Обычный 101-клавишный PC</description>
+        <description xml:lang="rw">Urufunguzo</description>
+        <description xml:lang="sk">Všeobecná PC 101 kláves</description>
+        <description xml:lang="sq">Generic 101-key PC</description>
+        <description xml:lang="sr">Обична са 101 тастером</description>
+        <description xml:lang="sv">Allmän 101-tangenters PC</description>
+        <description xml:lang="tr">Soysal 101 tuşlu PC</description>
+        <description xml:lang="uk">Звичайна 101-клавішна для ПК</description>
+        <description xml:lang="vi">PC chung 101 phím</description>
+        <description xml:lang="zh_CN">通用 101 键电脑</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>pc102</name>
+        <description>Generic 102-key (Intl) PC</description>
+        <description xml:lang="af">Generies 102-sleutel (Intl) PC</description>
+        <description xml:lang="az">Generic 102-key (Intl) PC</description>
+        <description xml:lang="bg">Стандартна 102 клавишна PC клавиатура</description>
+        <description xml:lang="cs">Obecné PC 102 kláves (mez.)</description>
+        <description xml:lang="da">Generisk 102-taster (Intl) PC</description>
+        <description xml:lang="el">Τυπικός Ηλεκ. Υπολογιστής 102-πλήκτρων (Διεθνές)</description>
+        <description xml:lang="en_GB">Generic 102-key (Intl) PC</description>
+        <description xml:lang="fr">clavier Generic 102-key (Intl) PC</description>
+        <description xml:lang="hu">általános 102 gombos (nemzetközi) PC</description>
+        <description xml:lang="nl">Algemeen 102-toetsen (internationaal) PC</description>
+        <description xml:lang="ru">Обычный 102-клавишный PC</description>
+        <description xml:lang="rw">Urufunguzo</description>
+        <description xml:lang="sk">Všeobecná PC 102 kláves (medz.)</description>
+        <description xml:lang="sq">Generic 102-key (Intl) PC</description>
+        <description xml:lang="sr">Обична са 102 тастера (међунар.)</description>
+        <description xml:lang="sv">Allmän 102-tangenters (internationell) PC</description>
+        <description xml:lang="tr">Soysal 102 tuşlu (Uluslararası) PC</description>
+        <description xml:lang="uk">Звичайна 102-клавішна для ПК</description>
+        <description xml:lang="vi">PC chung 102 phím (Intl)</description>
+        <description xml:lang="zh_CN">通用 102 键(国际)电脑</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>pc104</name>
+        <description>Generic 104-key PC</description>
+        <description xml:lang="af">Generies 104-sleutel PC</description>
+        <description xml:lang="az">Generic 104-key PC</description>
+        <description xml:lang="bg">Стандартна 104 клавишна PC клавиатура</description>
+        <description xml:lang="cs">Obecné PC 104 kláves</description>
+        <description xml:lang="da">Generisk 104-taster PC</description>
+        <description xml:lang="el">Τυπικός Ηλεκ. Υπολογιστής 104-πλήκτρων</description>
+        <description xml:lang="en_GB">Generic 104-key PC</description>
+        <description xml:lang="fr">clavier Generic 104-key PC</description>
+        <description xml:lang="hu">általános 104 gombos PC</description>
+        <description xml:lang="nl">Algemeen 104-toetsen PC</description>
+        <description xml:lang="ru">Обычный 104-клавишный PC</description>
+        <description xml:lang="rw">Urufunguzo</description>
+        <description xml:lang="sk">Všeobecná PC 104 kláves</description>
+        <description xml:lang="sq">Generic 104-key PC</description>
+        <description xml:lang="sr">Обична са 104 тастера</description>
+        <description xml:lang="sv">Allmän 104-tangenters PC</description>
+        <description xml:lang="tr">Soysal 104 tuşlu PC</description>
+        <description xml:lang="uk">Звичайна 104-клавішна для ПК</description>
+        <description xml:lang="vi">PC chung 104 phím</description>
+        <description xml:lang="zh_CN">通用 104 键电脑</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>pc105</name>
+        <description>Generic 105-key (Intl) PC</description>
+        <description xml:lang="af">Generies 105-sleutel (Intl) PC</description>
+        <description xml:lang="az">Generic 105-key (Intl) PC</description>
+        <description xml:lang="bg">Стандартна 105 клавишна PC клавиатура</description>
+        <description xml:lang="cs">Obecné PC 105 kláves (mez.)</description>
+        <description xml:lang="da">Generisk 105-taster (Intl) PC</description>
+        <description xml:lang="el">Τυπικός Ηλεκ. Υπολογιστής 105-πλήκτρων (Διεθνές)</description>
+        <description xml:lang="en_GB">Generic 105-key (Intl) PC</description>
+        <description xml:lang="fr">clavier Generic 105-key (Intl) PC</description>
+        <description xml:lang="hu">általános 105 gombos (nemzetközi) PC</description>
+        <description xml:lang="nl">Algemeen 105-toetsen (internationaal) PC</description>
+        <description xml:lang="ru">Обычный 105-клавишный (инт.) РС</description>
+        <description xml:lang="rw">Urufunguzo</description>
+        <description xml:lang="sk">Všeobecná 105-kláv. (medzinár.) PC</description>
+        <description xml:lang="sq">Generic 105-key (Intl) PC</description>
+        <description xml:lang="sr">Обична са 105 тастера (међунар.)</description>
+        <description xml:lang="sv">Allmän 105-tangenters (internationell) PC</description>
+        <description xml:lang="tr">Soysal 105 tuşlu (uluslararası) PC</description>
+        <description xml:lang="uk">Звичайна 105-клавішна для ПК</description>
+        <description xml:lang="vi">PC chung 105 phím (Intl)</description>
+        <description xml:lang="zh_CN">通用 105 键(国际)电脑</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>dell101</name>
+        <description>Dell 101-key PC</description>
+        <description xml:lang="af">Dell 101-key PC</description>
+        <description xml:lang="az">Dell 101-key PC</description>
+        <description xml:lang="bg">101 клавишна PC клавиатура на Dell</description>
+        <description xml:lang="cs">Dell PC 101 kláves</description>
+        <description xml:lang="da">Dell 101-taster PC</description>
+        <description xml:lang="en_GB">Dell 101-key PC</description>
+        <description xml:lang="fr">clavier Dell 101-key PC</description>
+        <description xml:lang="hu">Dell 101-key PC</description>
+        <description xml:lang="nl">Dell 101-toetsen PC</description>
+        <description xml:lang="ru">Dell 101-клавишный PC</description>
+        <description xml:lang="rw">Urufunguzo</description>
+        <description xml:lang="sk">DELL PC 101 kláves</description>
+        <description xml:lang="sq">Dell 101-key PC</description>
+        <description xml:lang="sr">Dell 101-тастер PC</description>
+        <description xml:lang="sv">Dell 101-tangenters PC</description>
+        <description xml:lang="tr">Dell 101 tuşlu PC</description>
+        <description xml:lang="uk">Dell 101-клавішна для ПК</description>
+        <description xml:lang="vi">Dell PC 101 phím</description>
+        <description xml:lang="zh_CN">Dell 101 键电脑</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>everex</name>
+        <description>Everex STEPnote</description>
+        <description xml:lang="af">Everex STEPnote</description>
+        <description xml:lang="az">Everex STEPnote</description>
+        <description xml:lang="bg">Everex STEPnote</description>
+        <description xml:lang="cs">Everex STEPnote</description>
+        <description xml:lang="da">Everex STEPnote</description>
+        <description xml:lang="en_GB">Everex STEPnote</description>
+        <description xml:lang="fr">Everex STEPnote</description>
+        <description xml:lang="hu">Everex STEPnote</description>
+        <description xml:lang="nl">Everex STEPnote</description>
+        <description xml:lang="ru">Everex STEPnote</description>
+        <description xml:lang="sk">Everex STEPnote</description>
+        <description xml:lang="sq">Everex STEPnote</description>
+        <description xml:lang="sr">Everex STEPnote</description>
+        <description xml:lang="sv">Everex STEPnote</description>
+        <description xml:lang="tr">Everex STEPnote</description>
+        <description xml:lang="uk">Everex STEPnote</description>
+        <description xml:lang="vi">Everex STEPnote</description>
+        <description xml:lang="zh_CN">Everex STEPnote</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>flexpro</name>
+        <description>Keytronic FlexPro</description>
+        <description xml:lang="af">Keytronic FlexPro</description>
+        <description xml:lang="az">Keytronic FlexPro</description>
+        <description xml:lang="bg">Keytronic FlexPro</description>
+        <description xml:lang="cs">Keytronic FlexPro</description>
+        <description xml:lang="da">Keytronic FlexPro</description>
+        <description xml:lang="en_GB">Keytronic FlexPro</description>
+        <description xml:lang="fr">Keytronic FlexPro</description>
+        <description xml:lang="hu">Keytronic FlexPro</description>
+        <description xml:lang="nl">Keytronic FlexPro</description>
+        <description xml:lang="ru">Keytronic FlexPro</description>
+        <description xml:lang="sk">Keytronic FlexPro</description>
+        <description xml:lang="sq">Keytronic FlexPro</description>
+        <description xml:lang="sr">Keytronic FlexPro</description>
+        <description xml:lang="sv">Keytronic FlexPro</description>
+        <description xml:lang="tr">Keytronic FlexPro</description>
+        <description xml:lang="uk">Keytronic FlexPro</description>
+        <description xml:lang="vi">Keytronic FlexPro</description>
+        <description xml:lang="zh_CN">Keytronic FlexPro</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoft</name>
+        <description>Microsoft Natural</description>
+        <description xml:lang="af">Microsoft Natuurlik</description>
+        <description xml:lang="az">Microsoft Natural</description>
+        <description xml:lang="bg">Microsoft Natural</description>
+        <description xml:lang="cs">Microsoft Natural</description>
+        <description xml:lang="da">Microsoft Natural</description>
+        <description xml:lang="en_GB">Microsoft Natural</description>
+        <description xml:lang="fr">Microsoft Natural</description>
+        <description xml:lang="hu">Microsoft Natural</description>
+        <description xml:lang="nl">Microsoft Natural</description>
+        <description xml:lang="ru">Microsoft Natural</description>
+        <description xml:lang="sk">Microsoft Natural</description>
+        <description xml:lang="sq">Microsoft Natural</description>
+        <description xml:lang="sr">Микрософт Натурал</description>
+        <description xml:lang="sv">Microsoft Natural</description>
+        <description xml:lang="tr">Microsoft Basit</description>
+        <description xml:lang="uk">Microsoft Natural</description>
+        <description xml:lang="vi">Microsoft Natural</description>
+        <description xml:lang="zh_CN">微软自然键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>omnikey101</name>
+        <description>Northgate OmniKey 101</description>
+        <description xml:lang="af">Northgate OmniKey 101</description>
+        <description xml:lang="az">Northgate OmniKey 101</description>
+        <description xml:lang="bg">Northgate OmniKey 101</description>
+        <description xml:lang="cs">Northgate OmniKey 101</description>
+        <description xml:lang="da">Northgate OmniKey 101</description>
+        <description xml:lang="en_GB">Northgate OmniKey 101</description>
+        <description xml:lang="fr">Northgate OmniKey 101</description>
+        <description xml:lang="hu">Northgate OmniKey 101</description>
+        <description xml:lang="nl">Northgate OmniKey 101</description>
+        <description xml:lang="ru">Northgate OmniKey 101</description>
+        <description xml:lang="sk">Northgate OmniKey 101</description>
+        <description xml:lang="sq">Northgate OmniKey 101</description>
+        <description xml:lang="sr">Northgate OmniKey 101</description>
+        <description xml:lang="sv">Northgate OmniKey 101</description>
+        <description xml:lang="tr">Northgate OmniKey 101</description>
+        <description xml:lang="uk">Northgate OmniKey 101</description>
+        <description xml:lang="vi">Northgate OmniKey 101</description>
+        <description xml:lang="zh_CN">Northgate OmniKey 101</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>winbook</name>
+        <description>Winbook Model XP5</description>
+        <description xml:lang="af">Winbook Model XP5</description>
+        <description xml:lang="az">Winbook Model XP5</description>
+        <description xml:lang="bg">Winbook Model XP5</description>
+        <description xml:lang="cs">Winbook Model XP5</description>
+        <description xml:lang="da">Winbook Model XP5</description>
+        <description xml:lang="en_GB">Winbook Model XP5</description>
+        <description xml:lang="fr">Winbook Model XP5</description>
+        <description xml:lang="hu">Winbook Model XP5</description>
+        <description xml:lang="nl">Winbook Model XP5</description>
+        <description xml:lang="ru">Winbook Model XP5</description>
+        <description xml:lang="sk">Winbook Model XP5</description>
+        <description xml:lang="sq">Winbook Model XP5</description>
+        <description xml:lang="sr">Winbook Model XP5</description>
+        <description xml:lang="sv">Winbook Model XP5</description>
+        <description xml:lang="tr">Winbook Model XP5</description>
+        <description xml:lang="uk">Winbook Model XP5</description>
+        <description xml:lang="vi">Winbook kiểu mẫu XP5</description>
+        <description xml:lang="zh_CN">Winbook Model XP5</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>jp106</name>
+        <description>Japanese 106-key</description>
+        <description xml:lang="af">Japanees 106-sleutel</description>
+        <description xml:lang="az">Yaponca 106-düymə</description>
+        <description xml:lang="bg">японска 106 клавишна</description>
+        <description xml:lang="cs">Japonské 106 kláves</description>
+        <description xml:lang="da">Japansk 106-taster</description>
+        <description xml:lang="en_GB">Japanese 106-key</description>
+        <description xml:lang="fr">Japanese 106-clés</description>
+        <description xml:lang="hu">japán 106 gombos</description>
+        <description xml:lang="nl">Japans 106-toetsen</description>
+        <description xml:lang="ru">Японская 106-клавишная</description>
+        <description xml:lang="rw">Urufunguzo</description>
+        <description xml:lang="sk">Japonskáé106 kláves</description>
+        <description xml:lang="sq">Japoneze 106-pulsantë</description>
+        <description xml:lang="sr">јапански са 106 тастера</description>
+        <description xml:lang="sv">Japansk 106-tangenters</description>
+        <description xml:lang="tr">Japonca 106 tuşlu</description>
+        <description xml:lang="uk">Японська 106-клавішна</description>
+        <description xml:lang="vi">Nhật bản 106 phím</description>
+        <description xml:lang="zh_CN">日语 106 键</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>pc98</name>
+        <description>PC-98xx Series</description>
+        <description xml:lang="af">PC-98xx Reeks</description>
+        <description xml:lang="az">PC-98xx Seriyaları</description>
+        <description xml:lang="bg">PC-98xx серии</description>
+        <description xml:lang="cs">PC-98xx řada</description>
+        <description xml:lang="da">PC-98xx-serien</description>
+        <description xml:lang="en_GB">PC-98xx Series</description>
+        <description xml:lang="fr">PC-98xx Series</description>
+        <description xml:lang="hu">PC-98xx Series</description>
+        <description xml:lang="nl">PC-98xx serie</description>
+        <description xml:lang="ru">PC-98xx</description>
+        <description xml:lang="sk">Séria PC-98xx</description>
+        <description xml:lang="sq">Seritë PC-98xx</description>
+        <description xml:lang="sr">PC-98xx серија</description>
+        <description xml:lang="sv">PC-98xx-serien</description>
+        <description xml:lang="tr">PC-98xx Serisi</description>
+        <description xml:lang="uk">Моделі PC-98xx</description>
+        <description xml:lang="vi">Sê ri PC-98xx</description>
+        <description xml:lang="zh_CN">PC-98xx 系列</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>a4techKB21</name>
+        <description>A4Tech KB-21</description>
+        <description xml:lang="en_GB">A4Tech KB-21</description>
+        <description xml:lang="nl">A4Tech KB-21</description>
+        <description xml:lang="ru">A4Tech KB-21</description>
+        <description xml:lang="rw">21</description>
+        <description xml:lang="vi">A4Tech KB-21</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>a4techKBS8</name>
+        <description>A4Tech KBS-8</description>
+        <description xml:lang="en_GB">A4Tech KBS-8</description>
+        <description xml:lang="nl">A4Tech KBS-8</description>
+        <description xml:lang="ru">A4Tech KBS-8</description>
+        <description xml:lang="rw">8</description>
+        <description xml:lang="vi">A4Tech KBS-8</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>abnt2</name>
+        <description>Brazilian ABNT2</description>
+        <description xml:lang="af">Braziliaans ABNT2</description>
+        <description xml:lang="az">Brazilya düzülüşü ABNT2</description>
+        <description xml:lang="bg">бразилска ABNT2</description>
+        <description xml:lang="cs">Brazilské ABNT2</description>
+        <description xml:lang="da">Brasiliansk ABNT2</description>
+        <description xml:lang="en_GB">Brazilian ABNT2</description>
+        <description xml:lang="fr">Brézilien ABNT2</description>
+        <description xml:lang="hu">brazil ABNT2</description>
+        <description xml:lang="nl">Braziliaans ABNT2</description>
+        <description xml:lang="ru">ABNT2</description>
+        <description xml:lang="sk">Brazílska ABNT2</description>
+        <description xml:lang="sq">Braziliane ABNT2</description>
+        <description xml:lang="sr">бразилски ABNT2</description>
+        <description xml:lang="sv">Brasiliansk ABNT2</description>
+        <description xml:lang="tr">Brazilya dili ABNT2</description>
+        <description xml:lang="uk">Бразильська ABTN2</description>
+        <description xml:lang="vi">ABNT2 của Bra-zil</description>
+        <description xml:lang="zh_CN">巴西 ABNT2</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>airkey</name>
+        <description>Acer AirKey V</description>
+        <description xml:lang="af">Acer AirKey V</description>
+        <description xml:lang="az">Acer AirKey V</description>
+        <description xml:lang="cs">Acer AirKey V</description>
+        <description xml:lang="da">Acer AirKey V</description>
+        <description xml:lang="en_GB">Acer AirKey V</description>
+        <description xml:lang="fr">Acer AirKey V</description>
+        <description xml:lang="hu">Acer AirKey V</description>
+        <description xml:lang="nl">Acer AirKey V</description>
+        <description xml:lang="ru">Acer AirKey V</description>
+        <description xml:lang="rw">V</description>
+        <description xml:lang="sk">Acer AirKey V</description>
+        <description xml:lang="sq">Acer AirKey V</description>
+        <description xml:lang="sr">Acer AirKey V</description>
+        <description xml:lang="sv">Acer AirKey V</description>
+        <description xml:lang="tr">Acer AirKey V</description>
+        <description xml:lang="uk">Acer AirKey V</description>
+        <description xml:lang="vi">Acer AirKey V</description>
+        <description xml:lang="zh_CN">Acer AirKey V</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>acpi</name>
+        <description>ACPI Standard</description>
+        <description xml:lang="af">ACPI Standaard</description>
+        <description xml:lang="az">ACPI Standartı</description>
+        <description xml:lang="cs">Standard ACPI</description>
+        <description xml:lang="da">ACPI-standard</description>
+        <description xml:lang="en_GB">ACPI Standard</description>
+        <description xml:lang="fr">norme ACPI</description>
+        <description xml:lang="hu">ACPI szabvány</description>
+        <description xml:lang="nl">ACPI standaard</description>
+        <description xml:lang="ru">Стандартная ACPI</description>
+        <description xml:lang="sk">Štandard ACPI</description>
+        <description xml:lang="sq">ACPI Standart</description>
+        <description xml:lang="sr">ACPI стандард</description>
+        <description xml:lang="sv">ACPI-standard</description>
+        <description xml:lang="tr">ACPI Standardı</description>
+        <description xml:lang="uk">Типова ACPI</description>
+        <description xml:lang="vi">ACPI Tiêu chuẩn</description>
+        <description xml:lang="zh_CN">ACPI 标准</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>azonaRF2300</name>
+        <description>Azona RF2300 wireless Internet Keyboard</description>
+        <description xml:lang="en_GB">Azona RF2300 wireless Internet Keyboard</description>
+        <description xml:lang="nl">Azona RF2300 draadloos internettoetsenbord</description>
+        <description xml:lang="ru">Azona RF2300 wireless Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím không dây Internet Azona RF2300</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>scorpius</name>
+        <description>Advance Scorpius KI</description>
+        <description xml:lang="af">Advance Scorpius KI</description>
+        <description xml:lang="az">Advance Scorpius KI</description>
+        <description xml:lang="cs">Advance Scorpius KI</description>
+        <description xml:lang="da">Advance Scorpius KI</description>
+        <description xml:lang="en_GB">Advance Scorpius KI</description>
+        <description xml:lang="fr">Advance Scorpius KI</description>
+        <description xml:lang="hu">Advance Scorpius KI</description>
+        <description xml:lang="nl">Advance Scorpius KI</description>
+        <description xml:lang="ru">Advance Scorpius KI</description>
+        <description xml:lang="sk">Advance Scorpius KI</description>
+        <description xml:lang="sq">Advance Scorpius KI</description>
+        <description xml:lang="sr">Напредни Шкорпион КИ</description>
+        <description xml:lang="sv">Advance Scorpius KI</description>
+        <description xml:lang="tr">Advance Scorpius KI</description>
+        <description xml:lang="uk">Advance Scorpius KI</description>
+        <description xml:lang="vi">Nâng cao Scorpius KI</description>
+        <description xml:lang="zh_CN">高级 Scorpius KI</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>brother</name>
+        <description>Brother Internet Keyboard</description>
+        <description xml:lang="af">Brother Internetsleutelbord</description>
+        <description xml:lang="az">Brother Internet Keyboard</description>
+        <description xml:lang="bg">Logitech Интернет клавиатура</description>
+        <description xml:lang="cs">Brother Internet Keyboard</description>
+        <description xml:lang="da">Brother Internet Keyboard</description>
+        <description xml:lang="en_GB">Brother Internet Keyboard</description>
+        <description xml:lang="fr">clavier Brother Internet</description>
+        <description xml:lang="hu">Brother Internet Keyboard</description>
+        <description xml:lang="nl">Brother internet toetsenbord</description>
+        <description xml:lang="ru">Brother Internet Keyboard</description>
+        <description xml:lang="sk">Brother Internet Keyboard</description>
+        <description xml:lang="sq">Tastiera Internet Brother</description>
+        <description xml:lang="sr">Brother Интернет тастатура</description>
+        <description xml:lang="sv">Brother Internettangentbord</description>
+        <description xml:lang="tr">Brother Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Brother Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím Internet Brother</description>
+        <description xml:lang="zh_CN">Brother 网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>btc5113rf</name>
+        <description>BTC 5113RF Multimedia</description>
+        <description xml:lang="af">BTC 5113RF Multimedia</description>
+        <description xml:lang="az">BTC 5113RF Multimedia</description>
+        <description xml:lang="cs">BTC 5113RF Multimedia</description>
+        <description xml:lang="da">BTC 5113RF-multimedie</description>
+        <description xml:lang="en_GB">BTC 5113RF Multimedia</description>
+        <description xml:lang="fr">BTC 5113RF Multimedia</description>
+        <description xml:lang="hu">BTC 5113RF Multimedia</description>
+        <description xml:lang="nl">BTC 5113RF multimedia</description>
+        <description xml:lang="ru">BTC 5113RF Multimedia</description>
+        <description xml:lang="sk">BTC 5113RF Multimedia</description>
+        <description xml:lang="sq">BTC 5113RF Multimedia</description>
+        <description xml:lang="sr">BTC 5113RF мултимедијална</description>
+        <description xml:lang="sv">BTC 5113RF Multimedia</description>
+        <description xml:lang="tr">BTC 5113RF Çokluortam</description>
+        <description xml:lang="uk">BTC 5113RF мультимедія</description>
+        <description xml:lang="vi">BTC 5113RF Phim nhạc</description>
+        <description xml:lang="zh_CN">BTC 5113RF 多媒体</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>btc5126t</name>
+        <description>BTC 5126T</description>
+        <description xml:lang="af">BTC 5126T</description>
+        <description xml:lang="az">BTC 5126T</description>
+        <description xml:lang="cs">BTC 5126T</description>
+        <description xml:lang="da">BTC 5126T</description>
+        <description xml:lang="en_GB">BTC 5126T</description>
+        <description xml:lang="fr">BTC 5126T</description>
+        <description xml:lang="hu">BTC 5126T</description>
+        <description xml:lang="nl">BTC 5126T</description>
+        <description xml:lang="ru">BTC 5126T</description>
+        <description xml:lang="sk">BTC 5126T</description>
+        <description xml:lang="sq">BTC 5126T</description>
+        <description xml:lang="sr">BTC 5126T</description>
+        <description xml:lang="sv">BTC 5126T</description>
+        <description xml:lang="tr">BTC 5126T</description>
+        <description xml:lang="uk">BTC 5126T</description>
+        <description xml:lang="vi">BTC 5126T</description>
+        <description xml:lang="zh_CN">BTC 5126T</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>btc9000</name>
+        <description>BTC 9000</description>
+        <description xml:lang="af">BTC 9000</description>
+        <description xml:lang="az">BTC 9000</description>
+        <description xml:lang="cs">BTC 9000</description>
+        <description xml:lang="da">BTC 9000</description>
+        <description xml:lang="en_GB">BTC 9000</description>
+        <description xml:lang="fr">BTC 9000</description>
+        <description xml:lang="hu">BTC 9000</description>
+        <description xml:lang="nl">BTC 9000</description>
+        <description xml:lang="ru">BTC 9000</description>
+        <description xml:lang="sk">BTC 9000</description>
+        <description xml:lang="sq">BTC 9000</description>
+        <description xml:lang="sr">BTC 9000</description>
+        <description xml:lang="sv">BTC 9000</description>
+        <description xml:lang="tr">BTC 9000</description>
+        <description xml:lang="uk">BTC 9000</description>
+        <description xml:lang="vi">BTC 9000</description>
+        <description xml:lang="zh_CN">BTC 9000</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>btc9000a</name>
+        <description>BTC 9000A</description>
+        <description xml:lang="af">BTC 9000A</description>
+        <description xml:lang="az">BTC 9000A</description>
+        <description xml:lang="cs">BTC 9000A</description>
+        <description xml:lang="da">BTC 9000A</description>
+        <description xml:lang="en_GB">BTC 9000A</description>
+        <description xml:lang="fr">BTC 9000A</description>
+        <description xml:lang="hu">BTC 9000A</description>
+        <description xml:lang="nl">BTC 9000A</description>
+        <description xml:lang="ru">BTC 9000A</description>
+        <description xml:lang="sk">BTC 9000A</description>
+        <description xml:lang="sq">BTC 9000A</description>
+        <description xml:lang="sr">BTC 9000A</description>
+        <description xml:lang="sv">BTC 9000A</description>
+        <description xml:lang="tr">BTC 9000A</description>
+        <description xml:lang="uk">BTC 9000A</description>
+        <description xml:lang="vi">BTC 9000A</description>
+        <description xml:lang="zh_CN">BTC 9000A</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>btc9001ah</name>
+        <description>BTC 9001AH</description>
+        <description xml:lang="af">BTC 9001AH</description>
+        <description xml:lang="az">BTC 9001AH</description>
+        <description xml:lang="cs">BTC 9001AH</description>
+        <description xml:lang="da">BTC 9001AH</description>
+        <description xml:lang="en_GB">BTC 9001AH</description>
+        <description xml:lang="fr">BTC 9001AH</description>
+        <description xml:lang="hu">BTC 9001AH</description>
+        <description xml:lang="nl">BTC 9001AH</description>
+        <description xml:lang="ru">BTC·9001AH</description>
+        <description xml:lang="sk">BTC 9001AH</description>
+        <description xml:lang="sq">BTC 9001AH</description>
+        <description xml:lang="sr">BTC 9001AH</description>
+        <description xml:lang="sv">BTC 9001AH</description>
+        <description xml:lang="tr">BTC 9001AH</description>
+        <description xml:lang="uk">BTC 9001AH</description>
+        <description xml:lang="vi">BTC 9001AH</description>
+        <description xml:lang="zh_CN">BTC 9001AH</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>btc5090</name>
+        <description>BTC 5090</description>
+        <description xml:lang="af">BTC 5090</description>
+        <description xml:lang="az">BTC 5090</description>
+        <description xml:lang="cs">BTC 5090</description>
+        <description xml:lang="da">BTC 5090</description>
+        <description xml:lang="en_GB">BTC 5090</description>
+        <description xml:lang="fr">BTC 5090</description>
+        <description xml:lang="hu">BTC 5090</description>
+        <description xml:lang="nl">BTC 5090</description>
+        <description xml:lang="ru">BTC 5090</description>
+        <description xml:lang="sk">BTC 5090</description>
+        <description xml:lang="sq">BTC 5090</description>
+        <description xml:lang="sr">BTC 5090</description>
+        <description xml:lang="sv">BTC 5090</description>
+        <description xml:lang="tr">BTC 5090</description>
+        <description xml:lang="uk">BTC 5090</description>
+        <description xml:lang="vi">BTC 5090</description>
+        <description xml:lang="zh_CN">BTC 5090</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>cherryblue</name>
+        <description>Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="af">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="az">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="cs">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="da">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="en_GB">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="fr">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="hu">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="nl">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="ru">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="sk">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="sq">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="sr">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="sv">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="tr">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="uk">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="vi">Cherry Blue Line CyBo@rd</description>
+        <description xml:lang="zh_CN">Cherry Blue Line CyBo@rd</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>cherryblueb</name>
+        <description>Cherry CyMotion Master XPress</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>cherrybluea</name>
+        <description>Cherry Blue Line CyBo@rd (alternate option)</description>
+        <description xml:lang="af">Cherry Blue Line CyBo@rd (alternatief)</description>
+        <description xml:lang="az">Cherry Blue Line CyBo@rd (alternate option)</description>
+        <description xml:lang="cs">Cherry Blue Line CyBo@rd (alternativní volba)</description>
+        <description xml:lang="da">Cherry Blue Line CyBo@rd (alternativ)</description>
+        <description xml:lang="en_GB">Cherry Blue Line CyBo@rd (alternate option)</description>
+        <description xml:lang="fr">Cherry Blue Line CyBo@rd (option alternative)</description>
+        <description xml:lang="hu">Cherry Blue Line CyBo@rd (másik lehetőség)</description>
+        <description xml:lang="nl">Cherry Blue Line CyBo@rd (alternatieve optie)</description>
+        <description xml:lang="ru">Cherry Blue Line CyBo@rd (альтернативный вариант)</description>
+        <description xml:lang="rw">Ihitamo</description>
+        <description xml:lang="sk">Cherry Blue Line CyBo@rd (alternatívna voľba)</description>
+        <description xml:lang="sq">Cherry Blue Line CyBo@rd (opcioni alterno)</description>
+        <description xml:lang="sr">Cherry Blue Line CyBo@rd (друга могућност)</description>
+        <description xml:lang="sv">Cherry Blue Line CyBo@rd (alternativ)</description>
+        <description xml:lang="tr">Cherry Blue Line CyBo@rd (diğer seçenek)</description>
+        <description xml:lang="uk">Cherry Blue Line CyBo@rd (альтернативний варіант)</description>
+        <description xml:lang="vi">Cherry Blue Line CyBo@rd (luân phiên tùy chọn)</description>
+        <description xml:lang="zh_CN">Cherry Blue Line CyBo@rd (替代选项)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>chicony</name>
+        <description>Chicony Internet Keyboard</description>
+        <description xml:lang="af">Chicony Internetsleutelbord</description>
+        <description xml:lang="az">Chicony Internet Keyboard</description>
+        <description xml:lang="bg">Интернет клавиатура на Chicony</description>
+        <description xml:lang="cs">Chicony Internet Keyboard</description>
+        <description xml:lang="da">Chicony Internet Keyboard</description>
+        <description xml:lang="en_GB">Chicony Internet Keyboard</description>
+        <description xml:lang="fr">clavier Chicony Internet</description>
+        <description xml:lang="hu">Chicony Internet Keyboard</description>
+        <description xml:lang="nl">Chicony internet toetsenbord</description>
+        <description xml:lang="ru">Chicony Internet Keyboard</description>
+        <description xml:lang="sk">Chicony Internet Keyboard</description>
+        <description xml:lang="sq">Tastiera Internet Chicony</description>
+        <description xml:lang="sr">Chicony Интернет тастатура</description>
+        <description xml:lang="sv">Chicony Internettangentbord</description>
+        <description xml:lang="tr">Chicony Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Інтернет-клавіатура Chicony</description>
+        <description xml:lang="vi">Bàn phím Internet Chicony</description>
+        <description xml:lang="zh_CN">Chicony Internet 键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>chicony9885</name>
+        <description>Chicony KB-9885</description>
+        <description xml:lang="af">Chicony KB-9885</description>
+        <description xml:lang="az">Chicony KB-9885</description>
+        <description xml:lang="cs">Chicony KB-9885</description>
+        <description xml:lang="da">Chicony KB-9885</description>
+        <description xml:lang="en_GB">Chicony KB-9885</description>
+        <description xml:lang="fr">Chicony KB-9885</description>
+        <description xml:lang="hu">Chicony KB-9885</description>
+        <description xml:lang="nl">Chicony KB-9885</description>
+        <description xml:lang="ru">Chicony KB-9885</description>
+        <description xml:lang="sk">Chicony KB-9885</description>
+        <description xml:lang="sq">Chicony KB-9885</description>
+        <description xml:lang="sr">Chicony KB-9885</description>
+        <description xml:lang="sv">Chicony KB-9885</description>
+        <description xml:lang="tr">Chicony KB-9885</description>
+        <description xml:lang="uk">Chicony KB-9885</description>
+        <description xml:lang="vi">Chicony KB-9885</description>
+        <description xml:lang="zh_CN">Chicony KB-9885</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>compaqeak8</name>
+        <description>Compaq Easy Access Keyboard</description>
+        <description xml:lang="af">Compaq Easy Access Keyboard</description>
+        <description xml:lang="az">Compaq Easy Access Keyboard</description>
+        <description xml:lang="cs">Compaq Easy Access Keyboard</description>
+        <description xml:lang="da">Compaq Easy Access Keyboard</description>
+        <description xml:lang="en_GB">Compaq Easy Access Keyboard</description>
+        <description xml:lang="fr">clavier Compaq Easy Access</description>
+        <description xml:lang="hu">Compaq Easy Access Keyboard</description>
+        <description xml:lang="nl">Compaq Easy Access toetsenbord</description>
+        <description xml:lang="ru">Compaq Easy Access Keyboard</description>
+        <description xml:lang="sk">Compaq Easy Access Keyboard</description>
+        <description xml:lang="sq">Tastiera Compaq Easy Access</description>
+        <description xml:lang="sr">Compaq тастатура за лак приступ</description>
+        <description xml:lang="sv">Compaq Easy Access-tangentbord</description>
+        <description xml:lang="tr">Compaq Kolay Erişim Klavyesi</description>
+        <description xml:lang="uk">Compaq Easy Access Keyboard</description>
+        <description xml:lang="vi">Bàn phím Truy cập Dễ dàng của Compaq</description>
+        <description xml:lang="zh_CN">Compaq Easy Access 键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>compaqik7</name>
+        <description>Compaq Internet Keyboard (7 keys)</description>
+        <description xml:lang="af">Compaq Internet Keyboard (7 sleutels)</description>
+        <description xml:lang="az">Compaq Internet Keyboard (7 düymə)</description>
+        <description xml:lang="bg">Интернет клавиатура на Chicony</description>
+        <description xml:lang="cs">Compaq Internet Keyboard (7 kláves)</description>
+        <description xml:lang="da">Compaq Internet Keyboard (7 taster)</description>
+        <description xml:lang="en_GB">Compaq Internet Keyboard (7 keys)</description>
+        <description xml:lang="fr">clavier Compaq Internet (7 clés)</description>
+        <description xml:lang="hu">Compaq Internet Keyboard (7 gombos)</description>
+        <description xml:lang="nl">Compaq internet toetsenbord (7 toetsen)</description>
+        <description xml:lang="ru">Compaq Internet Keyboard (7 клавиш)</description>
+        <description xml:lang="rw">7 Utubuto</description>
+        <description xml:lang="sk">Compaq Internet Keyboard (7 kláves)</description>
+        <description xml:lang="sq">Tastiera Internet Compaq (7 pulsante)</description>
+        <description xml:lang="sr">Compaq Интернет тастатура (7 тастера)</description>
+        <description xml:lang="sv">Compaq Internettangentbord (7 tangenter)</description>
+        <description xml:lang="tr">Örütbağ Klavyesi (7 tuşlu)</description>
+        <description xml:lang="uk">Compaq Internet Keyboard (7 клавіш)</description>
+        <description xml:lang="vi">Bàn phím Internet Compaq (7 phím)</description>
+        <description xml:lang="zh_CN">Compaq 网际键盘(7键)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>compaqik13</name>
+        <description>Compaq Internet Keyboard (13 keys)</description>
+        <description xml:lang="af">Compaq Internet Keyboard (13 sleutels)</description>
+        <description xml:lang="az">Compaq Internet Keyboard (13 düymə)</description>
+        <description xml:lang="bg">Интернет клавиатура на Chicony</description>
+        <description xml:lang="cs">Compaq Internet Keyboard (13 kláves)</description>
+        <description xml:lang="da">Compaq Internet Keyboard (13 taster)</description>
+        <description xml:lang="en_GB">Compaq Internet Keyboard (13 keys)</description>
+        <description xml:lang="fr">clavier Compaq Internet (13 clés)</description>
+        <description xml:lang="hu">Compaq Internet Keyboard (13 gombos)</description>
+        <description xml:lang="nl">Compaq internet toetsenbord (13 toetsen)</description>
+        <description xml:lang="ru">Compaq Internet Keyboard (13 клавиш)</description>
+        <description xml:lang="rw">Utubuto</description>
+        <description xml:lang="sk">Compaq Internet Keyboard (13 kláves)</description>
+        <description xml:lang="sq">Tatiera Internet Compaq (13 pulsante)</description>
+        <description xml:lang="sr">Compaq Интернет тастатура (13 тастера)</description>
+        <description xml:lang="sv">Compaq Internettangentbord (13 tangenter)</description>
+        <description xml:lang="tr">Compaq Örütbağ Klavyesi (13 tuşlu)</description>
+        <description xml:lang="uk">Compaq Internet Keyboard (13 клавіш)</description>
+        <description xml:lang="vi">Bàn phím Internet Compaq (13 phím)</description>
+        <description xml:lang="zh_CN">Compaq 网际键盘(13键)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>compaqik18</name>
+        <description>Compaq Internet Keyboard (18 keys)</description>
+        <description xml:lang="af">Compaq Internet Keyboard (18 sleutels)</description>
+        <description xml:lang="az">Compaq Internet Keyboard (18 düymə)</description>
+        <description xml:lang="bg">Интернет клавиатура на Chicony</description>
+        <description xml:lang="cs">Compaq Internet Keyboard (18 kláves)</description>
+        <description xml:lang="da">Compaq Internet Keyboard (18 taster)</description>
+        <description xml:lang="en_GB">Compaq Internet Keyboard (18 keys)</description>
+        <description xml:lang="fr">clavier Compaq Internet (18 clés)</description>
+        <description xml:lang="hu">Compaq Internet Keyboard (18 gombos)</description>
+        <description xml:lang="nl">Compaq internet toetsenbord (18 toetsen)</description>
+        <description xml:lang="ru">Compaq Internet Keyboard (18 клавиш)</description>
+        <description xml:lang="rw">Utubuto</description>
+        <description xml:lang="sk">Compaq Internet Keyboard (18 kláves)</description>
+        <description xml:lang="sq">Tastiera Internet Compaq (18 pulsante)</description>
+        <description xml:lang="sr">Compaq Интернет тастатура (18 тастера)</description>
+        <description xml:lang="sv">Compaq Internettangentbord (18 tangenter)</description>
+        <description xml:lang="tr">Compaq Örütbağ Klavyesi (18 tuşlu)</description>
+        <description xml:lang="uk">Compaq Internet Keyboard (18 клавіш)</description>
+        <description xml:lang="vi">Bàn phím Internet Compaq (18 phím)</description>
+        <description xml:lang="zh_CN">Compaq 网际键盘(18键)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>cymotionlinux</name>
+        <description>Cherry CyMotion Master Linux</description>
+        <description xml:lang="ru">Cherry CyMotion Master Linux</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>armada</name>
+        <description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard</description>
+        <description xml:lang="af">Laptop/notebook Compaq (eg. Armada) Laptop Keyboard</description>
+        <description xml:lang="az">Laptop/notebook Compaq (məs. Armada) Laptop Klaviaturası</description>
+        <description xml:lang="cs">Laptop/notebook Compaq (např. Armada) Laptop Keyboard</description>
+        <description xml:lang="da">Bærbar Compaq (fx Armada) Laptop Keyboard</description>
+        <description xml:lang="en_GB">Laptop/notebook Compaq (eg. Armada) Laptop Keyboard</description>
+        <description xml:lang="fr">clavier Laptop/notebook Compaq (ie. Armada) Laptop</description>
+        <description xml:lang="hu">Laptop/notebook Compaq (pl. Armada) Laptop Keyboard</description>
+        <description xml:lang="nl">Laptop/notebook Compaq (bijv. Armada) laptop toetsenbord</description>
+        <description xml:lang="ru">Клавиатура для компьютеров Compaq (например Armada)</description>
+        <description xml:lang="sk">Laptop/notebook Compaq (napr. Armada) Laptop Keyboard</description>
+        <description xml:lang="sq">Tastierë laptop për Laptop/notebook Compaq (p.sh. Armada)</description>
+        <description xml:lang="sr">Тастатуре преносних рачунара из Compaq-а (нпр. Armada)</description>
+        <description xml:lang="sv">Laptop-tangentbord för bärbar Compaq-dator (t.ex. Armada)</description>
+        <description xml:lang="tr">Laptop/notebook Compaq (örn. Armada) Dizüstü Klavyesi</description>
+        <description xml:lang="uk">Клавіатура для комп'ютерів Compaq (напр., Armada)</description>
+        <description xml:lang="vi">Bàn phím nhỏ gọn cho máy xách tay/notebook Compaq (ví dụ Armada)</description>
+        <description xml:lang="zh_CN">便携/笔记本 Compaq(如 Armada)便携键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>presario</name>
+        <description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard</description>
+        <description xml:lang="af">Laptop/notebook Compaq (eg. Presario) Internet Keyboard</description>
+        <description xml:lang="az">Laptop/notebook Compaq (məs. Presario) İnternet Klaviaturası</description>
+        <description xml:lang="cs">Laptop/notebook Compaq (např. Presario) Internet Keyboard</description>
+        <description xml:lang="da">Bærbar Compaq (fx Presario) Internet Keyboard</description>
+        <description xml:lang="en_GB">Laptop/notebook Compaq (eg. Presario) Internet Keyboard</description>
+        <description xml:lang="fr">clavier Laptop/notebook Compaq (ie. Presario) Internet</description>
+        <description xml:lang="hu">Laptop/notebook Compaq (pl. Presario) Internet Keyboard</description>
+        <description xml:lang="nl">Laptop/notebook Compaq (bijv. Presario) internet toetsenbord</description>
+        <description xml:lang="ru">"Интернет" клавиатура для компьютеров Compaq (например Presario)</description>
+        <description xml:lang="sk">Laptop/notebook Compaq (napr. Presario) Internet Keyboard</description>
+        <description xml:lang="sq">Tastierë për Internet për Laptop/notebook Compaq (p.sh. Presario)</description>
+        <description xml:lang="sr">Тастатуре преносних рачунара из Compaq-а (нпр. Presario)</description>
+        <description xml:lang="sv">Internettangentbord för bärbar Compaq-dator (t.ex. Presario)</description>
+        <description xml:lang="tr">Laptop/notebook Compaq (örn. Presario) Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Інтернет-клавіатура для ноутбуків Compaq (напр., Presario)</description>
+        <description xml:lang="vi">Bàn phím Internet cho máy xách tay/notebook Compaq (ví dụ Presario)</description>
+        <description xml:lang="zh_CN">便携/笔记本 Compaq(如自由人)网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>ipaq</name>
+        <description>Compaq iPaq Keyboard</description>
+        <description xml:lang="af">Compaq iPaq Keyboard</description>
+        <description xml:lang="az">Compaq iPaq Keyboard</description>
+        <description xml:lang="cs">Compaq iPaq Keyboard</description>
+        <description xml:lang="da">Compaq iPaq Keyboard</description>
+        <description xml:lang="en_GB">Compaq iPaq Keyboard</description>
+        <description xml:lang="fr">clavier Compaq iPaq</description>
+        <description xml:lang="hu">Compaq iPaq Keyboard</description>
+        <description xml:lang="nl">Compaq iPaq toetsenbord</description>
+        <description xml:lang="ru">Compaq iPaq Keyboard</description>
+        <description xml:lang="sk">Compaq iPaq Keyboard</description>
+        <description xml:lang="sq">Tastiera Compaq iPaq</description>
+        <description xml:lang="sr">Compaq iPaq тастатура</description>
+        <description xml:lang="sv">Compaq iPaq-tangentbord</description>
+        <description xml:lang="tr">Compaq iPaq Klavyesi</description>
+        <description xml:lang="uk">Compaq iPaq Keyboard</description>
+        <description xml:lang="vi">Bàn phím iPaq Compaq</description>
+        <description xml:lang="zh_CN">Compaq iPaq 键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>dell</name>
+        <description>Dell</description>
+        <description xml:lang="af">Dell</description>
+        <description xml:lang="az">Dell</description>
+        <description xml:lang="cs">Dell</description>
+        <description xml:lang="da">Dell</description>
+        <description xml:lang="en_GB">Dell</description>
+        <description xml:lang="fr">Dell</description>
+        <description xml:lang="hu">Dell</description>
+        <description xml:lang="nl">Dell</description>
+        <description xml:lang="ru">Dell</description>
+        <description xml:lang="sk">Dell</description>
+        <description xml:lang="sq">Dell</description>
+        <description xml:lang="sr">Dell</description>
+        <description xml:lang="sv">Dell</description>
+        <description xml:lang="tr">Dell</description>
+        <description xml:lang="uk">Dell</description>
+        <description xml:lang="vi">Dell</description>
+        <description xml:lang="zh_CN">Dell</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>inspiron</name>
+        <description>Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="af">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="az">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="cs">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="da">Bærbar Dell Inspiron 8xxx</description>
+        <description xml:lang="en_GB">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="fr">clavier Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="hu">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="nl">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="ru">Настольная/портативная для Dell Inspiron 8xxx</description>
+        <description xml:lang="sk">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="sq">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="sr">Тастатуре преносних рачунара Dell Inspiron 8xxx</description>
+        <description xml:lang="sv">Bärbar Dell Inspiron 8xxx</description>
+        <description xml:lang="tr">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="uk">Для ноутбуків Dell Inspiron 8xxx</description>
+        <description xml:lang="vi">Laptop/notebook Dell Inspiron 8xxx</description>
+        <description xml:lang="zh_CN">便携/笔记本 Dell Inspiron 8xxx</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>dexxa</name>
+        <description>Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="af">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="az">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="cs">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="da">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="en_GB">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="fr">clavier Dexxa Wireless Desktop</description>
+        <description xml:lang="hu">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="nl">Dexxa Wireless Desktop toetsenbord</description>
+        <description xml:lang="ru">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="sk">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="sq">Tastierë Dexxa Wireless Desktop</description>
+        <description xml:lang="sr">Dexxa бежична тастатура</description>
+        <description xml:lang="sv">Dexxa trådlöst skrivbordstangentbord</description>
+        <description xml:lang="tr">Dexxa Kablosuz Masaüstü Klavyesi</description>
+        <description xml:lang="uk">Dexxa Wireless Desktop Keyboard</description>
+        <description xml:lang="vi">Bàn phím Không dây Dexxa cho Desktop</description>
+        <description xml:lang="zh_CN">Dexxa 无线桌面键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>diamond</name>
+        <description>Diamond 9801 / 9802 series</description>
+        <description xml:lang="af">Diamond 9801 / 9802 series</description>
+        <description xml:lang="az">Diamond 9801 / 9802 seryaları</description>
+        <description xml:lang="cs">Diamond řada 9801 / 9802</description>
+        <description xml:lang="da">Diamond 9801 / 9802-serien</description>
+        <description xml:lang="en_GB">Diamond 9801 / 9802 series</description>
+        <description xml:lang="fr">clavier Diamond 9801 / 9802 series</description>
+        <description xml:lang="hu">Diamond 9801 / 9802 series</description>
+        <description xml:lang="nl">Diamond 9801 / 9802 serie</description>
+        <description xml:lang="ru">Модели Diamond 9801/9802</description>
+        <description xml:lang="rw">Ibyiciro</description>
+        <description xml:lang="sk">Diamond séria 9801 / 9802</description>
+        <description xml:lang="sq">Seritë Diamond 9801 / 9802</description>
+        <description xml:lang="sr">Diamond 9801 / 9802 серија</description>
+        <description xml:lang="sv">Diamond 9801/9802-serien</description>
+        <description xml:lang="tr">Diamond 9801 / 9802 serileri</description>
+        <description xml:lang="uk">Моделі Diamond 9801/9802</description>
+        <description xml:lang="vi">Sê ri Diamond 9801 / 9802</description>
+        <description xml:lang="zh_CN">Diamond 9801 / 9802 系列</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>dtk2000</name>
+        <description>DTK2000</description>
+        <description xml:lang="en_GB">DTK2000</description>
+        <description xml:lang="nl">DTK2000</description>
+        <description xml:lang="ru">DTK2000</description>
+        <description xml:lang="vi">DTK2000</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>ennyah_dkb1008</name>
+        <description>Ennyah DKB-1008</description>
+        <description xml:lang="af">Ennyah DKB-1008</description>
+        <description xml:lang="az">Ennyah DKB-1008</description>
+        <description xml:lang="cs">Ennyah DKB-1008</description>
+        <description xml:lang="da">Ennyah DKB-1008</description>
+        <description xml:lang="en_GB">Ennyah DKB-1008</description>
+        <description xml:lang="fr">Ennyah DKB-1008</description>
+        <description xml:lang="hu">Ennyah DKB-1008</description>
+        <description xml:lang="nl">Ennyah DKB-1008</description>
+        <description xml:lang="ru">Ennyah DKB-1008</description>
+        <description xml:lang="sk">Ennyah DKB-1008</description>
+        <description xml:lang="sq">Ennyah DKB-1008</description>
+        <description xml:lang="sr">Ennyah DKB-1008</description>
+        <description xml:lang="sv">Ennyah DKB-1008</description>
+        <description xml:lang="tr">Ennyah DKB-1008</description>
+        <description xml:lang="uk">Ennyah DKB-1008</description>
+        <description xml:lang="vi">Ennyah DKB-1008</description>
+        <description xml:lang="zh_CN">Ennyah DKB-1008</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>genius</name>
+        <description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="af">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="az">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="cs">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="da">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="en_GB">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="fr">clavier Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="hu">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="nl">Genius Comfy KB-16M / Genius MM toetsenbord KWD-910</description>
+        <description xml:lang="ru">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="sk">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="sq">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="sr">Genius Comfy KB-16M / Genius ММ тастатура KWD-910</description>
+        <description xml:lang="sv">Genius Comfy KB-16M / Genius MM-tangentbord KWD-910</description>
+        <description xml:lang="tr">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="uk">Genius Comfy KB-16M / Genius MM Keyboard KWD-910</description>
+        <description xml:lang="vi">Genius Tiện lợi KB-16M / Bàn phím Genius MM KWD-910</description>
+        <description xml:lang="zh_CN">通用 Comfy KB-16M / Genius MM 键盘 KWD-910</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>geniuscomfy2</name>
+        <description>Genius Comfy KB-21e-Scroll</description>
+        <description xml:lang="en_GB">Genius Comfy KB-21e-Scroll</description>
+        <description xml:lang="nl">Genius Comfy KB-21e-Scroll</description>
+        <description xml:lang="ru">Genius Comfy KB-21e-Scroll</description>
+        <description xml:lang="vi">Genius Comfy KB-21e-Scroll</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>gyration</name>
+        <description>Gyration</description>
+        <description xml:lang="en_GB">Gyration</description>
+        <description xml:lang="nl">Kroatisch</description>
+        <description xml:lang="ru">Гирашн</description>
+        <description xml:lang="vi">Sự chuyển hồi</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hpi6</name>
+        <description>Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="af">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="az">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="bg">Интернет клавиатура на Dell</description>
+        <description xml:lang="cs">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="da">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="en_GB">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Internet</description>
+        <description xml:lang="hu">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="nl">Hewlett-Packard internet toetsenbord</description>
+        <description xml:lang="ru">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="sk">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="sq">Tastierë për Internet Hewlett-Packard</description>
+        <description xml:lang="sr">Hewlett-Packard Интернет тастатура</description>
+        <description xml:lang="sv">Hewlett-Packard Internettangentbord</description>
+        <description xml:lang="tr">Hewlett-Packard Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Hewlett-Packard Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím Internet Hewlett-Packard</description>
+        <description xml:lang="zh_CN">惠普网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hp2501</name>
+        <description>Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="af">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="az">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="cs">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="da">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="en_GB">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="fr">clavier Hewlett-Packard SK-2501 Multimedia</description>
+        <description xml:lang="hu">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="nl">Hewlett-Packard SK-2501 multimedia toetsenbord</description>
+        <description xml:lang="ru">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="sk">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="sq">Tastierë multimediale Hewlett-Packard SK-2501</description>
+        <description xml:lang="sr">Hewlett-Packard SK-2501 мултимедијална тастатура</description>
+        <description xml:lang="sv">Hewlett-Packard SK-2501 multimediatangentbord</description>
+        <description xml:lang="tr">Hewlett-Packard SK-2501 Çokluortam Klavyesi</description>
+        <description xml:lang="uk">Hewlett-Packard SK-2501 Multimedia Keyboard</description>
+        <description xml:lang="vi">Bàn phím phim nhạc Hewlett-Packard SK-2501</description>
+        <description xml:lang="zh_CN">惠普 SK-2501 多媒体键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hp2505</name>
+        <description>Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="af">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="az">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="bg">Интернет клавиатура на Dell</description>
+        <description xml:lang="cs">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="da">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="en_GB">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="fr">clavier Hewlett-Packard SK-2505 Internet</description>
+        <description xml:lang="hu">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="nl">Hewlett-Packard SK-2505 internet toetsenbord</description>
+        <description xml:lang="ru">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="sk">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="sq">Tastierë për Internet Hewlett-Packard SK-2505</description>
+        <description xml:lang="sr">Hewlett-Packard SK-2505 Интернет тастатура</description>
+        <description xml:lang="sv">Hewlett-Packard SK-2505 Internettangentbord</description>
+        <description xml:lang="tr">Hewlett-Packard SK-2505 Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Hewlett-Packard SK-2505 Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím Internet Hewlett-Packard SK-2505</description>
+        <description xml:lang="zh_CN">惠普 SK-2505 网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hpxe3gc</name>
+        <description>Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="af">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="az">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="cs">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="da">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="en_GB">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="hu">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="nl">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="ru">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="sk">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="sq">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="sr">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="sv">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="tr">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="uk">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="vi">Hewlett-Packard Omnibook XE3 GC</description>
+        <description xml:lang="zh_CN">惠普 Omnibook XE3 GC</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hpxe3gf</name>
+        <description>Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="af">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="az">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="cs">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="da">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="en_GB">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="hu">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="nl">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="ru">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="sk">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="sq">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="sr">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="sv">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="tr">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="uk">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="vi">Hewlett-Packard Omnibook XE3 GF</description>
+        <description xml:lang="zh_CN">惠普 Omnibook XE3 CF</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hpxt1000</name>
+        <description>Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="af">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="az">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="cs">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="da">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="en_GB">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="hu">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="nl">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="ru">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="sk">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="sq">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="sr">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="sv">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="tr">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="uk">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="vi">Hewlett-Packard Omnibook XT1000</description>
+        <description xml:lang="zh_CN">惠普 Omnibook XT1000</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hpzt11xx</name>
+        <description>Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="af">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="az">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="cs">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="da">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="en_GB">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="hu">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="nl">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="ru">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="sk">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="sq">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="sr">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="sv">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="tr">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="uk">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="vi">Hewlett-Packard Pavilion ZT11xx</description>
+        <description xml:lang="zh_CN">惠普 Pavilion ZT11xx</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hp500fa</name>
+        <description>Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="af">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="az">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="cs">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="da">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="en_GB">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="hu">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="nl">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="ru">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="rw">500</description>
+        <description xml:lang="sk">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="sq">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="sr">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="sv">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="tr">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="uk">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="vi">Hewlett-Packard Omnibook 500 FA</description>
+        <description xml:lang="zh_CN">惠普 Omnibook 500 FA</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hp5xx</name>
+        <description>Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="af">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="az">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="bg">Интернет клавиатура на Dell</description>
+        <description xml:lang="cs">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="da">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="en_GB">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="hu">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="nl">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="ru">Hewlett-Packard·Omnibook·5xx</description>
+        <description xml:lang="sk">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="sq">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="sr">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="sv">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="tr">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="uk">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="vi">Hewlett-Packard Omnibook 5xx</description>
+        <description xml:lang="zh_CN">惠普 Omnibook 5xx</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>hp6000</name>
+        <description>Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="af">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="az">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="cs">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="da">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="en_GB">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="fr">clavier Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="hu">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="nl">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="ru">Hewlett-Packard·Omnibook·6000/6100</description>
+        <description xml:lang="sk">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="sq">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="sr">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="sv">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="tr">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="uk">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="vi">Hewlett-Packard Omnibook 6000/6100</description>
+        <description xml:lang="zh_CN">惠普 Omnibook 6000/6100</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>honeywell_euroboard</name>
+        <description>Honeywell Euroboard</description>
+        <description xml:lang="af">Honeywell Euroboard</description>
+        <description xml:lang="az">Honeywell Euroboard</description>
+        <description xml:lang="cs">Honeywell Euroboard</description>
+        <description xml:lang="da">Honeywell Euroboard</description>
+        <description xml:lang="en_GB">Honeywell Euroboard</description>
+        <description xml:lang="fr">Honeywell Euroboard</description>
+        <description xml:lang="hu">Honeywell Euroboard</description>
+        <description xml:lang="nl">Honeywell Euroboard</description>
+        <description xml:lang="ru">Honeywell Euroboard</description>
+        <description xml:lang="sk">Honeywell Euroboard</description>
+        <description xml:lang="sq">Honeywell Euroboard</description>
+        <description xml:lang="sr">Honeywell Euroboard</description>
+        <description xml:lang="sv">Honeywell Euroboard</description>
+        <description xml:lang="tr">Honeywell Euroboard</description>
+        <description xml:lang="uk">Honeywell Euroboard</description>
+        <description xml:lang="vi">Honeywell Euroboard</description>
+        <description xml:lang="zh_CN">Honeywell 欧洲键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>rapidaccess</name>
+        <description>IBM Rapid Access</description>
+        <description xml:lang="af">IBM Rapid Access</description>
+        <description xml:lang="az">IBM Rapid Access</description>
+        <description xml:lang="bg">IBM Rapid Access</description>
+        <description xml:lang="cs">IBM Rapid Access</description>
+        <description xml:lang="da">IBM Rapid Access</description>
+        <description xml:lang="en_GB">IBM Rapid Access</description>
+        <description xml:lang="fr">clavier IBM Rapid Access</description>
+        <description xml:lang="hu">IBM Rapid Access</description>
+        <description xml:lang="nl">IBM Rapid Access</description>
+        <description xml:lang="ru">IBM Rapid Access</description>
+        <description xml:lang="sk">IBM Rapid Access</description>
+        <description xml:lang="sq">IBM Rapid Access</description>
+        <description xml:lang="sr">IBM Rapid Access</description>
+        <description xml:lang="sv">IBM Rapid Access</description>
+        <description xml:lang="tr">IBM Hızlı Erişim</description>
+        <description xml:lang="uk">IBM Rapid Access</description>
+        <description xml:lang="vi">Truy cập nhanh IBM</description>
+        <description xml:lang="zh_CN">IBM Rapid Access</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>rapidaccess2</name>
+        <description>IBM Rapid Access II</description>
+        <description xml:lang="af">IBM Rapid Access II</description>
+        <description xml:lang="az">IBM Rapid Access II</description>
+        <description xml:lang="bg">IBM Rapid Access II</description>
+        <description xml:lang="cs">IBM Rapid Access II</description>
+        <description xml:lang="da">IBM Rapid Access II</description>
+        <description xml:lang="en_GB">IBM Rapid Access II</description>
+        <description xml:lang="fr">clavier IBM Rapid Access II</description>
+        <description xml:lang="hu">IBM Rapid Access II</description>
+        <description xml:lang="nl">IBM Rapid Access II</description>
+        <description xml:lang="ru">IBM Rapid Access II</description>
+        <description xml:lang="sk">IBM Rapid Access II</description>
+        <description xml:lang="sq">IBM Rapid Access II</description>
+        <description xml:lang="sr">IBM Rapid Access II</description>
+        <description xml:lang="sv">IBM Rapid Access II</description>
+        <description xml:lang="tr">IBM Hızlı Erişim II</description>
+        <description xml:lang="uk">IBM Rapid Access II</description>
+        <description xml:lang="vi">Truy cập nhanh IBM II</description>
+        <description xml:lang="zh_CN">IBM Rapid Access II</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>rapidaccess2a</name>
+        <description>IBM Rapid Access II (alternate option)</description>
+        <description xml:lang="af">IBM Rapid Access II (alternate option)</description>
+        <description xml:lang="az">IBM Rapid Access II (alternate option)</description>
+        <description xml:lang="bg">IBM Rapid Access II</description>
+        <description xml:lang="cs">IBM Rapid Access II (alternativní volba)</description>
+        <description xml:lang="da">IBM Rapid Access II (alternativ)</description>
+        <description xml:lang="en_GB">IBM Rapid Access II (alternate option)</description>
+        <description xml:lang="fr">clavier IBM Rapid Access II (option alternative)</description>
+        <description xml:lang="hu">IBM Rapid Access II (másik lehetőség)</description>
+        <description xml:lang="nl">IBM Rapid Access II (alternatieve optie)</description>
+        <description xml:lang="ru">IBM Rapid Access II (альтернативный вариант)</description>
+        <description xml:lang="rw">Ihitamo</description>
+        <description xml:lang="sk">IBM Rapid Access II (alternatívna voľba)</description>
+        <description xml:lang="sq">IBM Rapid Access II (opcioni alternativ)</description>
+        <description xml:lang="sr">IBM Rapid Access II (друга могућност)</description>
+        <description xml:lang="sv">IBM Rapid Access II (alternativ)</description>
+        <description xml:lang="tr">IBM Hızlı Erişim II (diğer seçenek)</description>
+        <description xml:lang="uk">IBM Rapid Access II (альтернативний варіант)</description>
+        <description xml:lang="vi">Truy cập nhanh IBM II (luân phiên tùy chọn)</description>
+        <description xml:lang="zh_CN">IBM Rapid Access II(替代选项)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>thinkpad</name>
+        <description>IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="af">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="az">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="cs">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="da">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="en_GB">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="fr">clavier IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="hu">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="nl">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="ru">IBM·ThinkPad·560Z/600/600E/A22E</description>
+        <description xml:lang="rw">600</description>
+        <description xml:lang="sk">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="sq">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="sr">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="sv">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="tr">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="uk">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="vi">IBM ThinkPad 560Z/600/600E/A22E</description>
+        <description xml:lang="zh_CN">IBM ThinkPad 560Z/600/600E/A22E</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logiaccess</name>
+        <description>Logitech Access Keyboard</description>
+        <description xml:lang="en_GB">Logitech Access Keyboard</description>
+        <description xml:lang="nl">Logitech Access toetsenbord</description>
+        <description xml:lang="ru">Logitech Access Keyboard</description>
+        <description xml:lang="vi">Bàn phím Truy cập Logitech</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>ltcd</name>
+        <description>Logitech Cordless Desktop</description>
+        <description xml:lang="af">Logitech Cordless Desktop</description>
+        <description xml:lang="az">Logitech Cordless Desktop</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Desktop</description>
+        <description xml:lang="da">Logitech Cordless Desktop</description>
+        <description xml:lang="en_GB">Logitech Cordless Desktop</description>
+        <description xml:lang="fr">Logitech Cordless Desktop</description>
+        <description xml:lang="hu">Logitech Cordless Desktop</description>
+        <description xml:lang="nl">Logitech Cordless Desktop</description>
+        <description xml:lang="ru">Logitech Cordless Desktop</description>
+        <description xml:lang="sk">Logitech Cordless Desktop</description>
+        <description xml:lang="sq">Logitech Cordless Desktop</description>
+        <description xml:lang="sr">Logitech Cordless Desktop</description>
+        <description xml:lang="sv">Logitech Cordless Desktop</description>
+        <description xml:lang="tr">Logitech Kablosuz Masaüstü</description>
+        <description xml:lang="uk">Logitech Cordless Desktop</description>
+        <description xml:lang="vi">Logitech Cordless Desktop</description>
+        <description xml:lang="zh_CN">罗技无影手</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logicdit</name>
+        <description>Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="af">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="az">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="da">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="en_GB">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="fr">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="hu">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="nl">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="ru">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="sk">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="sq">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="sr">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="sv">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="tr">Logitech Kablosuz Masaüstü iTouch</description>
+        <description xml:lang="uk">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="vi">Logitech Cordless Desktop iTouch</description>
+        <description xml:lang="zh_CN">罗技网际无影手</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logicdp</name>
+        <description>Logitech Cordless Desktop Pro</description>
+        <description xml:lang="af">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="az">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="da">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="en_GB">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="fr">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="hu">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="nl">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="ru">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="sk">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="sq">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="sr">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="sv">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="tr">Logitech Kablosuz Masaüstü Pro</description>
+        <description xml:lang="uk">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="vi">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="zh_CN">罗技无影手高级版</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logicdpa</name>
+        <description>Logitech Cordless Desktop Pro (alternate option)</description>
+        <description xml:lang="af">Logitech Cordless Desktop Pro (alternatiewe opsie)</description>
+        <description xml:lang="az">Logitech Cordless Desktop Pro (alternate option)</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Desktop Pro (alternativní volba)</description>
+        <description xml:lang="da">Logitech Cordless Desktop Pro (alternativ)</description>
+        <description xml:lang="en_GB">Logitech Cordless Desktop Pro (alternate option)</description>
+        <description xml:lang="fr">Logitech Cordless Desktop Pro (option alternative)</description>
+        <description xml:lang="hu">Logitech Cordless Desktop Pro (másik lehetőség)</description>
+        <description xml:lang="nl">Logitech Cordless Desktop Pro (alternatieve optie)</description>
+        <description xml:lang="ru">Logitech Cordless Desktop Pro (альтернативный вариант)</description>
+        <description xml:lang="rw">Ihitamo</description>
+        <description xml:lang="sk">Logitech Cordless Desktop Pro (alternatívna voľba)</description>
+        <description xml:lang="sq">Logitech Cordless Desktop Pro (opcioni alternativ)</description>
+        <description xml:lang="sr">Logitech Cordless Desktop Pro (додатна могућност)</description>
+        <description xml:lang="sv">Logitech Cordless Desktop Pro (alternativ)</description>
+        <description xml:lang="tr">Logitech Kablosuz Masaüstü Pro (diğer seçenek)</description>
+        <description xml:lang="uk">Logitech Cordless Desktop Pro (альтернативний варіант)</description>
+        <description xml:lang="vi">Logitech Cordless Desktop Pro (luân phiên tùy chọn)</description>
+        <description xml:lang="zh_CN">罗技无影手高级版(替代选项)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logicdpa2</name>
+        <description>Logitech Cordless Desktop Pro (alternate option2)</description>
+        <description xml:lang="af">Logitech Cordless Desktop Pro (alternatiewe opsie2)</description>
+        <description xml:lang="az">Logitech Cordless Desktop Pro (alternate option2)</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Desktop Pro (alternativní volba 2)</description>
+        <description xml:lang="da">Logitech Cordless Desktop Pro (alternativ 2)</description>
+        <description xml:lang="en_GB">Logitech Cordless Desktop Pro (alternate option2)</description>
+        <description xml:lang="fr">Logitech Cordless Desktop Pro (option2 alternative)</description>
+        <description xml:lang="hu">Logitech Cordless Desktop Pro (harmadik lehetőség)</description>
+        <description xml:lang="nl">Logitech Cordless Desktop Pro (alternatieve optie2)</description>
+        <description xml:lang="ru">Logitech Cordless Desktop Pro (альтернативный вариант 2)</description>
+        <description xml:lang="sk">Logitech Cordless Desktop Pro (alternatívna voľba2)</description>
+        <description xml:lang="sq">Logitech Cordless Desktop Pro (opcioni i dytë alternativ)</description>
+        <description xml:lang="sr">Logitech Cordless Desktop Pro (додатна могућност 2)</description>
+        <description xml:lang="sv">Logitech Cordless Desktop Pro (alternativ2)</description>
+        <description xml:lang="tr">Logitech Kablosuz Masaüstü Pro (diğer 2. seçenek)</description>
+        <description xml:lang="uk">Logitech Cordless Desktop Pro (альтернативний варіант 2)</description>
+        <description xml:lang="vi">Logitech Cordless Desktop Pro (luân phiên tùy chọn2)</description>
+        <description xml:lang="zh_CN">罗技无影手高级版(替代选项)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logicdo</name>
+        <description>Logitech Cordless Desktop Optical</description>
+        <description xml:lang="af">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="az">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="da">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="en_GB">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="fr">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="hu">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="nl">Logitech Cordless Desktop Optisch</description>
+        <description xml:lang="ru">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="sk">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="sq">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="sr">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="sv">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="tr">Logitech Kablosuz Masaüstü Optik</description>
+        <description xml:lang="uk">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="vi">Logitech Cordless Desktop Optical</description>
+        <description xml:lang="zh_CN">罗技无影手光学组合</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logicfn</name>
+        <description>Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="af">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="az">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="da">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="en_GB">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="fr">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="hu">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="nl">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="ru">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="sk">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="sq">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="sr">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="sv">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="tr">Logitech Kablosuz Özgür/Masaüstü Tarayıcı</description>
+        <description xml:lang="uk">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="vi">Logitech Cordless Freedom/Desktop Navigator</description>
+        <description xml:lang="zh_CN">罗技极光无影手组合/桌面导航器</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logicdn</name>
+        <description>Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="af">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="az">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="bg">Logitech Cordless Desktop Pro</description>
+        <description xml:lang="cs">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="da">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="en_GB">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="fr">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="hu">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="nl">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="ru">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="sk">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="sq">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="sr">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="sv">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="tr">Logitech Kablosuz Masaüstü Tarayıcı</description>
+        <description xml:lang="uk">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="vi">Logitech Cordless Desktop Navigator</description>
+        <description xml:lang="zh_CN">罗技无影手桌面导航器</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logidak</name>
+        <description>Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="af">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="az">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="bg">Logitech Интернет клавиатура</description>
+        <description xml:lang="cs">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="da">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="en_GB">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="fr">clavier Logitech Deluxe Access</description>
+        <description xml:lang="hu">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="nl">Logitech Deluxe Access toetsenbord</description>
+        <description xml:lang="ru">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="sk">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="sq">Tastierë Logitech Deluxe Access</description>
+        <description xml:lang="sr">Logitech Deluxe Access тастатура</description>
+        <description xml:lang="sv">Logitech Deluxe Access-tangentbord</description>
+        <description xml:lang="tr">Logitech Deluxe Erişim Klavyesi</description>
+        <description xml:lang="uk">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="vi">Logitech Deluxe Access Keyboard</description>
+        <description xml:lang="zh_CN">罗技强手键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logiitc</name>
+        <description>Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="af">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="az">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="cs">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="da">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="en_GB">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="fr">clavier Logitech iTouch Cordless (model Y-RB6)</description>
+        <description xml:lang="hu">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="nl">Logitech iTouch draadloos toetsenbord (model Y-RB6)</description>
+        <description xml:lang="ru">Logitech iTouch Cordless Keyboard (модель Y-RB6)</description>
+        <description xml:lang="rw">Urugero</description>
+        <description xml:lang="sk">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="sq">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="sr">Logitech iTouch Cordless тастатура (модел Y-RB6)</description>
+        <description xml:lang="sv">Logitech iTouch Cordless Keyboard (modell Y-RB6)</description>
+        <description xml:lang="tr">Logitech iTouch Kablosuz Klavyesi (model Y-RB6)</description>
+        <description xml:lang="uk">Logitech iTouch Cordless Keyboard (модель Y-RB6)</description>
+        <description xml:lang="vi">Bàn phím Không dây Logitech iTouch (mẫu mã Y-RB6)</description>
+        <description xml:lang="zh_CN">罗技 iTouch 无影手键盘(型号 Y-RB6)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logiik</name>
+        <description>Logitech Internet Keyboard</description>
+        <description xml:lang="af">Logitech Internet Keyboard</description>
+        <description xml:lang="az">Logitech Internet Keyboard</description>
+        <description xml:lang="bg">Logitech Интернет клавиатура</description>
+        <description xml:lang="cs">Logitech Internet Keyboard</description>
+        <description xml:lang="da">Logitech Internet Keyboard</description>
+        <description xml:lang="en_GB">Logitech Internet Keyboard</description>
+        <description xml:lang="fr">clavier Logitech Internet</description>
+        <description xml:lang="hu">Logitech Internet Keyboard</description>
+        <description xml:lang="nl">Logitech internet toetsenbord</description>
+        <description xml:lang="ru">Logitech Internet Keyboard</description>
+        <description xml:lang="sk">Logitech Internet Keyboard</description>
+        <description xml:lang="sq">Tastierë për Internet Logitech</description>
+        <description xml:lang="sr">Logitech Интернет тастатура</description>
+        <description xml:lang="sv">Logitech Internettangentbord</description>
+        <description xml:lang="tr">Logitech Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Logitech Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím Internet Logitech</description>
+        <description xml:lang="zh_CN">罗技网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>itouch</name>
+        <description>Logitech iTouch</description>
+        <description xml:lang="af">Logitech iTouch</description>
+        <description xml:lang="az">Logitech iTouch</description>
+        <description xml:lang="bg">Logitech iTouch</description>
+        <description xml:lang="cs">Logitech iTouch</description>
+        <description xml:lang="da">Logitech iTouch</description>
+        <description xml:lang="en_GB">Logitech iTouch</description>
+        <description xml:lang="fr">Logitech iTouch</description>
+        <description xml:lang="hu">Logitech iTouch</description>
+        <description xml:lang="nl">Logitech iTouch</description>
+        <description xml:lang="ru">Logitech iTouch</description>
+        <description xml:lang="sk">Logitech iTouch</description>
+        <description xml:lang="sq">Logitech iTouch</description>
+        <description xml:lang="sr">Logitech iTouch</description>
+        <description xml:lang="sv">Logitech iTouch</description>
+        <description xml:lang="tr">Logitech iTouch</description>
+        <description xml:lang="uk">Logitech iTouch</description>
+        <description xml:lang="vi">Logitech iTouch</description>
+        <description xml:lang="zh_CN">罗技 iTouch</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logiitc</name>
+        <description>Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="af">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="az">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="cs">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="da">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="en_GB">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="fr">clavier Logitech iTouch Cordless (model Y-RB6)</description>
+        <description xml:lang="hu">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="nl">Logitech iTouch draadloos toetsenbord (model Y-RB6)</description>
+        <description xml:lang="ru">Logitech iTouch Cordless Keyboard (модель Y-RB6)</description>
+        <description xml:lang="rw">Urugero</description>
+        <description xml:lang="sk">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="sq">Logitech iTouch Cordless Keyboard (model Y-RB6)</description>
+        <description xml:lang="sr">Logitech iTouch Cordless тастатура (модел Y-RB6)</description>
+        <description xml:lang="sv">Logitech iTouch Cordless Keyboard (modell Y-RB6)</description>
+        <description xml:lang="tr">Logitech iTouch Kablosuz Klavyesi (model Y-RB6)</description>
+        <description xml:lang="uk">Logitech iTouch Cordless Keyboard (модель Y-RB6)</description>
+        <description xml:lang="vi">Bàn phím Không dây Logitech iTouch (mẫu mã Y-RB6)</description>
+        <description xml:lang="zh_CN">罗技 iTouch 无影手键盘(型号 Y-RB6)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logiik</name>
+        <description>Logitech Internet Keyboard</description>
+        <description xml:lang="af">Logitech Internet Keyboard</description>
+        <description xml:lang="az">Logitech Internet Keyboard</description>
+        <description xml:lang="bg">Logitech Интернет клавиатура</description>
+        <description xml:lang="cs">Logitech Internet Keyboard</description>
+        <description xml:lang="da">Logitech Internet Keyboard</description>
+        <description xml:lang="en_GB">Logitech Internet Keyboard</description>
+        <description xml:lang="fr">clavier Logitech Internet</description>
+        <description xml:lang="hu">Logitech Internet Keyboard</description>
+        <description xml:lang="nl">Logitech internet toetsenbord</description>
+        <description xml:lang="ru">Logitech Internet Keyboard</description>
+        <description xml:lang="sk">Logitech Internet Keyboard</description>
+        <description xml:lang="sq">Tastierë për Internet Logitech</description>
+        <description xml:lang="sr">Logitech Интернет тастатура</description>
+        <description xml:lang="sv">Logitech Internettangentbord</description>
+        <description xml:lang="tr">Logitech Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Logitech Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím Internet Logitech</description>
+        <description xml:lang="zh_CN">罗技网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logiink</name>
+        <description>Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="af">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="az">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="bg">Logitech клавиатура за Интернет навигация</description>
+        <description xml:lang="cs">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="da">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="en_GB">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="fr">clavier Logitech Internet Navigator</description>
+        <description xml:lang="hu">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="nl">Logitech Internet Navigator toetsenbord</description>
+        <description xml:lang="ru">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="sk">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="sq">Tastierë Logitech Internet Navigator</description>
+        <description xml:lang="sr">Logitech Интернет навигатор тастатура</description>
+        <description xml:lang="sv">Logitech Internet Navigator-tangentbord</description>
+        <description xml:lang="tr">Logitech Örütbağ Tarayıcı Klavyesi</description>
+        <description xml:lang="uk">Logitech Internet Navigator Keyboard</description>
+        <description xml:lang="vi">Bàn phím Logitech Internet Navigator</description>
+        <description xml:lang="zh_CN">罗技网际导航键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>itouchin</name>
+        <description>Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="af">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="az">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="bg">Logitech клавиатура за Интернет навигация</description>
+        <description xml:lang="cs">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="da">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="en_GB">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="fr">clavier Logitech iTouch Internet Navigator</description>
+        <description xml:lang="hu">Logitech iTouch Keyboard Internet Navigator</description>
+        <description xml:lang="nl">Logitech iTouch toetsenbord Internet Navigator</description>
+        <description xml:lang="ru">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="rw">Mwandikisho</description>
+        <description xml:lang="sk">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="sq">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="sr">Logitech iTouch тастатура Интернет навигатор</description>
+        <description xml:lang="sv">Logitech iTouch-tangentbord Internet Navigator</description>
+        <description xml:lang="tr">Logitech iTouch klavyesi Örütbağ Tarayıcı</description>
+        <description xml:lang="uk">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="vi">Logitech iTouch keyboard Internet Navigator</description>
+        <description xml:lang="zh_CN">罗技 iTouch 键盘网际导航器</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>logiultrax</name>
+        <description>Logitech Ultra-X Keyboard</description>
+        <description xml:lang="ru">Logitech Ultra-X Keyboard</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>mx1998</name>
+        <description>Memorex MX1998</description>
+        <description xml:lang="af">Memorex MX1998</description>
+        <description xml:lang="az">Memorex MX1998</description>
+        <description xml:lang="cs">Memorex MX1998</description>
+        <description xml:lang="da">Memorex MX1998</description>
+        <description xml:lang="en_GB">Memorex MX1998</description>
+        <description xml:lang="fr">Memorex MX1998</description>
+        <description xml:lang="hu">Memorex MX1998</description>
+        <description xml:lang="nl">Memorex MX1998</description>
+        <description xml:lang="ru">Memorex MX1998</description>
+        <description xml:lang="sk">Memorex MX1998</description>
+        <description xml:lang="sq">Memorex MX1998</description>
+        <description xml:lang="sr">Memorex MX1998</description>
+        <description xml:lang="sv">Memorex MX1998</description>
+        <description xml:lang="tr">Memorex MX1998</description>
+        <description xml:lang="uk">Memorex MX1998</description>
+        <description xml:lang="vi">Memorex MX1998</description>
+        <description xml:lang="zh_CN">Memorex MX1998</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>mx2500</name>
+        <description>Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="af">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="az">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="cs">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="da">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="en_GB">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="fr">clavier Memorex MX2500 EZ-Access</description>
+        <description xml:lang="hu">Memorex MX2500 EZ-Access billentyűzet</description>
+        <description xml:lang="nl">Memorex MX2500 EZ-Access toetsenbord</description>
+        <description xml:lang="ru">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="sk">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="sq">Tastierë Memorex MX2500 EZ-Access</description>
+        <description xml:lang="sr">Memorex MX2500 EZ-Access тастатура</description>
+        <description xml:lang="sv">Memorex MX2500 EZ-Access-tangentbord</description>
+        <description xml:lang="tr">Memorex MX2500 EZ Erişim Klavyesi</description>
+        <description xml:lang="uk">Memorex MX2500 EZ-Access Keyboard</description>
+        <description xml:lang="vi">Bàn phím Memorex MX2500 EZ-Access</description>
+        <description xml:lang="zh_CN">Memorex MX2500 EZ-Access 键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>mx2750</name>
+        <description>Memorex MX2750</description>
+        <description xml:lang="af">Memorex MX2750</description>
+        <description xml:lang="az">Memorex MX2750</description>
+        <description xml:lang="cs">Memorex MX2750</description>
+        <description xml:lang="da">Memorex MX2750</description>
+        <description xml:lang="en_GB">Memorex MX2750</description>
+        <description xml:lang="fr">Memorex MX2750</description>
+        <description xml:lang="hu">Memorex MX2750</description>
+        <description xml:lang="nl">Memorex MX2750</description>
+        <description xml:lang="ru">Memorex MX2750</description>
+        <description xml:lang="sk">Memorex MX2750</description>
+        <description xml:lang="sq">Memorex MX2750</description>
+        <description xml:lang="sr">Memorex MX2750</description>
+        <description xml:lang="sv">Memorex MX2750</description>
+        <description xml:lang="tr">Memorex MX2750</description>
+        <description xml:lang="uk">Memorex MX2750</description>
+        <description xml:lang="vi">Memorex MX2750</description>
+        <description xml:lang="zh_CN">Memorex MX2750</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoftinet</name>
+        <description>Microsoft Internet Keyboard</description>
+        <description xml:lang="af">Microsoft Internetsleutelbord</description>
+        <description xml:lang="az">Microsoft Internet Keyboard</description>
+        <description xml:lang="bg">Интернет клавиатура на Chicony</description>
+        <description xml:lang="cs">Microsoft Internet Keyboard</description>
+        <description xml:lang="da">Microsoft Internet Keyboard</description>
+        <description xml:lang="en_GB">Microsoft Internet Keyboard</description>
+        <description xml:lang="fr">clavier Microsoft Internet</description>
+        <description xml:lang="hu">Microsoft Internet Keyboard</description>
+        <description xml:lang="nl">Microsoft internet toetsenbord</description>
+        <description xml:lang="ru">Microsoft Internet Keyboard</description>
+        <description xml:lang="sk">Microsoft Internet Keyboard</description>
+        <description xml:lang="sq">Tastierë Microsoft Internet</description>
+        <description xml:lang="sr">Микрософтова Интернет тастатура</description>
+        <description xml:lang="sv">Microsoft Internet Keyboard</description>
+        <description xml:lang="tr">Microsoft Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Microsoft Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím Internet Microsoft</description>
+        <description xml:lang="zh_CN">微软网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoftpro</name>
+        <description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="af">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="az">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="cs">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="da">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="en_GB">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="fr">clavier Microsoft Natural Pro / Microsoft Internet Pro</description>
+        <description xml:lang="hu">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="nl">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="ru">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="sk">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="sq">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="sr">Микрософт Натурал тастатура Про / Микрософт Интернет тастатура Про </description>
+        <description xml:lang="sv">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="tr">Microsoft Basit Klavye Pro / Microsoft Örütbağ Klavyesi Pro</description>
+        <description xml:lang="uk">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="vi">Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="zh_CN">微软自然键盘增强版/微软网际键盘增强版</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoftprousb</name>
+        <description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="en_GB">Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="nl">Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="ru">Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</description>
+        <description xml:lang="vi">Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoftprooem</name>
+        <description>Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="af">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="az">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="bg">Microsoft Natural Pro</description>
+        <description xml:lang="cs">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="da">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="en_GB">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="fr">clavier Microsoft Natural Pro OEM</description>
+        <description xml:lang="hu">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="nl">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="ru">Microsoft·Natural·Keyboard·Pro·OEM</description>
+        <description xml:lang="sk">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="sq">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="sr">Микрософт Натурал тастатура Про ОЕМ</description>
+        <description xml:lang="sv">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="tr">Microsoft Basit Klavye Pro OEM</description>
+        <description xml:lang="uk">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="vi">Microsoft Natural Keyboard Pro OEM</description>
+        <description xml:lang="zh_CN">微软自然键盘增强版 OEM</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoftprose</name>
+        <description>Microsoft Internet Keyboard Pro, Swedish</description>
+        <description xml:lang="af">Microsoft Internet Keyboard Pro, Sweeds</description>
+        <description xml:lang="az">Microsoft Internet Keyboard Pro, Swedish</description>
+        <description xml:lang="bg">Интернет клавиатура на Chicony</description>
+        <description xml:lang="cs">Microsoft Internet Keyboard Pro, Švédská</description>
+        <description xml:lang="da">Microsoft Internet Keyboard Pro, svensk</description>
+        <description xml:lang="en_GB">Microsoft Internet Keyboard Pro, Swedish</description>
+        <description xml:lang="fr">clavier Microsoft Internet Pro, Suédois</description>
+        <description xml:lang="hu">Microsoft Internet Keyboard Pro, svéd</description>
+        <description xml:lang="nl">Microsoft Internet Keyboard Pro, Zweeds</description>
+        <description xml:lang="ru">Microsoft Internet Keyboard Pro, шведская</description>
+        <description xml:lang="sk">Microsoft Internet Keyboard Pro, Švédska</description>
+        <description xml:lang="sq">Microsoft Internet Keyboard Pro, Suedeze</description>
+        <description xml:lang="sr">Микрософтова Интернет Про тастатура, шведски</description>
+        <description xml:lang="sv">Microsoft Internet Keyboard Pro, svensk</description>
+        <description xml:lang="tr">Microsoft Örütbağ Klavyesi Pro, İsveçce</description>
+        <description xml:lang="uk">Microsoft Internet Keyboard Pro, шведська</description>
+        <description xml:lang="vi">Bàn phím Internet Microsoft Pro, Thụy Điển</description>
+        <description xml:lang="zh_CN">微软网际键盘增强版,瑞典</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoftoffice</name>
+        <description>Microsoft Office Keyboard</description>
+        <description xml:lang="af">Microsoft Office sleutelbord</description>
+        <description xml:lang="az">Microsoft Office Keyboard</description>
+        <description xml:lang="cs">Microsoft Office Keyboard</description>
+        <description xml:lang="da">Microsoft Office Keyboard</description>
+        <description xml:lang="en_GB">Microsoft Office Keyboard</description>
+        <description xml:lang="fr">clavier Microsoft Office</description>
+        <description xml:lang="hu">Microsoft Office billentyűzet</description>
+        <description xml:lang="nl">Microsoft Office toetsenbord</description>
+        <description xml:lang="ru">Microsoft Office Keyboard</description>
+        <description xml:lang="sk">Microsoft Office Keyboard</description>
+        <description xml:lang="sq">Tastierë Microsoft Office</description>
+        <description xml:lang="sr">Микрософтова канцеларијска тастатура</description>
+        <description xml:lang="sv">Microsoft Office-tangentbord</description>
+        <description xml:lang="tr">Microsoft Ofis Klavyesi</description>
+        <description xml:lang="uk">Microsoft Office Keyboard</description>
+        <description xml:lang="vi">Bàn phím Văn phòng Microsoft</description>
+        <description xml:lang="zh_CN">微软 Office 键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>microsoftmult</name> 
+        <description>Microsoft Wireless Multimedia Keyboard 1.0A</description>
+        <description xml:lang="en_GB">Microsoft Wireless Multimedia Keyboard 1.0A</description>
+        <description xml:lang="nl">Microsoft draadloos multimediatoetsenbord 1.0A</description>
+        <description xml:lang="ru">Microsoft Wireless Multimedia Keyboard 1.0A</description>
+        <description xml:lang="rw">1.</description>
+        <description xml:lang="vi">Microsoft Wireless Multimedia Keyboard 1.0A</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>oretec</name>
+        <description>Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="af">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="az">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="bg">Logitech Интернет клавиатура</description>
+        <description xml:lang="cs">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="da">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="en_GB">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="fr">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="hu">Oretec MCK-800 MM/Internet billentyűzet</description>
+        <description xml:lang="nl">Oretec MCK-800 MM/Internet toetsenbord</description>
+        <description xml:lang="ru">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="rw">Mwandikisho</description>
+        <description xml:lang="sk">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="sq">Tastierë Oretec MCK-800 MM/Internet</description>
+        <description xml:lang="sr">Oretec MCK-800 ММ/Интернет тастатура</description>
+        <description xml:lang="sv">Oretec MCK-800 MM/Internet-tangentbord</description>
+        <description xml:lang="tr">Oretec MCK-800 MM/Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Oretec MCK-800 MM/Internet keyboard</description>
+        <description xml:lang="vi">Bàn phím Oretec MCK-800 MM/Internet</description>
+        <description xml:lang="zh_CN">Oretec MCK-800 MM/网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>propeller</name>
+        <description>Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="af">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="az">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="cs">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="da">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="en_GB">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="fr">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="hu">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="nl">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="ru">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="rw">1000</description>
+        <description xml:lang="sk">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="sq">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="sr">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="sv">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="tr">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="uk">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="vi">Propeller Voyager (KTEZ-1000)</description>
+        <description xml:lang="zh_CN">Propeller Voyager (KTEZ-1000)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>qtronix</name>
+        <description>QTronix Scorpius 98N+</description>
+        <description xml:lang="af">QTronix Scorpius 98N+</description>
+        <description xml:lang="az">QTronix Scorpius 98N+</description>
+        <description xml:lang="cs">QTronix Scorpius 98N+</description>
+        <description xml:lang="da">QTronix Scorpius 98N+</description>
+        <description xml:lang="en_GB">QTronix Scorpius 98N+</description>
+        <description xml:lang="fr">QTronix Scorpius 98N+</description>
+        <description xml:lang="hu">QTronix Scorpius 98N+</description>
+        <description xml:lang="nl">QTronix Scorpius 98N+</description>
+        <description xml:lang="ru">QTronix Scorpius 98N+</description>
+        <description xml:lang="sk">QTronix Scorpius 98N+</description>
+        <description xml:lang="sq">QTronix Scorpius 98N+</description>
+        <description xml:lang="sr">QTronix Scorpius 98N+</description>
+        <description xml:lang="sv">QTronix Scorpius 98N+</description>
+        <description xml:lang="tr">QTronix Scorpius 98N+</description>
+        <description xml:lang="uk">QTronix Scorpius 98N+</description>
+        <description xml:lang="vi">QTronix Scorpius 98N+</description>
+        <description xml:lang="zh_CN">QTronix Scorpius 98N+</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>samsung4500</name>
+        <description>Samsung SDM 4500P</description>
+        <description xml:lang="af">Samsung SDM 4500P</description>
+        <description xml:lang="az">Samsung SDM 4500P</description>
+        <description xml:lang="cs">Samsung SDM 4500P</description>
+        <description xml:lang="da">Samsung SDM 4500P</description>
+        <description xml:lang="en_GB">Samsung SDM 4500P</description>
+        <description xml:lang="fr">Samsung SDM 4500P</description>
+        <description xml:lang="hu">Samsung SDM 4500P</description>
+        <description xml:lang="nl">Samsung SDM 4500P</description>
+        <description xml:lang="ru">Samsung SDM 4500P</description>
+        <description xml:lang="sk">Samsung SDM 4500P</description>
+        <description xml:lang="sq">Samsung SDM 4500P</description>
+        <description xml:lang="sr">Samsung SDM 4500P</description>
+        <description xml:lang="sv">Samsung SDM 4500P</description>
+        <description xml:lang="tr">Samsung SDM 4500P</description>
+        <description xml:lang="uk">Samsung SDM 4500P</description>
+        <description xml:lang="vi">Samsung SDM 4500P</description>
+        <description xml:lang="zh_CN">三星 SDM 4500P</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>samsung4510</name>
+        <description>Samsung SDM 4510P</description>
+        <description xml:lang="af">Samsung SDM 4510P</description>
+        <description xml:lang="az">Samsung SDM 4510P</description>
+        <description xml:lang="cs">Samsung SDM 4510P</description>
+        <description xml:lang="da">Samsung SDM 4510P</description>
+        <description xml:lang="en_GB">Samsung SDM 4510P</description>
+        <description xml:lang="fr">Samsung SDM 4510P</description>
+        <description xml:lang="hu">Samsung SDM 4510P</description>
+        <description xml:lang="nl">Samsung SDM 4510P</description>
+        <description xml:lang="ru">Samsung SDM 4510P</description>
+        <description xml:lang="sk">Samsung SDM 4510P</description>
+        <description xml:lang="sq">Samsung SDM 4510P</description>
+        <description xml:lang="sr">Samsung SDM 4510P</description>
+        <description xml:lang="sv">Samsung SDM 4510P</description>
+        <description xml:lang="tr">Samsung SDM 4510P</description>
+        <description xml:lang="uk">Samsung SDM 4510P</description>
+        <description xml:lang="vi">Samsung SDM 4510P</description>
+        <description xml:lang="zh_CN">三星 SDM 4510P</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sk1300</name>
+        <description>SK-1300</description>
+        <description xml:lang="af">SK-1300</description>
+        <description xml:lang="az">SK-1300</description>
+        <description xml:lang="cs">SK-1300</description>
+        <description xml:lang="da">SK-1300</description>
+        <description xml:lang="en_GB">SK-1300</description>
+        <description xml:lang="fr">SK-1300</description>
+        <description xml:lang="hu">SK-1300</description>
+        <description xml:lang="nl">SK-1300</description>
+        <description xml:lang="ru">SK-1300</description>
+        <description xml:lang="sk">SK-1300</description>
+        <description xml:lang="sq">SK-1300</description>
+        <description xml:lang="sr">SK-1300</description>
+        <description xml:lang="sv">SK-1300</description>
+        <description xml:lang="tr">SK-1300</description>
+        <description xml:lang="uk">SK-1300</description>
+        <description xml:lang="vi">SK-1300</description>
+        <description xml:lang="zh_CN">SK-1300</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sk2500</name>
+        <description>SK-2500</description>
+        <description xml:lang="af">SK-2500</description>
+        <description xml:lang="az">SK-2500</description>
+        <description xml:lang="cs">SK-2500</description>
+        <description xml:lang="da">SK-2500</description>
+        <description xml:lang="en_GB">SK-2500</description>
+        <description xml:lang="fr">SK-2500</description>
+        <description xml:lang="hu">SK-2500</description>
+        <description xml:lang="nl">SK-2500</description>
+        <description xml:lang="ru">SK-2500</description>
+        <description xml:lang="sk">SK-2500</description>
+        <description xml:lang="sq">SK-2500</description>
+        <description xml:lang="sr">SK-2500</description>
+        <description xml:lang="sv">SK-2500</description>
+        <description xml:lang="tr">SK-2500</description>
+        <description xml:lang="uk">SK-2500</description>
+        <description xml:lang="vi">SK-2500</description>
+        <description xml:lang="zh_CN">SK-2500</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sk6200</name>
+        <description>SK-6200</description>
+        <description xml:lang="af">SK-6200</description>
+        <description xml:lang="az">SK-6200</description>
+        <description xml:lang="cs">SK-6200</description>
+        <description xml:lang="da">SK-6200</description>
+        <description xml:lang="en_GB">SK-6200</description>
+        <description xml:lang="fr">SK-6200</description>
+        <description xml:lang="hu">SK-6200</description>
+        <description xml:lang="nl">SK-6200</description>
+        <description xml:lang="ru">SK-6200</description>
+        <description xml:lang="sk">SK-6200</description>
+        <description xml:lang="sq">SK-6200</description>
+        <description xml:lang="sr">SK-6200</description>
+        <description xml:lang="sv">SK-6200</description>
+        <description xml:lang="tr">SK-6200</description>
+        <description xml:lang="uk">SK-6200</description>
+        <description xml:lang="vi">SK-6200</description>
+        <description xml:lang="zh_CN">SK-6200</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sk7100</name>
+        <description>SK-7100</description>
+        <description xml:lang="af">SK-7100</description>
+        <description xml:lang="az">SK-7100</description>
+        <description xml:lang="cs">SK-7100</description>
+        <description xml:lang="da">SK-7100</description>
+        <description xml:lang="en_GB">SK-7100</description>
+        <description xml:lang="fr">SK-7100</description>
+        <description xml:lang="hu">SK-7100</description>
+        <description xml:lang="nl">SK-7100</description>
+        <description xml:lang="ru">SK-7100</description>
+        <description xml:lang="sk">SK-7100</description>
+        <description xml:lang="sq">SK-7100</description>
+        <description xml:lang="sr">SK-7100</description>
+        <description xml:lang="sv">SK-7100</description>
+        <description xml:lang="tr">SK-7100</description>
+        <description xml:lang="uk">SK-7100</description>
+        <description xml:lang="vi">SK-7100</description>
+        <description xml:lang="zh_CN">SK-7100</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sp_inet</name>
+        <description>Super Power Multimedia Keyboard</description>
+        <description xml:lang="en_GB">Super Power Multimedia Keyboard</description>
+        <description xml:lang="nl">Super Power multimediatoetsenbord</description>
+        <description xml:lang="ru">Super Power Multimedia Keyboard</description>
+        <description xml:lang="vi">Bàn phím Phim nhạc Siêu Năng Lực</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>sven</name>
+        <description>SVEN Ergonomic 2500</description>
+        <description xml:lang="af">SVEN Ergonomic 2500</description>
+        <description xml:lang="az">SVEN Ergonomic 2500</description>
+        <description xml:lang="cs">SVEN Ergonomic 2500</description>
+        <description xml:lang="da">SVEN Ergonomic 2500</description>
+        <description xml:lang="en_GB">SVEN Ergonomic 2500</description>
+        <description xml:lang="fr">SVEN Ergonomic 2500</description>
+        <description xml:lang="hu">SVEN Ergonomic 2500</description>
+        <description xml:lang="nl">SVEN Ergonomic 2500</description>
+        <description xml:lang="ru">SVEN Ergonomic 2500</description>
+        <description xml:lang="sk">SVEN Ergonomic 2500</description>
+        <description xml:lang="sq">SVEN Ergonomic 2500</description>
+        <description xml:lang="sr">SVEN ергономска 2500</description>
+        <description xml:lang="sv">SVEN Ergonomic 2500</description>
+        <description xml:lang="tr">SVEN Ergonomik 2500</description>
+        <description xml:lang="uk">SVEN Ergonomic 2500</description>
+        <description xml:lang="vi">SVEN Ergonomic 2500</description>
+        <description xml:lang="zh_CN">SVEN Ergonomic 2500</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>symplon</name>
+        <description>Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="af">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="az">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="cs">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="da">Symplon PaceBook (tablet-pc)</description>
+        <description xml:lang="en_GB">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="fr">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="hu">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="nl">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="ru">Symplon PaceBook (карманный ПК)</description>
+        <description xml:lang="sk">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="sq">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="sr">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="sv">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="tr">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="uk">Symplon PaceBook (переносний ПК)</description>
+        <description xml:lang="vi">Symplon PaceBook (tablet PC)</description>
+        <description xml:lang="zh_CN">Symplon PaceBook(平板电脑)</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>toshiba_s3000</name>
+        <description>Toshiba Satellite S3000</description>
+        <description xml:lang="af">Toshiba Satellite S3000</description>
+        <description xml:lang="az">Toshiba Satellite S3000</description>
+        <description xml:lang="cs">Toshiba Satellite S3000</description>
+        <description xml:lang="da">Toshiba Satellite S3000</description>
+        <description xml:lang="en_GB">Toshiba Satellite S3000</description>
+        <description xml:lang="fr">Toshiba Satellite S3000</description>
+        <description xml:lang="hu">Toshiba Satellite S3000</description>
+        <description xml:lang="nl">Toshiba Satellite S3000</description>
+        <description xml:lang="ru">Toshiba Satellite S3000</description>
+        <description xml:lang="sk">Toshiba Satellite S3000</description>
+        <description xml:lang="sq">Toshiba Satellite S3000</description>
+        <description xml:lang="sr">Toshiba Satellite S3000</description>
+        <description xml:lang="sv">Toshiba Satellite S3000</description>
+        <description xml:lang="tr">Toshiba Satellite S3000</description>
+        <description xml:lang="uk">Toshiba Satellite S3000</description>
+        <description xml:lang="vi">Toshiba Satellite S3000</description>
+        <description xml:lang="zh_CN">东芝 Satellite S3000</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>trust</name>
+        <description>Trust Wireless Keyboard Classic</description>
+        <description xml:lang="af">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="az">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="cs">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="da">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="en_GB">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="fr">clavier classique Trust Wireless</description>
+        <description xml:lang="hu">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="nl">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="ru">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="sk">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="sq">Tastierë klasike Trust Wireless</description>
+        <description xml:lang="sr">Trust класична бежична тастатура</description>
+        <description xml:lang="sv">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="tr">Trust Kablosuz Klasik Klavye</description>
+        <description xml:lang="uk">Trust Wireless Keyboard Classic</description>
+        <description xml:lang="vi">Bàn Phím Cổ điển Không dây Tin tưởng</description>
+        <description xml:lang="zh_CN">Trust 无线经典键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>trustda</name>
+        <description>Trust Direct Access Keyboard</description>
+        <description xml:lang="af">Trust Direct Access Keyboard</description>
+        <description xml:lang="az">Trust Direct Access Keyboard</description>
+        <description xml:lang="cs">Trust Direct Access Keyboard</description>
+        <description xml:lang="da">Trust Direct Access Keyboard</description>
+        <description xml:lang="en_GB">Trust Direct Access Keyboard</description>
+        <description xml:lang="fr">clavier Trust Direct Access</description>
+        <description xml:lang="hu">Trust Direct Access billentyűzet</description>
+        <description xml:lang="nl">Trust Direct Access toetsenbord</description>
+        <description xml:lang="ru">Trust Direct Access Keyboard</description>
+        <description xml:lang="sk">Trust Direct Access Keyboard</description>
+        <description xml:lang="sq">Tastierë Trust Direct Access</description>
+        <description xml:lang="sr">Trust Direct Access тастатура</description>
+        <description xml:lang="sv">Trust Direct Access-tangentbord</description>
+        <description xml:lang="tr">Trust Doğrudan Erişimli Klavye</description>
+        <description xml:lang="uk">Trust Direct Access Keyboard</description>
+        <description xml:lang="vi">Bàn phím Truy cập Thẳng Tin tưởng</description>
+        <description xml:lang="zh_CN">Trust Direct Access 键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>yahoo</name>
+        <description>Yahoo! Internet Keyboard</description>
+        <description xml:lang="af">Yahoo! Internetsleutelbord</description>
+        <description xml:lang="az">Yahoo! Internet Keyboard</description>
+        <description xml:lang="bg">Интернет клавиатура на Chicony</description>
+        <description xml:lang="cs">Yahoo! Internet Keyboard</description>
+        <description xml:lang="da">Yahoo! Internet Keyboard</description>
+        <description xml:lang="en_GB">Yahoo! Internet Keyboard</description>
+        <description xml:lang="fr">clavier Yahoo! Internet</description>
+        <description xml:lang="hu">Yahoo! Internet billentyűzet</description>
+        <description xml:lang="nl">Yahoo! internet toetsenbord</description>
+        <description xml:lang="ru">Yahoo! Internet Keyboard</description>
+        <description xml:lang="sk">Yahoo! Internet Keyboard</description>
+        <description xml:lang="sq">Tastierë Yahoo! Internet</description>
+        <description xml:lang="sr">Yahoo! Интернет тастатура</description>
+        <description xml:lang="sv">Yahoo! Internettangentbord</description>
+        <description xml:lang="tr">Yahoo! Örütbağ Klavyesi</description>
+        <description xml:lang="uk">Yahoo! Internet Keyboard</description>
+        <description xml:lang="vi">Bàn phím Internet Yahoo! </description>
+        <description xml:lang="zh_CN">雅虎网际键盘</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>macintosh</name>
+        <description>Macintosh</description>
+        <description xml:lang="af">Macintosh</description>
+        <description xml:lang="az">Macintosh</description>
+        <description xml:lang="cs">Macintosh</description>
+        <description xml:lang="da">Macintosh</description>
+        <description xml:lang="en_GB">Macintosh</description>
+        <description xml:lang="fr">Macintosh</description>
+        <description xml:lang="hu">Macintosh</description>
+        <description xml:lang="nl">Macintosh</description>
+        <description xml:lang="ru">Macintosh</description>
+        <description xml:lang="rw">masinitoshi</description>
+        <description xml:lang="sk">Macintosh</description>
+        <description xml:lang="sq">Macintosh</description>
+        <description xml:lang="sr">Мекинтош</description>
+        <description xml:lang="sv">Macintosh</description>
+        <description xml:lang="tr">Macintosh</description>
+        <description xml:lang="uk">Macintosh</description>
+        <description xml:lang="vi">Macintosh</description>
+        <description xml:lang="zh_CN">Macintosh</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>macintosh_old</name>
+        <description>Macintosh Old</description>
+        <description xml:lang="af">Macintosh (oud)</description>
+        <description xml:lang="az">Macintosh Old</description>
+        <description xml:lang="cs">Macintosh staré</description>
+        <description xml:lang="da">Macintosh gammel</description>
+        <description xml:lang="en_GB">Macintosh Old</description>
+        <description xml:lang="fr">Macintosh ancien</description>
+        <description xml:lang="hu">Macintosh Old</description>
+        <description xml:lang="nl">Macintosh oud</description>
+        <description xml:lang="ru">Старый Macintosh</description>
+        <description xml:lang="sk">Macintosh staré</description>
+        <description xml:lang="sq">Macintosh i vjetër</description>
+        <description xml:lang="sr">Стари Мекинтош</description>
+        <description xml:lang="sv">Macintosh gammal</description>
+        <description xml:lang="tr">Eski Macintosh</description>
+        <description xml:lang="uk">Старий Macintosh</description>
+        <description xml:lang="vi">Macintosh Cũ</description>
+        <description xml:lang="zh_CN">Macintosh 旧产品</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>powerpcps2</name>
+        <description>PowerPC PS/2</description>
+        <description xml:lang="af">PowerPC PS/2</description>
+        <description xml:lang="az">PowerPC PS/2</description>
+        <description xml:lang="cs">PowerPC PS/2</description>
+        <description xml:lang="da">PowerPC PS/2</description>
+        <description xml:lang="en_GB">PowerPC PS/2</description>
+        <description xml:lang="fr">PowerPC PS/2</description>
+        <description xml:lang="hu">PowerPC PS/2</description>
+        <description xml:lang="nl">PowerPC PS/2</description>
+        <description xml:lang="ru">PowerPC PS/2</description>
+        <description xml:lang="rw">2.</description>
+        <description xml:lang="sk">PowerPC PS/2</description>
+        <description xml:lang="sq">PowerPC PS/2</description>
+        <description xml:lang="sr">PowerPC PS/2</description>
+        <description xml:lang="sv">PowerPC PS/2</description>
+        <description xml:lang="tr">PowerPC PS/2</description>
+        <description xml:lang="uk">PowerPC PS/2</description>
+        <description xml:lang="vi">PowerPC PS/2</description>
+        <description xml:lang="zh_CN">PowerPC PS/2</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
+        <name>acer_tm_800</name>
+        <description>Acer TravelMate 800</description>
+        <description xml:lang="en_GB">Acer TravelMate 800</description>
+        <description xml:lang="ru">Acer TravelMate 800</description>
+      </configItem>
+    </model>
+  </modelList>
+  <layoutList>
+    <layout>
+      <configItem>
+        <name>us</name>
+        <shortDescription>USA</shortDescription>
+        <shortDescription xml:lang="af">VSA</shortDescription>
+        <shortDescription xml:lang="az">ABŞ</shortDescription>
+        <shortDescription xml:lang="cs">USA</shortDescription>
+        <shortDescription xml:lang="da">USA</shortDescription>
+        <shortDescription xml:lang="el">ΗΠΑ</shortDescription>
+        <shortDescription xml:lang="en_GB">USA</shortDescription>
+        <shortDescription xml:lang="fr">USA</shortDescription>
+        <shortDescription xml:lang="hu">USA</shortDescription>
+        <shortDescription xml:lang="nl">USA</shortDescription>
+        <shortDescription xml:lang="ru">США</shortDescription>
+        <shortDescription xml:lang="rw">Amerika</shortDescription>
+        <shortDescription xml:lang="sk">USA</shortDescription>
+        <shortDescription xml:lang="sq">USA</shortDescription>
+        <shortDescription xml:lang="sr">САД</shortDescription>
+        <shortDescription xml:lang="sv">USA</shortDescription>
+        <shortDescription xml:lang="tr">ABD</shortDescription>
+        <shortDescription xml:lang="uk">США</shortDescription>
+        <shortDescription xml:lang="vi">Mỹ</shortDescription>
+        <shortDescription xml:lang="zh_CN">USA</shortDescription>
+        <description>U.S. English</description>
+        <description xml:lang="af">VSA Engels</description>
+        <description xml:lang="az">A.B.Ş. İngiliscəsi</description>
+        <description xml:lang="bg">американска английска</description>
+        <description xml:lang="cs">Anglické (US)</description>
+        <description xml:lang="da">U.S. Engelsk</description>
+        <description xml:lang="el">Αγγλικά ΗΠΑ</description>
+        <description xml:lang="en_GB">U.S. English</description>
+        <description xml:lang="fr">Anglais U.S.</description>
+        <description xml:lang="hu">amerikai angol</description>
+        <description xml:lang="nl">Amerikaans-Engels</description>
+        <description xml:lang="ru">Английская (США)</description>
+        <description xml:lang="rw">U.</description>
+        <description xml:lang="sk">U.S.A. anglické</description>
+        <description xml:lang="sq">U.S. Anglisht</description>
+        <description xml:lang="sr">амерички енглески</description>
+        <description xml:lang="sv">Engelskamerikansk</description>
+        <description xml:lang="tr">Amerikan ingilizcesi</description>
+        <description xml:lang="uk">Англійська (США)</description>
+        <description xml:lang="vi">Anh Mỹ</description>
+        <description xml:lang="zh_CN">美国英语</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>intl</name>
+            <description>International (with dead keys)</description>
+            <description xml:lang="en_GB">International (with dead keys)</description>
+            <description xml:lang="nl">Internationaal (met dode toetsen)</description>
+            <description xml:lang="ru">Международная, со спец. клавишами (dead keys)</description>
+            <description xml:lang="rw">Na: Utubuto</description>
+            <description xml:lang="vi">Quốc tế (với phím chết)</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>alt-intl</name>
+            <description>Alternative international (former us_intl)</description>
+            <description xml:lang="en_GB">Alternative international (former us_intl)</description>
+            <description xml:lang="nl">Alternatief internationaal (voormalig us_intl)</description>
+            <description xml:lang="ru">Альтернативная международная (бывшая us_intl)</description>
+            <description xml:lang="rw">Mpuzamahanga</description>
+            <description xml:lang="vi">Quốc tế tương đương (cũ us_intl)</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>rus</name>
+            <description>Russian phonetic</description>
+            <description xml:lang="ru">Русская фонетическая</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ara</name>
+        <shortDescription>Ara</shortDescription>
+        <shortDescription xml:lang="el">Αρα</shortDescription>
+        <shortDescription xml:lang="en_GB">Ara</shortDescription>
+        <shortDescription xml:lang="nl">Fra</shortDescription>
+        <shortDescription xml:lang="ru">Ара</shortDescription>
+        <shortDescription xml:lang="vi">Ara</shortDescription>
+        <description>Arabic</description>
+        <description xml:lang="af">Arabies</description>
+        <description xml:lang="az">Ərəbcə</description>
+        <description xml:lang="bg">арабска</description>
+        <description xml:lang="cs">Arabské</description>
+        <description xml:lang="da">Arabisk</description>
+        <description xml:lang="el">Αραβικό</description>
+        <description xml:lang="en_GB">Arabic</description>
+        <description xml:lang="fr">Arabe</description>
+        <description xml:lang="hu">arab</description>
+        <description xml:lang="nl">Arabisch</description>
+        <description xml:lang="ru">Арабская</description>
+        <description xml:lang="rw">Icyarabu</description>
+        <description xml:lang="sk">Arabsky</description>
+        <description xml:lang="sq">Arabe</description>
+        <description xml:lang="sr">арапски</description>
+        <description xml:lang="sv">Arabisk</description>
+        <description xml:lang="tr">Arapça</description>
+        <description xml:lang="uk">Арабська</description>
+        <description xml:lang="vi">Ả Rập</description>
+        <description xml:lang="zh_CN">阿拉伯</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>azerty</name>
+            <description>azerty</description>
+            <description xml:lang="af">azerty</description>
+            <description xml:lang="az">azerty</description>
+            <description xml:lang="cs">azerty</description>
+            <description xml:lang="da">azerty</description>
+            <description xml:lang="en_GB">azerty</description>
+            <description xml:lang="fr">azerty</description>
+            <description xml:lang="hu">azerty</description>
+            <description xml:lang="nl">azerty</description>
+            <description xml:lang="ru">azerty</description>
+            <description xml:lang="sk">azerty</description>
+            <description xml:lang="sq">azerty</description>
+            <description xml:lang="sr">azerty</description>
+            <description xml:lang="sv">azerty</description>
+            <description xml:lang="tr">azerty</description>
+            <description xml:lang="uk">azerty</description>
+            <description xml:lang="vi">azerty</description>
+            <description xml:lang="zh_CN">azerty</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>azerty_digits</name>
+            <description>azerty/digits</description>
+            <description xml:lang="af">azerty/syfers</description>
+            <description xml:lang="az">azerty/ədədlər</description>
+            <description xml:lang="cs">azerty/číslice</description>
+            <description xml:lang="da">azerty/cifre</description>
+            <description xml:lang="en_GB">azerty/digits</description>
+            <description xml:lang="fr">azerty/chiffres</description>
+            <description xml:lang="hu">azerty/számjegyek</description>
+            <description xml:lang="nl">azerty/cijfers</description>
+            <description xml:lang="ru">azerty/цифры</description>
+            <description xml:lang="sk">azerty/číslice</description>
+            <description xml:lang="sq">azerty/digits</description>
+            <description xml:lang="sr">azerty/цифре</description>
+            <description xml:lang="sv">azerty/siffror</description>
+            <description xml:lang="tr">azerty/rakamlar</description>
+            <description xml:lang="uk">azerty/цифри</description>
+            <description xml:lang="vi">azerty/chữ số</description>
+            <description xml:lang="zh_CN">azerty/数字</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>digits</name>
+            <description>digits</description>
+            <description xml:lang="af">syfers</description>
+            <description xml:lang="az">ədədlər</description>
+            <description xml:lang="cs">číslice</description>
+            <description xml:lang="da">cifre</description>
+            <description xml:lang="en_GB">digits</description>
+            <description xml:lang="fr">chiffres</description>
+            <description xml:lang="hu">számjegyek</description>
+            <description xml:lang="nl">cijfers</description>
+            <description xml:lang="ru">цифры</description>
+            <description xml:lang="sk">číslice</description>
+            <description xml:lang="sq">numra</description>
+            <description xml:lang="sr">цифре</description>
+            <description xml:lang="sv">siffror</description>
+            <description xml:lang="tr">rakamlar</description>
+            <description xml:lang="uk">цифри</description>
+            <description xml:lang="vi">chữ số</description>
+            <description xml:lang="zh_CN">数字</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>qwerty</name>
+            <description>qwerty</description>
+            <description xml:lang="af">qwerty</description>
+            <description xml:lang="az">qwerty</description>
+            <description xml:lang="bg">чешка (qwerty)</description>
+            <description xml:lang="cs">qwerty</description>
+            <description xml:lang="da">qwerty</description>
+            <description xml:lang="en_GB">qwerty</description>
+            <description xml:lang="fr">qwerty</description>
+            <description xml:lang="hu">qwerty</description>
+            <description xml:lang="nl">qwerty</description>
+            <description xml:lang="ru">qwerty</description>
+            <description xml:lang="sk">qwerty</description>
+            <description xml:lang="sq">qwerty</description>
+            <description xml:lang="sr">qwerty</description>
+            <description xml:lang="sv">qwerty</description>
+            <description xml:lang="tr">qwerty</description>
+            <description xml:lang="uk">qwerty</description>
+            <description xml:lang="vi">qwerty</description>
+            <description xml:lang="zh_CN">qwerty</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>qwerty_digits</name>
+            <description>qwerty/digits</description>
+            <description xml:lang="af">qwerty/syfers</description>
+            <description xml:lang="az">qwerty/ədədlər</description>
+            <description xml:lang="cs">qwerty/číslice</description>
+            <description xml:lang="da">qwerty/cifre</description>
+            <description xml:lang="en_GB">qwerty/digits</description>
+            <description xml:lang="fr">qwerty/chiffres</description>
+            <description xml:lang="hu">qwerty/számjegyek</description>
+            <description xml:lang="nl">qwerty/cijfers</description>
+            <description xml:lang="ru">qwerty/цифры</description>
+            <description xml:lang="sk">qwerty/číslice</description>
+            <description xml:lang="sq">qwerty/numra</description>
+            <description xml:lang="sr">qwerty/цифре</description>
+            <description xml:lang="sv">qwerty/siffror</description>
+            <description xml:lang="tr">qwerty/rakamlar</description>
+            <description xml:lang="uk">qwerty/цифри</description>
+            <description xml:lang="vi">qwerty/chữ số</description>
+            <description xml:lang="zh_CN">qwerty/digits</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>al</name>
+        <shortDescription>Alb</shortDescription>
+        <shortDescription xml:lang="af">Alb</shortDescription>
+        <shortDescription xml:lang="az">Alb</shortDescription>
+        <shortDescription xml:lang="cs">Alb</shortDescription>
+        <shortDescription xml:lang="da">Alb</shortDescription>
+        <shortDescription xml:lang="en_GB">Alb</shortDescription>
+        <shortDescription xml:lang="fr">Alb</shortDescription>
+        <shortDescription xml:lang="hu">Alb</shortDescription>
+        <shortDescription xml:lang="nl">Alb</shortDescription>
+        <shortDescription xml:lang="ru">Алб</shortDescription>
+        <shortDescription xml:lang="sk">Alb</shortDescription>
+        <shortDescription xml:lang="sq">Alb</shortDescription>
+        <shortDescription xml:lang="sr">алб</shortDescription>
+        <shortDescription xml:lang="sv">Alb</shortDescription>
+        <shortDescription xml:lang="tr">Arn</shortDescription>
+        <shortDescription xml:lang="uk">Алб</shortDescription>
+        <shortDescription xml:lang="vi">Alb</shortDescription>
+        <shortDescription xml:lang="zh_CN">Alb</shortDescription>
+        <description>Albania</description>
+        <description xml:lang="en_GB">Albania</description>
+        <description xml:lang="nl">Albanië</description>
+        <description xml:lang="ru">Албания</description>
+        <description xml:lang="rw">Alubaniya</description>
+        <description xml:lang="vi">Al-ba-ni-a</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>am</name>
+        <shortDescription>Arm</shortDescription>
+        <shortDescription xml:lang="af">Arm</shortDescription>
+        <shortDescription xml:lang="az">Erm</shortDescription>
+        <shortDescription xml:lang="bg">арабска</shortDescription>
+        <shortDescription xml:lang="cs">Arm</shortDescription>
+        <shortDescription xml:lang="da">Arm</shortDescription>
+        <shortDescription xml:lang="el">Αρμ</shortDescription>
+        <shortDescription xml:lang="en_GB">Arm</shortDescription>
+        <shortDescription xml:lang="fr">Arm</shortDescription>
+        <shortDescription xml:lang="hu">Arm</shortDescription>
+        <shortDescription xml:lang="nl">Arm</shortDescription>
+        <shortDescription xml:lang="ru">Арм</shortDescription>
+        <shortDescription xml:lang="sk">Arm</shortDescription>
+        <shortDescription xml:lang="sq">Arm</shortDescription>
+        <shortDescription xml:lang="sr">јрм</shortDescription>
+        <shortDescription xml:lang="sv">Arm</shortDescription>
+        <shortDescription xml:lang="tr">Erm</shortDescription>
+        <shortDescription xml:lang="uk">Вірм</shortDescription>
+        <shortDescription xml:lang="vi">Arm</shortDescription>
+        <shortDescription xml:lang="zh_CN">Arm</shortDescription>
+        <description>Armenia</description>
+        <description xml:lang="en_GB">Armenia</description>
+        <description xml:lang="nl">Armenië</description>
+        <description xml:lang="ru">Армения</description>
+        <description xml:lang="rw">Arumeniya</description>
+        <description xml:lang="vi">Ác-mê-ni</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>phonetic</name>
+            <description>Phonetic</description>
+            <description xml:lang="af">Foneties</description>
+            <description xml:lang="az">Fonetik</description>
+            <description xml:lang="cs">Fonetické</description>
+            <description xml:lang="da">Fonetisk</description>
+            <description xml:lang="el">Φωνητικά</description>
+            <description xml:lang="en_GB">Phonetic</description>
+            <description xml:lang="fr">Phonétique</description>
+            <description xml:lang="hu">fonetikus</description>
+            <description xml:lang="nl">Fonetisch</description>
+            <description xml:lang="ru">Фонетическая</description>
+            <description xml:lang="rw">Nyigamvugo:</description>
+            <description xml:lang="sk">Fonetické</description>
+            <description xml:lang="sq">Phonetic</description>
+            <description xml:lang="sr">фонетски</description>
+            <description xml:lang="sv">Fonetisk</description>
+            <description xml:lang="tr">Fonetik</description>
+            <description xml:lang="uk">Фонетична</description>
+            <description xml:lang="vi">Ngữ âm</description>
+            <description xml:lang="zh_CN">Phonetic</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>az</name>
+        <shortDescription>Aze</shortDescription>
+        <shortDescription xml:lang="af">Aze</shortDescription>
+        <shortDescription xml:lang="az">Azə</shortDescription>
+        <shortDescription xml:lang="cs">Aze</shortDescription>
+        <shortDescription xml:lang="da">Ase</shortDescription>
+        <shortDescription xml:lang="el">Αζε</shortDescription>
+        <shortDescription xml:lang="en_GB">Aze</shortDescription>
+        <shortDescription xml:lang="fr">Aze</shortDescription>
+        <shortDescription xml:lang="hu">Aze</shortDescription>
+        <shortDescription xml:lang="nl">Aze</shortDescription>
+        <shortDescription xml:lang="ru">Азер</shortDescription>
+        <shortDescription xml:lang="sk">Aze</shortDescription>
+        <shortDescription xml:lang="sq">Aze</shortDescription>
+        <shortDescription xml:lang="sr">азб</shortDescription>
+        <shortDescription xml:lang="sv">Aze</shortDescription>
+        <shortDescription xml:lang="tr">Aze</shortDescription>
+        <shortDescription xml:lang="uk">Азер</shortDescription>
+        <shortDescription xml:lang="vi">Aze</shortDescription>
+        <shortDescription xml:lang="zh_CN">Aze</shortDescription>
+        <description>Azerbaijan</description>
+        <description xml:lang="en_GB">Azerbaijan</description>
+        <description xml:lang="nl">Azerbeidzjan</description>
+        <description xml:lang="ru">Азербайджан</description>
+        <description xml:lang="rw">Azeribayijani</description>
+        <description xml:lang="vi">A-zéc-bai-gian</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>cyrillic</name>
+            <description>Cyrillic</description>
+            <description xml:lang="af">Kirrillies</description>
+            <description xml:lang="az">Kiril</description>
+            <description xml:lang="cs">Cyrilika</description>
+            <description xml:lang="da">Kyrillisk</description>
+            <description xml:lang="el">Κυριλλικά</description>
+            <description xml:lang="en_GB">Cyrillic</description>
+            <description xml:lang="fr">Cérillique</description>
+            <description xml:lang="hu">cirill</description>
+            <description xml:lang="nl">Cyrillisch</description>
+            <description xml:lang="ru">Кириллическая</description>
+            <description xml:lang="rw">Nyasilike</description>
+            <description xml:lang="sk">Cyrilika</description>
+            <description xml:lang="sq">Cyrillic</description>
+            <description xml:lang="sr">ћирилични</description>
+            <description xml:lang="sv">Kyrillisk</description>
+            <description xml:lang="tr">Kril</description>
+            <description xml:lang="uk">Кирилична</description>
+            <description xml:lang="vi">Cyrillic</description>
+            <description xml:lang="zh_CN">西里尔</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>by</name>
+        <shortDescription>Blr</shortDescription>
+        <shortDescription xml:lang="af">Blr</shortDescription>
+        <shortDescription xml:lang="az">Blr</shortDescription>
+        <shortDescription xml:lang="cs">Běl</shortDescription>
+        <shortDescription xml:lang="da">Blr</shortDescription>
+        <shortDescription xml:lang="en_GB">Blr</shortDescription>
+        <shortDescription xml:lang="fr">Blr</shortDescription>
+        <shortDescription xml:lang="hu">Blr</shortDescription>
+        <shortDescription xml:lang="nl">Blr</shortDescription>
+        <shortDescription xml:lang="ru">Бел</shortDescription>
+        <shortDescription xml:lang="sk">Blr</shortDescription>
+        <shortDescription xml:lang="sq">Blr</shortDescription>
+        <shortDescription xml:lang="sr">блр</shortDescription>
+        <shortDescription xml:lang="sv">Blr</shortDescription>
+        <shortDescription xml:lang="tr">Blr</shortDescription>
+        <shortDescription xml:lang="uk">Біл</shortDescription>
+        <shortDescription xml:lang="vi">Blr</shortDescription>
+        <shortDescription xml:lang="zh_CN">Blr</shortDescription>
+        <description>Belarus</description>
+        <description xml:lang="en_GB">Belarus</description>
+        <description xml:lang="nl">Wit-Rusland</description>
+        <description xml:lang="ru">Беларусь</description>
+        <description xml:lang="rw">Belarusi</description>
+        <description xml:lang="vi">Bê-la-rút</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>winkeys</name>
+            <description>Winkeys</description>
+            <description xml:lang="af">Winkeys</description>
+            <description xml:lang="az">Winkeys</description>
+            <description xml:lang="cs">Winkeys</description>
+            <description xml:lang="da">Win-taster</description>
+            <description xml:lang="en_GB">Winkeys</description>
+            <description xml:lang="fr">Winkeys</description>
+            <description xml:lang="hu">Winkeys</description>
+            <description xml:lang="nl">Win-toetsen</description>
+            <description xml:lang="ru">Клавиатура Windows</description>
+            <description xml:lang="sk">Win klávesy</description>
+            <description xml:lang="sq">Winkeys</description>
+            <description xml:lang="sr">Windows тастери</description>
+            <description xml:lang="sv">Wintangenter</description>
+            <description xml:lang="tr">Win tuşları</description>
+            <description xml:lang="uk">Розкладка Windows</description>
+            <description xml:lang="vi">Phím Win</description>
+            <description xml:lang="zh_CN">Winkeys</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>be</name>
+        <shortDescription>Bel</shortDescription>
+        <shortDescription xml:lang="af">Bel</shortDescription>
+        <shortDescription xml:lang="az">Bel</shortDescription>
+        <shortDescription xml:lang="cs">Bel</shortDescription>
+        <shortDescription xml:lang="da">Bel</shortDescription>
+        <shortDescription xml:lang="el">Λευ</shortDescription>
+        <shortDescription xml:lang="en_GB">Bel</shortDescription>
+        <shortDescription xml:lang="fr">Bel</shortDescription>
+        <shortDescription xml:lang="hu">Bel</shortDescription>
+        <shortDescription xml:lang="nl">Bel</shortDescription>
+        <shortDescription xml:lang="ru">Бельг</shortDescription>
+        <shortDescription xml:lang="sk">Bel</shortDescription>
+        <shortDescription xml:lang="sq">Bel</shortDescription>
+        <shortDescription xml:lang="sr">блг</shortDescription>
+        <shortDescription xml:lang="sv">Bel</shortDescription>
+        <shortDescription xml:lang="tr">Bel</shortDescription>
+        <shortDescription xml:lang="uk">Бельг</shortDescription>
+        <shortDescription xml:lang="vi">Bel</shortDescription>
+        <shortDescription xml:lang="zh_CN">Bel</shortDescription>
+        <description>Belgium</description>
+        <description xml:lang="en_GB">Belgium</description>
+        <description xml:lang="nl">België</description>
+        <description xml:lang="ru">Бельгия</description>
+        <description xml:lang="rw">Ububiligi</description>
+        <description xml:lang="vi">Bỉ</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>iso-alternate</name>
+            <description>ISO Alternate</description>
+            <description xml:lang="af">ISO Alternatief</description>
+            <description xml:lang="az">ISO Alternate</description>
+            <description xml:lang="cs">ISO alternativní</description>
+            <description xml:lang="da">ISO-alternativ</description>
+            <description xml:lang="en_GB">ISO Alternate</description>
+            <description xml:lang="fr">ISO alternative</description>
+            <description xml:lang="hu">ISO Alternate</description>
+            <description xml:lang="nl">ISO alternatief</description>
+            <description xml:lang="ru">Дополнительная ISO</description>
+            <description xml:lang="sk">ISO alternatívne</description>
+            <description xml:lang="sq">ISO Alternative</description>
+            <description xml:lang="sr">Додатни ИСО</description>
+            <description xml:lang="sv">ISO-alternativ</description>
+            <description xml:lang="tr">ISO diğer</description>
+            <description xml:lang="uk">Додаткова ISO</description>
+            <description xml:lang="vi">ISO Xen kẽ</description>
+            <description xml:lang="zh_CN">ISO 替代</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>sundeadkeys</name>
+            <description>Sun dead keys</description>
+            <description xml:lang="af">Sun (dooie sleutels)</description>
+            <description xml:lang="az">Sun ölü düymələr</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Mrtvé klávesy Sun</description>
+            <description xml:lang="da">Sun døde taster</description>
+            <description xml:lang="en_GB">Sun dead keys</description>
+            <description xml:lang="fr">clés mortes Sun</description>
+            <description xml:lang="hu">Sun halott billentyűk</description>
+            <description xml:lang="nl">Sun dode toetsen</description>
+            <description xml:lang="ru">Специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Mŕtve klávesy Sun</description>
+            <description xml:lang="sq">Pulsantë të vdekur Sun</description>
+            <description xml:lang="sr">Sun-ови акценти</description>
+            <description xml:lang="sv">Sun stumma tangenter</description>
+            <description xml:lang="tr">Sun ölü tuşlar</description>
+            <description xml:lang="uk">Спеціальні клавіші (dead keys) Sun</description>
+            <description xml:lang="vi">Phím chết Sun</description>
+            <description xml:lang="zh_CN">Sun 死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>bd</name>
+        <shortDescription>Ban</shortDescription>
+        <shortDescription xml:lang="ru">Бан</shortDescription>
+        <description>Bangladesh</description>
+        <description xml:lang="ru">Бангладеш</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>probhat</name>
+            <description>Probhat</description>
+            <description xml:lang="en_GB">Probhat</description>
+            <description xml:lang="nl">Prt</description>
+            <description xml:lang="ru">Пробат</description>
+            <description xml:lang="vi">Probhat</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>in</name>
+        <shortDescription>Ind</shortDescription>
+        <shortDescription xml:lang="ru">Инд</shortDescription>
+        <description>India</description>
+        <description xml:lang="ru">Индия</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>ben</name>
+            <description>Bengali</description>
+            <description xml:lang="af">Bengaals</description>
+            <description xml:lang="az">Benqalca</description>
+            <description xml:lang="bg">бенгалска</description>
+            <description xml:lang="cs">Bengálské</description>
+            <description xml:lang="da">Bengali</description>
+            <description xml:lang="en_GB">Bengali</description>
+            <description xml:lang="fr">Bengali</description>
+            <description xml:lang="hu">bengáli</description>
+            <description xml:lang="nl">Bengaals</description>
+            <description xml:lang="ru">Бенгальская</description>
+            <description xml:lang="rw">Bengali</description>
+            <description xml:lang="sk">Bengálska</description>
+            <description xml:lang="sq">Bengali</description>
+            <description xml:lang="sr">бенгалски</description>
+            <description xml:lang="sv">Bengalisk</description>
+            <description xml:lang="tr">Bengalce</description>
+            <description xml:lang="uk">Бенгальська</description>
+            <description xml:lang="vi">Băng-gan</description>
+            <description xml:lang="zh_CN">孟加拉</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>ben_probhat</name>
+            <description>Bengali Probhat</description>
+            <description xml:lang="ru">Бенгальская Пробат</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>guj</name>
+            <description>Gujarati</description>
+            <description xml:lang="af">Gujarati</description>
+            <description xml:lang="az">Gujaraticə</description>
+            <description xml:lang="bg">гуджарати</description>
+            <description xml:lang="cs">Gujarati</description>
+            <description xml:lang="da">Gujarati</description>
+            <description xml:lang="en_GB">Gujarati</description>
+            <description xml:lang="fr">Gujarati</description>
+            <description xml:lang="hu">gudzsarati</description>
+            <description xml:lang="nl">Gujarati</description>
+            <description xml:lang="ru">Гуджарати</description>
+            <description xml:lang="rw">Gujarati</description>
+            <description xml:lang="sk">Gudžarati</description>
+            <description xml:lang="sq">Gujarati</description>
+            <description xml:lang="sr">гујарати</description>
+            <description xml:lang="sv">Gujaratisk</description>
+            <description xml:lang="tr">Batı Hint dili</description>
+            <description xml:lang="uk">Гуяраті</description>
+            <description xml:lang="vi">Gujarati</description>
+            <description xml:lang="zh_CN">古吉拉特</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>guru</name>
+            <description>Gurmukhi</description>
+            <description xml:lang="af">Gurmukhi</description>
+            <description xml:lang="az">Gurmukhi</description>
+            <description xml:lang="bg">гурмуки</description>
+            <description xml:lang="cs">Gurmukhi</description>
+            <description xml:lang="da">Gurmukhi</description>
+            <description xml:lang="en_GB">Gurmukhi</description>
+            <description xml:lang="fr">Gurmukhi</description>
+            <description xml:lang="hu">gurmukhi</description>
+            <description xml:lang="nl">Gurmukhi</description>
+            <description xml:lang="ru">Гурмукхи</description>
+            <description xml:lang="rw">Gurumuki</description>
+            <description xml:lang="sk">Gurmuchské</description>
+            <description xml:lang="sq">Gurmukhi</description>
+            <description xml:lang="sr">гурмуки</description>
+            <description xml:lang="sv">Gurmukhisk</description>
+            <description xml:lang="tr">Gurmukhi</description>
+            <description xml:lang="uk">Гурмукхі</description>
+            <description xml:lang="vi">Gurmukhi</description>
+            <description xml:lang="zh_CN">旁遮普</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>kan</name>
+            <description>Kannada</description>
+            <description xml:lang="af">Kannada</description>
+            <description xml:lang="az">Kannada</description>
+            <description xml:lang="bg">канадска</description>
+            <description xml:lang="cs">Kannadské</description>
+            <description xml:lang="da">Kannada</description>
+            <description xml:lang="en_GB">Kannada</description>
+            <description xml:lang="fr">Kannada</description>
+            <description xml:lang="hu">kannada</description>
+            <description xml:lang="nl">Kannada</description>
+            <description xml:lang="ru">Каннада</description>
+            <description xml:lang="rw">Kannada</description>
+            <description xml:lang="sk">Kannadské</description>
+            <description xml:lang="sq">Kanadeze</description>
+            <description xml:lang="sr">канада (јужна индија)</description>
+            <description xml:lang="sv">Kannada</description>
+            <description xml:lang="tr">Güney Hint dili</description>
+            <description xml:lang="uk">Канадська</description>
+            <description xml:lang="vi">Kannada</description>
+            <description xml:lang="zh_CN">埃纳德</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>mal</name>
+            <description>Malayalam</description>
+            <description xml:lang="af">Malayalam</description>
+            <description xml:lang="az">Malayalamca</description>
+            <description xml:lang="cs">Malajské</description>
+            <description xml:lang="da">Malayalam</description>
+            <description xml:lang="en_GB">Malayalam</description>
+            <description xml:lang="fr">Malayalam</description>
+            <description xml:lang="hu">malajalam</description>
+            <description xml:lang="nl">Malayalamees</description>
+            <description xml:lang="ru">Малайaлам</description>
+            <description xml:lang="rw">Malayalamu</description>
+            <description xml:lang="sk">Malajalamské</description>
+            <description xml:lang="sq">Malayalam</description>
+            <description xml:lang="sr">малајамски</description>
+            <description xml:lang="sv">Malayalam</description>
+            <description xml:lang="tr">Malayalam dili</description>
+            <description xml:lang="uk">Малайська</description>
+            <description xml:lang="vi">Malayalam</description>
+            <description xml:lang="zh_CN">马来西亚</description>
+         </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>ori</name>
+            <description>Oriya</description>
+            <description xml:lang="af">Oriya</description>
+            <description xml:lang="az">Oriya</description>
+            <description xml:lang="cs">Oriya</description>
+            <description xml:lang="da">Oriya</description>
+            <description xml:lang="en_GB">Oriya</description>
+            <description xml:lang="fr">Oriya</description>
+            <description xml:lang="hu">orija</description>
+            <description xml:lang="nl">Oriya</description>
+            <description xml:lang="ru">Орийя</description>
+            <description xml:lang="rw">Oriya</description>
+            <description xml:lang="sk">Oriya</description>
+            <description xml:lang="sq">Oriya</description>
+            <description xml:lang="sr">орија</description>
+            <description xml:lang="sv">Oriya</description>
+            <description xml:lang="tr">Orissa dili</description>
+            <description xml:lang="uk">Орія</description>
+            <description xml:lang="vi">Oriya</description>
+            <description xml:lang="zh_CN">Oriya</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tam_unicode</name>
+            <description>Tamil Unicode</description>
+            <description xml:lang="ru">Тамильская Unicode</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tam_TAB</name>
+            <description>Tamil TAB Typewriter</description>
+            <description xml:lang="ru">Тамильская "Печатная машинка" TAB</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tam_TSCII</name>
+            <description>Tamil TSCII Typewriter</description>
+            <description xml:lang="ru">Тамильская "Печатная машинка" TSCII</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tam</name>
+            <description>Tamil</description>
+            <description xml:lang="af">Tamilees</description>
+            <description xml:lang="az">Tamilcə</description>
+            <description xml:lang="bg">тамилска</description>
+            <description xml:lang="cs">Tamilské</description>
+            <description xml:lang="da">Tamil</description>
+            <description xml:lang="el">Ταμίλ</description>
+            <description xml:lang="en_GB">Tamil</description>
+            <description xml:lang="fr">Tamoul</description>
+            <description xml:lang="hu">tamil</description>
+            <description xml:lang="nl">Tamil</description>
+            <description xml:lang="ru">Тамильская</description>
+            <description xml:lang="rw">Tamili</description>
+            <description xml:lang="sk">Tamilské</description>
+            <description xml:lang="sq">Tamil</description>
+            <description xml:lang="sr">тамил</description>
+            <description xml:lang="sv">Tamilsk</description>
+            <description xml:lang="tr">Tamil dili</description>
+            <description xml:lang="uk">Тамільська</description>
+            <description xml:lang="vi">Tamil</description>
+            <description xml:lang="zh_CN">泰米尔</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tel</name>
+            <description>Telugu</description>
+            <description xml:lang="af">Telugu</description>
+            <description xml:lang="az">Telugu</description>
+            <description xml:lang="cs">Telugu</description>
+            <description xml:lang="da">Telugu</description>
+            <description xml:lang="el">Τελούγκου</description>
+            <description xml:lang="en_GB">Telugu</description>
+            <description xml:lang="fr">Telugu</description>
+            <description xml:lang="hu">telugu</description>
+            <description xml:lang="nl">Telugu</description>
+            <description xml:lang="ru">Телугу</description>
+            <description xml:lang="rw">Tegulu</description>
+            <description xml:lang="sk">Telugské</description>
+            <description xml:lang="sq">Telugu</description>
+            <description xml:lang="sr">телугу</description>
+            <description xml:lang="sv">Telugo</description>
+            <description xml:lang="tr">Telugu dili</description>
+            <description xml:lang="uk">Телугу</description>
+            <description xml:lang="vi">Telugu</description>
+            <description xml:lang="zh_CN">泰卢固</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>urd</name>
+            <description>Urdu</description>
+            <description xml:lang="el">Ούρντου</description>
+            <description xml:lang="en_GB">Urdu</description>
+            <description xml:lang="nl">Urdu</description>
+            <description xml:lang="ru">Урду</description>
+            <description xml:lang="rw">Urudu</description>
+            <description xml:lang="vi">Ur-du</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ba</name>
+        <shortDescription>Bih</shortDescription>
+        <shortDescription xml:lang="af">Bih</shortDescription>
+        <shortDescription xml:lang="az">Bih</shortDescription>
+        <shortDescription xml:lang="cs">Bos</shortDescription>
+        <shortDescription xml:lang="da">Bih</shortDescription>
+        <shortDescription xml:lang="en_GB">Bih</shortDescription>
+        <shortDescription xml:lang="fr">Bih</shortDescription>
+        <shortDescription xml:lang="hu">Bih</shortDescription>
+        <shortDescription xml:lang="nl">Bih</shortDescription>
+        <shortDescription xml:lang="ru">Босн</shortDescription>
+        <shortDescription xml:lang="sk">Bih</shortDescription>
+        <shortDescription xml:lang="sq">Bih</shortDescription>
+        <shortDescription xml:lang="sr">бос</shortDescription>
+        <shortDescription xml:lang="sv">Bih</shortDescription>
+        <shortDescription xml:lang="tr">Bih</shortDescription>
+        <shortDescription xml:lang="uk">Босн</shortDescription>
+        <shortDescription xml:lang="vi">Bih</shortDescription>
+        <shortDescription xml:lang="zh_CN">Bih</shortDescription>
+        <description>Bosnia and Herzegovina</description>
+        <description xml:lang="en_GB">Bosnia and Herzegovina</description>
+        <description xml:lang="nl">Bosnië-Hercegovina</description>
+        <description xml:lang="ru">Босния и Герцеговина</description>
+        <description xml:lang="rw">Bosiniya na Herizegovina</description>
+        <description xml:lang="vi">Bosnia và Herzegovina</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>br</name>
+        <shortDescription>Bra</shortDescription>
+        <shortDescription xml:lang="af">Bra</shortDescription>
+        <shortDescription xml:lang="az">Bra</shortDescription>
+        <shortDescription xml:lang="cs">Bra</shortDescription>
+        <shortDescription xml:lang="da">Bra</shortDescription>
+        <shortDescription xml:lang="en_GB">Bra</shortDescription>
+        <shortDescription xml:lang="fr">Bra</shortDescription>
+        <shortDescription xml:lang="hu">Bra</shortDescription>
+        <shortDescription xml:lang="nl">Bra</shortDescription>
+        <shortDescription xml:lang="ru">Браз</shortDescription>
+        <shortDescription xml:lang="sk">Bra</shortDescription>
+        <shortDescription xml:lang="sq">Bra</shortDescription>
+        <shortDescription xml:lang="sr">бра</shortDescription>
+        <shortDescription xml:lang="sv">Bra</shortDescription>
+        <shortDescription xml:lang="tr">Bra</shortDescription>
+        <shortDescription xml:lang="uk">Браз</shortDescription>
+        <shortDescription xml:lang="vi">Bra</shortDescription>
+        <shortDescription xml:lang="zh_CN">Bra</shortDescription>
+        <description>Brazil</description>
+        <description xml:lang="en_GB">Brazil</description>
+        <description xml:lang="nl">Brazilië</description>
+        <description xml:lang="ru">Бразилия</description>
+        <description xml:lang="rw">Burezile</description>
+        <description xml:lang="vi">Bra-zil</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>bg</name>
+        <shortDescription>Bgr</shortDescription>
+        <shortDescription xml:lang="af">Bgr</shortDescription>
+        <shortDescription xml:lang="az">Bgr</shortDescription>
+        <shortDescription xml:lang="cs">Bul</shortDescription>
+        <shortDescription xml:lang="da">Bgr</shortDescription>
+        <shortDescription xml:lang="en_GB">Bgr</shortDescription>
+        <shortDescription xml:lang="fr">Bgr</shortDescription>
+        <shortDescription xml:lang="hu">Bgr</shortDescription>
+        <shortDescription xml:lang="nl">Bgr</shortDescription>
+        <shortDescription xml:lang="ru">Болг</shortDescription>
+        <shortDescription xml:lang="sk">Bgr</shortDescription>
+        <shortDescription xml:lang="sq">Bgr</shortDescription>
+        <shortDescription xml:lang="sr">буг</shortDescription>
+        <shortDescription xml:lang="sv">Bgr</shortDescription>
+        <shortDescription xml:lang="tr">Bgr</shortDescription>
+        <shortDescription xml:lang="uk">Болг</shortDescription>
+        <shortDescription xml:lang="vi">Bgr</shortDescription>
+        <shortDescription xml:lang="zh_CN">Bgr</shortDescription>
+        <description>Bulgaria</description>
+        <description xml:lang="en_GB">Bulgaria</description>
+        <description xml:lang="nl">Bulgarije</description>
+        <description xml:lang="ru">Болгария</description>
+        <description xml:lang="rw">Buligariya</description>
+        <description xml:lang="vi">Bun-ga-ri</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>phonetic</name>
+            <description>Phonetic</description>
+            <description xml:lang="af">Foneties</description>
+            <description xml:lang="az">Fonetik</description>
+            <description xml:lang="cs">Fonetické</description>
+            <description xml:lang="da">Fonetisk</description>
+            <description xml:lang="el">Φωνητικά</description>
+            <description xml:lang="en_GB">Phonetic</description>
+            <description xml:lang="fr">Phonétique</description>
+            <description xml:lang="hu">fonetikus</description>
+            <description xml:lang="nl">Fonetisch</description>
+            <description xml:lang="ru">Фонетическая</description>
+            <description xml:lang="rw">Nyigamvugo:</description>
+            <description xml:lang="sk">Fonetické</description>
+            <description xml:lang="sq">Phonetic</description>
+            <description xml:lang="sr">фонетски</description>
+            <description xml:lang="sv">Fonetisk</description>
+            <description xml:lang="tr">Fonetik</description>
+            <description xml:lang="uk">Фонетична</description>
+            <description xml:lang="vi">Ngữ âm</description>
+            <description xml:lang="zh_CN">Phonetic</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>mm</name>
+        <shortDescription>Mmr</shortDescription>
+        <shortDescription xml:lang="af">Mmr</shortDescription>
+        <shortDescription xml:lang="az">Mmr</shortDescription>
+        <shortDescription xml:lang="cs">Mmr</shortDescription>
+        <shortDescription xml:lang="da">Mmr</shortDescription>
+        <shortDescription xml:lang="en_GB">Mmr</shortDescription>
+        <shortDescription xml:lang="fr">Mmr</shortDescription>
+        <shortDescription xml:lang="hu">Mmr</shortDescription>
+        <shortDescription xml:lang="nl">Mmr</shortDescription>
+        <shortDescription xml:lang="ru">Мьянм</shortDescription>
+        <shortDescription xml:lang="sk">Mmr</shortDescription>
+        <shortDescription xml:lang="sq">Mmr</shortDescription>
+        <shortDescription xml:lang="sr">ммр</shortDescription>
+        <shortDescription xml:lang="sv">Mmr</shortDescription>
+        <shortDescription xml:lang="tr">Mmr</shortDescription>
+        <shortDescription xml:lang="uk">Мьянм</shortDescription>
+        <shortDescription xml:lang="vi">Mmr</shortDescription>
+        <shortDescription xml:lang="zh_CN">Mmr</shortDescription>
+        <description>Myanmar</description>
+        <description xml:lang="en_GB">Myanmar</description>
+        <description xml:lang="nl">Myanmar</description>
+        <description xml:lang="ru">Мьянмар</description>
+        <description xml:lang="rw">Myanmar</description>
+        <description xml:lang="vi">Myanmar</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ca</name>
+        <shortDescription>Can</shortDescription>
+        <shortDescription xml:lang="af">Kan</shortDescription>
+        <shortDescription xml:lang="az">Kan</shortDescription>
+        <shortDescription xml:lang="cs">Kan</shortDescription>
+        <shortDescription xml:lang="da">Can</shortDescription>
+        <shortDescription xml:lang="el">Καν</shortDescription>
+        <shortDescription xml:lang="en_GB">Can</shortDescription>
+        <shortDescription xml:lang="fr">Can</shortDescription>
+        <shortDescription xml:lang="hu">Can</shortDescription>
+        <shortDescription xml:lang="nl">Can</shortDescription>
+        <shortDescription xml:lang="ru">Кан</shortDescription>
+        <shortDescription xml:lang="sk">Can</shortDescription>
+        <shortDescription xml:lang="sq">Can</shortDescription>
+        <shortDescription xml:lang="sr">кан</shortDescription>
+        <shortDescription xml:lang="sv">Can</shortDescription>
+        <shortDescription xml:lang="tr">Kan</shortDescription>
+        <shortDescription xml:lang="uk">Кан</shortDescription>
+        <shortDescription xml:lang="vi">Can</shortDescription>
+        <shortDescription xml:lang="zh_CN">Can</shortDescription>
+        <description>Canada</description>
+        <description xml:lang="en_GB">Canada</description>
+        <description xml:lang="nl">Canada</description>
+        <description xml:lang="ru">Канада</description>
+        <description xml:lang="rw">Kanada</description>
+        <description xml:lang="vi">Ca-na-da</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>fr-dvorak</name>
+            <description>French Dvorak</description>
+            <description xml:lang="en_GB">French Dvorak</description>
+            <description xml:lang="nl">Frans-Dvorak</description>
+            <description xml:lang="ru">Французская Dvorak</description>
+            <description xml:lang="vi">Pháp Dvorak</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>fr-legacy</name>
+            <description>French (legacy)</description>
+            <description xml:lang="en_GB">French (legacy)</description>
+            <description xml:lang="nl">Frans (oud)</description>
+            <description xml:lang="ru">Французская (унаследованная)</description>
+            <description xml:lang="vi">Pháp (di sản)</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>multi</name>
+            <description>Multilingual</description>
+            <description xml:lang="en_GB">Multilingual</description>
+            <description xml:lang="nl">Meertalig</description>
+            <description xml:lang="ru">Многоязычная</description>
+            <description xml:lang="vi">Đa ngôn ngữ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>multi-2gr</name>
+            <description>Multilingual, second part</description>
+            <description xml:lang="en_GB">Multilingual, second part</description>
+            <description xml:lang="nl">Meertalig, tweede deel</description>
+            <description xml:lang="ru">Многоязычная, вторая часть</description>
+            <description xml:lang="rw">ISEGONDA</description>
+            <description xml:lang="vi">Đa ngôn ngữ, phần hai</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>ike</name>
+            <description>Inuktitut</description>
+            <description xml:lang="af">Inuktitut</description>
+            <description xml:lang="az">İnuktitut</description>
+            <description xml:lang="bg">ескимоска</description>
+            <description xml:lang="cs">Inuitské</description>
+            <description xml:lang="da">Inuktitut</description>
+            <description xml:lang="en_GB">Inuktitut</description>
+            <description xml:lang="fr">Inuktitut</description>
+            <description xml:lang="hu">inuktitut</description>
+            <description xml:lang="nl">Inuktitut</description>
+            <description xml:lang="ru">Иннуитская</description>
+            <description xml:lang="rw">Ikinukititutu</description>
+            <description xml:lang="sk">Inuktitutské</description>
+            <description xml:lang="sq">Inuktitut</description>
+            <description xml:lang="sr">инуктитут</description>
+            <description xml:lang="sv">Inuktitut</description>
+            <description xml:lang="tr">Inuktitut</description>
+            <description xml:lang="uk">Іннуітська</description>
+            <description xml:lang="vi">Inuktitut</description>
+            <description xml:lang="zh_CN">因纽特</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>hr</name>
+        <shortDescription>Hrv</shortDescription>
+        <shortDescription xml:lang="af">Hrv</shortDescription>
+        <shortDescription xml:lang="az">Xrv</shortDescription>
+        <shortDescription xml:lang="cs">Chor</shortDescription>
+        <shortDescription xml:lang="da">Hrv</shortDescription>
+        <shortDescription xml:lang="en_GB">Hrv</shortDescription>
+        <shortDescription xml:lang="fr">Hrv</shortDescription>
+        <shortDescription xml:lang="hu">Hrv</shortDescription>
+        <shortDescription xml:lang="nl">Hrv</shortDescription>
+        <shortDescription xml:lang="ru">Хорв</shortDescription>
+        <shortDescription xml:lang="sk">Chor</shortDescription>
+        <shortDescription xml:lang="sq">Hrv</shortDescription>
+        <shortDescription xml:lang="sr">хрв</shortDescription>
+        <shortDescription xml:lang="sv">Hrv</shortDescription>
+        <shortDescription xml:lang="tr">Hrv</shortDescription>
+        <shortDescription xml:lang="uk">Хорв</shortDescription>
+        <shortDescription xml:lang="vi">Hrv</shortDescription>
+        <shortDescription xml:lang="zh_CN">Hrv</shortDescription>
+        <description>Croatia</description>
+        <description xml:lang="en_GB">Croatia</description>
+        <description xml:lang="nl">Kroatië</description>
+        <description xml:lang="ru">Хорватия</description>
+        <description xml:lang="rw">Korowatiya</description>
+        <description xml:lang="vi">Croátia</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>us</name>
+            <description>US keyboard with Croatian letters</description>
+            <description xml:lang="en_GB">US keyboard with Croatian letters</description>
+            <description xml:lang="nl">Amerikaans toetsenbord met Kroatische letters</description>
+            <description xml:lang="ru">Клавиатура США с хорватскими буквами</description>
+            <description xml:lang="rw">Mwandikisho Na:</description>
+            <description xml:lang="vi">Bàn phím Mỹ với các chữ cái Croát-chi-a</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>cz</name>
+        <shortDescription>Cze</shortDescription>
+        <shortDescription xml:lang="af">Cze</shortDescription>
+        <shortDescription xml:lang="az">Çex</shortDescription>
+        <shortDescription xml:lang="bg">чехшка</shortDescription>
+        <shortDescription xml:lang="cs">Čes</shortDescription>
+        <shortDescription xml:lang="da">Tje</shortDescription>
+        <shortDescription xml:lang="el">Τσε</shortDescription>
+        <shortDescription xml:lang="en_GB">Cze</shortDescription>
+        <shortDescription xml:lang="fr">Cze</shortDescription>
+        <shortDescription xml:lang="hu">Cze</shortDescription>
+        <shortDescription xml:lang="nl">Cze</shortDescription>
+        <shortDescription xml:lang="ru">Чех</shortDescription>
+        <shortDescription xml:lang="sk">Čes</shortDescription>
+        <shortDescription xml:lang="sq">Cze</shortDescription>
+        <shortDescription xml:lang="sr">чеш</shortDescription>
+        <shortDescription xml:lang="sv">Cze</shortDescription>
+        <shortDescription xml:lang="tr">Çek</shortDescription>
+        <shortDescription xml:lang="uk">Чес</shortDescription>
+        <shortDescription xml:lang="vi">Séc</shortDescription>
+        <shortDescription xml:lang="zh_CN">Cze</shortDescription>
+        <description>Czechia</description>
+        <description xml:lang="en_GB">Czechia</description>
+        <description xml:lang="nl">Tsjechië</description>
+        <description xml:lang="ru">Чехия</description>
+        <description xml:lang="vi">Czechia</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>bksl</name>
+            <description>With &lt;\|&gt; key</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>qwerty</name>
+            <description>qwerty</description>
+            <description xml:lang="af">qwerty</description>
+            <description xml:lang="az">qwerty</description>
+            <description xml:lang="bg">чешка (qwerty)</description>
+            <description xml:lang="cs">qwerty</description>
+            <description xml:lang="da">qwerty</description>
+            <description xml:lang="en_GB">qwerty</description>
+            <description xml:lang="fr">qwerty</description>
+            <description xml:lang="hu">qwerty</description>
+            <description xml:lang="nl">qwerty</description>
+            <description xml:lang="ru">qwerty</description>
+            <description xml:lang="sk">qwerty</description>
+            <description xml:lang="sq">qwerty</description>
+            <description xml:lang="sr">qwerty</description>
+            <description xml:lang="sv">qwerty</description>
+            <description xml:lang="tr">qwerty</description>
+            <description xml:lang="uk">qwerty</description>
+            <description xml:lang="vi">qwerty</description>
+            <description xml:lang="zh_CN">qwerty</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>qwerty_bksl</name>
+            <description>qwerty, extended Backslash</description>
+            <description xml:lang="en_GB">qwerty, extended Backslash</description>
+            <description xml:lang="nl">qwerty, uitgebreide backslash</description>
+            <description xml:lang="ru">qwerty, расширенные функции Backslash</description>
+            <description xml:lang="rw">Byongerewe...</description>
+            <description xml:lang="vi">qwerty, Gạch ngược mở rộng</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>dk</name>
+        <shortDescription>Dnk</shortDescription>
+        <shortDescription xml:lang="af">Dnk</shortDescription>
+        <shortDescription xml:lang="az">Dnk</shortDescription>
+        <shortDescription xml:lang="cs">Dán</shortDescription>
+        <shortDescription xml:lang="da">Dnk</shortDescription>
+        <shortDescription xml:lang="en_GB">Dnk</shortDescription>
+        <shortDescription xml:lang="fr">Dnk</shortDescription>
+        <shortDescription xml:lang="hu">Dnk</shortDescription>
+        <shortDescription xml:lang="nl">Dnk</shortDescription>
+        <shortDescription xml:lang="ru">Дат</shortDescription>
+        <shortDescription xml:lang="sk">Dán</shortDescription>
+        <shortDescription xml:lang="sq">Dnk</shortDescription>
+        <shortDescription xml:lang="sr">дан</shortDescription>
+        <shortDescription xml:lang="sv">Dnk</shortDescription>
+        <shortDescription xml:lang="tr">Dnk</shortDescription>
+        <shortDescription xml:lang="uk">Дат</shortDescription>
+        <shortDescription xml:lang="vi">Dnk</shortDescription>
+        <shortDescription xml:lang="zh_CN">Dnk</shortDescription>
+        <description>Denmark</description>
+        <description xml:lang="en_GB">Denmark</description>
+        <description xml:lang="nl">Denemarken</description>
+        <description xml:lang="ru">Дания</description>
+        <description xml:lang="rw">Danimarike</description>
+        <description xml:lang="vi">Đan Mạch</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>nl</name>
+        <shortDescription>Nld</shortDescription>
+        <shortDescription xml:lang="af">Nld</shortDescription>
+        <shortDescription xml:lang="az">Nld</shortDescription>
+        <shortDescription xml:lang="cs">Nld</shortDescription>
+        <shortDescription xml:lang="da">Hollandsk</shortDescription>
+        <shortDescription xml:lang="en_GB">Nld</shortDescription>
+        <shortDescription xml:lang="fr">Nld</shortDescription>
+        <shortDescription xml:lang="hu">Nld</shortDescription>
+        <shortDescription xml:lang="nl">Nld</shortDescription>
+        <shortDescription xml:lang="ru">Флам</shortDescription>
+        <shortDescription xml:lang="sk">Nld</shortDescription>
+        <shortDescription xml:lang="sq">Nld</shortDescription>
+        <shortDescription xml:lang="sr">хол</shortDescription>
+        <shortDescription xml:lang="sv">Nld</shortDescription>
+        <shortDescription xml:lang="tr">Hol</shortDescription>
+        <shortDescription xml:lang="uk">Флам</shortDescription>
+        <shortDescription xml:lang="vi">Nld</shortDescription>
+        <shortDescription xml:lang="zh_CN">Nld</shortDescription>
+        <description>Netherlands</description>
+        <description xml:lang="en_GB">Netherlands</description>
+        <description xml:lang="nl">Nederland</description>
+        <description xml:lang="ru">Нидерланды</description>
+        <description xml:lang="rw">Nederilande</description>
+        <description xml:lang="vi">Hà Lan</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>bt</name>
+        <shortDescription>Bhu</shortDescription>
+        <shortDescription xml:lang="ru">Бут</shortDescription>
+        <description>Bhutan</description>
+        <description xml:lang="ru">Бутан</description>
+      </configItem>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ee</name>
+        <shortDescription>Est</shortDescription>
+        <shortDescription xml:lang="af">Est</shortDescription>
+        <shortDescription xml:lang="az">Est</shortDescription>
+        <shortDescription xml:lang="cs">Est</shortDescription>
+        <shortDescription xml:lang="da">Est</shortDescription>
+        <shortDescription xml:lang="en_GB">Est</shortDescription>
+        <shortDescription xml:lang="fr">Est</shortDescription>
+        <shortDescription xml:lang="hu">Est</shortDescription>
+        <shortDescription xml:lang="nl">Est</shortDescription>
+        <shortDescription xml:lang="ru">Эст</shortDescription>
+        <shortDescription xml:lang="sk">Est</shortDescription>
+        <shortDescription xml:lang="sq">Est</shortDescription>
+        <shortDescription xml:lang="sr">ест</shortDescription>
+        <shortDescription xml:lang="sv">Est</shortDescription>
+        <shortDescription xml:lang="tr">Est</shortDescription>
+        <shortDescription xml:lang="uk">Ест</shortDescription>
+        <shortDescription xml:lang="vi">Est</shortDescription>
+        <shortDescription xml:lang="zh_CN">Est</shortDescription>
+        <description>Estonia</description>
+        <description xml:lang="en_GB">Estonia</description>
+        <description xml:lang="nl">Estland</description>
+        <description xml:lang="ru">Эстония</description>
+        <description xml:lang="rw">Esitoniya</description>
+        <description xml:lang="vi">Ex-tô-nhia</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ir</name>
+        <shortDescription>Irn</shortDescription>
+        <shortDescription xml:lang="af">Irn</shortDescription>
+        <shortDescription xml:lang="az">İrn</shortDescription>
+        <shortDescription xml:lang="cs">Irn</shortDescription>
+        <shortDescription xml:lang="da">Irn</shortDescription>
+        <shortDescription xml:lang="en_GB">Irn</shortDescription>
+        <shortDescription xml:lang="fr">Irn</shortDescription>
+        <shortDescription xml:lang="hu">Irn</shortDescription>
+        <shortDescription xml:lang="nl">Irn</shortDescription>
+        <shortDescription xml:lang="ru">Перс</shortDescription>
+        <shortDescription xml:lang="sk">Irn</shortDescription>
+        <shortDescription xml:lang="sq">Irn</shortDescription>
+        <shortDescription xml:lang="sr">ирн</shortDescription>
+        <shortDescription xml:lang="sv">Irn</shortDescription>
+        <shortDescription xml:lang="tr">Irn</shortDescription>
+        <shortDescription xml:lang="uk">Перс</shortDescription>
+        <shortDescription xml:lang="vi">Irn</shortDescription>
+        <shortDescription xml:lang="zh_CN">Irn</shortDescription>
+        <description>Iran</description>
+        <description xml:lang="en_GB">Iran</description>
+        <description xml:lang="nl">Iran</description>
+        <description xml:lang="ru">Иран</description>
+        <description xml:lang="vi">Iran</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>fo</name>
+        <shortDescription>Fao</shortDescription>
+        <shortDescription xml:lang="af">Fao</shortDescription>
+        <shortDescription xml:lang="az">Fao</shortDescription>
+        <shortDescription xml:lang="cs">Fao</shortDescription>
+        <shortDescription xml:lang="da">Fær</shortDescription>
+        <shortDescription xml:lang="en_GB">Fao</shortDescription>
+        <shortDescription xml:lang="fr">Fao</shortDescription>
+        <shortDescription xml:lang="hu">Fao</shortDescription>
+        <shortDescription xml:lang="nl">Fao</shortDescription>
+        <shortDescription xml:lang="ru">Фар</shortDescription>
+        <shortDescription xml:lang="sk">Fao</shortDescription>
+        <shortDescription xml:lang="sq">Fao</shortDescription>
+        <shortDescription xml:lang="sr">фар</shortDescription>
+        <shortDescription xml:lang="sv">Fao</shortDescription>
+        <shortDescription xml:lang="tr">Fao</shortDescription>
+        <shortDescription xml:lang="uk">Фарер</shortDescription>
+        <shortDescription xml:lang="vi">Fao</shortDescription>
+        <shortDescription xml:lang="zh_CN">Fao</shortDescription>
+        <description>Faroe Islands</description>
+        <description xml:lang="en_GB">Faroe Islands</description>
+        <description xml:lang="nl">Faröer-eilanden</description>
+        <description xml:lang="ru">Острова Фаро</description>
+        <description xml:lang="rw">Ibirwa bya Farowe</description>
+        <description xml:lang="vi">Faroe Islands</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>fi</name>
+        <shortDescription>Fin</shortDescription>
+        <shortDescription xml:lang="af">Fin</shortDescription>
+        <shortDescription xml:lang="az">Fin</shortDescription>
+        <shortDescription xml:lang="cs">Fin</shortDescription>
+        <shortDescription xml:lang="da">Fin</shortDescription>
+        <shortDescription xml:lang="el">Φιν</shortDescription>
+        <shortDescription xml:lang="en_GB">Fin</shortDescription>
+        <shortDescription xml:lang="fr">Fin</shortDescription>
+        <shortDescription xml:lang="hu">Fin</shortDescription>
+        <shortDescription xml:lang="nl">Fin</shortDescription>
+        <shortDescription xml:lang="ru">Фин</shortDescription>
+        <shortDescription xml:lang="sk">Fín</shortDescription>
+        <shortDescription xml:lang="sq">Fin</shortDescription>
+        <shortDescription xml:lang="sr">фин</shortDescription>
+        <shortDescription xml:lang="sv">Fin</shortDescription>
+        <shortDescription xml:lang="tr">Fin</shortDescription>
+        <shortDescription xml:lang="uk">Фін</shortDescription>
+        <shortDescription xml:lang="vi">Fin</shortDescription>
+        <shortDescription xml:lang="zh_CN">Fin</shortDescription>
+        <description>Finland</description>
+        <description xml:lang="en_GB">Finland</description>
+        <description xml:lang="nl">Finland</description>
+        <description xml:lang="ru">Финляндия</description>
+        <description xml:lang="rw">Finilande</description>
+        <description xml:lang="vi">Phần Lan</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>smi</name>
+            <description>Northern Saami</description>
+            <description xml:lang="en_GB">Northern Saami</description>
+            <description xml:lang="nl">Noord-Lapland</description>
+            <description xml:lang="ru">Северная Саамская</description>
+            <description xml:lang="rw">Sami y'Amajyaruguru</description>
+            <description xml:lang="vi">Bắc Saami</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>fr</name>
+        <shortDescription>Fra</shortDescription>
+        <shortDescription xml:lang="af">Fra</shortDescription>
+        <shortDescription xml:lang="az">Fra</shortDescription>
+        <shortDescription xml:lang="cs">Fra</shortDescription>
+        <shortDescription xml:lang="da">Fra</shortDescription>
+        <shortDescription xml:lang="el">Γαλ</shortDescription>
+        <shortDescription xml:lang="en_GB">Fra</shortDescription>
+        <shortDescription xml:lang="fr">Fra</shortDescription>
+        <shortDescription xml:lang="hu">Fra</shortDescription>
+        <shortDescription xml:lang="nl">Fra</shortDescription>
+        <shortDescription xml:lang="ru">Фр</shortDescription>
+        <shortDescription xml:lang="sk">Fra</shortDescription>
+        <shortDescription xml:lang="sq">Fra</shortDescription>
+        <shortDescription xml:lang="sr">фра</shortDescription>
+        <shortDescription xml:lang="sv">Fra</shortDescription>
+        <shortDescription xml:lang="tr">Fra</shortDescription>
+        <shortDescription xml:lang="uk">Фра</shortDescription>
+        <shortDescription xml:lang="vi">Fra</shortDescription>
+        <shortDescription xml:lang="zh_CN">Fra</shortDescription>
+        <description>France</description>
+        <description xml:lang="en_GB">France</description>
+        <description xml:lang="nl">Frankrijk</description>
+        <description xml:lang="ru">Франция</description>
+        <description xml:lang="rw">Ubufaransa</description>
+        <description xml:lang="vi">Pháp</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>sundeadkeys</name>
+            <description>Sun dead keys</description>
+            <description xml:lang="af">Sun (dooie sleutels)</description>
+            <description xml:lang="az">Sun ölü düymələr</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Mrtvé klávesy Sun</description>
+            <description xml:lang="da">Sun døde taster</description>
+            <description xml:lang="en_GB">Sun dead keys</description>
+            <description xml:lang="fr">clés mortes Sun</description>
+            <description xml:lang="hu">Sun halott billentyűk</description>
+            <description xml:lang="nl">Sun dode toetsen</description>
+            <description xml:lang="ru">Специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Mŕtve klávesy Sun</description>
+            <description xml:lang="sq">Pulsantë të vdekur Sun</description>
+            <description xml:lang="sr">Sun-ови акценти</description>
+            <description xml:lang="sv">Sun stumma tangenter</description>
+            <description xml:lang="tr">Sun ölü tuşlar</description>
+            <description xml:lang="uk">Спеціальні клавіші (dead keys) Sun</description>
+            <description xml:lang="vi">Phím chết Sun</description>
+            <description xml:lang="zh_CN">Sun 死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latin9</name>
+            <description>Alternative</description>
+            <description xml:lang="el">Ενναλακτικό</description>
+            <description xml:lang="en_GB">Alternative</description>
+            <description xml:lang="nl">Alternatief</description>
+            <description xml:lang="ru">Альтернативная</description>
+            <description xml:lang="vi">Tương đương</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latin9_nodeadkeys</name>
+            <description>Alternative, eliminate dead keys</description>
+            <description xml:lang="en_GB">Alternative, eliminate dead keys</description>
+            <description xml:lang="nl">Alternatief, zonder dode toetsen</description>
+            <description xml:lang="ru">Альтернативная, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="vi">Tương đương, phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latin9_sundeadkeys</name>
+            <description>Alternative, Sun dead keys</description>
+            <description xml:lang="en_GB">Alternative, Sun dead keys</description>
+            <description xml:lang="nl">Alternatief, Sun-dode toetsen</description>
+            <description xml:lang="ru">Альтернативная, специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="vi">Tương đương, phím chết Sun</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ge</name>
+        <shortDescription>Geo</shortDescription>
+        <shortDescription xml:lang="af">Geo</shortDescription>
+        <shortDescription xml:lang="az">Gür</shortDescription>
+        <shortDescription xml:lang="cs">Gru</shortDescription>
+        <shortDescription xml:lang="da">Geo</shortDescription>
+        <shortDescription xml:lang="en_GB">Geo</shortDescription>
+        <shortDescription xml:lang="fr">Geo</shortDescription>
+        <shortDescription xml:lang="hu">Geo</shortDescription>
+        <shortDescription xml:lang="nl">Geo</shortDescription>
+        <shortDescription xml:lang="ru">Груз</shortDescription>
+        <shortDescription xml:lang="sk">Gru</shortDescription>
+        <shortDescription xml:lang="sq">Geo</shortDescription>
+        <shortDescription xml:lang="sr">гру</shortDescription>
+        <shortDescription xml:lang="sv">Geo</shortDescription>
+        <shortDescription xml:lang="tr">Geo</shortDescription>
+        <shortDescription xml:lang="uk">Груз</shortDescription>
+        <shortDescription xml:lang="vi">Geo</shortDescription>
+        <shortDescription xml:lang="zh_CN">Geo</shortDescription>
+        <description>Georgia</description>
+        <description xml:lang="en_GB">Georgia</description>
+        <description xml:lang="nl">Georgië</description>
+        <description xml:lang="ru">Грузия</description>
+        <description xml:lang="rw">Geworigiya</description>
+        <description xml:lang="vi">Georgia</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>ru</name>
+            <description>Russian</description>
+            <description xml:lang="af">Russies</description>
+            <description xml:lang="az">Rusca</description>
+            <description xml:lang="bg">руска</description>
+            <description xml:lang="cs">Ruské</description>
+            <description xml:lang="da">Russisk</description>
+            <description xml:lang="el">Ρωσσικά</description>
+            <description xml:lang="en_GB">Russian</description>
+            <description xml:lang="fr">Russe</description>
+            <description xml:lang="hu">orosz</description>
+            <description xml:lang="nl">Russisch</description>
+            <description xml:lang="ru">Русская</description>
+            <description xml:lang="rw">Ikirusiya</description>
+            <description xml:lang="sk">Ruské</description>
+            <description xml:lang="sq">Rusisht</description>
+            <description xml:lang="sr">руски</description>
+            <description xml:lang="sv">Rysk</description>
+            <description xml:lang="tr">Rusça</description>
+            <description xml:lang="uk">Російська</description>
+            <description xml:lang="vi">Nga</description>
+            <description xml:lang="zh_CN">俄语</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>de</name>
+        <shortDescription>Deu</shortDescription>
+        <shortDescription xml:lang="af">Deu</shortDescription>
+        <shortDescription xml:lang="az">Deu</shortDescription>
+        <shortDescription xml:lang="cs">Něm</shortDescription>
+        <shortDescription xml:lang="da">Tys</shortDescription>
+        <shortDescription xml:lang="en_GB">Deu</shortDescription>
+        <shortDescription xml:lang="fr">Deu</shortDescription>
+        <shortDescription xml:lang="hu">Deu</shortDescription>
+        <shortDescription xml:lang="nl">Deu</shortDescription>
+        <shortDescription xml:lang="ru">Нем</shortDescription>
+        <shortDescription xml:lang="sk">Nem</shortDescription>
+        <shortDescription xml:lang="sq">Deu</shortDescription>
+        <shortDescription xml:lang="sr">нем</shortDescription>
+        <shortDescription xml:lang="sv">Deu</shortDescription>
+        <shortDescription xml:lang="tr">Alm</shortDescription>
+        <shortDescription xml:lang="uk">Нім</shortDescription>
+        <shortDescription xml:lang="vi">Deu</shortDescription>
+        <shortDescription xml:lang="zh_CN">Deu</shortDescription>
+        <description>Germany</description>
+        <description xml:lang="en_GB">Germany</description>
+        <description xml:lang="nl">Duitsland</description>
+        <description xml:lang="ru">Германия</description>
+        <description xml:lang="rw">Ubudage</description>
+        <description xml:lang="vi">Đức</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>deadacute</name>
+            <description>Dead acute</description>
+            <description xml:lang="af">Dooie akuutaksent</description>
+            <description xml:lang="az">Dead acute</description>
+            <description xml:lang="cs">Mrtvá čárka</description>
+            <description xml:lang="da">Død accent</description>
+            <description xml:lang="en_GB">Dead acute</description>
+            <description xml:lang="fr">clé morte d'accent aigu</description>
+            <description xml:lang="hu">Halott vessző (´) ékezet</description>
+            <description xml:lang="nl">Dood acutus</description>
+            <description xml:lang="ru">Спец. символ Dead acute</description>
+            <description xml:lang="sk">Mŕtva čiarka</description>
+            <description xml:lang="sq">Fund kritik</description>
+            <description xml:lang="sr">Акутски акценат</description>
+            <description xml:lang="sv">Stum akut accent</description>
+            <description xml:lang="tr">Ölü acute (´)</description>
+            <description xml:lang="uk">Спец. символ Dead acute</description>
+            <description xml:lang="vi">Chết sâu</description>
+            <description xml:lang="zh_CN">Dead acute</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>deadgraveacute</name>
+            <description>Dead grave acute</description>
+            <description xml:lang="af">Dooie gravisaksent</description>
+            <description xml:lang="az">Dead grave acute</description>
+            <description xml:lang="cs">Mrtvá opačná čárka</description>
+            <description xml:lang="da">Død accent grave</description>
+            <description xml:lang="en_GB">Dead grave acute</description>
+            <description xml:lang="fr">clé morte d'accent grave</description>
+            <description xml:lang="hu">Halott grave (`) ékezet</description>
+            <description xml:lang="nl">Dood gravis-acutus</description>
+            <description xml:lang="ru">Спец. символ Dead grave acute</description>
+            <description xml:lang="sk">Mŕtva opačná čiarka</description>
+            <description xml:lang="sq">Fund kritik serioz</description>
+            <description xml:lang="sr">Гравис акутски акценат</description>
+            <description xml:lang="sv">Stum grav och akut accent</description>
+            <description xml:lang="tr">Ölü grave acute (`)</description>
+            <description xml:lang="uk">Спец. символ Dead grave acute</description>
+            <description xml:lang="vi">Chết non sâu</description>
+            <description xml:lang="zh_CN">Dead grave acute</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>ro</name>
+            <description>Romanian keyboard with German letters</description>
+            <description xml:lang="en_GB">Romanian keyboard with German letters</description>
+            <description xml:lang="nl">Roemeens toetsenbord met Duitse letters</description>
+            <description xml:lang="ru">Румынская клавиатура с немецкими буквами</description>
+            <description xml:lang="rw">Mwandikisho Na:</description>
+            <description xml:lang="vi">Bàn phím Rô-ma-ni với các chữ cái Đức</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>ro_nodeadkeys</name>
+            <description>Romanian keyboard with German letters, eliminate dead keys</description>
+            <description xml:lang="en_GB">Romanian keyboard with German letters, eliminate dead keys</description>
+            <description xml:lang="nl">Roemeens toetsenbord met Duitse letters, zonder dode toetsen</description>
+            <description xml:lang="rw">Mwandikisho Na: Utubuto</description>
+            <description xml:lang="vi">Bàn phím Rô-ma-ni với các chữ cái Đức, các phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>gr</name>
+        <shortDescription>Gre</shortDescription>
+        <shortDescription xml:lang="el">Ελλ</shortDescription>
+        <shortDescription xml:lang="en_GB">Gre</shortDescription>
+        <shortDescription xml:lang="nl">Grieks</shortDescription>
+        <shortDescription xml:lang="ru">Гре</shortDescription>
+        <shortDescription xml:lang="vi">Gre</shortDescription>
+        <description>Greece</description>
+        <description xml:lang="en_GB">Greece</description>
+        <description xml:lang="nl">Griekenland</description>
+        <description xml:lang="ru">Греция</description>
+        <description xml:lang="rw">Ikigereki</description>
+        <description xml:lang="vi">Hy Lạp</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>extended</name>
+            <description>Extended</description>
+            <description xml:lang="af">Uitgebreide</description>
+            <description xml:lang="az">Uzadılmış</description>
+            <description xml:lang="cs">Rozšířené</description>
+            <description xml:lang="da">Udvidet</description>
+            <description xml:lang="en_GB">Extended</description>
+            <description xml:lang="fr">Étendue</description>
+            <description xml:lang="hu">Kibővített</description>
+            <description xml:lang="nl">Uitgebreid</description>
+            <description xml:lang="ru">Расширенная</description>
+            <description xml:lang="rw">cya/byagutse</description>
+            <description xml:lang="sk">Rozšírené</description>
+            <description xml:lang="sq">E zgjeruar</description>
+            <description xml:lang="sr">Проширено</description>
+            <description xml:lang="sv">Utökad</description>
+            <description xml:lang="tr">Gelişmiş</description>
+            <description xml:lang="uk">Розширена</description>
+            <description xml:lang="vi">Mở rộng</description>
+            <description xml:lang="zh_CN">扩展</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>polytonic</name>
+            <description>Polytonic</description>
+            <description xml:lang="af">Polytonic</description>
+            <description xml:lang="az">Politonik</description>
+            <description xml:lang="cs">Polytónické</description>
+            <description xml:lang="da">Polytonisk</description>
+            <description xml:lang="el">Πολυτονικά</description>
+            <description xml:lang="en_GB">Polytonic</description>
+            <description xml:lang="fr">Polytonique</description>
+            <description xml:lang="hu">Polytonic</description>
+            <description xml:lang="nl">Polytonisch</description>
+            <description xml:lang="ru">Полифоническая</description>
+            <description xml:lang="sk">Polytónické</description>
+            <description xml:lang="sq">Polytonic</description>
+            <description xml:lang="sr">вишезвучни</description>
+            <description xml:lang="sv">Polytonic</description>
+            <description xml:lang="tr">Politonik</description>
+            <description xml:lang="uk">Поліфонічна</description>
+            <description xml:lang="vi">Nhiều âm</description>
+            <description xml:lang="zh_CN">Polytonic</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>hu</name>
+        <shortDescription>Hun</shortDescription>
+        <shortDescription xml:lang="af">Hun</shortDescription>
+        <shortDescription xml:lang="az">Mac</shortDescription>
+        <shortDescription xml:lang="cs">Maď</shortDescription>
+        <shortDescription xml:lang="da">Ung</shortDescription>
+        <shortDescription xml:lang="en_GB">Hun</shortDescription>
+        <shortDescription xml:lang="fr">Hun</shortDescription>
+        <shortDescription xml:lang="hu">Hun</shortDescription>
+        <shortDescription xml:lang="nl">Hun</shortDescription>
+        <shortDescription xml:lang="ru">Венг</shortDescription>
+        <shortDescription xml:lang="sk">Maď</shortDescription>
+        <shortDescription xml:lang="sq">Hun</shortDescription>
+        <shortDescription xml:lang="sr">мађ</shortDescription>
+        <shortDescription xml:lang="sv">Hun</shortDescription>
+        <shortDescription xml:lang="tr">Mcr</shortDescription>
+        <shortDescription xml:lang="uk">Уго</shortDescription>
+        <shortDescription xml:lang="vi">Hun</shortDescription>
+        <shortDescription xml:lang="zh_CN">Hun</shortDescription>
+        <description>Hungary</description>
+        <description xml:lang="en_GB">Hungary</description>
+        <description xml:lang="nl">Hongarije</description>
+        <description xml:lang="ru">Венгрия</description>
+        <description xml:lang="rw">Hongiriya</description>
+        <description xml:lang="vi">Hungary</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>standard</name>
+            <description>Standard</description>
+            <description xml:lang="af">Standaard</description>
+            <description xml:lang="az">Standart</description>
+            <description xml:lang="cs">Standardní</description>
+            <description xml:lang="da">Standard</description>
+            <description xml:lang="el">Εξ ορισμού</description>
+            <description xml:lang="en_GB">Standard</description>
+            <description xml:lang="fr">Standard</description>
+            <description xml:lang="hu">Szabványos</description>
+            <description xml:lang="nl">Standaard</description>
+            <description xml:lang="ru">Стандартная</description>
+            <description xml:lang="rw">gisanzwe/kimenyerewe</description>
+            <description xml:lang="sk">Štandardné</description>
+            <description xml:lang="sq">Standart</description>
+            <description xml:lang="sr">стандардна</description>
+            <description xml:lang="sv">Standard</description>
+            <description xml:lang="tr">Standart</description>
+            <description xml:lang="uk">Стандартна</description>
+            <description xml:lang="vi">Tiêu chuẩn</description>
+            <description xml:lang="zh_CN">标准</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>qwerty</name>
+            <description>qwerty</description>
+            <description xml:lang="af">qwerty</description>
+            <description xml:lang="az">qwerty</description>
+            <description xml:lang="bg">чешка (qwerty)</description>
+            <description xml:lang="cs">qwerty</description>
+            <description xml:lang="da">qwerty</description>
+            <description xml:lang="en_GB">qwerty</description>
+            <description xml:lang="fr">qwerty</description>
+            <description xml:lang="hu">qwerty</description>
+            <description xml:lang="nl">qwerty</description>
+            <description xml:lang="ru">qwerty</description>
+            <description xml:lang="sk">qwerty</description>
+            <description xml:lang="sq">qwerty</description>
+            <description xml:lang="sr">qwerty</description>
+            <description xml:lang="sv">qwerty</description>
+            <description xml:lang="tr">qwerty</description>
+            <description xml:lang="uk">qwerty</description>
+            <description xml:lang="vi">qwerty</description>
+            <description xml:lang="zh_CN">qwerty</description>
+          </configItem>
+        </variant>
+
+        <!-- 101 keys -->
+        <variant>
+          <configItem>
+            <name>101_qwertz_comma_dead</name>
+            <description>101/qwertz/comma/Dead keys</description>
+            <description xml:lang="en_GB">101/qwertz/comma/Dead keys</description>
+            <description xml:lang="nl">101/qwertz/komma/Dode toetsen</description>
+            <description xml:lang="ru">pc101, qwertz, запятая, специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">101/qwertz/dấu phẩy/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>101_qwertz_comma_nodead</name>
+            <description>101/qwertz/comma/Eliminate dead keys</description>
+            <description xml:lang="en_GB">101/qwertz/comma/Eliminate dead keys</description>
+            <description xml:lang="nl">101/qwertz/komma/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc101, qwertz, запятая, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">101/qwertz/dấu phẩy/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>101_qwertz_dot_dead</name>
+            <description>101/qwertz/dot/Dead keys</description>
+            <description xml:lang="en_GB">101/qwertz/dot/Dead keys</description>
+            <description xml:lang="nl">101/qwertz/punt/Dode toetsen</description>
+            <description xml:lang="ru">pc101, qwertz, точка, специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">101/qwertz/dấu chấm/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>101_qwertz_dot_nodead</name>
+            <description>101/qwertz/dot/Eliminate dead keys</description>
+            <description xml:lang="en_GB">101/qwertz/dot/Eliminate dead keys</description>
+            <description xml:lang="nl">101/qwertz/punt/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc101, qwertz, точка, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">101/qwertz/dấu chấm/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>101_qwerty_comma_dead</name>
+            <description>101/qwerty/comma/Dead keys</description>
+            <description xml:lang="en_GB">101/qwerty/comma/Dead keys</description>
+            <description xml:lang="nl">101/qwerty/komma/Dode toetsen</description>
+            <description xml:lang="ru">pc101, qwerty, запятая, специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">101/qwerty/dấu phẩy/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>101_qwerty_comma_nodead</name>
+            <description>101/qwerty/comma/Eliminate dead keys</description>
+            <description xml:lang="en_GB">101/qwerty/comma/Eliminate dead keys</description>
+            <description xml:lang="nl">101/qwerty/komma/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc101, qwerty, запятая, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">101/qwerty/dấu phẩy/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>101_qwerty_dot_dead</name>
+            <description>101/qwerty/dot/Dead keys</description>
+            <description xml:lang="en_GB">101/qwerty/dot/Dead keys</description>
+            <description xml:lang="nl">101/qwerty/punt/Dode toetsen</description>
+            <description xml:lang="ru">pc101, qwerty, точка, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">101/qwerty/dấu chấm/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>101_qwerty_dot_nodead</name>
+            <description>101/qwerty/dot/Eliminate dead keys</description>
+            <description xml:lang="en_GB">101/qwerty/dot/Eliminate dead keys</description>
+            <description xml:lang="nl">101/qwerty/punt/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc101, qwerty, точка, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">101/qwerty/dấu chấm/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+
+
+        <!-- 102 keys -->
+        <variant>
+          <configItem>
+            <name>102_qwertz_comma_dead</name>
+            <description>102/qwertz/comma/Dead keys</description>
+            <description xml:lang="en_GB">102/qwertz/comma/Dead keys</description>
+            <description xml:lang="nl">102/qwertz/komma/Dode toetsen</description>
+            <description xml:lang="ru">pc102, qwertz, запятая, специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">102/qwertz/dấu phẩy/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>102_qwertz_comma_nodead</name>
+            <description>102/qwertz/comma/Eliminate dead keys</description>
+            <description xml:lang="en_GB">102/qwertz/comma/Eliminate dead keys</description>
+            <description xml:lang="nl">102/qwertz/komma/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc102, qwertz, запятая, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">102/qwertz/dấu phẩy/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>102_qwertz_dot_dead</name>
+            <description>102/qwertz/dot/Dead keys</description>
+            <description xml:lang="en_GB">102/qwertz/dot/Dead keys</description>
+            <description xml:lang="nl">102/qwertz/punt/Dode toetsen</description>
+            <description xml:lang="ru">pc102, qwertz, точка, специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">102/qwertz/dấu chấm/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>102_qwertz_dot_nodead</name>
+            <description>102/qwertz/dot/Eliminate dead keys</description>
+            <description xml:lang="en_GB">102/qwertz/dot/Eliminate dead keys</description>
+            <description xml:lang="nl">102/qwertz/punt/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc102, qwertz, точка, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">102/qwertz/dấu chấm/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>102_qwerty_comma_dead</name>
+            <description>102/qwerty/comma/Dead keys</description>
+            <description xml:lang="en_GB">102/qwerty/comma/Dead keys</description>
+            <description xml:lang="nl">102/qwerty/komma/Dode toetsen</description>
+            <description xml:lang="ru">pc102, qwerty, запятая, специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">102/qwerty/dấu phẩy/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>102_qwerty_comma_nodead</name>
+            <description>102/qwerty/comma/Eliminate dead keys</description>
+            <description xml:lang="en_GB">102/qwerty/comma/Eliminate dead keys</description>
+            <description xml:lang="nl">102/qwerty/komma/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc102, qwerty, запятая, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akitso Utubuto</description>
+            <description xml:lang="vi">102/qwerty/dấu phẩy/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>102_qwerty_dot_dead</name>
+            <description>102/qwerty/dot/Dead keys</description>
+            <description xml:lang="en_GB">102/qwerty/dot/Dead keys</description>
+            <description xml:lang="nl">102/qwerty/punt/Dode toetsen</description>
+            <description xml:lang="ru">pc102, qwerty, точка, специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">102/qwerty/dấu chấm/Phím chết</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>102_qwerty_dot_nodead</name>
+            <description>102/qwerty/dot/Eliminate dead keys</description>
+            <description xml:lang="en_GB">102/qwerty/dot/Eliminate dead keys</description>
+            <description xml:lang="nl">102/qwerty/punt/Dode toetsen verwijderen</description>
+            <description xml:lang="ru">pc102, qwerty, точка, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Akadomo Utubuto</description>
+            <description xml:lang="vi">102/qwerty/dấu chấm/Phím chết loại trừ</description>
+          </configItem>
+        </variant>
+
+
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>is</name>
+        <shortDescription>Isl</shortDescription>
+        <shortDescription xml:lang="af">Isl</shortDescription>
+        <shortDescription xml:lang="az">İsl</shortDescription>
+        <shortDescription xml:lang="cs">Isl</shortDescription>
+        <shortDescription xml:lang="da">Isl</shortDescription>
+        <shortDescription xml:lang="en_GB">Isl</shortDescription>
+        <shortDescription xml:lang="fr">Isl</shortDescription>
+        <shortDescription xml:lang="hu">Isl</shortDescription>
+        <shortDescription xml:lang="nl">Isl</shortDescription>
+        <shortDescription xml:lang="ru">Исл</shortDescription>
+        <shortDescription xml:lang="sk">Isl</shortDescription>
+        <shortDescription xml:lang="sq">Isl</shortDescription>
+        <shortDescription xml:lang="sr">исл</shortDescription>
+        <shortDescription xml:lang="sv">Isl</shortDescription>
+        <shortDescription xml:lang="tr">Izl</shortDescription>
+        <shortDescription xml:lang="uk">Ісл</shortDescription>
+        <shortDescription xml:lang="vi">Isl</shortDescription>
+        <shortDescription xml:lang="zh_CN">Isl</shortDescription>
+        <description>Iceland</description>
+        <description xml:lang="en_GB">Iceland</description>
+        <description xml:lang="nl">IJsland</description>
+        <description xml:lang="ru">Исландия</description>
+        <description xml:lang="rw">Isilande</description>
+        <description xml:lang="vi">Iceland</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>Sundeadkeys</name>
+            <description>Sun dead keys</description>
+            <description xml:lang="af">Sun (dooie sleutels)</description>
+            <description xml:lang="az">Sun ölü düymələr</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Mrtvé klávesy Sun</description>
+            <description xml:lang="da">Sun døde taster</description>
+            <description xml:lang="en_GB">Sun dead keys</description>
+            <description xml:lang="fr">clés mortes Sun</description>
+            <description xml:lang="hu">Sun halott billentyűk</description>
+            <description xml:lang="nl">Sun dode toetsen</description>
+            <description xml:lang="ru">Специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Mŕtve klávesy Sun</description>
+            <description xml:lang="sq">Pulsantë të vdekur Sun</description>
+            <description xml:lang="sr">Sun-ови акценти</description>
+            <description xml:lang="sv">Sun stumma tangenter</description>
+            <description xml:lang="tr">Sun ölü tuşlar</description>
+            <description xml:lang="uk">Спеціальні клавіші (dead keys) Sun</description>
+            <description xml:lang="vi">Phím chết Sun</description>
+            <description xml:lang="zh_CN">Sun 死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>il</name>
+        <shortDescription>Isr</shortDescription>
+        <shortDescription xml:lang="af">Isr</shortDescription>
+        <shortDescription xml:lang="az">İsr</shortDescription>
+        <shortDescription xml:lang="cs">Izr</shortDescription>
+        <shortDescription xml:lang="da">Isr</shortDescription>
+        <shortDescription xml:lang="en_GB">Isr</shortDescription>
+        <shortDescription xml:lang="fr">Isr</shortDescription>
+        <shortDescription xml:lang="hu">Isr</shortDescription>
+        <shortDescription xml:lang="nl">Isr</shortDescription>
+        <shortDescription xml:lang="ru">Ивр</shortDescription>
+        <shortDescription xml:lang="sk">Izr</shortDescription>
+        <shortDescription xml:lang="sq">Isr</shortDescription>
+        <shortDescription xml:lang="sr">изр</shortDescription>
+        <shortDescription xml:lang="sv">Isr</shortDescription>
+        <shortDescription xml:lang="tr">İbr</shortDescription>
+        <shortDescription xml:lang="uk">Івр</shortDescription>
+        <shortDescription xml:lang="vi">Isr</shortDescription>
+        <shortDescription xml:lang="zh_CN">Isr</shortDescription>
+        <description>Israel</description>
+        <description xml:lang="en_GB">Israel</description>
+        <description xml:lang="nl">Israël</description>
+        <description xml:lang="ru">Израиль</description>
+        <description xml:lang="rw">Isirayeli</description>
+        <description xml:lang="vi">Israel</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>lyx</name>
+            <description>lyx</description>
+            <description xml:lang="af">lyx</description>
+            <description xml:lang="az">lyx</description>
+            <description xml:lang="cs">lyx</description>
+            <description xml:lang="da">lyx</description>
+            <description xml:lang="en_GB">lyx</description>
+            <description xml:lang="fr">lyx</description>
+            <description xml:lang="hu">lyx</description>
+            <description xml:lang="nl">lyx</description>
+            <description xml:lang="ru">lyx</description>
+            <description xml:lang="sk">lyx</description>
+            <description xml:lang="sq">lyx</description>
+            <description xml:lang="sr">lyx</description>
+            <description xml:lang="sv">lyx</description>
+            <description xml:lang="tr">lyx</description>
+            <description xml:lang="uk">lyx</description>
+            <description xml:lang="vi">lyx</description>
+            <description xml:lang="zh_CN">lyx</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>si1452</name>
+            <description>si1452</description>
+            <description xml:lang="af">si1452</description>
+            <description xml:lang="az">si1452</description>
+            <description xml:lang="cs">si1452</description>
+            <description xml:lang="da">si1452</description>
+            <description xml:lang="en_GB">si1452</description>
+            <description xml:lang="fr">si1452</description>
+            <description xml:lang="hu">si1452</description>
+            <description xml:lang="nl">si1452</description>
+            <description xml:lang="ru">si1452</description>
+            <description xml:lang="sk">si1452</description>
+            <description xml:lang="sq">si1452</description>
+            <description xml:lang="sr">si1452</description>
+            <description xml:lang="sv">si1452</description>
+            <description xml:lang="tr">si1452</description>
+            <description xml:lang="uk">si1452</description>
+            <description xml:lang="vi">si1452</description>
+            <description xml:lang="zh_CN">si1452</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>phonetic</name>
+            <description>Phonetic</description>
+            <description xml:lang="af">Foneties</description>
+            <description xml:lang="az">Fonetik</description>
+            <description xml:lang="cs">Fonetické</description>
+            <description xml:lang="da">Fonetisk</description>
+            <description xml:lang="el">Φωνητικά</description>
+            <description xml:lang="en_GB">Phonetic</description>
+            <description xml:lang="fr">Phonétique</description>
+            <description xml:lang="hu">fonetikus</description>
+            <description xml:lang="nl">Fonetisch</description>
+            <description xml:lang="ru">Фонетическая</description>
+            <description xml:lang="rw">Nyigamvugo:</description>
+            <description xml:lang="sk">Fonetické</description>
+            <description xml:lang="sq">Phonetic</description>
+            <description xml:lang="sr">фонетски</description>
+            <description xml:lang="sv">Fonetisk</description>
+            <description xml:lang="tr">Fonetik</description>
+            <description xml:lang="uk">Фонетична</description>
+            <description xml:lang="vi">Ngữ âm</description>
+            <description xml:lang="zh_CN">Phonetic</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>it</name>
+        <shortDescription>Ita</shortDescription>
+        <shortDescription xml:lang="af">Ita</shortDescription>
+        <shortDescription xml:lang="az">İta</shortDescription>
+        <shortDescription xml:lang="cs">Ita</shortDescription>
+        <shortDescription xml:lang="da">Ita</shortDescription>
+        <shortDescription xml:lang="en_GB">Ita</shortDescription>
+        <shortDescription xml:lang="fr">Ita</shortDescription>
+        <shortDescription xml:lang="hu">Ita</shortDescription>
+        <shortDescription xml:lang="nl">Ita</shortDescription>
+        <shortDescription xml:lang="ru">Ит</shortDescription>
+        <shortDescription xml:lang="sk">Tal</shortDescription>
+        <shortDescription xml:lang="sq">Ita</shortDescription>
+        <shortDescription xml:lang="sr">ита</shortDescription>
+        <shortDescription xml:lang="sv">Ita</shortDescription>
+        <shortDescription xml:lang="tr">İta</shortDescription>
+        <shortDescription xml:lang="uk">Іта</shortDescription>
+        <shortDescription xml:lang="vi">Ita</shortDescription>
+        <shortDescription xml:lang="zh_CN">Ita</shortDescription>
+        <description>Italy</description>
+        <description xml:lang="en_GB">Italy</description>
+        <description xml:lang="nl">Italië</description>
+        <description xml:lang="ru">Италия</description>
+        <description xml:lang="rw">Ubutariyani</description>
+        <description xml:lang="vi">Italy</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>jp</name>
+        <shortDescription>Jpn</shortDescription>
+        <shortDescription xml:lang="af">Jpn</shortDescription>
+        <shortDescription xml:lang="az">Ypn</shortDescription>
+        <shortDescription xml:lang="cs">Jap</shortDescription>
+        <shortDescription xml:lang="da">Jpn</shortDescription>
+        <shortDescription xml:lang="el">Ιαπ</shortDescription>
+        <shortDescription xml:lang="en_GB">Jpn</shortDescription>
+        <shortDescription xml:lang="fr">Jpn</shortDescription>
+        <shortDescription xml:lang="hu">Jpn</shortDescription>
+        <shortDescription xml:lang="nl">Jpn</shortDescription>
+        <shortDescription xml:lang="ru">Яп</shortDescription>
+        <shortDescription xml:lang="sk">Jpn</shortDescription>
+        <shortDescription xml:lang="sq">Jpn</shortDescription>
+        <shortDescription xml:lang="sr">јпн</shortDescription>
+        <shortDescription xml:lang="sv">Jpn</shortDescription>
+        <shortDescription xml:lang="tr">Jpn</shortDescription>
+        <shortDescription xml:lang="uk">Япо</shortDescription>
+        <shortDescription xml:lang="vi">Jpn</shortDescription>
+        <shortDescription xml:lang="zh_CN">Jpn</shortDescription>
+        <description>Japan</description>
+        <description xml:lang="en_GB">Japan</description>
+        <description xml:lang="nl">Japan</description>
+        <description xml:lang="ru">Япония</description>
+        <description xml:lang="rw">Ubuyapani</description>
+        <description xml:lang="vi">Nhật Bản</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>kg</name>
+        <shortDescription>Kyr</shortDescription>
+        <shortDescription xml:lang="en_GB">Kyr</shortDescription>
+        <shortDescription xml:lang="nl">Syr</shortDescription>
+        <shortDescription xml:lang="ru">Кыр</shortDescription>
+        <shortDescription xml:lang="vi">Kyr</shortDescription>
+        <description>Kyrgyzstan</description>
+        <description xml:lang="en_GB">Kyrgyzstan</description>
+        <description xml:lang="nl">Kirgizië</description>
+        <description xml:lang="ru">Кыргызстан</description>
+        <description xml:lang="rw">Kirigizasitani</description>
+        <description xml:lang="vi">Kyrgyzstan</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>la</name>
+        <shortDescription>Lao</shortDescription>
+        <shortDescription xml:lang="en_GB">Lao</shortDescription>
+        <shortDescription xml:lang="nl">Mal</shortDescription>
+        <shortDescription xml:lang="ru">Лао</shortDescription>
+        <shortDescription xml:lang="rw">Lawo</shortDescription>
+        <shortDescription xml:lang="vi">Lào</shortDescription>
+        <description>Laos</description>
+        <description xml:lang="en_GB">Laos</description>
+        <description xml:lang="nl">Laos</description>
+        <description xml:lang="ru">Лаос</description>
+        <description xml:lang="vi">Lào</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>latam</name>
+        <shortDescription>LAm</shortDescription>
+        <shortDescription xml:lang="af">LAm</shortDescription>
+        <shortDescription xml:lang="az">LAm</shortDescription>
+        <shortDescription xml:lang="cs">LAm</shortDescription>
+        <shortDescription xml:lang="da">LAm</shortDescription>
+        <shortDescription xml:lang="en_GB">LAm</shortDescription>
+        <shortDescription xml:lang="fr">LAm</shortDescription>
+        <shortDescription xml:lang="hu">LAm</shortDescription>
+        <shortDescription xml:lang="nl">LAm</shortDescription>
+        <shortDescription xml:lang="ru">ЛатАм</shortDescription>
+        <shortDescription xml:lang="sk">LAm</shortDescription>
+        <shortDescription xml:lang="sq">LAm</shortDescription>
+        <shortDescription xml:lang="sr">ЈАм</shortDescription>
+        <shortDescription xml:lang="sv">LAm</shortDescription>
+        <shortDescription xml:lang="tr">LAm</shortDescription>
+        <shortDescription xml:lang="uk">ЛатАм</shortDescription>
+        <shortDescription xml:lang="vi">LAm</shortDescription>
+        <shortDescription xml:lang="zh_CN">LAm</shortDescription>
+        <description>Latin American</description>
+        <description xml:lang="en_GB">Latin American</description>
+        <description xml:lang="nl">Latijns-Amerika</description>
+        <description xml:lang="ru">Латиноамериканская</description>
+        <description xml:lang="vi">La tinh Mỹ</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>sundeadkeys</name>
+            <description>Sun dead keys</description>
+            <description xml:lang="af">Sun (dooie sleutels)</description>
+            <description xml:lang="az">Sun ölü düymələr</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Mrtvé klávesy Sun</description>
+            <description xml:lang="da">Sun døde taster</description>
+            <description xml:lang="en_GB">Sun dead keys</description>
+            <description xml:lang="fr">clés mortes Sun</description>
+            <description xml:lang="hu">Sun halott billentyűk</description>
+            <description xml:lang="nl">Sun dode toetsen</description>
+            <description xml:lang="ru">Специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Mŕtve klávesy Sun</description>
+            <description xml:lang="sq">Pulsantë të vdekur Sun</description>
+            <description xml:lang="sr">Sun-ови акценти</description>
+            <description xml:lang="sv">Sun stumma tangenter</description>
+            <description xml:lang="tr">Sun ölü tuşlar</description>
+            <description xml:lang="uk">Спеціальні клавіші (dead keys) Sun</description>
+            <description xml:lang="vi">Phím chết Sun</description>
+            <description xml:lang="zh_CN">Sun 死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>lt</name>
+        <shortDescription>Ltu</shortDescription>
+        <shortDescription xml:lang="af">Ltu</shortDescription>
+        <shortDescription xml:lang="az">Ltu</shortDescription>
+        <shortDescription xml:lang="cs">Lit</shortDescription>
+        <shortDescription xml:lang="da">Lit</shortDescription>
+        <shortDescription xml:lang="en_GB">Ltu</shortDescription>
+        <shortDescription xml:lang="fr">Ltu</shortDescription>
+        <shortDescription xml:lang="hu">Ltu</shortDescription>
+        <shortDescription xml:lang="nl">Ltu</shortDescription>
+        <shortDescription xml:lang="ru">Лит</shortDescription>
+        <shortDescription xml:lang="sk">Lit</shortDescription>
+        <shortDescription xml:lang="sq">Ltu</shortDescription>
+        <shortDescription xml:lang="sr">лтв</shortDescription>
+        <shortDescription xml:lang="sv">Ltu</shortDescription>
+        <shortDescription xml:lang="tr">Ltu</shortDescription>
+        <shortDescription xml:lang="uk">Лит</shortDescription>
+        <shortDescription xml:lang="vi">Ltu</shortDescription>
+        <shortDescription xml:lang="zh_CN">Ltu</shortDescription>
+        <description>Lithuania</description>
+        <description xml:lang="en_GB">Lithuania</description>
+        <description xml:lang="nl">Litouwen</description>
+        <description xml:lang="ru">Литва</description>
+        <description xml:lang="rw">Lituwaniya</description>
+        <description xml:lang="vi">Li-tu-a-ni</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>std</name>
+            <description>"Standard"</description>
+            <description xml:lang="el">"Εξ ορισμού"</description>
+            <description xml:lang="en_GB">"Standard"</description>
+            <description xml:lang="nl">"Standaard"</description>
+            <description xml:lang="ru">"Стандартная"</description>
+            <description xml:lang="rw">"Bisanzwe-</description>
+            <description xml:lang="vi">"Tiêu chuẩn"</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>us</name>
+            <description>US keyboard with Lithuanian letters</description>
+            <description xml:lang="en_GB">US keyboard with Lithuanian letters</description>
+            <description xml:lang="nl">Amerikaans toetsenbord met Litouwse letters</description>
+            <description xml:lang="ru">Клавиатура США с литовскими буквами</description>
+            <description xml:lang="rw">Mwandikisho Na:</description>
+            <description xml:lang="vi">Bàn phím Mỹ với các chữ cái Li-tu-a-nia</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>lv</name>
+        <shortDescription>Lva</shortDescription>
+        <shortDescription xml:lang="af">Lva</shortDescription>
+        <shortDescription xml:lang="az">Lva</shortDescription>
+        <shortDescription xml:lang="cs">Lot</shortDescription>
+        <shortDescription xml:lang="da">Let</shortDescription>
+        <shortDescription xml:lang="en_GB">Lva</shortDescription>
+        <shortDescription xml:lang="fr">Lva</shortDescription>
+        <shortDescription xml:lang="hu">Lva</shortDescription>
+        <shortDescription xml:lang="nl">Lva</shortDescription>
+        <shortDescription xml:lang="ru">Латв</shortDescription>
+        <shortDescription xml:lang="sk">Lot</shortDescription>
+        <shortDescription xml:lang="sq">Lva</shortDescription>
+        <shortDescription xml:lang="sr">лет</shortDescription>
+        <shortDescription xml:lang="sv">Lva</shortDescription>
+        <shortDescription xml:lang="tr">Lva</shortDescription>
+        <shortDescription xml:lang="uk">Латв</shortDescription>
+        <shortDescription xml:lang="vi">Lva</shortDescription>
+        <shortDescription xml:lang="zh_CN">Lva</shortDescription>
+        <description>Latvia</description>
+        <description xml:lang="en_GB">Latvia</description>
+        <description xml:lang="nl">Letland</description>
+        <description xml:lang="ru">Латвия</description>
+        <description xml:lang="rw">Lativiya</description>
+        <description xml:lang="vi">Lát-via</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>apostrophe</name>
+            <description>Apostrophe (') variant</description>
+            <description xml:lang="en_GB">Apostrophe (') variant</description>
+            <description xml:lang="ru">Вариант с апострофом (')</description>
+            <description xml:lang="vi">Phương án hô ngữ (')</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tilde</name>
+            <description>Tilde (~) variant</description>
+            <description xml:lang="en_GB">Tilde (~) variant</description>
+            <description xml:lang="ru">Вариант с тильдой (~)</description>
+            <description xml:lang="vi">Phương án dấu sóng (~)</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>fkey</name>
+            <description>F-letter (F) variant</description>
+            <description xml:lang="en_GB">F-letter (F) variant</description>
+            <description xml:lang="nl">F-letter (F) variant</description>
+            <description xml:lang="ru">Вариант с F</description>
+            <description xml:lang="rw">Ibaruwa...</description>
+            <description xml:lang="vi">Phương án chữ cái F (F)</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>mao</name>
+        <shortDescription>Mao</shortDescription>
+        <shortDescription xml:lang="en_GB">Mao</shortDescription>
+        <shortDescription xml:lang="nl">Mal</shortDescription>
+        <shortDescription xml:lang="ru">Мао</shortDescription>
+        <shortDescription xml:lang="vi">Mao</shortDescription>
+        <description>Maori</description>
+        <description xml:lang="en_GB">Maori</description>
+        <description xml:lang="nl">Maori</description>
+        <description xml:lang="ru">Маори</description>
+        <description xml:lang="rw">Ikimawori</description>
+        <description xml:lang="vi">Maori</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>mkd</name>
+        <shortDescription>Mkd</shortDescription>
+        <shortDescription xml:lang="af">Mkd</shortDescription>
+        <shortDescription xml:lang="az">Mkd</shortDescription>
+        <shortDescription xml:lang="cs">Mak</shortDescription>
+        <shortDescription xml:lang="da">Mkd</shortDescription>
+        <shortDescription xml:lang="en_GB">Mkd</shortDescription>
+        <shortDescription xml:lang="fr">Mkd</shortDescription>
+        <shortDescription xml:lang="hu">Mkd</shortDescription>
+        <shortDescription xml:lang="nl">Mkd</shortDescription>
+        <shortDescription xml:lang="ru">Мак</shortDescription>
+        <shortDescription xml:lang="sk">Mak</shortDescription>
+        <shortDescription xml:lang="sq">Mkd</shortDescription>
+        <shortDescription xml:lang="sr">мак</shortDescription>
+        <shortDescription xml:lang="sv">Mkd</shortDescription>
+        <shortDescription xml:lang="tr">Mkd</shortDescription>
+        <shortDescription xml:lang="uk">Мкд</shortDescription>
+        <shortDescription xml:lang="vi">Mkd</shortDescription>
+        <shortDescription xml:lang="zh_CN">Mkd</shortDescription>
+        <description>Macedonian</description>
+        <description xml:lang="af">Masedonies</description>
+        <description xml:lang="az">Makedonca</description>
+        <description xml:lang="bg">македонска</description>
+        <description xml:lang="cs">Makedonské</description>
+        <description xml:lang="da">Makedonsk</description>
+        <description xml:lang="el">Φυρομιακά</description>
+        <description xml:lang="en_GB">Macedonian</description>
+        <description xml:lang="fr">Macédonien</description>
+        <description xml:lang="hu">macedón</description>
+        <description xml:lang="nl">Macedonisch</description>
+        <description xml:lang="ru">Македонская</description>
+        <description xml:lang="rw">Nyamasedoniya</description>
+        <description xml:lang="sk">Macedónske</description>
+        <description xml:lang="sq">Maqedonisht</description>
+        <description xml:lang="sr">македонски</description>
+        <description xml:lang="sv">Makedonsk</description>
+        <description xml:lang="tr">Makedonya dili</description>
+        <description xml:lang="uk">Македонська</description>
+        <description xml:lang="vi">Mác-kê-đô-nhia</description>
+        <description xml:lang="zh_CN">马其顿</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>mt</name>
+        <shortDescription>Mlt</shortDescription>
+        <shortDescription xml:lang="af">Mlt</shortDescription>
+        <shortDescription xml:lang="az">Mlt</shortDescription>
+        <shortDescription xml:lang="cs">Mlt</shortDescription>
+        <shortDescription xml:lang="da">Mlt</shortDescription>
+        <shortDescription xml:lang="en_GB">Mlt</shortDescription>
+        <shortDescription xml:lang="fr">Mlt</shortDescription>
+        <shortDescription xml:lang="hu">Mlt</shortDescription>
+        <shortDescription xml:lang="nl">Mlt</shortDescription>
+        <shortDescription xml:lang="ru">Мальт</shortDescription>
+        <shortDescription xml:lang="sk">Mlt</shortDescription>
+        <shortDescription xml:lang="sq">Mlt</shortDescription>
+        <shortDescription xml:lang="sr">мал</shortDescription>
+        <shortDescription xml:lang="sv">Mlt</shortDescription>
+        <shortDescription xml:lang="tr">Mlt</shortDescription>
+        <shortDescription xml:lang="uk">Мальт</shortDescription>
+        <shortDescription xml:lang="vi">Mlt</shortDescription>
+        <shortDescription xml:lang="zh_CN">Mlt</shortDescription>
+        <description>Malta</description>
+        <description xml:lang="en_GB">Malta</description>
+        <description xml:lang="nl">Malta</description>
+        <description xml:lang="ru">Мальта</description>
+        <description xml:lang="rw">Malita</description>
+        <description xml:lang="vi">Malta</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>us</name>
+            <description>US keyboard with Maltian letters</description>
+            <description xml:lang="en_GB">US keyboard with Maltian letters</description>
+            <description xml:lang="nl">Amerikaans toetsenbord met Roemeense letters</description>
+            <description xml:lang="ru">Клавиатура США с мальтийскими буквами</description>
+            <description xml:lang="rw">Mwandikisho Na:</description>
+            <description xml:lang="vi">Bàn phím Mỹ với các chữ cái Mal-chi-a</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>mn</name>
+        <shortDescription>Mng</shortDescription>
+        <shortDescription xml:lang="af">Mng</shortDescription>
+        <shortDescription xml:lang="az">Mng</shortDescription>
+        <shortDescription xml:lang="cs">Mng</shortDescription>
+        <shortDescription xml:lang="da">Mng</shortDescription>
+        <shortDescription xml:lang="en_GB">Mng</shortDescription>
+        <shortDescription xml:lang="fr">Mng</shortDescription>
+        <shortDescription xml:lang="hu">Mng</shortDescription>
+        <shortDescription xml:lang="nl">Mng</shortDescription>
+        <shortDescription xml:lang="ru">Монг</shortDescription>
+        <shortDescription xml:lang="sk">Mng</shortDescription>
+        <shortDescription xml:lang="sq">Mng</shortDescription>
+        <shortDescription xml:lang="sr">мон</shortDescription>
+        <shortDescription xml:lang="sv">Mng</shortDescription>
+        <shortDescription xml:lang="tr">Moğ</shortDescription>
+        <shortDescription xml:lang="uk">Монг</shortDescription>
+        <shortDescription xml:lang="vi">Mng</shortDescription>
+        <shortDescription xml:lang="zh_CN">Mng</shortDescription>
+        <description>Mongolia</description>
+        <description xml:lang="en_GB">Mongolia</description>
+        <description xml:lang="nl">Mongolië</description>
+        <description xml:lang="ru">Монголия</description>
+        <description xml:lang="rw">Mongoliya</description>
+        <description xml:lang="vi">Mông cổ</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>no</name>
+        <shortDescription>Nor</shortDescription>
+        <shortDescription xml:lang="af">Nor</shortDescription>
+        <shortDescription xml:lang="az">Nor</shortDescription>
+        <shortDescription xml:lang="cs">Nor</shortDescription>
+        <shortDescription xml:lang="da">Nor</shortDescription>
+        <shortDescription xml:lang="en_GB">Nor</shortDescription>
+        <shortDescription xml:lang="fr">Nor</shortDescription>
+        <shortDescription xml:lang="hu">Nor</shortDescription>
+        <shortDescription xml:lang="nl">Nor</shortDescription>
+        <shortDescription xml:lang="ru">Нор</shortDescription>
+        <shortDescription xml:lang="sk">Nor</shortDescription>
+        <shortDescription xml:lang="sq">Nor</shortDescription>
+        <shortDescription xml:lang="sr">нор</shortDescription>
+        <shortDescription xml:lang="sv">Nor</shortDescription>
+        <shortDescription xml:lang="tr">Nor</shortDescription>
+        <shortDescription xml:lang="uk">Нор</shortDescription>
+        <shortDescription xml:lang="vi">Nor</shortDescription>
+        <shortDescription xml:lang="zh_CN">Nor</shortDescription>
+        <description>Norway</description>
+        <description xml:lang="en_GB">Norway</description>
+        <description xml:lang="nl">Noorwegen</description>
+        <description xml:lang="ru">Норвегия</description>
+        <description xml:lang="rw">Noruveje</description>
+        <description xml:lang="vi">Na Uy</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>smi</name>
+            <description>Northern Saami</description>
+            <description xml:lang="en_GB">Northern Saami</description>
+            <description xml:lang="nl">Noord-Lapland</description>
+            <description xml:lang="ru">Северная Саамская</description>
+            <description xml:lang="rw">Sami y'Amajyaruguru</description>
+            <description xml:lang="vi">Bắc Saami</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>smi_nodeadkeys</name>
+            <description>Northern Saami, eliminate dead keys</description>
+            <description xml:lang="ru">Северная Саамская, исключить специальные клавиши (dead keys)</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>pl</name>
+        <shortDescription>Pol</shortDescription>
+        <shortDescription xml:lang="af">Pol</shortDescription>
+        <shortDescription xml:lang="az">Pol</shortDescription>
+        <shortDescription xml:lang="bg">полска</shortDescription>
+        <shortDescription xml:lang="cs">Pol</shortDescription>
+        <shortDescription xml:lang="da">Pol</shortDescription>
+        <shortDescription xml:lang="el">Πολ</shortDescription>
+        <shortDescription xml:lang="en_GB">Pol</shortDescription>
+        <shortDescription xml:lang="fr">Pol</shortDescription>
+        <shortDescription xml:lang="hu">Pol</shortDescription>
+        <shortDescription xml:lang="nl">Pol</shortDescription>
+        <shortDescription xml:lang="ru">Польск</shortDescription>
+        <shortDescription xml:lang="sk">Pol</shortDescription>
+        <shortDescription xml:lang="sq">Pol</shortDescription>
+        <shortDescription xml:lang="sr">пољ</shortDescription>
+        <shortDescription xml:lang="sv">Pol</shortDescription>
+        <shortDescription xml:lang="tr">Pol</shortDescription>
+        <shortDescription xml:lang="uk">Пол</shortDescription>
+        <shortDescription xml:lang="vi">Pol</shortDescription>
+        <shortDescription xml:lang="zh_CN">Pol</shortDescription>
+        <description>Poland</description>
+        <description xml:lang="en_GB">Poland</description>
+        <description xml:lang="nl">Polen</description>
+        <description xml:lang="ru">Польша</description>
+        <description xml:lang="rw">Polonye</description>
+        <description xml:lang="vi">Phần Lan</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>qwertz</name>
+            <description>qwertz</description>
+            <description xml:lang="en_GB">qwertz</description>
+            <description xml:lang="nl">qwertz</description>
+            <description xml:lang="ru">qwertz</description>
+            <description xml:lang="vi">qwertz</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak_quotes</name>
+            <description>Dvorak, Polish quotes on quotemark key</description>
+            <description xml:lang="en_GB">Dvorak, Polish quotes on quotemark key</description>
+            <description xml:lang="ru">Dvorak, польские кавычки на клавишах с кавычками</description>
+            <description xml:lang="rw">ku Urufunguzo</description>
+            <description xml:lang="vi">Dvorak, dấu ngoặc Polish trên phím đánh dấu ngoặc</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak_altquotes</name>
+            <description>Dvorak, Polish quotes on key "1/!"</description>
+            <description xml:lang="en_GB">Dvorak, Polish quotes on key "1/!"</description>
+            <description xml:lang="ru">Dvorak, польские кавычки на клавише "1/!"</description>
+            <description xml:lang="rw">ku Urufunguzo 1.</description>
+            <description xml:lang="vi">Dvorak, dấu ngoặc Polish trên phím "1/!"</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>pt</name>
+        <shortDescription>Prt</shortDescription>
+        <shortDescription xml:lang="af">Prt</shortDescription>
+        <shortDescription xml:lang="az">Prt</shortDescription>
+        <shortDescription xml:lang="cs">Prt</shortDescription>
+        <shortDescription xml:lang="da">Prt</shortDescription>
+        <shortDescription xml:lang="en_GB">Prt</shortDescription>
+        <shortDescription xml:lang="fr">Prt</shortDescription>
+        <shortDescription xml:lang="hu">Prt</shortDescription>
+        <shortDescription xml:lang="nl">Prt</shortDescription>
+        <shortDescription xml:lang="ru">Порт</shortDescription>
+        <shortDescription xml:lang="sk">Prt</shortDescription>
+        <shortDescription xml:lang="sq">Prt</shortDescription>
+        <shortDescription xml:lang="sr">прт</shortDescription>
+        <shortDescription xml:lang="sv">Prt</shortDescription>
+        <shortDescription xml:lang="tr">Prt</shortDescription>
+        <shortDescription xml:lang="uk">Порт</shortDescription>
+        <shortDescription xml:lang="vi">Prt</shortDescription>
+        <shortDescription xml:lang="zh_CN">Prt</shortDescription>
+        <description>Portugal</description>
+        <description xml:lang="en_GB">Portugal</description>
+        <description xml:lang="nl">Portugal</description>
+        <description xml:lang="ru">Португалия</description>
+        <description xml:lang="rw">Porutigali</description>
+        <description xml:lang="vi">Bồ Đào Nha</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>sundeadkeys</name>
+            <description>Sun dead keys</description>
+            <description xml:lang="af">Sun (dooie sleutels)</description>
+            <description xml:lang="az">Sun ölü düymələr</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Mrtvé klávesy Sun</description>
+            <description xml:lang="da">Sun døde taster</description>
+            <description xml:lang="en_GB">Sun dead keys</description>
+            <description xml:lang="fr">clés mortes Sun</description>
+            <description xml:lang="hu">Sun halott billentyűk</description>
+            <description xml:lang="nl">Sun dode toetsen</description>
+            <description xml:lang="ru">Специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Mŕtve klávesy Sun</description>
+            <description xml:lang="sq">Pulsantë të vdekur Sun</description>
+            <description xml:lang="sr">Sun-ови акценти</description>
+            <description xml:lang="sv">Sun stumma tangenter</description>
+            <description xml:lang="tr">Sun ölü tuşlar</description>
+            <description xml:lang="uk">Спеціальні клавіші (dead keys) Sun</description>
+            <description xml:lang="vi">Phím chết Sun</description>
+            <description xml:lang="zh_CN">Sun 死键</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ro</name>
+        <shortDescription>Rou</shortDescription>
+        <shortDescription xml:lang="af">Rou</shortDescription>
+        <shortDescription xml:lang="az">Rou</shortDescription>
+        <shortDescription xml:lang="cs">Rum</shortDescription>
+        <shortDescription xml:lang="da">Rum</shortDescription>
+        <shortDescription xml:lang="en_GB">Rou</shortDescription>
+        <shortDescription xml:lang="fr">Rou</shortDescription>
+        <shortDescription xml:lang="hu">Rou</shortDescription>
+        <shortDescription xml:lang="nl">Rou</shortDescription>
+        <shortDescription xml:lang="ru">Рум</shortDescription>
+        <shortDescription xml:lang="sk">Rum</shortDescription>
+        <shortDescription xml:lang="sq">Rou</shortDescription>
+        <shortDescription xml:lang="sr">рум</shortDescription>
+        <shortDescription xml:lang="sv">Rou</shortDescription>
+        <shortDescription xml:lang="tr">Rou</shortDescription>
+        <shortDescription xml:lang="uk">Рум</shortDescription>
+        <shortDescription xml:lang="vi">Rou</shortDescription>
+        <shortDescription xml:lang="zh_CN">Rou</shortDescription>
+        <description>Romania</description>
+        <description xml:lang="en_GB">Romania</description>
+        <description xml:lang="nl">Roemenië</description>
+        <description xml:lang="ru">Румыния</description>
+        <description xml:lang="rw">Romaniya</description>
+        <description xml:lang="vi">Rô-ma-ni</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>us</name>
+            <description>US keyboard with Romanian letters</description>
+            <description xml:lang="af">VSA sleutelbord met Romeense letters</description>
+            <description xml:lang="az">Roman hərfli ABŞ klaviaturası</description>
+            <description xml:lang="cs">Americká klávesnice s rumunskými písmeny</description>
+            <description xml:lang="da">US-tastatur med rumænske bogstaver</description>
+            <description xml:lang="en_GB">US keyboard with Romanian letters</description>
+            <description xml:lang="fr">clavier US avec lettres roumaines</description>
+            <description xml:lang="hu">US billentyűzet román betűkkel</description>
+            <description xml:lang="nl">Amerikaans toetsenbord met Roemeense letters</description>
+            <description xml:lang="ru">Клавиатура США с румынскими буквами</description>
+            <description xml:lang="rw">Mwandikisho Na:</description>
+            <description xml:lang="sk">Americká klávesnica s rumunskými písmami</description>
+            <description xml:lang="sq">Tastierë US me gërma Romane</description>
+            <description xml:lang="sr">Америчка тастатура са румунским словима</description>
+            <description xml:lang="sv">USA-tangentbord med rumänska bokstäver</description>
+            <description xml:lang="tr">Romen harfleriyle amerikan klavyesi</description>
+            <description xml:lang="uk">Клавіатура США з румунськими буквами</description>
+            <description xml:lang="vi">Bàn phím Mỹ với các chữ cái Ro-ma-ni</description>
+            <description xml:lang="zh_CN">美国键盘,带罗马尼亚字符</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>de</name>
+            <description>Romanian keyboard with German letters</description>
+            <description xml:lang="en_GB">Romanian keyboard with German letters</description>
+            <description xml:lang="nl">Roemeens toetsenbord met Duitse letters</description>
+            <description xml:lang="ru">Румынская клавиатура с немецкими буквами</description>
+            <description xml:lang="rw">Mwandikisho Na:</description>
+            <description xml:lang="vi">Bàn phím Rô-ma-ni với các chữ cái Đức</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ru</name>
+        <shortDescription>Rus</shortDescription>
+        <shortDescription xml:lang="af">Rus</shortDescription>
+        <shortDescription xml:lang="az">Rus</shortDescription>
+        <shortDescription xml:lang="cs">Rus</shortDescription>
+        <shortDescription xml:lang="da">Rus</shortDescription>
+        <shortDescription xml:lang="el">Ρωσ</shortDescription>
+        <shortDescription xml:lang="en_GB">Rus</shortDescription>
+        <shortDescription xml:lang="fr">Rus</shortDescription>
+        <shortDescription xml:lang="hu">Rus</shortDescription>
+        <shortDescription xml:lang="nl">Rus</shortDescription>
+        <shortDescription xml:lang="ru">Рус</shortDescription>
+        <shortDescription xml:lang="sk">Rus</shortDescription>
+        <shortDescription xml:lang="sq">Rus</shortDescription>
+        <shortDescription xml:lang="sr">рус</shortDescription>
+        <shortDescription xml:lang="sv">Rus</shortDescription>
+        <shortDescription xml:lang="tr">Rus</shortDescription>
+        <shortDescription xml:lang="uk">Рос</shortDescription>
+        <shortDescription xml:lang="vi">Nga</shortDescription>
+        <shortDescription xml:lang="zh_CN">Rus</shortDescription>
+        <description>Russia</description>
+        <description xml:lang="en_GB">Russia</description>
+        <description xml:lang="nl">Rusland</description>
+        <description xml:lang="ru">Россия</description>
+        <description xml:lang="vi">Nga</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>phonetic</name>
+            <description>Phonetic</description>
+            <description xml:lang="af">Foneties</description>
+            <description xml:lang="az">Fonetik</description>
+            <description xml:lang="cs">Fonetické</description>
+            <description xml:lang="da">Fonetisk</description>
+            <description xml:lang="el">Φωνητικά</description>
+            <description xml:lang="en_GB">Phonetic</description>
+            <description xml:lang="fr">Phonétique</description>
+            <description xml:lang="hu">fonetikus</description>
+            <description xml:lang="nl">Fonetisch</description>
+            <description xml:lang="ru">Фонетическая</description>
+            <description xml:lang="rw">Nyigamvugo:</description>
+            <description xml:lang="sk">Fonetické</description>
+            <description xml:lang="sq">Phonetic</description>
+            <description xml:lang="sr">фонетски</description>
+            <description xml:lang="sv">Fonetisk</description>
+            <description xml:lang="tr">Fonetik</description>
+            <description xml:lang="uk">Фонетична</description>
+            <description xml:lang="vi">Ngữ âm</description>
+            <description xml:lang="zh_CN">Phonetic</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>typewriter</name>
+            <description>Typewriter</description>
+            <description xml:lang="ru">Печатная машинка</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>winkeys</name>
+            <description>Winkeys</description>
+            <description xml:lang="af">Winkeys</description>
+            <description xml:lang="az">Winkeys</description>
+            <description xml:lang="cs">Winkeys</description>
+            <description xml:lang="da">Win-taster</description>
+            <description xml:lang="en_GB">Winkeys</description>
+            <description xml:lang="fr">Winkeys</description>
+            <description xml:lang="hu">Winkeys</description>
+            <description xml:lang="nl">Win-toetsen</description>
+            <description xml:lang="ru">Клавиатура Windows</description>
+            <description xml:lang="sk">Win klávesy</description>
+            <description xml:lang="sq">Winkeys</description>
+            <description xml:lang="sr">Windows тастери</description>
+            <description xml:lang="sv">Wintangenter</description>
+            <description xml:lang="tr">Win tuşları</description>
+            <description xml:lang="uk">Розкладка Windows</description>
+            <description xml:lang="vi">Phím Win</description>
+            <description xml:lang="zh_CN">Winkeys</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>srp</name>
+        <shortDescription>Srp</shortDescription>
+        <shortDescription xml:lang="en_GB">Srp</shortDescription>
+        <shortDescription xml:lang="nl">Syr</shortDescription>
+        <shortDescription xml:lang="ru">Срб</shortDescription>
+        <shortDescription xml:lang="vi">Srp</shortDescription>
+        <description>Serbian</description>
+        <description xml:lang="af">Serbies</description>
+        <description xml:lang="az">Servcə</description>
+        <description xml:lang="bg">сръбска</description>
+        <description xml:lang="cs">Srbské</description>
+        <description xml:lang="da">Serbisk</description>
+        <description xml:lang="en_GB">Serbian</description>
+        <description xml:lang="fr">Serbe</description>
+        <description xml:lang="hu">szerb</description>
+        <description xml:lang="nl">Servisch</description>
+        <description xml:lang="ru">Сербская</description>
+        <description xml:lang="rw">Ikinyaseribiya</description>
+        <description xml:lang="sk">Srbské</description>
+        <description xml:lang="sq">Sërbisht</description>
+        <description xml:lang="sr">српски</description>
+        <description xml:lang="sv">Serbisk</description>
+        <description xml:lang="tr">Sırpça</description>
+        <description xml:lang="uk">Сербська</description>
+        <description xml:lang="vi">Séc-bia</description>
+        <description xml:lang="zh_CN">塞尔维亚</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>yz</name>
+            <description>Z and ZHE swapped</description>
+            <description xml:lang="en_GB">Z and ZHE swapped</description>
+            <description xml:lang="nl">Z en ZHE verwisseld</description>
+            <description xml:lang="ru">З и Ж переставлены</description>
+            <description xml:lang="rw">Na</description>
+            <description xml:lang="vi">Đổi chỗ Z và ZHE</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latin</name>
+            <description>Latin</description>
+            <description xml:lang="af">Latyns</description>
+            <description xml:lang="az">Latın</description>
+            <description xml:lang="bg">латвийска</description>
+            <description xml:lang="cs">Latinské</description>
+            <description xml:lang="da">Latin</description>
+            <description xml:lang="en_GB">Latin</description>
+            <description xml:lang="fr">Latin</description>
+            <description xml:lang="hu">latin</description>
+            <description xml:lang="nl">Latijn</description>
+            <description xml:lang="ru">Латинская</description>
+            <description xml:lang="rw">Ikiratini</description>
+            <description xml:lang="sk">Latinské</description>
+            <description xml:lang="sq">Latinishte</description>
+            <description xml:lang="sr">латинични</description>
+            <description xml:lang="sv">Latin</description>
+            <description xml:lang="tr">Latin</description>
+            <description xml:lang="uk">Латинська</description>
+            <description xml:lang="vi">La tinh</description>
+            <description xml:lang="zh_CN">拉丁</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latinunicode</name>
+            <description>Latin Unicode</description>
+            <description xml:lang="en_GB">Latin Unicode</description>
+            <description xml:lang="nl">Latijns-Unicode</description>
+            <description xml:lang="ru">Латинская Unicode</description>
+            <description xml:lang="vi">La tinh Unicode</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latinyz</name>
+            <description>Latin qwerty</description>
+            <description xml:lang="en_GB">Latin qwerty</description>
+            <description xml:lang="nl">Latijns qwerty</description>
+            <description xml:lang="ru">Латинская qwerty</description>
+            <description xml:lang="vi">La tinh qwerty</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latinunicodeyz</name>
+            <description>Latin Unicode qwerty</description>
+            <description xml:lang="en_GB">Latin Unicode qwerty</description>
+            <description xml:lang="nl">Latijns-Unicode qwerty</description>
+            <description xml:lang="ru">Латинская Unicode qwerty</description>
+            <description xml:lang="vi">La tinh Unicode qwerty</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>alternatequotes</name>
+            <description>With guillemots</description>
+            <description xml:lang="en_GB">With guillemots</description>
+            <description xml:lang="ru">С guillemots</description>
+            <description xml:lang="vi">Với chim guillemot</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>latinalternatequotes</name>
+            <description>Latin with guillemots</description>
+            <description xml:lang="en_GB">Latin with guillemots</description>
+            <description xml:lang="ru">Латинская с guillemots</description>
+            <description xml:lang="rw">Na:</description>
+            <description xml:lang="vi">La tinh với chim guillemot</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>si</name>
+        <shortDescription>Svn</shortDescription>
+        <shortDescription xml:lang="af">Svn</shortDescription>
+        <shortDescription xml:lang="az">Svn</shortDescription>
+        <shortDescription xml:lang="cs">Svn</shortDescription>
+        <shortDescription xml:lang="da">Svn</shortDescription>
+        <shortDescription xml:lang="en_GB">Svn</shortDescription>
+        <shortDescription xml:lang="fr">Svn</shortDescription>
+        <shortDescription xml:lang="hu">Svn</shortDescription>
+        <shortDescription xml:lang="nl">Svn</shortDescription>
+        <shortDescription xml:lang="ru">Cловен</shortDescription>
+        <shortDescription xml:lang="sk">Svn</shortDescription>
+        <shortDescription xml:lang="sq">Svn</shortDescription>
+        <shortDescription xml:lang="sr">сло</shortDescription>
+        <shortDescription xml:lang="sv">Svn</shortDescription>
+        <shortDescription xml:lang="tr">Svn</shortDescription>
+        <shortDescription xml:lang="uk">Словен</shortDescription>
+        <shortDescription xml:lang="vi">Svn</shortDescription>
+        <shortDescription xml:lang="zh_CN">Svn</shortDescription>
+        <description>Slovenia</description>
+        <description xml:lang="en_GB">Slovenia</description>
+        <description xml:lang="nl">Slovenië</description>
+        <description xml:lang="ru">Словения</description>
+        <description xml:lang="rw">Siloveniya</description>
+        <description xml:lang="vi">Slovenia</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>sk</name>
+        <shortDescription>Svk</shortDescription>
+        <shortDescription xml:lang="af">Svk</shortDescription>
+        <shortDescription xml:lang="az">Svk</shortDescription>
+        <shortDescription xml:lang="bg">словашка</shortDescription>
+        <shortDescription xml:lang="cs">Svk</shortDescription>
+        <shortDescription xml:lang="da">Svk</shortDescription>
+        <shortDescription xml:lang="en_GB">Svk</shortDescription>
+        <shortDescription xml:lang="fr">Svk</shortDescription>
+        <shortDescription xml:lang="hu">Svk</shortDescription>
+        <shortDescription xml:lang="nl">Svk</shortDescription>
+        <shortDescription xml:lang="ru">Слов</shortDescription>
+        <shortDescription xml:lang="sk">Svk</shortDescription>
+        <shortDescription xml:lang="sq">Svk</shortDescription>
+        <shortDescription xml:lang="sr">слк</shortDescription>
+        <shortDescription xml:lang="sv">Svk</shortDescription>
+        <shortDescription xml:lang="tr">Svk</shortDescription>
+        <shortDescription xml:lang="uk">Слов</shortDescription>
+        <shortDescription xml:lang="vi">Svk</shortDescription>
+        <shortDescription xml:lang="zh_CN">Svk</shortDescription>
+        <description>Slovakia</description>
+        <description xml:lang="en_GB">Slovakia</description>
+        <description xml:lang="nl">Slowakije</description>
+        <description xml:lang="ru">Словакия</description>
+        <description xml:lang="rw">Silovakiya</description>
+        <description xml:lang="vi">Slovakia</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>bksl</name>
+            <description>Extended Backslash</description>
+            <description xml:lang="en_GB">Extended Backslash</description>
+            <description xml:lang="nl">Uitgebreide backslash</description>
+            <description xml:lang="ru">Расширенные функции Backslash</description>
+            <description xml:lang="vi">Gạch chéo ngược Mở rộng</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>qwerty</name>
+            <description>qwerty</description>
+            <description xml:lang="af">qwerty</description>
+            <description xml:lang="az">qwerty</description>
+            <description xml:lang="bg">чешка (qwerty)</description>
+            <description xml:lang="cs">qwerty</description>
+            <description xml:lang="da">qwerty</description>
+            <description xml:lang="en_GB">qwerty</description>
+            <description xml:lang="fr">qwerty</description>
+            <description xml:lang="hu">qwerty</description>
+            <description xml:lang="nl">qwerty</description>
+            <description xml:lang="ru">qwerty</description>
+            <description xml:lang="sk">qwerty</description>
+            <description xml:lang="sq">qwerty</description>
+            <description xml:lang="sr">qwerty</description>
+            <description xml:lang="sv">qwerty</description>
+            <description xml:lang="tr">qwerty</description>
+            <description xml:lang="uk">qwerty</description>
+            <description xml:lang="vi">qwerty</description>
+            <description xml:lang="zh_CN">qwerty</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>qwerty_bksl</name>
+            <description>qwerty, extended Backslash</description>
+            <description xml:lang="en_GB">qwerty, extended Backslash</description>
+            <description xml:lang="nl">qwerty, uitgebreide backslash</description>
+            <description xml:lang="ru">qwerty, расширенные функции Backslash</description>
+            <description xml:lang="rw">Byongerewe...</description>
+            <description xml:lang="vi">qwerty, Gạch ngược mở rộng</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>es</name>
+        <shortDescription>Esp</shortDescription>
+        <shortDescription xml:lang="af">Esp</shortDescription>
+        <shortDescription xml:lang="az">İsp</shortDescription>
+        <shortDescription xml:lang="cs">Špa</shortDescription>
+        <shortDescription xml:lang="da">Esp</shortDescription>
+        <shortDescription xml:lang="en_GB">Esp</shortDescription>
+        <shortDescription xml:lang="fr">Esp</shortDescription>
+        <shortDescription xml:lang="hu">Esp</shortDescription>
+        <shortDescription xml:lang="nl">Esp</shortDescription>
+        <shortDescription xml:lang="ru">Исп</shortDescription>
+        <shortDescription xml:lang="sk">Špa</shortDescription>
+        <shortDescription xml:lang="sq">Esp</shortDescription>
+        <shortDescription xml:lang="sr">шпа</shortDescription>
+        <shortDescription xml:lang="sv">Esp</shortDescription>
+        <shortDescription xml:lang="tr">İsp</shortDescription>
+        <shortDescription xml:lang="uk">Ісп</shortDescription>
+        <shortDescription xml:lang="vi">Esp</shortDescription>
+        <shortDescription xml:lang="zh_CN">Esp</shortDescription>
+        <description>Spain</description>
+        <description xml:lang="en_GB">Spain</description>
+        <description xml:lang="nl">Spanje</description>
+        <description xml:lang="ru">Испания</description>
+        <description xml:lang="rw">Esipanye</description>
+        <description xml:lang="vi">Tây Ban Nha</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>sundeadkeys</name>
+            <description>Sun dead keys</description>
+            <description xml:lang="af">Sun (dooie sleutels)</description>
+            <description xml:lang="az">Sun ölü düymələr</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Mrtvé klávesy Sun</description>
+            <description xml:lang="da">Sun døde taster</description>
+            <description xml:lang="en_GB">Sun dead keys</description>
+            <description xml:lang="fr">clés mortes Sun</description>
+            <description xml:lang="hu">Sun halott billentyűk</description>
+            <description xml:lang="nl">Sun dode toetsen</description>
+            <description xml:lang="ru">Специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Mŕtve klávesy Sun</description>
+            <description xml:lang="sq">Pulsantë të vdekur Sun</description>
+            <description xml:lang="sr">Sun-ови акценти</description>
+            <description xml:lang="sv">Sun stumma tangenter</description>
+            <description xml:lang="tr">Sun ölü tuşlar</description>
+            <description xml:lang="uk">Спеціальні клавіші (dead keys) Sun</description>
+            <description xml:lang="vi">Phím chết Sun</description>
+            <description xml:lang="zh_CN">Sun 死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>se</name>
+        <shortDescription>Swe</shortDescription>
+        <shortDescription xml:lang="af">Swe</shortDescription>
+        <shortDescription xml:lang="az">Swe</shortDescription>
+        <shortDescription xml:lang="cs">Švé</shortDescription>
+        <shortDescription xml:lang="da">Sve</shortDescription>
+        <shortDescription xml:lang="el">Σου</shortDescription>
+        <shortDescription xml:lang="en_GB">Swe</shortDescription>
+        <shortDescription xml:lang="fr">Sué</shortDescription>
+        <shortDescription xml:lang="hu">Swe</shortDescription>
+        <shortDescription xml:lang="nl">Swe</shortDescription>
+        <shortDescription xml:lang="ru">Швед</shortDescription>
+        <shortDescription xml:lang="sk">Swe</shortDescription>
+        <shortDescription xml:lang="sq">Swe</shortDescription>
+        <shortDescription xml:lang="sr">шве</shortDescription>
+        <shortDescription xml:lang="sv">Swe</shortDescription>
+        <shortDescription xml:lang="tr">İsve</shortDescription>
+        <shortDescription xml:lang="uk">Швед</shortDescription>
+        <shortDescription xml:lang="vi">Swe</shortDescription>
+        <shortDescription xml:lang="zh_CN">Swe</shortDescription>
+        <description>Sweden</description>
+        <description xml:lang="en_GB">Sweden</description>
+        <description xml:lang="nl">Zweden</description>
+        <description xml:lang="ru">Швеция</description>
+        <description xml:lang="rw">Suwede</description>
+        <description xml:lang="vi">Thụy Điển</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>nodeadkeys</name>
+            <description>Eliminate dead keys</description>
+            <description xml:lang="af">Elimineer dooie sleutels</description>
+            <description xml:lang="az">Ölü düymələri sayma</description>
+            <description xml:lang="bg">Изключи специалните клавиши (dead keys)</description>
+            <description xml:lang="cs">Eliminovat mrtvé klávesy</description>
+            <description xml:lang="da">Slå døde taster fra</description>
+            <description xml:lang="el">Χωρίς νεκρά πλήκτρα</description>
+            <description xml:lang="en_GB">Eliminate dead keys</description>
+            <description xml:lang="fr">éliminer des clés mortes</description>
+            <description xml:lang="hu">Halott billentyűk tiltása</description>
+            <description xml:lang="nl">Dode toetsen niet doen</description>
+            <description xml:lang="ru">Исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="sk">Eliminovať mrtvé kláves</description>
+            <description xml:lang="sq">Elemino pulsantët e vdekur</description>
+            <description xml:lang="sr">Уклони акценте</description>
+            <description xml:lang="sv">Eliminera stumma tangenter</description>
+            <description xml:lang="tr">Ölü tuşları normal yapar</description>
+            <description xml:lang="uk">Вилучити спеціальні клавіші (dead keys)</description>
+            <description xml:lang="vi">Phím chết loại trừ</description>
+            <description xml:lang="zh_CN">除去死键</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>rus</name>
+            <description>Russian phonetic</description>
+            <description xml:lang="ru">Русская фонетическая</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>rus_nodeadkeys</name>
+            <description>Russian phonetic, eliminate dead keys</description>
+            <description xml:lang="ru">Русская фонетическая, исключить специальные клавиши (dead keys)</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>smi</name>
+            <description>Northern Saami</description>
+            <description xml:lang="en_GB">Northern Saami</description>
+            <description xml:lang="nl">Noord-Lapland</description>
+            <description xml:lang="ru">Северная Саамская</description>
+            <description xml:lang="rw">Sami y'Amajyaruguru</description>
+            <description xml:lang="vi">Bắc Saami</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ch</name>
+        <shortDescription>Che</shortDescription>
+        <shortDescription xml:lang="en_GB">Che</shortDescription>
+        <shortDescription xml:lang="nl">Cze</shortDescription>
+        <shortDescription xml:lang="ru">Швейц.</shortDescription>
+        <shortDescription xml:lang="vi">Che</shortDescription>
+        <description>Switzerland</description>
+        <description xml:lang="en_GB">Switzerland</description>
+        <description xml:lang="nl">Zwitserland</description>
+        <description xml:lang="ru">Швейцария</description>
+        <description xml:lang="rw">Ubusuwisi</description>
+        <description xml:lang="vi">Thụy Sĩ</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>de_nodeadkeys</name>
+            <description>German, eliminate dead keys</description>
+            <description xml:lang="en_GB">German, eliminate dead keys</description>
+            <description xml:lang="nl">Duits, zonder dode toetsen</description>
+            <description xml:lang="ru">Немецкая, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="vi">Đức, phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>de_sundeadkeys</name>
+            <description>German, Sun dead keys</description>
+            <description xml:lang="en_GB">German, Sun dead keys</description>
+            <description xml:lang="nl">Duits, Sun-dode toetsen</description>
+            <description xml:lang="ru">Немецкая, специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="vi">Đức, phím chết Sun</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>fr</name>
+            <description>French</description>
+            <description xml:lang="af">Frans</description>
+            <description xml:lang="az">Fransızca</description>
+            <description xml:lang="bg">френска</description>
+            <description xml:lang="cs">Francouzské</description>
+            <description xml:lang="da">Fransk</description>
+            <description xml:lang="el">Γαλλικά</description>
+            <description xml:lang="en_GB">French</description>
+            <description xml:lang="fr">Français</description>
+            <description xml:lang="hu">francia</description>
+            <description xml:lang="nl">Frans</description>
+            <description xml:lang="ru">Французская</description>
+            <description xml:lang="rw">Igifaransa</description>
+            <description xml:lang="sk">Francúzske</description>
+            <description xml:lang="sq">Frengjisht</description>
+            <description xml:lang="sr">француски</description>
+            <description xml:lang="sv">Fransk</description>
+            <description xml:lang="tr">Fransızca</description>
+            <description xml:lang="uk">Французька</description>
+            <description xml:lang="vi">Pháp</description>
+            <description xml:lang="zh_CN">法语</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>fr_nodeadkeys</name>
+            <description>French, eliminate dead keys</description>
+            <description xml:lang="en_GB">French, eliminate dead keys</description>
+            <description xml:lang="nl">Frans, zonder dode toetsen</description>
+            <description xml:lang="ru">Французская, исключить специальные клавиши (dead keys)</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="vi">Pháp, phím chết loại trừ</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>fr_sundeadkeys</name>
+            <description>French, Sun dead keys</description>
+            <description xml:lang="en_GB">French, Sun dead keys</description>
+            <description xml:lang="nl">Frans, Sun-dode toetsen</description>
+            <description xml:lang="ru">Французская, специальные клавиши (dead keys) Sun</description>
+            <description xml:lang="rw">Utubuto</description>
+            <description xml:lang="vi">Pháp, phím chết Sun</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>sy</name>
+        <shortDescription>Syr</shortDescription>
+        <shortDescription xml:lang="af">Syr</shortDescription>
+        <shortDescription xml:lang="az">Syr</shortDescription>
+        <shortDescription xml:lang="bg">сръбска</shortDescription>
+        <shortDescription xml:lang="cs">Syr</shortDescription>
+        <shortDescription xml:lang="da">Syr</shortDescription>
+        <shortDescription xml:lang="el">Συρ</shortDescription>
+        <shortDescription xml:lang="en_GB">Syr</shortDescription>
+        <shortDescription xml:lang="fr">Syr</shortDescription>
+        <shortDescription xml:lang="hu">Syr</shortDescription>
+        <shortDescription xml:lang="nl">Syr</shortDescription>
+        <shortDescription xml:lang="ru">Асс</shortDescription>
+        <shortDescription xml:lang="sk">Syr</shortDescription>
+        <shortDescription xml:lang="sq">Syr</shortDescription>
+        <shortDescription xml:lang="sr">сир</shortDescription>
+        <shortDescription xml:lang="sv">Syr</shortDescription>
+        <shortDescription xml:lang="tr">Sur</shortDescription>
+        <shortDescription xml:lang="uk">Сир</shortDescription>
+        <shortDescription xml:lang="vi">Syr</shortDescription>
+        <shortDescription xml:lang="zh_CN">Syr</shortDescription>
+        <description>Syria</description>
+        <description xml:lang="ru">Сирийская</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>syc</name>
+            <description>Syriac</description>
+            <description xml:lang="af">Siries</description>
+            <description xml:lang="az">Syriac</description>
+            <description xml:lang="bg">сръбска</description>
+            <description xml:lang="cs">Syrské</description>
+            <description xml:lang="da">Syrisk</description>
+            <description xml:lang="el">Συριακά</description>
+            <description xml:lang="en_GB">Syriac</description>
+            <description xml:lang="fr">Syriac</description>
+            <description xml:lang="hu">szír</description>
+            <description xml:lang="nl">Syrisch</description>
+            <description xml:lang="ru">Сирийская</description>
+            <description xml:lang="rw">Syriac</description>
+            <description xml:lang="sk">Syrské</description>
+            <description xml:lang="sq">Siriane</description>
+            <description xml:lang="sr">сиријски</description>
+            <description xml:lang="sv">Syrisk</description>
+            <description xml:lang="tr">Suriye dili</description>
+            <description xml:lang="uk">Сирійська</description>
+            <description xml:lang="vi">Syriac</description>
+            <description xml:lang="zh_CN">叙利亚</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>syc_phonetic</name>
+            <description>Syriac phonetic</description>
+            <description xml:lang="ru">Сирийская фонетическая</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>tj</name>
+        <shortDescription>Tjk</shortDescription>
+        <shortDescription xml:lang="af">Tjk</shortDescription>
+        <shortDescription xml:lang="az">Tac</shortDescription>
+        <shortDescription xml:lang="bg">таджикска</shortDescription>
+        <shortDescription xml:lang="cs">Tjk</shortDescription>
+        <shortDescription xml:lang="da">Tjk</shortDescription>
+        <shortDescription xml:lang="en_GB">Tjk</shortDescription>
+        <shortDescription xml:lang="fr">Tjk</shortDescription>
+        <shortDescription xml:lang="hu">Tjk</shortDescription>
+        <shortDescription xml:lang="nl">Tjk</shortDescription>
+        <shortDescription xml:lang="ru">Тадж</shortDescription>
+        <shortDescription xml:lang="sk">Tjk</shortDescription>
+        <shortDescription xml:lang="sq">Tjk</shortDescription>
+        <shortDescription xml:lang="sr">тџк</shortDescription>
+        <shortDescription xml:lang="sv">Tjk</shortDescription>
+        <shortDescription xml:lang="tr">Tck</shortDescription>
+        <shortDescription xml:lang="uk">Тдж</shortDescription>
+        <shortDescription xml:lang="vi">Tjk</shortDescription>
+        <shortDescription xml:lang="zh_CN">Tjk</shortDescription>
+        <description>Tajikistan</description>
+        <description xml:lang="en_GB">Tajikistan</description>
+        <description xml:lang="nl">Tadzjikistan</description>
+        <description xml:lang="ru">Таджикистан</description>
+        <description xml:lang="rw">Tajikisitani</description>
+        <description xml:lang="vi">Ta-zi-kix-tan</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>lk</name>
+        <shortDescription>SrL</shortDescription>
+        <shortDescription xml:lang="ru">ШрЛ</shortDescription>
+        <description>Sri Lanka</description>
+        <description xml:lang="ru">Шри Ланка</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>tam_unicode</name>
+            <description>Tamil Unicode</description>
+            <description xml:lang="ru">Тамильская Unicode</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tam_TAB</name>
+            <description>Tamil TAB Typewriter</description>
+            <description xml:lang="ru">Тамильская "Печатная машинка" TAB</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>tam_TSCII</name>
+            <description>Tamil TSCII Typewriter</description>
+            <description xml:lang="ru">Тамильская "Печатная машинка" TSCII</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>sin_phonetic</name>
+            <description>Sinhala phonetic</description>
+            <description xml:lang="ru">Синхала фонетическая</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>th</name>
+        <shortDescription>Tha</shortDescription>
+        <shortDescription xml:lang="af">Tha</shortDescription>
+        <shortDescription xml:lang="az">Tay</shortDescription>
+        <shortDescription xml:lang="bg">тайландска</shortDescription>
+        <shortDescription xml:lang="cs">Tha</shortDescription>
+        <shortDescription xml:lang="da">Tha</shortDescription>
+        <shortDescription xml:lang="en_GB">Tha</shortDescription>
+        <shortDescription xml:lang="fr">Tha</shortDescription>
+        <shortDescription xml:lang="hu">Tha</shortDescription>
+        <shortDescription xml:lang="nl">Tha</shortDescription>
+        <shortDescription xml:lang="ru">Таи</shortDescription>
+        <shortDescription xml:lang="sk">Tha</shortDescription>
+        <shortDescription xml:lang="sq">Tha</shortDescription>
+        <shortDescription xml:lang="sr">тај</shortDescription>
+        <shortDescription xml:lang="sv">Tha</shortDescription>
+        <shortDescription xml:lang="tr">Tha</shortDescription>
+        <shortDescription xml:lang="uk">Тай</shortDescription>
+        <shortDescription xml:lang="vi">Tha</shortDescription>
+        <shortDescription xml:lang="zh_CN">Tha</shortDescription>
+        <description>Thailand</description>
+        <description xml:lang="en_GB">Thailand</description>
+        <description xml:lang="nl">Thaïland</description>
+        <description xml:lang="ru">Таиланд</description>
+        <description xml:lang="rw">Tayilande</description>
+        <description xml:lang="vi">Thái Lan</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>tis</name>
+            <description>TIS-820.2538</description>
+            <description xml:lang="en_GB">TIS-820.2538</description>
+            <description xml:lang="nl">TIS-820.2538</description>
+            <description xml:lang="ru">TIS-820.2538</description>
+            <description xml:lang="vi">TIS-820.2538</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>pat</name>
+            <description>Pattachote</description>
+            <description xml:lang="en_GB">Pattachote</description>
+            <description xml:lang="nl">Pattachote</description>
+            <description xml:lang="ru">Паттачот</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>tr</name>
+        <shortDescription>Tur</shortDescription>
+        <shortDescription xml:lang="af">Tur</shortDescription>
+        <shortDescription xml:lang="az">Tür</shortDescription>
+        <shortDescription xml:lang="cs">Tur</shortDescription>
+        <shortDescription xml:lang="da">Tyr</shortDescription>
+        <shortDescription xml:lang="el">Του</shortDescription>
+        <shortDescription xml:lang="en_GB">Tur</shortDescription>
+        <shortDescription xml:lang="fr">Tur</shortDescription>
+        <shortDescription xml:lang="hu">Tur</shortDescription>
+        <shortDescription xml:lang="nl">Tur</shortDescription>
+        <shortDescription xml:lang="ru">Тур</shortDescription>
+        <shortDescription xml:lang="sk">Tur</shortDescription>
+        <shortDescription xml:lang="sq">Tur</shortDescription>
+        <shortDescription xml:lang="sr">тур</shortDescription>
+        <shortDescription xml:lang="sv">Tur</shortDescription>
+        <shortDescription xml:lang="tr">Trk</shortDescription>
+        <shortDescription xml:lang="uk">Тур</shortDescription>
+        <shortDescription xml:lang="vi">Tur</shortDescription>
+        <shortDescription xml:lang="zh_CN">Tur</shortDescription>
+        <description>Turkish </description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>f</name>
+            <description>(F)</description>
+            <description xml:lang="en_GB">(F)</description>
+            <description xml:lang="nl">(F)</description>
+            <description xml:lang="ru">(F)</description>
+            <description xml:lang="vi">(F)</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>alt</name>
+            <description>Alt-Q</description>
+            <description xml:lang="el">Alt-Q</description>
+            <description xml:lang="en_GB">Alt-Q</description>
+            <description xml:lang="nl">Alt-Q</description>
+            <description xml:lang="ru">Alt-Q</description>
+            <description xml:lang="vi">Alt-Q</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ua</name>
+        <shortDescription>Ukr</shortDescription>
+        <shortDescription xml:lang="af">Ukr</shortDescription>
+        <shortDescription xml:lang="az">Ukr</shortDescription>
+        <shortDescription xml:lang="cs">Ukr</shortDescription>
+        <shortDescription xml:lang="da">Ukr</shortDescription>
+        <shortDescription xml:lang="el">Ουκ</shortDescription>
+        <shortDescription xml:lang="en_GB">Ukr</shortDescription>
+        <shortDescription xml:lang="fr">Ukr</shortDescription>
+        <shortDescription xml:lang="hu">Ukr</shortDescription>
+        <shortDescription xml:lang="nl">Ukr</shortDescription>
+        <shortDescription xml:lang="ru">Укр</shortDescription>
+        <shortDescription xml:lang="sk">Ukr</shortDescription>
+        <shortDescription xml:lang="sq">Ukr</shortDescription>
+        <shortDescription xml:lang="sr">укр</shortDescription>
+        <shortDescription xml:lang="sv">Ukr</shortDescription>
+        <shortDescription xml:lang="tr">Ukr</shortDescription>
+        <shortDescription xml:lang="uk">Укр</shortDescription>
+        <shortDescription xml:lang="vi">Ukr</shortDescription>
+        <shortDescription xml:lang="zh_CN">Ukr</shortDescription>
+        <description>Ukraine</description>
+        <description xml:lang="en_GB">Ukraine</description>
+        <description xml:lang="nl">Oekraïne</description>
+        <description xml:lang="ru">Украина</description>
+        <description xml:lang="rw">Ikerene</description>
+        <description xml:lang="vi">U-cra-in</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>phonetic</name>
+            <description>Phonetic</description>
+            <description xml:lang="af">Foneties</description>
+            <description xml:lang="az">Fonetik</description>
+            <description xml:lang="cs">Fonetické</description>
+            <description xml:lang="da">Fonetisk</description>
+            <description xml:lang="el">Φωνητικά</description>
+            <description xml:lang="en_GB">Phonetic</description>
+            <description xml:lang="fr">Phonétique</description>
+            <description xml:lang="hu">fonetikus</description>
+            <description xml:lang="nl">Fonetisch</description>
+            <description xml:lang="ru">Фонетическая</description>
+            <description xml:lang="rw">Nyigamvugo:</description>
+            <description xml:lang="sk">Fonetické</description>
+            <description xml:lang="sq">Phonetic</description>
+            <description xml:lang="sr">фонетски</description>
+            <description xml:lang="sv">Fonetisk</description>
+            <description xml:lang="tr">Fonetik</description>
+            <description xml:lang="uk">Фонетична</description>
+            <description xml:lang="vi">Ngữ âm</description>
+            <description xml:lang="zh_CN">Phonetic</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>typewriter</name>
+            <description>Typewriter</description>
+            <description xml:lang="ru">Печатная машинка</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>winkeys</name>
+            <description>Winkeys</description>
+            <description xml:lang="af">Winkeys</description>
+            <description xml:lang="az">Winkeys</description>
+            <description xml:lang="cs">Winkeys</description>
+            <description xml:lang="da">Win-taster</description>
+            <description xml:lang="en_GB">Winkeys</description>
+            <description xml:lang="fr">Winkeys</description>
+            <description xml:lang="hu">Winkeys</description>
+            <description xml:lang="nl">Win-toetsen</description>
+            <description xml:lang="ru">Клавиатура Windows</description>
+            <description xml:lang="sk">Win klávesy</description>
+            <description xml:lang="sq">Winkeys</description>
+            <description xml:lang="sr">Windows тастери</description>
+            <description xml:lang="sv">Wintangenter</description>
+            <description xml:lang="tr">Win tuşları</description>
+            <description xml:lang="uk">Розкладка Windows</description>
+            <description xml:lang="vi">Phím Win</description>
+            <description xml:lang="zh_CN">Winkeys</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>rstu</name>
+<!-- RSTU 2019-91 -->
+            <description>Standard RSTU</description>
+            <description xml:lang="ru">Стандартная RSTU</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>rstu_ru</name>
+<!-- RSTU 2019-91 -->
+            <description>Standard RSTU on Russian layout</description>
+            <description xml:lang="ru">Стандартная RSTU, русская</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>gb</name>
+        <shortDescription>GBr</shortDescription>
+        <shortDescription xml:lang="af">GBr</shortDescription>
+        <shortDescription xml:lang="az">GBr</shortDescription>
+        <shortDescription xml:lang="cs">VBr</shortDescription>
+        <shortDescription xml:lang="da">GBr</shortDescription>
+        <shortDescription xml:lang="en_GB">GBr</shortDescription>
+        <shortDescription xml:lang="fr">GBr</shortDescription>
+        <shortDescription xml:lang="hu">GBr</shortDescription>
+        <shortDescription xml:lang="nl">GBr</shortDescription>
+        <shortDescription xml:lang="ru">Брит</shortDescription>
+        <shortDescription xml:lang="sk">VBr</shortDescription>
+        <shortDescription xml:lang="sq">GBr</shortDescription>
+        <shortDescription xml:lang="sr">вбр</shortDescription>
+        <shortDescription xml:lang="sv">GBr</shortDescription>
+        <shortDescription xml:lang="tr">GBr</shortDescription>
+        <shortDescription xml:lang="uk">Брит</shortDescription>
+        <shortDescription xml:lang="vi">GBr</shortDescription>
+        <shortDescription xml:lang="zh_CN">GBr</shortDescription>
+        <description>United Kingdom</description>
+        <description xml:lang="af">Vereenigde Koninkryk</description>
+        <description xml:lang="az">Birləşik Krallıq</description>
+        <description xml:lang="bg">британска</description>
+        <description xml:lang="cs">Spojené království</description>
+        <description xml:lang="da">United Kingdom</description>
+        <description xml:lang="el">Ηνωμένο Βασίλειο</description>
+        <description xml:lang="en_GB">United Kingdom</description>
+        <description xml:lang="fr">Royaume Uni</description>
+        <description xml:lang="hu">brit angol</description>
+        <description xml:lang="nl">Verenigd Koninkrijk</description>
+        <description xml:lang="ru">Английская (Великобритания)</description>
+        <description xml:lang="rw">Ubwongereza (UK)</description>
+        <description xml:lang="sk">Spojené kráľovstvo</description>
+        <description xml:lang="sq">Mbretëria e Bashkuar</description>
+        <description xml:lang="sr">Велика Британија</description>
+        <description xml:lang="sv">Storbritannien</description>
+        <description xml:lang="tr">İngiltere</description>
+        <description xml:lang="uk">Англійська (Великобританія)</description>
+        <description xml:lang="vi">Vương Quốc Anh</description>
+        <description xml:lang="zh_CN">英国</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>intl</name>
+            <description>International (with dead keys)</description>
+            <description xml:lang="en_GB">International (with dead keys)</description>
+            <description xml:lang="nl">Internationaal (met dode toetsen)</description>
+            <description xml:lang="ru">Международная, со спец. клавишами (dead keys)</description>
+            <description xml:lang="rw">Na: Utubuto</description>
+            <description xml:lang="vi">Quốc tế (với phím chết)</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>dvorak</name>
+            <description>Dvorak</description>
+            <description xml:lang="af">Dvorak</description>
+            <description xml:lang="az">Dvorak</description>
+            <description xml:lang="bg">Дворак</description>
+            <description xml:lang="cs">Dvorak</description>
+            <description xml:lang="da">Dvorak</description>
+            <description xml:lang="en_GB">Dvorak</description>
+            <description xml:lang="fr">Dvorak</description>
+            <description xml:lang="hu">Dvorak-féle</description>
+            <description xml:lang="nl">Dvorak</description>
+            <description xml:lang="ru">Дворак</description>
+            <description xml:lang="sk">Dvorak</description>
+            <description xml:lang="sq">Dvorak</description>
+            <description xml:lang="sr">дворак</description>
+            <description xml:lang="sv">Dvorak</description>
+            <description xml:lang="tr">Dvorak</description>
+            <description xml:lang="uk">Дворак</description>
+            <description xml:lang="vi">Dvorak</description>
+            <description xml:lang="zh_CN">Dvorak</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>uz</name>
+        <shortDescription>Uzb</shortDescription>
+        <shortDescription xml:lang="af">Uzb</shortDescription>
+        <shortDescription xml:lang="az">Özb</shortDescription>
+        <shortDescription xml:lang="cs">Uzb</shortDescription>
+        <shortDescription xml:lang="da">Uzb</shortDescription>
+        <shortDescription xml:lang="en_GB">Uzb</shortDescription>
+        <shortDescription xml:lang="fr">Uzb</shortDescription>
+        <shortDescription xml:lang="hu">Uzb</shortDescription>
+        <shortDescription xml:lang="nl">Uzb</shortDescription>
+        <shortDescription xml:lang="ru">Узб</shortDescription>
+        <shortDescription xml:lang="sk">Uzb</shortDescription>
+        <shortDescription xml:lang="sq">Uzb</shortDescription>
+        <shortDescription xml:lang="sr">узб</shortDescription>
+        <shortDescription xml:lang="sv">Uzb</shortDescription>
+        <shortDescription xml:lang="tr">Özb</shortDescription>
+        <shortDescription xml:lang="uk">Узб</shortDescription>
+        <shortDescription xml:lang="vi">Uzb</shortDescription>
+        <shortDescription xml:lang="zh_CN">Uzb</shortDescription>
+        <description>Uzbekistan</description>
+        <description xml:lang="en_GB">Uzbekistan</description>
+        <description xml:lang="nl">Oezbekistan</description>
+        <description xml:lang="ru">Узбекистан</description>
+        <description xml:lang="rw">Uzubekisitani</description>
+        <description xml:lang="vi">Uz-bê-kix-tan</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>vn</name>
+        <shortDescription>Vnm</shortDescription>
+        <shortDescription xml:lang="af">Vnm</shortDescription>
+        <shortDescription xml:lang="az">Vye</shortDescription>
+        <shortDescription xml:lang="cs">Vnm</shortDescription>
+        <shortDescription xml:lang="da">Vnm</shortDescription>
+        <shortDescription xml:lang="en_GB">Vnm</shortDescription>
+        <shortDescription xml:lang="fr">Vnm</shortDescription>
+        <shortDescription xml:lang="hu">Vnm</shortDescription>
+        <shortDescription xml:lang="nl">Vnm</shortDescription>
+        <shortDescription xml:lang="ru">Вьет</shortDescription>
+        <shortDescription xml:lang="sk">Vnm</shortDescription>
+        <shortDescription xml:lang="sq">Vnm</shortDescription>
+        <shortDescription xml:lang="sr">вјт</shortDescription>
+        <shortDescription xml:lang="sv">Vnm</shortDescription>
+        <shortDescription xml:lang="tr">Vnm</shortDescription>
+        <shortDescription xml:lang="uk">Вьет</shortDescription>
+        <shortDescription xml:lang="vi">Vnm</shortDescription>
+        <shortDescription xml:lang="zh_CN">Vnm</shortDescription>
+        <description>Vietnam</description>
+        <description xml:lang="en_GB">Vietnam</description>
+        <description xml:lang="nl">Viëtnam</description>
+        <description xml:lang="ru">Вьетнам</description>
+        <description xml:lang="rw">Viyetinamu</description>
+        <description xml:lang="vi">Việt nam</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>nec_vndr/jp</name>
+        <shortDescription>Jpn</shortDescription>
+        <shortDescription xml:lang="af">Jpn</shortDescription>
+        <shortDescription xml:lang="az">Ypn</shortDescription>
+        <shortDescription xml:lang="cs">Jap</shortDescription>
+        <shortDescription xml:lang="da">Jpn</shortDescription>
+        <shortDescription xml:lang="el">Ιαπ</shortDescription>
+        <shortDescription xml:lang="en_GB">Jpn</shortDescription>
+        <shortDescription xml:lang="fr">Jpn</shortDescription>
+        <shortDescription xml:lang="hu">Jpn</shortDescription>
+        <shortDescription xml:lang="nl">Jpn</shortDescription>
+        <shortDescription xml:lang="ru">Яп</shortDescription>
+        <shortDescription xml:lang="sk">Jpn</shortDescription>
+        <shortDescription xml:lang="sq">Jpn</shortDescription>
+        <shortDescription xml:lang="sr">јпн</shortDescription>
+        <shortDescription xml:lang="sv">Jpn</shortDescription>
+        <shortDescription xml:lang="tr">Jpn</shortDescription>
+        <shortDescription xml:lang="uk">Япо</shortDescription>
+        <shortDescription xml:lang="vi">Jpn</shortDescription>
+        <shortDescription xml:lang="zh_CN">Jpn</shortDescription>
+        <description>PC-98xx Series</description>
+        <description xml:lang="af">PC-98xx Reeks</description>
+        <description xml:lang="az">PC-98xx Seriyaları</description>
+        <description xml:lang="bg">PC-98xx серии</description>
+        <description xml:lang="cs">PC-98xx řada</description>
+        <description xml:lang="da">PC-98xx-serien</description>
+        <description xml:lang="en_GB">PC-98xx Series</description>
+        <description xml:lang="fr">PC-98xx Series</description>
+        <description xml:lang="hu">PC-98xx Series</description>
+        <description xml:lang="nl">PC-98xx serie</description>
+        <description xml:lang="ru">PC-98xx</description>
+        <description xml:lang="sk">Séria PC-98xx</description>
+        <description xml:lang="sq">Seritë PC-98xx</description>
+        <description xml:lang="sr">PC-98xx серија</description>
+        <description xml:lang="sv">PC-98xx-serien</description>
+        <description xml:lang="tr">PC-98xx Serisi</description>
+        <description xml:lang="uk">Моделі PC-98xx</description>
+        <description xml:lang="vi">Sê ri PC-98xx</description>
+        <description xml:lang="zh_CN">PC-98xx 系列</description>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
+        <name>ie</name>
+        <shortDescription>Irl</shortDescription>
+        <shortDescription xml:lang="af">Irl</shortDescription>
+        <shortDescription xml:lang="az">İrl</shortDescription>
+        <shortDescription xml:lang="cs">Irs</shortDescription>
+        <shortDescription xml:lang="da">Irl</shortDescription>
+        <shortDescription xml:lang="en_GB">Irl</shortDescription>
+        <shortDescription xml:lang="fr">Irl</shortDescription>
+        <shortDescription xml:lang="hu">Irl</shortDescription>
+        <shortDescription xml:lang="nl">Irl</shortDescription>
+        <shortDescription xml:lang="ru">Ирл</shortDescription>
+        <shortDescription xml:lang="sk">Irs</shortDescription>
+        <shortDescription xml:lang="sq">Irl</shortDescription>
+        <shortDescription xml:lang="sr">ирс</shortDescription>
+        <shortDescription xml:lang="sv">Irl</shortDescription>
+        <shortDescription xml:lang="tr">İrl</shortDescription>
+        <shortDescription xml:lang="uk">Ірл</shortDescription>
+        <shortDescription xml:lang="vi">Irl</shortDescription>
+        <shortDescription xml:lang="zh_CN">Irl</shortDescription>
+        <description>Ireland</description>
+        <description xml:lang="en_GB">Ireland</description>
+        <description xml:lang="nl">Ierland</description>
+        <description xml:lang="ru">Ирландия</description>
+        <description xml:lang="rw">Irilande</description>
+        <description xml:lang="vi">Ireland</description>
+      </configItem>
+      <variantList>
+        <variant>
+          <configItem>
+            <name>CloGaelach</name>
+            <description>CloGaelach</description>
+            <description xml:lang="af">CloGaelach</description>
+            <description xml:lang="az">CloGaelach</description>
+            <description xml:lang="cs">CloGaelach</description>
+            <description xml:lang="da">CloGaelach</description>
+            <description xml:lang="en_GB">CloGaelach</description>
+            <description xml:lang="fr">CloGaelach</description>
+            <description xml:lang="hu">CloGaelach</description>
+            <description xml:lang="nl">CloGaelach</description>
+            <description xml:lang="ru">CloGaelach</description>
+            <description xml:lang="sk">CloGaelach</description>
+            <description xml:lang="sq">CloGaelach</description>
+            <description xml:lang="sr">CloGaelach</description>
+            <description xml:lang="sv">CloGaelach</description>
+            <description xml:lang="tr">CloGaelach</description>
+            <description xml:lang="uk">CloGaelach</description>
+            <description xml:lang="vi">CloGaelach</description>
+            <description xml:lang="zh_CN">CloGaelach</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>UnicodeExpert</name>
+            <description>UnicodeExpert</description>
+            <description xml:lang="af">UnicodeExpert</description>
+            <description xml:lang="az">UnicodeExpert</description>
+            <description xml:lang="cs">UnicodeExpert</description>
+            <description xml:lang="da">UnicodeExpert</description>
+            <description xml:lang="en_GB">UnicodeExpert</description>
+            <description xml:lang="fr">UnicodeExpert</description>
+            <description xml:lang="hu">UnicodeExpert</description>
+            <description xml:lang="nl">UnicodeExpert</description>
+            <description xml:lang="ru">UnicodeExpert</description>
+            <description xml:lang="sk">UnicodeExpert</description>
+            <description xml:lang="sq">EkspertUnicode</description>
+            <description xml:lang="sr">Стручна за Уникод</description>
+            <description xml:lang="sv">UnicodeExpert</description>
+            <description xml:lang="tr">Unicode Uzman</description>
+            <description xml:lang="uk">UnicodeExpert</description>
+            <description xml:lang="vi">Unicode Chuyên môn</description>
+            <description xml:lang="zh_CN">UnicodeExpert</description>
+          </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>ogam</name>
+            <description>Ogham</description>
+            <description xml:lang="af">Ogham</description>
+            <description xml:lang="az">Ogham</description>
+            <description xml:lang="cs">Oghamské</description>
+            <description xml:lang="da">Ogham</description>
+            <description xml:lang="en_GB">Ogham</description>
+            <description xml:lang="fr">Ogham</description>
+            <description xml:lang="hu">ogham</description>
+            <description xml:lang="nl">Oghamees</description>
+            <description xml:lang="ru">Огхам (древнеирланская)</description>
+            <description xml:lang="rw">Ogham</description>
+            <description xml:lang="sk">Oghamské</description>
+            <description xml:lang="sq">Ogham</description>
+            <description xml:lang="sr">огам</description>
+            <description xml:lang="sv">Ogham</description>
+            <description xml:lang="tr">Ogham</description>
+            <description xml:lang="uk">Огхам (давньоірландська)</description>
+            <description xml:lang="vi">Ogham</description>
+            <description xml:lang="zh_CN">欧甘</description>
+         </configItem>
+        </variant>
+        <variant>
+          <configItem>
+            <name>ogam_is434</name>
+            <description>Ogham IS434</description>
+            <description xml:lang="ru">Огхам IS434</description>
+          </configItem>
+        </variant>
+      </variantList>
+    </layout>
+    <layout>
+      <configItem>
+        <name>pk</name>
+        <shortDescription>Pak</shortDescription>
+        <shortDescription xml:lang="ru">Пак</shortDescription>
+        <description>Pakistan</description>
+        <description xml:lang="ru">Пакистан</description>
+      </configItem>
+      <variantList/>
+    </layout>
+ <!--   <layout>
+      <configItem>
+        <name>div</name>
+        <shortDescription>Div</shortDescription>
+        <shortDescription xml:lang="ru">Див</shortDescription>
+        <description>Dhivehi</description>
+        <description xml:lang="ru">Дивехи</description>
+      </configItem>
+      <variantList/>
+    </layout> -->
+  </layoutList>
+  <optionList>
+    <group allowMultipleSelection="true">
+      <!-- The key combination used to switch between groups -->
+      <configItem>
+        <name>grp</name>
+        <description>Group Shift/Lock behavior</description>
+        <description xml:lang="af">Groep Shift/Lock gedrag</description>
+        <description xml:lang="az">Shift/Lock Qrupu Davranışı</description>
+        <description xml:lang="bg">Функции на клавишите Shift/Lock</description>
+        <description xml:lang="cs">Chování skupiny Shift/Lock</description>
+        <description xml:lang="da">Gruppeskift/-lås-opførsel</description>
+        <description xml:lang="en_GB">Group Shift/Lock behaviour</description>
+        <description xml:lang="fr">comportement de groupe Shitf/Lock</description>
+        <description xml:lang="hu">Csoportváltás és -zárolás</description>
+        <description xml:lang="nl">Groepgedrag Shift/Lock</description>
+        <description xml:lang="ru">Функция смены раскладки</description>
+        <description xml:lang="rw">imyitwarire</description>
+        <description xml:lang="sk">Zoskupiť chovanie Shift/Lock</description>
+        <description xml:lang="sq">Sjellja e grupit Shift/Lock</description>
+        <description xml:lang="sr">Понашање измене/избора групе</description>
+        <description xml:lang="sv">Gruppbeteende för Skift/Lock</description>
+        <description xml:lang="tr">Shift/Lock Grubu davranışı</description>
+        <description xml:lang="uk">Функція зміни групи</description>
+        <description xml:lang="vi">Đặc điểm của nhóm Shift/Lock</description>
+        <description xml:lang="zh_CN">组切换/锁定行为</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>grp:switch</name>
+          <description>R-Alt switches group while pressed.</description>
+          <description xml:lang="en_GB">R-Alt switches group while pressed.</description>
+          <description xml:lang="nl">Rechter Alt schakelt groep bij indrukken.</description>
+          <description xml:lang="ru">Правая клавиша Alt переключает группу на время нажатия.</description>
+          <description xml:lang="rw">Itsinda</description>
+          <description xml:lang="vi">R-Alt thay đổi ngôn ngữ nhập vào khi được nhấn.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:lswitch</name>
+          <description>Left Alt key switches group while pressed.</description>
+          <description xml:lang="en_GB">Left Alt key switches group while pressed.</description>
+          <description xml:lang="nl">Linker Alt-toets schakelt groep bij indrukken.</description>
+          <description xml:lang="ru">Левая клавиша Alt переключает группу на время нажатия.</description>
+          <description xml:lang="rw">Urufunguzo Itsinda</description>
+          <description xml:lang="vi">Phím Alt bên trái chuyển đổi ngôn ngữ khi được nhấn.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:lwin_switch</name>
+          <description>Left Win-key switches group while pressed.</description>
+          <description xml:lang="en_GB">Left Win-key switches group while pressed.</description>
+          <description xml:lang="nl">Linker Win-toets schakelt groep bij indrukken.</description>
+          <description xml:lang="ru">Левая клавиша Win переключает группу на время нажатия.</description>
+          <description xml:lang="rw">Urufunguzo Itsinda</description>
+          <description xml:lang="vi">Phím Win bên trái chuyển đổi ngôn ngữ khi được nhấn.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:rwin_switch</name>
+          <description>Right Win-key switches group while pressed.</description>
+          <description xml:lang="en_GB">Right Win-key switches group while pressed.</description>
+          <description xml:lang="nl">Rechter Win-toets schakelt groep bij indrukken.</description>
+          <description xml:lang="ru">Правая клавиша Win переключает группу на время нажатия.</description>
+          <description xml:lang="rw">Urufunguzo Itsinda</description>
+          <description xml:lang="vi">Phím Alt bên phải thay đổi ngôn ngữ nhập vào khi được nhấn.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:win_switch</name>
+          <description>Both Win-keys switch group while pressed.</description>
+          <description xml:lang="en_GB">Both Win-keys switch group while pressed.</description>
+          <description xml:lang="nl">Beide Win-toetsen schakelen groep bij indrukken.</description>
+          <description xml:lang="ru">Две клавиши Win переключает группу на время нажатия.</description>
+          <description xml:lang="rw">Utubuto Hindura Itsinda</description>
+          <description xml:lang="vi">Cả hai phím Win chuyển ngôn ngữ nhập khi nhấn.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:rctrl_switch</name>
+          <description>Right Ctrl key switches group while pressed.</description>
+          <description xml:lang="en_GB">Right Ctrl key switches group while pressed.</description>
+          <description xml:lang="nl">Rechter Ctrl-toets schakelt groep bij indrukken.</description>
+          <description xml:lang="ru">Правая клавиша Ctrl переключает группу на время нажатия.</description>
+          <description xml:lang="rw">Urufunguzo Itsinda</description>
+          <description xml:lang="vi">Ctrl bên phải thay đổi ngôn ngữ nhập vào khi được nhấn.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:toggle</name>
+          <description>Right Alt key changes group.</description>
+          <description xml:lang="en_GB">Right Alt key changes group.</description>
+          <description xml:lang="nl">Rechter Alt-toets verandert groep.</description>
+          <description xml:lang="ru">Правая клавиша Alt меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Alt bên phải thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:lalt_toggle</name>
+          <description>Left Alt key changes group.</description>
+          <description xml:lang="en_GB">Left Alt key changes group.</description>
+          <description xml:lang="nl">Linker Alt-toets verandert groep.</description>
+          <description xml:lang="ru">Левая клавиша Alt меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Alt bên trái thay đổi ngôn ngữ nhập vào.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:caps_toggle</name>
+          <description>CapsLock key changes group.</description>
+          <description xml:lang="en_GB">Caps Lock key changes group.</description>
+          <description xml:lang="nl">CapsLock-toets verandert groep.</description>
+          <description xml:lang="ru">Клавиша CapsLock меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím CapsLock thay đổi nhóm.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:shift_caps_toggle</name>
+          <description>Shift+CapsLock changes group.</description>
+          <description xml:lang="en_GB">Shift+Caps Lock changes group.</description>
+          <description xml:lang="nl">Shift+CapsLock verandert groep.</description>
+          <description xml:lang="ru">Клавиши Shift и Caps Lock, нажатые вместе, меняют группу.</description>
+          <description xml:lang="rw">Amahinduka Itsinda</description>
+          <description xml:lang="vi">Shift+CapsLock thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:shifts_toggle</name>
+          <description>Both Shift keys together change group.</description>
+          <description xml:lang="en_GB">Both Shift keys together change group.</description>
+          <description xml:lang="nl">Beide Shift-toetsen samen veranderen groep.</description>
+          <description xml:lang="ru">Две клавиши Shift вместе меняют группу.</description>
+          <description xml:lang="rw">Utubuto Guhindura&gt;&gt; Itsinda</description>
+          <description xml:lang="vi">Nhấn đồng thời hai phím Shift thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:alts_toggle</name>
+          <description>Both Alt keys together change group.</description>
+          <description xml:lang="en_GB">Both Alt keys together change group.</description>
+          <description xml:lang="nl">Beide Alt-toetsen samen veranderen groep.</description>
+          <description xml:lang="ru">Две клавиши Alt вместе меняют группу.</description>
+          <description xml:lang="rw">Utubuto Guhindura&gt;&gt; Itsinda</description>
+          <description xml:lang="vi">Nhấn đồng thời hai phím Alt thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:ctrls_toggle</name>
+          <description>Both Ctrl keys together change group.</description>
+          <description xml:lang="en_GB">Both Ctrl keys together change group.</description>
+          <description xml:lang="nl">Beide Ctrl-toetsen samen veranderen groep.</description>
+          <description xml:lang="ru">Две клавиши Ctrl вместе меняют группу.</description>
+          <description xml:lang="rw">Utubuto Guhindura&gt;&gt; Itsinda</description>
+          <description xml:lang="vi">Nhấn đồng thời hai phím Ctrl thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:ctrl_shift_toggle</name>
+          <description>Control+Shift changes group.</description>
+          <description xml:lang="el">Το Control+Shift αλλάζει ομάδα.</description>
+          <description xml:lang="en_GB">Control+Shift changes group.</description>
+          <description xml:lang="nl">Control+Shift verandert groep.</description>
+          <description xml:lang="ru">Control+Shift меняют группу.</description>
+          <description xml:lang="rw">Amahinduka Itsinda</description>
+          <description xml:lang="vi">Control+Shift thay đổi ngôn ngữ nhập vào.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:ctrl_alt_toggle</name>
+          <description>Alt+Control changes group.</description>
+          <description xml:lang="el">Το Alt+Control αλλάζει ομάδα.</description>
+          <description xml:lang="en_GB">Alt+Control changes group.</description>
+          <description xml:lang="nl">Alt+Control verandert groep.</description>
+          <description xml:lang="ru">Alt+Control меняют группу.</description>
+          <description xml:lang="rw">Amahinduka Itsinda</description>
+          <description xml:lang="vi">Alt+Control thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:alt_shift_toggle</name>
+          <description>Alt+Shift changes group.</description>
+          <description xml:lang="el">Το Alt+Shift αλλάζει ομάδα.</description>
+          <description xml:lang="en_GB">Alt+Shift changes group.</description>
+          <description xml:lang="nl">Alt+Shift verandert groep.</description>
+          <description xml:lang="ru">Alt+Shift меняют группу.</description>
+          <description xml:lang="rw">Amahinduka Itsinda</description>
+          <description xml:lang="vi">Alt+Shift thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:menu_toggle</name>
+          <description>Menu key changes group.</description>
+          <description xml:lang="en_GB">Menu key changes group.</description>
+          <description xml:lang="nl">Menu-toets verandert groep.</description>
+          <description xml:lang="ru">Клавиша Menu меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Menu thay đổi ngôn ngữ nhập vào.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:lwin_toggle</name>
+          <description>Left Win-key changes group.</description>
+          <description xml:lang="en_GB">Left Win-key changes group.</description>
+          <description xml:lang="nl">Linker Win-toets verandert groep.</description>
+          <description xml:lang="ru">Левая клавиша Win меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Win bên trái thay đổi ngôn ngữ nhập vào.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:rwin_toggle</name>
+          <description>Right Win-key changes group.</description>
+          <description xml:lang="en_GB">Right Win-key changes group.</description>
+          <description xml:lang="nl">Rechter Win-toets verandert groep.</description>
+          <description xml:lang="ru">Правая клавиша Win меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Win bên phải thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:lshift_toggle</name>
+          <description>Left Shift key changes group.</description>
+          <description xml:lang="en_GB">Left Shift key changes group.</description>
+          <description xml:lang="nl">Linker Shift-toets verandert groep.</description>
+          <description xml:lang="ru">Левая клавиша Shift меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Shift bên trái thay đổi ngôn ngữ nhập vào.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:rshift_toggle</name>
+          <description>Right Shift key changes group.</description>
+          <description xml:lang="en_GB">Right Shift key changes group.</description>
+          <description xml:lang="nl">Rechter Shift-toets verandert groep.</description>
+          <description xml:lang="ru">Правая клавиша Shift меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Shift bên phải thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:lctrl_toggle</name>
+          <description>Left Ctrl key changes group.</description>
+          <description xml:lang="en_GB">Left Ctrl key changes group.</description>
+          <description xml:lang="nl">Linker Ctrl-toets verandert groep.</description>
+          <description xml:lang="ru">Левая клавиша Ctrl меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Ctrl bên trái thay đổi ngôn ngữ nhập vào.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp:rctrl_toggle</name>
+          <description>Right Ctrl key changes group.</description>
+          <description xml:lang="en_GB">Right Ctrl key changes group.</description>
+          <description xml:lang="nl">Rechter Ctrl-toets verandert groep.</description>
+          <description xml:lang="ru">Правая клавиша Ctrl меняет группу.</description>
+          <description xml:lang="rw">Urufunguzo Amahinduka Itsinda</description>
+          <description xml:lang="vi">Phím Ctrl bên phải thay đổi ngôn ngữ nhập.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="true">
+      <!-- The key combination used to choose the 3rd (and 4th, together with Shift)
+	   level of symbols -->
+      <configItem>
+        <name>lv3</name>
+        <description>Third level choosers</description>
+        <description xml:lang="af">Derdevlak kiesers</description>
+        <description xml:lang="az">Üçüncü səviyyə seçicilər</description>
+        <description xml:lang="bg">Избор на третата група</description>
+        <description xml:lang="cs">Výběr třetí úrovně</description>
+        <description xml:lang="da">Tredje niveaus vælgere</description>
+        <description xml:lang="en_GB">Third level choosers</description>
+        <description xml:lang="fr">sélecteur du 3e niveau</description>
+        <description xml:lang="hu">Harmadik szintű választók</description>
+        <description xml:lang="nl">Derde niveau kiezers</description>
+        <description xml:lang="ru">Выбор 3-го уровня</description>
+        <description xml:lang="rw">urwego</description>
+        <description xml:lang="sk">Výber tretej úrovne</description>
+        <description xml:lang="sq">Zgjedhësit e nivelit të tretë</description>
+        <description xml:lang="sr">Избор трећег нивоа</description>
+        <description xml:lang="sv">Tredjenivåsväljare</description>
+        <description xml:lang="tr">3. seviye seçiciler</description>
+        <description xml:lang="uk">Вибір 3-го рівня</description>
+        <description xml:lang="vi">Trình chọn ngôn ngữ thứ ba</description>
+        <description xml:lang="zh_CN">第三级选择</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>lv3:switch</name>
+          <description>Press Right Control to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press Right Control to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op de rechter Control-toets op het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием правой клавиши Control.</description>
+          <description xml:lang="rw">Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Control bên phải để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>lv3:menu_switch</name>
+          <description>Press Menu key to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press Menu key to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op de Menu-toets om het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием клавиши Menu.</description>
+          <description xml:lang="rw">Urufunguzo Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Menu để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>lv3:win_switch</name>
+          <description>Press any of Win-keys to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press any of Win-keys to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op een Win-toets om het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием любой клавиши Win.</description>
+          <description xml:lang="rw">Bya Utubuto Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Win bất kỳ để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>lv3:lwin_switch</name>
+          <description>Press Left Win-key to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press Left Win-key to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op de linker Win-toets om het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием левой клавиши Win.</description>
+          <description xml:lang="rw">Urufunguzo Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Win bên trái để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>lv3:rwin_switch</name>
+          <description>Press Right Win-key to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press Right Win-key to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op de rechter Win-toets om het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием правой клавиши Win.</description>
+          <description xml:lang="rw">Urufunguzo Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Win bên phải để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>lv3:alt_switch</name>
+          <description>Press any of Alt keys to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press any of Alt keys to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op een Alt-toets om het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием любой клавиши Alt.</description>
+          <description xml:lang="rw">Bya Utubuto Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Alt bất kỳ để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>lv3:lalt_switch</name>
+          <description>Press Left Alt key to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press Left Alt key to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op de linker Alt-toets om het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием левой клавиши Alt.</description>
+          <description xml:lang="rw">Urufunguzo Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Alt bên trái để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>lv3:ralt_switch</name>
+          <description>Press Right Alt key to choose 3rd level.</description>
+          <description xml:lang="en_GB">Press Right Alt key to choose 3rd level.</description>
+          <description xml:lang="nl">Druk op de rechter Win-toets om het 3e niveau te kiezen.</description>
+          <description xml:lang="ru">Выбор 3-го уровня нажатием правой клавиши Alt.</description>
+          <description xml:lang="rw">Urufunguzo Kuri Guhitamo urwego</description>
+          <description xml:lang="vi">Nhấn phím Alt bên phải để chọn ngôn ngữ thứ 3.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="false">
+      <!-- Tweaking the position of the "Ctrl" key -->
+      <configItem>
+        <name>ctrl</name>
+        <description>Control key position</description>
+        <description xml:lang="ru">Положение клавиши Control</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>ctrl:nocaps</name>
+          <description>Make CapsLock an additional Control.</description>
+          <description xml:lang="en_GB">Make Caps Lock an additional Control.</description>
+          <description xml:lang="nl">Van CapsLock een extra Control maken.</description>
+          <description xml:lang="ru">Использовать CapsLock как дополнительную клавишу Control.</description>
+          <description xml:lang="vi">Dùng CapsLock làm một Control bổ sung.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>ctrl:swapcaps</name>
+          <description>Swap Control and CapsLock.</description>
+          <description xml:lang="en_GB">Swap Control and Caps Lock.</description>
+          <description xml:lang="nl">Control en CapsLock verwisselen.</description>
+          <description xml:lang="ru">Поменять местами клавиши Control и CapsLock.</description>
+          <description xml:lang="rw">Na</description>
+          <description xml:lang="vi">Trao đổi Control và CapsLock.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>ctrl:ctrl_ac</name>
+          <description>Control key at left of 'A'</description>
+          <description xml:lang="af">Kontrolesleutel links van 'A'</description>
+          <description xml:lang="az">Control düyməsi 'A' hərfinin solunda</description>
+          <description xml:lang="bg">Control е вляво от 'A'</description>
+          <description xml:lang="cs">Klávesa Control nalevo od 'A'</description>
+          <description xml:lang="da">Ctrl-tast til venstre for 'A'</description>
+          <description xml:lang="el">Πλήκτρο Control στα αριστερά του 'Α'</description>
+          <description xml:lang="en_GB">Control key at left of 'A'</description>
+          <description xml:lang="fr">clé de contrône à la gauche du « A »</description>
+          <description xml:lang="hu">A Ctrl billentyű az 'A' betűtől jobbra van</description>
+          <description xml:lang="nl">Control-toets links van 'A'</description>
+          <description xml:lang="ru">Клавиша Control слева от 'Ф'</description>
+          <description xml:lang="rw">Urufunguzo ku Ibumoso: Bya</description>
+          <description xml:lang="sk">Kláves Control naľavo od 'A'</description>
+          <description xml:lang="sq">Pulsanti Control në të majtë të 'A'</description>
+          <description xml:lang="sr">Тастер Control је у лево од „А“</description>
+          <description xml:lang="sv">Control-tangenten till vänster om "A"</description>
+          <description xml:lang="tr">Control tuşu, 'A' tuşunu solunda</description>
+          <description xml:lang="uk">Клавіша Control зліва від 'Ф'</description>
+          <description xml:lang="vi">Phím Control ở bên trái của 'A'</description>
+          <description xml:lang="zh_CN">Ctrl 键在“A”左侧</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>ctrl:ctrl_aa</name>
+          <description>Control key at bottom left</description>
+          <description xml:lang="af">Kontrolesleutel links onder</description>
+          <description xml:lang="az">Control düyməsi sol altda</description>
+          <description xml:lang="bg">Control е долу вляво</description>
+          <description xml:lang="cs">Klávesa Control vlevo dole</description>
+          <description xml:lang="da">Ctrl-tast nederst til venstre</description>
+          <description xml:lang="el">Πλήκτρο Control κάτω αριστερά</description>
+          <description xml:lang="en_GB">Control key at bottom left</description>
+          <description xml:lang="fr">clé de contrôle au bas à gauche</description>
+          <description xml:lang="hu">A Ctrl billentyű a bal alsó sarokban van</description>
+          <description xml:lang="nl">Control-toets linksonder</description>
+          <description xml:lang="ru">Клавиша Control снизу слева</description>
+          <description xml:lang="rw">Urufunguzo ku Hasi: Ibumoso:</description>
+          <description xml:lang="sk">Kláves Control vľavo dole</description>
+          <description xml:lang="sq">Pulsanti Control sipër majtas</description>
+          <description xml:lang="sr">Тастер Control је у дну лево</description>
+          <description xml:lang="sv">Control-tangenten nere till vänster</description>
+          <description xml:lang="tr">Control tuşu, alt solda</description>
+          <description xml:lang="uk">Клавіша Control знизу зліва</description>
+          <description xml:lang="vi">Phím Control ở phía dưới bên trái</description>
+          <description xml:lang="zh_CN">Ctrl 键在左下角</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>ctrl:ctrl_ra</name>
+          <description>Right Control key works as Right Alt.</description>
+          <description xml:lang="en_GB">Right Control key works as Right Alt.</description>
+          <description xml:lang="nl">Rechter Control-toets werkt als rechter Alt.</description>
+          <description xml:lang="ru">Правая клавиша Control работает как правая клавиша Alt.</description>
+          <description xml:lang="rw">Urufunguzo Nka</description>
+          <description xml:lang="vi">Control bên phải làm việc như Alt bên phải.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="true">
+      <!-- Using startard LEDs to indicate the alternative (not first) group(s) -->
+      <configItem>
+        <name>grp_led</name>
+        <description>Use keyboard LED to show alternative group.</description>
+        <description xml:lang="en_GB">Use keyboard LED to show alternative group.</description>
+        <description xml:lang="nl">Toetsenbord LED gebruiken om alternatieve groep te tonen.</description>
+        <description xml:lang="ru">Использование клавиатурных индикаторов для отображения доп. групп.</description>
+        <description xml:lang="rw">Mwandikisho Kuri Garagaza Itsinda</description>
+        <description xml:lang="vi">Sử dụng đèn bàn phím để chỉ ra ngôn ngữ tương đương.</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>grp_led:num</name>
+          <description>NumLock LED shows alternative group.</description>
+          <description xml:lang="en_GB">Num Lock LED shows alternative group.</description>
+          <description xml:lang="nl">NumLock LED toont alternatieve groep.</description>
+          <description xml:lang="ru">Индикатор NumLock отображает доп. группу.</description>
+          <description xml:lang="rw">Itsinda</description>
+          <description xml:lang="vi">Đèn NumLock cho biết ngôn ngữ tương đương.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp_led:caps</name>
+          <description>CapsLock LED shows alternative group.</description>
+          <description xml:lang="en_GB">Caps Lock LED shows alternative group.</description>
+          <description xml:lang="nl">CapsLock LED toont alternatieve groep.</description>
+          <description xml:lang="ru">Индикатор CapsLock отображает доп. группу.</description>
+          <description xml:lang="rw">Itsinda</description>
+          <description xml:lang="vi">Đèn CapsLock cho biết ngôn ngữ nhập tương đương.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>grp_led:scroll</name>
+          <description>ScrollLock LED shows alternative group.</description>
+          <description xml:lang="en_GB">Scroll Lock LED shows alternative group.</description>
+          <description xml:lang="nl">ScrollLock LED toont alternatieve groep.</description>
+          <description xml:lang="ru">Индикатор ScrollLock отображает доп. группу.</description>
+          <description xml:lang="rw">Itsinda</description>
+          <description xml:lang="vi">Đèn ScrollLock cho biết ngôn ngữ tương đương.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="false">
+      <!-- CapsLock tweaks. 
+	   "Internal" capitalization means capitalization using some internal tables.
+	   Otherwise "as Shift" - means using next group. -->
+      <configItem>
+        <name>caps</name>
+        <description>CapsLock key behavior</description>
+        <description xml:lang="af">CapsLock-sleutelgedrag</description>
+        <description xml:lang="az">CapsLock düyməsinin davranışı</description>
+        <description xml:lang="bg">Поведение на Caps Lock</description>
+        <description xml:lang="cs">Chování klávesy CapsLock</description>
+        <description xml:lang="da">Opførsel for Caps Lock-tast</description>
+        <description xml:lang="el">Συμπεριφορά πλήκτρου Κλείδωμα Κεφαλαίων</description>
+        <description xml:lang="en_GB">Caps Lock key behaviour</description>
+        <description xml:lang="fr">comportement de la clé Capslock</description>
+        <description xml:lang="hu">A Caps Lock használati módja</description>
+        <description xml:lang="nl">CapsLock-toets gedrag</description>
+        <description xml:lang="ru">Клавиша Caps Lock</description>
+        <description xml:lang="rw">Urufunguzo imyitwarire</description>
+        <description xml:lang="sk">Chovanie klávesa Caps Lock</description>
+        <description xml:lang="sq">Sjellja e pulsantit CapsLock</description>
+        <description xml:lang="sr">Понашање Caps Lock тастера</description>
+        <description xml:lang="sv">Beteende för Caps Lock-tangenten</description>
+        <description xml:lang="tr">CapsLock tuşunun davranışı</description>
+        <description xml:lang="uk">Клавіша Caps Lock</description>
+        <description xml:lang="vi">Đặc điểm của phím CapsLock</description>
+        <description xml:lang="zh_CN">CapsLock 键行为</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>caps:internal</name>
+          <description>CapsLock uses internal capitalization. Shift cancels CapsLock.</description>
+          <description xml:lang="en_GB">Caps Lock uses internal capitalisation. Shift cancels Caps Lock.</description>
+          <description xml:lang="nl">CapsLock gebruikt interne conversie naar hoofdletters. Shift heft CapsLock op.</description>
+          <description xml:lang="ru">Включает внутреннюю капитализацию. Shift отменяет CapsLock.</description>
+          <description xml:lang="rw">By'imbere</description>
+          <description xml:lang="vi">CapsLock sử dụng viết hoa nội bộ. Shift dừng CapsLock.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>caps:internal_nocancel</name>
+          <description>CapsLock uses internal capitalization. Shift doesn't cancel CapsLock.</description>
+          <description xml:lang="en_GB">Caps Lock uses internal capitalisation. Shift doesn't cancel Caps Lock.</description>
+          <description xml:lang="nl">CapsLock gebruikt interne conversie naar hoofdletters. Shift heft CapsLock niet op.</description>
+          <description xml:lang="ru">Включает внутреннюю капитализацию. Shift не отменяет CapsLock.</description>
+          <description xml:lang="rw">By'imbere Kureka</description>
+          <description xml:lang="vi">CapsLock sử dụng viết hoa nội bộ. Shift không dừng CapsLock.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>caps:shift</name>
+          <description>CapsLock acts as Shift with locking. Shift cancels CapsLock.</description>
+          <description xml:lang="en_GB">Caps Lock acts as Shift with locking. Shift cancels Caps Lock.</description>
+          <description xml:lang="nl">CapsLock werkt als Shift met blokkering, Shift heft CapsLock op.</description>
+          <description xml:lang="ru">Действует как Shift с блокировкой. Shift отменяет CapsLock.</description>
+          <description xml:lang="rw">Nka Na:</description>
+          <description xml:lang="vi">CapsLock hoạt động như Shift với việc khóa. Shift dừng CapsLock.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>caps:shift_nocancel</name>
+          <description>CapsLock acts as Shift with locking. Shift doesn't cancel CapsLock.</description>
+          <description xml:lang="en_GB">Caps Lock acts as Shift with locking. Shift doesn't cancel Caps Lock.</description>
+          <description xml:lang="nl">CapsLock werkt als Shift met blokkering. Shift heft CapsLock niet op.</description>
+          <description xml:lang="ru">Действует как Shift с блокировкой. Shift не отменяет CapsLock.</description>
+          <description xml:lang="rw">Nka Na: Kureka</description>
+          <description xml:lang="vi">CapsLock hoạt động như Shift với việc khóa. Shift không dừng CapsLock.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>caps:shift_lock</name>
+          <description>CapsLock just locks the Shift modifier.</description>
+          <description xml:lang="en_GB">Caps Lock just locks the Shift modifier.</description>
+          <description xml:lang="nl">CapsLock blokkeert slechts de Shift-toets.</description>
+          <description xml:lang="ru">Просто блокирует модификатор Shift.</description>
+          <description xml:lang="rw">i</description>
+          <description xml:lang="vi">CapsLock khóa tính năng của Shift.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>caps:capslock</name>
+          <description>CapsLock toggles normal capitalization of alphabetic characters.</description>
+          <description xml:lang="en_GB">Caps Lock toggles normal capitalisation of alphabetic characters.</description>
+          <description xml:lang="nl">CapsLock bepaalt hoofdletters/kleine letters bij alfabetische tekens.</description>
+          <description xml:lang="ru">Включает обычную капитализацию символов алфавита.</description>
+          <description xml:lang="rw">Bisanzwe Bya Inyuguti</description>
+          <description xml:lang="vi">CapsLock bật tắt viết hoa thông thường của các ký tự chữ cái.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>caps:shiftlock</name>
+          <description>CapsLock toggles Shift so all keys are affected.</description>
+          <description xml:lang="en_GB">Caps Lock toggles Shift so all keys are affected.</description>
+          <description xml:lang="nl">CapsLock verwisselt Shift zodat het alle toetsen beïnvloedt.</description>
+          <description xml:lang="ru">Включает Shift, относится ко всем клавишам.</description>
+          <description xml:lang="rw">Byose Utubuto</description>
+          <description xml:lang="vi">CapsLock bật tắt Shift vì thế mọi phím đều bị ảnh hưởng.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="false">
+      <!-- Using special PC keys (Win, Menu) to work as standard X keys (Super, Hyper, etc.) -->
+      <configItem>
+        <name>altwin</name>
+        <description>Alt/Win key behavior</description>
+        <description xml:lang="af">Alt/Win-sleutel gedrag</description>
+        <description xml:lang="az">Alt/Win düyməsinin davranışları</description>
+        <description xml:lang="bg">Функцията на Alt/Win</description>
+        <description xml:lang="cs">Chování klávesy Alt/Win</description>
+        <description xml:lang="da">Alt/Win-tasteopførsel</description>
+        <description xml:lang="el">Συμπεριφορά πλήκτρου Alt/Win</description>
+        <description xml:lang="en_GB">Alt/Win key behaviour</description>
+        <description xml:lang="fr">comportement de la clé Alt/Win</description>
+        <description xml:lang="hu">Az Alt/Win billentyűk viselkedése</description>
+        <description xml:lang="nl">Alt/Win-toets gedrag</description>
+        <description xml:lang="ru">Клавиши Alt/Win</description>
+        <description xml:lang="rw">Urufunguzo imyitwarire</description>
+        <description xml:lang="sk">Chovanie klávesu Alt/Win</description>
+        <description xml:lang="sq">Sjellja e pulsantit Alt/Win</description>
+        <description xml:lang="sr">Понашање Alt/Win тастера</description>
+        <description xml:lang="sv">Alt/Win-tangentbeteende</description>
+        <description xml:lang="tr">Alt/Win tuşu davranışı</description>
+        <description xml:lang="uk">Клавіші Alt/Win</description>
+        <description xml:lang="vi">Các làm việc của Alt/Win</description>
+        <description xml:lang="zh_CN">Alt/Win 键行为</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>altwin:menu</name>
+          <description>Add the standard behavior to Menu key.</description>
+          <description xml:lang="af">Voeg by die standaardgedrag by die Kieslyssleutel.</description>
+          <description xml:lang="az">Menyu düyməsinə standart davranış əlavə et.</description>
+          <description xml:lang="bg">Добавя стандартното поведение на клавиша Menu.</description>
+          <description xml:lang="cs">Přidá standardní chování ke klávese Menu.</description>
+          <description xml:lang="da">Tilføj standardopførslen til menutasten.</description>
+          <description xml:lang="en_GB">Add the standard behaviour to Menu key.</description>
+          <description xml:lang="fr">Ajouter le comportement standard au menu de clés</description>
+          <description xml:lang="hu">A standard funkcionalitás hozzáadása a Menü gombhoz.</description>
+          <description xml:lang="nl">Het standaard gedrag toevoegen aan Menu-toets.</description>
+          <description xml:lang="ru">Добавить стандартную функцию клавиши Menu</description>
+          <description xml:lang="rw">i Bisanzwe imyitwarire Kuri Urufunguzo</description>
+          <description xml:lang="sk">Pridať štandardné chovanie klávesu Ponuka.</description>
+          <description xml:lang="sq">Shto sjelljen standarte tek Menu key.</description>
+          <description xml:lang="sr">Додај обично понашање Menu тастеру.</description>
+          <description xml:lang="sv">Lägg till standardbeteendet till Meny-tangenten.</description>
+          <description xml:lang="tr">Menü tuşuna standart işlevini ekler.</description>
+          <description xml:lang="uk">Надає клавіші Menu типову функцію.</description>
+          <description xml:lang="vi">Thêm tính năng cơ bản vào phím Menu.</description>
+          <description xml:lang="zh_CN">将标准行为添加到菜单键。</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>altwin:meta_alt</name>
+          <description>Alt and Meta are on the Alt keys (default).</description>
+          <description xml:lang="en_GB">Alt and Meta are on the Alt keys (default).</description>
+          <description xml:lang="nl">Alt en Meta zijn op de Als-toetsen (standaard).</description>
+          <description xml:lang="ru">Alt и Meta на клавишах Alt (по умолчанию).</description>
+          <description xml:lang="rw">Na ku i Utubuto Mburabuzi</description>
+          <description xml:lang="vi">Alt và Meta trên phím các Alt (mặc định).</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>altwin:meta_win</name>
+          <description>Meta is mapped to the Win-keys.</description>
+          <description xml:lang="af">Meta is verbind aan die Win-sleutels.</description>
+          <description xml:lang="az">Meta Win düymələrinə xəritələnib.</description>
+          <description xml:lang="bg">Win клавишите фунцкионират като Meta</description>
+          <description xml:lang="cs">Meta je mapována na klávesy Win.</description>
+          <description xml:lang="da">Meta ligger på Win-tasterne.</description>
+          <description xml:lang="en_GB">Meta is mapped to the Win-keys.</description>
+          <description xml:lang="fr">Méta est mappé sur les Win-Keys</description>
+          <description xml:lang="hu">A Meta a Win billentyűkhöz van rendelve.</description>
+          <description xml:lang="nl">Meta wordt afgebeeld op de Win-toetsen.</description>
+          <description xml:lang="ru">Мета соответствует клавишам Win</description>
+          <description xml:lang="rw">ni Kuri i Utubuto</description>
+          <description xml:lang="sk">Meta je mapovaný na Win-klávesy.</description>
+          <description xml:lang="sq">Meta është vendosur tek pulsantët Win. </description>
+          <description xml:lang="sr">Meta је мапиран на Windows тастере.</description>
+          <description xml:lang="sv">Meta är mappat till Win-tangenterna.</description>
+          <description xml:lang="tr">Meta, Win tuşları ile eşleştirilir.</description>
+          <description xml:lang="uk">Клавіша Meta відповідає клавішам Win</description>
+          <description xml:lang="vi">Meta được gắn với các phím Win.</description>
+          <description xml:lang="zh_CN">Meta 被映射到 Windows 键。</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>altwin:left_meta_win</name>
+          <description>Meta is mapped to the left Win-key.</description>
+          <description xml:lang="af">Meta is verbind aan die linkerkantste Win-sleutel.</description>
+          <description xml:lang="az">Meta sol Win düyməsinə xəritələnib.</description>
+          <description xml:lang="bg">Левият Win клавиш функционира като Meta</description>
+          <description xml:lang="cs">Meta je mapována na levou klávesu Win.</description>
+          <description xml:lang="da">Meta ligger på venstre Win-tast.</description>
+          <description xml:lang="en_GB">Meta is mapped to the left Win-key.</description>
+          <description xml:lang="fr">Méta est mappé à la clé gauche Win-key</description>
+          <description xml:lang="hu">A Meta a bal Win billentyűhöz van rendelve.</description>
+          <description xml:lang="nl">Meta wordt afgebeeld op de linker Win-toets.</description>
+          <description xml:lang="ru">Meta соответствует левой клавише Win</description>
+          <description xml:lang="rw">ni Kuri i Ibumoso: Urufunguzo</description>
+          <description xml:lang="sk">Meta je mapovaný na ľavý Win-kláves.</description>
+          <description xml:lang="sq">Meta është vendosur tek pulsanti i majtë Win.</description>
+          <description xml:lang="sr">Meta је мапиран на леви Windows тастер.</description>
+          <description xml:lang="sv">Meta är mappat till vänster Win-tangent.</description>
+          <description xml:lang="tr">Meta, soldaki Win tuşu ile eşleştirilir.</description>
+          <description xml:lang="uk">Клавіша Meta відповідає лівій клавіші Win</description>
+          <description xml:lang="vi">Meta được gắn với phím Win bên trái.</description>
+          <description xml:lang="zh_CN">Meta 被映射到左 Windows 键。</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>altwin:super_win</name>
+          <description>Super is mapped to the Win-keys (default).</description>
+          <description xml:lang="af">Super is verbind aan die Win-sleutels (verstek).</description>
+          <description xml:lang="az">Super Win düymələrinə xəritələnib (ön qurğulu).</description>
+          <description xml:lang="bg">Win клавишите функционират като Super</description>
+          <description xml:lang="cs">Super je mapováno na klávesy Win (výchozí).</description>
+          <description xml:lang="da">Super ligger på Win-tasterne (standard).</description>
+          <description xml:lang="en_GB">Super is mapped to the Win-keys (default).</description>
+          <description xml:lang="fr">Super est mappé au clés Win-keys (par défaut).</description>
+          <description xml:lang="hu">A Super billentyű a Win billentyűkhöz van rendelve (ez az alapértelmezés).</description>
+          <description xml:lang="nl">Super wordt afgebeeld op de Win-toetsen (standaard).</description>
+          <description xml:lang="ru">Super соответствует клавишам Win (по умолчанию)</description>
+          <description xml:lang="rw">ni Kuri i Utubuto Mburabuzi</description>
+          <description xml:lang="sk">Super je mapovaný na Win-klávesy (štandardné).</description>
+          <description xml:lang="sq">Super është vendosur tek pulsantët Win (e prezgjedhur).</description>
+          <description xml:lang="sr">Super је мапиран на Windows тастере (подразумевано).</description>
+          <description xml:lang="sv">Super är mappat till Win-tangenterna (standard).</description>
+          <description xml:lang="tr">Super, Win tuşlarına eşlenir (öntanımlı).</description>
+          <description xml:lang="uk">Super відповідає клавішам Win (типово).</description>
+          <description xml:lang="vi">Super được ánh xạ tới các phím Win (mặc định).</description>
+          <description xml:lang="zh_CN">Super 被映射到 Windows 键(默认)。</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>altwin:hyper_win</name>
+          <description>Hyper is mapped to the Win-keys.</description>
+          <description xml:lang="af">Hiper is verbind aan die Win-sleutels.</description>
+          <description xml:lang="az">Hyper Win düymələrinə xəritələnib.</description>
+          <description xml:lang="bg">Hyper съответства на клавишите Win</description>
+          <description xml:lang="cs">Hyper je mapována na klávesy Win.</description>
+          <description xml:lang="da">Hyper ligger på Win-tasterne.</description>
+          <description xml:lang="en_GB">Hyper is mapped to the Win-keys.</description>
+          <description xml:lang="fr">Hyper est mappé aux clés Win-keys.</description>
+          <description xml:lang="hu">A Hyper a Win billentyűkhöz van rendelve.</description>
+          <description xml:lang="nl">Hyper wordt afgebeeld naar de Win-toetsen.</description>
+          <description xml:lang="ru">Hyper соответствует клавишам Win</description>
+          <description xml:lang="rw">ni Kuri i Utubuto</description>
+          <description xml:lang="sk">Hyper je mapovaný na Win-klávesy.</description>
+          <description xml:lang="sq">Hyper është vendosur tek pulsantët Win.</description>
+          <description xml:lang="sr">Hyper је мапиран на Win тастере.</description>
+          <description xml:lang="sv">Hyper är mappat till Win-tangenterna.</description>
+          <description xml:lang="tr">Hyper, Win tuşlarına eşlenir.</description>
+          <description xml:lang="uk">Hyper відповідає клавішам Win</description>
+          <description xml:lang="vi">Hyper được gắn tới các phím Win.</description>
+          <description xml:lang="zh_CN">Hyper 被映射到 Windows 键。</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>altwin:alt_super_win</name>
+          <description>Alt is mapped to the right Win-key and Super to Menu.</description>
+          <description xml:lang="en_GB">Alt is mapped to the right Win-key and Super to Menu.</description>
+          <description xml:lang="nl">Alt wordt afgebeeld op de rechter Win-toets en Super op Menu.</description>
+          <description xml:lang="ru">Alt соответствует правой клавише Win, а Super - Menu.</description>
+          <description xml:lang="rw">ni Kuri i Iburyo: Urufunguzo Na Kuri</description>
+          <description xml:lang="vi">Ánh xạ Alt sang phím Win bên phải và Super sang Menu.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="true">
+      <!-- Tweaking the position of the "Compose" key: mapping to existing PC keys -->
+      <configItem>
+        <name>Compose key</name>
+        <description>Compose key position</description>
+        <description xml:lang="ru">Положение клавиши Control</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>compose:ralt</name>
+          <description>Right Alt is Compose.</description>
+          <description xml:lang="en_GB">Right Alt is Compose.</description>
+          <description xml:lang="nl">Rechter Alt is samenstellingstoets.</description>
+          <description xml:lang="ru">Правая клавиша Alt соответствует клавише Alt.</description>
+          <description xml:lang="rw">ni</description>
+          <description xml:lang="vi">Alt bên phải là Soạn thảo.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>compose:rwin</name>
+          <description>Right Win-key is Compose.</description>
+          <description xml:lang="en_GB">Right Win-key is Compose.</description>
+          <description xml:lang="nl">Rechter Win-toets is samenstellingstoets.</description>
+          <description xml:lang="ru">Правая клавиша Win соответствует клавише Compose.</description>
+          <description xml:lang="rw">Urufunguzo ni</description>
+          <description xml:lang="vi">Phím Win bên phải là Soạn thảo.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>compose:menu</name>
+          <description>Menu is Compose.</description>
+          <description xml:lang="en_GB">Menu is Compose.</description>
+          <description xml:lang="nl">Menu is samenstellingstoets.</description>
+          <description xml:lang="ru">Клавиша Menu соответствует клавише Compose.</description>
+          <description xml:lang="rw">ni</description>
+          <description xml:lang="vi">Menu là Soạn thảo.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>compose:rctrl</name>
+          <description>Right Ctrl is Compose.</description>
+          <description xml:lang="en_GB">Right Ctrl is Compose.</description>
+          <description xml:lang="nl">Rechter Ctrl is samenstellingstoets.</description>
+          <description xml:lang="ru">Правая клавиша Ctrl соответствует клавише Compose.</description>
+          <description xml:lang="rw">ni</description>
+          <description xml:lang="vi">Ctrl bên phải là Soạn thảo.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="true">
+      <configItem>
+        <name>compat</name>
+        <description>Miscellaneous compatibility options</description>
+        <description xml:lang="af">Verskeie versoenbaarheid-opsies</description>
+        <description xml:lang="az">Müxtəlif yetişmə qabiliyyəti seçimləri</description>
+        <description xml:lang="cs">Dodatečné volby pro kompatibilitu</description>
+        <description xml:lang="da">Diverse kompatibilitetsvalg</description>
+        <description xml:lang="en_GB">Miscellaneous compatibility options</description>
+        <description xml:lang="fr">diverses options de compatibilité</description>
+        <description xml:lang="hu">Egyéb kompatibilitási beállítások</description>
+        <description xml:lang="nl">Overige compatibiliteitsopties</description>
+        <description xml:lang="ru">Разные параметры совместимости</description>
+        <description xml:lang="rw">Bihuye neza Amahitamo</description>
+        <description xml:lang="sk">Dodatočné voľby pre kompatibilitu</description>
+        <description xml:lang="sq">Opcione të ndryshme kompatibiliteti</description>
+        <description xml:lang="sr">Разне могућности за сагласност</description>
+        <description xml:lang="sv">Diverse kompatibilitetsalternativ</description>
+        <description xml:lang="tr">Çeşitli uyumluluk seçenekleri</description>
+        <description xml:lang="uk">Різна параметри сумісності</description>
+        <description xml:lang="vi">Tùy chọn tương thích khác</description>
+        <description xml:lang="zh_CN">其它兼容选项</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>numpad:microsoft</name>
+          <description>Shift with numpad keys works as in MS Windows.</description>
+          <description xml:lang="en_GB">Shift with numpad keys works as in MS Windows.</description>
+          <description xml:lang="nl">Shift met cijferblok-toetsen werkt zoals in MS Windows.</description>
+          <description xml:lang="rw">Na: Utubuto Nka in</description>
+          <description xml:lang="vi">Shift với các phím của bàn phím số làm việc như trong MS Windows.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>srvrkeys:none</name>
+          <description>Special keys (Ctrl+Alt+&lt;key&gt;) handled in a server.</description>
+          <description xml:lang="af">Spesiale sleutels (Ctrl+Alt+&lt;sleutel&gt;) word hanteer in 'n bediener.</description>
+          <description xml:lang="az">Xüsusi düymələr (Ctrl+Alt+&lt;düyməsi&gt;) verici tərəfindən idarə edilsin.</description>
+          <description xml:lang="cs">Speciální klávesy (Ctrl+Alt+&lt;key&gt;) zpracovány v serveru.</description>
+          <description xml:lang="da">Specialtaster (Ctrl+Alt+&lt;key&gt;) håndteret i en server.</description>
+          <description xml:lang="en_GB">Special keys (Ctrl+Alt+&lt;key&gt;) handled in a server.</description>
+          <description xml:lang="fr">les spéciales (Ctrl+Alt+&lt;clé&gt;) sont traitées par le serveur.</description>
+          <description xml:lang="hu">Speciális billentyűk (Ctrl+Alt+&lt;key&gt;), amelyeket a kiszolgáló kezel.</description>
+          <description xml:lang="nl">Speciale toetsen (Ctrl+Alt+&lt;toets&gt;) afgehandeld in een server.</description>
+          <description xml:lang="ru">Специальные клавиши (Ctrl+Alt+&lt;клв&gt;)·обрабатываются сервером.</description>
+          <description xml:lang="rw">Utubuto in a Seriveri</description>
+          <description xml:lang="sk">Špeciálne klávesy (Ctrl+Alt+&lt;key&gt;) spracované na serveru.</description>
+          <description xml:lang="sq">Çelsa specialë (Ctrl+Alt+&lt;çelsi&gt;) të manazhuar në një server.</description>
+          <description xml:lang="sr">Нарочити тастери (Ctrl+Alt+&lt;тастер&gt;) које обрађује сервер.</description>
+          <description xml:lang="sv">Specialtangenter (Ctrl+Alt+&lt;tangent&gt;) hanteras i en server.</description>
+          <description xml:lang="tr">Bir sunucuda elde edilen özel tuşlar (Ctrl+Alt+&lt;tuş&gt;)</description>
+          <description xml:lang="uk">Спеціальні клавіші (Ctrl+Alt+&lt;key&gt;) обробляються на сервері.</description>
+          <description xml:lang="vi">Điều khiển các phím đặt biệt (Ctrl+Alt+&lt;key&gt;) trên một máy chủ.</description>
+          <description xml:lang="zh_CN">服务器处理的特殊键 (Ctrl+Alt+&lt;key&gt;)。</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="true">
+      <!-- Special shortcuts for the Euro character -->
+      <configItem>
+        <name>eurosign</name>
+        <description>Adding the EuroSign to certain keys</description>
+        <description xml:lang="en_GB">Adding the Euro sign to certain keys</description>
+        <description xml:lang="nl">Euro-teken aan bepaalde toetsen toevoegen</description>
+        <description xml:lang="ru">Добавить знак Евро к некоторым клавишам</description>
+        <description xml:lang="rw">i Kuri Utubuto</description>
+        <description xml:lang="vi">Thêm ký hiệu đồng Euro vào các phím chắc chắn</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>eurosign:e</name>
+          <description>Add the EuroSign to the E key.</description>
+          <description xml:lang="en_GB">Add the Euro sign to the E key.</description>
+          <description xml:lang="nl">Euro-teken toevoegen aan E-toets.</description>
+          <description xml:lang="ru">Добавить знак Евро к клавише E.</description>
+          <description xml:lang="rw">i Kuri i E Urufunguzo</description>
+          <description xml:lang="vi">Thêm ký hiệu đồng Euro vào phím E.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>eurosign:5</name>
+          <description>Add the EuroSign to the 5 key.</description>
+          <description xml:lang="en_GB">Add the Euro sign to the 5 key.</description>
+          <description xml:lang="nl">Euro-teken toevoegen aan 5-toets.</description>
+          <description xml:lang="ru">Добавить знак Евро к клавише 5.</description>
+          <description xml:lang="rw">i Kuri i 5 Urufunguzo</description>
+          <description xml:lang="vi">Thêm ký hiệu đồng Euro vào phím 5.</description>
+        </configItem>
+      </option>
+      <option>
+        <configItem>
+          <name>eurosign:2</name>
+          <description>Add the EuroSign to the 2 key.</description>
+          <description xml:lang="en_GB">Add the Euro sign to the 2 key.</description>
+          <description xml:lang="nl">Euro-teken toevoegen aan 2-toets.</description>
+          <description xml:lang="ru">Добавить знак Евро к клавише 2.</description>
+          <description xml:lang="rw">i Kuri i 2. Urufunguzo</description>
+          <description xml:lang="vi">Thêm ký hiệu đồng Euro vào phím 2.</description>
+        </configItem>
+      </option>
+    </group>
+    <group allowMultipleSelection="true">
+      <configItem>
+        <name>japan</name>
+        <description>Japanese Keyboard Options</description>
+      </configItem>
+      <option>
+        <configItem>
+          <name>japan:kana_lock</name>
+          <description>Kana Lock key is locking</description>
+	</configItem>
+      </option>
+    </group>
+  </optionList>
+</xkbConfigRegistry>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/de	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,192 @@
+// $Xorg: de,v 1.3 2000/08/17 19:54:42 cpqbld Exp $
+
+
+
+
+// $XFree86: xc/programs/xkbcomp/symbols/de,v 3.14 2003/09/08 13:12:37 pascal Exp $
+
+default partial alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple German keyboard
+
+    // Alphanumeric section
+    name[Group1]= "German";
+    key <TLDE> {	[ dead_circumflex,	degree	],
+			[   notsign 			]	};
+    key <AE02> {	[	  2,	quotedbl	],
+			[ twosuperior			]	};
+    key <AE03> {	[	  3,	section	],
+			[ threesuperior,sterling	]	};
+    key <AE04> {	[	  4,	dollar		],
+			[ onequarter,	currency	]	};
+    key <AE05> {	[	  5,	percent		],
+			[   onehalf			]	};
+    key <AE06> {	[	  6,	ampersand	],
+			[ threequarters			]	};
+    key <AE07> {	[	  7,	slash		],
+			[ braceleft			]	};
+    key <AE08> {	[	  8,	parenleft	],
+			[ bracketleft			]	};
+    key <AE09> {	[	  9,	parenright	],
+			[ bracketright,	plusminus	]	};
+    key <AE10> {	[	  0,	equal		],
+			[ braceright,	degree		]	};
+    key <AE11> {	[    ssharp,	question	],
+			[ backslash,	questiondown	]	};
+    key <AE12> {	[ dead_acute,	dead_grave	],
+			[ dead_cedilla,	dead_ogonek	]	};
+
+    key <AD01> {	[	  q,	Q 		],
+			[	 at			]	};
+    key <AD03> {	[	  e,	E		],
+			[  EuroSign			]	};
+    key <AD05> {	[	  t,	T		]	};
+    key <AD06> {	[	  z,	Z		]	};
+    key <AD07> {	[	  u,	U		]	};
+    key <AD08> {	[	  i,	I		]	};
+    key <AD11> {	[ udiaeresis,	Udiaeresis	],
+			[ dead_diaeresis 		]	};
+    key <AD12> {	[      plus,	asterisk	],
+			[ dead_tilde,	dead_macron	]	};
+    key <AC04> {	[	  f,	F		]	};
+    key <AC05> {	[	  g,	G		]	};
+    key <AC10> {	[ odiaeresis,	Odiaeresis	],
+			[ dead_doubleacute		]	};
+    key <AC11> {	[ adiaeresis,	Adiaeresis	],
+			[ dead_circumflex		]	};
+
+    key <LSGT> {	[      less,	greater		],
+			[       bar			]	};
+    key <AB01> {	[	  y,	Y 		],
+			[ guillemotleft,less		]	};
+    key <AB07> {	[	  m,	M		],
+			[	 mu			]	};
+    key <AB08> {	[     comma,	semicolon	]	};
+    key <AB09> {	[    period,	colon		],
+			[ periodcentered, division	]	};
+    key <AB10> {	[     minus,	underscore	]	};
+    key <BKSL> {	[ numbersign,	apostrophe	],
+			[ dead_grave			]	};
+    key <RALT> {	[ Mode_switch,	Multi_key	]	};
+
+    // End alphanumeric section, begin "Keypad"
+    key <KPDL> {	[  KP_Delete,	KP_Separator	]	};
+    // End "Keypad" section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3	{ Mode_switch };
+};
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    // modify the default German layout to not have any dead keys
+    include "de(basic)"
+    key <TLDE> {	[ asciicircum,	degree		],
+			[   notsign 			]	};
+    key <AE12> {	[ apostrophe,	grave		],
+			[ cedilla			]	};
+    key <AD11> {	[ udiaeresis,	Udiaeresis	],
+			[ diaeresis 			]	};
+    key <AD12> {	[      plus,	asterisk	],
+			[ asciitilde,	macron		]	};
+    key <AC10> {	[ odiaeresis,	Odiaeresis	],
+			[ doubleacute			]	};
+    key <AC11> {	[ adiaeresis,	Adiaeresis	],
+			[ asciicircum			]	};
+
+    key <BKSL> {	[ numbersign,	apostrophe	],
+			[ grave				]	};
+};
+
+partial alphanumeric_keys 
+xkb_symbols "deadgraveacute" {
+    // modify the default German layout to have only acute and grave
+    // as dead keys (tilde and circumflex are needed as spacing characters
+    // in many programming languages)
+    include "de(basic)"
+    key <TLDE> {	[ asciicircum,	degree		],
+			[ notsign			]	};
+    key <AD12> {	[ plus,		asterisk	],
+			[ asciitilde,   dead_macron	]	};
+    key <BKSL> {	[ numbersign,   apostrophe	],
+			[ grave				]	};
+};
+
+partial alphanumeric_keys
+xkb_symbols "deadacute" {
+    // modify the default German layout to have only acute as
+    // dead keys (ASCII grave, tilde and circumflex are needed as
+    // spacing characters in many programming languages and text formatters)
+    include "de(deadgraveacute)"
+    key <AE12> {	[ dead_acute,	grave		],
+			[ dead_cedilla,	dead_ogonek	]	};
+    key <BKSL> {	[ numbersign,	apostrophe	],
+			[ dead_grave			]	};
+};
+
+partial alphanumeric_keys
+xkb_symbols "de_ro" {
+    // add romanian-specific characters to the basic German layout.
+    // Romanian symbols are accessible with combination of <AltGr> and
+    // 'a', 's', 't', 'i', '� (&auml)' (+<Shift> for capital letters).
+    // To view romanian specific symbols, add "export LC_CTYPE=ro_RO"
+    // or "export LC_CTYPE=de_DE.utf8" to your .profile.
+
+    include "de(basic)"
+
+    name[Group1]="Romanian for German keyboard";
+
+    key <AD05> {        [         t,    T               ],
+                        [ tcedilla,     Tcedilla        ]       };
+    key <AD08> {        [         i,    I               ],
+                        [ icircumflex,  Icircumflex     ]       };
+    key <AC01> {        [         a,    A               ],
+                        [ acircumflex,  Acircumflex     ]       };
+    key <AC02> {        [         s,    S               ],
+                        [ scedilla,     Scedilla        ]       };
+    key <AC11> {        [ adiaeresis,   Adiaeresis      ],
+                        [ abreve,       Abreve          ]       };
+};
+
+partial alphanumeric_keys
+xkb_symbols "de_ro_nodeadkeys" {
+    // add romanian-specific characters to the "nodeadkeys" German layout.
+    // Read the comment for de_ro !
+
+    include "de(nodeadkeys)"
+
+    key <AD05> {        [         t,    T               ],
+                        [ tcedilla,     Tcedilla        ]       };
+    key <AD08> {        [         i,    I               ],
+                        [ icircumflex,  Icircumflex     ]       };
+    key <AC01> {        [         a,    A               ],
+                        [ acircumflex,  Acircumflex     ]       };
+    key <AC02> {        [         s,    S               ],
+                        [ scedilla,     Scedilla        ]       };
+    key <AC11> {        [ adiaeresis,   Adiaeresis      ],
+                        [ abreve,       Abreve          ]       };
+};
+
+partial alphanumeric_keys
+xkb_symbols "Sundeadkeys" {
+
+    // For naming consistency
+
+    include "de(basic)"
+
+};
+
+partial alphanumeric_keys
+xkb_symbols "sundeadkeys" {
+
+    // For naming consistency
+
+    include "de(Sundeadkeys)"
+
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/nl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,117 @@
+// Converted keytable file to xkb/symbols/ file
+// with mk_xkb by [email protected] Tue Sep 30 00:53:29 MET DST 1997
+
+// converted from the nl-latin.map of the Linux kbd package by
+// Pablo Saratxaga <[email protected]>
+
+default partial alphanumeric_keys
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Nederland keyboard
+
+    // Alphanumeric section
+    name[Group1]= "Nederland";
+
+    key <AE01> {	[         1,	exclam   	],
+			[ onesuperior			]	};
+    key <AE02> {	[         2,	quotedbl 	],
+			[ twosuperior			]	};
+    key <AE03> {	[         3,	numbersign	],
+			[ threesuperior			]	};
+    key <AE04> {	[         4,	dollar   	],
+			[ onequarter			]	};
+    key <AE05> {	[         5,	percent  	],
+			[ EuroSign			]	};
+    key <AE06> {	[         6,	ampersand	],
+			[ threequarters			]	};
+    key <AE07> {	[         7,	underscore	],
+			[  sterling			]	};
+    key <AE08> {	[         8,	parenleft	],
+			[ braceleft			]	};
+    key <AE09> {	[         9,	parenright	],
+			[ braceright			]	};
+    key <AE10> {	[         0,	apostrophe	]	};
+    key <AE11> {	[     slash,	question 	],
+			[ backslash			]	};
+    key <AE12> {	[    degree,	dead_tilde	],
+			[ dead_cedilla			]	};
+    key <AD03> {	[         e,	E        	],
+			[    EuroSign,	cent    	]	};
+    key <AD04> {	[         r,	R        	],
+			[ paragraph,	registered	]	};
+    key <AD05> {	[         t,	T        	],
+			[     thorn,	THORN    	]	};
+    key <AD06> {	[         y,	Y        	],
+			[ ydiaeresis,	yen      	]	};
+    key <AD07> {	[         u,	U        	],
+			[ udiaeresis,	Udiaeresis	]	};
+    key <AD08> {	[         i,	I        	],
+			[ idiaeresis,	Idiaeresis	]	};
+    key <AD09> {	[         o,	O        	],
+			[    ograve,	Ograve   	]	};
+    key <AD10> {	[         p,	P        	],
+			[ paragraph			]	};
+    key <AD11> {	[ dead_diaeresis,	dead_circumflex	],
+			[ asciitilde,	asciicircum	]	};
+    key <AD12> {	[  asterisk,	bar      	]	};
+    key <AC01> {	[         a,	A        	],
+			[    aacute,	Aacute   	]	};
+    key <AC02> {	[         s,	S        	],
+			[    ssharp			]	};
+    key <AC03> {	[         d,	D        	],
+			[       eth,	ETH      	]	};
+    key <AC04> {	[         f,	F        	],
+			[ ordfeminine,	ordfeminine	]	};
+    key <AC10> {	[      plus,	plusminus	]	};
+    key <AC11> {	[ apostrophe,	grave    	],
+			[ dead_acute,	dead_grave	]	};
+    key <TLDE> {	[        at,	section  	],
+			[   notsign			]	};
+    key <BKSL> {	[      less,	greater  	]	};
+    key <AB01> {	[         z,	Z        	],
+			[ guillemotleft			]	};
+    key <AB02> {	[         x,	X        	],
+			[ guillemotright			]	};
+    key <AB03> {	[         c,	C        	],
+			[      cent,	copyright	]	};
+    key <AB06> {	[         n,	N        	],
+			[    ntilde,	Ntilde   	]	};
+    key <AB07> {	[         m,	M        	],
+			[  Greek_mu,	masculine	]	};
+    key <AB08> {	[     comma,	semicolon	],
+			[   cedilla,	guillemotleft	]	};
+    key <AB09> {	[    period,	colon    	],
+			[ periodcentered,	guillemotright	]	};
+    key <AB10> {	[     minus,	equal    	],
+			[    hyphen			]	};
+    key <LSGT> {	[ bracketright,	bracketleft	],
+			[       bar			]	};
+
+    // End alphanumeric section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
+partial alphanumeric_keys
+xkb_symbols "Sundeadkeys" {
+
+    // For naming consistency
+
+    include "nl(basic)"
+
+};
+
+partial alphanumeric_keys
+xkb_symbols "sundeadkeys" {
+
+    // For naming consistency
+
+    include "nl(Sundeadkeys)"
+
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/ca	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,120 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+
+    key <FK01> { [ Escape               ]                       };
+    key <FK02> { [ F1                   ]                       };
+    key <FK03> { [ F2                   ]                       };
+    key <FK04> { [ F3                   ]                       };
+    key <FK05> { [ F4                   ]                       };
+    key <FK06> { [ F5                   ]                       };
+    key <FK07> { [ F6                   ]                       };
+    key <FK08> { [ F7                   ]                       };
+    key <FK09> { [ F8                   ]                       };
+    key <FK10> { [ F9                   ]                       };
+    key <FK11> { [ F10                  ]                       };
+    key <FK12> { [ SunF36               ]                       };
+    key <BKSL> { [ SunF37, NoSymbol	] 			};
+    key <ESC>  { [ degree		], [ notsign	]	};
+    key <AE02> { [ 2, quotedbl		], [ at		]	};
+    key <AE06> { [ 6, question		] 			};
+    key <AE07> { [ 7, ampersand		], [ braceleft	]	};
+    key <AE08> { [ 8, asterisk		], [ bracketleft ]	};
+    key <AE09> { [ 9, parenleft		], [ bracketright ]	};
+    key <AE10> { [ 0, parenright	], [ braceright	]	};
+//    key <AD11> { [ SunFA_Circum, SunFA_Diaresis ], [ asciicircum ] };
+    key <AD12> { [ Ccedilla, NoSymbol	], [ asciitilde	]	};
+    key <LCTL> { [ Caps_Lock		]			};
+    key <AC11> { [ Egrave		]			};
+    key <TLDE> { [ Agrave, NoSymbol	], [ quoteleft 	]	};
+    key <LSGT> { [ Ugrave, NoSymbol	], [ backslash	]	};
+    key <AB08> { [ comma, quoteright	], [ less	]	};
+    key <AB09> { [ period, NoSymbol	], [ greater	]	};
+    key <AB10> { [ Eacute, NoSymbol	], [ slash	]	};
+    key <CAPS> { [ SunAltGraph		]			};
+    key <COMP> { [ SunCompose		]			};
+    key <ALGR> { [ Control_R		]			};
+ 
+};
+
+xkb_symbols "type5" {
+
+    key <TLDE> { [ slash, backslash	], [ bar			]};
+    key <AE01> { [ 1, exclam		], [ plusminus			]};
+    key <AE02> { [ 2, at		]				};
+    key <AE03> { [ 3, numbersign	], [ sterling			]};
+    key <AE04> { [ 4, dollar		], [ cent			]};
+    key <AE05> { [ 5, percent		], [ currency			]};
+    key <AE06> { [ 6, question		]				};
+    key <AE07> { [ 7, ampersand		], [ braceleft ]		};
+    key <AE08> { [ 8, asterisk		], [ braceright ]		};
+    key <AE09> { [ 9, parenleft		], [ bracketleft		]};
+    key <AE10> { [ 0, parenright	], [ bracketright		]};
+    key <AE11> { [ minus, underscore	]				};
+    key <AE12> { [ equal, plus		], [ notsign			]};
+    
+    key <AD10> { [ p, P			], [ paragraph			]};
+    key <AD11> { [ SunFA_Circum, SunFA_Diaeresis], [ SunFA_Grave	]};
+    key <AD12> { [ ccedilla, Ccedilla	], [ asciitilde			]};
+
+    key <AC10> { [ semicolon, colon	], [ degree			]};
+    key <AC11> { [ Egrave		]				};
+    key <BKSL> { [ Agrave		]				};
+
+    key <LSGT> { [ Uacute		]				};
+    key <AB01> { [ z, Z			], [ guillemotleft		]};
+    key <AB02> { [ x, X			], [ guillemotright		]};
+    key <AB07> { [ m, M			], [ mu				]};
+    key <AB08> { [ comma, quoteright	], [ less			]};
+    key <AB09> { [ period, quotedbl	], [ greater			]};
+    key <AB10> { [ eacute, Eacute	], [ quoteleft			]};
+    
+};
+
+xkb_symbols "type5tbits5"
+{
+    include "sun/ca(type5)"
+    
+    key <LSGT> { [ Ugrave		]				};
+    key <SPCE> { [ space, space		], [ nobreakspace		]};
+};
+
+xkb_symbols "x86"
+{
+    include "ca"
+    
+    key <ALGR> { [ Mode_switch		]				};
+    key <RALT> { [ Alt_R		]				};
+    key <RCTL> { [ Control_R		]				};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/cs	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,59 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "type5" {
+    include "sun/us(type5)"
+    include "cz"
+
+    // A few keys are different
+    
+
+    key <TLDE> { [ quoteleft, asciitilde	]			};
+//     key <AE02> { [ ecaron, 2		], [ at 		]	};
+//     key <AE03> { [ scaron, 3		], [ numbersign		]	};
+//     key <AE04> { [ ccaron, 4		], [ dollar		]	};
+//     key <AE05> { [ rcaron, 5		], [ percent		]	};
+//     key <AE06> { [ zcaron, 6		], [ asciicircum	]	};
+//     key <AE07> { [ yacute, 7		], [ ampersand		]	};
+//     key <AE08> { [ aacute, 8		], [ asterisk		]	};
+    key <AE09> { [ iacute, 9		], [ braceleft		]	};
+    key <AE10> { [ eacute, 0		], [ braceright		]	};
+
+    key <AD03> { [ e, E		        ]                               };
+    key <AD11> { [ uacute, slash        ], [ bracketleft		] };
+    key <AD12> { [ parenright, parenleft], [ bracketright		] };
+    
+    key <AC02> { [ s, S			], [ ssharp, ssharp		] };
+    key <BKSL> { [ SunFA_Diaeresis, backslash	]			  };
+
+    key <LSGT> { [ backslash, bar		]			};
+    
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/cz	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,59 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "type5" {
+    include "sun/us(type5)"
+    include "cz"
+
+    // A few keys are different
+    
+
+    key <TLDE> { [ quoteleft, asciitilde	]			};
+//     key <AE02> { [ ecaron, 2		], [ at 		]	};
+//     key <AE03> { [ scaron, 3		], [ numbersign		]	};
+//     key <AE04> { [ ccaron, 4		], [ dollar		]	};
+//     key <AE05> { [ rcaron, 5		], [ percent		]	};
+//     key <AE06> { [ zcaron, 6		], [ asciicircum	]	};
+//     key <AE07> { [ yacute, 7		], [ ampersand		]	};
+//     key <AE08> { [ aacute, 8		], [ asterisk		]	};
+    key <AE09> { [ iacute, 9		], [ braceleft		]	};
+    key <AE10> { [ eacute, 0		], [ braceright		]	};
+
+    key <AD03> { [ e, E		        ]                               };
+    key <AD11> { [ uacute, slash        ], [ bracketleft		] };
+    key <AD12> { [ parenright, parenleft], [ bracketright		] };
+    
+    key <AC02> { [ s, S			], [ ssharp, ssharp		] };
+    key <BKSL> { [ SunFA_Diaeresis, backslash	]			  };
+
+    key <LSGT> { [ backslash, bar		]			};
+    
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/de	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,71 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+
+
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+    key <BKSL> { [ less, braceleft      ]                       };
+
+    key <BRCR> { [ greater, braceright  ]                       };
+    key <DELE> { [ Delete               ]                       };
+
+    key <AE01> { [ 1, plus              ], [exclam      ]       };
+    key <AE02> { [ 2, quotedbl          ], [at          ]       };
+    key <AE03> { [ 3, asterisk          ], [numbersign  ]       };
+    key <AE04> { [ 4, ccedilla          ], [cent        ]       };
+    key <AE05> { [ 5, percent           ], [asciitilde  ]       };
+    key <AE06> { [ 6, ampersand         ], [section     ]       };
+    key <AE07> { [ 7, slash             ], [bar         ]       };
+    key <AE08> { [ 8, parenleft         ], [degree      ]       };
+    key <AE09> { [ 9, parenright        ], [backslash   ]       };
+    key <AE10> { [ 0, equal             ], [asciicircum ]       };
+    Key <AE11> { [ quoteright, question ], [quoteleft   ]       };
+    key <AE12> { [ SunFA_Circum, SunFA_Grave    ]               };
+    key <AD03> { [ e, E                 ], [EuroSign    ]       };
+    key <AD06> { [ Z                    ]                       };
+    key <AD11> { [ udiaeresis, egrave   ]                       };
+    key <AD12> { [ SunFA_Diaeresis, SunFA_Acute ]               };
+    key <AC10> { [ odiaeresis, eacute   ]                       };
+    key <AC11> { [ adiaeresis, agrave   ]                       };
+    key <TLDE> { [ dollar, SunFA_Tilde  ], [sterling    ]       };
+    key <LSGT> { [ bracketright, bracketleft   ], [ backslash ] };
+    key <AB01> { [ Y                    ]                       };
+    key <AB07> { [ M, NoSymbol          ], [mu  ]               };
+    key <AB08> { [ comma, semicolon     ]                       };
+    key <AB09> { [ period, colon        ]                       };
+    key <AB10> { [ minus, underscore    ]                       };
+    key <COMP> { [ SunAltGraph          ]                       };
+    key <ALGR> { [ SunCompose           ]                       };
+
+
+
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/dk	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,77 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+   key <BKSL> { [ onehalf, section	]                       };
+   key <BRCR> { [ asciitilde, asciicircum	 ] 		};
+   key <AE02> { [ 2, quotedbl		], [ at		]	};
+   key <AE03> { [ 3, numbersign		], [ sterling	]	};
+   key <AE04> { [ 4, currency		], [ dollar	]	};
+   key <AE06> { [ 6, ampersand		] 			};
+   key <AE07> { [ 7, slash		], [ braceleft	]	};
+   key <AE08> { [ 8, parenleft		], [ bracketleft]	};
+   key <AE09> { [ 9, parenright		], [ bracketright] 	};
+   key <AE10> { [ 0, equal		], [ braceright	]	};
+   key <AE11> { [ plus, question	]			};
+   key <AE12> { [ SunFA_Acute, SunFA_Grave], [ bar	]	};
+   key <AD03> { [ e, E			], [ EuroSign	]	};
+   key <AD11> { [ Aring			]			};
+   key <AD12> { [ SunFA_Diaeresis, SunFA_Circum], [SunFA_Tilde] };
+   key <LCTL> { [ Caps_Lock		]			};
+   key <AC10> { [ AE			]			};
+   key <AC11> { [ Ooblique		]			};
+   key <TLDE> { [ quoteright, asterisk	], [ quoteleft	]	};
+   key <LSGT> { [ less, greater		], [ backslash  ]	};
+   key <AB08> { [ comma, semicolon	]			};
+   key <AB09> { [ period, colon		]			};
+   key <AB10> { [ minus, underscore	]			};
+   key <CAPS> { [ Control_L		]			};
+   key <COMP> { [ SunAltGraph		]			};
+   key <ALGR> { [ SunCompose		]			};
+
+
+
+
+};
+
+xkb_symbols "type5" {
+   include "dk"
+
+    key <AE05> { [ 5, percent		], [asciitilde			]};
+    key <AE06> { [ 6, ampersand		], [asciicircum			]};
+    key <AE07> { [ 7, slash		], [ braceleft			]};
+    key <AE08> { [ 8, parenleft		], [ bracketleft		]};
+    key <AE09> { [ 9, parenright	], [ bracketright		]};
+    key <AE10> { [ 0, equal		], [ braceright			]};
+    key <BKSL> { [ quoteright, asterisk	], [ quoteleft			]};
+  
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/es	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,91 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+partial
+xkb_symbols "type4" {
+    key <BKSL> { [ bracketleft, braceleft ], [ guillemotleft	] };
+    key <BRCR> { [ bracketright, braceright ], [ guillemotright ] };
+    key <AE02> { [ 2, quotedbl		], [ at			] };
+    key <AE03> { [ 3, periodcentered    ], [ numbersign       ] };
+    key <AE05> { [ 5, percent           ], [ degree           ] };
+    key <AE06> { [ 6, ampersand         ], [ notsign          ] };
+    key <AE07> { [ 7, slash             ]                       };
+    key <AE08> { [ 8, parenleft         ] 			};
+    key <AE09> { [ 9, parenright        ], [ backslash        ] };
+    key <AE10> { [ 0, equal             ], [ bar              ] };
+    key <AE11> { [ quoteright, question ], [ quoteleft        ] };
+    key <AE12> { [ exclamdown, questiondown ] };
+    key <AD03> { [ e, E                 ], [ EuroSign         ] };
+    key <AD09> { [ o, O                 ], [ masculine        ] };
+    key <AD11> { [ SunFA_Grave, SunFA_Circum ], [ asciicircum ] };
+    key <AD12> { [ plus, asterisk       ], [ asciitilde       ] };
+    key <AC01> { [ a, A			], [ ordfeminine      ] };
+    key <AC10> { [ Ntilde		]			};
+    key <AC11> { [ SunFA_Acute, SunFA_Diaeresis ]			};
+    key <TLDE> { [ Ccedilla		]			};
+    key <RALT> { [ Alt_R                ]                       };
+    key <LCTL> { [ Caps_Lock ] };
+    key <CAPS> { [ Control_L ] };
+    key <LSGT> { [ less, greater	]			};
+    key <AB08> { [ comma, semicolon	]			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, underscore	]			};
+};
+
+partial
+xkb_symbols "type5" {
+    include "es"
+
+    key <AE03> { [ 3, periodcentered	], [ numbersign			] };
+    key <AE04> { [ 4, dollar		], [ asciicircum		] };
+    key <AE05> { [ 5, percent		], [ asciitilde			] };
+    key <AE07> { [ 7, slash		], [ braceleft			]};
+    key <AE08> { [ 8, parenleft		], [ bracketleft		]};
+    key <AE09> { [ 9, parenright	], [ bracketright		]};
+    key <AE10> { [ 0, equal		], [ braceright			]};
+    key <AE11> { [ quoteright, question	], [ quoteleft			] };
+
+    key <AD11> { [ SunFA_Grave, SunFA_Circum ], [ bracketleft		] };
+
+    key <AC11> { [ SunFA_Acute, SunFA_Diaeresis ], [ braceleft		] };
+};
+
+partial 
+xkb_symbols "type6" {
+    include "es(Sundeadkeys)"
+
+    key <AE04> { [ 4, dollar		], [ asciicircum		] };
+    key <AE05> { [ 5, percent		], [ asciitilde			] };
+    key <AE07> { [ 7, slash		], [ braceleft			]};
+    key <AE08> { [ 8, parenleft		], [ bracketleft		]};
+    key <AE09> { [ 9, parenright	], [ bracketright		]};
+    key <AE10> { [ 0, equal		], [ braceright			]};
+    key <AE11> { [ quoteright, question	], [ quoteleft			] };
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/fi	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,42 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "basic" {
+    include "fi"
+    // A few keys are different
+    key <AE11> {	[            plus,        question      ],
+			[	backslash			]	};
+    key <AD12> {	[       diaeresis,     asciicircum     	],
+			[      asciitilde			]	};
+    key <BKSL> {	[      apostrophe,        asterisk	],
+			[	quoteleft			]	};
+
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/fr	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,92 @@
+// $XdotOrg: $
+//
+// 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.
+//
+// NOTE:
+// These are the French keyboard symbols
+// French Swiss symbols are in sw
+
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+
+    key <BKSL> { [ bracketleft, braceleft ]			};
+    key <BRCR> { [ bracketright, braceright ]			};
+    key <DELE> { [ Delete               ]                       };
+
+    key <AE01> { [ ampersand, 1		], [			]	};
+    key <AE02> { [ eacute, 2		], [ twosuperior	]	};
+    key <AE03> { [ quotedbl, 3		], [ threesuperior	]	};
+    key <AE04> { [ quoteright, 4	]				};
+    key <AE05> { [ parenleft, 5		]				};
+    key <AE06> { [ section, 6		], [ asciicircum	]	};
+    key <AE07> { [ egrave, 7		]				};
+    key <AE08> { [ exclam, 8		], [ sterling		]	};
+    key <AE09> { [ ccedilla, 9		], [ backslash		]	};
+    key <AE10> { [ agrave, 0		] 				};
+    Key <AE11> { [ parenright, degree	], [ asciitilde		]	};
+    key <AE12> { [ minus, underscore 	], [ numbersign		]  	};
+
+    key <AD01> { [ a, A			]				};
+    key <AD02> { [ z, Z			] 				};
+    key <AD03> { [ e, E			], [EuroSign	]		};
+    key <AD11> { [ SunFA_Circum, SunFA_Diaeresis	]		};
+    key <AD12> { [ quoteleft, dollar	], [ at		]		};
+ 
+    key <AC01> { [ q, Q			]				};
+    key <AC10> { [ m, M			], [ mu		]		};
+    key <AC11> { [ ugrave, percent	]				};
+    key <TLDE> { [ asterisk, bar	], [ currency	]		};
+
+    key <LSGT> { [ less, greater	]				};
+    key <AB01> { [ w, W			]			};
+
+    key <AB07> { [ comma, question	]			};
+    key <AB08> { [ semicolon, period	]			};
+    key <AB09> { [ colon, slash		]			};
+    key <AB10> { [ equal, plus		]			};
+
+    key <CAPS> { [ SunAltGraph		]			};
+    key <ALGR> { [ Caps_Lock		]			}; 
+
+
+
+};
+
+xkb_symbols "type5" {
+    include "fr"
+
+    key <LSGT> { [ less, greater	]				};
+};
+
+xkb_symbols "type6" {
+    include "sun/us(type6)"
+    include "fr"
+
+    key <LSGT> { [ less, greater	]				};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/gb	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,53 @@
+// $XdotOrg: $
+//
+// 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.
+//
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+    key <AE01> { [ 1, exclam		], [brokenbar	]	};
+    key <AE03> { [ 3, sterling		], [numbersign	]	};
+    key <AE04> { [ 4, dollar		], [EuroSign	]	};
+    key <AE11> { [ minus, underscore	], [notsign	]	};
+    key <AD03> { [ e, E			], [EuroSign	]	};
+
+
+};
+
+partial
+xkb_symbols "type5" {
+    include "gb(Sundeadkeys)"
+
+    key <TLDE> { [ quoteleft, notsign	], [ brokenbar	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+};
+
+partial
+xkb_symbols "type6" {
+  include "sun/gb(type5)"
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/gr	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "type5" {
+    include "sun/us(type5basic)"
+    // A few keys are different
+    key <AE04> { [ 4, dollar ], [ EuroSign ] };
+    key <AD03> { [ e, E], [ EuroSign ] };
+    key <AC10> { [ dead_acute, dead_diaeresis ]			};
+    key <LSGT> { [ backslash, bar	]			};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/hu	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,94 @@
+// $XdotOrg: $
+//
+// 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.
+//
+// $TOG: hu /main/2 1997/06/13 06:25:05 kaleb $
+default partial alphanumeric_keys 
+xkb_symbols "type5" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Hungarian keyboard.
+
+    // Alphanumeric section
+
+    name[group1]="Hungarian";
+
+    key <TLDE> {	[	0,		section		]	};
+    key <AE01> {	[	1,      	apostrophe	]	};
+    key <AE02> {	[	2,		quotedbl	]	};
+    key <AE03> {	[	3,		plus		],
+			[	numbersign			]	};
+    key <AE04> {	[	4,		exclam		],
+			[	dollar				]	};
+    key <AE06> {	[	6,		slash		],
+			[	asciicircum			]	};
+    key <AE07> {	[	7,		equal		],
+			[	braceleft			]	};
+    key <AE08> {	[	8,		parenleft	],
+			[	bracketleft			]	};
+    key <AE09> {	[	9,		parenright	],
+			[	bracketright			]	};
+    key <AE10> {	[	odiaeresis,	Odiaeresis	],
+			[	braceright  			]	};
+    key <AE11> {	[	udiaeresis,	Udiaeresis	],
+			[	backslash			]	};
+    key <AE12> {	[	oacute,		Oacute		],
+			[	asciitilde				]	};
+
+    key <AD01> {	[	q,		Q		],
+			[	at				]	};
+    key <AD06> {        [       z,              Z               ]	};
+    key <AD11> {	[	odoubleacute,	Odoubleacute	]	};
+    key <AD12> {	[	uacute,		Uacute		]	};
+
+    key <AC02> {	[	s,		S		],
+			[	ssharp				]	};
+    key <AC08> {	[	k,		K		],
+			[	ampersand			]	};
+    key <AC10> {	[	eacute,		Eacute		],
+			[	semicolon			]	};
+    key <AC11> {	[	aacute,		Aacute		],
+			[	adiaeresis,	Adiaeresis	]	};
+    key <BKSL> {	[	udoubleacute,	Udoubleacute	]	};
+
+    key <LSGT> {	[	iacute,		Iacute		],
+			[       bar				]	};
+    key <AB01> {	[	y,		Y		],
+			[	less				]	};
+    key <AB02> {	[	x,		X		],
+			[	greater			]	};
+    key <AB03> {	[	c,		C		],
+			[	quoteleft			]	};
+    key <AB08> {	[	comma,		question	],
+			[	asterisk			]	};
+    key <AB09> {	[	period,		colon		]	};
+    key <AB10> {	[	minus,		underscore	]	};
+
+    // End alphanumeric section
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/it	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,77 @@
+// $XdotOrg: $
+//
+// 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.
+//
+xkb_symbols "type4" {
+
+    key <BKSL> { [ bracketleft, braceleft ], [ guillemotleft	]	 };
+    key <BRCR> { [ bracketright, braceright ], [ guillemotright ] 	};
+    key <AE02> { [ 2, quotedbl		], [ twosuperior	] 	};
+    key <AE03> { [ 3, sterling		], [ threesuperior	] 	};
+    key <AE06> { [ 6, ampersand		], [ notsign		] 	};
+    key <AE06> { [ 7, slash		]				};
+    key <AE06> { [ 8, parenleft		]				};
+    key <AE09> { [ 9, parenright        ], [ backslash		] 	};
+    key <AE10> { [ 0, equal             ], [ bar		] 	};
+    key <AE11> { [ quoteright, question ], [ quoteleft		] 	};
+    key <AE12> { [ igrave, asciicircum	] };
+
+    key <AD11> { [ egrave, eacute       ]				};
+    key <AD12> { [ plus, asterisk       ], [ asciitilde   	]	};
+
+    key <AC10> { [ ograve, ccedilla 	], [ at			]	};
+    key <AC11> { [ agrave, degree	], [ numbersign		]	};
+    key <TLDE> { [ ugrave, section	]				};
+
+    key <LSGT> { [ less, greater	]				};
+    key <AB08> { [ comma, semicolon	]				};
+    key <AB09> { [ period, colon	]				};
+    key <AB10> { [ minus, underscore	]				};
+    
+
+    key <LALT> { [ Alt_L	       	]              	       		};
+    key <COMP> { [ SunCompose       	]				};
+    key <RALT> { [ SunAltGraph		]				};
+    key <LCTL> { [ Caps_Lock 		] 				};
+    key <CAPS> { [ Control_L 		] 				};
+
+};
+
+xkb_symbols "type5" {
+    include "it"
+
+    key <AE08> { [ 8, parenleft		], [ braceleft			] };
+    key <AE09> { [ 9, parenright	], [ braceright			] };
+
+    key <BKSL> { [ ugrave, section	], [ asciitilde			] };
+};
+
+partial 
+xkb_symbols "type6" {
+    include "sun/it(type5)"
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/jp	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,798 @@
+// $XdotOrg: $
+//
+// 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.
+//
+// $TOG: us /main/5 1998/02/10 13:45:06 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//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.
+//
+// US/ASCII layout for a Type 4 Sun keyboard
+
+xkb_symbols "basic" {
+    // Alphanumeric section
+    key <AE01> { [ 1, exclam 		], [ kana_NU		]	};
+    key <AE02> { [ 2, quotedbl		], [ kana_FU		]	};
+    key <AE03> { [ 3, numbersign	], [ kana_A, kana_a	]	};
+    key <AE04> { [ 4, dollar		], [ kana_U, kana_u	]	};
+    key <AE05> { [ 5, percent		], [ kana_E, kana_e	]	};
+    key <AE06> { [ 6, ampersand		], [ kana_O, kana_o	]	};
+    key <AE07> { [ 7, apostrophe	], [ kana_YA, kana_ya	]	};
+    key <AE08> { [ 8, parenleft		], [ kana_YU, kana_yu	]	};
+    key <AE09> { [ 9, parenright	], [ kana_YO, kana_yo	]	};
+    key <AE10> { [ 0			], [ kana_WA, kana_WO	]	};
+    key <AE11> { [ minus, equal		], [ kana_HO		]	};
+    key <AE12> { [ asciicircum,	asciitilde], [ kana_HE		]	};
+    key <BKSP> { [ BackSpace		]	};
+
+    key  <TAB> { [ Tab,	ISO_Left_Tab	]	};
+    key <AD01> { [ q, Q 		], [ kana_TA		]	};
+    key <AD02> { [ w, W			], [ kana_TE		]	};
+    key <AD03> { [ e, E			], [ kana_I, kana_i	]	};
+    key <AD04> { [ r, R			], [ kana_SU		]	};
+    key <AD05> { [ t, T			], [ kana_KA		]	};
+    key <AD06> { [ y, Y			], [ kana_N		]	};
+    key <AD07> { [ u, U			], [ kana_NA		]	};
+    key <AD08> { [ i, I			], [ kana_NI		]	};
+    key <AD09> { [ o, O			], [ kana_RA		]	};
+    key <AD10> { [ p, P			], [ kana_SE		]	};
+    key <AD11> { [ at, quoteleft	], [ voicedsound	]	};
+    key <AD12> { [ bracketleft,	braceleft ], [ semivoicedsound, kana_openingbracket ] };
+    key <RTRN> { [ Return		]	};
+
+    key <CAPS> { [ Caps_Lock		]	};
+    key <AC01> { [ a, A 		], [ kana_CHI		]	};
+    key <AC02> { [ s, S			], [ kana_TO		]	};
+    key <AC03> { [ d, D			], [ kana_SHI		]	};
+    key <AC04> { [ f, F			], [ kana_HA		]	};
+    key <AC05> { [ g, G			], [ kana_KI		]	};
+    key <AC06> { [ h, H			], [ kana_KU		]	};
+    key <AC07> { [ j, J			], [ kana_MA		]	};
+    key <AC08> { [ k, K			], [ kana_NO		]	};
+    key <AC09> { [ l, L			], [ kana_RI		]	};
+    key <AC10> { [ semicolon, plus	], [ kana_RE		]	};
+    key <AC11> { [ colon, asterisk	], [ kana_KE		]	};
+    key <TLDE> { [ bracketright, braceright ], [ kana_MU, kana_closingbracket ] };
+
+    key <AB01> { [ z, Z 		], [ kana_TSU, kana_tsu	]	};
+    key <AB02> { [ x, X			], [ kana_SA		]	};
+    key <AB03> { [ c, C			], [ kana_SO		]	};
+    key <AB04> { [ v, V			], [ kana_HI		]	};
+    key <AB05> { [ b, B			], [ kana_KO		]	};
+    key <AB06> { [ n, N			], [ kana_MI		]	};
+    key <AB07> { [ m, M			], [ kana_MO		]	};
+    key <AB08> { [ comma, less		], [ kana_NE, kana_comma ]	};
+    key <AB09> { [ period, greater	], [ kana_RU, kana_fullstop ]	};
+    key <AB10> { [ slash, question	], [ kana_ME, kana_conjunctive ]};
+    key <UNDR> { [ backslash, underscore], [ kana_RO		]	};
+
+    key <SPCE> { [ space		]			};
+    key <KANJ> { [ Kanji		]			};
+    key <HENK> { [ Henkan_Mode		]			};
+//    key <LNFD> { [ backslash, underscore], [ kana_RO		]};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <ESC>  { [ Escape		]			};
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <BKSL> { [ backslash, bar	], [ prolongedsound 	] };
+//    key <BRCR> { [ Linefeed		]			};
+    key <EXEC> { [ Execute		]			};
+};
+xkb_symbols "type4" {
+
+    // Alphanumeric section
+    key <AE01> { [ 1, exclam 		], [ kana_NU		]	};
+    key <AE02> { [ 2, quotedbl		], [ kana_FU		]	};
+    key <AE03> { [ 3, numbersign	], [ kana_A, kana_a	]	};
+    key <AE04> { [ 4, dollar		], [ kana_U, kana_u	]	};
+    key <AE05> { [ 5, percent		], [ kana_E, kana_e	]	};
+    key <AE06> { [ 6, ampersand		], [ kana_O, kana_o	]	};
+    key <AE07> { [ 7, apostrophe	], [ kana_YA, kana_ya	]	};
+    key <AE08> { [ 8, parenleft		], [ kana_YU, kana_yu	]	};
+    key <AE09> { [ 9, parenright	], [ kana_YO, kana_yo	]	};
+    key <AE10> { [ 0			], [ kana_WA, kana_WO	]	};
+    key <AE11> { [ minus, equal		], [ kana_HO		]	};
+    key <AE12> { [ asciicircum,	asciitilde], [ kana_HE		]	};
+    key <BKSP> { [ BackSpace		]	};
+
+    key  <TAB> { [ Tab,	ISO_Left_Tab	]	};
+    key <AD01> { [ q, Q 		], [ kana_TA		]	};
+    key <AD02> { [ w, W			], [ kana_TE		]	};
+    key <AD03> { [ e, E			], [ kana_I, kana_i	]	};
+    key <AD04> { [ r, R			], [ kana_SU		]	};
+    key <AD05> { [ t, T			], [ kana_KA		]	};
+    key <AD06> { [ y, Y			], [ kana_N		]	};
+    key <AD07> { [ u, U			], [ kana_NA		]	};
+    key <AD08> { [ i, I			], [ kana_NI		]	};
+    key <AD09> { [ o, O			], [ kana_RA		]	};
+    key <AD10> { [ p, P			], [ kana_SE		]	};
+    key <AD11> { [ at, quoteleft	], [ voicedsound	]	};
+    key <AD12> { [ bracketleft,	braceleft ], [ semivoicedsound, kana_openingbracket ] };
+    key <RTRN> { [ Return		]	};
+
+    key <CAPS> { [ Caps_Lock		]	};
+    key <AC01> { [ a, A 		], [ kana_CHI		]	};
+    key <AC02> { [ s, S			], [ kana_TO		]	};
+    key <AC03> { [ d, D			], [ kana_SHI		]	};
+    key <AC04> { [ f, F			], [ kana_HA		]	};
+    key <AC05> { [ g, G			], [ kana_KI		]	};
+    key <AC06> { [ h, H			], [ kana_KU		]	};
+    key <AC07> { [ j, J			], [ kana_MA		]	};
+    key <AC08> { [ k, K			], [ kana_NO		]	};
+    key <AC09> { [ l, L			], [ kana_RI		]	};
+    key <AC10> { [ semicolon, plus	], [ kana_RE		]	};
+    key <AC11> { [ colon, asterisk	], [ kana_KE		]	};
+    key <TLDE> { [ bracketright, braceright ], [ kana_MU, kana_closingbracket ] };
+
+    key <LFSH> { [ Shift_L		]	};
+    key <AB01> { [ z, Z 		], [ kana_TSU, kana_tsu	]	};
+    key <AB02> { [ x, X			], [ kana_SA		]	};
+    key <AB03> { [ c, C			], [ kana_SO		]	};
+    key <AB04> { [ v, V			], [ kana_HI		]	};
+    key <AB05> { [ b, B			], [ kana_KO		]	};
+    key <AB06> { [ n, N			], [ kana_MI		]	};
+    key <AB07> { [ m, M			], [ kana_MO		]	};
+    key <AB08> { [ comma, less		], [ kana_NE, kana_comma ]	};
+    key <AB09> { [ period, greater	], [ kana_RU, kana_fullstop ]	};
+    key <AB10> { [ slash, question	], [ kana_ME, kana_conjunctive ]};
+    key <UNDR> { [ backslash, underscore], [ kana_RO		]	};
+    key <RTSH> { [ Shift_R		]	};
+
+    key <LCTL> { [ Control_L		]			};
+    key <SPCE> { [ space		]			};
+    key <KANJ> { [ Kanji		]			};
+    key <HENK> { [ Henkan_Mode		]			};
+    key <LALT> { [ Alt_L		]			};
+    key <ALGR> { [ Mode_switch		]			};
+    key <LMTA> { [ Meta_L		]			};
+    key <RMTA> { [ Meta_R		]			};
+    key <LNFD> { [ backslash, underscore], [ kana_RO		]};
+    key <COMP> { [ Multi_key		]			};
+    key <EXEC> { [ Execute		]			};
+//    key <TLFD> { [ Linefeed		]			};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <ESC>  { [ Escape		]			};
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <BKSL> { [ backslash, bar	], [ prolongedsound 	] };
+    key <BRCR> { [ Linefeed		]			};
+
+    key <STOP> { [ L1,	L1		], [ SunStop	]	};
+    key <AGAI> { [ L2,	L2		], [ SunAgain	]	};
+    key <PROP> { [ L3,	L3		], [ SunProps	]	};
+    key <UNDO> { [ L4,	L4		], [ SunUndo	]	};
+    key <FRNT> { [ L5,	L5		], [ SunFront	]	};
+    key <COPY> { [ L6,	L6		], [ SunCopy	]	};
+    key <OPEN> { [ L7,	L7		], [ SunOpen	]	};
+    key <PAST> { [ L8,	L8		], [ SunPaste	]	};
+    key <FIND> { [ L9,	L9		], [ SunFind	]	};
+    key <CUT>  { [ L10,	L10		], [ SunCut	]	};
+    // End "Function" section
+
+    // Begin "Editing" section
+    key <PRSC> { [ R2,	R2		], [ Print		] };
+    key <SCLK> { [ R3,	R3		], [ Scroll_Lock, Break	] };
+    key <PAUS> { [ R1,	R1		], [ Pause		] };
+    key <DELE> { [ Delete		]			};
+    key <HELP> { [ Help			]			};
+
+    // End "Editing" section, begin "Keypad"
+    key <NMLK> { [ Num_Lock 		]			};
+    key <KPEQ> { [ R4,	R4 		], [ KP_Equal		] };
+    key <KPDV> { [ R5,	R5		], [ KP_Divide		] };
+    key <KPMU> { [ R6,	R6		], [ KP_Multiply	] };
+    key <KPSU> { [ KP_Subtract		]			};
+
+    key  <KP7> { [ R7,	R7		], [ KP_7, Home		] };
+    key  <KP8> { [ Up,	R8		], [ KP_8		] };
+    key  <KP9> { [ R9,	R9		], [ KP_9, Prior	] };
+    key <KPAD> { [ KP_Add		]			};
+
+    key  <KP4> { [ Left, R10		], [ KP_4		] };
+    key  <KP5> { [ R11,	R11		], [ KP_5		] };
+    key  <KP6> { [ Right, R12		], [ KP_6		] };
+
+    key  <KP1> { [ R13,	R13		], [ KP_1,	End	] };
+    key  <KP2> { [ Down, R14		], [ KP_2		] };
+    key  <KP3> { [ R15,	R15		], [ KP_3,	Next	] };
+    key <KPEN> { [ KP_Enter		]			}; 
+    key  <KP0> { [ KP_Insert, KP_Insert], [ KP_0		]	};
+    key <KPDL> { [ Delete, Delete	], [ KP_Decimal ]	};
+    // End "Keypad" section
+
+
+    // begin modifier mappings
+    modifier_map Shift  	{ Shift_R, Shift_L };
+    modifier_map Mod1   	{ Meta_L, Meta_R };
+    modifier_map Mod2   	{ Mode_switch };
+    modifier_map Mod3   	{ Num_Lock };
+    modifier_map Mod4		{ Alt_L };
+};
+
+// US/ASCII layout for a Type 5 Sun keyboard
+xkb_symbols "type5" {
+
+    // Alphanumeric section
+    key <TLDE> { [ backslash, bar	], [ prolongedsound	]	};
+    key <AE01> { [ 1, exclam 		], [ kana_NU		]	};
+    key <AE02> { [ 2, quotedbl		], [ kana_FU		]	};
+    key <AE03> { [ 3, numbersign	], [ kana_A, kana_a	]	};
+    key <AE04> { [ 4, dollar		], [ kana_U, kana_u	]	};
+    key <AE05> { [ 5, percent		], [ kana_E, kana_e	]	};
+    key <AE06> { [ 6, ampersand		], [ kana_O, kana_o	]	};
+    key <AE07> { [ 7, apostrophe	], [ kana_YA, kana_ya	]	};
+    key <AE08> { [ 8, parenleft		], [ kana_YU, kana_yu	]	};
+    key <AE09> { [ 9, parenright	], [ kana_YO, kana_yo	]	};
+    key <AE10> { [ 0			], [ kana_WA, kana_WO	]	};
+    key <AE11> { [ minus, equal		], [ kana_HO		]	};
+    key <AE12> { [ asciicircum,	asciitilde], [ kana_HE		]	};
+    key <BKSP> { [ BackSpace		]	};
+
+    key  <TAB> { [ Tab,	ISO_Left_Tab	]	};
+    key <AD01> { [ q, Q 		], [ kana_TA		]	};
+    key <AD02> { [ w, W			], [ kana_TE		]	};
+    key <AD03> { [ e, E			], [ kana_I, kana_i	]	};
+    key <AD04> { [ r, R			], [ kana_SU		]	};
+    key <AD05> { [ t, T			], [ kana_KA		]	};
+    key <AD06> { [ y, Y			], [ kana_N		]	};
+    key <AD07> { [ u, U			], [ kana_NA		]	};
+    key <AD08> { [ i, I			], [ kana_NI		]	};
+    key <AD09> { [ o, O			], [ kana_RA		]	};
+    key <AD10> { [ p, P			], [ kana_SE		]	};
+    key <AD11> { [ at, quoteleft	], [ voicedsound	]	};
+    key <AD12> { [ bracketleft,	braceleft ], [ semivoicedsound, kana_openingbracket ] };
+    key <RTRN> { [ Return		]	};
+
+    key <CAPS> { [ Caps_Lock		]	};
+    key <AC01> { [ a, A 		], [ kana_CHI		]	};
+    key <AC02> { [ s, S			], [ kana_TO		]	};
+    key <AC03> { [ d, D			], [ kana_SHI		]	};
+    key <AC04> { [ f, F			], [ kana_HA		]	};
+    key <AC05> { [ g, G			], [ kana_KI		]	};
+    key <AC06> { [ h, H			], [ kana_KU		]	};
+    key <AC07> { [ j, J			], [ kana_MA		]	};
+    key <AC08> { [ k, K			], [ kana_NO		]	};
+    key <AC09> { [ l, L			], [ kana_RI		]	};
+    key <AC10> { [ semicolon, plus	], [ kana_RE		]	};
+    key <AC11> { [ colon, asterisk	], [ kana_KE		]	};
+    key <BKSL> { [ bracketright, braceright ], [ kana_MU, kana_closingbracket ] };
+
+    key <LFSH> { [ Shift_L		]	};
+    key <AB01> { [ z, Z 		], [ kana_TSU, kana_tsu	]	};
+    key <AB02> { [ x, X			], [ kana_SA		]	};
+    key <AB03> { [ c, C			], [ kana_SO		]	};
+    key <AB04> { [ v, V			], [ kana_HI		]	};
+    key <AB05> { [ b, B			], [ kana_KO		]	};
+    key <AB06> { [ n, N			], [ kana_MI		]	};
+    key <AB07> { [ m, M			], [ kana_MO		]	};
+    key <AB08> { [ comma, less		], [ kana_NE, kana_comma ]	};
+    key <AB09> { [ period, greater	], [ kana_RU, kana_fullstop ]	};
+    key <AB10> { [ slash, question	], [ kana_ME, kana_conjunctive ]};
+    key <UNDR> { [ backslash, underscore], [ kana_RO		]	};
+    key <RTSH> { [ Shift_R		]	};
+
+    key <LCTL> { [ Control_L		]			};
+//    key <RCTL> { [ Control_R		]			};
+    key <EXEC> { [ Execute		]			};
+    key <SPCE> { [ space		]			};
+    key <KANJ> { [ Kanji		]			};
+    key <HENK> { [ Henkan_Mode		]			};
+    key <LALT> { [ Alt_L		]	};
+    key <ALGR> { [ Mode_switch		]	};
+    key <LMTA> { [ Meta_L		]	};
+    key <RMTA> { [ Meta_R		]	};
+    key <COMP> { [ Multi_key		]	};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <ESC>  { [ Escape		]			};
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <STOP> { [ L1, L1		], [ SunStop	]	};
+    key <AGAI> { [ L2, L2		], [ SunAgain	]	};
+    key <PROP> { [ L3, L3		], [ SunProps	]	};
+    key <UNDO> { [ L4, L4		], [ SunUndo	]	};
+    key <FRNT> { [ L5, L5		], [ SunFront	]	};
+    key <COPY> { [ L6, L6		], [ SunCopy	]	};
+    key <OPEN> { [ L7, L7		], [ SunOpen	]	};
+    key <PAST> { [ L8, L8		], [ SunPaste	]	};
+    key <FIND> { [ L9, L9		], [ SunFind	]	};
+    key <CUT>  { [ L10, L10		], [ SunCut	]	};
+    // End "Function" section
+
+    // Begin "Editing" section
+    key <PRSC> { [ R2, R2 		], [ Print, SunSys_Req	]	};
+    key <SCLK> { [ R3, R3		], [ Scroll_Lock	]	};
+    key <PAUS> { [ R1, R1		], [ Pause, Break	]	};
+    key <LEFT> { [ Left			]			};
+    key <RGHT> { [ Right		]			};
+    key <UP>   { [ Up			]			};
+    key <DOWN> { [ Down			]			};
+
+    key <DELE> { [ Delete		]			};
+    key <INS>  { [ Insert		]			};
+    key <PGUP> { [ Prior		]			};
+    key <PGDN> { [ Next			]			};
+    key <HOME> { [ Home			]			};
+    key <END>  { [ End			]			};
+    key <HELP> { [ Help			]			};
+
+    // End "Editing" section, begin "Keypad"
+    key <NMLK> { [ Num_Lock 		]				};
+    key <KPDV> { [ R5, R5		], [ KP_Divide	]	};
+    key <KPMU> { [ R6, R6		], [ KP_Multiply	]	};
+    key <KPSU> { [ R4, R4		], [ KP_Subtract	]	};
+
+    key  <KP7> { [ R7, R7		], [ KP_7, Home		]	};
+    key  <KP8> { [ Up, R8		], [ KP_8		]	};
+    key  <KP9> { [ R9, R9		], [ KP_9, Prior	]	};
+    key <KPAD> { [ KP_Add		]				};
+
+    key  <KP4> { [ Left, R10		], [ KP_4		]	};
+    key  <KP5> { [ R11,	R11		], [ KP_5		]	};
+    key  <KP6> { [ Right, R12		], [ KP_6		]	};
+
+    key  <KP1> { [ R13,	R13		], [ KP_1, End		]	};
+    key  <KP2> { [ Down, R14		], [ KP_2		]	};
+    key  <KP3> { [ R15,	R15		], [ KP_3		]	};
+    key <KPEN> { [ KP_Enter		]				};
+
+    key  <KP0> { [ KP_Insert, KP_Insert	], [ KP_0		]	};
+    key <KPDL> { [ KP_Delete, KP_Delete ], [ KP_Decimal 	]	};
+    // End "Keypad" section, 
+    // begin "four keys up on the right"
+
+    key <MUTE> { [ SunAudioMute,	SunVideoDegauss		]	};
+    key <VOL-> { [ SunAudioLowerVolume,	SunVideoLowerBrightness ]	};
+    key <VOL+> { [ SunAudioRaiseVolume,	SunVideoRaiseBrightness	]	};
+    key <POWR> { [ SunPowerSwitch,	SunPowerSwitchShift	]	};
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_R };
+    modifier_map Mod1	{ Meta_L, Meta_R };
+    modifier_map Mod2	{ Alt_R };
+    modifier_map Mod3	{ Num_Lock };
+    modifier_map Mod4	{ Alt_L };
+};
+
+xkb_symbols "type5hobo" {
+
+    // Alphanumeric section
+    key <TLDE> { [ backslash, bar	], [ prolongedsound	]	};
+    key <AE01> { [ 1, exclam 		], [ kana_NU		]	};
+    key <AE02> { [ 2, quotedbl		], [ kana_FU		]	};
+    key <AE03> { [ 3, numbersign	], [ kana_A, kana_a	]	};
+    key <AE04> { [ 4, dollar		], [ kana_U, kana_u	]	};
+    key <AE05> { [ 5, percent		], [ kana_E, kana_e	]	};
+    key <AE06> { [ 6, ampersand		], [ kana_O, kana_o	]	};
+    key <AE07> { [ 7, apostrophe	], [ kana_YA, kana_ya	], [ KP_7 ]};
+    key <AE08> { [ 8, parenleft		], [ kana_YU, kana_yu	], [ KP_8 ]};
+    key <AE09> { [ 9, parenright	], [ kana_YO, kana_yo	], [ KP_9 ]};
+    key <AE10> { [ 0			], [ kana_WA, kana_WO	], [ KP_Multiply]};
+    key <AE11> { [ minus, equal		], [ kana_HO		]	};
+    key <AE12> { [ asciicircum,	asciitilde], [ kana_HE		]	};
+    key <BKSP> { [ BackSpace		]	};
+
+    key  <TAB> { [ Tab,	ISO_Left_Tab	]	};
+    key <AD01> { [ q, Q 		], [ kana_TA		]	};
+    key <AD02> { [ w, W			], [ kana_TE		]	};
+    key <AD03> { [ e, E			], [ kana_I, kana_i	]	};
+    key <AD04> { [ r, R			], [ kana_SU		]	};
+    key <AD05> { [ t, T			], [ kana_KA		]	};
+    key <AD06> { [ y, Y			], [ kana_N		]	};
+    key <AD07> { [ u, U		], [ kana_NA		], [ KP_4 ]	};
+    key <AD08> { [ i, I		], [ kana_NI		], [ KP_5 ]	};
+    key <AD09> { [ o, O		], [ kana_RA		], [ KP_6 ]	};
+    key <AD10> { [ p, P		], [ kana_SE		], [ KP_Subtract]};
+    key <AD11> { [ at, quoteleft	], [ voicedsound	]	};
+    key <AD12> { [ bracketleft,	braceleft ], [ semivoicedsound, kana_openingbracket ] };
+    key <RTRN> { [ Return	], [ NoSymbol, NoSymbol], [ KP_Enter	] };
+
+    key <CAPS> { [ Caps_Lock		]	};
+    key <AC01> { [ a, A 		], [ kana_CHI		]	};
+    key <AC02> { [ s, S			], [ kana_TO		]	};
+    key <AC03> { [ d, D			], [ kana_SHI		]	};
+    key <AC04> { [ f, F			], [ kana_HA		]	};
+    key <AC05> { [ g, G			], [ kana_KI		]	};
+    key <AC06> { [ h, H			], [ kana_KU		]	};
+    key <AC07> { [ j, J		], [ kana_MA		], [ KP_1 ]};
+    key <AC08> { [ k, K		], [ kana_NO		], [ KP_2 ]};
+    key <AC09> { [ l, L		], [ kana_RI		], [ KP_3 ]};
+    key <AC10> { [ semicolon, plus], [ kana_RE		], [ KP_Add ]};
+    key <AC11> { [ colon, asterisk	], [ kana_KE		]	};
+    key <BKSL> { [ bracketright, braceright ], [ kana_MU, kana_closingbracket ] };
+
+    key <LFSH> { [ Shift_L		]	};
+    key <AB01> { [ z, Z 		], [ kana_TSU, kana_tsu	]	};
+    key <AB02> { [ x, X			], [ kana_SA		]	};
+    key <AB03> { [ c, C			], [ kana_SO		]	};
+    key <AB04> { [ v, V			], [ kana_HI		]	};
+    key <AB05> { [ b, B			], [ kana_KO		]	};
+    key <AB06> { [ n, N			], [ kana_MI		]	};
+    key <AB07> { [ m, M			], [ kana_MO		], [ KP_0 ]};
+    key <AB08> { [ comma, less		], [ kana_NE, kana_comma ]	};
+    key <AB09> { [ period, greater	], [ kana_RU, kana_fullstop ], [ KP_Decimal ]	};
+    key <AB10> { [ slash, question	], [ kana_ME, kana_conjunctive ], [ KP_Divide ]};
+    key <UNDR> { [ backslash, underscore], [ kana_RO		]	};
+    key <RTSH> { [ Shift_R		]	};
+
+    key <LCTL> { [ Control_L		]			};
+    key <EXEC> { [ Execute		]			};
+    key <SPCE> { [ space		]			};
+    key <KANJ> { [ Kanji		]			};
+    key <HENK> { [ Henkan_Mode		]			};
+    key <LALT> { [ Alt_L		]	};
+    key <ALGR> { [ Mode_switch		]	};
+    key <LMTA> { [ Meta_L		]	};
+    key <RMTA> { [ Meta_R		]	};
+    key <COMP> { [ Multi_key		]	};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <ESC>  { [ Escape		]			};
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <STOP> { [ L1, L1		], [ SunStop	]	};
+    key <AGAI> { [ L2, L2		], [ SunAgain	]	};
+    key <PROP> { [ L3, L3		], [ SunProps	]	};
+    key <UNDO> { [ L4, L4		], [ SunUndo	]	};
+    key <FRNT> { [ L5, L5		], [ SunFront	]	};
+    key <COPY> { [ L6, L6		], [ SunCopy	]	};
+    key <OPEN> { [ L7, L7		], [ SunOpen	]	};
+    key <PAST> { [ L8, L8		], [ SunPaste	]	};
+    key <FIND> { [ L9, L9		], [ SunFind	]	};
+    key <CUT>  { [ L10, L10		], [ SunCut	]	};
+    // End "Function" section
+
+    // Begin "Editing" section
+    key <PRSC> { [ R2, R2 		], [ Print, SunSys_Req	]	};
+    key <SCLK> { [ R3, R3		], [ Scroll_Lock	]	};
+    key <PAUS> { [ R1, R1		], [ Pause, Break	]	};
+    key <LEFT> { [ Left			]			};
+    key <RGHT> { [ Right		]			};
+    key <UP>   { [ Up			]			};
+    key <DOWN> { [ Down			]			};
+
+    key <DELE> { [ Delete		]			};
+    key <INS>  { [ Insert		]			};
+    key <PGUP> { [ Prior		]			};
+    key <PGDN> { [ Next			]			};
+    key <HOME> { [ Home			]			};
+    key <END>  { [ End			]			};
+    key <HELP> { [ Help			]			};
+
+    // End "Editing" section, begin "Keypad"
+     key <NMLK> { [ Num_Lock 		]				};
+//     key <KPDV> { [ R5, R5		], [ KP_Divide	]	};
+//     key <KPMU> { [ R6, R6		], [ KP_Multiply	]	};
+//     key <KPSU> { [ R4, R4		], [ KP_Subtract	]	};
+
+//     key  <KP7> { [ R7, R7		], [ KP_7, Home		]	};
+//     key  <KP8> { [ Up, R8		], [ KP_8		]	};
+//     key  <KP9> { [ R9, R9		], [ KP_9, Prior	]	};
+//     key <KPAD> { [ KP_Add		]				};
+
+//     key  <KP4> { [ Left, R10		], [ KP_4		]	};
+//     key  <KP5> { [ R11,	R11		], [ KP_5		]	};
+//     key  <KP6> { [ Right, R12		], [ KP_6		]	};
+
+//     key  <KP1> { [ R13,	R13		], [ KP_1, End		]	};
+//     key  <KP2> { [ Down, R14		], [ KP_2		]	};
+//     key  <KP3> { [ R15,	R15		], [ KP_3		]	};
+//     key <KPEN> { [ KP_Enter		]				};
+
+//     key  <KP0> { [ KP_Insert, KP_Insert	], [ KP_0		]	};
+//     key <KPDL> { [ KP_Delete, KP_Delete ], [ KP_Decimal 	]	};
+    // End "Keypad" section, 
+    // begin "four keys up on the right"
+
+    key <MUTE> { [ SunAudioMute,	SunVideoDegauss		]	};
+    key <VOL-> { [ SunAudioLowerVolume,	SunVideoLowerBrightness ]	};
+    key <VOL+> { [ SunAudioRaiseVolume,	SunVideoRaiseBrightness	]	};
+    key <POWR> { [ SunPowerSwitch,	SunPowerSwitchShift	]	};
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_R };
+    modifier_map Mod1	{ Meta_L, Meta_R };
+    modifier_map Mod2	{ Alt_R };
+    modifier_map Mod3	{ Num_Lock };
+    modifier_map Mod4	{ Alt_L };
+};
+
+// layout for a Japanese Type 6 Sun keyboard
+// Just shows differences from Type 6 US layout 
+partial
+xkb_symbols "type6" {
+
+    // Alphanumeric section
+    // Though Yen symbol is engraved on key AE13, JA L10N folks want backslash.
+    key <AE13> { [ backslash, bar       ], [ prolongedsound     ]       };
+    key <AE01> { [ 1, exclam 		], [ kana_NU		]	};
+    key <AE02> { [ 2, quotedbl		], [ kana_FU		]	};
+    key <AE03> { [ 3, numbersign	], [ kana_A, kana_a	]	};
+    key <AE04> { [ 4, dollar		], [ kana_U, kana_u	]	};
+    key <AE05> { [ 5, percent		], [ kana_E, kana_e	]	};
+    key <AE06> { [ 6, ampersand		], [ kana_O, kana_o	]	};
+    key <AE07> { [ 7, apostrophe	], [ kana_YA, kana_ya	]	};
+    key <AE08> { [ 8, parenleft		], [ kana_YU, kana_yu	]	};
+    key <AE09> { [ 9, parenright	], [ kana_YO, kana_yo	]	};
+    key <AE10> { [ 0			], [ kana_WA, kana_WO	]	};
+    key <AE11> { [ minus, equal		], [ kana_HO		]	};
+    key <AE12> { [ asciicircum,	asciitilde], [ kana_HE		]	};
+
+    key <AD01> { [ q, Q 		], [ kana_TA		]	};
+    key <AD02> { [ w, W			], [ kana_TE		]	};
+    key <AD03> { [ e, E			], [ kana_I, kana_i	]	};
+    key <AD04> { [ r, R			], [ kana_SU		]	};
+    key <AD05> { [ t, T			], [ kana_KA		]	};
+    key <AD06> { [ y, Y			], [ kana_N		]	};
+    key <AD07> { [ u, U			], [ kana_NA		]	};
+    key <AD08> { [ i, I			], [ kana_NI		]	};
+    key <AD09> { [ o, O			], [ kana_RA		]	};
+    key <AD10> { [ p, P			], [ kana_SE		]	};
+    key <AD11> { [ at, quoteleft	], [ voicedsound	]	};
+    key <AD12> { [ bracketleft,	braceleft ], [ semivoicedsound, kana_openingbracket ] };
+
+    key <AC01> { [ a, A 		], [ kana_CHI		]	};
+    key <AC02> { [ s, S			], [ kana_TO		]	};
+    key <AC03> { [ d, D			], [ kana_SHI		]	};
+    key <AC04> { [ f, F			], [ kana_HA		]	};
+    key <AC05> { [ g, G			], [ kana_KI		]	};
+    key <AC06> { [ h, H			], [ kana_KU		]	};
+    key <AC07> { [ j, J			], [ kana_MA		]	};
+    key <AC08> { [ k, K			], [ kana_NO		]	};
+    key <AC09> { [ l, L			], [ kana_RI		]	};
+    key <AC10> { [ semicolon, plus	], [ kana_RE		]	};
+    key <AC11> { [ colon, asterisk	], [ kana_KE		]	};
+    key <BKSL> { [ bracketright, braceright ], [ kana_MU, kana_closingbracket ] };
+
+    key <AB01> { [ z, Z 		], [ kana_TSU, kana_tsu	]	};
+    key <AB02> { [ x, X			], [ kana_SA		]	};
+    key <AB03> { [ c, C			], [ kana_SO		]	};
+    key <AB04> { [ v, V			], [ kana_HI		]	};
+    key <AB05> { [ b, B			], [ kana_KO		]	};
+    key <AB06> { [ n, N			], [ kana_MI		]	};
+    key <AB07> { [ m, M			], [ kana_MO		]	};
+    key <AB08> { [ comma, less		], [ kana_NE, kana_comma ]	};
+    key <AB09> { [ period, greater	], [ kana_RU, kana_fullstop ]	};
+    key <AB10> { [ slash, question	], [ kana_ME, kana_conjunctive ]};
+    key <AB11> { [ backslash, underscore], [ kana_RO		]	};
+    key <UNDR> { [ backslash, underscore], [ kana_RO		]	};
+
+    key <EXEC> { [ Execute		]			};
+    key <KANJ> { [ Kanji		]			};
+    key <HENK> { [ Henkan_Mode		]			};
+    key <ALGR> { [ Kana_Lock, Mode_switch ]	};
+    // End alphanumeric section
+};
+
+xkb_symbols "x86" {
+    include "sun/us(pc101)"
+    include "sun/jp(basic)"
+    key <TLDE> { [ Henkan_Mode, Henkan_Mode ], [ Henkan_Mode ] };
+
+    key <AE10> { [ 0, asciitilde	    ], [ kana_WA, kana_WO	]};
+    key <AE13> { [ backslash, bar	    ], [ prolongedsound		]};
+
+    
+    key <AC12> { [ bracketright, braceright ], [ kana_MU, kana_closingbracket	]};
+
+    key <ALGR> { [ Mode_switch ]	       };
+    key <RALT> { [ Alt_R ]	       };
+
+};
+
+xkb_symbols "J3100" {
+    include "sun/us(pc101)"
+
+    // Alphanumeric section
+    key <AE01> { [ 1, exclam 		], [ kana_NU		]	};
+    key <AE02> { [ 2, quotedbl		], [ kana_FU		]	};
+    key <AE03> { [ 3, numbersign	], [ kana_A, kana_a	]	};
+    key <AE04> { [ 4, dollar		], [ kana_U, kana_u	]	};
+    key <AE05> { [ 5, percent		], [ kana_E, kana_e	]	};
+    key <AE06> { [ 6, ampersand		], [ kana_O, kana_o	]	};
+    key <AE07> { [ 7, apostrophe	], [ kana_YA, kana_ya	]	};
+    key <AE08> { [ 8, parenleft		], [ kana_YU, kana_yu	]	};
+    key <AE09> { [ 9, parenright	], [ kana_YO, kana_yo	]	};
+    key <AE10> { [ 0			], [ kana_WA, kana_WO	]	};
+    key <AE11> { [ minus, equal		], [ kana_HO		]	};
+    key <AE12> { [ asciicircum,	asciitilde], [ kana_HE		]	};
+    key <BKSP> { [ BackSpace		]	};
+
+    key  <TAB> { [ Tab,	ISO_Left_Tab	]	};
+    key <AD01> { [ q, Q 		], [ kana_TA		]	};
+    key <AD02> { [ w, W			], [ kana_TE		]	};
+    key <AD03> { [ e, E			], [ kana_I, kana_i	]	};
+    key <AD04> { [ r, R			], [ kana_SU		]	};
+    key <AD05> { [ t, T			], [ kana_KA		]	};
+    key <AD06> { [ y, Y			], [ kana_N		]	};
+    key <AD07> { [ u, U			], [ kana_NA		]	};
+    key <AD08> { [ i, I			], [ kana_NI		]	};
+    key <AD09> { [ o, O			], [ kana_RA		]	};
+    key <AD10> { [ p, P			], [ kana_SE		]	};
+    key <AD11> { [ at, quoteleft	], [ voicedsound	]	};
+    key <AD12> { [ bracketleft,	braceleft ], [ semivoicedsound, kana_openingbracket ] };
+    key <RTRN> { [ Return		]	};
+
+    key <CAPS> { [ Caps_Lock		]	};
+    key <AC01> { [ a, A 		], [ kana_CHI		]	};
+    key <AC02> { [ s, S			], [ kana_TO		]	};
+    key <AC03> { [ d, D			], [ kana_SHI		]	};
+    key <AC04> { [ f, F			], [ kana_HA		]	};
+    key <AC05> { [ g, G			], [ kana_KI		]	};
+    key <AC06> { [ h, H			], [ kana_KU		]	};
+    key <AC07> { [ j, J			], [ kana_MA		]	};
+    key <AC08> { [ k, K			], [ kana_NO		]	};
+    key <AC09> { [ l, L			], [ kana_RI		]	};
+    key <AC10> { [ semicolon, plus	], [ kana_RE		]	};
+    key <AC11> { [ colon, asterisk	], [ kana_KE		]	};
+    key <TLDE> { [ bracketright, braceright ], [ kana_MU, kana_closingbracket ] };
+
+    key <AB01> { [ z, Z 		], [ kana_TSU, kana_tsu	]	};
+    key <AB02> { [ x, X			], [ kana_SA		]	};
+    key <AB03> { [ c, C			], [ kana_SO		]	};
+    key <AB04> { [ v, V			], [ kana_HI		]	};
+    key <AB05> { [ b, B			], [ kana_KO		]	};
+    key <AB06> { [ n, N			], [ kana_MI		]	};
+    key <AB07> { [ m, M			], [ kana_MO		]	};
+    key <AB08> { [ comma, less		], [ kana_NE, kana_comma ]	};
+    key <AB09> { [ period, greater	], [ kana_RU, kana_fullstop ]	};
+    key <AB10> { [ slash, question	], [ kana_ME, kana_conjunctive ]};
+//    key <UNDR> { [ backslash, underscore], [ kana_RO		]	};
+
+    key <SPCE> { [ space		]			};
+//    key <KANJ> { [ Kanji		]			};
+//    key <HENK> { [ Henkan_Mode		]			};
+//    key <LNFD> { [ backslash, underscore], [ kana_RO		]};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <ESC>  { [ Escape		]			};
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <BKSL> { [ backslash, bar	], [ prolongedsound 	] };
+//    key <BRCR> { [ Linefeed		]			};
+//    key <EXEC> { [ Execute		]			};
+
+    key <ESC>  { [ Escape, 3 ] };
+
+    key <AE02> { [ 2, at		], [ kana_FU			]};
+    key <AE06> { [ 6, asciicircum	], [ kana_O, kana_o		]};
+    key <AE07> { [ 7, ampersand		], [ kana_YA, kana_ya		]};
+    key <AE08> { [ 8, asterisk		], [ kana_YU, kana_yu		]};
+    key <AE09> { [ 9, parenleft		], [ kana_YO, kana_yo		]};
+    key <AE10> { [ 0, parenright	], [ kana_WA, kana_WO		]};
+    key <AE11> { [ minus, underscore	], [ kana_HO			]};
+    key <AE12> { [ equal, plus		], [ kana_HE			]};
+
+    key <BKSL> { [ backslash, bar	    ], [ prolongedsound		]};
+    key <AE12> { [ equal, plus		], [ kana_HE			]};
+
+    key <AD11> { [ bracketleft, braceleft  ], [ voicedsound		]};    
+    key <AD12> { [ bracketright, braceright  ], [ semivoicedsound, kana_openingbracket	]};    
+
+    key <AC10> { [ semicolon, colon	     ], [ kana_RE		]};    
+    key <AC11> { [ quoteright, quotedbl	     ], [ kana_KE		]};    
+
+    key <TLDE> { [ quoteleft, asciitilde ], [ kana_MU, kana_closingbracket	]};
+    key <LSGT> { [ backslash, bar	 ], [ kana_RO			]};
+//    key <ALGR> { [ Mode_switch ]	       };
+    key <RALT> { [ Henkan_Mode ]	       };
+    key <RCTL> { [ Mode_switch ]	       };
+
+};
+
+xkb_symbols "Muhenkan_x86" {
+    include "sun/jp(x86)"
+
+    key <EXEC> { [ Muhenkan ] };
+};
+
+
+
+partial
+xkb_symbols "type7" {
+    include "sun/jp(type6)"
+    key <AE10> { [ 0, asciitilde       ], [ kana_WA, kana_WO   ]       };
+    key <HZTG> { [ Henkan_Mode ] };
+    key <HENK> { [ Kana_Lock, Mode_switch ] };
+    key <ALGR> { [ Alt_R ] };
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/ko	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,63 @@
+// $XdotOrg: $
+//
+// Copyright 2005 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.
+//
+//
+// Korean layout for a Type 4 Sun keyboard
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]		};
+
+    key <LNFD> { [ Hangul		]			};
+    key <RALT> { [ Linefeed		]			};
+    key <COMP> { [ Hangul_Hanja		]			};
+
+};
+
+// Korean layout for a Type 5 Sun keyboard
+xkb_symbols "type5" {
+//    include "sun/us(type5basic)"
+
+    // A few keys are different
+    key <ALGR> { [ Hangul		]				  };
+    key <COMP> { [ Hangul_Hanja		]				  };
+    key <BKSL> { [ backslash, bar	], [ brokenbar			] };
+};
+
+// Korean layout for a Type 6 Sun keyboard
+partial
+xkb_symbols "type6" {
+//    include "sun/us(type5basic)"
+
+    // A few keys are different
+    key <ALGR> { [ Hangul		]				  };
+    key <COMP> { [ Hangul_Hanja		]				  };
+    key <BKSL> { [ backslash, bar	], [ brokenbar			] };
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/localmacros	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,38 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localmacros 1.5     05/11/08 SMI"
+XCOMM
+
+	EXTRADATAFILES = solaris ca cs cz de dk es fi fr gb gr hu it jp \
+			 ko lt lv nl no pl pt ru sw tr tuv tw
+
+InstallMultiple($(EXTRADATAFILES),$(LIBDIR)/xkb/symbols/sun)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/lt	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,81 @@
+// $XdotOrg: $
+//
+// 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.
+//
+// $TOG: hu /main/2 1997/06/13 06:25:05 kaleb $
+default partial alphanumeric_keys 
+xkb_symbols "type5" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Hungarian keyboard.
+
+    // Alphanumeric section
+
+    name[group1]="Lithuanian";
+
+    key <TLDE> {	[	quoteright,	asciitilde	],
+			[	quoteleft,	caron		]	};
+    key <AE02> {	[	2,		quotedbl	],
+			[	at				]	};
+    key <AE03> {	[	3,		slash		],
+			[	numbersign			]	};
+    key <AE04> {	[	4,		semicolon	],
+			[	dollar				]	};
+    key <AE05> {	[	5,		colon		],
+			[	percent				]	};
+    key <AE06> {	[	6,		comma		],
+			[	asciicircum			]	};
+    key <AE07> {	[	7,		period		],
+			[	ampersand			]	};
+    key <AE08> {	[	8,		question	],
+			[	asterisk			]	};
+    key <AE09> {	[	9,		parenleft	],
+			[	bracketleft,	braceleft	]	};
+    key <AE10> {	[	0,		parenright	],
+			[	bracketright,	braceright 	]	};
+    key <AD01> {	[	aogonek,	Aogonek		],
+			[	q,		Q		]	};
+    key <AD02> {	[	zcaron,		Zcaron		],
+			[	w,		W		]	};
+    key <AD11> {	[	iogonek,	Iogonek		]	};
+    key <AD12> {	[	ogonek				]	};
+    key <AC10> {	[	uogonek,	Uogonek		]	};
+    key <AC11> {	[	eabovedot,	Eabovedot	]	};
+    key <BKSL> {	[	asciicircum,	quoteright	]	};
+    key <LSGT> {	[	backslash,	bar		]	};
+    key <AB02> {	[	umacron,	Umacron		],
+			[	x,		X		]	};
+    key <AB08> {	[	ccaron,		Ccaron		],
+			[	less				]	};
+    key <AB09> {	[	scaron,		Scaron		],
+			[	greater				]	};
+    key <AB10> {	[	eogonek,	Eogonek		]	};
+
+    // End alphanumeric section
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/lv	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,75 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+default partial alphanumeric_keys 
+xkb_symbols "type5" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Latvian keyboard.
+
+    // Alphanumeric section
+
+    name[group1]="Latvian";
+
+    key <AE04> {	[	4,		dollar		],
+			[	section				]	};
+    key <AE08> {	[	8,		asterisk	],
+			[	multiply			]	};
+    key <AD03> {        [       e,              E               ],
+			[	emacron,	Emacron		]	};
+    key <AD04> {        [       r,              R               ],
+			[	rcedilla,	Rcedilla	]	};
+    key <AD07> {        [       u,              U               ],
+			[	umacron,	Umacron		]	};
+    key <AD08> {        [       i,              I               ],
+			[	imacron,	Imacron		]	};
+    key <AD09> {        [       o,              O               ],
+			[	omacron,	Omacron		]	};
+    key <AC01> {	[	a,		A		],
+			[	amacron,	Amacron		]	};
+    key <AC02> {	[	s,		S		],
+			[	scaron,		Scaron		]	};
+    key <AC05> {	[	g,		G		],
+			[	gcedilla,	Gcedilla	]	};
+    key <AC08> {	[	k,		K		],
+			[	kcedilla,	Kcedilla	]	};
+    key <AC09> {	[	l,		L		],
+			[	lcedilla,	Lcedilla	]	};
+    key <BKSL> {	[	degree,		bar		]	};
+    key <LSGT> {	[	backslash,	bar		]	};
+    key <AB01> {	[	z,		Z		],
+			[	zcaron,		Zcaron		]	};
+    key <AB03> {	[	c,		C		],
+			[	ccaron,		ccaron		]	};
+    key <AB06> {	[	n,		N		],
+			[	ncedilla,	Ncedilla	]	};
+    // End alphanumeric section
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/nl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,68 @@
+// $XdotOrg: $
+//
+// 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.
+//
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+
+    key <BKSL> { [ at, section		], [notsign ]		};
+    key <BRCR> { [ backslash, bar	]			};
+    key <AE01> { [ 1, exclam		], [onesuperior	]	};
+    key <AE02> { [ 2, quotedbl		], [twosuperior	]	};
+    key <AE03> { [ 3, numbersign	], [threesuperior]	};
+    key <AE04> { [ 4, dollar		], [onequarter	]	};
+    key <AE05> { [ 5, percent		], [onehalf	]	};
+    key <AE06> { [ 6, ampersand		], [threequarters]	};
+    key <AE07> { [ 7, underscore	], [sterling	]	};
+    key <AE08> { [ 8, parenleft		], [braceleft	]	};
+    key <AE09> { [ 9, parenright	], [braceright	]	};
+    key <AE10> { [ 0, quoteright	], [quoteleft	]	};
+    key <AE11> { [ slash, question	]			};
+    key <AE12> { [ degree, SunFA_Tilde	], [SunFA_Cedilla]	};
+    key <AD03> { [ e, E			], [EuroSign	]	};
+    key <AD11> { [ SunFA_Diaeresis, asciicircum], [SunFA_Circum]};
+    key <AD12> { [ asterisk, brokenbar	], [asciitilde	]	};
+    key <AC02> { [ S, NoSymbol		], [ssharp	]	};
+    key <AC10> { [ plus, plusminus	]			};
+    key <AC11> { [ SunFA_Acute, SunFA_Grave]			};
+    key <TLDE> { [ less, greater	]			};
+    key <LSGT> { [ bracketright, bracketleft]			};
+    key <AB01> { [ Z, NoSymbol		], [guillemotleft]	};
+    key <AB02> { [ X, NoSymbol		], [guillemotright]	};
+    key <AB03> { [ C, NoSymbol		], [cent	]	};
+    key <AB07> { [ M, NoSymbol		], [mu		]	};
+    key <AB08> { [ comma, semicolon	] 			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, equal		]			};
+    key <CAPS> { [ SunAltGraph		]			};
+//    key <COMP> { [ SunCompose		]			};
+    key <ALGR> { [ Caps_Lock		]			};
+ 
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/no	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,77 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+
+    key <BKSL> { [ bar, section		]			};
+    key <BRCR> { [ asciitilde, asciicircum]			};
+    key <AE02> { [ 2, quotedbl		], [at		]	};
+    key <AE03> { [ 3, numbersign	], [sterling	]	};
+    key <AE04> { [ 4, currency		], [dollar	]	};
+    key <AE06> { [ 6, ampersand		]			};
+    key <AE07> { [ 7, slash		], [braceleft	]	};
+    key <AE08> { [ 8, parenleft		], [bracketleft	]	};
+    key <AE09> { [ 9, parenright	], [bracketright]	};
+    key <AE10> { [ 0, equal		], [braceright	]	};
+    key <AE11> { [ plus, question	]			};
+    key <AE12> { [ backslash, SunFA_Grave], [SunFA_Acute]	};
+    key <AD03> { [ e, E			], [EuroSign	]	};
+    key <AD11> { [ Aring		]			};
+    key <AD12> { [ SunFA_Diaeresis, SunFA_Circum],[SunFA_Tilde] };
+    key <LCTL> { [ Caps_Lock		]			};
+    key <AC10> { [ Ooblique		]			};
+    key <AC11> { [ AE			]			};
+    key <TLDE> { [ quoteright, asterisk ], [quoteleft	]	};
+    key <LSGT> { [ less, greater	]			};
+    key <AB08> { [ comma, semicolon	]			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, underscore	]			};
+    key <CAPS> { [ Control_L		]			};
+
+};
+
+xkb_symbols "type5" {
+    include "no"
+
+    key <AE05> { [ 5, percent		], [asciitilde			]};
+    key <AE06> { [ 6, ampersand		], [asciicircum			]};
+    key <AE07> { [ 7, slash		], [ braceleft			]};
+    key <AE08> { [ 8, parenleft		], [ bracketright		]};
+    key <AE09> { [ 9, parenright	], [ bracketright		]};
+    key <AE10> { [ 0, equal		], [ braceright			]};
+
+    key <BKSL> { [ quoteright, asterisk	], [ quoteleft			]};
+    key <LSGT> { [ less, greater	]				};
+};
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/pl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,57 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "type5" {
+    include "sun/us(type5basic)"
+    // A few keys are different
+    key <TLDE> { [ quoteleft, asciitilde], [ degree, degree ]	};
+    key <AE02> { [ 2, quotedbl		], [ at		]	};
+    key <AE03> { [ 3, colon		], [ numbersign	]	};
+    key <AE04> { [ 4, question		], [ dollar	]	};
+    key <AE06> { [ 6, plus		], [ asciicircum ]	};
+    key <AE07> { [ 7, underscore	], [ ampersand	]	};
+    key <AE08> { [ 8, parenleft		], [ asterisk	]	};
+    key <AE09> { [ 9, parenright	]			};
+    key <AE10> { [ 0, equal		]			};
+    key <AE11> { [ zabovedot, Zabovedot	]			};
+    key <AE12> { [ dead_ogonek, Aacute ]			};
+    key <AD11> { [ oacute, zacute	], [ bracketleft, braceleft ] };
+    key <AD12> { [ slash, section	], [ bracketright, braceright ] };
+    key <AC02> { [ s, S			], [ ssharp	]	};
+    key <AC08> { [ k, K			], [ ampersand	]	};
+    key <AC10> { [ lstroke, Lstroke	]			};
+    key <AC11> { [ aogonek, eogonek	], [ quoteright	]	};
+    key <BKSL> { [ backslash, semicolon	], [ currency, bar ]	};
+    key <LSGT> { [ less, greater	]			};
+    key <AB08> { [ comma, sacute	], [ less	]	};
+    key <AB09> { [ period, nacute	], [ greater	]	};
+    key <AB10> { [ minus, cacute	]			};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/pt	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,88 @@
+// $XdotOrg: $
+//
+// 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.
+//
+xkb_symbols "type4" {
+    //this is a Portugal4 keyboard
+
+    key <BKSL> { [ bracketleft, braceleft], [guillemotleft]	};
+    key <BRCR> { [ bracketright, braceright], [guillemotright]	};
+    key <AE02> { [ 2, quotedbl		], [at		]	};
+    key <AE03> { [ 3, numbersign	], [sterling	]	};
+    key <AE04> { [ 4, dollar		], [section	]	};
+    key <AE06> { [ 6, ampersand		], [notsign	]	};
+    key <AE07> { [ 7, slash		]			};
+    key <AE08> { [ 8, parenleft		]			};
+    key <AE09> { [ 9, parenright	], [backslash	]	};
+    key <AE10> { [ 0, equal		], [bar		]	};
+    key <AE11> { [ quoteright, question	], [quoteleft	]	};
+    key <AE12> { [ exclamdown, questiondown]			};
+    key <AD03> { [ e, E			], [EuroSign	]	};
+    key <AD11> { [ SunFA_Diaeresis, asterisk], [plus	]	};
+    key <AD12> { [ SunFA_Acute, SunFA_Grave], [asciitilde]	};
+    key <LCTL> { [ Caps_Lock		]			};
+    key <AC10> { [ Ccedilla		]			};
+    key <AC11> { [ masculine, ordfeminine]			};
+    key <TLDE> { [ SunFA_Tilde, SunFA_Circum], [asciicircum]	};
+    key <LSGT> { [ less, greater	]			};
+    key <AB08> { [ comma, semicolon	]			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, underscore	]			};
+    key <CAPS> { [ Control_L		]			};
+
+};
+
+xkb_symbols "type5" {
+    include "pt"
+
+    key <TLDE> { [ backslash, bar	]				};
+    key <AE05> { [ 5, percent		], [asciitilde			]};
+    key <AE06> { [ 6, ampersand		], [asciicircum			]};
+    key <AE07> { [ 7, slash		], [ braceleft			]};
+    key <AE08> { [ 8, parenleft		], [ bracketleft		]};
+    key <AE09> { [ 9, parenright	], [ bracketright		]};
+    key <AE10> { [ 0, equal		], [ braceright			]};
+    key <AE11> { [ quoteright, question	], [quoteleft			]};
+
+    key <AD11> { [ plus, asterisk	], [SunFA_Diaeresis		]};
+
+};
+
+partial 
+xkb_symbols "type6" {
+    include "pt(sundeadkeys)"
+
+    key <AE05> { [ 5, percent		], [asciitilde			]};
+    key <AE06> { [ 6, ampersand		], [asciicircum			]};
+    key <AE07> { [ 7, slash		], [ braceleft			]};
+    key <AE08> { [ 8, parenleft		], [ bracketleft		]};
+    key <AE09> { [ 9, parenright	], [ bracketright		]};
+    key <AE10> { [ 0, equal		], [ braceright			]};
+    key <AE11> { [ quoteright, question	], [quoteleft			]};
+
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/ru	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,52 @@
+// $XdotOrg: $
+//
+// 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.
+//
+
+xkb_symbols "basic" {
+    include "ru"
+    // A few keys are different
+    key	<BKSL> {	[	backslash,	       bar	],
+			[	slash,           question	]	};
+   key	<AB10> {	[	    slash,	  question	],
+			[	  ediaeresis,	Ediaeresis	]	};
+
+};
+
+// layout for a Sun Type 6 Russian keyboard
+partial
+xkb_symbols "type6" {
+    include "sun/ru(basic)"
+
+    key <AE03> {        [               3,      numbersign      ],
+                        [               3,      numerosign      ]       };
+    key	<AE04> {	[		4,	dollar		],
+			[		4,	percent		]	};
+
+    key	<LSGT> {	[	backslash,	       bar	] };
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/se	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,81 @@
+// $XdotOrg: $
+//
+// 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.
+//
+xkb_symbols "type4" {
+    key <BKSL> { [ section, onehalf	]			};
+    key <BRCR> { [ asciitilde, asciicircum ]			};
+    key <AE02> { [ 2, quotedbl		], [ at			] };
+    key <AE03> { [ 3, numbersign	], [ sterling		] };
+    key <AE04> { [ 4, currency		], [ dollar		] };
+    key <AE05> { [ 5, percent           ], [ degree           	] };
+    key <AE06> { [ 6, ampersand         ], [ notsign          	] };
+    key <AE07> { [ 7, slash             ], [ braceleft		] };
+    key <AE08> { [ 8, parenleft         ], [ bracketleft 	]};
+    key <AE09> { [ 9, parenright        ], [ bracketright     	] };
+    key <AE10> { [ 0, equal             ], [ braceright        	] };
+    key <AE11> { [ plus, question 	], [ backslash       	] };
+    key <AE12> { [ SunFA_Acute, SunFA_Grave ]			  };
+
+    key <AD03> { [ e, E                 ], [ EuroSign         ] };
+    key <AD11> { [ Aring ]					};
+    key <AD12> { [ SunFA_Diaeresis, SunFA_Circum ], [ SunFA_Tilde ] };
+
+    key <AC10> { [ Odiaeresis		]			};
+    key <AC11> { [ Adiaeresis		]			};
+    key <TLDE> { [ quoteright, asterisk	], [ quoteleft 		]};
+
+    key <LCTL> { [ Caps_Lock ] };
+    key <CAPS> { [ Control_L ] };
+    key <LSGT> { [ less, greater	]			};
+    key <AB08> { [ comma, semicolon	]			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, underscore	]			};
+};
+
+
+xkb_symbols "type5" {
+    include "se"
+
+    key <TLDE> { [ section, onehalf	]			};
+    key <AE07> { [ 7, slash             ], [ braceleft		] };
+    key <AE08> { [ 8, parenleft         ], [ bracketleft 	]};
+    key <AE09> { [ 9, parenright        ], [ bracketright     	] };
+    key <AE10> { [ 0, equal             ], [ braceright        	] };
+    key <AE11> { [ plus, question 	], [ backslash       	] };
+
+    key <AD12> { [ SunFA_Diaeresis, asciicircum ], [ asciitilde ] };
+    key <BKSL> { [ quoteright, asterisk	], [ quoteleft 		]};
+};
+
+partial 
+xkb_symbols "type6" {
+    include "se(Sundeadkeys)"
+
+    key <AD12> { [ SunFA_Diaeresis, asciicircum ], [ asciitilde, caron ] };
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/solaris	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,179 @@
+//-------------------------------------------------------------------------
+//
+// Copyright 2005 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.
+//
+//-------------------------------------------------------------------------
+//
+// ident "@(#)solaris 1.7     05/11/08 SMI"
+//
+
+// Default map provides backwards compatibility with Sun keyboards from
+// long ago and the key mappings still used in Solaris Xsun today
+
+partial default
+xkb_symbols "defaults" {
+
+    // Left side keys were labeled L1-L10 on Sun Type 2 & Type 3 keyboards
+    // and the names have stuck (you can spot a longtime Sun admin when you
+    // hear them say to hit "L1-A" to enter the OpenBoot PROM)
+    // These names get mapped to the keysyms F11-F20
+    key <STOP> { [ L1,  L1              ], [ SunStop    ]       };
+    key <AGAI> { [ L2,  L2              ], [ SunAgain   ]       };
+    key <PROP> { [ L3,  L3              ], [ SunProps   ]       };
+    key <UNDO> { [ L4,  L4              ], [ SunUndo    ]       };
+    key <FRNT> { [ L5,  L5              ], [ SunFront   ]       };
+    key <COPY> { [ L6,  L6              ], [ SunCopy    ]       };
+    key <OPEN> { [ L7,  L7              ], [ SunOpen    ]       };
+    key <PAST> { [ L8,  L8              ], [ SunPaste   ]       };
+    key <FIND> { [ L9,  L9              ], [ SunFind    ]       };
+    key <CUT>  { [ L10, L10             ], [ SunCut     ]       };
+
+    // And on the right side, the function keys were labeled R1-R15,
+    // which get mapped to the keysyms F21-F35
+    // This includes the keys that became the numeric keypad
+    key <PAUS> { [ R1,  R1              ], [ Pause              ] };
+    key <PRSC> { [ R2,  R2              ], [ Print              ] };
+    key <SCLK> { [ R3,  R3              ], [ Scroll_Lock, Break ] };
+
+    key <KPEQ> { [ KP_Equal             ], [ R4, KP_Equal       ] };
+    key <KPDV> { [ KP_Divide            ], [ R5, KP_Divide      ] };
+    key <KPMU> { [ KP_Multiply          ], [ R6, KP_Multiply    ] };
+
+    key  <KP7> { [ KP_Home,  KP_7, R7   ], [ R7, KP_7, Home     ] };
+    key  <KP8> { [ KP_Up,    KP_8, R8   ], [ R8, KP_8, Up       ] };
+    key  <KP9> { [ KP_Prior, KP_9, R9   ], [ R9, KP_9, Prior    ] };
+
+    key  <KP4> { [ KP_Left,  KP_4, R10  ], [ R10, KP_4, Left    ] };
+    key  <KP5> { [ KP_Begin, KP_5, R11  ], [ R11, KP_5          ] };
+    key  <KP6> { [ KP_Right, KP_6, R12  ], [ R12, KP_6, Right   ] };
+
+    key  <KP1> { [ KP_End,   KP_1, R13  ], [ R13, KP_1, End     ] };
+    key  <KP2> { [ KP_Down,  KP_2, R14  ], [ R14, KP_2, Down    ] };
+    key  <KP3> { [ KP_Next,  KP_3, R15  ], [ R15, KP_3, Next    ] };
+
+    // F11 & F12 are mapped to SunF36 and SunF37 since they were added
+    // after F11-F35 were already assigned on Sun keyboards
+    key <FK11> { [ SunF36               ], [ F11                ] };
+    key <FK12> { [ SunF37               ], [ F12                ] };
+
+    // These were added to the keyboard much later and simply got mapped
+    // to their logical names
+    key <HELP> { [ Help                 ]                       };
+    key <MUTE> { [  SunAudioMute,	SunVideoDegauss		]	};
+    key <VOL-> { [  SunAudioLowerVolume,SunVideoLowerBrightness ]	};
+    key <VOL+> { [  SunAudioRaiseVolume,SunVideoRaiseBrightness	]	};
+    key <POWR> { [  SunPowerSwitch,	SunPowerSwitchShift	]	};
+
+    key <LALT> { [ Alt_L                ]                       };
+    // key <RALT> { [ Mode_switch          ]                       };
+    // key <ALGR> { [ Mode_switch          ]                       };
+    key <LMTA> { [ Meta_L               ]                       };
+    key <RMTA> { [ Meta_R               ]                       };
+    key <COMP> { [ Multi_key            ]                       };
+
+    // begin modifier mappings
+    modifier_map Shift          { Shift_R, Shift_L };
+    modifier_map Mod1           { Alt_L };
+    modifier_map Mod2           { Alt_R, Mode_switch };
+    modifier_map Mod3           { Num_Lock };
+    modifier_map Mod4           { Meta_L, Meta_R };
+
+};
+
+// Map the keys to the actual key names instead of the ancient Sun function
+// keys
+partial
+xkb_symbols "keynames" {
+    key <FK11> { [ F11          ],      [ SunF36   ]    };
+    key <FK12> { [ F12          ],      [ SunF37   ]    };
+
+    key <STOP> { [ Cancel	],	[ F11	]	};
+    key <AGAI> { [ Redo		],	[ F12	]	};
+    key <PROP> { [ SunProps	],	[ F13	]	};
+    key <UNDO> { [ Undo		],	[ F14	]	};
+    key <FRNT> { [ SunFront	],	[ F15	]	};
+    key <COPY> { [ SunCopy	],	[ F16	]	};
+    key <OPEN> { [ SunOpen	],	[ F17	]	};
+    key <PAST> { [ SunPaste	],	[ F18	]	};
+    key <FIND> { [ Find		],	[ F19	]	};
+    key <CUT>  { [ SunCut	],	[ F20	]	};
+
+    key <HELP> { [ Help		]	                };
+
+    key <PAUS> {  [  Pause                      ]       };
+    key <PRSC> {  [  Print                      ]       };
+    key <SCLK> {  [  Scroll_Lock, Break         ]       };
+
+    key  <KP7> {        [  KP_Home,     KP_7    ]       };
+    key  <KP8> {        [  KP_Up,       KP_8    ]       };
+    key  <KP9> {        [  KP_Prior,    KP_9    ]       };
+
+    key  <KP4> {        [  KP_Left,     KP_4    ]       };
+    key  <KP5> {        [  KP_Begin,    KP_5    ]       };
+    key  <KP6> {        [  KP_Right,    KP_6    ]       };
+
+    key  <KP1> {        [  KP_End,      KP_1    ]       };
+    key  <KP2> {        [  KP_Down,     KP_2    ]       };
+    key  <KP3> {        [  KP_Next,     KP_3    ]       };
+
+    key <KPEN> {        [       KP_Enter        ]       };
+    key <KPEQ> {        [       KP_Equal        ]       };
+
+    key <MUTE> { [ SunAudioMute,	SunVideoDegauss		]	};
+    key <VOL-> { [ SunAudioLowerVolume, SunVideoLowerBrightness ]	};
+    key <VOL+> { [ SunAudioRaiseVolume, SunVideoRaiseBrightness	]	};
+    key <POWR> { [ SunPowerSwitch,	SunPowerSwitchShift	]	};
+
+    key <LALT> { [ Alt_L                ]                       };
+    key <RALT> { [ Mode_switch          ]                       };
+    key <ALGR> { [ Mode_switch          ]                       };
+    key <LMTA> { [ Meta_L               ]                       };
+    key <RMTA> { [ Meta_R               ]                       };
+    key <COMP> { [ Multi_key            ]                       };
+
+};
+
+// Map the keys to the XFree86 key names instead of the Sun key names
+partial
+xkb_symbols "xf86keynames" {
+    key <STOP> { [ XF86Stop	],	[ F11	]	};
+    key <AGAI> { [ Redo		],	[ F12	]	};
+    key <PROP> { [ SunProps	],	[ F13	]	};
+    key <UNDO> { [ Undo		],	[ F14	]	};
+    key <FRNT> { [ SunFront	],	[ F15	]	};
+    key <COPY> { [ XF86Copy	],	[ F16	]	};
+    key <OPEN> { [ XF86Open	],	[ F17	]	};
+    key <PAST> { [ XF86Paste	],	[ F18	]	};
+    key <FIND> { [ Find		],	[ F19	]	};
+    key <CUT>  { [ XF86Cut	],	[ F20	]	};
+
+    key <MUTE> { [ XF86AudioMute,	SunVideoDegauss		]	};
+    key <VOL-> { [ XF86AudioLowerVolume,SunVideoLowerBrightness ]	};
+    key <VOL+> { [ XF86AudioRaiseVolume,SunVideoRaiseBrightness	]	};
+    key <POWR> { [ XF86Sleep,		XF86PowerDown	]	};
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/sw	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,173 @@
+// $XdotOrg: $
+//
+// 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.
+//
+xkb_symbols "type4de" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+    key <BKSL> { [ less, braceleft      ]                       };
+
+    key <BRCR> { [ greater, braceright  ]                       };
+    key <DELE> { [ Delete               ]                       };
+
+    key <AE01> { [ 1, plus              ], [exclam      ]       };
+    key <AE02> { [ 2, quotedbl          ], [at          ]       };
+    key <AE03> { [ 3, asterisk          ], [numbersign  ]       };
+    key <AE04> { [ 4, ccedilla          ], [cent        ]       };
+    key <AE05> { [ 5, percent           ], [asciitilde  ]       };
+    key <AE06> { [ 6, ampersand         ], [section     ]       };
+    key <AE07> { [ 7, slash             ], [bar         ]       };
+    key <AE08> { [ 8, parenleft         ], [degree      ]       };
+    key <AE09> { [ 9, parenright        ], [backslash   ]       };
+    key <AE10> { [ 0, equal             ], [asciicircum ]       };
+    Key <AE11> { [ quoteright, question ], [quoteleft   ]       };
+    key <AE12> { [ SunFA_Circum, SunFA_Grave    ]               };
+    key <AD03> { [ e, E                 ], [EuroSign    ]       };
+    key <AD06> { [ Z                    ]                       };
+    key <AD11> { [ udiaeresis, egrave   ]                       };
+    key <AD12> { [ SunFA_Diaeresis, SunFA_Acute ]               };
+    key <AC10> { [ odiaeresis, eacute   ]                       };
+    key <AC11> { [ adiaeresis, agrave   ]                       };
+    key <TLDE> { [ dollar, SunFA_Tilde  ], [sterling    ]       };
+    key <LSGT> { [ bracketright, bracketleft   ], [ backslash ] };
+    key <AB01> { [ Y                    ]                       };
+    key <AB07> { [ M, NoSymbol          ], [mu  ]               };
+    key <AB08> { [ comma, semicolon     ]                       };
+    key <AB09> { [ period, colon        ]                       };
+    key <AB10> { [ minus, underscore    ]                       };
+    key <COMP> { [ SunAltGraph          ]                       };
+    key <ALGR> { [ SunCompose           ]                       };
+
+};
+
+xkb_symbols "type4fr" {
+    include "sun/us(type4basic)"
+    // A few keys are different
+    key <BKSL> { [ less, braceleft	]			};
+
+    key <BRCR> { [ greater, braceright  ]                       };
+    key <DELE> { [ Delete               ]                       };
+
+    key <AE01> { [ 1, plus		], [exclam	]	};
+    key <AE02> { [ 2, quotedbl		], [at	 	]	};
+    key <AE03> { [ 3, asterisk		], [numbersign	]	};
+    key <AE04> { [ 4, ccedilla		], [cent	]	};
+    key <AE05> { [ 5, percent		], [asciitilde	]	};
+    key <AE06> { [ 6, ampersand		], [section	]	};
+    key <AE07> { [ 7, slash		], [bar		]	};
+    key <AE08> { [ 8, parenleft		], [degree	]	};
+    key <AE09> { [ 9, parenright	], [backslash	]	};
+    key <AE10> { [ 0, equal		], [asciicircum	]	};
+    Key <AE11> { [ quoteright, question ], [quoteleft	]	};
+    key <AE12> { [ SunFA_Circum, SunFA_Grave	]		};
+    key <AD03> { [ e, E			], [EuroSign	]	};
+    key <AD06> { [ Z			]			};
+    key <AD11> { [ egrave, udiaeresis	]			};
+    key <AD12> { [ SunFA_Diaeresis, SunFA_Acute	]		};
+    key <AC10> { [ eacute, odiaeresis	]			};
+    key <AC11> { [ agrave, adiaeresis	]			};
+    key <TLDE> { [ dollar, SunFA_Tilde	], [sterling	]	};
+    key <LSGT> { [ bracketright, bracketleft   ], [ backslash ] };
+    key <AB01> { [ Y			]			};
+    key <AB07> { [ M, NoSymbol		], [mu	]		};
+    key <AB08> { [ comma, semicolon	]			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, underscore	]			};
+    key <COMP> { [ SunAltGraph		]			};
+    key <ALGR> { [ SunCompose		]			}; 
+
+
+
+};
+
+xkb_symbols "type5fr" {
+
+    key <TLDE> { [ section, degree	]				};
+
+    key <AE01> { [ 1, plus		], [bar				]};
+    key <AE02> { [ 2, quotedbl		], [at	 	]		};
+    key <AE03> { [ 3, asterisk		], [numbersign	]		};
+    key <AE04> { [ 4, ccedilla		], [asciicircum	]		};
+    key <AE05> { [ 5, percent		], [asciitilde	]		};
+    key <AE06> { [ 6, ampersand		], [section	]		};
+    key <AE07> { [ 7, slash		], [bar		]		};
+    key <AE08> { [ 8, parenleft		], [degree	]		};
+    key <AE09> { [ 9, parenright	], [backslash	]		};
+    key <AE10> { [ 0, equal		], [quoteleft	]		};
+    Key <AE11> { [ quoteright, question ], [SunFA_Acute	]		};
+    key <AE12> { [ SunFA_Circum, SunFA_Grave], [ SunFA_Tilde		]};
+    key <AD03> { [ e, E			], [EuroSign	]		};
+    key <AD06> { [ z, Z			]				};
+    key <AD11> { [ egrave, udiaeresis	], [ bracketleft		]};
+    key <AD12> { [ SunFA_Diaeresis, exclam], [ bracketright		]};
+
+    key <AC10> { [ eacute, odiaeresis	]				};
+    key <AC11> { [ agrave, adiaeresis	], [ braceleft			]};
+    key <BKSL> { [ dollar, sterling	], [ braceright			]};
+
+    key <LSGT> { [ less, greater	], [ backslash			]};
+    key <AB01> { [ y, Y			]			};
+    key <AB08> { [ comma, semicolon	]			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, underscore	]			};
+    
+};
+
+xkb_symbols "type5de" {
+
+    key <TLDE> { [ section, degree	]				};
+
+    key <AE01> { [ 1, plus		], [bar				]};
+    key <AE02> { [ 2, quotedbl		], [at	 	]		};
+    key <AE03> { [ 3, asterisk		], [numbersign	]		};
+    key <AE04> { [ 4, ccedilla		], [asciicircum	]		};
+    key <AE05> { [ 5, percent		], [asciitilde	]		};
+    key <AE06> { [ 6, ampersand		], [section	]		};
+    key <AE07> { [ 7, slash		], [bar		]		};
+    key <AE08> { [ 8, parenleft		], [degree	]		};
+    key <AE09> { [ 9, parenright	], [backslash	]		};
+    key <AE10> { [ 0, equal		], [quoteleft	]		};
+    Key <AE11> { [ quoteright, question ], [SunFA_Acute	]		};
+    key <AE12> { [ SunFA_Circum, SunFA_Grave], [ SunFA_Tilde		]};
+    key <AD03> { [ e, E			], [EuroSign	]		};
+    key <AD06> { [ z, Z			]				};
+    key <AD11> { [ udiaeresis, egrave	], [ bracketleft		]};
+    key <AD12> { [ SunFA_Diaeresis, exclam], [ bracketright		]};
+
+    key <AC10> { [ odiaeresis, eacute	]				};
+    key <AC11> { [ adiaeresis, agrave	], [ braceleft			]};
+    key <BKSL> { [ dollar, sterling	], [ braceright			]};
+
+    key <LSGT> { [ less, greater	], [ backslash			]};
+    key <AB01> { [ y, Y			]			};
+    key <AB08> { [ comma, semicolon	]			};
+    key <AB09> { [ period, colon	]			};
+    key <AB10> { [ minus, underscore	]			};
+    
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/tr	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,119 @@
+// $XdotOrg: $
+//
+// 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.
+//
+xkb_symbols "basic" {
+   include "sun/tr(type6Q)"
+};
+
+xkb_symbols "type6Q" {
+
+   key <TLDE> { [ quotedbl, eacute	], [ asciitilde			]};
+   key <AE02> { [ 2, quoteright		]				};
+   key <AE03> { [ 3, asciicircum	], [ numbersign			]};
+   key <AE04> { [ 4, plus		], [ dollar			]};
+   key <AE06> { [ 6, ampersand		]				};
+   key <AE07> { [ 7, slash		], [ braceleft			]};
+   key <AE08> { [ 8, parenleft		], [ bracketright		]};
+   key <AE09> { [ 9, parenright		], [ bracketright		]};
+   key <AE10> { [ 0, equal		], [ braceright			]};
+   key <AE11> { [ asterisk, question	], [ backslash			]};
+   key <AE12> { [ minus, underscore	]				};
+
+   key <AD01> { [ q, Q			], [ at				]};
+   key <AD11> { [ gbreve, Gbreve	], [ gbreve, Gbreve		]};
+   key <AD12> { [ udiaeresis, Udiaeresis], [ asciitilde, Udiaeresis	]};
+
+   key <AC10> { [ scedilla, Scedilla	], [ comma			]};
+   key <AC11> { [ Iabovedot, Iabovedot	], [ Iabovedot, Iabovedot	]};
+   key <BKSL> { [ comma, semicolon	], [ quoteleft			]};
+
+   key <LSGT> { [ less, greater		], [ bar			]};
+   key <AB08> { [ odiaeresis, Odiaeresis], [ odiaeresis, Odiaeresis	]};
+   key <AB09> { [ ccedilla, Ccedilla	], [ ccedilla, Ccedilla		]};
+   key <AB10> { [ period, colon		], [ quotedbl			]};
+   
+};
+
+xkb_symbols "type6F" {
+
+
+   key	<TLDE> { [ plus     ,asterisk		],  [plusminus     ]};
+   key	<AE01> { [ 1	    ,exclam		],  [onesuperior   ]};
+   key	<AE02> { [ 2	    ,quotedbl		],  [twosuperior   ]};
+   key	<AE03> { [ 3	    ,asciicircum  	],  [numbersign    ]};
+   key	<AE04> { [ 4	    ,dollar		],  [onequarter    ]};
+   key	<AE05> { [ 5	    ,percent		],  [onehalf       ]};
+   key	<AE06> { [ 6	    ,ampersand		],  [threequarters ]};
+   key	<AE07> { [ 7	    ,quoteright   	],  [braceleft     ]};
+   key	<AE08> { [ 8	    ,parenleft		],  [bracketleft   ]};
+   key	<AE09> { [ 9	    ,parenright		],  [bracketright  ]};
+   key	<AE10> { [ 0	    ,equal		],  [braceright    ]};
+   key	<AE11> { [ slash    ,question    	],  [backslash     ]};
+   key	<AE12> { [ minus    ,underscore   	],  [bar           ]};
+
+   key  <AD01> { [ f         ,F            ],  [at		]};
+   key  <AD02> { [ g         ,G            ]};
+   key  <AD03> { [ gbreve    ,Gbreve       ],  [gbreve, Gbreve	]};
+   key  <AD04> { [ idotless  ,I            ],  [paragraph	]};
+   key  <AD05> { [ o         ,O            ]};
+   key  <AD06> { [ d         ,D            ],  [yen		]};
+   key  <AD07> { [ r         ,R            ]};
+   key  <AD08> { [ n         ,N            ]};
+   key  <AD09> { [ h         ,H            ],  [degree		]};
+   key  <AD10> { [ p         ,P            ],  [sterling	]};
+   key  <AD11> { [ q         ,Q            ],  [diaeresis	]};
+   key  <AD12> { [ w         ,W            ],  [asciitilde	]};
+   key  <BKSL> { [ x         ,X            ],  [quoteleft	]};
+
+   key  <AC01> { [ u         ,U        	],	[AE			]};
+   key  <AC02> { [ i	     ,Iabovedot	],	[ssharp			]};
+   key  <AC03> { [ e	     ,E  	]};
+   key  <AC04> { [ a	     ,A  	]};
+   key  <AC05> { [ udiaeresis,Udiaeresis]}; 
+   key  <AC06> { [ t	     ,T  	]};
+   key  <AC07> { [ k	     ,K  	]};
+   key  <AC08> { [ m	     ,M  	]};
+   key  <AC10> { [ y         ,Y		],	[quoteright		]};
+   key  <AC11> { [ scedilla  ,Scedilla	],	[numbersign,   Scedilla	]};
+
+   key  <LSGT> { [ less, greater           ],  [bar		]};
+   key  <AB01> { [ j           ,J          ],  [less		]};
+   key  <AB02> { [ odiaeresis  ,Odiaeresis ],  [greater		]};
+   key  <AB03> { [ v           ,V          ],  [cent		]};
+   key  <AB04> { [ c	       ,C          ]};
+   key  <AB05> { [ ccedilla    ,Ccedilla   ],  [ccedilla, Ccedilla	]};
+   key  <AB06> { [ z	       ,Z          ]};
+   key  <AB07> { [ s           ,S          ],  [mu		]};
+   key  <AB08> { [ b           ,B          ],  [multiply	]};
+   key  <AB09> { [ period      ,colon      ],  [division	]};
+   key  <AB10> { [ comma       ,semicolon  ]};
+
+
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/tuv	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,241 @@
+// $XdotOrg: $
+//
+// 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.
+//
+// $TOG: us /main/5 1998/02/10 13:45:06 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//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.
+//
+// US/ASCII layout for a Type 4 Sun keyboard
+xkb_symbols "type4basic" {
+    include "us(basic)"
+
+    key <RTSH> { [ Shift_R		]			};
+    key <LALT> { [ Alt_L		]			};
+    key <ALGR> { [ Mode_switch		]			};
+    key <LMTA> { [ Meta_L		]			};
+    key <RMTA> { [ Meta_R		]			};
+    key <LNFD> { [ Linefeed		]			};
+    key <COMP> { [ Multi_key		]			};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <STOP> { [ L1,	L1		], [ SunStop	]	};
+    key <AGAI> { [ L2,	L2		], [ SunAgain	]	};
+    key <PROP> { [ L3,	L3		], [ SunProps	]	};
+    key <UNDO> { [ L4,	L4		], [ SunUndo	]	};
+    key <FRNT> { [ L5,	L5		], [ SunFront	]	};
+    key <COPY> { [ L6,	L6		], [ SunCopy	]	};
+    key <OPEN> { [ L7,	L7		], [ SunOpen	]	};
+    key <PAST> { [ L8,	L8		], [ SunPaste	]	};
+    key <FIND> { [ L9,	L9		], [ SunFind	]	};
+    key <CUT>  { [ L10,	L10		], [ SunCut	]	};
+    // End "Function" section
+
+    // Begin "Editing" section
+    key <PRSC> { [ R2,	R2		], [ Print		] };
+    key <SCLK> { [ R3,	R3		], [ Scroll_Lock, Break	] };
+    key <PAUS> { [ R1,	R1		], [ Pause		] };
+    key <DELE> { [ Delete		]			};
+    key <HELP> { [ Help			]			};
+
+    // End "Editing" section, begin "Keypad"
+    key <NMLK> { [ Num_Lock 		]			};
+    key <KPEQ> { [ R4,	R4 		], [ KP_Equal		] };
+    key <KPDV> { [ R5,	R5		], [ KP_Divide		] };
+    key <KPMU> { [ R6,	R6		], [ KP_Multiply	] };
+    key <KPSU> { [ KP_Subtract		]			};
+
+    key  <KP7> { [ R7,	R7		], [ KP_7, Home		] };
+    key  <KP8> { [ Up, R8               ], [ KP_8               ] };
+//    key  <KP8> { [ R8,	R8		], [ KP_8		] };
+    key  <KP9> { [ R9,	R9		], [ KP_9, Prior	] };
+    key <KPAD> { [ KP_Add		]			};
+
+    key  <KP4> { [ Left, R10		], [ KP_4		] };
+    key  <KP5> { [ R11,	R11		], [ KP_5		] };
+    key  <KP6> { [ Right, R12		], [ KP_6		] };
+
+    key  <KP1> { [ R13,	R13		], [ KP_1,	End	] };
+    key  <KP2> { [ Down, R14		], [ KP_2		] };
+    key  <KP3> { [ R15,	R15		], [ KP_3,	Next	] };
+    key <KPEN> { [ KP_Enter		]			}; 
+    key  <KP0> { [ KP_Insert, KP_Insert], [ KP_0		]	};
+    key <KPDL> { [ Delete, Delete	], [ KP_Decimal ]	};
+    // End "Keypad" section
+
+
+    // begin modifier mappings
+    modifier_map Shift  	{ Shift_R, Shift_L };
+    modifier_map Mod1   	{ Meta_L, Meta_R };
+    modifier_map Mod2   	{ Mode_switch };
+    modifier_map Mod3   	{ Num_Lock };
+    modifier_map Mod4		{ Alt_L };
+};
+
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+
+    // A few alphanumeric keys are different
+    key <AE04> { [ 4, dollar		], [ EuroSign	]	};
+    key <AE05> { [ 5, percent		], [ EuroSign	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+};
+
+// US/ASCII layout for a Type 5 Sun keyboard
+xkb_symbols "type5basic" {
+    include "us(basic)"
+
+    key <RTSH> { [ Shift_R		]	};
+    key <LALT> { [ Alt_L		]	};
+    key <ALGR> { [ Mode_switch		]	};
+    key <LMTA> { [ Meta_L		]	};
+    key <RMTA> { [ Meta_R		]	};
+    key <COMP> { [ Multi_key		]	};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <STOP> { [ L1, L1		], [ SunStop	]	};
+    key <AGAI> { [ L2, L2		], [ SunAgain	]	};
+    key <PROP> { [ L3, L3		], [ SunProps	]	};
+    key <UNDO> { [ L4, L4		], [ SunUndo	]	};
+    key <FRNT> { [ L5, L5		], [ SunFront	]	};
+    key <COPY> { [ L6, L6		], [ SunCopy	]	};
+    key <OPEN> { [ L7, L7		], [ SunOpen	]	};
+    key <PAST> { [ L8, L8		], [ SunPaste	]	};
+    key <FIND> { [ L9, L9		], [ SunFind	]	};
+    key <CUT>  { [ L10, L10		], [ SunCut	]	};
+    // End "Function" section
+
+    // Begin "Editing" section
+    key <PRSC> { [ R2, R2 		], [ Print, SunSys_Req	]	};
+    key <SCLK> { [ R3, R3		], [ Scroll_Lock	]	};
+    key <PAUS> { [ R1, R1		], [ Pause, Break	]	};
+    key <LEFT> { [ Left			]			};
+    key <RGHT> { [ Right		]			};
+    key <UP>   { [ Up			]			};
+    key <DOWN> { [ Down			]			};
+
+    key <DELE> { [ Delete		]			};
+    key <INS>  { [ Insert		]			};
+    key <PGUP> { [ Prior		]			};
+    key <PGDN> { [ Next			]			};
+    key <HOME> { [ Home			]			};
+    key <END>  { [ End			]			};
+    key <HELP> { [ Help			]			};
+
+    // End "Editing" section, begin "Keypad"
+    key <NMLK> { [ Num_Lock 		]				};
+    key <KPDV> { [ R5, R5		], [ KP_Divide	]	};
+    key <KPMU> { [ R6, R6		], [ KP_Multiply	]	};
+    key <KPSU> { [ R4, R4		], [ KP_Subtract	]	};
+
+    key  <KP7> { [ R7, R7		], [ KP_7, Home		]	};
+    key  <KP8> { [ Up, R8		], [ KP_8		]	};
+    key  <KP9> { [ R9, R9		], [ KP_9, Prior	]	};
+    key <KPAD> { [ KP_Add		]				};
+
+    key  <KP4> { [ Left, R10		], [ KP_4		]	};
+    key  <KP5> { [ R11,	R11		], [ KP_5		]	};
+    key  <KP6> { [ Right, R12		], [ KP_6		]	};
+
+    key  <KP1> { [ R13,	R13		], [ KP_1, End		]	};
+    key  <KP2> { [ Down, R14		], [ KP_2		]	};
+    key  <KP3> { [ R15,	R15		], [ KP_3		]	};
+    key <KPEN> { [ KP_Enter		]				};
+
+    key  <KP0> { [ KP_Insert, KP_Insert	], [ KP_0		]	};
+    key <KPDL> { [ KP_Delete, KP_Delete ], [ KP_Decimal 	]	};
+    // End "Keypad" section, 
+    // begin "four keys up on the right"
+
+    key <MUTE> { [ SunAudioMute,	SunVideoDegauss		]	};
+    key <VOL-> { [ SunAudioLowerVolume,	SunVideoLowerBrightness ]	};
+    key <VOL+> { [ SunAudioRaiseVolume,	SunVideoRaiseBrightness	]	};
+    key <POWR> { [ SunPowerSwitch,	SunPowerSwitchShift	]	};
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_R };
+    modifier_map Mod1	{ Meta_L, Meta_R };
+    modifier_map Mod2	{ Alt_R };
+    modifier_map Mod3	{ Num_Lock };
+    modifier_map Mod4	{ Alt_L };
+};
+
+xkb_symbols "type5" {
+    include "sun/us(type5basic)"
+
+    // A few alphanumeric keys are different
+    key <AE04> { [ 4, dollar		], [ EuroSign	]	};
+    key <AE05> { [ 5, percent		], [ EuroSign	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]	};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/tw	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,59 @@
+// $XdotOrg: $
+//
+// Copyright 2005 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.
+//
+//
+// Taiwanese layout for a Type 4 Sun keyboard
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]		};
+
+//    key <LNFD> { [ Hangul		]			};
+//    key <RALT> { [ Linefeed		]			};
+    key <COMP> { [ Henkan_Mode		]			};
+
+};
+
+// Taiwanese layout for a Type 5 Sun keyboard
+xkb_symbols "type5" {
+
+    // A few keys are different
+    key <ALGR> { [ Henkan_Mode		]			};
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]		};
+
+};
+
+// Taiwanese layout for a Type 6 Sun keyboard
+partial
+xkb_symbols "type6" {
+    // A few keys are different from US layout - only those are shown here
+    key <ALGR> { [ Henkan_Mode		]			};
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]		};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/sun/us	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,347 @@
+// $XdotOrg: $
+//
+// 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.
+//
+// $TOG: us /main/5 1998/02/10 13:45:06 kaleb $
+// Sun: @(#)us	1.5	03/04/21 SMI
+//
+//Copyright 1996, 1998  The Open Group
+//
+//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.
+//
+
+// Symbols shared by all Sun Keyboard layouts
+xkb_symbols "sunbasic" {
+    include "srvr_ctrl(stdkeypad)"
+    include "us(basic)"
+
+    key <RTSH> { [ Shift_R		]			};
+    key <LALT> { [ Alt_L		]			};
+    key <ALGR> { [ Mode_switch		]			};
+    key <LMTA> { [ Meta_L		]			};
+    key <RMTA> { [ Meta_R		]			};
+    key <RCTL> { [ Control_R		]			};
+    key <COMP> { [ Multi_key		]			};
+    // End alphanumeric section
+
+    // Begin "Function" section
+    key <FK01> { [ F1			]			};
+    key <FK02> { [ F2			]			};
+    key <FK03> { [ F3			]			};
+    key <FK04> { [ F4			]			};
+    key <FK05> { [ F5			]			};
+    key <FK06> { [ F6			]			};
+    key <FK07> { [ F7			]			};
+    key <FK08> { [ F8			]			};
+    key <FK09> { [ F9			]			};
+    key <FK10> { [ F10			]			};
+    key <FK11> { [ SunF36		]			};
+    key <FK12> { [ SunF37		]			};
+    key <STOP> { [ L1,	L1		], [ SunStop	]	};
+    key <AGAI> { [ L2,	L2		], [ SunAgain	]	};
+    key <PROP> { [ L3,	L3		], [ SunProps	]	};
+    key <UNDO> { [ L4,	L4		], [ SunUndo	]	};
+    key <FRNT> { [ L5,	L5		], [ SunFront	]	};
+    key <COPY> { [ L6,	L6		], [ SunCopy	]	};
+    key <OPEN> { [ L7,	L7		], [ SunOpen	]	};
+    key <PAST> { [ L8,	L8		], [ SunPaste	]	};
+    key <FIND> { [ L9,	L9		], [ SunFind	]	};
+    key <CUT>  { [ L10,	L10		], [ SunCut	]	};
+    // End "Function" section
+
+    // Begin "Editing" section
+    key <DELE> { [ Delete		]			};
+    key <HELP> { [ Help			]			};
+
+    // End "Editing" section, begin "Keypad"
+
+    key <NMLK> {	[  Num_Lock, Pointer_EnableKeys		]	};
+
+    // This default section uses the same symbols as other XKB implementations
+    // for greater compatibility & AccessX MouseKeys support, but it is 
+    // different than the traditional Sun key mappings that date back to the
+    // Sun Type 2 keyboard, in which the right side numpad were "R" function
+    // keys.  To restore the original behavior, comment out this section and
+    // uncomment the section below that lists the R key mappings.
+    key <KPDV> {	[  KP_Divide		]	};
+    key <KPMU> {	[  KP_Multiply		]	};
+    key <KPSU> {	[  KP_Subtract		]	};
+
+    key  <KP7> {	[  KP_Home,	KP_7	]	};
+    key  <KP8> {	[  KP_Up,	KP_8	]	};
+    key  <KP9> {	[  KP_Prior,	KP_9	]	};
+    key <KPAD> {	[  	KP_Add		]	};
+
+    key  <KP4> {	[  KP_Left,	KP_4	]	};
+    key  <KP5> {	[  KP_Begin,	KP_5	]	};
+    key  <KP6> {	[  KP_Right,	KP_6	]	};
+
+    key  <KP1> {	[  KP_End,	KP_1	]	};
+    key  <KP2> {	[  KP_Down,	KP_2	]	};
+    key  <KP3> {	[  KP_Next,	KP_3	]	};
+    key <KPEN> {	[  	KP_Enter	]	};
+
+    key  <KP0> {	[  KP_Insert,	KP_0	]	};
+    key <KPDL> {  [  KP_Delete,	KP_Decimal ]	};
+
+// End New Keypad section - Begin Sun traditional Keypad section
+
+//    key  <KP7> { [ R7,	R7		], [ KP_7, Home		] };
+//    key  <KP8> { [ Up, R8               ], [ KP_8               ] };
+//    key  <KP9> { [ R9,	R9		], [ KP_9, Prior	] };
+//    key <KPAD> { [ KP_Add		]			};
+//
+//    key  <KP4> { [ Left, R10		], [ KP_4		] };
+//    key  <KP5> { [ R11,	R11		], [ KP_5		] };
+//    key  <KP6> { [ Right, R12		], [ KP_6		] };
+//
+//    key  <KP1> { [ R13,	R13		], [ KP_1,	End	] };
+//    key  <KP2> { [ Down, R14		], [ KP_2		] };
+//    key  <KP3> { [ R15,	R15		], [ KP_3,	Next	] };
+//    key <KPEN> { [ KP_Enter		]			}; 
+//    key  <KP0> { [ KP_Insert, KP_Insert], [ KP_0		]	};
+//    key <KPDL> { [ Delete, Delete	], [ KP_Decimal ]	};
+
+    // End "Keypad" section
+
+    modifier_map Control{ Control_R };
+
+};
+
+// US/ASCII layout for a Type 4 Sun keyboard
+xkb_symbols "type4basic" {
+    include "sun/us(sunbasic)"
+
+    // A few alphanumeric keys are different
+    key <AE04> { [ 4, dollar		], [ EuroSign	]	};
+    key <AE05> { [ 5, percent		], [ EuroSign	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+
+    key <LNFD> { [ Linefeed		]			};
+
+    // Begin "Editing" section
+    key <PRSC> { [ R2,	R2		], [ Print		] };
+    key <SCLK> { [ R3,	R3		], [ Scroll_Lock, Break	] };
+    key <PAUS> { [ R1,	R1		], [ Pause		] };
+
+    // End "Editing" section, begin "Keypad"
+    key <KPEQ> { [ R4,	KP_Equal	], [ KP_Equal		] };
+
+    // begin modifier mappings
+    modifier_map Shift  	{ Shift_R, Shift_L };
+    modifier_map Mod1   	{ Meta_L, Meta_R };
+    modifier_map Mod2   	{ Mode_switch };
+    modifier_map Mod3   	{ Num_Lock };
+    modifier_map Mod4		{ Alt_L };
+
+};
+
+xkb_symbols "type4" {
+    include "sun/us(type4basic)"
+
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]	};
+};
+
+// US/ASCII layout for a Type 5 Sun keyboard
+xkb_symbols "type5basic" {
+    include "sun/us(sunbasic)"
+
+    // Begin "Editing" section
+    key <PRSC> { [ R2, R2 		], [ Print, SunSys_Req	]	};
+    key <SCLK> { [ R3, R3		], [ Scroll_Lock	]	};
+    key <PAUS> { [ R1, R1		], [ Pause, Break	]	};
+
+    key <LEFT> { [ Left			]			};
+    key <RGHT> { [ Right		]			};
+    key <UP>   { [ Up			]			};
+    key <DOWN> { [ Down			]			};
+
+    key <DELE> { [ Delete		]			};
+    key <INS>  { [ Insert		]			};
+    key <PGUP> { [ Prior		]			};
+    key <PGDN> { [ Next			]			};
+    key <HOME> { [ Home			]			};
+    key <END>  { [ End			]			};
+    key <HELP> { [ Help			]			};
+
+    // End "Editing" section
+
+    // begin "four keys up on the right"
+    key <MUTE> { [ SunAudioMute,	SunVideoDegauss		]	};
+    key <VOL-> { [ SunAudioLowerVolume,	SunVideoLowerBrightness ]	};
+    key <VOL+> { [ SunAudioRaiseVolume,	SunVideoRaiseBrightness	]	};
+    key <POWR> { [ SunPowerSwitch,	SunPowerSwitchShift	]	};
+
+    // begin modifier mappings
+    modifier_map Shift          { Shift_R, Shift_L };
+    modifier_map Mod1           { Alt_L };
+    modifier_map Mod2           { Alt_R, Mode_switch };
+    modifier_map Mod3           { Num_Lock };
+    modifier_map Mod4           { Meta_L, Meta_R };
+};
+
+xkb_symbols "type5" {
+    include "sun/us(type5basic)"
+
+    // A few alphanumeric keys are different
+    key <AE04> { [ 4, dollar		], [ EuroSign	]	};
+    key <AE05> { [ 5, percent		], [ EuroSign	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]	};
+};
+
+xkb_symbols "type6" {
+    include "sun/us(type5)"
+};
+
+
+// US/ASCII layout for a Type 5 Sun keyboard
+xkb_symbols "type5hobobasic" {
+    include "sun/us(type5basic)"
+};
+
+xkb_symbols "type5hobo" {
+    include "sun/us(type5hobobasic)"
+
+    // A few alphanumeric keys are different
+    key <AE04> { [ 4, dollar		], [ EuroSign 	]	};
+    key <AE05> { [ 5, percent		], [ EuroSign	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+    key <BKSL> { [ backslash, bar	], [ brokenbar	]	};
+
+    // Here is the hobo keypad:
+
+    key <AE07> { [ 7, ampersand	], [ NoSymbol, NoSymbol	], [ KP_7	] };
+    key <AE08> { [ 8, asterisk	], [ NoSymbol, NoSymbol	], [ KP_8	] };
+    key <AE09> { [ 9, parenleft	], [ NoSymbol, NoSymbol	], [ KP_9	] };
+    key <AE10> { [ 0, parenright], [ NoSymbol, NoSymbol	], [ KP_Multiply] };
+
+    key <AD07> { [ u, U		], [ NoSymbol, NoSymbol	], [ KP_4	] };
+    key <AD08> { [ i, I		], [ NoSymbol, NoSymbol	], [ KP_5	] };
+    key <AD09> { [ o, O		], [ NoSymbol, NoSymbol	], [ KP_6	] };
+    key <AD10> { [ p, P		], [ NoSymbol, NoSymbol	], [ KP_Subtract]};
+
+    key <AC07> { [ j, J		], [ NoSymbol, NoSymbol	], [ KP_1	] };
+    key <AC08> { [ k, K		], [ NoSymbol, NoSymbol	], [ KP_2	] };
+    key <AC09> { [ l, L		], [ NoSymbol, NoSymbol	], [ KP_3	] };
+    key <AC10> { [ semicolon, colon], [ NoSymbol, NoSymbol], [ KP_Add	] };
+
+    key <RTRN> { [ Return	], [ NoSymbol, NoSymbol], [ KP_Enter	] };
+
+    key <AB07> { [ m, M		], [ NoSymbol, NoSymbol	], [ KP_0	] };
+
+    key <AB09> { [ period, greater], [ NoSymbol, NoSymbol], [ KP_Decimal] };
+    key <AB10> { [ slash, question], [ NoSymbol, NoSymbol], [ KP_Divide	] };
+
+};
+
+xkb_symbols "pc101" {
+    include "us(pc101)"
+    key <RALT> { [ Mode_switch, Meta_R	] };
+};
+
+xkb_symbols "pc102" {
+    include "us(pc102)"
+    key <RALT> { [ Mode_switch, Meta_R	] };
+};
+
+xkb_symbols "pc104" {
+    include "us(pc104)"
+};
+
+xkb_symbols "pc101currency" {
+
+    key <AE04> { [ 4, dollar		], [ EuroSign	]	};
+    key <AE05> { [ 5, percent		], [ EuroSign	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+    key <BKSL> { [ backslash, bar	], [ brokenbar			]};
+};
+
+xkb_symbols "US101A_Sun" {
+
+    key <AE04> { [ 4, dollar		], [ EuroSign	]	};
+    key <AE05> { [ 5, percent		], [ EuroSign	]	};
+    key <AD03> { [ e, E			], [ EuroSign	]	};
+    key <BKSL> { [ backslash, bar	], [ brokenbar			]};
+
+    // Begin "Editing" section
+    key <PRSC> { [ L5, L5		], [ Print, SunSys_Req 		]};
+    key <SCLK> { [ L7, L7		], [  Scroll_Lock		]};
+    key <PAUS> { [ L1, L1		], [ Pause, Break 		]};
+    key  <INS> { [ L8, L8		], [  Insert			]};
+    key <HOME> { [ L6, L6		], [  Home			]};
+    key <PGUP> { [ L3, L3		], [  Prior			]};
+
+
+    key <DELE> { [ L10, L10		], [ Delete			]};
+    key  <END> { [ L9, L9		], [  End			]};
+    key <PGDN> { [ L4, L4		], [  Next			]};
+
+    key   <UP> {	[  Up			]	};
+    key <LEFT> {	[  Left			]	};
+    key <DOWN> {	[  Down			]	};
+    key <RGHT> {	[  Right		]	};
+
+    key <KPDV> { [ R5, R5		], [ KP_Divide	]	};
+    key <KPMU> { [ R6, R6		], [ KP_Multiply	]	};
+
+    key  <KP7> { [ R7, KP_7		], [ KP_7, Home		]	};
+    key  <KP8> { [ KP_Up, KP_8		], [ KP_8		]	};
+    key  <KP9> { [ R9, KP_9		], [ KP_9, Prior	]	};
+    key <KPAD> { [ KP_Add		]				};
+
+    key  <KP4> { [ KP_Left, KP_4	], [ KP_4		]	};
+    key  <KP5> { [ R11,	KP_5		], [ KP_5		]	};
+    key  <KP6> { [ KP_Right, KP_6	], [ KP_6		]	};
+
+    key  <KP1> { [ R13,	KP_1		], [ KP_1, End		]	};
+    key  <KP2> { [ KP_Down, KP_2	], [ KP_2		]	};
+    key  <KP3> { [ R15,	KP_3		], [ KP_3, Next		]	};
+    key <KPEN> { [ KP_Enter		]				};
+
+    key <LALT> { [ Meta_L		]				};
+    key <RALT> { [ Alt_L		]				};
+    key <RCTL> { [ Multi_key		]				};
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/tr	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,84 @@
+// $XFree86: xc/programs/xkbcomp/symbols/tr,v 1.1 2000/12/06 20:18:08 eich Exp $
+// Converted keytable file to xkb/symbols/ file
+// with mk_xkb by [email protected] Tue Sep 30 01:21:59 MET DST 1997
+
+//  turkish "Q" keyboard, copyed from LyX turkish keyboard description
+//  as the names of some chars in iso-8859-9 are not consistent whith
+//  the rest of latin iso-8859-* I declare them in hexa (ugly, but what else?)
+//
+//  Pablo Saratxaga <[email protected]>
+
+
+default partial alphanumeric_keys
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Turkish "Q" (computer modern) keybaord
+
+    // Alphanumeric section
+    name[Group1]= "Turkish \"Q\" (computer modern)";
+
+    key <AE02> {	[         2,	apostrophe	],
+			[        at			]	};
+    key <AE03> {	[         3,	dead_circumflex	],
+			[ numbersign			]	};
+    key <AE04> {	[         4,	plus     	],
+			[    dollar			]	};
+    key <AE06> {	[         6,	ampersand	],
+			[ asciicircum			]	};
+    key <AE07> {	[         7,	slash    	],
+			[ braceleft			]	};
+    key <AE08> {	[         8,	parenleft	],
+			[ bracketleft			]	};
+    key <AE09> {	[         9,	parenright	],
+			[ bracketright			]	};
+    key <AE10> {	[         0,	equal    	],
+			[ braceright			]	};
+    key <AE11> {	[  asterisk,	question 	],
+			[ backslash			]	};
+    key <AE12> {	[     minus,	underscore	]	};
+    key <AD08> {	[  idotless,    I		]	};
+    key <AD11> {	[    gbreve,    Gbreve		]	};
+    key <AD12> {	[ udiaeresis,	Udiaeresis	],
+			[ asciitilde			]	};
+    key <AC10> {	[   scedilla,   Scedilla	]	};
+    key <AC11> {	[         i,    Iabovedot	]	};
+    key <TLDE> {	[ backslash,	quotedbl 	],
+			[ asciitilde			]	};
+    key <BKSL> {	[     comma,	semicolon	],
+			[       bar			]	};
+    key <AB08> {	[ odiaeresis,	Odiaeresis	],
+			[      less			]	};
+    key <AB09> {	[  ccedilla,	Ccedilla 	],
+			[   greater			]	};
+    key <AB10> {	[    period,	colon    	]	};
+    key <LSGT> {	[      less,	greater  	],
+			[       bar			]	};
+
+    // End alphanumeric section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
+partial alphanumeric_keys
+xkb_symbols "Sundeadkeys" {
+
+    // For naming consistency
+
+    include "tr(basic)"
+
+};
+
+partial alphanumeric_keys
+xkb_symbols "sundeadkeys" {
+
+    // For naming consistency
+
+    include "tr(Sundeadkeys)"
+
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xkbcomp/symbols/tr_f	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,153 @@
+// Converted keytable file to xkb/symbols/ file
+// with mk_xkb by [email protected] Tue Sep 30 01:29:39 MET DST 1997
+
+//  turkish "F" keyboard, copyed from LyX turkish keyboard description
+//  right Ctrl key switches to an almost US keyboard (number row is mangled
+//  us keyboard mode, this to allow simple access by AltGr while in turkish
+//  mode to all needed symbols)
+//  as the names of some chars in iso-8859-9 are not consistent whith
+//  the rest of latin iso-8859-* I declare them in hexa (ugly, but what else?)
+//
+//  Pablo Saratxaga <[email protected]>
+//  FIXME: I'm not sure about the ISO_* stuff, the original *.map uses
+//         AltGr_Lock as modifier.
+
+partial alphanumeric_keys
+xkb_symbols "toggle" {
+    include "tr_f(basic)"
+    key <RCTL> {        [  ISO_Next_Group,       Caps_Lock      ]       };
+};
+partial alphanumeric_keys
+xkb_symbols "shift_toggle" {
+    include "tr_f(basic)"
+    key <LFSH>  {       [       Shift_L,        ISO_Prev_Group ]        };
+    key <RTSH>  {       [       Shift_R,        ISO_Next_Group ]        };
+};
+
+default partial alphanumeric_keys
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Turkish "F" (traditional) keyboard
+
+    // Alphanumeric section
+    name[Group1]= "Turkish \"F\" (traditional)";
+    name[Group2]= "US/ASCII";
+
+    key <AE02> {	[         2,	apostrophe	],
+			[        at			]	};
+    key <AE03> {	[         3,	dead_circumflex	],
+			[ numbersign			]	};
+    key <AE04> {	[         4,	plus     	],
+			[    dollar			]	};
+    key <AE06> {	[         6,	ampersand	],
+			[ asciicircum			]	};
+    key <AE07> {	[         7,	slash    	],
+			[ braceleft			]	};
+    key <AE08> {	[         8,	parenleft	],
+			[ bracketleft			]	};
+    key <AE09> {	[         9,	parenright	],
+			[ bracketright			]	};
+    key <AE10> {	[         0,	equal    	],
+			[ braceright			]	};
+    key <AE11> {	[  asterisk,	question 	],
+			[ backslash,    underscore	]	};
+    key <AE12> {	[     minus,	underscore	],
+			[     equal,    plus		]	};
+    key <AD01> {	[         f,	F        	],
+			[         q,	Q        	]	};
+    key <AD02> {	[         g,	G        	],
+			[         w,	W        	]	};
+    key <AD03> {	[    gbreve,	Gbreve		],
+			[         e,	E        	]	};
+    key <AD04> {	[  idotless	I		],      
+			[         r,	R        	]	};
+    key <AD05> {	[         o,	O        	],
+			[         t,	T        	]	};
+    key <AD06> {	[         d,	D        	],
+			[         y,	Y        	]	};
+    key <AD07> {	[         r,	R        	],
+			[         u,	U        	]	};
+    key <AD08> {	[         n,	N        	],
+			[         i,	I        	]	};
+    key <AD09> {	[         h,	H        	],
+			[         o,	O        	]	};
+    key <AD10> {	[         p,    P	 	]	};
+    key <AD11> {	[         q,	Q        	],
+			[ bracketleft,	braceleft	]	};
+    key <AD12> {	[         w,	W        	],
+			[ bracketright,	braceright	]	};
+    key <AC01> {	[         u,	U        	],
+			[         a,	A        	]	};
+    key <AC02> {	[         i,	Iabovedot	],
+			[         s,	S        	]	};
+    key <AC03> {	[         e,	E        	],
+			[         d,	D        	]	};
+    key <AC04> {	[         a,	A        	],
+			[         f,	F        	]	};
+    key <AC05> {	[         g,    G		]	};
+    key <AC06> {	[         t,	T        	],
+			[         h,	H        	]	};
+    key <AC07> {	[         k,	K        	],
+			[         j,	J        	]	};
+    key <AC08> {	[         m,	M        	],
+			[         k,	K        	]	};
+    key <AC09> {	[         l,    L		]	};
+    key <AC10> {	[         y,	Y        	],
+			[ semicolon,	colon    	]	};
+    key <AC11> {	[  scedilla,	Scedilla	],
+			[ apostrophe,	quotedbl 	]	};
+    key <TLDE> {	[ backslash,	quotedbl 	],
+			[     grave,	asciitilde	]	};
+    key <BKSL> {	[         x,	X        	],
+			[ backslash,	bar      	]	};
+    key <AB01> {	[         j,	J        	],
+			[         z,	Z        	]	};
+    key <AB02> {	[ odiaeresis,	Odiaeresis	],
+			[         x,	X        	]	};
+    key <AB03> {	[         v,	V        	],
+			[         c,	C        	]	};
+    key <AB04> {	[         c,	C        	],
+			[         v,	V        	]	};
+    key <AB05> {	[  ccedilla,	Ccedilla 	],
+			[         b,	B        	]	};
+    key <AB06> {	[         z,	Z        	],
+			[         n,	N        	]	};
+    key <AB07> {	[         s,	S        	],
+			[         m,	M        	]	};
+    key <AB08> {	[         b,	B        	],
+			[     comma,	less     	]	};
+    key <AB09> {	[    period,	colon    	],
+			[    period,	greater  	]	};
+    key <AB10> {	[     comma,	semicolon	],
+			[     slash,	question 	]	};
+    key <LSGT> {	[      less,	greater  	],
+			[      bar			]	};
+
+    // End alphanumeric section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock ISO_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
+partial alphanumeric_keys
+xkb_symbols "Sundeadkeys" {
+
+    // For naming consistency
+
+    include "tr_f(basic)"
+
+};
+
+partial alphanumeric_keys
+xkb_symbols "sundeadkeys" {
+
+    // For naming consistency
+
+    include "tr_f(Sundeadkeys)"
+
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xrandr/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,42 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/openwin/lib -R/usr/openwin/lib -L/usr/openwin/sfw/lib -R/usr/openwin/sfw/lib -L$(BUILDLIBDIR) -R/usr/X11/lib
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-client-programs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xvidtune/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,42 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/openwin/lib -L$(BUILDLIBDIR) -R/usr/X11/lib
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-client-programs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/xvinfo/localdefines	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,42 @@
+XCOMM ########################################################################
+XCOMM
+XCOMM Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, and/or sell copies of the Software, and to permit persons
+XCOMM to whom the Software is furnished to do so, provided that the above
+XCOMM copyright notice(s) and this permission notice appear in all copies of
+XCOMM the Software and that both the above copyright notice(s) and this
+XCOMM permission notice appear in supporting documentation.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+XCOMM OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+XCOMM HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+XCOMM INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+XCOMM FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+XCOMM NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+XCOMM WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of a copyright holder
+XCOMM shall not be used in advertising or otherwise to promote the sale, use
+XCOMM or other dealings in this Software without prior written authorization
+XCOMM of the copyright holder.
+XCOMM
+XCOMM ########################################################################
+XCOMM
+XCOMM ident "@(#)localdefines 1.2     05/11/08 SMI"
+XCOMM
+
+/* Override library paths for initial server-only Solaris builds */
+#define LdPreLib -L/usr/openwin/lib -L$(BUILDLIBDIR) -R/usr/X11/lib
+
+XCOMM Include ARC-required External stability statement in man pages
+SUNMANDEFS  = -D__package__=SUNWxorg-client-programs -D__stability__=External
+SUNMANSTART = $(SUNMAN_TABLE_PREPEND)
+SUNMANEND   = $(SUNMAN_ATTRIBUTES_APPEND)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/buildit	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,114 @@
+#!/bin/sh
+#
+# buildit
+# Script for building OpenSolaris X Consolidation
+#
+###########################################################################
+#
+# Copyright 2006 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.
+#
+###########################################################################
+#
+# ident "@(#)buildit	1.1	06/03/31 SMI"
+#
+
+
+CLOBBER=0
+MAKE_PKGS=0
+XORG_BUILD_ARGS="$*"
+
+set -- `getopt cp $*`
+if [ $? != 0 ]
+then
+    echo USAGE: $0 [-c] [-p]
+    exit 2
+fi
+
+for i in $* ; do 
+    case $i in
+	-c)     CLOBBER=1; shift;;
+	-p)     MAKE_PKGS=1; shift;;
+    esac
+done
+
+
+# Add /usr/sfw/bin & /opt/sfw/bin to path for GNU tools for external modules
+
+PATH=$PATH:/usr/sfw/bin:/opt/sfw/bin
+export PATH
+
+[ -d log ] || mkdir log
+
+# Append all further output & errors to the log file
+exec > log/buildit-XW 2>&1
+
+echo "------------------------------------------------------------------------------"
+echo "Start time: "
+date
+START=`perl -e 'print time'`
+echo "Building on: "
+uname -a
+echo "Using this compiler: "
+which cc
+cc -V
+
+MACH=`uname -p`
+if [ "$MACH" = "i386" ]; then
+    /bin/rm -rf proto-i386-svr4
+else
+    /bin/rm -rf proto-sun4-svr4
+fi
+
+cd open-src
+make -k clean beforeX-install
+cd ../..
+
+cd XORG_NV/
+./buildit $XORG_BUILD_ARGS
+cd ..
+
+cd open-src
+make -k afterX-install
+cd ..
+
+if [ $MAKE_PKGS = 1 ] ; then
+    PACKAGE_LIST=`cd packages && echo SUNW*`
+    export PACKAGE_LIST
+    chmod +x make_release_packages
+    mkdir packages/common_files
+    ./make_release_packages
+fi
+
+
+echo ""
+date
+echo "\nFinished building the X Window System Consolidation for OpenSolaris.\n"
+echo ""
+echo "Finish time: "
+date
+perl -e '$runtime=time-$ARGV[0];printf("Runtime: %d:%02d\n", $runtime/3600, ($runtime%3600)/60); ' $START
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/download-tarballs	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+###########################################################################
+#
+# Copyright 2006 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.
+#
+###########################################################################
+#
+# ident "@(#)download-tarballs	1.1	06/03/29 SMI"
+#
+
+CLOBBER=0
+WGET=/usr/sfw/bin/wget
+MAKE_FLAGS="-k"
+
+set -- `getopt cn $*`
+if [ $? != 0 ]
+then
+    echo USAGE: $0 [-c] [-n]
+    exit 2
+fi
+
+for i in $* ; do 
+    case $i in
+	-c)     CLOBBER=1; shift;;
+	-n)     WGET="echo $WGET"; MAKE_FLAGS="$MAKE_FLAGS -n" ; shift;;
+    esac
+done
+
+set -v
+
+cd open-src
+if [ $CLOBBER = 1 ] ; then
+    rm -rf tarballs
+fi
+if [ ! -d tarballs ] ; then 
+    mkdir tarballs
+fi
+make $MAKE_FLAGS download
+cd ../..
+
+cd XORG_NV/
+if [ $CLOBBER = 1 ] ; then
+    rm -rf tarballs
+fi
+if [ ! -d tarballs ] ; then 
+    mkdir tarballs
+fi
+cd tarballs
+if [ ! -f X11R6.9.0-src.tar.bz2 ] ; then
+    $WGET http://xorg.freedesktop.org/releases/X11R6.9.0/src-single/X11R6.9.0-src.tar.bz2
+fi
+cd ../..
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make_release_packages	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,249 @@
+#! /bin/sh
+#
+# Copyright 2006 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.
+# 
+# @(#)make_release_packages	1.41 03/07/06 06/03/07
+#
+#	Create and fill a package staging area for X
+#
+#	This script should be run from the base of the build tree.
+#	It takes no parameters.
+#
+#	Example:
+#	    cd /export/home/hammer1/WORKSPACES_S493_ALPHA2.1
+#	    ./make_release_packages
+#
+#   To build a subset of packages
+#	env PACKAGE_LIST="packages" ./make_release_packages
+#
+
+#   Make sure that we aren't affected by the personal environment of
+#   whoever is running this script
+PATH=/opt/SUNWspro/bin:/opt/SUNWguide/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:.
+SHELL=/bin/sh
+
+MACH=`uname -p`
+DATE=`date +0.%Y.%m.%d`
+
+#   List of official (deliverable) X-window packages
+XW_PACKAGE_LIST="SUNWxwcft SUNWxwdem SUNWxwdim SUNWxwfs SUNWxwinc \
+	SUNWxwice SUNWxwopt SUNWxwpmn SUNWxwsrc SUNWxwacx SUNWxwdxm \
+	SUNWxwhl SUNWi1of SUNWxwfa SUNWxwpft SUNWxwsrv SUNWxwoft \
+	SUNWfontconfig SUNWfontconfig-root SUNWfontconfig-docs SUNWxwsvr
+	SUNWxscreensaver-hacks SUNWstsfr SUNWfreetype2 SUNWxwxft SUNWxwfsw"
+
+# L10N packages are normally only built on sparc since they only have text
+# files that are the same for both platforms
+if [ "$MACH" = "sparc" ]; then
+    XW_L10N_PACKAGES="SUNW0xacx SUNW0xman SUNW0xpmn SUNW0xwfa SUNW0xwplt \
+	    SUNW0xwopt SUNW0xwsvr"
+else
+    XW_L10N_PACKAGES=" "
+fi
+
+# Which platform name do we use for 64-bit?
+if [ "$MACH" = "sparc" ]; then
+    PLAT_64="sparcv9"
+else 
+    if [ "$MACH" = "i386" ]; then
+	PLAT_64="amd64"
+    else
+	echo "Unknown architecture - not SPARC nor i386."
+	exit 1
+    fi
+fi
+
+#
+# Trusted Extensions packages do not get built by default.
+# export BUILD_XTSOL=yes and run this script to build
+#
+if [ x$BUILD_XTSOL = xyes ] ; then
+    TSOL_PACKAGE="SUNWxwts"
+fi
+
+# Packages with platform-specific prototype files, including those with
+# 64-bit libraries
+XW_PLT_PACKAGE="SUNWxwplt SUNWxwplr SUNWxwfnt SUNWxwrtl SUNWxwslb \
+    SUNWxwmod SUNWstsf SUNWxwxst SUNWxscreensaver-hacks-gl SUNWxwman $TSOL_PACKAGE"
+
+# Some packages are only built for sparc currently
+if [ "$MACH" = "sparc" ]; then
+	XW_PLT_PACKAGE="$XW_PLT_PACKAGE SUNWxwpsr"
+fi
+
+EXTRA_PACKAGES=" "
+
+#   To build a subset of packages
+#	PACKAGE_LIST="packages" make_release_packages
+#
+: ${PACKAGE_LIST:="$XW_PACKAGE_LIST $XW_PLT_PACKAGE $EXTRA_PACKAGES $XW_L10N_PACKAGES"}
+
+: ${PACKAGE_DIR:=`pwd`/proto-packages}
+SOURCEDIR=`pwd`
+
+cd $SOURCEDIR/packages
+
+# Get build version from pkgversion
+if [ -f pkgversion ] ; then
+    . pkgversion
+else
+    echo "Error: $SOURCEDIR/packages/pkgversion not found.  Cannot continue."
+    exit 1
+fi
+
+if [ "x${VERSION}" = "x" ] ; then
+    echo "VERSION not set in $SOURCEDIR/packages/pkgversion - run newPkRev"
+    exit 1
+fi
+
+if [ "x${BUILD}" = "x" ] ; then
+    echo "BUILD not set in $SOURCEDIR/packages/pkgversion - run newPkRev"
+    exit 1
+fi
+
+DECIMAL_BUILD=`echo ${BUILD} | awk '{print $1 / 100.0}'`
+echo "Building packages for X11 version ${VERSION} build ${DECIMAL_BUILD}"
+
+#   Next, create the staging area.  Make sure that the logs directory
+#   is writeable by everyone because it is likely that we will need to
+#   write into it as root across an NFS link...
+#
+echo 'Removing old proto-packages and recreating'
+/bin/rm -rf $PACKAGE_DIR
+/bin/mkdir $PACKAGE_DIR
+/bin/mkdir $PACKAGE_DIR/logs
+/bin/chmod a+w $PACKAGE_DIR/logs
+
+
+#  Now copy the package description info
+echo 'Copying package descriptions'
+
+#   We can't just use `sccs get SCCS' because it will punt if it hits
+#   a file which is being edited (writeable).
+#   
+for F in SCCS/s.*
+do
+    /usr/ccs/bin/get -s $F
+done
+
+/bin/cp copyright depend i.* r.* $PACKAGE_DIR >/dev/null 2>&1
+
+for package in $PACKAGE_LIST common_files
+do
+    cd $package
+
+    #   See above about sccs usage
+    for F in SCCS/s.*
+    do
+	/usr/ccs/bin/get $F >/dev/null 2>&1
+    done
+
+    /bin/mkdir $PACKAGE_DIR/$package
+    /bin/cp p* d* lib* i.* r.* M* $PACKAGE_DIR/$package >/dev/null 2>&1
+
+    # We keep the master copyright in the top-level copyright file
+    # Packages that need additional copyright have copyright.add files
+    # that we then merge here
+    if [ -f copyright.add ] ; then
+	cat ../copyright copyright.add > $PACKAGE_DIR/$package/copyright
+    else
+	cp ../copyright $PACKAGE_DIR/$package/copyright
+    fi
+    cd ..
+done
+
+
+#   Now move into the package staging area and build the packages.
+cd $PACKAGE_DIR
+
+if [ "$MACH" = "sparc" ]; then
+    PROTODIR=$SOURCEDIR/proto-sun4-svr4
+else
+    PROTODIR=$SOURCEDIR/proto-${MACH}-svr4
+fi
+
+for D in etc usr var lib ; do
+    /bin/rm -f $D
+    /bin/ln -s $PROTODIR/$D $D
+done
+
+for D in openwin dt sfw bin ; do
+    /bin/rm -f $D
+    /bin/ln -s $PROTODIR/usr/$D $D
+done
+
+LOGfile=logs/package_build
+
+echo '---Building packages'
+XW_PLT_PAT="`echo $XW_PLT_PACKAGE | tr ' ' '|'`"
+
+# Variables to pass to pkgmk for use in prototype files
+# They must start with lowercase letters to be resolved at pkgmk time
+PKGMK_VARS="plat_64=${PLAT_64} plat=${MACH}"
+
+for package in $PACKAGE_LIST
+do
+	cd $package
+	date
+	echo "******** Making the $package package ********"
+
+	cat pkginfo.tmpl | sed -e '/ARCH/s/ISA/'$MACH'/' -e 's/SUNW_PRODVERS=.*$/SUNW_PRODVERS='${VERSION}/ -e 's/VERSION=.*$/VERSION='${VERSION}.${BUILD},REV=${DATE}/ > pkginfo
+	if [ -f Makefile ]; then
+		echo make all
+		/usr/ccs/bin/make SOURCEDIR=$SOURCEDIR/packages all
+	fi
+
+	eval "case $package in
+	$XW_PLT_PAT)
+		if [ ! -f prototype_$MACH ]; then
+		    ln -s prototype_com prototype_$MACH
+		fi
+		echo /usr/bin/pkgmk -f prototype_$MACH -d $PACKAGE_DIR/$package -o ${PKGMK_VARS}
+		/usr/bin/pkgmk -f prototype_$MACH -d $PACKAGE_DIR/$package -o ${PKGMK_VARS}
+		;;
+	*)
+		echo /usr/bin/pkgmk -d $PACKAGE_DIR/$package -o ${PKGMK_VARS}
+		/usr/bin/pkgmk -d $PACKAGE_DIR/$package -o ${PKGMK_VARS} 
+		;;
+	esac"
+	
+	echo "******** Done Making the $package package ********"
+	cd ..
+done >$LOGfile 2>&1
+
+echo result log is in $PACKAGE_DIR/$LOGfile
+
+# Create an installdir with symlinks to SUNW* pkgs
+cd $PACKAGE_DIR
+mkdir installdir
+cd installdir
+ln -s ../SUNW*/SUNW* .
+cp -p $SOURCEDIR/packages/upgrade-X .
+chmod a+x upgrade-X
+
+exit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/newPkRev	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# Copyright 1999-2004 by Sun Microsystems Inc.  All rights reserved.
+#
+# @(#)newPkRev	1.19 04/12/17
+#
+
+if [ x${1}x = "xx" ] ; then
+	echo need a build number
+	exit
+fi
+
+# Sun's X11 version number - should match what's in xc/config/OWversion
+VERSION="6.6.3"
+
+sccs edit pkgversion
+echo VERSION=\"$VERSION\" > pkgversion
+echo BUILD=\"$1\" >> pkgversion
+sccs delget -y"VERSION=${VERSION}.${1}" pkgversion
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/Makefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,92 @@
+# Makefile for X Consolidation Open Source bits
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+# @(#)Makefile	1.1	05/09/02
+#
+###############################################################################
+#
+# Modules in this makefile are divided into 2 sections - those that need to
+# be built before the X11 monolithic tree (because X depends on them) and 
+# those that need to be build after the X11 monolithic tree (because they 
+# depend on X).
+
+BEFOREX = \
+	lib/freetype \
+	lib/fontconfig \
+	lib/Xft
+
+AFTERX = \
+	font/bitstream-vera
+
+ALL = $(BEFOREX) $(AFTERX)
+
+# Need to install to proto area by default for inter-package dependencies to
+# work right.
+all: install
+
+World: clean install
+
+beforeX-all: 
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=all OS_SUBDIRS=BEFOREX
+
+afterX-all: 
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=all OS_SUBDIRS=AFTERX
+
+clean: beforeX-clean afterX-clean
+
+beforeX-clean: 
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=clean OS_SUBDIRS=BEFOREX
+
+afterX-clean: 
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=clean OS_SUBDIRS=AFTERX
+
+install: beforeX-install afterX-install
+
+beforeX-install:
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=install OS_SUBDIRS=BEFOREX
+
+afterX-install:
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=install OS_SUBDIRS=AFTERX
+
+download: beforeX-download afterX-download
+
+beforeX-download:
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=download OS_SUBDIRS=BEFOREX
+
+afterX-download:
+	$(MAKE) $(MFLAGS) subdirs OS_TARGET=download OS_SUBDIRS=AFTERX
+
+subdirs:
+	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
+	for i in $($(OS_SUBDIRS)) ;\
+	do \
+	(cd $$i ; echo "## making" $(OS_TARGET) "in open-src/$$i..."; \
+	$(MAKE) $(MFLAGS) CDEBUGFLAGS="$(CDEBUGFLAGS)" $(OS_TARGET)); \
+	done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/common/Makefile.inc	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,188 @@
+# -*- Makefile -*- rules commonly shared among X consolidation open source dirs
+#
+# Use subject to license terms.
+#
+# 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.
+#
+# @(#)Makefile.inc	1.59	05/09/02
+#
+
+BUILD_DATE:sh=date +'%e-%B-%Y'
+BUILD_ID = X11 for Solaris Nevada, built $(BUILD_DATE)
+
+### Default compiler & options
+CC     			= cc
+DEFAULT_OPT_CFLAGS 	= -xO4 -xbuiltin -xlibmil -xprefetch
+OPT_CFLAGS 		= $(DEFAULT_OPT_CFLAGS)
+CFLAGS 			=  -v -mc $(OPT_CFLAGS) $(ARCH_FLAGS)
+LDFLAGS 		= -z combreloc -z lazyload $(MAPFILES_FOR_ALL)
+
+### Flags for libraries to meet various Solaris requirements
+#
+# REQUIRED_LDFLAGS are forced on via LD_OPTIONS to override libtool when
+# building libraries.
+#
+LIB_CFLAGS 		= $(CFLAGS) -D_REENTRANT $(ARCH_LIB_FLAGS)
+LIB_REQUIRED_LDFLAGS	= -z text -z defs
+LIB_LDFLAGS 		= $(LDFLAGS) $(LIB_REQUIRED_LDFLAGS)
+
+# Flags for programs
+PROG_LDFLAGS		= $(LDFLAGS) $(MAPFILES_FOR_PROGS)
+
+# Linker mapfiles to link with for better performance & security
+# SPARC archicteture requires PLT section in .data be executable, so
+# we can only make .bss, not all of .data no-exec on SPARC
+MAPFILE_DIR 		= $(TOP)/common/mapfiles/
+MAPFILE_NOEXBSS		= $(MAPFILE_DIR)/map.noexbss
+MAPFILE_NOEXDATA_sun4	= $(MAPFILE_NOEXBSS)
+MAPFILE_NOEXDATA_i86pc	= /usr/lib/ld/map.noexdata
+MAPFILE_NOEXDATA:sh=arch | sed 's/^\(.*\)$/\$\(MAPFILE_NOEXDATA_\1\)/'
+
+MAPFILES_FOR_ALL   = -M /usr/lib/ld/map.pagealign -M $(MAPFILE_NOEXDATA)
+MAPFILES_FOR_PROGS = -M /usr/lib/ld/map.bssalign -M /usr/lib/ld/map.noexstk \
+			-M $(MAPFILE_NOEXBSS)
+
+### Architecture specific flags
+DEFAULT_sun4_ARCH32_FLAGS 	= -xarch=v8plus
+DEFAULT_sun4_ARCH64_FLAGS 	= -xarch=v9
+DEFAULT_sun4_ARCH_LIB_FLAGS 	= -xregs=no%appl
+
+# -xregs=no%frameptr is required on x86 when compiling at -xO4 or higher to 
+# avoid losing stack frame pointers so you can't get stack traces or debug
+DEFAULT_i86pc_ARCH32_FLAGS 	= -xpentium -xregs=no%frameptr
+DEFAULT_i86pc_ARCH64_FLAGS 	= -xarch=generic64 -xregs=no%frameptr
+DEFAULT_i86pc_ARCH_LIB_FLAGS 	=  
+
+ARCH:sh=arch | sed s/i86pc/i386/
+ARCH32_FLAGS:sh=arch | sed 's/^\(.*\)$/\$\(DEFAULT_\1_ARCH32_FLAGS\)/'
+ARCH64_FLAGS:sh=arch | sed 's/^\(.*\)$/\$\(DEFAULT_\1_ARCH64_FLAGS\)/'
+ARCH_LIB_FLAGS:sh=arch | sed 's/^\(.*\)$/\$\(DEFAULT_\1_ARCH_LIB_FLAGS\)/'
+
+SUBDIR64_sun4 	= sparcv9
+SUBDIR64_i86pc 	= amd64
+SUBDIR64:sh=arch | sed 's/^\(.*\)$/\$\(SUBDIR64_\1\)/'
+
+ARCH_MAPFILE:sh=uname -p | sed 's/^\(.*\)$/mapfile_pga_\1/'
+MAPFILE_FLAGS = -M $(TOP)/common/mapfiles/$(ARCH_MAPFILE)
+
+### Proto directory to install into for packaging
+PROTODIR=$(TOP)/../proto-$(ARCH)-svr4
+
+# Common subdirs
+OW_DIR=/usr/openwin
+OW_X11LIB_DIR=$(OW_DIR)/lib/X11
+
+FONT_DIR=$(OW_X11LIB_DIR)/fonts
+TRUETYPE_DIR=$(FONT_DIR)/TrueType
+
+### Default rules
+
+BUILD_DIR_32 = build_32
+BUILD_DIR_64 = build_64
+
+all: $(BUILD_TYPES:%=source_%) $(BUILD_TYPES:%=build_%)
+install: $(BUILD_TYPES:%=install_%)
+
+clean: $(BUILD_TYPES:%=clean_%)
+
+clean_32::
+	-rm -rf $(BUILD_DIR_32)
+
+clean_64::
+	-rm -rf $(BUILD_DIR_64)
+
+build_gen: $(BUILD_TARGETS)
+
+build_32::
+	$(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_32) ARCH_FLAGS="$(ARCH32_FLAGS)" build_gen
+
+build_64::
+	$(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_64) ARCH_FLAGS="$(ARCH64_FLAGS)" LIBSUBDIR=/$(SUBDIR64) build_gen
+
+install_32::
+	$(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_32) ARCH_FLAGS="$(ARCH32_FLAGS)" install_gen
+
+install_64::
+	$(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_64) ARCH_FLAGS="$(ARCH64_FLAGS)" LIBSUBDIR=/64 ARCHLIBSUBDIR=/$(SUBDIR64) install_gen
+
+debug:
+	$(MAKE) $(MFLAGS) all OPT_FLAGS="-g"
+
+### Unpack source and apply patches
+
+source: $(BUILD_TYPES:%=source_%)
+source_32: $(BUILD_DIR_32)/.unpack_done
+source_64: $(BUILD_DIR_64)/.unpack_done
+
+UNPACK_TARGET = $(BUILD_DIR)/.unpack_done
+
+$(BUILD_DIR_32)/.unpack_done:
+	$(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_32) source_gen
+
+$(BUILD_DIR_64)/.unpack_done:
+	$(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_64) source_gen
+
+source_gen::
+	mkdir -p $(BUILD_DIR)
+	@if [ "x$(SOURCE_UNCOMPRESS)" = "x" ] ; then \
+	    echo "bzcat $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )" ; \
+	    ( bzcat $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )) ; \
+	else \
+	    echo "$(SOURCE_UNCOMPRESS) $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )" ; \
+	    ( $(SOURCE_UNCOMPRESS) $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )) ; \
+	fi
+	@if [ "x$(SOURCE_PATCHES)" != "x" ] ; then \
+	    for p in $(SOURCE_PATCHES) x ; do \
+	        if [ "$$p" != "x" ] ; then \
+		    echo "gpatch -d $(SOURCE_DIR) -p0 < $$p" ; \
+		    gpatch -d $(SOURCE_DIR) -p0 < $$p ; \
+		fi ; \
+	    done ; \
+	fi
+	touch $(BUILD_DIR)/.unpack_done
+
+
+### Source tarballs & downloading if necessary
+
+TARBALLDIR=$(TOP)/tarballs
+WGET=/usr/sfw/bin/wget
+SOURCE_TARBALL=$(TARBALLDIR)/$(SOURCE_TARBALL_NAME)
+
+download:
+	if [ ! -f $(SOURCE_TARBALL) ] ; then \
+		$(WGET) -O $(SOURCE_TARBALL) $(SOURCE_URL) ;\
+	fi
+
+### Other tools needed to build
+
+# Some modules (such as FreeType 2) require GNU make
+GNUMAKE = gmake
+
+$(GNUMAKE):
+	@echo "Checking for GNU make:"
+	$(GNUMAKE) --version
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/common/mapfiles/map.noexbss	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,36 @@
+#ident  "@(#)map.noexbss 1.5     05/09/02 SMI"
+#
+# Copyright 2005 by Sun Microsystems, Inc. All rights reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+############################################################################
+#
+# Make bss section non-executable for further buffer overflow protection
+# (can't make whole data section non-exec on SPARC since that includes PLT
+#  which must be executable on SPARC).  
+bss = ?RW;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/common/sunman-stability	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,16 @@
+.\\" Begin Sun update
+.SH ATTRIBUTES
+See
+.BR attributes (5)
+for descriptions of the following attributes:
+.sp
+.TS
+box;
+cbp-1 | cbp-1
+l | l .
+ATTRIBUTE TYPE	ATTRIBUTE VALUE
+=
+Availability	__package__
+Interface Stability	External
+.TE 
+.\\" End Sun update
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/font/bitstream-vera/Makefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,85 @@
+###############################################################################
+#
+# Bitstream Vera Fonts Makefile
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+# @(#)Makefile	1.1	05/09/02
+#
+
+PWD:sh=pwd
+TOP=$(PWD)/../..
+
+# Not really 32 or 64-bit, but we call it 32-bit to avoid subdirs
+BUILD_TYPES=32 
+
+# Version number (used in path names)
+VERSION=1.10
+
+# Source tarball
+SOURCE_TARBALL_NAME=ttf-bitstream-vera-$(VERSION).tar.bz2
+
+# Download site for source
+SOURCE_URL=http://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-vera/$(VERSION)/ttf-bitstream-vera-$(VERSION).tar.bz2
+
+# Patches to apply to source after unpacking, in order
+SOURCE_PATCHES=		# None
+
+# Directory created by unpacking source
+SOURCE_DIR=$(BUILD_DIR)/ttf-bitstream-vera-$(VERSION)
+
+# What to build: nothing, just unpack files
+BUILD_TARGETS=$(UNPACK_TARGET)
+
+# Directory to install to
+DEST_DIR=$(PROTODIR)$(TRUETYPE_DIR)
+
+### Include common rulesets
+include $(TOP)/common/Makefile.inc
+
+### Rules specific to this directory:
+
+VERA_FONT_FILES= \
+	Vera.ttf	\
+	VeraBI.ttf	\
+	VeraBd.ttf	\
+	VeraIt.ttf	\
+	VeraMoBI.ttf	\
+	VeraMoBd.ttf	\
+	VeraMoIt.ttf	\
+	VeraMono.ttf	\
+	VeraSe.ttf	\
+	VeraSeBd.ttf
+
+install_gen: $(BUILD_TARGETS)
+	mkdir -p $(DEST_DIR)
+	-( cd $(DEST_DIR) ; rm -f $(VERA_FONT_FILES) VeraFontsCopyright.txt )
+	( cd $(SOURCE_DIR) ; cp -p $(VERA_FONT_FILES) $(DEST_DIR) )
+	cp -p $(SOURCE_DIR)/COPYRIGHT.TXT $(DEST_DIR)/VeraFontsCopyright.txt 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/Xft/Makefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,90 @@
+###############################################################################
+#
+# Xft 2.x Makefile
+#
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+# @(#)Makefile	1.4	06/02/22
+#
+
+PWD:sh=pwd
+TOP=$(PWD)/../..
+BUILD_TYPES=32 64
+
+# Version number (used in path names)
+XFT_VERS=2.1.6
+
+# Source tarball
+SOURCE_TARBALL_NAME=libXft-$(XFT_VERS).tar.bz2
+
+# Download site for source
+SOURCE_URL=http://xlibs.freedesktop.org/release/$(SOURCE_TARBALL_NAME)
+
+# Patches to apply to source after unpacking, in order
+SOURCE_PATCHES = \
+	xft.pc.patch \
+	xftcore-6261221.patch \
+	cjk-embolden.patch
+
+# Directory created by unpacking source
+SOURCE_DIR=$(BUILD_DIR)/libXft-$(XFT_VERS)
+
+include $(TOP)/common/Makefile.inc
+
+# Where to install files
+XFT_prefix=$(OW_DIR)
+
+# Command line options to GNU autoconf configure script
+CONFIG_OPTS = --enable-shared=yes --enable-static=no --prefix=$(XFT_prefix) --x-libraries="/usr/openwin/lib$(LIBSUBDIR) -L/usr/openwin/sfw/lib$(LIBSUBDIR) -R/usr/openwin/lib$(LIBSUBDIR) -R/usr/openwin/sfw/lib$(LIBSUBDIR)" --libdir='$${exec_prefix}/lib$(LIBSUBDIR)'
+
+# Paths to find libraries at build time (LD_LIBRARY_PATH) 
+# and run time (LD_RUN_PATH) and freetype-config binary at build time (PATH)
+LIBPATHS = LD_LIBRARY_PATH=$(PROTODIR)/usr/sfw/lib$(LIBSUBDIR):$(PROTODIR)/usr/openwin/lib$(LIBSUBDIR):/usr/sfw/lib$(LIBSUBDIR) LD_RUN_PATH=/usr/sfw/lib$(LIBSUBDIR) PATH=$(PROTODIR)/usr/sfw/bin$(LIBSUBDIR):$(PATH)
+
+# Include Paths - need headers for fontconfig & freetype from build area
+INCLUDES = -I$(PROTODIR)/usr/include -I$(PROTODIR)/usr/sfw/include
+
+# Library built in tree
+XFT_LIB=$(BUILD_DIR)/.libs/libXft.so.2
+
+# Mapfile used to control which symbols are exported
+XFT_MAPFILE=$(PWD)/mapfile.scope
+
+build_gen: $(XFT_LIB)
+
+$(XFT_LIB): $(SOURCE_DIR)/Makefile $(XFT_MAPFILE)
+	(cd $(SOURCE_DIR) ; $(LIBPATHS) LD_OPTIONS="$(LIB_REQUIRED_LDFLAGS) -M$(XFT_MAPFILE)" $(MAKE) $(MFLAGS))
+
+# Run configure script
+$(SOURCE_DIR)/Makefile: $(UNPACK_TARGET)
+	(cd $(SOURCE_DIR) ; chmod a+x configure ; \
+	 CC=$(CC) CFLAGS="$(LIB_CFLAGS) $(INCLUDES)" LD="$(CC) $(LIB_CFLAGS) $(LDFLAGS)"  LDFLAGS="$(LIB_LDFLAGS)" $(LIBPATHS) ./configure $(CONFIG_OPTS) )
+
+install_gen: $(XFT_LIB)
+	(cd $(SOURCE_DIR) ; $(LIBPATHS) LD_OPTIONS="$(LIB_REQUIRED_LDFLAGS)" $(MAKE) $(MFLAGS) -e DESTDIR=$(PROTODIR) libdir=$(XFT_prefix)/lib$(ARCHLIBSUBDIR) bindir=$(XFT_prefix)/bin$(ARCHLIBSUBDIR) install)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/Xft/cjk-embolden.patch	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,324 @@
+This combined patch includes the fixes for:
+Bug 5048680, 5067795: Add embolden/italicize support for CJK
+Bug 5071008: darken chinese characters
+Bug 5104233: Chinese font rendering is not correct for certain sizes
+
+diff -u libXft-2.1.6-orig/xftfreetype.c libXft-2.1.6/xftfreetype.c
+--- xftfreetype.c	Fri Mar 19 10:54:08 2004
++++ xftfreetype.c	Tue Jan 11 16:23:09 2005
+@@ -374,6 +374,8 @@
+     _XftUnlockFile (font->info.file);
+ }
+ 
++int darken_candidate = 0;
++
+ static FcBool
+ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
+ {
+@@ -390,6 +392,7 @@
+     FcChar32	    hash, *hashp;
+     FT_Face	    face;
+     int		    nhash;
++    FcBool          embed; /* Use embededbitmap switch */
+ 
+     if (!info)
+ 	return FcFalse;
+@@ -433,6 +436,35 @@
+     if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &dsize) != FcResultMatch)
+ 	goto bail1;
+ 
++    /*
++     * Determine if user wants text darker than normally created.
++     */
++    switch ( FcPatternGetBool (pattern, "darken", 0, &darken_candidate)) {
++    case FcResultNoMatch:
++        darken_candidate = FcFalse;
++        break;
++    case FcResultMatch:
++	if ( dsize < 24 )
++	{
++            if (FcPatternGetInteger (pattern, "darken_value", 0, &darken_candidate) != FcResultMatch)
++		darken_candidate = 6;
++
++	    if ( darken_candidate < 1 || darken_candidate > 9 )
++		darken_candidate = 6;
++	}
++	else
++            darken_candidate = FcFalse;
++        break;
++    default:
++        goto bail1;
++    }
++
++    /*
++     * Add By Firefly ([email protected])
++     */
++    if (dsize != (long)dsize) /* for speed - avoid math compute */
++        dsize = ((dsize - (long)dsize) >= 0.5) ? (long)dsize + 1: (long)dsize;
++
+     if (FcPatternGetDouble (pattern, FC_ASPECT, 0, &aspect) != FcResultMatch)
+ 	aspect = 1.0;
+     
+@@ -513,8 +545,36 @@
+     fi->load_flags = FT_LOAD_DEFAULT;
+ 
+     /* disable bitmaps when anti-aliasing or transforming glyphs */
+-    if (fi->antialias || fi->transform)
++
++    /*------------------------------------------------------------------
++     * Add by Firefly ( [email protected])
++     * enable bitmaps first if requested
++     */
++    switch ( FcPatternGetBool (pattern, "prefer_bitmap", 0, &embed)) {
++    case FcResultNoMatch:
++        embed = FcTrue;
++        break;
++    case FcResultMatch:
++        break;
++    default:
++        goto bail1;
++    }
++
++    if ((fi->antialias && !embed ) || fi->transform)
+ 	fi->load_flags |= FT_LOAD_NO_BITMAP;
++
++    /*
++     * Check for weight
++     */
++    switch (FcPatternGetInteger(pattern, FC_WEIGHT, 0, &fi->weight)) {
++    case FcResultNoMatch:
++        fi->weight = FC_WEIGHT_MEDIUM;
++        break;
++    case FcResultMatch:
++        break;
++    default:
++        goto bail1;
++    }
+     
+     /* disable hinting if requested */
+     switch (FcPatternGetBool (pattern, FC_HINTING, 0, &hinting)) {
+diff -u xftglyphs.c xftglyphs.c
+--- xftglyphs.c	Wed Apr 30 17:13:17 2003
++++ xftglyphs.c	Tue Jan 11 16:23:09 2005
+@@ -103,6 +103,9 @@
+     FT_Vector	    vector;
+     Bool	    subpixel = False;
+     FT_Face	    face;
++    int             bold_advance_width = 0;
++    int             darken = 0;
++    extern int      darken_candidate;
+ 
+     if (!info)
+ 	return;
+@@ -112,6 +115,15 @@
+     if (!face)
+ 	return;
+ 
++    /*-------------------------------------------------------
++     * Add by Firefly ([email protected])
++     *------------------------------------------------------*/
++    if (font->info.weight >= FC_WEIGHT_BOLD &&
++       !(face->style_flags & FT_STYLE_FLAG_BOLD))
++    {
++       bold_advance_width = 64;
++    }
++
+     matrix.xx = matrix.yy = 0x10000L;
+     matrix.xy = matrix.yx = 0;
+ 
+@@ -136,6 +148,10 @@
+     while (nglyph--)
+     {
+ 	glyphindex = *glyphs++;
++
++	if ( glyphindex > 256 && darken_candidate )
++	    darken = 1;
++
+ 	xftg = font->glyphs[glyphindex];
+ 	if (!xftg)
+ 	    continue;
+@@ -216,7 +232,7 @@
+ 	    bottom = FLOOR( glyphslot->metrics.horiBearingY - glyphslot->metrics.height );
+ 	}
+ 
+-	width = TRUNC(right - left);
++	width = TRUNC(right - left) + (bold_advance_width/64);
+ 	height = TRUNC( top - bottom );
+ 
+ 	/*
+@@ -223,34 +239,43 @@
+ 	 * Try to keep monospace fonts ink-inside
+ 	 * XXX transformed?
+ 	 */
++        /* Modified by Firefly ([email protected])
++         *
++         * Don't use "font->public.max_advance_width", because CJK fonts
++         * have both half-width and full-width.
++         * So must use "glyphslot->metrics.vertAdvance" &
++         * "glyphslot->metrics.horiAdvance" in order to get correctly width.
++         *----------------------------------------------------------------*/
++        glyphslot->metrics.horiAdvance += bold_advance_width;
++
+ 	if (font->info.spacing != FC_PROPORTIONAL && !font->info.transform)
+ 	{
+ 	    if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
+ 	    {
+-		if (TRUNC(bottom) > font->public.max_advance_width)
++		if (bottom > glyphslot->metrics.vertAdvance)
+ 		{
+ 		    int adjust;
+     
+-		    adjust = bottom - (font->public.max_advance_width << 6);
++		    adjust = bottom - glyphslot->metrics.vertAdvance;
+ 		    if (adjust > top)
+ 			adjust = top;
+ 		    top -= adjust;
+ 		    bottom -= adjust;
+-		    height = font->public.max_advance_width;
++		    height = TRUNC(glyphslot->metrics.vertAdvance);
+ 		}
+ 	    }
+ 	    else
+ 	    {
+-		if (TRUNC(right) > font->public.max_advance_width)
++		if (right > glyphslot->metrics.horiAdvance)
+ 		{
+ 		    int adjust;
+     
+-		    adjust = right - (font->public.max_advance_width << 6);
++		    adjust = right - glyphslot->metrics.horiAdvance;
+ 		    if (adjust > left)
+ 			adjust = left;
+ 		    left -= adjust;
+ 		    right -= adjust;
+-		    width = font->public.max_advance_width;
++		    width = TRUNC(glyphslot->metrics.horiAdvance);
+ 		}
+ 	    }
+ 	}
+@@ -274,11 +299,11 @@
+ 		if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
+ 		{
+ 		    vector.x = 0;
+-		    vector.y = -face->size->metrics.max_advance;
++		    vector.y = -glyphslot->metrics.vertAdvance;
+ 		}
+ 		else
+ 		{
+-		    vector.x = face->size->metrics.max_advance;
++		    vector.x = glyphslot->metrics.horiAdvance;
+ 		    vector.y = 0;
+ 		}
+ 		FT_Vector_Transform (&vector, &font->info.matrix);
+@@ -290,11 +315,11 @@
+ 		if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
+ 		{
+ 		    xftg->metrics.xOff = 0;
+-		    xftg->metrics.yOff = -font->public.max_advance_width;
++		    xftg->metrics.yOff = -(glyphslot->metrics.vertAdvance >> 6);
+ 		}
+ 		else
+ 		{
+-		    xftg->metrics.xOff = font->public.max_advance_width;
++		    xftg->metrics.xOff = glyphslot->metrics.horiAdvance >> 6;
+ 		    xftg->metrics.yOff = 0;
+ 		}
+ 	    }
+@@ -301,7 +326,7 @@
+ 	}
+ 	else
+ 	{
+-	    xftg->metrics.xOff = TRUNC(ROUND(glyphslot->advance.x));
++	    xftg->metrics.xOff = TRUNC(ROUND(glyphslot->advance.x + bold_advance_width));
+ 	    xftg->metrics.yOff = -TRUNC(ROUND(glyphslot->advance.y));
+ 	}
+ 	
+@@ -402,7 +427,75 @@
+ 			(int) glyphindex);
+ 	    continue;
+ 	}
+-	
++
++	if ( font->info.antialias && darken )
++	{
++	    int h = height * vmul;
++            int w = font->info.antialias ? pitch : pitch * 8;
++            unsigned char *p = bufBitmap;
++	    int i, x, y;
++	    int steps = 10 - darken_candidate;
++	    int max   = 255 / steps;
++
++	    for ( y = 0; y < h; y++ )
++	    {
++		for ( x = 0; x < w; x++ )
++		{
++		    int val = p[x] / steps;
++/**
++		    if ( p[x] )
++		    {
++		        p[x] += 30;
++		        if ( p[x] > 255 )
++			    p[x] = 255;
++		    }
++**/
++		    p[x] += ( p[x] > 30 ? max-val: 0 );
++/**
++		    p[x] += ( p[x] ? ((val > max - val)?max-val:val): 0 );
++**/
++		}
++                p += w;
++	    }
++	}
++
++        /*-------------------------------------------------------
++         * Add by Firefly ([email protected])
++         * some code from XFree86's X-TrueType module.
++         *------------------------------------------------------*/
++        if ( bold_advance_width)
++        {
++            int h = height * vmul;
++            int w = font->info.antialias ? pitch : pitch * 8;
++            unsigned char *p = bufBitmap;
++            unsigned char lsb, tmp;
++            int i, x, y;
++            
++            for (y = 0; y < h ; y++)
++            {
++                if (font->info.antialias)
++                {
++                    for (x = w; x > 0; x--)
++                    {
++                        if ( p[x] < p[x-1] )
++                            p[x] = p[x-1];
++                    }
++                }
++                else
++                {
++                    lsb = 0;
++
++                    for (x = 0; x < w; x++)
++                    {
++                        tmp = p[x] << 7;
++                        p[x] |= (p[x] >> 1) | lsb;
++                        lsb = tmp;
++                    }
++                }
++                p += w;
++            }
++	}
++
+ 	if (XftDebug() & XFT_DBG_GLYPH)
+ 	{
+ 	    printf ("glyph %d:\n", (int) glyphindex);
+diff -u libXft-2.1.6-orig/xftint.h libXft-2.1.6/xftint.h
+--- xftint.h	Wed Mar 10 14:07:29 2004
++++ xftint.h	Tue Jan 11 16:23:09 2005
+@@ -120,6 +120,7 @@
+     int			spacing;
+     FcBool		minspace;
+     int			char_width;
++    int                 weight;
+ };
+ 
+ /*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/Xft/mapfile.scope	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,82 @@
+{
+  global:
+    XftColorAllocName;
+    XftColorAllocValue;
+    XftColorFree;
+    XftDefaultHasRender;
+    XftDefaultSet;
+    XftDefaultSubstitute;
+    XftDrawCreate;
+    XftDrawCreateBitmap;
+    XftDrawCreateAlpha;
+    XftDrawChange;
+    XftDrawDisplay;
+    XftDrawDrawable;
+    XftDrawColormap;
+    XftDrawVisual;
+    XftDrawDestroy;
+    XftDrawPicture;
+    XftDrawSrcPicture;
+    XftDrawGlyphs;
+    XftDrawString8;
+    XftDrawString16;
+    XftDrawString32;
+    XftDrawStringUtf8;
+    XftDrawStringUtf16;
+    XftDrawCharSpec;
+    XftDrawCharFontSpec;
+    XftDrawGlyphSpec;
+    XftDrawGlyphFontSpec;
+    XftDrawRect;
+    XftDrawSetClip;
+    XftDrawSetClipRectangles;
+    XftDrawSetSubwindowMode;
+    XftGlyphExtents;
+    XftTextExtents8;
+    XftTextExtents16;
+    XftTextExtents32;
+    XftTextExtentsUtf8;
+    XftTextExtentsUtf16;
+    XftFontMatch;
+    XftFontOpen;
+    XftFontOpenName;
+    XftFontOpenXlfd;
+    XftLockFace;
+    XftUnlockFace;
+    XftFontInfoCreate;
+    XftFontInfoDestroy;
+    XftFontInfoHash;
+    XftFontInfoEqual;
+    XftFontOpenInfo;
+    XftFontOpenPattern;
+    XftFontCopy;
+    XftFontClose;
+    XftFontLoadGlyphs;
+    XftFontUnloadGlyphs;
+    XftFontCheckGlyph;
+    XftCharExists;
+    XftCharIndex;
+    XftInit;
+    XftInitFtLibrary;
+    XftGetVersion;
+    XftListFonts;
+    XftNameParse;
+    XftGlyphRender;
+    XftGlyphSpecRender;
+    XftCharSpecRender;
+    XftGlyphFontSpecRender;
+    XftCharFontSpecRender;
+    XftTextRender8;
+    XftTextRender16;
+    XftTextRender16BE;
+    XftTextRender16LE;
+    XftTextRender32;
+    XftTextRender32BE;
+    XftTextRender32LE;
+    XftTextRenderUtf8;
+    XftTextRenderUtf16;
+    XftXlfdParse;
+
+  local:
+    *;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/Xft/xft.pc.patch	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,11 @@
+Set flags for libraries that link with Xft to meet normal Solaris rules
+
+--- xft.pc.in	Wed Apr 30 17:49:20 2003
++++ xft.pc.in	Wed Aug 24 18:59:14 2005
+@@ -11,5 +11,5 @@
+ Description: X FreeType library
+ Version: @VERSION@
+ Requires: fontconfig
+-Libs: -L${libdir} -lXft -lX11 ${freetypelibs} ${xrenderlibs}
++Libs: -L${libdir} -R${libdir} -lXft
+ Cflags: -I${includedir} ${freetypecflags} ${xrendercflags}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/Xft/xftcore-6261221.patch	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,23 @@
+D 1.4	05/05/24 14:18:14 wangd	5 4	00009/00002/01375
+fixed CR6261221: view page source causes mozilla crash on S10 b74L2a
+
+--- xftcore.c	Wed Aug 24 19:24:00 2005
++++ xftcore.c	Fri Jun 10 13:52:54 2005
+@@ -1256,8 +1256,15 @@
+ 	g_y2 = g_y1 + gi.height;
+ 	if (i)
+ 	{
+-	    if (g_x1 < x1)
+-		x1 = g_x1;
++	    if (g_x1 < x1) {
++                if(g_x1 < 0 ) {
++                    /* do nothing if the given glyphs are out of range */
++                    short t = glyphs[i-1].font->max_advance_width + glyphs[i-1].x;
++                    if(t < 0 && glyphs[i-1].x > 0)
++                        goto bail1;
++                }
++                x1 = g_x1;
++            }
+ 	    if (g_y1 < y1)
+ 		y1 = g_y1;
+ 	    if (g_x2 > x2)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/Makefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,159 @@
+###############################################################################
+#
+# Fontconfig 2.x Makefile
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+# @(#)Makefile	1.61	05/11/30
+#
+
+PWD:sh=pwd
+TOP=$(PWD)/../..
+BUILD_TYPES=32 64
+
+# Version number (used in path names)
+FONTCONFIG_VERS=2.3.2
+
+# Source tarball
+SOURCE_TARBALL_NAME=fontconfig-$(FONTCONFIG_VERS).tar.gz
+
+# Download site for source
+SOURCE_URL=http://fontconfig.org/release/fontconfig-2.3.2.tar.gz
+
+SOURCE_UNCOMPRESS=gzcat
+
+# Patches to apply to source after unpacking, in order
+SOURCE_PATCHES=fontconfig-$(FONTCONFIG_VERS).patch
+
+include $(TOP)/common/Makefile.inc
+
+# Directory created by unpacking source
+SOURCE_DIR=$(BUILD_DIR)/fontconfig-$(FONTCONFIG_VERS)
+
+# Special version of freetype config to force certain arguments
+FONTCONFIG_FT2CFG=$(BUILD_DIR)/freetype-config
+
+# Command line options to GNU autoconf configure script
+FONTCONFIG_CFG=--enable-shared=yes --enable-static=no --with-expat-includes=/usr/sfw/include --with-expat-lib=/usr/sfw/lib$(LIBSUBDIR) --prefix=/usr --with-confdir=/etc/fonts --with-default-fonts='--font-dirs-go-here--' --with-freetype-config=../freetype-config --libdir='$${exec_prefix}/lib$(LIBSUBDIR)'
+
+# Library built in tree
+FONTCONFIG_LIB=$(SOURCE_DIR)/src/.libs/libfontconfig.so.1.0.4
+
+# Where to install most files
+FONTCONFIG_prefix=$(PROTODIR)
+
+# Where to install libraries
+FONTCONFIG_libdir=$(FONTCONFIG_prefix)/usr/lib
+
+# Paths to find libraries
+FONTCONFIG_libpaths= LD_LIBRARY_PATH=$(PROTODIR)/usr/sfw/lib$(LIBSUBDIR) LD_RUN_PATH=/usr/sfw/lib$(LIBSUBDIR)
+
+# Path to install fc-cache manifest
+FONTCONFIG_SMF_MANIFEST_dir=$(PROTODIR)/var/svc/manifest/application/font
+FONTCONFIG_SMF_MANIFEST=$(FONTCONFIG_SMF_MANIFEST_dir)/fc-cache.xml
+
+build_gen: $(FONTCONFIG_LIB)
+
+$(FONTCONFIG_FT2CFG): $(PROTODIR)/usr/sfw/bin$(LIBSUBDIR)/freetype-config
+	-if [ -f $@ ] ; then rm $@ ; fi
+	sed -e 's|-L$$libdir|-L$(PROTODIR)$${exec_prefix}/lib$(LIBSUBDIR) -L$$libdir|' -e 's|^includedir=$${prefix}|includedir=$(PROTODIR)$${prefix}|' $(PROTODIR)/usr/sfw/bin$(LIBSUBDIR)/freetype-config > $@
+	chmod +x $@
+
+# Run configure script
+$(SOURCE_DIR)/Makefile:= OPT_CFLAGS=$(FC_OPTFLAGS)
+FC_OPTFLAGS:sh=arch | sed 's/^\(.*\)$/\$\(FC_\1_OPT_FLAGS\)/'
+FC_i386_OPT_FLAGS = ""
+FC_sun4_OPT_FLAGS = $(DEFAULT_OPT_CFLAGS)
+
+$(SOURCE_DIR)/Makefile: $(UNPACK_TARGET) $(FONTCONFIG_FT2CFG)
+	(cd $(SOURCE_DIR) ; \
+	 chmod a+x configure ; \
+	 CC=$(CC) CFLAGS="$(LIB_CFLAGS)" LD="$(CC) $(LIB_CFLAGS) $(LDFLAGS)" LDFLAGS="$(LIB_LDFLAGS)" $(FONTCONFIG_libpaths) ./configure $(FONTCONFIG_CFG) )
+	if [ -f $(SOURCE_DIR)/src/Makefile.bak ] ; then 	\
+		rm -f $(SOURCE_DIR)/src/Makefile.bak ; 	\
+	fi
+
+$(SOURCE_DIR)/fonts.conf-SUNW: $(SOURCE_DIR)/fonts.conf fonts.conf.append fonts.conf.preuser fix-fonts.conf.pl
+	perl fix-fonts.conf.pl < $(SOURCE_DIR)/fonts.conf > $(SOURCE_DIR)/fonts.conf-SUNW
+
+# Build Fontconfig 
+$(FONTCONFIG_LIB): $(SOURCE_DIR)/Makefile $(SOURCE_DIR)/fonts.conf-SUNW
+	(cd $(SOURCE_DIR) ; LD_OPTIONS="$(LIB_LDFLAGS)" $(FONTCONFIG_libpaths) $(MAKE) $(MFLAGS) )
+
+install_gen: $(FONTCONFIG_LIB) $(SOURCE_DIR)/fonts.conf-SUNW $(FONTCONFIG_SMF_MANIFEST)
+	(cd $(SOURCE_DIR) ; $(FONTCONFIG_libpaths) $(MAKE) -e DESTDIR=$(FONTCONFIG_prefix) libdir=/usr/lib$(ARCHLIBSUBDIR) bindir=/usr/bin$(ARCHLIBSUBDIR) install )
+	rm $(PROTODIR)/etc/fonts/fonts.conf
+	cp $(SOURCE_DIR)/fonts.conf-SUNW $(PROTODIR)/etc/fonts/fonts.conf
+	$(MAKE) $(MFLAGS) fontconfig-sunman-install
+
+$(FONTCONFIG_SMF_MANIFEST): fc-cache.xml
+	/usr/sbin/svccfg validate fc-cache.xml
+	mkdir -p $(FONTCONFIG_SMF_MANIFEST_dir)
+	if [ -f $@ ] ; then /bin/rm -f $@ ; fi
+	cp fc-cache.xml $@
+
+# Quick inline perl script to fix up fc-cache & fc-list man pages
+FC_MAN_FIX=perl -n -MPOSIX=strftime -e \
+  'BEGIN { \
+	$$date=strftime("%e %b %Y",localtime((stat($$ARGV[0]))[9])); \
+	print "\047\\\" t\n"; \
+   } \
+   { \
+	s|__vendorversion__|"$$date"| ; \
+	s|__package__|SUNWfontconfig| ; \
+	s|fontconfig\(3\)|libfontconfig\(3lib\)|; \
+	s%^\\\|\.%.IR \\|.%; \
+	print \
+   }'
+
+fontconfig-sunman-install: $(PROTODIR)/usr/man/man5/fonts-conf.5
+	mkdir -p $(PROTODIR)/usr/man/man1 $(PROTODIR)/usr/man/man4 $(PROTODIR)/usr/man/man3lib
+	$(FC_MAN_FIX) $(PROTODIR)/usr/man/man5/fonts-conf.5 sunman-notes-fonts.conf $(TOP)/common/sunman-stability | sed -e 's/.TH "FONTS-CONF" "5"/.TH "fonts.conf" "4"/' -e 's/SUNWfontconfig/SUNWfontconfig-root/' > $(PROTODIR)/usr/man/man4/fonts.conf.4
+	-if [ -f $(PROTODIR)/usr/man/man3lib/libfontconfig.3lib ] ; then \
+		rm -f $(PROTODIR)/usr/man/man3lib/libfontconfig.3lib ; \
+	fi
+	perl -p -e 's/^$$/.LP/;' -e 's/\251/\\(co/;' libfontconfig.3lib $(SOURCE_DIR)/COPYING >> $(PROTODIR)/usr/man/man3lib/libfontconfig.3lib
+	for i in fc-cache fc-list ; do 			\
+	    if [ -f $(PROTODIR)/usr/man/man1/$$i.1 ] ; then 	\
+		rm -f $(PROTODIR)/usr/man/man1/$$i.1 ; 		\
+	    fi ;						\
+	    if [ -f sunman-notes-$$i ] ; then			\
+		APPEND="sunman-notes-$$i $(TOP)/common/sunman-stability" ;	\
+	    else						\
+		APPEND=$(TOP)/common/sunman-stability ;		\
+	    fi ;						\
+	    $(FC_MAN_FIX) $(SOURCE_DIR)/$$i/$$i.man $$APPEND > \
+		$(PROTODIR)/usr/man/man1/$$i.1 ;		\
+	done
+
+install_64::
+	-/bin/rm -f $(FONTCONFIG_libdir)/64
+	ln -s $(FONTCONFIG_libdir)/$(SUBDIR64) $(FONTCONFIG_libdir)/64
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/fc-cache.xml	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+	Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+	Use is subject to license terms.
+
+	ident	"@(#)fc-cache.xml	1.3	05/01/24 SMI"
+
+	Service manifest for ensuring fontconfig caches are up to date.
+-->
+
+<service_bundle type='manifest' name='SUNWfontconfig-root:fc-cache'>
+
+<service
+	name='application/font/fc-cache'
+	type='service'
+	version='1'>
+
+	<create_default_instance enabled='true' />
+
+	<single_instance />
+
+	<dependency
+		name='usr'
+		type='service'
+		grouping='require_all'
+		restart_on='none'>
+		<service_fmri value='svc:/system/filesystem/local' />
+	</dependency>
+
+	<dependency
+		name='config-file'
+		grouping='require_all'
+		restart_on='refresh'
+		type='path'>
+		<service_fmri value='file://localhost/etc/fonts/fonts.conf' />
+	</dependency>
+
+	<dependency
+		name='fc-cache'
+		grouping='require_all'
+		restart_on='none'
+		type='path'>
+		<service_fmri value='file://localhost/usr/bin/fc-cache' />
+	</dependency>
+
+	<exec_method
+		type='method'
+		name='start'
+		exec='/usr/bin/fc-cache'
+		timeout_seconds='3600'>
+		<method_context>
+                        <method_credential user='root' group='root' />
+                </method_context>
+        </exec_method>
+
+	<property_group name='startd' type='framework'>
+		<propval name='duration' type='astring'
+			value='transient' />
+	</property_group>
+
+	<property_group name='general' type='framework'>
+		<!-- manage server state -->
+		<propval name='action_authorization' type='astring'
+			value='solaris.smf.manage.font' />
+	</property_group>
+
+	<stability value='Evolving' />
+
+	<template>
+		<common_name>
+			<loctext xml:lang='C'>FontConfig Cache Builder
+				</loctext>
+		</common_name>
+
+		<documentation>
+			<manpage
+				title='fc-cache'
+				section='1M'
+				manpath='/usr/share/man' />
+		</documentation>
+	</template>
+</service>
+
+</service_bundle>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/fix-fonts.conf.pl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,198 @@
+#!/usr/perl5/bin/perl -w
+#
+# ident	"@(#)fix-fonts.conf.pl	1.5	04/11/16 SMI"
+#
+# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# This script performs a number of customizations to the fonts.conf shipped
+# with Solaris, including:
+#   - adding all the locale specific dirs listed in fontdirs file to the font path
+#   - append additional settings from fonts.conf.append file just before closing </fontdir>
+#   - Japanese customization requested in bug 5028919 - replace Kochi fonts with Sun fonts
+
+
+require 5.005;                          # minimal Perl version required
+use strict;                             # 
+use diagnostics;                        #
+
+my $line;
+my $newline;
+my $inalias = 0;
+my $aliasfamily = "";
+
+my $fontdirsreplaced = 0;
+my $kochifontsreplaced = 0;
+my $eudcfontsadded = 0;
+my $appended = 0;
+my $preuserconf = 0;
+
+while ($line = <>) {
+  # keep track of if we're in an <alias>...</alias> block and if so which one
+  if ($inalias == 0) {
+    if ($line =~ m|<alias>|) {
+      $inalias = 1;
+    }
+  } else {
+    if ($line =~ m|</alias>|) {
+      $inalias = 0;
+      $aliasfamily = "";
+    } elsif (($aliasfamily eq "") && ($line =~ m|<family>([^>]*)</family>|)) {
+      $aliasfamily = $1;
+    }
+  }
+
+  # replace --font-dirs-go-here-- with all the extra font dirs from the fontdirs file
+  if ($line =~ m|--font-dirs-go-here--|) {
+    my $fontdir;
+
+    open(FONTDIRLIST, "<fontdirs") || die "Cannot open file fontdirs";
+    while ($fontdir = <FONTDIRLIST>) {
+      $newline = $line;
+      chomp($fontdir);
+      # skip if line is blank or commented out
+      next if ($fontdir =~ /^\s*$/);
+      next if ($fontdir =~ /^\s*\#/);
+      $newline =~ s|--font-dirs-go-here--|$fontdir|;
+      print $newline;
+    }
+    close(FONTDIRLIST);
+    $fontdirsreplaced++;
+    next;
+  }
+  # Append contents of fonts.conf.preuser just before loading user configuration
+  if ($line =~ m|Load per-user customization file|) {
+    print " Additional Solaris-specific configuration settings\n -->\n\n";
+    open(INSERT, "<fonts.conf.preuser") || die "Cannot open file fonts.conf.preuser";
+    while ($newline = <INSERT>) {
+      print $newline;
+    }
+    close(INSERT);
+    $preuserconf++;
+    print "\n<!-- \n";
+    # Fall through to print $line at end
+  }
+  # Append contents of fonts.conf.append just before closing </fontconfig>
+  if ($line =~ m|</fontconfig>|) {
+    open(APPEND, "<fonts.conf.append") || die "Cannot open file fonts.conf.append";
+    while ($newline = <APPEND>) {
+      print $newline;
+    }
+    close(APPEND);
+    $appended++;
+    # Fall through to print $line at end
+  }
+  # Replace Kochi Mincho fonts with Sun Mincho fonts
+  # Add additional Sun CJK fonts
+  if ($line =~ m|<family>Kochi Mincho</family>|) {
+    $newline = $line;
+    $newline =~ s|Kochi Mincho|HG-PMinchoL-Sun|;
+    print $newline;
+    $newline = $line;
+    $newline =~ s|Kochi Mincho|HG-MinchoL-Sun|;
+    print $newline;
+    $newline = $line;
+    $newline =~ s|Kochi Mincho|FZSongTi|;
+    print $newline;
+    $newline = $line;
+    $newline =~ s|Kochi Mincho|FZMingTi|;
+    print $newline;
+    $newline = $line;
+    $newline =~ s|Kochi Mincho|KacstQurn|;
+    print $newline;
+    $line =~ s|Kochi Mincho|SunDotum|;
+    $kochifontsreplaced++;
+    # Fall through to print $line at end
+  }
+  # Replace Kochi Gothic fonts with Sun Gothic fonts
+  # Add additional Sun CJK fonts
+  if ($line =~ m|<family>Kochi Gothic</family>|) {
+    $newline = $line;
+    if ($aliasfamily ne "monospace") {
+        $newline =~ s|Kochi Gothic|HG-PGothicB-Sun|;
+    } else {
+        $newline =~ s|Kochi Gothic|HG-GothicB-Sun|;
+    }
+    print $newline;
+    $newline = $line;
+    if ($aliasfamily ne "monospace") {
+        $newline =~ s|Kochi Gothic|HG-GothicB-Sun|;
+    } else {
+        $newline =~ s|Kochi Gothic|HG-MinchoL-Sun|;
+    }
+    print $newline;
+    $newline = $line;
+    $newline =~ s|Kochi Gothic|FZSongTi|;
+    print $newline;
+    $newline = $line;
+    $newline =~ s|Kochi Gothic|FZMingTi|;
+    print $newline;
+    $newline = $line;
+    $newline =~ s|Kochi Gothic|KacstQurn|;
+    print $newline;
+    if ($aliasfamily ne "monospace") {
+      $line =~ s|Kochi Gothic|SunDotum|;
+    } else {
+      $line =~ s|Kochi Gothic|SunDotumChe|;
+    }
+    $kochifontsreplaced++;
+    # Fall through to print $line at end
+  }
+  # Add additional entries to monospace faces list
+  if ($line =~ m|<default><family>monospace</family></default>| ) {
+    $newline = $line;
+    $newline =~ s|<default><family>monospace</family></default>|<family>KacstQurn</family>|;
+    print $newline;
+    $newline = $line;
+    $newline =~ s|<default><family>monospace</family></default>|<family>SunDotumChe</family>|;
+    print $newline;
+  }
+  # Add Arial before Bitstream Vera Sans
+  if ($line =~ m|<family>Bitstream Vera Sans</family>| ) {
+    print "		<family>Arial</family>\n";
+  }
+  # Add Lucida Bright before Bitstream Vera Serif
+  if ($line =~ m|<family>Bitstream Vera Serif</family>| ) {
+    print "		<family>Lucida Bright</family>\n";
+  }
+  # Add Lucida Sans Typewriter before Bitstream Vera Serif
+  if ($line =~ m|<family>Bitstream Vera Sans Mono</family>| ) {
+    print "		<family>Lucida Sans Typewriter</family>\n";
+  }
+  # Add EUDC fonts to preferred fonts lists (bug 6195182)
+  if (($line =~ m|<family>Bitstream Vera|) && 
+      (($aliasfamily eq "serif") || ($aliasfamily eq "sans-serif") ||
+       ($aliasfamily eq "monospace"))) {
+    print $line;
+    $line =~ s|<family>[^>]+</family>|<family>EUDC</family>|;
+    $eudcfontsadded++;
+    # Fall through to print $line at end
+  }
+  print $line;
+}
+
+
+# Check to make sure we did everything
+if ($fontdirsreplaced == 0) {
+  die "Did not find --font-dirs-go-here-- tag to replace with list of font dirs!";
+}
+
+if ($appended == 0) {
+  die "Did not find </fontconfig> tag to add fonts.conf.append contents!";
+} elsif ($appended > 1) {
+  die "Found too many </fontconfig> tags!";
+}
+
+if ($preuserconf == 0) {
+  die "Did not find per-user customization comment tag to add fonts.conf.preuse contents!";
+} elsif ($appended > 1) {
+  die "Found too many per-user customization comment tags!";
+}
+
+if ($kochifontsreplaced != 5) {
+  die "Did not find expected number of Kochi font entries to edit! (Found $kochifontsreplaced instead of 5)";
+}
+
+if ($eudcfontsadded != 3) {
+  die "Did not find expected number of preferred font alias entries to insert EUDC into! (Found $eudcfontsadded instead of 3)";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/fontconfig-2.2.3.patch	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,126 @@
+Fixes these bugs:
+5036458: Chinese font is ugly and not match with English  [fccfg.c, fclang.c]
+5080044: Display Chinese in Japanese Font in UTF-8		[fcdefault.c]
+
+diff -ur src/fccfg.c
+--- src/fccfg.c	Wed Jun 30 11:20:19 2004
++++ src/fccfg.c	Wed Jun 30 14:24:04 2004
+@@ -606,12 +606,12 @@
+ 	case FcTypeCharSet:
+ 	    switch (op) {
+ 	    case FcOpContains:
+-		/* m contains v if v is a subset of m */
+-		ret = FcCharSetIsSubset (v.u.c, m.u.c);
++		/* v contains m if m is a subset of v */
++		ret = FcCharSetIsSubset (m.u.c, v.u.c);
+ 		break;
+ 	    case FcOpNotContains:
+-		/* m contains v if v is a subset of m */
+-		ret = !FcCharSetIsSubset (v.u.c, m.u.c);
++		/* v contains m if m is a subset of v */
++		ret = !FcCharSetIsSubset (m.u.c, v.u.c);
+ 		break;
+ 	    case FcOpEqual:
+ 		ret = FcCharSetEqual (m.u.c, v.u.c);
+@@ -626,16 +626,16 @@
+ 	case FcTypeLangSet:
+ 	    switch (op) {
+ 	    case FcOpContains:
+-		ret = FcLangSetContains (v.u.l, m.u.l);
++		ret = FcLangSetContains (m.u.l, v.u.l);
+ 		break;
+ 	    case FcOpNotContains:
+-		ret = FcLangSetContains (v.u.l, m.u.l);
++		ret = FcLangSetContains (m.u.l, v.u.l);
+ 		break;
+ 	    case FcOpEqual:
+-		ret = FcLangSetEqual (v.u.l, m.u.l);
++		ret = FcLangSetEqual (m.u.l, v.u.l);
+ 		break;
+ 	    case FcOpNotEqual:
+-		ret = !FcLangSetEqual (v.u.l, m.u.l);
++		ret = !FcLangSetEqual (m.u.l, v.u.l);
+ 		break;
+ 	    default:
+ 		break;
+diff -ur src/fclang.c
+--- src/fclang.c	Mon Jun  9 11:25:04 2003
++++ src/fclang.c	Wed Jun 30 14:24:04 2004
+@@ -144,29 +144,33 @@
+ }
+ 
+ /*
+- * Return FcTrue when s1 contains s2. 
++ * Return FcTrue when super contains sub. 
+  *
+- * s1 contains s2 if s1 equals s2 or if s1 is a
+- * language with a country and s2 is just a language
++ * super contains sub if super and sub have the same
++ * language and either the same country or one
++ * is missing the country
+  */
+ 
+ static FcBool
+-FcLangContains (const FcChar8 *s1, const FcChar8 *s2)
++FcLangContains (const FcChar8 *super, const FcChar8 *sub)
+ {
+     FcChar8	    c1, c2;
+ 
+     for (;;)
+     {
+-	c1 = *s1++;
+-	c2 = *s2++;
++	c1 = *super++;
++	c2 = *sub++;
+ 	
+ 	c1 = FcToLower (c1);
+ 	c2 = FcToLower (c2);
+ 	if (c1 != c2)
+ 	{
+-	    /* see if s1 has a country while s2 is mising one */
++	    /* see if super has a country while sub is mising one */
+ 	    if (c1 == '-' && c2 == '\0')
+ 		return FcTrue;
++	    /* see if sub has a country while super is mising one */
++	    if (c1 == '\0' && c2 == '-')
++		return FcTrue;
+ 	    return FcFalse;
+ 	}
+ 	else if (!c1)
+--- src/fcdefault.c	Wed Mar 12 14:16:25 2003
++++ src/fcdefault.c	Thu Sep 23 13:36:36 2004
+@@ -115,8 +115,11 @@
+ 	{
+ 	    lang = ctype;
+ 	    territory = strchr (ctype, '_');
+-	    if (territory)
++	    after = strchr (ctype, '.');
++	    if (territory || after)
+ 	    {
++	      if (territory)
++	      {
+ 		lang_len = territory - lang;
+ 		territory = territory + 1;
+ 		after = strchr (territory, '.');
+@@ -135,6 +138,21 @@
+ 		    lang_local[lang_len + 1 + territory_len] = '\0';
+ 		    FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang_local);
+ 		}
++              }
++	      /*
++	       * Hack for Solaris platform, it has some locales that don't have
++	       * territory information in their locale name such as zh.GBK,
++	       * zh.UTF-8 and ko.UTF-8 etc.
++	       * Bugfix 5080044, without this hack, Japanese font would be 
++	       * wrongly used in gnome terminal in above locales.
++               */
++	      else
++	      {
++		  lang_len = after - lang;
++		  strncpy (lang_local, lang, lang_len);
++		  lang_local[lang_len] = '\0';
++		  FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang_local);
++	      }
+ 	    }
+ 	    else
+ 		FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/fontconfig-2.3.2.patch	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,296 @@
+diff -ur fontconfig-2.3.2/src/fccfg.c fontconfig-2.3.2.new/src/fccfg.c
+--- src/fccfg.c	Wed Jun 30 11:20:19 2004
++++ new/src/fccfg.c	Wed Jun 30 14:24:04 2004
+@@ -655,12 +655,12 @@
+ 	    switch (op) {
+ 	    case FcOpContains:
+ 	    case FcOpListing:
+-		/* left contains right if right is a subset of left */
+-		ret = FcCharSetIsSubset (right.u.c, left.u.c);
++		/* right contains left if left is a subset of right */
++		ret = FcCharSetIsSubset (left.u.c, right.u.c);
+ 		break;
+ 	    case FcOpNotContains:
+-		/* left contains right if right is a subset of left */
+-		ret = !FcCharSetIsSubset (right.u.c, left.u.c);
++		/* right contains left if left is a subset of right */
++		ret = !FcCharSetIsSubset (left.u.c, right.u.c);
+ 		break;
+ 	    case FcOpEqual:
+ 		ret = FcCharSetEqual (left.u.c, right.u.c);
+--- src/fcdefault.c	Wed Mar 12 14:16:25 2003
++++ new/src/fcdefault.c	Thu Sep 23 13:36:36 2004
+@@ -115,8 +115,11 @@
+ 	{
+ 	    lang = ctype;
+ 	    territory = strchr (ctype, '_');
+-	    if (territory)
++	    after = strchr (ctype, '.');
++	    if (territory || after)
+ 	    {
++	      if (territory)
++	      {
+ 		lang_len = territory - lang;
+ 		territory = territory + 1;
+ 		after = strchr (territory, '.');
+@@ -135,6 +138,21 @@
+ 		    lang_local[lang_len + 1 + territory_len] = '\0';
+ 		    FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang_local);
+ 		}
++	      }
++              /*
++               * Hack for Solaris platform, it has some locales that don't have
++               * territory information in their locale name such as zh.GBK,
++               * zh.UTF-8 and ko.UTF-8 etc.
++               * Bugfix 5080044, without this hack, Japanese font would be
++               * wrongly used in gnome terminal in above locales.
++                */
++              else
++              {
++                  lang_len = after - lang;
++                  strncpy (lang_local, lang, lang_len);
++                  lang_local[lang_len] = '\0';
++                  FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang_local);
++              }
+ 	    }
+ 	    else
+ 		FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang);
+--- src/fcmatch.c	Tue Oct  4 15:13:20 2005
++++ new/src/fcmatch.c	Fri Jan 13 14:49:32 2006
+@@ -162,6 +162,15 @@
+     if (v2 == 0)
+ 	return 0;
+     v = v2 - v1;
++
++    /*
++     * Hack to allow bitmap fonts to equal requested font if it is close
++     */
++    if ( v > -.5 && v <= .5 )
++    {
++        v = 0;
++    }
++
+     if (v < 0)
+ 	v = -v;
+     return v;
+@@ -482,6 +491,45 @@
+     return new;
+ }
+ 
++static void
++FcChangeFormat ( FcPattern *p )
++{
++    int i;
++
++    /*
++     * Hack. If user want monochrome mode, then try to pick bitmaps over
++     * outlines.
++     */
++    for ( i = 0; i < p->num; i++ )
++    {
++        if ( !strcmp(p->elts[i].object, "antialias" ))
++        {
++            int aa = (int)p->elts[i].values->value.u.b;
++            int j;
++            int done = 0;
++            FcValue v;
++ 
++            v.type = FcTypeBool;
++            v.u.b  = aa;
++ 
++            for ( j = 0; j < p->num; j++ )
++            {
++                if ( !strcmp(p->elts[j].object, "outline" ))
++                {
++                    done = 1;
++                    break;
++                }
++            }
++            if ( !done )
++            {
++                FcPatternAddWithBinding  (p, "outline", v,
++                            FcValueBindingStrong, 1);
++            }
++            break;
++        }
++    }
++}
++
+ FcPattern *
+ FcFontSetMatch (FcConfig    *config,
+ 		FcFontSet   **sets,
+@@ -496,6 +544,8 @@
+     int		    i;
+     int		    set;
+ 
++    FcChangeFormat ( p );
++
+     for (i = 0; i < NUM_MATCH_VALUES; i++)
+ 	bestscore[i] = 0;
+     best = 0;
+@@ -679,9 +729,11 @@
+     int		    f;
+     int		    i;
+     int		    nPatternLang;
+-    FcBool    	    *patternLangSat;
++    int    	    *patternLangSat;
+     FcValue	    patternLang;
+ 
++    FcChangeFormat ( p );
++
+     if (FcDebug () & FC_DBG_MATCH)
+     {
+ 	printf ("Sort ");
+@@ -710,7 +762,7 @@
+     if (!nodes)
+ 	goto bail0;
+     nodeps = (FcSortNode **) (nodes + nnodes);
+-    patternLangSat = (FcBool *) (nodeps + nnodes);
++    patternLangSat = (int *) (nodeps + nnodes);
+     
+     new = nodes;
+     nodep = nodeps;
+@@ -750,8 +802,13 @@
+ 	   FcSortCompare);
+     
+     for (i = 0; i < nPatternLang; i++)
+-	patternLangSat[i] = FcFalse;
+-    
++	patternLangSat[i] = 0;
++
++    /*
++     * For Solaris, because of ja_JP, en_US, and such locales, exact matches
++     * with font language support is sporatic. To resolve this, allow close
++     * matches to succeed, but be able to accept exact matches above them.
++     */
+     for (f = 0; f < nnodes; f++)
+     {
+ 	FcBool	satisfies = FcFalse;
+@@ -759,19 +816,19 @@
+ 	 * If this node matches any language, go check
+ 	 * which ones and satisfy those entries
+ 	 */
+-	if (nodeps[f]->score[MATCH_LANG_INDEX] < nPatternLang)
++	if (nodeps[f]->score[MATCH_LANG_INDEX] <= 100 )
+ 	{
+ 	    for (i = 0; i < nPatternLang; i++)
+ 	    {
+ 		FcValue	    nodeLang;
+ 		
+-		if (!patternLangSat[i] &&
++		if (patternLangSat[i] != 1 &&
+ 		    FcPatternGet (p, FC_LANG, i, &patternLang) == FcResultMatch &&
+ 		    FcPatternGet (nodeps[f]->pattern, FC_LANG, 0, &nodeLang) == FcResultMatch)
+ 		{
+ 		    double  compare = FcCompareLang (FC_LANG, patternLang, 
+ 						     nodeLang);
+-		    if (compare >= 0 && compare < 2)
++		    if (compare >= 0 && compare < 2 && ( patternLangSat[i] == 0 || compare + 1 < patternLangSat[i]))
+ 		    {
+ 			if (FcDebug () & FC_DBG_MATCHV)
+ 			{
+@@ -782,7 +839,7 @@
+ 				FcPatternGetString (nodeps[f]->pattern, FC_STYLE, 0, &style) == FcResultMatch)
+ 				printf ("Font %s:%s matches language %d\n", family, style, i);
+ 			}
+-			patternLangSat[i] = FcTrue;
++			patternLangSat[i] = (int)compare + 1;
+ 			satisfies = FcTrue;
+ 			break;
+ 		    }
+--- src/fcxml.c		Tue Jan 24 10:37:09 2006
++++ new/src/fcxml.c	Tue Jan 24 10:46:08 2006
+@@ -22,6 +22,7 @@
+  * PERFORMANCE OF THIS SOFTWARE.
+  */
+ 
++#include <fcntl.h>
+ #include <stdarg.h>
+ #include "fcint.h"
+ #include <dirent.h>
+@@ -2304,7 +2305,7 @@
+ 
+     XML_Parser	    p;
+     FcChar8	    *filename;
+-    FILE	    *f;
++    int		    fd;
+     int		    len;
+     void	    *buf;
+     FcConfigParse   parse;
+@@ -2330,12 +2331,15 @@
+     if (FcDebug () & FC_DBG_CONFIG)
+ 	printf ("\tLoading config file %s\n", filename);
+ 
+-    f = fopen ((char *) filename, "r");
+-    FcStrFree (filename);
+-    if (!f)
++    fd = open ((char *) filename, O_RDONLY);
++    if (fd == -1) { 
++	FcStrFree (filename);
+ 	goto bail0;
++    }
+     
+     p = XML_ParserCreate ("UTF-8");
++    FcStrFree (filename);
++
+     if (!p)
+ 	goto bail1;
+ 
+@@ -2355,7 +2359,7 @@
+ 	    FcConfigMessage (&parse, FcSevereError, "cannot get parse buffer");
+ 	    goto bail3;
+ 	}
+-	len = fread (buf, 1, BUFSIZ, f);
++	len = read (fd, buf, BUFSIZ);
+ 	if (len < 0)
+ 	{
+ 	    FcConfigMessage (&parse, FcSevereError, "failed reading config file");
+@@ -2374,7 +2378,8 @@
+ bail2:
+     XML_ParserFree (p);
+ bail1:
+-    fclose (f);
++    close (fd);
++    fd = -1;
+ bail0:
+     if (error && complain)
+     {
+
+--- Makefile.am	Wed Mar  2 22:20:57 2005
++++ Makefile.am	Wed Feb  8 13:21:18 2006
+@@ -91,16 +91,6 @@
+ 	  echo " $(INSTALL_DATA) fonts.conf $(DESTDIR)$(configdir)/fonts.conf"; \
+ 	  $(INSTALL_DATA) fonts.conf $(DESTDIR)$(configdir)/fonts.conf; \
+ 	fi; fi
+-	if $(RUN_FC_CACHE_TEST); then \
+-	    echo " fc-cache/fc-cache -f -v"; \
+-	    fc-cache/fc-cache -f -v; \
+-	else \
+-	    echo "***"; \
+-	    echo "*** Warning: fonts.cache not built"; \
+-	    echo "***"; \
+-	    echo "*** Generate this file manually on host system using fc-cache"; \
+-	    echo "***"; \
+-	fi
+ 
+ uninstall-local:
+ 	if [ -f $(srcdir)/fonts.conf ]; then \
+--- Makefile.in	Wed Apr 27 12:08:47 2005
++++ Makefile.in	Wed Feb  8 13:32:14 2006
+@@ -733,16 +733,6 @@
+ 	  echo " $(INSTALL_DATA) fonts.conf $(DESTDIR)$(configdir)/fonts.conf"; \
+ 	  $(INSTALL_DATA) fonts.conf $(DESTDIR)$(configdir)/fonts.conf; \
+ 	fi; fi
+-	if $(RUN_FC_CACHE_TEST); then \
+-	    echo " fc-cache/fc-cache -f -v"; \
+-	    fc-cache/fc-cache -f -v; \
+-	else \
+-	    echo "***"; \
+-	    echo "*** Warning: fonts.cache not built"; \
+-	    echo "***"; \
+-	    echo "*** Generate this file manually on host system using fc-cache"; \
+-	    echo "***"; \
+-	fi
+ 
+ uninstall-local:
+ 	if [ -f $(srcdir)/fonts.conf ]; then \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/fontdirs	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,50 @@
+/usr/openwin/lib/X11/fonts/TrueType
+/usr/openwin/lib/X11/fonts/Type1
+/usr/openwin/lib/X11/fonts/pcf
+/usr/openwin/lib/locale/KOI8-R/X11/fonts/TrueType/
+/usr/openwin/lib/locale/ar/X11/fonts/TrueType/
+/usr/openwin/lib/locale/en_US.UTF-8/X11/fonts/misc/
+/usr/openwin/lib/locale/hi_IN.UTF-8/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_13/X11/fonts/75dpi/
+/usr/openwin/lib/locale/iso_8859_13/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_15/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_2/X11/fonts/75dpi/
+/usr/openwin/lib/locale/iso_8859_2/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_2/X11/fonts/Type1/
+/usr/openwin/lib/locale/iso_8859_4/X11/fonts/75dpi/
+/usr/openwin/lib/locale/iso_8859_4/X11/fonts/Type1/
+/usr/openwin/lib/locale/iso_8859_5/X11/fonts/75dpi/
+/usr/openwin/lib/locale/iso_8859_5/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_5/X11/fonts/Type1/
+/usr/openwin/lib/locale/iso_8859_7/X11/fonts/75dpi/
+/usr/openwin/lib/locale/iso_8859_7/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_7/X11/fonts/Type1/
+/usr/openwin/lib/locale/iso_8859_8/X11/fonts/75dpi/
+/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_8/X11/fonts/Type1/
+/usr/openwin/lib/locale/iso_8859_9/X11/fonts/75dpi/
+/usr/openwin/lib/locale/iso_8859_9/X11/fonts/TrueType/
+/usr/openwin/lib/locale/iso_8859_9/X11/fonts/Type1/
+/usr/openwin/lib/locale/ja/X11/fonts/75dpi/
+/usr/openwin/lib/locale/ja/X11/fonts/TT/
+/usr/openwin/lib/locale/ja/X11/fonts/TTbitmaps/
+/usr/openwin/lib/locale/ko.UTF-8/X11/fonts/75dpi/
+/usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType/
+/usr/openwin/lib/locale/ko/X11/fonts/75dpi/
+/usr/openwin/lib/locale/ko/X11/fonts/TrueType/
+/usr/openwin/lib/locale/ru.ansi-1251/X11/fonts/TrueType/
+/usr/openwin/lib/locale/th_TH/X11/fonts/75dpi/
+/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/
+/usr/openwin/lib/locale/zh.GBK/X11/fonts/75dpi/
+/usr/openwin/lib/locale/zh.GBK/X11/fonts/TrueType/
+/usr/openwin/lib/locale/zh/X11/fonts/75dpi/
+/usr/openwin/lib/locale/zh/X11/fonts/TrueType/
+/usr/openwin/lib/locale/zh_CN.GB18030/X11/fonts/75dpi/
+/usr/openwin/lib/locale/zh_CN.GB18030/X11/fonts/TrueType/
+/usr/openwin/lib/locale/zh_HK.BIG5HK/X11/fonts/75dpi/
+/usr/openwin/lib/locale/zh_HK.BIG5HK/X11/fonts/TT/
+/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/75dpi/
+/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT/
+/usr/openwin/lib/locale/zh_TW/X11/fonts/75dpi/
+/usr/openwin/lib/locale/zh_TW/X11/fonts/TrueType/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/fonts.conf.append	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,99 @@
+<!--
+  Prefer bitmap	fonts if the option "prefer_bitmap" is set to true.
+ -->
+
+<match target="font">
+	<test name="prefer_bitmap">
+		<bool>true</bool>
+	</test>
+	<test name="family">
+		<string>FZSongTi</string>
+		<string>FZMingTi</string>
+	</test>
+	<test name="pixelsize" compare="more_eq">
+		<double>11.5</double>
+	</test>
+	<test name="pixelsize" compare="less">
+		<double>17.5</double>
+	</test>
+	<edit name="antialias" mode="assign">
+		<bool>false</bool>
+	</edit>
+</match>
+<match target="font">
+	<test name="prefer_bitmap">
+		<bool>true</bool>
+	</test>
+	<test name="family">
+		<string>SunDotum</string>
+		<string>SunDotumChe</string>
+	</test>
+	<test name="pixelsize" compare="more_eq">
+		<double>11</double>
+	</test>
+	<test name="pixelsize" compare="less">
+		<double>25</double>
+	</test>
+	<edit name="antialias" mode="assign">
+		<bool>false</bool>
+	</edit>
+</match>
+
+<match target="font">
+	<test name="prefer_bitmap">
+		<bool>true</bool>
+	</test>
+	<test name="family">
+		<string>HG-GothicB-Sun</string>
+		<string>HG-PGothicB-Sun</string>
+		<string>HG-MinchoL-Sun</string>
+		<string>HG-PMinchoL-Sun</string>
+	</test>
+	<test name="pixelsize" compare="more_eq">
+		<double>10</double>
+	</test>
+	<test name="pixelsize" compare="less">
+		<double>22</double>
+	</test>
+	<edit name="antialias" mode="assign">
+		<bool>false</bool>
+	</edit>
+</match>
+
+<match target="font">
+	<test name="prefer_bitmap">
+		<bool>true</bool>
+	</test>
+	<test name="family">
+		<string>MS Gothic</string>
+		<string>MS PGothic</string>
+		<string>MS UI Gothic</string>
+		<string>MS Mincho</string>
+		<string>MS PMincho</string>
+	</test>
+	<test name="pixelsize" compare="more_eq">
+		<double>7</double>
+	</test>
+	<test name="pixelsize" compare="less_eq">
+		<double>22</double>
+	</test>
+	<edit name="antialias" mode="assign">
+		<bool>false</bool>
+	</edit>
+</match>
+
+<!--
+ Artificial bold for fonts without an bold version
+ -->
+<match target="font">
+	<test name="weight" compare="less_eq">
+		<const>medium</const>
+	</test>
+	<test target="pattern" name="weight" compare="more">
+		<const>medium</const>
+	</test>
+	<edit name="weight" mode="assign">
+		<const>bold</const>
+	</edit>
+</match>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/fonts.conf.preuser	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,75 @@
+<!--
+ Hinting for CJK fonts doesn't yet work as well as for Latin fonts.
+ Some people may want to turn it off:
+ -->
+
+<match target="font">
+	<test name="lang" compare="contains">
+		<string>zh</string>
+		<string>ko</string>
+		<string>ja</string>
+	</test>
+	<edit name="hinting" mode="assign">
+		<bool>false</bool>
+	</edit>
+</match>
+
+<!--
+ Chinese fonts are too light. We want to darken them up.
+ darken_value is an int between 1 and 9 where 1 is a little
+ darker and 9 is very dark. The default is 6.
+ -->
+
+<match target="font">
+        <test name="lang" compare="contains">
+                <string>zh</string>
+        </test>
+        <edit name="darken" mode="assign">
+                <bool>true</bool>
+        </edit>
+        <edit name="darken_value" mode="assign">
+                <int>6</int>
+        </edit>
+</match>
+
+<!--
+  To avoid using embedded bitmaps in TrueType fonts
+  put the following rule in your personal ~/.fonts.conf file:
+                                                                         
+  <match target="pattern">
+        <edit name="prefer_bitmap">
+                <bool>false</bool>
+        </edit>
+  </match>
+-->
+<match target="pattern">
+	<edit name="prefer_bitmap">
+		<bool>true</bool>
+	</edit>
+</match>
+<match target="font">
+	<!-- check to see if the font is roman -->
+	<test name="slant">
+		<const>roman</const>
+	</test>
+	<!-- check to see if the pattern requested non-roman -->
+	<test target="pattern" name="slant" compare="not_eq">
+		<const>roman</const>
+	</test>
+	<edit name="prefer_bitmap">
+		<bool>false</bool>
+	</edit>
+</match>
+<!-- Latin fonts should not be used for ASCII characters when using
+     Japanese monospace families -->
+<match target="pattern">
+	<test name="family">
+		<string>monospace</string>
+	</test>
+	<test name="lang" compare="eq">
+		<string>ja-jp</string>
+	</test>
+	<edit name="disable_pango_script">
+		<bool>true</bool>
+	</edit>
+</match>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/libfontconfig.3lib	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,120 @@
+'\" t
+.\" Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+.\" Use subject to license terms.
+.\"
+.\" ident	"@(#)libfontconfig.3lib	1.3	04/11/17 SMI"
+.\"
+.\" This man page created by Sun to document stability level & license
+.\"
+.TH libfontconfig 3lib "4 Nov 2004"
+.SH NAME
+libfontconfig \- font configuration API
+.SH SYNOPSIS
+Use 
+.B pkg-config fontconfig
+to determine compiler and linker flags.
+.SH DESCRIPTION
+Fontconfig is a library for configuring and customizing font access.
+Information about fontconfig and open source releases may be found at
+.B http://www.fontconfig.org/
+.SH INTERFACES
+The shared object libfontconfig.so.1 provides the  public  interfaces
+defined  below.  See the man page for each function for additional 
+information.
+
+.TS
+lw(2.750000i) lw(2.750000i).
+FcAtomicCreate               FcFreeTypeQuery 
+FcAtomicDeleteNew            FcGetVersion 
+FcAtomicDestroy              FcInit 
+FcAtomicLock                 FcInitBringUptoDate 
+FcAtomicNewFile              FcInitLoadConfig 
+FcAtomicOrigFile             FcInitLoadConfigAndFonts 
+FcAtomicReplaceOrig          FcInitReinitialize 
+FcAtomicUnlock               FcMatrixCopy 
+FcBlanksAdd                  FcMatrixEqual 
+FcBlanksCreate               FcMatrixInit 
+FcBlanksDestroy              FcMatrixMultiply 
+FcBlanksIsMember             FcMatrixRotate 
+FcCharSetAddChar             FcMatrixScale 
+FcCharSetCopy                FcMatrixShear 
+FcCharSetCount               FcNameConstant 
+FcCharSetCreate              FcNameGetConstant 
+FcCharSetDestroy             FcNameGetObjectType 
+FcCharSetEqual               FcNameParse 
+FcCharSetFirstPage           FcNameRegisterConstants 
+FcCharSetHasChar             FcNameRegisterObjectTypes 
+FcCharSetIntersect           FcNameUnparse 
+FcCharSetIntersectCount      FcNameUnregisterConstants 
+FcCharSetIsSubset            FcNameUnregisterObjectTypes 
+FcCharSetNextPage            FcObjectSetAdd 
+FcCharSetSubtract            FcObjectSetBuild 
+FcCharSetSubtractCount       FcObjectSetCreate 
+FcCharSetUnion               FcObjectSetDestroy 
+FcConfigAppFontAddDir        FcPatternAdd-Type 
+FcConfigAppFontAddFile       FcPatternAdd 
+FcConfigAppFontClear         FcPatternAddWeak 
+FcConfigBuildFonts           FcPatternBuild 
+FcConfigCreate               FcPatternCreate 
+FcConfigDestroy              FcPatternDel 
+FcConfigFilename             FcPatternDestroy 
+FcConfigGetBlanks            FcPatternEqual 
+FcConfigGetCache             FcPatternEqualSubset 
+FcConfigGetConfigDirs        FcPatternGet-Type 
+FcConfigGetConfigFiles       FcPatternGet 
+FcConfigGetCurrent           FcPatternHash 
+FcConfigGetFontDirs          FcPatternPrint 
+FcConfigGetFonts             FcStrBasename 
+FcConfigGetRescanInverval    FcStrCmpIgnoreCase 
+FcConfigParseAndLoad         FcStrCopy 
+FcConfigSetCurrent           FcStrCopyFilename 
+FcConfigSetRescanInverval    FcStrDirname 
+FcConfigSubstitute           FcStrListCreate 
+FcConfigSubstituteWithPat    FcStrListDone 
+FcConfigUptoDate             FcStrListNext 
+FcDefaultSubstitute          FcStrSetAdd 
+FcDirCacheValid              FcStrSetAddFilename 
+FcDirSave                    FcStrSetCreate 
+FcDirScan                    FcStrSetDel 
+FcFileScan                   FcStrSetDestroy 
+FcFontList                   FcStrSetMember 
+FcFontMatch                  FcUcs4ToUtf8 
+FcFontRenderPrepare          FcUtf16Len 
+FcFontSetAdd                 FcUtf16ToUcs4 
+FcFontSetCreate              FcUtf8Len 
+FcFontSetDestroy             FcUtf8ToUcs4 
+FcFontSort                   FcValueDestroy 
+FcFreeTypeCharIndex          FcValueSave 
+FcFreeTypeCharSet
+.TE
+.SH FILES
+.PD 0
+.TP 20
+/usr/lib/libfontconfig.so.1
+shared object
+.TP
+/usr/lib/64/libfontconfig.so.1
+64-bit shared object
+.PD
+.SH ATTRIBUTES
+See
+.BR attributes (5)
+for descriptions of the following attributes:
+.sp
+.TS
+box;
+cbp-1 | cbp-1
+l | l .
+ATTRIBUTE TYPE	ATTRIBUTE VALUE
+=
+Availability	SUNWfontconfig
+=
+Interface Stability	External
+.TE
+.SH "SEE ALSO"
+.BR pkg-config (1), 
+.BR fc-cache (1), 
+.BR fc-list (1), 
+.BR fonts.conf (4)
+.SH LICENSE
+.\" Makefile will append license from COPYING file in fontconfig src here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/fontconfig/sunman-notes-fc-cache	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,16 @@
+.\\" Begin Sun update for SMF
+.SH "NOTES"
+.PP
+\fBfc-cache\fR is run automatically at system boot to ensure font caches are
+up to date via the \fBfc-cache\fR service.
+The \fBfc-cache\fR service is managed by the service management facility, 
+\fBsmf\fR(5), under the service identifier:
+.PP
+.nf
+svc:/application/font/fc-cache
+.fi
+.PP
+Administrative actions on this service, such as enabling, disabling, or 
+requesting restart, can be performed using \fBsvcadm\fR(1M)\&. 
+The service\&'s status can be queried using the \fBsvcs\fR(1) command\&.
+.\\" End Sun update
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/freetype/Makefile	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,108 @@
+###############################################################################
+#
+# Freetype 2.x Makefile
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+# @(#)Makefile	1.60	05/11/21
+#
+
+PWD:sh=pwd
+TOP=$(PWD)/../..
+
+# Build 32-bit, 64-bit, or both?
+BUILD_TYPES=32 64
+
+# Version number (used in path names)
+FT_VERS=2.1.10
+
+# Source tarball
+SOURCE_TARBALL_NAME=freetype-$(FT_VERS).tar.bz2
+
+# Download site for source
+SOURCE_URL=http://savannah.nongnu.org/download/freetype/$(SOURCE_TARBALL_NAME)
+
+# Patches to apply to source after unpacking, in order
+SOURCE_PATCHES=freetype-$(FT_VERS).patch
+
+# Directory created by unpacking source
+SOURCE_DIR=$(BUILD_DIR)/freetype-$(FT_VERS)
+
+# Command line options to GNU autoconf configure script
+FT_CFG="--enable-shared=yes --enable-static=no --prefix=/usr/sfw"
+
+# Library built in tree
+FT_LIB=$(FT_DIR)/objs/.libs/libfreetype.so.6.3.8
+
+# Where to install most files
+FT_prefix=$(PROTODIR)/usr/sfw
+
+# Where to install libraries
+FT_libdir=$(FT_prefix)/lib
+
+# What to build
+BUILD_TARGETS=$(GNUMAKE) $(FT_LIB)
+
+### Include common rulesets
+include $(TOP)/common/Makefile.inc
+
+### Rules specific to this directory:
+
+# Run configure script (Freetype helpfully does this the first time you call
+# gmake - this isn't normal for autoconf programs)
+$(SOURCE_DIR)/config.mk: $(UNPACK_TARGET)
+	(cd $(SOURCE_DIR) ; \
+	 chmod a+x builds/unix/configure builds/unix/mkinstalldirs builds/unix/install-sh ; \
+	 CC=$(CC) CFLAGS="$(LIB_CFLAGS)" LD="$(CC) $(LIB_CFLAGS) $(LDFLAGS)" LDFLAGS="$(LIB_LDFLAGS)" MAKE=$(GNUMAKE) CFG=$(FT_CFG) \
+	 $(GNUMAKE) $(MFLAGS) )
+
+# Build Freetype
+$(FT_LIB): $(SOURCE_DIR)/config.mk
+	(cd $(SOURCE_DIR) ; LD_OPTIONS="$(LIB_LDFLAGS)" $(GNUMAKE) )
+
+install_gen: $(FT_LIB) $(SOURCE_DIR)/builds/unix/SUNW-freetype-config
+	(cd $(SOURCE_DIR) ; $(GNUMAKE) prefix=$(FT_prefix) libdir=$(FT_libdir)/$(ARCHLIBSUBDIR) install )
+	mkdir -p $(PROTODIR)/usr/sfw/bin$(ARCHLIBSUBDIR)
+	-rm -f $(PROTODIR)/usr/sfw/bin$(ARCHLIBSUBDIR)/freetype-config 
+	rm $(PROTODIR)/usr/sfw/lib$(ARCHLIBSUBDIR)/pkgconfig/freetype2.pc $(PROTODIR)/usr/sfw/lib$(ARCHLIBSUBDIR)/libfreetype.la
+	$(SOURCE_DIR)/builds/unix/install-sh -m 755 $(SOURCE_DIR)/builds/unix/SUNW-freetype-config $(PROTODIR)/usr/sfw/bin$(ARCHLIBSUBDIR)/freetype-config
+	$(SOURCE_DIR)/builds/unix/install-sh -m 755 $(SOURCE_DIR)/builds/unix/SUNW-freetype2.pc $(PROTODIR)/usr/sfw/lib$(ARCHLIBSUBDIR)/pkgconfig/freetype2.pc
+
+install_64::
+	-/bin/rm -f $(FT_libdir)/64 $(PROTODIR)/usr/sfw/bin/64
+	ln -s $(FT_libdir)/$(SUBDIR64) $(FT_libdir)/64
+	ln -s $(PROTODIR)/usr/sfw/bin/$(SUBDIR64) $(PROTODIR)/usr/sfw/bin/64
+
+# Hack to add -R option required for linking on Solaris and 64-bit library path
+# and remove unnecessary -lz
+$(SOURCE_DIR)/builds/unix/freetype-config: $(SOURCE_DIR)/config.mk
+
+$(SOURCE_DIR)/builds/unix/SUNW-freetype-config: $(SOURCE_DIR)/builds/unix/freetype-config
+	sed -e 's|libdir=$${exec_prefix}/lib$$|libdir=$${exec_prefix}/lib${LIBSUBDIR}|' -e 's|-lz||' $(SOURCE_DIR)/builds/unix/freetype-config > $(SOURCE_DIR)/builds/unix/SUNW-freetype-config
+	sed -e 's|-L$${exec_prefix}/lib|-L$${exec_prefix}/lib -R$${exec_prefix}/lib|' -e 's|-L$${libdir}|-L$${libdir} -R$${libdir}|' -e 's|$${exec_prefix}/lib|$${exec_prefix}/lib${LIBSUBDIR}|' -e 's|-lz||' -e 's|-I$${includedir}/freetype2|-I$${includedir} -I$${includedir}/freetype2|' $(SOURCE_DIR)/builds/unix/freetype2.pc > $(SOURCE_DIR)/builds/unix/SUNW-freetype2.pc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/freetype/freetype-2.1.10.patch	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,98 @@
+fixed CR6229445: fc-cache crash
+
+--- src/lzw/zopen.c	Tue Mar  1 13:54:50 2005
++++ src/lzw/zopen.c	Tue Mar  1 16:00:09 2005
+@@ -355,7 +355,11 @@
+ 		}
+ 		roffset = 0;
+ 		/* Round size down to integral number of codes. */
+-		size = (size << 3) - (n_bits - 1);
++                if(size) {
++                    size = (size << 3) - (n_bits - 1);
++                }else
++                    return -1;
++
+ 	}
+ 	r_off = roffset;
+ 	bits = n_bits;
+--- src/pcf/pcfdrivr.c	Mon Nov 21 13:31:24 2004
++++ new/src/pcf/pcfdrivr.c Fri Sep 16 11:18:37 2005
+@@ -402,6 +402,11 @@
+                       FT_UInt     vert_resolution )
+   {
+     PCF_Face  face = (PCF_Face)FT_SIZE_FACE( size );
++    /*
++     * Find a close match. Does not have to be exact match. (too difficult)
++     */
++    int       sm_y_ppem = size->metrics.y_ppem;
++    int       fr_y_ppem = face->root.available_sizes->y_ppem >> 6;
+
+     FT_UNUSED( char_width );
+     FT_UNUSED( char_height );
+@@ -413,7 +418,7 @@
+                 size->metrics.y_ppem,
+                 face->root.available_sizes->y_ppem >> 6 ));
+
+-    if ( size->metrics.y_ppem == face->root.available_sizes->y_ppem >> 6 )
++    if ( sm_y_ppem >= fr_y_ppem - 4 && sm_y_ppem <= fr_y_ppem + 4 )
+     {
+       size->metrics.ascender    = face->accel.fontAscent << 6;
+       size->metrics.descender   = face->accel.fontDescent * (-64);
+--- src/pcf/pcfread.c      Fri Sep 23 14:50:03 2004
++++ new/src/pcf/pcfread.c   Fri Sep 23 14:39:23 2005
+@@ -891,6 +891,7 @@
+     FT_Error   error  = PCF_Err_Ok;
+     FT_Face    face   = FT_FACE( pcf );
+     FT_Memory  memory = face->memory;
++    int        weight = 0;
+
+     PCF_Property  prop;
+
+@@ -917,7 +918,8 @@
+
+     prop = pcf_find_property( pcf, "WEIGHT_NAME" );
+     if ( prop && prop->isString                                       &&
+-         ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
++         ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ||
++           *(prop->value.atom) == 'D' || *(prop->value.atom) == 'd' ) )
+     {
+       face->style_flags |= FT_STYLE_FLAG_BOLD;
+       bstr = (char *)"Bold";
+@@ -924,6 +926,11 @@
+       len += ft_strlen( bstr );
+       parts++;
+     }
++    if ( prop && prop->isString                                       &&
++         ( *(prop->value.atom) == 'M' || *(prop->value.atom) == 'm' ) )
++    {
++       weight = 100;
++    }
+
+     prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
+     if ( prop && prop->isString                                        &&
+@@ -947,10 +954,20 @@
+
+     if ( !parts || !len )
+     {
+-      if ( FT_ALLOC( face->style_name, 8 ) )
+-        return error;
+-      ft_strcpy( face->style_name, "Regular" );
+-      face->style_name[7] = '\0';
++      if ( weight == 0 )
++      {
++         if ( FT_ALLOC( face->style_name, 8 ) )
++           return error;
++         ft_strcpy( face->style_name, "Regular" );
++         face->style_name[7] = '\0';
++      }
++      else
++      {
++         if ( FT_ALLOC( face->style_name, 7 ) )
++           return error;
++         ft_strcpy( face->style_name, "Medium" );
++         face->style_name[7] = '\0';
++      }
+     }
+     else
+     {
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-docs/copyright.add	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.3 2003/04/04 20:17:40 keithp 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.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-docs/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+# Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#	@(#)depend	1.2	06/03/30
+#
+#  Fontconfig package
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcar	Core Archictecture, (Root)
+P SUNWkvm	Core Architecture, (Kvm)
+P SUNWcsl	Core Solaris, (Shared Libs)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-docs/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+# Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+#
+# 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.
+#
+#	@(#)pkginfo.tmpl	1.2	06/03/30 SMI
+
+PKG="SUNWfontconfig-docs"
+NAME="Fontconfig library documentation"
+ARCH="ISA"
+VERSION=6.6.2.0,REV=0.2000.02.02
+CATEGORY="system"
+SUNW_PRODNAME="Solaris X11"
+SUNW_PRODVERS=6.6.2
+DESC="Fontconfig library documentation"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGTYPE="usr"
+CLASSES=none
+SUNW_PKGVERS=1.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-docs/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,179 @@
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# 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.
+#
+# ident	"@(#)prototype	1.5	06/03/30 SMI"
+#
+# Fontconfig documentation
+
+i pkginfo
+i copyright
+i depend
+
+!HOME=../usr/man
+
+d none share 							0755 root sys
+d none share/man						0755 root bin
+
+!search      $HOME/man1
+d none share/man/man1						0755 root bin
+f none share/man/man1/fc-cache.1				0444 root bin
+f none share/man/man1/fc-list.1					0444 root bin
+
+!search      $HOME/man4
+d none share/man/man4						0755 root bin
+f none share/man/man4/fonts.conf.4				0444 root bin
+
+!search      $HOME/man3lib
+d none share/man/man3lib					0755 root bin
+f none share/man/man3lib/libfontconfig.3lib  0444 root bin
+
+!search      $HOME/man3
+d none share/man/man3fontconfig					0755 root bin
+f none share/man/man3fontconfig/FcAtomicCreate.3fontconfig=$HOME/man3/FcAtomicCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcAtomicDeleteNew.3fontconfig=$HOME/man3/FcAtomicDeleteNew.3 0444 root bin
+f none share/man/man3fontconfig/FcAtomicDestroy.3fontconfig=$HOME/man3/FcAtomicDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcAtomicLock.3fontconfig=$HOME/man3/FcAtomicLock.3 0444 root bin
+f none share/man/man3fontconfig/FcAtomicNewFile.3fontconfig=$HOME/man3/FcAtomicNewFile.3 0444 root bin
+f none share/man/man3fontconfig/FcAtomicOrigFile.3fontconfig=$HOME/man3/FcAtomicOrigFile.3 0444 root bin
+f none share/man/man3fontconfig/FcAtomicReplaceOrig.3fontconfig=$HOME/man3/FcAtomicReplaceOrig.3 0444 root bin
+f none share/man/man3fontconfig/FcAtomicUnlock.3fontconfig=$HOME/man3/FcAtomicUnlock.3 0444 root bin
+f none share/man/man3fontconfig/FcBlanksAdd.3fontconfig=$HOME/man3/FcBlanksAdd.3 0444 root bin
+f none share/man/man3fontconfig/FcBlanksCreate.3fontconfig=$HOME/man3/FcBlanksCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcBlanksDestroy.3fontconfig=$HOME/man3/FcBlanksDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcBlanksIsMember.3fontconfig=$HOME/man3/FcBlanksIsMember.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetAddChar.3fontconfig=$HOME/man3/FcCharSetAddChar.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetCopy.3fontconfig=$HOME/man3/FcCharSetCopy.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetCount.3fontconfig=$HOME/man3/FcCharSetCount.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetCreate.3fontconfig=$HOME/man3/FcCharSetCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetDestroy.3fontconfig=$HOME/man3/FcCharSetDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetEqual.3fontconfig=$HOME/man3/FcCharSetEqual.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetFirstPage.3fontconfig=$HOME/man3/FcCharSetFirstPage.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetHasChar.3fontconfig=$HOME/man3/FcCharSetHasChar.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetIntersect.3fontconfig=$HOME/man3/FcCharSetIntersect.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetIntersectCount.3fontconfig=$HOME/man3/FcCharSetIntersectCount.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetIsSubset.3fontconfig=$HOME/man3/FcCharSetIsSubset.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetNextPage.3fontconfig=$HOME/man3/FcCharSetNextPage.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetSubtract.3fontconfig=$HOME/man3/FcCharSetSubtract.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetSubtractCount.3fontconfig=$HOME/man3/FcCharSetSubtractCount.3 0444 root bin
+f none share/man/man3fontconfig/FcCharSetUnion.3fontconfig=$HOME/man3/FcCharSetUnion.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigAppFontAddDir.3fontconfig=$HOME/man3/FcConfigAppFontAddDir.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigAppFontAddFile.3fontconfig=$HOME/man3/FcConfigAppFontAddFile.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigAppFontClear.3fontconfig=$HOME/man3/FcConfigAppFontClear.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigBuildFonts.3fontconfig=$HOME/man3/FcConfigBuildFonts.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigCreate.3fontconfig=$HOME/man3/FcConfigCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigDestroy.3fontconfig=$HOME/man3/FcConfigDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigFilename.3fontconfig=$HOME/man3/FcConfigFilename.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetBlanks.3fontconfig=$HOME/man3/FcConfigGetBlanks.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetCache.3fontconfig=$HOME/man3/FcConfigGetCache.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetConfigDirs.3fontconfig=$HOME/man3/FcConfigGetConfigDirs.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetConfigFiles.3fontconfig=$HOME/man3/FcConfigGetConfigFiles.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetCurrent.3fontconfig=$HOME/man3/FcConfigGetCurrent.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetFontDirs.3fontconfig=$HOME/man3/FcConfigGetFontDirs.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetFonts.3fontconfig=$HOME/man3/FcConfigGetFonts.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigGetRescanInverval.3fontconfig=$HOME/man3/FcConfigGetRescanInverval.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigParseAndLoad.3fontconfig=$HOME/man3/FcConfigParseAndLoad.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigSetCurrent.3fontconfig=$HOME/man3/FcConfigSetCurrent.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigSetRescanInverval.3fontconfig=$HOME/man3/FcConfigSetRescanInverval.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigSubstitute.3fontconfig=$HOME/man3/FcConfigSubstitute.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigSubstituteWithPat.3fontconfig=$HOME/man3/FcConfigSubstituteWithPat.3 0444 root bin
+f none share/man/man3fontconfig/FcConfigUptoDate.3fontconfig=$HOME/man3/FcConfigUptoDate.3 0444 root bin
+f none share/man/man3fontconfig/FcDefaultSubstitute.3fontconfig=$HOME/man3/FcDefaultSubstitute.3 0444 root bin
+f none share/man/man3fontconfig/FcDirCacheValid.3fontconfig=$HOME/man3/FcDirCacheValid.3 0444 root bin
+f none share/man/man3fontconfig/FcDirSave.3fontconfig=$HOME/man3/FcDirSave.3 0444 root bin
+f none share/man/man3fontconfig/FcDirScan.3fontconfig=$HOME/man3/FcDirScan.3 0444 root bin
+f none share/man/man3fontconfig/FcFileScan.3fontconfig=$HOME/man3/FcFileScan.3 0444 root bin
+f none share/man/man3fontconfig/FcFontList.3fontconfig=$HOME/man3/FcFontList.3 0444 root bin
+f none share/man/man3fontconfig/FcFontMatch.3fontconfig=$HOME/man3/FcFontMatch.3 0444 root bin
+f none share/man/man3fontconfig/FcFontRenderPrepare.3fontconfig=$HOME/man3/FcFontRenderPrepare.3 0444 root bin
+f none share/man/man3fontconfig/FcFontSetAdd.3fontconfig=$HOME/man3/FcFontSetAdd.3 0444 root bin
+f none share/man/man3fontconfig/FcFontSetCreate.3fontconfig=$HOME/man3/FcFontSetCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcFontSetDestroy.3fontconfig=$HOME/man3/FcFontSetDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcFontSort.3fontconfig=$HOME/man3/FcFontSort.3 0444 root bin
+f none share/man/man3fontconfig/FcFreeTypeCharIndex.3fontconfig=$HOME/man3/FcFreeTypeCharIndex.3 0444 root bin
+f none share/man/man3fontconfig/FcFreeTypeCharSet.3fontconfig=$HOME/man3/FcFreeTypeCharSet.3 0444 root bin
+f none share/man/man3fontconfig/FcFreeTypeQuery.3fontconfig=$HOME/man3/FcFreeTypeQuery.3 0444 root bin
+f none share/man/man3fontconfig/FcGetVersion.3fontconfig=$HOME/man3/FcGetVersion.3 0444 root bin
+f none share/man/man3fontconfig/FcInit.3fontconfig=$HOME/man3/FcInit.3 0444 root bin
+f none share/man/man3fontconfig/FcInitBringUptoDate.3fontconfig=$HOME/man3/FcInitBringUptoDate.3 0444 root bin
+f none share/man/man3fontconfig/FcInitLoadConfig.3fontconfig=$HOME/man3/FcInitLoadConfig.3 0444 root bin
+f none share/man/man3fontconfig/FcInitLoadConfigAndFonts.3fontconfig=$HOME/man3/FcInitLoadConfigAndFonts.3 0444 root bin
+f none share/man/man3fontconfig/FcInitReinitialize.3fontconfig=$HOME/man3/FcInitReinitialize.3 0444 root bin
+f none share/man/man3fontconfig/FcMatrixCopy.3fontconfig=$HOME/man3/FcMatrixCopy.3 0444 root bin
+f none share/man/man3fontconfig/FcMatrixEqual.3fontconfig=$HOME/man3/FcMatrixEqual.3 0444 root bin
+f none share/man/man3fontconfig/FcMatrixInit.3fontconfig=$HOME/man3/FcMatrixInit.3 0444 root bin
+f none share/man/man3fontconfig/FcMatrixMultiply.3fontconfig=$HOME/man3/FcMatrixMultiply.3 0444 root bin
+f none share/man/man3fontconfig/FcMatrixRotate.3fontconfig=$HOME/man3/FcMatrixRotate.3 0444 root bin
+f none share/man/man3fontconfig/FcMatrixScale.3fontconfig=$HOME/man3/FcMatrixScale.3 0444 root bin
+f none share/man/man3fontconfig/FcMatrixShear.3fontconfig=$HOME/man3/FcMatrixShear.3 0444 root bin
+f none share/man/man3fontconfig/FcNameConstant.3fontconfig=$HOME/man3/FcNameConstant.3 0444 root bin
+f none share/man/man3fontconfig/FcNameGetConstant.3fontconfig=$HOME/man3/FcNameGetConstant.3 0444 root bin
+f none share/man/man3fontconfig/FcNameGetObjectType.3fontconfig=$HOME/man3/FcNameGetObjectType.3 0444 root bin
+f none share/man/man3fontconfig/FcNameParse.3fontconfig=$HOME/man3/FcNameParse.3 0444 root bin
+f none share/man/man3fontconfig/FcNameRegisterConstants.3fontconfig=$HOME/man3/FcNameRegisterConstants.3 0444 root bin
+f none share/man/man3fontconfig/FcNameRegisterObjectTypes.3fontconfig=$HOME/man3/FcNameRegisterObjectTypes.3 0444 root bin
+f none share/man/man3fontconfig/FcNameUnparse.3fontconfig=$HOME/man3/FcNameUnparse.3 0444 root bin
+f none share/man/man3fontconfig/FcNameUnregisterConstants.3fontconfig=$HOME/man3/FcNameUnregisterConstants.3 0444 root bin
+f none share/man/man3fontconfig/FcNameUnregisterObjectTypes.3fontconfig=$HOME/man3/FcNameUnregisterObjectTypes.3 0444 root bin
+f none share/man/man3fontconfig/FcObjectSetAdd.3fontconfig=$HOME/man3/FcObjectSetAdd.3 0444 root bin
+f none share/man/man3fontconfig/FcObjectSetBuild.3fontconfig=$HOME/man3/FcObjectSetBuild.3 0444 root bin
+f none share/man/man3fontconfig/FcObjectSetCreate.3fontconfig=$HOME/man3/FcObjectSetCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcObjectSetDestroy.3fontconfig=$HOME/man3/FcObjectSetDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternAdd-Type.3fontconfig=$HOME/man3/FcPatternAdd-Type.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternAdd.3fontconfig=$HOME/man3/FcPatternAdd.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternAddWeak.3fontconfig=$HOME/man3/FcPatternAddWeak.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternBuild.3fontconfig=$HOME/man3/FcPatternBuild.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternCreate.3fontconfig=$HOME/man3/FcPatternCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternDel.3fontconfig=$HOME/man3/FcPatternDel.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternDestroy.3fontconfig=$HOME/man3/FcPatternDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternEqual.3fontconfig=$HOME/man3/FcPatternEqual.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternEqualSubset.3fontconfig=$HOME/man3/FcPatternEqualSubset.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternGet-Type.3fontconfig=$HOME/man3/FcPatternGet-Type.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternGet.3fontconfig=$HOME/man3/FcPatternGet.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternHash.3fontconfig=$HOME/man3/FcPatternHash.3 0444 root bin
+f none share/man/man3fontconfig/FcPatternPrint.3fontconfig=$HOME/man3/FcPatternPrint.3 0444 root bin
+f none share/man/man3fontconfig/FcStrBasename.3fontconfig=$HOME/man3/FcStrBasename.3 0444 root bin
+f none share/man/man3fontconfig/FcStrCmpIgnoreCase.3fontconfig=$HOME/man3/FcStrCmpIgnoreCase.3 0444 root bin
+f none share/man/man3fontconfig/FcStrCopy.3fontconfig=$HOME/man3/FcStrCopy.3 0444 root bin
+f none share/man/man3fontconfig/FcStrCopyFilename.3fontconfig=$HOME/man3/FcStrCopyFilename.3 0444 root bin
+f none share/man/man3fontconfig/FcStrDirname.3fontconfig=$HOME/man3/FcStrDirname.3 0444 root bin
+f none share/man/man3fontconfig/FcStrListCreate.3fontconfig=$HOME/man3/FcStrListCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcStrListDone.3fontconfig=$HOME/man3/FcStrListDone.3 0444 root bin
+f none share/man/man3fontconfig/FcStrListNext.3fontconfig=$HOME/man3/FcStrListNext.3 0444 root bin
+f none share/man/man3fontconfig/FcStrSetAdd.3fontconfig=$HOME/man3/FcStrSetAdd.3 0444 root bin
+f none share/man/man3fontconfig/FcStrSetAddFilename.3fontconfig=$HOME/man3/FcStrSetAddFilename.3 0444 root bin
+f none share/man/man3fontconfig/FcStrSetCreate.3fontconfig=$HOME/man3/FcStrSetCreate.3 0444 root bin
+f none share/man/man3fontconfig/FcStrSetDel.3fontconfig=$HOME/man3/FcStrSetDel.3 0444 root bin
+f none share/man/man3fontconfig/FcStrSetDestroy.3fontconfig=$HOME/man3/FcStrSetDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcStrSetMember.3fontconfig=$HOME/man3/FcStrSetMember.3 0444 root bin
+f none share/man/man3fontconfig/FcUcs4ToUtf8.3fontconfig=$HOME/man3/FcUcs4ToUtf8.3 0444 root bin
+f none share/man/man3fontconfig/FcUtf16Len.3fontconfig=$HOME/man3/FcUtf16Len.3 0444 root bin
+f none share/man/man3fontconfig/FcUtf16ToUcs4.3fontconfig=$HOME/man3/FcUtf16ToUcs4.3 0444 root bin
+f none share/man/man3fontconfig/FcUtf8Len.3fontconfig=$HOME/man3/FcUtf8Len.3 0444 root bin
+f none share/man/man3fontconfig/FcUtf8ToUcs4.3fontconfig=$HOME/man3/FcUtf8ToUcs4.3 0444 root bin
+f none share/man/man3fontconfig/FcValueDestroy.3fontconfig=$HOME/man3/FcValueDestroy.3 0444 root bin
+f none share/man/man3fontconfig/FcValueSave.3fontconfig=$HOME/man3/FcValueSave.3 0444 root bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-root/copyright.add	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.3 2003/04/04 20:17:40 keithp 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.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-root/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,40 @@
+# Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#
+#	@(#)depend	1.2	06/03/30
+#
+#  Fontconfig config files (/etc) package
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcar	Core Archictecture, (Root)
+P SUNWkvm	Core Architecture, (Kvm)
+P SUNWcsl	Core Solaris, (Shared Libs)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-root/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+# Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#
+#	@(#)pkginfo.tmpl	1.4	06/03/30 (c) Sun Microsystems, Inc.
+
+PKG="SUNWfontconfig-root"
+NAME="Fontconfig library configuration files"
+ARCH="ISA"
+VERSION=6.6.2.0,REV=0.2000.02.02
+CATEGORY="system"
+SUNW_PRODNAME="Solaris X11"
+SUNW_PRODVERS=6.6.2
+DESC="Fontconfig library configuration files (/etc/fonts)"
+BASEDIR="/"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGTYPE="root"
+CLASSES=none manifest
+SUNW_PKGVERS=1.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig-root/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,51 @@
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# 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.
+#
+# ident	"@(#)prototype	1.5	06/03/30 SMI"
+#
+# Fontconfig config files
+
+i pkginfo
+i copyright
+i depend
+
+!HOME=../etc
+
+!search      $HOME/fonts
+d none etc			0755 root sys
+d none etc/fonts		0755 root sys
+f none etc/fonts/fonts.conf	0444 root bin
+f none etc/fonts/fonts.dtd	0444 root bin
+
+d none var 755 root sys
+d none var/svc 755 root sys
+d none var/svc/manifest 755 root sys
+d none var/svc/manifest/application 755 root sys
+d none var/svc/manifest/application/font 755 root sys
+!search ../var/svc/manifest/application/font
+f manifest var/svc/manifest/application/font/fc-cache.xml 0444 root sys
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig/copyright.add	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,22 @@
+$Id: COPYING,v 1.3 2003/04/04 20:17:40 keithp 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.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,41 @@
+# Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#	@(#)depend	1.4	06/03/30
+#
+#  Fontconfig package
+
+P SUNWcsr		Core Solaris, (Root)
+P SUNWcsu		Core Solaris, (Usr)
+P SUNWcar		Core Archictecture, (Root)
+P SUNWkvm		Core Architecture, (Kvm)
+P SUNWcsl		Core Solaris, (Shared Libs)
+P SUNWfreetype2		FreeType Font library
+P SUNWfontconfig-root	Fontconfig library configuration files
+P SUNWlexpt		libexpat - XML parser library
+P SUNWzlib		The Zip compression library
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+# Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#	@(#)pkginfo.tmpl	1.2	06/03/30 (c) Sun Microsystems, Inc.
+#
+
+PKG="SUNWfontconfig"
+NAME="Fontconfig library"
+ARCH="ISA"
+VERSION=6.6.2.0,REV=0.2000.02.02
+CATEGORY="system"
+SUNW_PRODNAME="Solaris X11"
+SUNW_PRODVERS=6.6.2
+DESC="Fontconfig library"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGTYPE="usr"
+CLASSES=none
+SUNW_PKGVERS=1.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfontconfig/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,70 @@
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# 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.
+#
+# ident	"@(#)prototype	1.5	06/03/30 SMI"
+#
+# Fontconfig library & binaries
+
+i pkginfo
+i copyright
+i depend
+
+!HOME=../usr
+
+!search      $HOME/bin
+d none bin 						0755 root bin
+f none bin/fc-cache					0755 root bin
+f none bin/fc-list					0755 root bin
+
+!search      $HOME/include/fontconfig
+d none include 						0755 root bin
+d none include/fontconfig				0755 root bin
+f none include/fontconfig/fcfreetype.h			0755 root bin
+f none include/fontconfig/fcprivate.h			0755 root bin
+f none include/fontconfig/fontconfig.h			0755 root bin
+
+!search      $HOME/lib
+d none lib 						0755 root bin
+f none lib/libfontconfig.so.1=$HOME/lib/libfontconfig.so.1.0.4	0755 root bin
+s none lib/libfontconfig.so=libfontconfig.so.1
+
+!search      $HOME/lib/pkgconfig
+d none lib/pkgconfig					0755 root other
+f none lib/pkgconfig/fontconfig.pc			0444 root other
+
+# 64-bit versions
+
+!search      $HOME/lib/$plat_64
+d none lib/$plat_64						0755 root bin
+s none lib/64=$plat_64
+f none lib/$plat_64/libfontconfig.so.1=$HOME/lib/$plat_64/libfontconfig.so.1.0.4	0755 root bin
+s none lib/$plat_64/libfontconfig.so=libfontconfig.so.1
+
+!search      $HOME/lib/$plat_64/pkgconfig
+d none lib/$plat_64/pkgconfig					0755 root other
+f none lib/$plat_64/pkgconfig/fontconfig.pc			0444 root other
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfreetype2/copyright.add	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,30 @@
+Portions of this software are copyright � 1996-2005 The FreeType
+Project <http://www.freetype.org/>.  All rights reserved.
+
+THE FREETYPE PROJECT  IS PROVIDED `AS IS' WITHOUT  WARRANTY OF ANY
+KIND, EITHER  EXPRESS OR IMPLIED,  INCLUDING, BUT NOT  LIMITED TO,
+WARRANTIES  OF  MERCHANTABILITY   AND  FITNESS  FOR  A  PARTICULAR
+PURPOSE.  IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE  FOR ANY DAMAGES CAUSED  BY THE USE OR  THE INABILITY TO
+USE, OF THE FREETYPE PROJECT.
+
+The FreeType PCF driver is Copyright (C) 2000 by Francesco Zappa Nardelli
+
+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.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfreetype2/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+# Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#
+#	@(#)depend	1.4	06/03/30
+#
+#  FreeType 2 package
+
+P SUNWcsr	Core Solaris, (Root)
+P SUNWcsu	Core Solaris, (Usr)
+P SUNWcar	Core Archictecture, (Root)
+P SUNWkvm	Core Architecture, (Kvm)
+P SUNWcsl	Core Solaris, (Shared Libs)
+P SUNWzlib	The Zip compression library
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfreetype2/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+# Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#	@(#)pkginfo.tmpl	1.5	06/03/30 (c) Sun Microsystems, Inc.
+#
+
+PKG="SUNWfreetype2"
+NAME="FreeType2 Font library"
+ARCH="ISA"
+VERSION=6.6.2.0,REV=0.2000.02.02
+CATEGORY="system"
+SUNW_PRODNAME="Solaris X11"
+SUNW_PRODVERS=6.6.2
+DESC="FreeType2 font handling library and rendering engine"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGTYPE="usr"
+CLASSES=none
+SUNW_PKGVERS=1.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWfreetype2/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,148 @@
+#	Copyright 2002-2005 Sun Microsystems, Inc.  All Rights Reserved.
+#	Use subject to license terms.
+#
+#	@(#)prototype	1.10	05/07/01 (c) Sun Microsystems, Inc.
+#
+#  FreeType 2 package
+
+i pkginfo
+i copyright=copyright
+i depend
+
+!HOME=../sfw
+
+d none sfw 							0755 root bin
+
+!search $HOME/bin
+d none sfw/bin 							0755 root bin
+f none sfw/bin/freetype-config					0755 root bin
+
+!search $HOME/include/
+d none sfw/include 						0755 root bin
+f none sfw/include/ft2build.h					0755 root bin
+d none sfw/include/freetype2					0755 root bin
+
+!search $HOME/include/freetype2/freetype
+d none sfw/include/freetype2/freetype				0755 root bin
+f none sfw/include/freetype2/freetype/freetype.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftbbox.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftbdf.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftbitmap.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftcache.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftchapters.h		0755 root bin
+f none sfw/include/freetype2/freetype/fterrdef.h		0755 root bin
+f none sfw/include/freetype2/freetype/fterrors.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftglyph.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftgzip.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftimage.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftincrem.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftlist.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftlzw.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftmac.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftmm.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftmodapi.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftmoderr.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftotval.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftoutln.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftpfr.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftrender.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftsizes.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftsnames.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftstroke.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftsynth.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftsysio.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftsysmem.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftsystem.h		0755 root bin
+f none sfw/include/freetype2/freetype/fttrigon.h		0755 root bin
+f none sfw/include/freetype2/freetype/fttypes.h			0755 root bin
+f none sfw/include/freetype2/freetype/ftwinfnt.h		0755 root bin
+f none sfw/include/freetype2/freetype/ftxf86.h			0755 root bin
+f none sfw/include/freetype2/freetype/t1tables.h		0755 root bin
+f none sfw/include/freetype2/freetype/ttnameid.h		0755 root bin
+f none sfw/include/freetype2/freetype/tttables.h		0755 root bin
+f none sfw/include/freetype2/freetype/tttags.h			0755 root bin
+f none sfw/include/freetype2/freetype/ttunpat.h			0755 root bin
+
+!search $HOME/include/freetype2/freetype/cache
+d none sfw/include/freetype2/freetype/cache			0755 root bin
+f none sfw/include/freetype2/freetype/cache/ftccache.h		0755 root bin
+f none sfw/include/freetype2/freetype/cache/ftccmap.h		0755 root bin
+f none sfw/include/freetype2/freetype/cache/ftcglyph.h		0755 root bin
+f none sfw/include/freetype2/freetype/cache/ftcimage.h		0755 root bin
+f none sfw/include/freetype2/freetype/cache/ftcmanag.h		0755 root bin
+f none sfw/include/freetype2/freetype/cache/ftcmru.h		0755 root bin
+f none sfw/include/freetype2/freetype/cache/ftcsbits.h		0755 root bin
+
+!search $HOME/include/freetype2/freetype/config
+d none sfw/include/freetype2/freetype/config			0755 root bin
+f none sfw/include/freetype2/freetype/config/ftconfig.h		0755 root bin
+f none sfw/include/freetype2/freetype/config/ftheader.h		0755 root bin
+f none sfw/include/freetype2/freetype/config/ftmodule.h		0755 root bin
+f none sfw/include/freetype2/freetype/config/ftoption.h		0755 root bin
+f none sfw/include/freetype2/freetype/config/ftstdlib.h		0755 root bin
+
+!search $HOME/include/freetype2/freetype/internal
+d none sfw/include/freetype2/freetype/internal			0755 root bin
+f none sfw/include/freetype2/freetype/internal/autohint.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftcalc.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftdebug.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftdriver.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftgloadr.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftmemory.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftobjs.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftrfork.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftserv.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftstream.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/fttrace.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/ftvalid.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/internal.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/pcftypes.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/psaux.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/pshints.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/sfnt.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/svbdf.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/svgldict.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/svmm.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/svotval.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/svpfr.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/svpostnm.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/svpscmap.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/svpsinfo.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/svsfnt.h		0755 root bin
+f none sfw/include/freetype2/freetype/internal/svttcmap.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/svwinfnt.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/svxf86nm.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/t1types.h	0755 root bin
+f none sfw/include/freetype2/freetype/internal/tttypes.h	0755 root bin
+
+!search $HOME/lib
+d none sfw/lib 							0755 root bin
+f none sfw/lib/libfreetype.so.6=$HOME/lib/libfreetype.so.6.3.8	0755 root bin
+s none sfw/lib/libfreetype.so=libfreetype.so.6
+
+d none sfw/share 						0755 root bin
+
+!search $HOME/share/aclocal
+d none sfw/share/aclocal					0755 root bin
+f none sfw/share/aclocal/freetype2.m4				0755 root bin
+
+!search $HOME/lib/pkgconfig
+d none lib	 						0755 root bin
+d none lib/pkgconfig 						0755 root other 
+f none lib/pkgconfig/freetype2.pc				0644 root bin
+
+#  FreeType 2 64-bit libraries 
+
+!search $HOME/lib/$plat_64
+d none sfw/lib/$plat_64						0755 root bin
+s none sfw/lib/64=$plat_64
+f none sfw/lib/$plat_64/libfreetype.so.6=$HOME/lib/$plat_64/libfreetype.so.6.3.8	0755 root bin
+s none sfw/lib/$plat_64/libfreetype.so=libfreetype.so.6
+
+!search $HOME/lib/$plat_64/pkgconfig
+d none lib/$plat_64						0755 root bin
+d none lib/$plat_64/pkgconfig					0755 root other 
+f none lib/$plat_64/pkgconfig/freetype2.pc			0644 root bin
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWxwxft/copyright.add	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,20 @@
+Copyright � 2000-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.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWxwxft/depend	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,39 @@
+# Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+# Use subject to license terms
+#
+# 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.
+#
+#	@(#)depend	1.4	06/03/30	SMI
+#
+
+P SUNWcsr		Core Sparc, (Root)
+P SUNWcsu		Core Sparc, (Usr)
+P SUNWcar		Core Archictecture, (Root)
+P SUNWkvm		Core Architecture, (Usr)
+P SUNWcsl		Core Solaris, (Shared Libs)
+P SUNWxwplt		X Window System Platform
+P SUNWfontconfig	Fontconfig library
+P SUNWfreetype2 	Software Font Engine (The FreeType 2 library)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWxwxft/pkginfo.tmpl	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,47 @@
+# Copyright 2003 Sun Microsystems, Inc. All Rights Reserved
+# Use subject to license terms.
+#
+# 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.
+#
+#	@(#)pkginfo.tmpl	1.2	06/03/30
+#
+
+PKG="SUNWxwxft"
+NAME="Xft (X Freetype) Library"
+ARCH="ISA"
+VERSION=6.4.2.0,REV=0.2000.02.02
+CATEGORY="system"
+SUNW_PRODNAME="Solaris X11"
+SUNW_PRODVERS=6.4.2
+DESC="X Window System XST extension"
+BASEDIR="/usr"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+MAXINST="1000"
+SUNW_PKGTYPE="ow"
+CLASSES=none
+SUNW_PKGVERS=1.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/SUNWxwxft/prototype	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,68 @@
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use subject to license terms.
+#
+# 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.
+#
+#	"@(#)prototype	1.3	05/09/02   Sun Microsystems" 
+#
+# Xft
+
+i pkginfo
+i copyright=copyright
+i depend
+
+!HOME=../openwin
+
+d none openwin 0755 root bin
+
+!search  $HOME/include/X11/Xft
+d none openwin/share 0755 root bin
+d none openwin/share/include 0755 root bin
+d none openwin/share/include/X11 0755 root bin
+d none openwin/share/include/X11/Xft 0755 root bin
+f none openwin/share/include/X11/Xft/Xft.h 0644 root bin
+f none openwin/share/include/X11/Xft/XftCompat.h 0644 root bin
+
+!search  $HOME/lib
+d none openwin/lib 		0755 root bin
+f none openwin/lib/libXft.so.2 	0755 root bin
+s none openwin/lib/libXft.so=./libXft.so.2
+
+!search  $HOME/lib/pkgconfig
+d none lib/pkgconfig                                    0755 root other
+f none lib/pkgconfig/xft.pc	                        0444 root other
+
+#    Xft 64-bit library
+!search  $HOME/lib/$plat_64
+s none openwin/lib/64=$plat_64
+d none openwin/lib/$plat_64 				0755 root bin
+f none openwin/lib/$plat_64/libXft.so.2          	0755 root bin
+s none openwin/lib/$plat_64/libXft.so=libXft.so.2
+
+!search  $HOME/lib/$plat_64/pkgconfig
+d none lib/$plat_64		                        0755 root bin
+d none lib/$plat_64/pkgconfig                           0755 root other
+f none lib/$plat_64/pkgconfig/xft.pc                    0444 root other
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/copyright	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2 @@
+Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+Use is subject to license terms.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/packages/pkgversion	Fri Mar 31 16:09:50 2006 -0800
@@ -0,0 +1,2 @@
+VERSION="6.6.3"
+BUILD="0000"