Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:48:48 +0000 (00:48 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:48:48 +0000 (00:48 +0900)
39 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0755]
ChangeLog [new file with mode: 0755]
Makefile.am [new file with mode: 0755]
NEWS [new file with mode: 0644]
README [new file with mode: 0755]
autogen.sh [new file with mode: 0644]
configure.ac [new file with mode: 0755]
debian/README.source [new file with mode: 0644]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0755]
debian/copyright [new file with mode: 0644]
debian/libsm-dev.install [new file with mode: 0755]
debian/libsm6.install [new file with mode: 0644]
debian/patches/0001-sm.pc-don-t-export-a-dependency-on-ice.patch [new file with mode: 0644]
debian/patches/series [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/watch [new file with mode: 0644]
debian/xsfbs/repack.sh [new file with mode: 0644]
debian/xsfbs/xsfbs.mk [new file with mode: 0644]
debian/xsfbs/xsfbs.sh [new file with mode: 0644]
doc/Makefile.am [new file with mode: 0755]
doc/SMlib.xml [new file with mode: 0755]
doc/xsmp.xml [new file with mode: 0755]
include/X11/SM/SM.h [new file with mode: 0755]
include/X11/SM/SMlib.h [new file with mode: 0755]
include/X11/SM/SMproto.h [new file with mode: 0755]
packaging/libSM.spec [new file with mode: 0644]
sm.pc.in [new file with mode: 0644]
src/Makefile.am [new file with mode: 0755]
src/SMlibint.h [new file with mode: 0755]
src/sm_auth.c [new file with mode: 0755]
src/sm_client.c [new file with mode: 0644]
src/sm_error.c [new file with mode: 0755]
src/sm_genid.c [new file with mode: 0755]
src/sm_manager.c [new file with mode: 0755]
src/sm_misc.c [new file with mode: 0755]
src/sm_process.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..d497b13
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,8 @@
+Author: Ralph Mor, X Consortium.
+
+Some bug fixes by Keith Packard.
+OS/2 support, Frank Giessler
+IPv6 support, Alan Coopersmith
+David Dawes and Dirk Hohndel - bug fixes
+
+Our apolgies if we've missed anyone.
diff --git a/COPYING b/COPYING
new file mode 100755 (executable)
index 0000000..0975602
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,42 @@
+Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (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 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.
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
diff --git a/ChangeLog b/ChangeLog
new file mode 100755 (executable)
index 0000000..fbac5dc
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,850 @@
+commit d2327760a52fdbcd3759211578e3663e00e4a31e
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Wed Oct 27 22:26:41 2010 -0700
+
+    libSM 1.2.0
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 784a330e337af16c1e385d0fbeee1e5369413656
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Oct 24 20:31:54 2010 -0700
+
+    SMlib.xml: Use <simplelist> instead of <synopsis> for lists of mask values
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 12af18dd9a731a816e7b074bbecaa5549bfdba31
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Oct 24 19:57:32 2010 -0700
+
+    SMlib.xml: Tag function names, parameters, constant values, etc.
+    
+    Includes correcting <function> tags on things that aren't functions
+    as some stylesheets may add () after <function> tagged items so we
+    shouldn't use them for constants, variables, filenames, etc.
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit ed9331e10babdd70da51134f0eaee8625a469ffe
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Oct 24 18:54:05 2010 -0700
+
+    SMlib.xml: Line wrapping & other whitespace cleanup
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 763b01e8e69d6132b3b4b57263f19de9de985f99
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Oct 23 00:47:27 2010 -0700
+
+    xsmp.xml: add internal cross-reference links
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 506af19b86af2a7960a3bb5cf72287349012c869
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Oct 23 00:43:28 2010 -0700
+
+    xsmp.xml: Use <synopsis> and related markup for protocol message definition
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 75443d72b4944391b809f429cc4cef2ffb76f7bf
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Oct 23 00:10:01 2010 -0700
+
+    xsmp.xml: Use <errorname> instead of <function> for error names
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 2ed7704e7d4b0086edc8667a80780c6c51ba84cb
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Oct 22 23:52:15 2010 -0700
+
+    xsmp.xml: Restore note titles (example/rationale/advice)
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 489566ca0e69ed6068fb4bdbaccd413ec2ee8319
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Oct 22 23:39:54 2010 -0700
+
+    xsmp.xml: Clean up tables
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit c5b211d9a01438958546669f95a5215784348534
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Oct 22 08:44:46 2010 -0700
+
+    xsmp.xml: Misc markup tag cleanups
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit a18973e643b0916a2f4bf6fb8fc29508429635bb
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Oct 22 08:34:49 2010 -0700
+
+    Coalesce copyright notices in xml docs
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit e3f357dbd39036766765e1de110a876adc2f8226
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Oct 22 08:32:04 2010 -0700
+
+    xsmp.xml: Convert -> & <- to &rarr; & &larr;
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 29e2ac62cb6a152499d1b3f9fe871b1252f3c22f
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Oct 22 08:21:27 2010 -0700
+
+    xsmp.xml: Line wrapping & other whitespace cleanup
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit c83363e83a937ba2ddd99e732bfde5f8d39bd648
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 23:48:42 2010 -0700
+
+    SMlib.xml: fix a couple parameter list entries
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 862e2b220bc928d6ab2f3bb6159bc4be03914979
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 23:43:49 2010 -0700
+
+    SMlib.xml: misc markup cleanups
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 0b15c3773db651863dc8374d45095bc5aa53d41d
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 23:16:14 2010 -0700
+
+    SMlib.xml: fix typo: SmProc -> SmProp
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit cd4739acb0c6d1bca2d3a7adc5c52324928a5561
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 22:55:04 2010 -0700
+
+    SMlib.xml: add internal cross-reference links
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 33a86926ae3a7ddcea817eda8c4b1aac7c518d10
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 16:31:08 2010 -0700
+
+    SMlib.xml: Convert remaining `` quotes to &ldquo; style
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 5abbdcde8a9ed3e489e2f9e5b9161dc9ebc5801f
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 16:29:21 2010 -0700
+
+    SMlib.xml: Convert remaining literallayout tags to synopsis tags
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 62bc296fefd0465c1f3eef283f3bf0a43d132ef9
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 16:17:09 2010 -0700
+
+    SMlib.xml: Convert function prototypes to <funcprototype> tags
+    
+    Provides automatic ansifaction & better formatted output
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit ee77c1932c0cd2050371117c3724d66072cbdbee
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Oct 21 15:43:33 2010 -0700
+
+    SMlib.xml: Remove some nroff macros left in tables by mistake
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 24e9d8a2a35452c67ba2e2e34857ce3691d9a22d
+Author: Jesse Adkins <jesserayadkins@gmail.com>
+Date:   Tue Sep 28 13:30:02 2010 -0700
+
+    Purge cvs tags.
+    
+    Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit e0be9c9dfb60f21edb37ff77d766395aa57a96e4
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sun Jun 27 20:31:28 2010 -0400
+
+    doc: remove trailing spaces in DocBook XML docs
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 8c42c25b90b10b2c5f20c93ebd9cf1df622b009f
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Fri Jun 25 21:43:08 2010 -0400
+
+    doc: replace groff input format with docbook xml format
+    
+    Initial version of SMlib and xsmp docbook xml.
+    Requires util-macros 1.10
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit fd37bd0ac012e15bffad7e83d36b87ee3941d6f5
+Author: Alexander Kabaev <kan@FreeBSD.org>
+Date:   Wed May 26 13:28:03 2010 -0400
+
+    Fix off by one error in SmsGenerateClientID when uuid_create is used
+    
+    Fix apparent typo in SmsGenerateClientID which always leaves the
+    first byte of allocated id string uninitialized. If that byte
+    happens to be 0, SmsGenerateClientId appears to return an empty
+    string to the caller, instead of proper GUID in text form.
+    
+    Reviewed-by: James CLoos <cloos@jhcloos.com>
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit af7364c20d91615251b1ec2b19e0cb38e9094ba0
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Apr 22 07:42:30 2010 -0700
+
+    Update README now that docs are in this module, not xorg-docs
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 7464514f60ff7754e5c1e91d6913000fb5d366c9
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Mon Mar 29 14:53:48 2010 -0400
+
+    config: remove the pkgconfig pc.in file from EXTRA_DIST
+    
+    Automake always includes it in the tarball.
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 39f4ed794168c824015754e451b4b191fddad643
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Tue Feb 16 19:57:27 2010 -0500
+
+    doc: use HAVE_GROFF_MS to skip doc when 's.tmac' macros missing
+    
+    This conditional is defined in XORG_WITH_GROFF macro.
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 64f201ae65de7024bce0a85d6380ac158a3b5852
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Tue Feb 16 14:41:22 2010 -0500
+
+    specs: change install cmd due to automake 1.11
+    
+    docData_INSTALL is defined in 1.9 and 1.10 but not 1.11
+    
+    Reported-by: Tobias Droste <tdroste@gmx.de>
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 98f205119011c016ec902c69d882a26dd7185a43
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Tue Feb 9 17:39:46 2010 -0500
+
+    doc: use $(mkdir_p) rather than $(MKDIR_P) due to automake 1.9.6
+    
+    $(MKDIR_P) is not defined in automake 1.9.
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit c22a324b4c1e1ac38b1c04656ecdcf9127343e8d
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Mon Feb 1 14:58:21 2010 -0500
+
+    doc: install generated images in $docdir
+    
+    The html installed doc is incomplete without the generated images.
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 844a1de311492a7666c60f39c6cbe23a5c3f22da
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sat Jan 30 14:11:36 2010 -0500
+
+    doc: use new macros to control doc generation
+    
+    Namely XORG_WITH_GROFF for the groff generation tool
+    XORG_ENABLE_DOCS for the generation of all docs
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 626788435d4a49eeea9fa2382f7ec554a0b92197
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Tue Jan 26 16:32:00 2010 -0500
+
+    doc: clean-up generated html images
+    
+    Generate images in /images as is the convention
+    Provide a base file name for images rather than process ID
+    Remove images directory when running make clean
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit b5af7f362e30b1bbde4eef4216385ae2b2ea1bee
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Jan 14 21:00:53 2010 -0800
+
+    Update Sun license notices to current X.Org standard form
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 0b2e5ca9da6b35f5cf98ac879601cf8083c72dde
+Author: Rémi Cardona <remi@gentoo.org>
+Date:   Thu Dec 17 08:26:28 2009 +0100
+
+    require autoconf 2.60 because of $(docdir) use
+    
+    Signed-off-by: Rémi Cardona <remi@gentoo.org>
+    Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@sun.com>
+    Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
+
+commit 7f92faa03910bf74fbebefb5d543c09958fb3b28
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Fri Nov 27 20:56:03 2009 -0500
+
+    Makefile.am: add ChangeLog and INSTALL on MAINTAINERCLEANFILES
+    
+    Now that the INSTALL file is generated.
+    Allows running make maintainer-clean.
+
+commit 802f5e2a67ef3d214a0560c36985f8fed3ab92f1
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Wed Nov 11 18:56:57 2009 -0500
+
+    Update .gitignore for the /doc directory #24239
+
+commit 7309ebe123d05955d81318bca5c58ee90b9887dd
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Wed Oct 28 14:09:10 2009 -0400
+
+    INSTALL, NEWS, README or AUTHORS files are missing/incorrect #24206
+    
+    Add missing INSTALL file. Use standard GNU file on building tarball
+    README may have been updated
+    Remove AUTHORS file as it is empty and no content available yet.
+    Remove NEWS file as it is empty and no content available yet.
+
+commit 2fb04f8726ddf8ad0749a6b733ab87c5e1bc06dc
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Mon Oct 26 22:08:41 2009 -0400
+
+    Makefile.am: ChangeLog not required: EXTRA_DIST or *CLEANFILES #24432
+    
+    ChangeLog filename is known to Automake and requires no further
+    coding in the makefile.
+
+commit e88afa3327621f8eb00d920c45536e08b7bc1898
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Thu Oct 22 12:34:18 2009 -0400
+
+    .gitignore: use common defaults with custom section # 24239
+    
+    Using common defaults will reduce errors and maintenance.
+    Only the very small or inexistent custom section need periodic maintenance
+    when the structure of the component changes. Do not edit defaults.
+
+commit d4e3653ff1eed208ea6f35158ad03da7729622b9
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon Nov 16 14:57:19 2009 -0800
+
+    Revert "Fix memory leak for SM_DeleteProperties"
+    
+    This reverts commit 58aa8879e10b12e478ab14b90afd1001b4abd316.
+    
+    Fixes gnome-session crashes due to double frees, as reported in
+    http://bugs.freedesktop.org/show_bug.cgi?id=24964
+
+commit 41d5bb13119b36a7ce6a344372df1b788994e2c7
+Author: Jeremy Huddleston <jeremyhu@freedesktop.org>
+Date:   Wed Oct 21 12:47:23 2009 -0700
+
+    This is not a GNU project, so declare it foreign.
+    
+    On Wed, 2009-10-21 at 13:36 +1000, Peter Hutterer wrote:
+    > On Tue, Oct 20, 2009 at 08:23:55PM -0700, Jeremy Huddleston wrote:
+    > > I noticed an INSTALL file in xlsclients and libXvMC today, and it
+    > > was quite annoying to work around since 'autoreconf -fvi' replaces
+    > > it and git wants to commit it.  Should these files even be in git?
+    > > Can I nuke them for the betterment of humanity and since they get
+    > > created by autoreconf anyways?
+    >
+    > See https://bugs.freedesktop.org/show_bug.cgi?id=24206
+    
+    As an interim measure, replace AM_INIT_AUTOMAKE([dist-bzip2]) with
+    AM_INIT_AUTOMAKE([foreign dist-bzip2]). This will prevent the generation
+    of the INSTALL file. It is also part of the 24206 solution.
+    
+    Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
+
+commit 58aa8879e10b12e478ab14b90afd1001b4abd316
+Author: Michael Jansen <kde@michael-jansen.biz>
+Date:   Wed Oct 14 11:01:46 2009 -0700
+
+    Fix memory leak for SM_DeleteProperties
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 6d43663bf01e055cfe713dccac39b651a0ccfacf
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Sat Oct 10 00:37:41 2009 -0700
+
+    Move session management protocol docs from xorg-docs here too
+    
+    Since we don't have a smproto package, but ship the protocol headers
+    in this module, might as well keep the protocol docs with the headers
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit b1363f9fa47e1564aa5e4fe822bd6a04b5a44954
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Sat Oct 10 00:02:04 2009 -0700
+
+    Move docs from xorg-docs, use groff to format for installation
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit c8e29f4a18041c7a649f701a7cfdd37080d7c6f6
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Fri Oct 9 23:28:11 2009 -0700
+
+    Migrate to xorg macros 1.3 & XORG_DEFAULT_OPTIONS
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 7fc343e70202279fd3daa3adf789ca35b0ec8891
+Author: Rémi Cardona <remi@gentoo.org>
+Date:   Fri Aug 14 11:20:34 2009 +0200
+
+    require libICE >= 1.0.5
+    
+    During the ansification (commit 896aeb5dd128), 2 extern decls for
+    _IcePaMagicCookie1Proc and _IcePoMagicCookie1Proc were dropped from
+    sm_client.c and sm_manager.c. Both decls were added between libICE 1.0.4
+    and 1.0.5.
+    
+    Signed-off-by: Rémi Cardona <remi@gentoo.org>
+
+commit 82bbf42a2ba0401a8346505b1292ddb7b58f4507
+Author: Rémi Cardona <remi@gentoo.org>
+Date:   Fri Aug 7 14:19:50 2009 +0200
+
+    libSM 1.1.1, update libtool version
+
+commit 45720a2e266748ac15bc0544b56e035383695588
+Author: Diego Elio 'Flameeyes' Pettenò <flameeyes@gmail.com>
+Date:   Sat May 16 01:01:39 2009 +0200
+
+    Use FreeBSD uuid functions when available.
+    
+    If the system provide the uuid_create function assume building on FreeBSD
+    or another OS with a compatible uuid interface. If that's the case, ignore
+    libuuid and just use the system functions without extra deps.
+
+commit 0389dbec3b738fa7e1dbef2b5317124b95bdfb20
+Author: Julien Cristau <jcristau@debian.org>
+Date:   Mon Feb 16 01:27:24 2009 +0100
+
+    Typo fix
+    
+    This makes us really error out if we want libuuid but can't find it.
+
+commit b75eae83221465bd0da4d21d0bab5af379dc31c1
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon Feb 2 20:34:30 2009 -0800
+
+    Add README with pointers to mailing list, bugzilla & git repos
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 896aeb5dd128fc8e489106fa7aaa5cee1e589106
+Author: Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>
+Date:   Wed Jan 28 18:48:47 2009 -0200
+
+    Janitor: ansification, make distcheck, compiler warnings.
+
+commit 1dcf5502137efe36d01b30169d4387438ad47be0
+Author: Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>
+Date:   Sat Nov 29 04:55:58 2008 -0200
+
+    avoid gcc warnings for libSM
+    
+      Patch from http://bugs.freedesktop.org/show_bug.cgi?id=17968 adapted
+    to current sources.
+      This corrects a potential (hypothetical) segmentation fault.
+
+commit 8bed01275a7c7caf8f777e4074a5ee1ba1c2b3e7
+Author: Caolan McNamara <caolanm@redhat.com>
+Date:   Fri Oct 17 17:21:49 2008 -0400
+
+    Bug #17644: Fix valgrind warning in _SmcProcessMessage
+
+commit 8ce4f47adb343aed069862a05b5e315173b17823
+Author: Julien Cristau <jcristau@debian.org>
+Date:   Fri Jul 18 16:35:57 2008 +0200
+
+    If we don't have libuuid, build without it instead of failing
+    
+    Only error out if configure was given --with-libuuid but we
+    don't find it.
+
+commit e3166eecfe7a04f0f622bd93e8a6a1faa672a029
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Wed Jul 2 14:24:24 2008 -0400
+
+    Avoid memcpy(foo, NULL, n), that's just nonsense.
+
+commit 27ebe517cabaf038fa65edff0140317f9438adec
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Wed Jul 2 14:00:54 2008 -0400
+
+    libSM 1.1.0
+
+commit 2e8a41efb10ae462e5e43e13e479ca4da0fb0103
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Wed Jun 25 09:55:14 2008 -0700
+
+    Fix --without-libuuid to not call PKG_CHECK_MODULES for libuuid
+
+commit 6702e2a15992f4cb85dfa7ac8214125eb0a2bb2d
+Author: Dan Williams <dcbw@redhat.com>
+Date:   Tue Jun 24 13:11:42 2008 -0400
+
+    Bug #14949: Don't use gethostbyname() for client IDs.
+    
+    gethostbyname() will hit the network, which leads to DNS timeouts, which
+    leads to fail.  Just use UUIDs.
+
+commit 2a827d26cfb10dc6b1203b77c0cc91dc838d97a3
+Author: James Cloos <cloos@jhcloos.com>
+Date:   Thu Dec 6 16:38:16 2007 -0500
+
+    Replace static ChangeLog with dist-hook to generate from git log
+
+commit 9b7029aba10356badeef134af2de7e26e6ae2ab9
+Author: James Cloos <cloos@jhcloos.com>
+Date:   Mon Sep 3 05:53:30 2007 -0400
+
+    Add *~ to .gitignore to skip patch/emacs droppings
+
+commit 837384e09dae2beda6ac3b8e1d10698dc0d23db4
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 14:21:39 2007 +0200
+
+    Bumped version to 1.0.3.
+
+commit 6c50f3639d74edd757dc72dbe6a29cb8aa3b87a3
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 11:47:47 2007 +0200
+
+    Another tiny char* vs const char* fix.
+
+commit 9bfa1101ac5dbb8d2de1d0431d7e7b281428168f
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 11:46:16 2007 +0200
+
+    Revert "Don't reinvent the wheel and just use strdup()."
+    
+    This reverts commit 57ea148fdbf047a012b361acdc7954e70679dad3.
+
+commit 24ac7974ef77d7832a8b3ddd300083c41a03cb79
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 01:44:12 2007 +0200
+
+    Added object files to .gitignore.
+
+commit 48d23e452780f327439a859fa941b1598eb249c8
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 01:43:49 2007 +0200
+
+    Removed some global writable variables.
+
+commit 57ea148fdbf047a012b361acdc7954e70679dad3
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 00:49:58 2007 +0200
+
+    Don't reinvent the wheel and just use strdup().
+
+commit 8ba3325ed15154a933c064831abf8f412a5154a7
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 00:44:50 2007 +0200
+
+    Fixed some const vs non-const mix ups.
+
+commit 2ded69bb857ae453d90534203e5857ac3a31a1c3
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date:   Sun May 13 00:16:36 2007 +0200
+
+    Sanitized hex string conversion in SmsGenerateClientID().
+    
+    This reduces the size of the DSO by almost 4K and gets rid of 255
+    relocations on load.
+
+commit 34b3d538061cd648d90eb2bc7284000d980c8d3e
+Author: Adam Jackson <ajax@benzedrine.nwnk.net>
+Date:   Fri Oct 13 15:55:08 2006 -0400
+
+    Bump to 1.0.2
+
+commit 2116811afe339a9b806f04debf2b6241fd00456f
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Jul 13 14:58:45 2006 -0700
+
+    renamed: .cvsignore -> .gitignore
+
+commit ff57e5d728c2f409b8852ee58d622c2c3323e2a8
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Mon Jun 26 17:30:22 2006 +0000
+
+    From Patch #6046 <https://bugs.freedesktop.org/attachment.cgi?id=6046>
+        freeaddrinfo() in error handling return (Peter Breitenlohner)
+
+commit d03116c682567dac793d52e65a1f0698ae6848f6
+Author: Adam Jackson <ajax@nwnk.net>
+Date:   Thu Apr 27 00:01:01 2006 +0000
+
+    Bump to 1.0.1
+
+commit c46e8ae80540713ec24fd6d1eea68744937ef158
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Fri Mar 17 03:05:32 2006 +0000
+
+    Specs say SmsInitialize & SmcOpenConnection return NULL terminated strings
+        in errorStringRet, but were just calling strncpy and not making sure
+        strings were NULL terminated if errorLength wasn't long enough.
+        (Noticed while evaluating Coverity ids 196 & 201.)
+
+commit 6842e89f85b1fa30344e2bf3d28e51dbfd978370
+Author: Kevin E Martin <kem@kem.org>
+Date:   Thu Dec 15 00:24:27 2005 +0000
+
+    Update package version number for final X11R7 release candidate.
+
+commit 2f62b1a35756301469de62b8830733ebeec2e908
+Author: Kevin E Martin <kem@kem.org>
+Date:   Sat Dec 3 05:49:42 2005 +0000
+
+    Update package version number for X11R7 RC3 release.
+
+commit 69c50fbc49f7589aa6afcf1be00be22a78ec3daa
+Author: Kevin E Martin <kem@kem.org>
+Date:   Sat Nov 19 07:15:39 2005 +0000
+
+    Update pkgconfig files to separate library build-time dependencies from
+        application build-time dependencies, and update package deps to work
+        with separate build roots.
+
+commit dea915c93437443b6bd4933263df44e734e40320
+Author: Kevin E Martin <kem@kem.org>
+Date:   Wed Nov 9 21:19:12 2005 +0000
+
+    Update package version number for X11R7 RC2 release.
+
+commit 922e2dc3116a88cc1e49d5e2486fe1ca21f888c7
+Author: Kean Johnson <kean@armory.com>
+Date:   Tue Nov 8 06:33:25 2005 +0000
+
+    See ChangeLog entry 2005-11-07 for details.
+
+commit df1260d8710f497e766ac52162585345f2d7669f
+Author: Kevin E Martin <kem@kem.org>
+Date:   Wed Oct 19 02:48:08 2005 +0000
+
+    Update package version number for RC1 release.
+
+commit 601c38a8b0bbe92db6374e00e485435316dce1cb
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Mon Aug 15 18:31:16 2005 +0000
+
+    Add XTRANS_CONNECTION_FLAGS to set TCP & IPv6 flags needed by libSM
+
+commit 0a00119745bef1bd67b53124a6a41b76454c5503
+Author: Kevin E Martin <kem@kem.org>
+Date:   Fri Jul 29 21:22:50 2005 +0000
+
+    Various changes preparing packages for RC0:
+    - Verify and update package version numbers as needed
+    - Implement versioning scheme
+    - Change bug address to point to bugzilla bug entry form
+    - Disable loadable i18n in libX11 by default (use --enable-loadable-i18n to
+        reenable it)
+    - Fix makedepend to use pkgconfig and pass distcheck
+    - Update build script to build macros first
+    - Update modular Xorg version
+
+commit c6f143cc14840ca029e651d84f6c9a68c003cf07
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Sat Jul 16 06:24:02 2005 +0000
+
+    Set soversion to 6.0.0 using -version-number.
+
+commit 9c370ec68d2606468296efc1f0a093c036e8d7ff
+Author: Keith Packard <keithp@keithp.com>
+Date:   Wed Jul 13 07:28:02 2005 +0000
+
+    Eliminate xtrans CFLAGS from .pc file as xtrans is not part of the public
+        API.
+
+commit 7b45eec97e390d8c8124b0a95b83ff7614903979
+Author: Keith Packard <keithp@keithp.com>
+Date:   Sat Jul 9 05:59:54 2005 +0000
+
+    Add .cvsignore files
+
+commit 0a4f43e5170110519bd34d01f1f20a72ea615485
+Author: Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>
+Date:   Thu Jun 9 15:52:02 2005 +0000
+
+    Replace <X11/Xtrans.h> with <X11/Xtrans/Xtrans.h>
+    Copy Xtrans.h to exports/include/X11/Xtrans only
+
+commit 8abfaa0bb923231da3dd2c0e245f8feec41a621f
+Author: Adam Jackson <ajax@nwnk.net>
+Date:   Thu May 19 00:22:32 2005 +0000
+
+    revert last change, didn't do right thing at all, sorry for the noise
+
+commit a2e7e1bb26e8a87b822acbeeff114beec4705fb0
+Author: Adam Jackson <ajax@nwnk.net>
+Date:   Thu May 19 00:10:07 2005 +0000
+
+    Require automake 1.7 in AM_INIT_AUTOMAKE
+
+commit 0b4b811191a1e74356b7ff78a09107e29a7ef695
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Tue May 17 21:25:16 2005 +0000
+
+    - Conditionally include config.h in xc/lib/SM
+    - Add libSM to symlink.sh
+    - Add SM build system
+
+commit 5004ef0b757c1cd7e4ceaa1759914f938d5ea295
+Author: Adam Jackson <ajax@nwnk.net>
+Date:   Sun Apr 3 18:24:25 2005 +0000
+
+    Bug #1447: Fix a use-after-free case in libSM. (Mark McLoughlin)
+
+commit c9f8774f04b398ac963b23ce1d5a12e703977064
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Fri Jan 28 19:15:39 2005 +0000
+
+    Move _IceGetPeerName into the ICE public API as IceGetPeerName; bump ICE
+        soversion to 6.4 accordingly. Change SM's use to the public version.
+        The old version will be retained for compatibility.
+
+commit 52435fb9fdaecfdc9b11d54e74388520dacc4b0b
+Author: Egbert Eich <eich@suse.de>
+Date:   Mon Oct 18 14:21:44 2004 +0000
+
+    Made handling of DevelDrivers for x86-64 more conformant to other
+        platforms.
+    Compress all font encodings (Stefan Dirsch).
+    Fixed warnings.
+    Turn on forwarding XNSpotLocation event to XIM server in OffTheSpot and
+        Root mode (bugzilla #1580, James Su).
+    Added another compose key combination for the Euro symbol (Stefan Dirsch).
+    Added support for UTF-8 in ja_JP, ko_KR and zh_TW locales (Mike Fabian).
+    Changed default encoding for ru from KOI8-R to ISO8859-5 (Mike Fabian).
+        This is the encoding that is also used by glibc. We may break other
+        libcs - lets see who complains.
+    Added explanation for DESTDIR to install to a different directory than /.
+    Added some early bailouts to atiprobe if PCI structure pointer is NULL to
+        prevent sig11.
+    XV support doesn't depend on 2D acceleration any more. This patch removes
+        this limitation from the NSC driver. This is a patch that I have
+        committed to XFree86 a while ago but never ported over to X.Org.
+        Matthieu Herrb contributed some build fixes.
+    Fixing SetDPMSTimers() so that DPMS*Time == 0 disables the appropriate
+        timer. This takes advantage of the fact that TimerSet() with a timeout
+        argument 0 behaves like TimerCanel().
+    Use /dev/xconsole (named pipe) or devpts for system logger (Werner Fink).
+    Create missing links for backward compatibility to XFree86 (Stefan Dirsch).
+    Changed comment to mention xorg.
+    Changed cursor for the 'kill' action from XC_draped_box to XC_Pirate. If
+        you don't like it we can change it back (original author unkown).
+    Added 'pic' to the man page rendering command pipeline (Werner Fink).
+    Added missing return value (Stefan Dirsch, Roland Mainz)
+
+commit 76d276193a610e4decf2f39b88e9ccf886d4c492
+Author: Kevin E Martin <kem@kem.org>
+Date:   Wed Aug 18 18:41:40 2004 +0000
+
+    Fix AIX build problems (Bugs #1020, 1102, 1103, Dan McNichol).
+    Remove old config files (Bug #1123, Jim Gettys).
+    Remove old log message (Bug #1123, Jim Gettys).
+
+commit 61bafb140eda240e69e3df28f47567af71ad1296
+Author: Egbert Eich <eich@suse.de>
+Date:   Mon May 24 19:06:58 2004 +0000
+
+    Fix build glitches when building modules independently using Imake.
+
+commit f161cb4a8a567d3ec93677689b6c5440b3027ab6
+Author: Egbert Eich <eich@suse.de>
+Date:   Fri Apr 23 18:43:23 2004 +0000
+
+    Merging XORG-CURRENT into trunk
+
+commit 19fe7606b46b0bbce96837c0ade7018e601fd73e
+Author: Egbert Eich <eich@suse.de>
+Date:   Sun Mar 14 08:31:52 2004 +0000
+
+    Importing vendor version xf86-4_4_99_1 on Sun Mar 14 00:26:39 PST 2004
+
+commit 0a04145c6f313d9a9d670716e2529d2dd0341598
+Author: Egbert Eich <eich@suse.de>
+Date:   Wed Mar 3 12:11:10 2004 +0000
+
+    Importing vendor version xf86-4_4_0 on Wed Mar 3 04:09:24 PST 2004
+
+commit 26ea9c0731055cc478337431353afb8a0a3122ae
+Author: Egbert Eich <eich@suse.de>
+Date:   Thu Feb 26 13:35:18 2004 +0000
+
+    readding XFree86's cvs IDs
+
+commit aa72cf15a99e09fc3e41184e01cbcceced4ef592
+Author: Egbert Eich <eich@suse.de>
+Date:   Thu Feb 26 09:22:34 2004 +0000
+
+    Importing vendor version xf86-4_3_99_903 on Wed Feb 26 01:21:00 PST 2004
+
+commit ea5d51824610a0b5205871a158b055d58879fc0c
+Author: Egbert Eich <eich@suse.de>
+Date:   Thu Jan 29 08:08:04 2004 +0000
+
+    Importing vendor version xf86-012804-2330 on Thu Jan 29 00:06:33 PST 2004
+
+commit a968ef24dfc9ddd1322f91acb4a6a1898fc15490
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Tue Nov 25 19:28:07 2003 +0000
+
+    XFree86 4.3.99.16 Bring the tree up to date for the Cygwin folks
+
+commit 8e18f1cdc21fe0e125620a912e946ec1031fa2c5
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Fri Nov 14 16:48:46 2003 +0000
+
+    XFree86 4.3.0.1
+
+commit abe0fd5d586b52a851a423a79b95070da418eb10
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Fri Nov 14 15:54:36 2003 +0000
+
+    R6.6 is the Xorg base-line
diff --git a/Makefile.am b/Makefile.am
new file mode 100755 (executable)
index 0000000..9cbf83d
--- /dev/null
@@ -0,0 +1,16 @@
+SUBDIRS=src doc
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = sm.pc
+
+MAINTAINERCLEANFILES = ChangeLog INSTALL
+
+.PHONY: ChangeLog INSTALL
+
+INSTALL:
+       $(INSTALL_CMD)
+
+ChangeLog:
+       $(CHANGELOG_CMD)
+
+dist-hook: ChangeLog INSTALL
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100755 (executable)
index 0000000..14fe244
--- /dev/null
+++ b/README
@@ -0,0 +1,25 @@
+libSM - X Session Management Library
+
+All questions regarding this software should be directed at the
+Xorg mailing list:
+
+        http://lists.freedesktop.org/mailman/listinfo/xorg
+
+Please submit bug reports to the Xorg bugzilla:
+
+        https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
+
+The master development code repository can be found at:
+
+        git://anongit.freedesktop.org/git/xorg/lib/libSM
+
+        http://cgit.freedesktop.org/xorg/lib/libSM
+
+For patch submission instructions, see:
+
+       http://www.x.org/wiki/Development/Documentation/SubmittingPatches
+
+For more information on the git code manager, see:
+
+        http://wiki.x.org/wiki/GitPage
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100644 (file)
index 0000000..904cd67
--- /dev/null
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100755 (executable)
index 0000000..54aabdb
--- /dev/null
@@ -0,0 +1,64 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.60)
+AC_INIT([libSM],
+        [1.2.0],
+        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+        libSM)
+
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+
+AM_MAINTAINER_MODE
+
+# Require xorg-macros minimum of 1.10 for DocBook XML documentation
+m4_ifndef([XORG_MACROS_VERSION],
+          [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.10)
+XORG_DEFAULT_OPTIONS
+XORG_ENABLE_DOCS
+XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_FOP
+XORG_CHECK_SGML_DOCTOOLS(1.5)
+
+AM_CONFIG_HEADER([config.h])
+
+# Checks for programs.
+AC_PROG_LIBTOOL
+AC_PROG_CC
+
+# Checks for pkg-config packages
+PKG_CHECK_MODULES(SM, [ice >= 1.0.5] xproto)
+AC_SUBST(SM_CFLAGS)
+AC_SUBST(SM_LIBS)
+
+PKG_CHECK_MODULES(XTRANS, xtrans)
+AC_SUBST(XTRANS_CFLAGS)
+AC_SUBST(XTRANS_LIBS)
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_STDC
+
+# Needed to check for TCP & IPv6 support and set flags appropriately
+XTRANS_CONNECTION_FLAGS
+
+AC_ARG_WITH(libuuid, AC_HELP_STRING([--with-libuuid], [Build with libuuid support for client IDs]))
+
+AC_CHECK_FUNCS([uuid_create], [], [
+    if test x"$with_libuuid" != xno && test x"$have_system_uuid" != xyes; then
+        PKG_CHECK_MODULES(LIBUUID, uuid, [HAVE_LIBUUID=yes], [HAVE_LIBUUID=no])
+    fi
+    if test x"$with_libuuid" = xyes && test x"$HAVE_LIBUUID" = xno; then
+        AC_MSG_ERROR([requested libuuid support but uuid.pc not found])
+    fi
+])
+
+AM_CONDITIONAL(WITH_LIBUUID, test x"$HAVE_LIBUUID" = xyes)
+
+AC_OUTPUT([Makefile
+          doc/Makefile
+          src/Makefile
+          sm.pc])
diff --git a/debian/README.source b/debian/README.source
new file mode 100644 (file)
index 0000000..34ab4bf
--- /dev/null
@@ -0,0 +1,73 @@
+------------------------------------------------------
+Quick Guide To Patching This Package For The Impatient
+------------------------------------------------------
+
+1. Make sure you have quilt installed
+2. Unpack the package as usual with "dpkg-source -x"
+3. Run the "patch" target in debian/rules
+4. Create a new patch with "quilt new" (see quilt(1))
+5. Edit all the files you want to include in the patch with "quilt edit" 
+   (see quilt(1)).
+6. Write the patch with "quilt refresh" (see quilt(1))
+7. Run the "clean" target in debian/rules
+
+Alternatively, instead of using quilt directly, you can drop the patch in to 
+debian/patches and add the name of the patch to debian/patches/series.
+
+------------------------------------
+Guide To The X Strike Force Packages
+------------------------------------
+
+The X Strike Force team maintains X packages in git repositories on
+git.debian.org in the pkg-xorg subdirectory. Most upstream packages
+are actually maintained in git repositories as well, so they often
+just need to be pulled into git.debian.org in a "upstream-*" branch.
+Otherwise, the upstream sources are manually installed in the Debian
+git repository.
+
+The .orig.tar.gz upstream source file could be generated this
+"upstream-*" branch in the Debian git repository but it is actually
+copied from upstream tarballs directly.
+
+Due to X.org being highly modular, packaging all X.org applications
+as their own independent packages would have created too many Debian
+packages. For this reason, some X.org applications have been grouped
+into larger packages: xutils, xutils-dev, x11-apps, x11-session-utils,
+x11-utils, x11-xfs-utils, x11-xkb-utils, x11-xserver-utils.
+Most packages, including the X.org server itself and all libraries
+and drivers are, however maintained independently.
+
+The Debian packaging is added by creating the "debian-*" git branch
+which contains the aforementioned "upstream-*" branch plus the debian/
+repository files.
+When a patch has to be applied to the Debian package, two solutions
+are involved:
+* If the patch is available in one of the upstream branches, it
+  may be git'cherry-picked into the Debian repository. In this
+  case, it appears directly in the .diff.gz.
+* Otherwise, the patch is added to debian/patches/ which is managed
+  with quilt as documented in /usr/share/doc/quilt/README.source.
+
+quilt is actually invoked by the Debian X packaging through a larger
+set of scripts called XSFBS. XSFBS brings some other X specific
+features such as managing dependencies and conflicts due to the video
+and input driver ABIs.
+XSFBS itself is maintained in a separate repository at
+  git://git.debian.org/pkg-xorg/xsfbs.git
+and it is pulled inside the other Debian X repositories when needed.
+
+The XSFBS patching system requires a build dependency on quilt. Also
+a dependency on $(STAMP_DIR)/patch has to be added to debian/rules
+so that the XSFBS patching occurs before the actual build. So the
+very first target of the build (likely the one running autoreconf)
+should depend on $(STAMP_DIR)/patch. It should also not depend on
+anything so that parallel builds are correctly supported (nothing
+should probably run while patching is being done). And finally, the
+clean target should depend on the xsfclean target so that patches
+are unapplied on clean.
+
+When the upstream sources contain some DFSG-nonfree files, they are
+listed in text files in debian/prune/ in the "debian-*" branch of
+the Debian repository. XSFBS' scripts then take care of removing
+these listed files during the build so as to generate a modified
+DFSG-free .orig.tar.gz tarball.
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..06bf0b8
--- /dev/null
@@ -0,0 +1,197 @@
+libsm (2:1.2.0-1slp2) unstable; urgency=low
+
+  * [X11R7.6] upgrade package
+  * Git: 165.213.180.234:slp/pkgs/xorg/lib/libsm
+  * Tag: libsm_1.2.0-1slp2
+
+ -- SooChan Lim <sc1.lim@samsung.com>  Mon, 03 Jan 2011 22:17:16 +0900
+
+libsm (2:1.1.1-6slp2) unstable; urgency=low
+
+  * Modify the changelog
+  * Git: 165.213.180.234:/git/slp/pkgs/xorg/lib/libsm
+  * Tag: libsm_1.1.1-6slp2 
+
+ -- SooChan Lim <sc1.lim@samsung.com>  Fri, 26 Nov 2010 10:53:37 +0900
+
+libsm (2:1.1.1-5slp2) unstable; urgency=low
+
+  * modify the package name
+
+ -- SooChan Lim <sc1.lim@samsung.com>  Thu, 25 Mar 2010 17:38:53 +0900
+
+libsm (2:1.1.1-4) unstable; urgency=low
+
+  * Change configure option (--with-uuid=no) temporarily for build rdepends packages properly.
+
+ -- Sung-Jin Park <sj76.park@samsung.com>  Thu, 17 Dec 2009 10:28:06 +0900
+
+libsm (2:1.1.1-3) unstable; urgency=low
+
+  * Fix debian/rules to install .la files properly
+
+ -- Sung-Jin Park <sj76.park@samsung.com>  Mon, 07 Dec 2009 14:37:58 +0900
+
+libsm (2:1.1.1-2) unstable; urgency=low
+
+  * Import debian package
+  * Install .la files
+
+ -- Sung-Jin Park <sj76.park@samsung.com>  Mon, 07 Dec 2009 10:30:25 +0900
+
+libsm (2:1.1.1-1) unstable; urgency=low
+
+  * New upstream release.
+  * Move libsm6-dbg to 'debug' section.
+  * Drop x11-common (pre-)dependencies, this isn't needed anymore.
+  * Bump libice-dev build-dep to 2:1.0.5.
+  * Bump xutils-dev build-dep to 1:7.4+4 for new util-macros.
+  * Add README.source from xsfbs, bump Standards-Version to 3.8.3.
+  * Look for space-separated DEB_BUILD_OPTIONS.
+
+ -- Julien Cristau <jcristau@debian.org>  Tue, 25 Aug 2009 17:58:18 +0200
+
+libsm (2:1.1.0-2) unstable; urgency=low
+
+  * Upload to unstable.
+
+ -- Julien Cristau <jcristau@debian.org>  Mon, 16 Feb 2009 01:33:27 +0100
+
+libsm (2:1.1.0-1) experimental; urgency=low
+
+  [ Brice Goglin ]
+  * Use ${binary:Version} instead of the deprecated ${Source-Version}.
+
+  [ Julien Cristau ]
+  * New upstream release.
+    - generate client IDs using libuuid instead of gethostbyname()
+  * Switch to running autoreconf at build time; clean up in debian/rules
+    clean, and build-depend on automake, libtool and xutils-dev.
+  * Drop -1 debian revisions from build-deps.
+  * Stop handling nostrip explicitly in debian/rules (dh_strip does it
+    already), and allow parallel builds using sample code from policy.
+  * Add myself to Uploaders.
+  * Don't export a dependency on ice in sm.pc.
+
+ -- Julien Cristau <jcristau@debian.org>  Fri, 18 Jul 2008 16:16:47 +0200
+
+libsm (2:1.0.3-2) unstable; urgency=low
+
+  * Fix short descriptions of libsm-dev and libsm-dbg,
+    thanks Philippe Cloutier, closes: #432967.
+  * Add upstream URL to debian/copyright.
+  * Bump Standards-Version to 3.7.3 (no changes).
+  * Add myself to Uploaders, and remove Branden and Fabio with their
+    permission.
+  * Add Vcs-Browser field and drop the XS- prefix from Vcs-Git.
+  * Add a link to www.X.org and a reference to the libSM module in the long
+    description.
+
+ -- Brice Goglin <bgoglin@debian.org>  Fri, 13 Jun 2008 07:07:33 +0200
+
+libsm (2:1.0.3-1) unstable; urgency=low
+
+  [ Julien Cristau ]
+  * Move binary packages to the proper sections.
+  * New upstream release.
+
+  [ Timo Aaltonen ]
+  * Bump the epoch so that this can be synced to Ubuntu in the future.
+
+ -- Julien Cristau <jcristau@debian.org>  Mon, 14 May 2007 16:41:22 +0200
+
+libsm (1:1.0.2-2) unstable; urgency=low
+
+  * Upload to unstable.
+
+ -- Julien Cristau <jcristau@debian.org>  Wed, 11 Apr 2007 10:53:40 +0200
+
+libsm (1:1.0.2-1) experimental; urgency=low
+
+  * New upstream release.
+  * Drop obsolete CVS info from the descriptions, and add XS-Vcs-Git.
+  * Install the upstream changelog.
+
+ -- Julien Cristau <jcristau@debian.org>  Fri,  9 Feb 2007 17:37:39 +0100
+
+libsm (1:1.0.1-3) unstable; urgency=low
+
+  * Exclude libSM.la from dh_install.
+  * The library in debian/rules is libsm6 not libxau6! Closes: #383468.
+  * libsm-dev uses versioned depends on libice-dev from X11R7. 
+    Closes: #372129.
+
+ -- Drew Parsons <dparsons@debian.org>  Fri, 22 Sep 2006 21:33:23 +1000
+
+libsm (1:1.0.1-2) unstable; urgency=low
+
+  [ Andres Salomon ]
+  * Test for obj-$(DEB_BUILD_GNU_TYPE) before creating it during build;
+    idempotency fix.
+
+  [ Drew Parsons ]
+  * dbg package has priority extra.
+
+ -- David Nusinow <dnusinow@debian.org>  Tue, 29 Aug 2006 23:35:12 +0000
+
+libsm (1:1.0.1-1) experimental; urgency=low
+
+  * New upstream release
+  * Run dh_install with --list-missing
+  * Bump debhelper compat to 5
+  * Remove extra x11-common dep from -dev package
+  * Version x11-common pre-dep in -dev package to be 1:7.0.0 to match the rest
+    of Debian and shut lintian up
+  * Bump standards version to 3.7.2.0
+  * Don't look to install manpages for -dev package, there aren't any
+
+ -- David Nusinow <dnusinow@debian.org>  Mon,  3 Jul 2006 17:18:41 -0400
+
+libsm (1:1.0.0-4) unstable; urgency=low
+
+  * Reorder makeshlib command in rules file so that ldconfig is run
+    properly. Thanks Drew Parsons and Steve Langasek.
+
+ -- David Nusinow <dnusinow@debian.org>  Tue, 18 Apr 2006 21:49:55 -0400
+
+libsm (1:1.0.0-3) unstable; urgency=low
+
+  * Upload to unstable
+
+ -- David Nusinow <dnusinow@debian.org>  Thu, 23 Mar 2006 22:44:25 -0500
+
+libsm (1:1.0.0-2) experimental; urgency=low
+
+  * Provide versioned build depends for the X libs
+
+ -- David Nusinow <dnusinow@debian.org>  Thu, 23 Feb 2006 22:46:43 -0500
+
+libsm (1:1.0.0-1) UNRLEASED; urgency=low
+
+  * First upload to Debian
+
+ -- David Nusinow <dnusinow@debian.org>  Thu, 29 Dec 2005 20:47:53 -0500
+
+libsm (1:6.0.4-4) breezy; urgency=low
+
+  * Version the x11proto-core-dev build-dep to avoid _XOPEN_SOURCE.
+
+ -- Adam Conrad <adconrad@ubuntu.com>  Sun, 24 Jul 2005 10:42:00 +0000
+
+libsm (1:6.0.4-3) breezy; urgency=low
+
+  * Add libice-dev to libsm-dev Depends.
+
+ -- Daniel Stone <daniel.stone@ubuntu.com>  Thu, 21 Jul 2005 18:07:37 +1000
+
+libsm (1:6.0.4-2) breezy; urgency=low
+
+  * Fix Build-Depends-Indep vs B-D hilarity/stupidity.
+
+ -- Daniel Stone <daniel.stone@ubuntu.com>  Wed,  1 Jun 2005 00:34:43 +1000
+
+libsm (1:6.0.4-1) breezy; urgency=low
+
+  * First libsm release.
+
+ -- Daniel Stone <daniel.stone@ubuntu.com>  Mon, 16 May 2005 22:10:17 +1000
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..8224b7f
--- /dev/null
@@ -0,0 +1,67 @@
+Source: libsm
+Section: x11
+Priority: optional
+Maintainer: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>, Debian X Strike Force <debian-x@lists.debian.org>
+Uploaders: SooChan Lim <sc1.lim@samsung.com>, David Nusinow <dnusinow@debian.org>, Brice Goglin <bgoglin@debian.org>, Julien Cristau <jcristau@debian.org>
+Build-Depends: debhelper (>= 5.0.0), pkg-config, x11proto-core-dev (>= 6.8.99.15+cvs.20050722), xtrans-dev, libice-dev (>= 2:1.0.5), libuuid-dev, automake, libtool, xutils-dev (>= 1:7.4+4), quilt
+Standards-Version: 3.8.3
+Vcs-Git: git://git.debian.org/git/pkg-xorg/lib/libsm
+Vcs-Browser: http://git.debian.org/?p=pkg-xorg/lib/libsm.git
+
+Package: libsm6
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: X11 Session Management library
+ This package provides the main interface to the X11 Session Management
+ library, which allows for applications to both manage sessions, and make use
+ of session managers to save and restore their state for later use.
+ .
+ More information about X.Org can be found at:
+ <URL:http://www.X.org>
+ <URL:http://xorg.freedesktop.org>
+ <URL:http://lists.freedesktop.org/mailman/listinfo/xorg>
+ .
+ This module can be found at
+ git://anongit.freedesktop.org/git/xorg/lib/libSM
+
+Package: libsm6-dbg
+Section: debug
+Architecture: any
+Priority: extra
+Depends: ${shlibs:Depends}, ${misc:Depends}, libsm6 (= ${binary:Version})
+Description: X11 Session Management library (debug package)
+ This package provides the main interface to the X11 Session Management
+ library, which allows for applications to both manage sessions, and make use
+ of session managers to save and restore their state for later use.
+ .
+ This package contains the debug versions of the library found in libsm6.
+ Non-developers likely have little use for this package.
+ .
+ More information about X.Org can be found at:
+ <URL:http://www.X.org>
+ <URL:http://xorg.freedesktop.org>
+ <URL:http://lists.freedesktop.org/mailman/listinfo/xorg>
+ .
+ This module can be found at
+ git://anongit.freedesktop.org/git/xorg/lib/libSM
+
+Package: libsm-dev
+Section: libdevel
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libsm6 (= ${binary:Version}), x11proto-core-dev, libice-dev (>= 1:1.0.0-1)
+Description: X11 Session Management library (development headers)
+ This package provides the main interface to the X11 Session Management
+ library, which allows for applications to both manage sessions, and make use
+ of session managers to save and restore their state for later use.
+ .
+ This package contains the development headers for the library found in libsm6.
+ Non-developers likely have little use for this package.
+ .
+ More information about X.Org can be found at:
+ <URL:http://www.X.org>
+ <URL:http://xorg.freedesktop.org>
+ <URL:http://lists.freedesktop.org/mailman/listinfo/xorg>
+ .
+ This module can be found at
+ git://anongit.freedesktop.org/git/xorg/lib/libSM
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..ddc4be2
--- /dev/null
@@ -0,0 +1,24 @@
+This package was downloaded from
+http://xorg.freedesktop.org/releases/individual/lib/
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
diff --git a/debian/libsm-dev.install b/debian/libsm-dev.install
new file mode 100755 (executable)
index 0000000..2ff2802
--- /dev/null
@@ -0,0 +1,5 @@
+usr/include/X11/*
+usr/lib/libSM.a
+usr/lib/libSM.la
+usr/lib/libSM.so
+usr/lib/pkgconfig/sm.pc
diff --git a/debian/libsm6.install b/debian/libsm6.install
new file mode 100644 (file)
index 0000000..f6c0204
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/libSM.so.6*
diff --git a/debian/patches/0001-sm.pc-don-t-export-a-dependency-on-ice.patch b/debian/patches/0001-sm.pc-don-t-export-a-dependency-on-ice.patch
new file mode 100644 (file)
index 0000000..3347ef4
--- /dev/null
@@ -0,0 +1,26 @@
+From 756399aa14618be0a8ac2e0a824356abf69cc466 Mon Sep 17 00:00:00 2001
+From: Julien Cristau <jcristau@debian.org>
+Date: Fri, 18 Jul 2008 16:12:29 +0200
+Subject: [PATCH] sm.pc: don't export a dependency on ice
+
+use Requires.private for this
+---
+ sm.pc.in |    3 +--
+ 1 files changed, 1 insertions(+), 2 deletions(-)
+
+diff --git a/sm.pc.in b/sm.pc.in
+index ab1261e..aefc38c 100644
+--- a/sm.pc.in
++++ b/sm.pc.in
+@@ -6,7 +6,6 @@ includedir=@includedir@
+ Name: SM
+ Description: X Session Management Library
+ Version: @PACKAGE_VERSION@
+-Requires: ice xproto
+-Requires.private: ice
++Requires.private: ice xproto
+ Cflags: -I${includedir}
+ Libs: -L${libdir} -lSM
+-- 
+1.5.6.2
+
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644 (file)
index 0000000..34b233e
--- /dev/null
@@ -0,0 +1 @@
+0001-sm.pc-don-t-export-a-dependency-on-ice.patch
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..58effb2
--- /dev/null
@@ -0,0 +1,112 @@
+#!/usr/bin/make -f
+# debian/rules for the Debian libxau package.
+# Copyright Â© 2004 Scott James Remnant <scott@netsplit.com>
+# Copyright Â© 2005 Daniel Stone <daniel@fooishbar.org>
+# Copyright Â© 2005 David Nusinow <dnusinow@debian.org>
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# set this to the name of the main shlib's binary package
+PACKAGE = libsm6
+
+include debian/xsfbs/xsfbs.mk
+
+CFLAGS = -Wall -g
+ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+       NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+       MAKEFLAGS += -j$(NUMJOBS)
+endif
+
+DEB_HOST_ARCH      ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+       confflags += --build=$(DEB_HOST_GNU_TYPE)
+else
+       confflags += --build=$(DEB_HOST_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
+#      confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
+endif
+
+confflags += --with-libuuid=no
+#confflags += --with-libuuid
+
+.PHONY: autogen
+autogen: autogen-stamp
+autogen-stamp:
+#autogen-stamp: $(STAMP_DIR)/patch
+       dh_testdir
+       autoreconf -vfi
+       >$@
+
+obj-$(DEB_BUILD_GNU_TYPE)/config.status: autogen-stamp
+       dh_testdir
+       test -d obj-$(DEB_BUILD_GNU_TYPE) || mkdir obj-$(DEB_BUILD_GNU_TYPE)
+       cd obj-$(DEB_BUILD_GNU_TYPE) && \
+       ../configure --prefix=/usr --mandir=\$${prefix}/share/man \
+                    --infodir=\$${prefix}/share/info $(confflags) \
+                    CFLAGS="$(CFLAGS)" 
+
+.PHONY: build
+build: build-stamp
+build-stamp: obj-$(DEB_BUILD_GNU_TYPE)/config.status
+       dh_testdir
+       cd obj-$(DEB_BUILD_GNU_TYPE) && $(MAKE)
+       >$@
+
+clean: xsfclean
+       dh_testdir
+       dh_testroot
+       rm -f autogen-stamp build-stamp
+
+       rm -f config.cache config.log config.status
+       rm -f */config.cache */config.log */config.status
+       rm -f conftest* */conftest*
+       rm -rf autom4te.cache */autom4te.cache
+       rm -rf obj-*
+       rm -f $$(find -name Makefile.in)
+       rm -f compile config.guess config.sub configure depcomp install-sh
+       rm -f ltmain.sh missing INSTALL aclocal.m4 config.h.in
+       rm -f mkinstalldirs
+
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       cd obj-$(DEB_BUILD_GNU_TYPE) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+
+#      dh_installdocs
+       dh_install --sourcedir=debian/tmp --list-missing
+       #dh_install --sourcedir=debian/tmp --list-missing --exclude=libSM.la
+#      dh_installchangelogs ChangeLog
+       dh_link
+       dh_strip --dbg-package=$(PACKAGE)-dbg
+       dh_compress
+       dh_fixperms
+       dh_makeshlibs
+       dh_shlibdeps
+       dh_installdeb
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+# Build architecture-independent files here.
+binary-indep: build install
+# Nothing to do
+
+binary: binary-indep binary-arch
+.PHONY: clean binary-indep binary-arch binary install
diff --git a/debian/watch b/debian/watch
new file mode 100644 (file)
index 0000000..d2e8274
--- /dev/null
@@ -0,0 +1,2 @@
+version=3
+http://xorg.freedesktop.org/releases/individual/lib/ libSM-(.*)\.tar\.gz
diff --git a/debian/xsfbs/repack.sh b/debian/xsfbs/repack.sh
new file mode 100644 (file)
index 0000000..5935cc9
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+set -e
+
+if ! [ -d debian/prune ]; then
+       exit 0
+fi
+
+if [ "x$1" != x--upstream-version ]; then
+       exit 1
+fi
+
+version="$2"
+filename="$3"
+
+if [ -z "$version" ] || ! [ -f "$filename" ]; then
+       exit 1
+fi
+
+dir="$(pwd)"
+tempdir="$(mktemp -d)"
+
+cd "$tempdir"
+tar xf "$dir/$filename"
+cat "$dir"/debian/prune/* | while read file; do rm -f */$file; done
+
+tar czf "$dir/$filename" *
+cd "$dir"
+rm -rf "$tempdir"
+echo "Done pruning upstream tarball"
+
+exit 0
diff --git a/debian/xsfbs/xsfbs.mk b/debian/xsfbs/xsfbs.mk
new file mode 100644 (file)
index 0000000..f0f8953
--- /dev/null
@@ -0,0 +1,293 @@
+#!/usr/bin/make -f
+
+# Debian X Strike Force Build System (XSFBS): Make portion
+
+# Copyright 1996 Stephen Early
+# Copyright 1997 Mark Eichin
+# Copyright 1998-2005, 2007 Branden Robinson
+# Copyright 2005 David Nusinow
+#
+# Licensed under the GNU General Public License, version 2.  See the file
+# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
+
+# Originally by Stephen Early <sde1000@debian.org>
+# Modified by Mark W. Eichin <eichin@kitten.gen.ma.us>
+# Modified by Adam Heath <doogie@debian.org>
+# Modified by Branden Robinson <branden@debian.org>
+# Modified by Fabio Massimo Di Nitto <fabbione@fabbione.net>
+# Modified by David Nusinow <dnusinow@debian.org>
+# Acknowledgements to Manoj Srivastava.
+
+# Pass $(DH_OPTIONS) into the environment for debhelper's benefit.
+export DH_OPTIONS
+
+# force quilt to not use ~/.quiltrc and to use debian/patches
+QUILT = QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null
+
+# Set up parameters for the upstream build environment.
+
+# Determine (source) package name from Debian changelog.
+SOURCE_NAME:=$(shell dpkg-parsechangelog -ldebian/changelog \
+                        | grep '^Source:' | awk '{print $$2}')
+
+# Determine package version from Debian changelog.
+SOURCE_VERSION:=$(shell dpkg-parsechangelog -ldebian/changelog \
+                        | grep '^Version:' | awk '{print $$2}')
+
+# Determine upstream version number.
+UPSTREAM_VERSION:=$(shell echo $(SOURCE_VERSION) | sed 's/-.*//')
+
+# Determine the source version without the epoch for make-orig-tar-gz
+NO_EPOCH_VER:=$(shell echo $(UPSTREAM_VERSION) | sed 's/^.://')
+
+# Figure out who's building this package.
+BUILDER:=$(shell echo $${DEBEMAIL:-$${EMAIL:-$$(echo $$LOGNAME@$$(cat /etc/mailname 2>/dev/null))}})
+
+# Find out if this is an official build; an official build has nothing but
+# digits, dots, and/or the codename of a release in the Debian part of the
+# version number.  Anything else indicates an unofficial build.
+OFFICIAL_BUILD:=$(shell VERSION=$(SOURCE_VERSION); if ! expr "$$(echo $${VERSION\#\#*-} | sed 's/\(woody\|sarge\|etch\|lenny\)//g')" : ".*[^0-9.].*" >/dev/null 2>&1; then echo yes; fi)
+
+# Set up parameters for the Debian build environment.
+
+# Determine our architecture.
+BUILD_ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
+# Work around some old-time dpkg braindamage.
+BUILD_ARCH:=$(subst i486,i386,$(BUILD_ARCH))
+# The DEB_HOST_ARCH variable may be set per the Debian cross-compilation policy.
+ifdef DEB_HOST_ARCH
+ ARCH:=$(DEB_HOST_ARCH)
+else
+ # dpkg-cross sets the ARCH environment variable; if set, use it.
+ ifdef ARCH
+  ARCH:=$(ARCH)
+ else
+  ARCH:=$(BUILD_ARCH)
+ endif
+endif
+
+# $(STAMP_DIR) houses stamp files for complex targets.
+STAMP_DIR:=stampdir
+
+# $(DEBTREEDIR) is where all install rules are told (via $(DESTDIR)) to place
+# their files.
+DEBTREEDIR:=$(CURDIR)/debian/tmp
+
+# All "important" targets have four lines:
+#   1) A target name that is invoked by a package-building tool or the user.
+#      This consists of a dependency on a "$(STAMP_DIR)/"-prefixed counterpart.
+#   2) A line delcaring 1) as a phony target (".PHONY:").
+#   3) A "$(STAMP_DIR)/"-prefixed target which does the actual work, and may
+#   depend on other targets.
+#   4) A line declaring 3) as a member of the $(stampdir_targets) variable; the
+#   "$(STAMP_DIR)/" prefix is omitted.
+#
+# This indirection is needed so that the "stamp" files that signify when a rule
+# is done can be located in a separate "stampdir".  Recall that make has no way
+# to know when a goal has been met for a phony target (like "build" or
+# "install").
+#
+# At the end of each "$(STAMP_DIR)/" target, be sure to run the command ">$@"
+# so that the target will not be run again.  Removing the file will make Make
+# run the target over.
+
+# All phony targets should be declared as dependencies of .PHONY, even if they
+# do not have "($STAMP_DIR)/"-prefixed counterparts.
+
+# Define a harmless default rule to keep things from going nuts by accident.
+.PHONY: default
+default:
+
+# Set up the $(STAMP_DIR) directory.
+.PHONY: stampdir
+stampdir_targets+=stampdir
+stampdir: $(STAMP_DIR)/stampdir
+$(STAMP_DIR)/stampdir:
+       mkdir $(STAMP_DIR)
+       >$@
+
+# Set up the package build directory as quilt expects to find it.
+.PHONY: prepare
+stampdir_targets+=prepare
+prepare: $(STAMP_DIR)/prepare
+$(STAMP_DIR)/prepare: $(STAMP_DIR)/log $(STAMP_DIR)/genscripts
+       >$@
+
+.PHONY: log
+stampdir_targets+=log
+log: $(STAMP_DIR)/log
+$(STAMP_DIR)/log: $(STAMP_DIR)/stampdir
+       mkdir -p $(STAMP_DIR)/log
+
+# Apply all patches to the upstream source.
+.PHONY: patch
+stampdir_targets+=patch
+patch: $(STAMP_DIR)/patch
+$(STAMP_DIR)/patch: $(STAMP_DIR)/prepare
+       if ! [ `which quilt` ]; then \
+               echo "Couldn't find quilt. Please install it or add it to the build-depends for this package."; \
+               exit 1; \
+       fi; \
+       if $(QUILT) next >/dev/null 2>&1; then \
+         echo -n "Applying patches..."; \
+         if $(QUILT) push -a -v >$(STAMP_DIR)/log/patch 2>&1; then \
+           cat $(STAMP_DIR)/log/patch; \
+           echo "successful."; \
+         else \
+           cat $(STAMP_DIR)/log/patch; \
+           echo "failed! (check $(STAMP_DIR)/log/patch for details)"; \
+           exit 1; \
+         fi; \
+       else \
+         echo "No patches to apply"; \
+       fi; \
+       >$@
+
+# Revert all patches to the upstream source.
+.PHONY: unpatch
+unpatch: $(STAMP_DIR)/log
+       rm -f $(STAMP_DIR)/patch
+       @echo -n "Unapplying patches..."; \
+       if $(QUILT) applied >/dev/null 2>/dev/null; then \
+         if $(QUILT) pop -a -v >$(STAMP_DIR)/log/unpatch 2>&1; then \
+           cat $(STAMP_DIR)/log/unpatch; \
+           echo "successful."; \
+         else \
+           cat $(STAMP_DIR)/log/unpatch; \
+           echo "failed! (check $(STAMP_DIR)/log/unpatch for details)"; \
+           exit 1; \
+         fi; \
+       else \
+         echo "nothing to do."; \
+       fi
+
+# Clean the generated maintainer scripts.
+.PHONY: cleanscripts
+cleanscripts:
+       rm -f $(STAMP_DIR)/genscripts
+       rm -f debian/*.config \
+             debian/*.postinst \
+             debian/*.postrm \
+             debian/*.preinst \
+             debian/*.prerm
+
+# Clean the package build tree.
+.PHONY: xsfclean
+xsfclean: cleanscripts unpatch
+       dh_testdir
+       rm -rf .pc
+       rm -rf $(STAMP_DIR) $(SOURCE_DIR)
+       rm -rf imports
+       dh_clean debian/shlibs.local \
+                debian/po/pothead
+
+# Generate the debconf templates POT file header.
+debian/po/pothead: debian/po/pothead.in
+       sed -e 's/SOURCE_VERSION/$(SOURCE_VERSION)/' \
+         -e 's/DATE/$(shell date "+%F %X%z"/)' <$< >$@
+
+# Update POT and PO files.
+.PHONY: updatepo
+updatepo: debian/po/pothead
+       debian/scripts/debconf-updatepo --pot-header=pothead --verbose
+
+# Remove files from the upstream source tree that we don't need, or which have
+# licensing problems.  It must be run before creating the .orig.tar.gz.
+#
+# Note: This rule is for Debian package maintainers' convenience, and is not
+# needed for conventional build scenarios.
+.PHONY: prune-upstream-tree
+prune-upstream-tree:
+       # Ensure we're in the correct directory.
+       dh_testdir
+       grep -rvh '^#' debian/prune/ | xargs --no-run-if-empty rm -rf
+
+# Verify that there are no offsets or fuzz in the patches we apply.
+#
+# Note: This rule is for Debian package maintainers' convenience, and is not
+# needed for conventional build scenarios.
+.PHONY: patch-audit
+patch-audit: prepare unpatch
+       @echo -n "Auditing patches..."; \
+       >$(STAMP_DIR)/log/patch; \
+       FUZZY=; \
+       while [ -n "$$($(QUILT) next)" ]; do \
+         RESULT=$$($(QUILT) push -v | tee -a $(STAMP_DIR)/log/patch | grep ^Hunk | sed 's/^Hunk.*\(succeeded\|FAILED\).*/\1/');\
+         case "$$RESULT" in \
+           succeeded) \
+             echo "fuzzy patch: $$($(QUILT) top)" \
+               | tee -a $(STAMP_DIR)/log/$$($(QUILT) top); \
+             FUZZY=yes; \
+             ;; \
+           FAILED) \
+             echo "broken patch: $$($(QUILT) next)" \
+               | tee -a $(STAMP_DIR)/log/$$($(QUILT) next); \
+             exit 1; \
+             ;; \
+         esac; \
+       done; \
+       if [ -n "$$FUZZY" ]; then \
+         echo "there were fuzzy patches; please fix."; \
+         exit 1; \
+       else \
+         echo "done."; \
+       fi
+
+# Generate the maintainer scripts.
+.PHONY: genscripts
+stampdir_targets+=genscripts
+genscripts: $(STAMP_DIR)/genscripts
+$(STAMP_DIR)/genscripts: $(STAMP_DIR)/stampdir
+       for FILE in debian/*.config.in \
+                   debian/*.postinst.in \
+                   debian/*.postrm.in \
+                   debian/*.preinst.in \
+                   debian/*.prerm.in; do \
+         if [ -e "$$FILE" ]; then \
+           MAINTSCRIPT=$$(echo $$FILE | sed 's/.in$$//'); \
+           sed -n '1,/^#INCLUDE_SHELL_LIB#$$/p' <$$FILE \
+             | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >$$MAINTSCRIPT.tmp; \
+           cat debian/xsfbs/xsfbs.sh >>$$MAINTSCRIPT.tmp; \
+           sed -n '/^#INCLUDE_SHELL_LIB#$$/,$$p' <$$FILE \
+             | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >>$$MAINTSCRIPT.tmp; \
+           sed -e 's/@SOURCE_VERSION@/$(SOURCE_VERSION)/' \
+               -e 's/@OFFICIAL_BUILD@/$(OFFICIAL_BUILD)/' \
+               -e 's/@DEFAULT_DCRESOLUTIONS@/$(DEFAULT_DCRESOLUTIONS)/' \
+             <$$MAINTSCRIPT.tmp >$$MAINTSCRIPT; \
+           rm $$MAINTSCRIPT.tmp; \
+         fi; \
+       done
+       # Validate syntax of generated shell scripts.
+       #sh debian/scripts/validate-posix-sh debian/*.config \
+       #                                    debian/*.postinst \
+       #                                    debian/*.postrm \
+       #                                    debian/*.preinst \
+       #                                    debian/*.prerm
+       >$@
+
+# Generate the shlibs.local file.
+debian/shlibs.local:
+       cat debian/*.shlibs >$@
+
+SERVERMINVERS = $(shell cat /usr/share/xserver-xorg/serverminver 2>/dev/null)
+VIDEOABI = $(shell cat /usr/share/xserver-xorg/videoabiver 2>/dev/null)
+INPUTABI = $(shell cat /usr/share/xserver-xorg/inputabiver 2>/dev/null)
+SERVER_DEPENDS = xserver-xorg-core (>= $(SERVERMINVERS))
+VIDDRIVER_PROVIDES = xserver-xorg-video-$(VIDEOABI)
+INPDRIVER_PROVIDES = xserver-xorg-input-$(INPUTABI)
+ifeq ($(PACKAGE),)
+PACKAGE=$(shell awk '/^Package:/ { print $$2; exit }' < debian/control)
+endif
+
+.PHONY: serverabi
+serverabi: install
+ifeq ($(SERVERMINVERS),)
+       @echo error: xserver-xorg-dev needs to be installed
+       @exit 1
+else
+       echo "xserver:Depends=$(SERVER_DEPENDS)" >> debian/$(PACKAGE).substvars
+       echo "xviddriver:Provides=$(VIDDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars
+       echo "xinpdriver:Provides=$(INPDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars
+endif
+
+# vim:set noet ai sts=8 sw=8 tw=0:
diff --git a/debian/xsfbs/xsfbs.sh b/debian/xsfbs/xsfbs.sh
new file mode 100644 (file)
index 0000000..781826f
--- /dev/null
@@ -0,0 +1,853 @@
+# $Id$
+
+# This is the X Strike Force shell library for X Window System package
+# maintainer scripts.  It serves to define shell functions commonly used by
+# such packages, and performs some error checking necessary for proper operation
+# of those functions.  By itself, it does not "do" much; the maintainer scripts
+# invoke the functions defined here to accomplish package installation and
+# removal tasks.
+
+# If you are reading this within a Debian package maintainer script (e.g.,
+# /var/lib/dpkg)info/PACKAGE.{config,preinst,postinst,prerm,postrm}), you can
+# skip past this library by scanning forward in this file to the string
+# "GOBSTOPPER".
+
+SOURCE_VERSION=@SOURCE_VERSION@
+OFFICIAL_BUILD=@OFFICIAL_BUILD@
+
+# Use special abnormal exit codes so that problems with this library are more
+# easily tracked down.
+SHELL_LIB_INTERNAL_ERROR=86
+SHELL_LIB_THROWN_ERROR=74
+SHELL_LIB_USAGE_ERROR=99
+
+# old -> new variable names
+if [ -z "$DEBUG_XORG_PACKAGE" ] && [ -n "$DEBUG_XFREE86_PACKAGE" ]; then
+  DEBUG_XORG_PACKAGE="$DEBUG_XFREE86_PACKAGE"
+fi
+if [ -z "$DEBUG_XORG_DEBCONF" ] && [ -n "$DEBUG_XFREE86_DEBCONF" ]; then
+  DEBUG_XORG_DEBCONF="$DEBUG_XFREE86_DEBCONF"
+fi
+
+# initial sanity checks
+if [ -z "$THIS_PACKAGE" ]; then
+  cat >&2 <<EOF
+Error: package maintainer script attempted to use shell library without
+definining \$THIS_PACKAGE shell variable.  Please report the package name,
+version, and the text of this error message to the Debian Bug Tracking System.
+Visit <http://www.debian.org/Bugs/Reporting> on the World Wide Web for
+instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the
+"doc-debian" package, or install the "reportbug" package and use the command of
+the same name to file a report against version $SOURCE_VERSION of this package.
+EOF
+  exit $SHELL_LIB_USAGE_ERROR
+fi
+
+if [ -z "$THIS_SCRIPT" ]; then
+  cat >&2 <<EOF
+Error: package maintainer script attempted to use shell library without
+definining \$THIS_SCRIPT shell variable.  Please report the package name,
+version, and the text of this error message to the Debian Bug Tracking System.
+Visit <http://www.debian.org/Bugs/Reporting> on the World Wide Web for
+instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the
+"doc-debian" package, or install the "reportbug" package and use the command of
+the same name to file a report against version $SOURCE_VERSION of the
+"$THIS_PACKAGE" package.
+EOF
+  exit $SHELL_LIB_USAGE_ERROR
+fi
+
+if [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then
+  RECONFIGURE="true"
+else
+  RECONFIGURE=
+fi
+
+if ([ "$1" = "install" ] || [ "$1" = "configure" ]) && [ -z "$2" ]; then
+  FIRSTINST="yes"
+fi
+
+if [ -z "$RECONFIGURE" ] && [ -z "$FIRSTINST" ]; then
+  UPGRADE="yes"
+fi
+
+trap "message;\
+      message \"Received signal.  Aborting $THIS_PACKAGE package $THIS_SCRIPT script.\";\
+      message;\
+      exit 1" HUP INT QUIT TERM
+
+reject_nondigits () {
+  # syntax: reject_nondigits [ operand ... ]
+  #
+  # scan operands (typically shell variables whose values cannot be trusted) for
+  # characters other than decimal digits and barf if any are found
+  while [ -n "$1" ]; do
+    # does the operand contain anything but digits?
+    if ! expr "$1" : "[[:digit:]]\+$" > /dev/null 2>&1; then
+      # can't use die(), because it wraps message() which wraps this function
+      echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_nondigits() encountered" \
+           "possibly malicious garbage \"$1\"" >&2
+      exit $SHELL_LIB_THROWN_ERROR
+    fi
+    shift
+  done
+}
+
+reject_whitespace () {
+  # syntax: reject_whitespace [ operand ]
+  #
+  # scan operand (typically a shell variable whose value cannot be trusted) for
+  # whitespace characters and barf if any are found
+  if [ -n "$1" ]; then
+    # does the operand contain any whitespace?
+    if expr "$1" : "[[:space:]]" > /dev/null 2>&1; then
+      # can't use die(), because I want to avoid forward references
+      echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_whitespace() encountered" \
+           "possibly malicious garbage \"$1\"" >&2
+      exit $SHELL_LIB_THROWN_ERROR
+    fi
+  fi
+}
+
+reject_unlikely_path_chars () {
+  # syntax: reject_unlikely_path_chars [ operand ... ]
+  #
+  # scan operands (typically shell variables whose values cannot be trusted) for
+  # characters unlikely to be seen in a path and which the shell might
+  # interpret and barf if any are found
+  while [ -n "$1" ]; do
+    # does the operand contain any funny characters?
+    if expr "$1" : '.*[!$&()*;<>?|].*' > /dev/null 2>&1; then
+      # can't use die(), because I want to avoid forward references
+      echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_unlikely_path_chars()" \
+           "encountered possibly malicious garbage \"$1\"" >&2
+      exit $SHELL_LIB_THROWN_ERROR
+    fi
+    shift
+  done
+}
+
+# Query the terminal to establish a default number of columns to use for
+# displaying messages to the user.  This is used only as a fallback in the
+# event the COLUMNS variable is not set.  ($COLUMNS can react to SIGWINCH while
+# the script is running, and this cannot, only being calculated once.)
+DEFCOLUMNS=$(stty size 2> /dev/null | awk '{print $2}') || true
+if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" > /dev/null 2>&1; then
+  DEFCOLUMNS=80
+fi
+
+message () {
+  # pretty-print messages of arbitrary length
+  reject_nondigits "$COLUMNS"
+  echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} >&2
+}
+
+observe () {
+  # syntax: observe message ...
+  #
+  # issue observational message suitable for logging someday when support for
+  # it exists in dpkg
+  if [ -n "$DEBUG_XORG_PACKAGE" ]; then
+    message "$THIS_PACKAGE $THIS_SCRIPT note: $*"
+  fi
+}
+
+warn () {
+  # syntax: warn message ...
+  #
+  # issue warning message suitable for logging someday when support for
+  # it exists in dpkg; also send to standard error
+  message "$THIS_PACKAGE $THIS_SCRIPT warning: $*"
+}
+
+die () {
+  # syntax: die message ...
+  #
+  # exit script with error message
+  message "$THIS_PACKAGE $THIS_SCRIPT error: $*"
+  exit $SHELL_LIB_THROWN_ERROR
+}
+
+internal_error () {
+  # exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message
+  message "internal error: $*"
+  if [ -n "$OFFICIAL_BUILD" ]; then
+    message "Please report a bug in the $THIS_SCRIPT script of the" \
+            "$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \
+            "Tracking System.  Include all messages above that mention the" \
+            "$THIS_PACKAGE package.  Visit " \
+            "<http://www.debian.org/Bugs/Reporting> on the World Wide Web for" \
+            "instructions, read the file" \
+            "/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \
+            "package, or install the reportbug package and use the command of" \
+            "the same name to file a report."
+  fi
+  exit $SHELL_LIB_INTERNAL_ERROR
+}
+
+usage_error () {
+  message "usage error: $*"
+  message "Please report a bug in the $THIS_SCRIPT script of the" \
+          "$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \
+          "Tracking System.  Include all messages above that mention the" \
+          "$THIS_PACKAGE package.  Visit " \
+          "<http://www.debian.org/Bugs/Reporting> on the World Wide Web for" \
+          "instructions, read the file" \
+          "/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \
+          "package, or install the reportbug package and use the command of" \
+          "the same name to file a report."
+  exit $SHELL_LIB_USAGE_ERROR
+}
+
+
+maplink () {
+  # returns what symlink should point to; i.e., what the "sane" answer is
+  # Keep this in sync with the debian/*.links files.
+  # This is only needed for symlinks to directories.
+  #
+  # XXX: Most of these look wrong in the X11R7 world and need to be fixed.
+  # If we've stopped using this function, fixing it might enable us to re-enable
+  # it again and catch more errors.
+  case "$1" in
+    /etc/X11/xkb/compiled) echo /var/lib/xkb ;;
+    /etc/X11/xkb/xkbcomp) echo /usr/X11R6/bin/xkbcomp ;;
+    /usr/X11R6/lib/X11/app-defaults) echo /etc/X11/app-defaults ;;
+    /usr/X11R6/lib/X11/fs) echo /etc/X11/fs ;;
+    /usr/X11R6/lib/X11/lbxproxy) echo /etc/X11/lbxproxy ;;
+    /usr/X11R6/lib/X11/proxymngr) echo /etc/X11/proxymngr ;;
+    /usr/X11R6/lib/X11/rstart) echo /etc/X11/rstart ;;
+    /usr/X11R6/lib/X11/twm) echo /etc/X11/twm ;;
+    /usr/X11R6/lib/X11/xdm) echo /etc/X11/xdm ;;
+    /usr/X11R6/lib/X11/xinit) echo /etc/X11/xinit ;;
+    /usr/X11R6/lib/X11/xkb) echo /etc/X11/xkb ;;
+    /usr/X11R6/lib/X11/xserver) echo /etc/X11/xserver ;;
+    /usr/X11R6/lib/X11/xsm) echo /etc/X11/xsm ;;
+    /usr/bin/X11) echo ../X11R6/bin ;;
+    /usr/bin/rstartd) echo ../X11R6/bin/rstartd ;;
+    /usr/include/X11) echo ../X11R6/include/X11 ;;
+    /usr/lib/X11) echo ../X11R6/lib/X11 ;;
+    *) internal_error "maplink() called with unknown path \"$1\"" ;;
+  esac
+}
+
+analyze_path () {
+  # given a supplied set of pathnames, break each one up by directory and do an
+  # ls -dl on each component, cumulatively; i.e.
+  # analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin
+  # Thanks to Randolph Chung for this clever hack.
+
+  local f g
+
+  while [ -n "$1" ]; do
+    reject_whitespace "$1"
+    g=
+    message "Analyzing $1:"
+    for f in $(echo "$1" | tr / \  ); do
+      if [ -e /$g$f ]; then
+        ls -dl /$g$f /$g$f.dpkg-* 2> /dev/null || true
+        g=$g$f/
+      else
+        message "/$g$f: nonexistent; directory contents of /$g:"
+        ls -l /$g
+        break
+      fi
+    done
+    shift
+  done
+}
+
+find_culprits () {
+  local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
+    msg
+
+  reject_whitespace "$1"
+  message "Searching for overlapping packages..."
+  dpkg_info_dir=/var/lib/dpkg/info
+  if [ -d $dpkg_info_dir ]; then
+    if [ "$(echo $dpkg_info_dir/*.list)" != "$dpkg_info_dir/*.list" ]; then
+      possible_culprits=$(ls -1 $dpkg_info_dir/*.list | egrep -v \
+        "(xbase-clients|x11-common|xfs|xlibs)")
+      if [ -n "$possible_culprits" ]; then
+        smoking_guns=$(grep -l "$1" $possible_culprits || true)
+        if [ -n "$smoking_guns" ]; then
+          bad_packages=$(printf "\\n")
+          for f in $smoking_guns; do
+            # too bad you can't nest parameter expansion voodoo
+            p=${f%*.list}      # strip off the trailing ".list"
+            package=${p##*/}   # strip off the directories
+            bad_packages=$(printf "%s\n%s" "$bad_packages" "$package")
+          done
+          msg=$(cat <<EOF
+The following packages appear to have file overlaps with the X.Org packages;
+these packages are either very old, or in violation of Debian Policy.  Try
+upgrading each of these packages to the latest available version if possible:
+for example, with the command "apt-get install".  If no newer version of a
+package is available, you will have to remove it; for example, with the command
+"apt-get remove".  If even the latest available version of the package has
+this file overlap, please file a bug against that package with the Debian Bug
+Tracking System.  You may want to refer the package maintainer to section 12.8
+of the Debian Policy manual.
+EOF
+)
+          message "$msg"
+          message "The overlapping packages are: $bad_packages"
+        else
+          message "no overlaps found."
+        fi
+      fi
+    else
+      message "cannot search; no matches for $dpkg_info_dir/*.list."
+    fi
+  else
+    message "cannot search; $dpkg_info_dir does not exist."
+  fi
+}
+
+check_symlink () {
+  # syntax: check_symlink symlink
+  #
+  # See if specified symlink points where it is supposed to.  Return 0 if it
+  # does, and 1 if it does not.
+  #
+  # Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb().
+
+  local symlink
+
+  # validate arguments
+  if [ $# -ne 1 ]; then
+    usage_error "check_symlink() called with wrong number of arguments;" \
+                "expected 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  symlink="$1"
+
+  if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+check_symlinks_and_warn () {
+  # syntax: check_symlinks_and_warn symlink ...
+  #
+  # For each argument, check for symlink sanity, and warn if it isn't sane.
+  #
+  # Call this function from a preinst script in the event $1 is "upgrade" or
+  # "install".
+
+  local errmsg symlink
+
+  # validate arguments
+  if [ $# -lt 1 ]; then
+    usage_error "check_symlinks_and_warn() called with wrong number of" \
+                "arguments; expected at least 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  while [ -n "$1" ]; do
+    symlink="$1"
+    if [ -L "$symlink" ]; then
+      if ! check_symlink "$symlink"; then
+        observe "$symlink symbolic link points to wrong location" \
+                "$(readlink "$symlink"); removing"
+        rm "$symlink"
+      fi
+    elif [ -e "$symlink" ]; then
+      errmsg="$symlink exists and is not a symbolic link; this package cannot"
+      errmsg="$errmsg be installed until this"
+      if [ -f "$symlink" ]; then
+        errmsg="$errmsg file"
+      elif [ -d "$symlink" ]; then
+        errmsg="$errmsg directory"
+      else
+        errmsg="$errmsg thing"
+      fi
+      errmsg="$errmsg is removed"
+      die "$errmsg"
+    fi
+    shift
+  done
+}
+
+check_symlinks_and_bomb () {
+  # syntax: check_symlinks_and_bomb symlink ...
+  #
+  # For each argument, check for symlink sanity, and bomb if it isn't sane.
+  #
+  # Call this function from a postinst script.
+
+  local problem symlink
+
+  # validate arguments
+  if [ $# -lt 1 ]; then
+    usage_error "check_symlinks_and_bomb() called with wrong number of"
+                "arguments; expected at least 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  while [ -n "$1" ]; do
+    problem=
+    symlink="$1"
+    if [ -L "$symlink" ]; then
+      if ! check_symlink "$symlink"; then
+        problem=yes
+        warn "$symlink symbolic link points to wrong location" \
+             "$(readlink "$symlink")"
+      fi
+    elif [ -e "$symlink" ]; then
+      problem=yes
+      warn "$symlink is not a symbolic link"
+    else
+      problem=yes
+      warn "$symlink symbolic link does not exist"
+    fi
+    if [ -n "$problem" ]; then
+      analyze_path "$symlink" "$(readlink "$symlink")"
+      find_culprits "$symlink"
+      die "bad symbolic links on system"
+    fi
+    shift
+  done
+}
+
+font_update () {
+  # run $UPDATECMDS in $FONTDIRS
+
+  local dir cmd shortcmd x_font_dir_prefix
+
+  x_font_dir_prefix="/usr/share/fonts/X11"
+
+  if [ -z "$UPDATECMDS" ]; then
+    usage_error "font_update() called but \$UPDATECMDS not set"
+  fi
+  if [ -z "$FONTDIRS" ]; then
+    usage_error "font_update() called but \$FONTDIRS not set"
+  fi
+
+  reject_unlikely_path_chars "$UPDATECMDS"
+  reject_unlikely_path_chars "$FONTDIRS"
+
+  for dir in $FONTDIRS; do
+    if [ -d "$x_font_dir_prefix/$dir" ]; then
+      for cmd in $UPDATECMDS; do
+        if which "$cmd" > /dev/null 2>&1; then
+          shortcmd=${cmd##*/}
+          observe "running $shortcmd in $dir font directory"
+         cmd_opts=
+          if [ "$shortcmd" = "update-fonts-alias" ]; then
+            cmd_opts=--x11r7-layout
+          fi
+          if [ "$shortcmd" = "update-fonts-dir" ]; then
+            cmd_opts=--x11r7-layout
+          fi
+          if [ "$shortcmd" = "update-fonts-scale" ]; then
+            cmd_opts=--x11r7-layout
+          fi
+          $cmd $cmd_opts $dir || warn "$cmd $cmd_opts $dir" \
+                              "failed; font directory data may not" \
+                              "be up to date"
+        else
+          warn "$cmd not found; not updating corresponding $dir font" \
+               "directory data"
+        fi
+      done
+    else
+      warn "$dir is not a directory; not updating font directory data"
+    fi
+  done
+}
+
+remove_conffile_prepare () {
+  # syntax: remove_conffile_prepare filename official_md5sum ...
+  #
+  # Check a conffile "filename" against a list of canonical MD5 checksums.
+  # If the file's current MD5 checksum matches one of the "official_md5sum"
+  # operands provided, then prepare the conffile for removal from the system.
+  # We defer actual deletion until the package is configured so that we can
+  # roll this operation back if package installation fails.
+  #
+  # Call this function from a preinst script in the event $1 is "upgrade" or
+  # "install" and verify $2 to ensure the package is being upgraded from a
+  # version (or installed over a version removed-but-not-purged) prior to the
+  # one in which the conffile was obsoleted.
+
+  local conffile current_checksum
+
+  # validate arguments
+  if [ $# -lt 2 ]; then
+    usage_error "remove_conffile_prepare() called with wrong number of" \
+                "arguments; expected at least 2, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  conffile="$1"
+  shift
+
+  # does the conffile even exist?
+  if [ -e "$conffile" ]; then
+    # calculate its checksum
+    current_checksum=$(md5sum < "$conffile" | sed 's/[[:space:]].*//')
+    # compare it to each supplied checksum
+    while [ -n "$1" ]; do
+      if [ "$current_checksum" = "$1" ]; then
+        # we found a match; move the confffile and stop looking
+        observe "preparing obsolete conffile $conffile for removal"
+        mv "$conffile" "$conffile.$THIS_PACKAGE-tmp"
+        break
+      fi
+      shift
+    done
+  fi
+}
+
+remove_conffile_lookup () {
+  # syntax: remove_conffile_lookup package filename
+  #
+  # Lookup the md5sum of a conffile in dpkg's database, and prepare for removal
+  # if it matches the actual file's md5sum.
+  #
+  # Call this function when you would call remove_conffile_prepare but only
+  # want to check against dpkg's status database instead of known checksums.
+
+  local package conffile old_md5sum
+
+  # validate arguments
+  if [ $# -ne 2 ]; then
+    usage_error "remove_conffile_lookup() called with wrong number of" \
+                "arguments; expected 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  package="$1"
+  conffile="$2"
+
+  if ! [ -e "$conffile" ]; then
+    return
+  fi
+  old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$package" | \
+    awk '{ if (match($0, "^ '"$conffile"' ")) print $2}')"
+  if [ -n "$old_md5sum" ]; then
+    remove_conffile_prepare "$conffile" "$old_md5sum"
+  fi
+}
+
+remove_conffile_commit () {
+  # syntax: remove_conffile_commit filename
+  #
+  # Complete the removal of a conffile "filename" that has become obsolete.
+  #
+  # Call this function from a postinst script after having used
+  # remove_conffile_prepare() in the preinst.
+
+  local conffile
+
+  # validate arguments
+  if [ $# -ne 1 ]; then
+    usage_error "remove_conffile_commit() called with wrong number of" \
+                "arguments; expected 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  conffile="$1"
+
+  # if the temporary file created by remove_conffile_prepare() exists, remove it
+  if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
+    observe "committing removal of obsolete conffile $conffile"
+    rm "$conffile.$THIS_PACKAGE-tmp"
+  fi
+}
+
+remove_conffile_rollback () {
+  # syntax: remove_conffile_rollback filename
+  #
+  # Roll back the removal of a conffile "filename".
+  #
+  # Call this function from a postrm script in the event $1 is "abort-upgrade"
+  # or "abort-install" is  after having used remove_conffile_prepare() in the
+  # preinst.
+
+  local conffile
+
+  # validate arguments
+  if [ $# -ne 1 ]; then
+    usage_error "remove_conffile_rollback() called with wrong number of" \
+                "arguments; expected 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  conffile="$1"
+
+  # if the temporary file created by remove_conffile_prepare() exists, move it
+  # back
+  if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
+    observe "rolling back removal of obsolete conffile $conffile"
+    mv "$conffile.$THIS_PACKAGE-tmp" "$conffile"
+  fi
+}
+
+replace_conffile_with_symlink_prepare () {
+  # syntax: replace_conffile_with_symlink_prepare oldfilename newfilename \
+  # official_md5sum ...
+  #
+  # Check a conffile "oldfilename" against a list of canonical MD5 checksums.
+  # If the file's current MD5 checksum matches one of the "official_md5sum"
+  # operands provided, then prepare the conffile for removal from the system.
+  # We defer actual deletion until the package is configured so that we can
+  # roll this operation back if package installation fails. Otherwise copy it
+  # to newfilename and let dpkg handle it through conffiles mechanism.
+  #
+  # Call this function from a preinst script in the event $1 is "upgrade" or
+  # "install" and verify $2 to ensure the package is being upgraded from a
+  # version (or installed over a version removed-but-not-purged) prior to the
+  # one in which the conffile was obsoleted.
+
+  local conffile current_checksum
+
+  # validate arguments
+  if [ $# -lt 3 ]; then
+    usage_error "replace_conffile_with_symlink_prepare() called with wrong" \
+                " number of arguments; expected at least 3, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  oldconffile="$1"
+  shift
+  newconffile="$1"
+  shift
+
+  remove_conffile_prepare "$_oldconffile" "$@"
+  # If $oldconffile still exists, then md5sums didn't match.
+  # Copy it to new one.
+  if [ -f "$oldconffile" ]; then
+    cp "$oldconffile" "$newconffile"
+  fi
+
+}
+
+replace_conffile_with_symlink_commit () {
+  # syntax: replace_conffile_with_symlink_commit oldfilename
+  #
+  # Complete the removal of a conffile "oldfilename" that has been
+  # replaced by a symlink.
+  #
+  # Call this function from a postinst script after having used
+  # replace_conffile_with_symlink_prepare() in the preinst.
+
+  local conffile
+
+  # validate arguments
+  if [ $# -ne 1 ]; then
+    usage_error "replace_conffile_with_symlink_commit() called with wrong" \
+                "number of arguments; expected 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  conffile="$1"
+
+  remove_conffile_commit "$conffile"
+}
+
+replace_conffile_with_symlink_rollback () {
+  # syntax: replace_conffile_with_symlink_rollback oldfilename newfilename
+  #
+  # Roll back the replacing of a conffile "oldfilename" with symlink to
+  # "newfilename".
+  #
+  # Call this function from a postrm script in the event $1 is "abort-upgrade"
+  # or "abort-install" and verify $2 to ensure the package failed to upgrade
+  # from a version (or install over a version removed-but-not-purged) prior
+  # to the one in which the conffile was obsoleted.
+  # You should have  used replace_conffile_with_symlink_prepare() in the
+  # preinst.
+
+  local conffile
+
+  # validate arguments
+  if [ $# -ne 2 ]; then
+    usage_error "replace_conffile_with_symlink_rollback() called with wrong" \
+                "number of arguments; expected 2, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  oldconffile="$1"
+  newconffile="$2"
+
+  remove_conffile_rollback "$_oldconffile"
+  if [ -f "$newconffile" ]; then
+    rm "$newconffile"
+  fi
+}
+
+run () {
+  # syntax: run command [ argument ... ]
+  #
+  # Run specified command with optional arguments and report its exit status.
+  # Useful for commands whose exit status may be nonzero, but still acceptable,
+  # or commands whose failure is not fatal to us.
+  #
+  # NOTE: Do *not* use this function with db_get or db_metaget commands; in
+  # those cases the return value of the debconf command *must* be checked
+  # before the string returned by debconf is used for anything.
+
+  local retval
+
+  # validate arguments
+  if [ $# -lt 1 ]; then
+    usage_error "run() called with wrong number of arguments; expected at" \
+                "least 1, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  "$@" || retval=$?
+
+  if [ ${retval:-0} -ne 0 ]; then
+    observe "command \"$*\" exited with status $retval"
+  fi
+}
+
+make_symlink_sane () {
+  # syntax: make_symlink_sane symlink target
+  #
+  # Ensure that the symbolic link symlink exists, and points to target.
+  #
+  # If symlink does not exist, create it and point it at target.
+  #
+  # If symlink exists but is not a symbolic link, back it up.
+  #
+  # If symlink exists, is a symbolic link, but points to the wrong location, fix
+  # it.
+  #
+  # If symlink exists, is a symbolic link, and already points to target, do
+  # nothing.
+  #
+  # This function wouldn't be needed if ln had an -I, --idempotent option.
+
+  # Validate arguments.
+  if [ $# -ne 2 ]; then
+    usage_error "make_symlink_sane() called with wrong number of arguments;" \
+      "expected 2, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  # We could just use the positional parameters as-is, but that makes things
+  # harder to follow.
+  local symlink target
+
+  symlink="$1"
+  target="$2"
+
+  if [ -L "$symlink" ] && [ "$(readlink "$symlink")" = "$target" ]; then
+      observe "link from $symlink to $target already exists"
+  else
+    observe "creating symbolic link from $symlink to $target"
+    mkdir -p "${target%/*}" "${symlink%/*}"
+    ln -s -b -S ".dpkg-old" "$target" "$symlink"
+  fi
+}
+
+migrate_dir_to_symlink () {
+  # syntax: migrate_dir_to_symlink old_location new_location
+  #
+  # Per Debian Policy section 6.5.4, "A directory will never be replaced by a
+  # symbolic link to a directory or vice versa; instead, the existing state
+  # (symlink or not) will be left alone and dpkg will follow the symlink if
+  # there is one."
+  #
+  # We have to do it ourselves.
+  #
+  # This function moves the contents of old_location, a directory, into
+  # new_location, a directory, then makes old_location a symbolic link to
+  # new_location.
+  #
+  # old_location need not exist, but if it does, it must be a directory (or a
+  # symlink to a directory).  If it is not, it is backed up.  If new_location
+  # exists already and is not a directory, it is backed up.
+  #
+  # This function should be called from a package's preinst so that other
+  # packages unpacked after this one --- but before this package's postinst runs
+  # --- are unpacked into new_location even if their payloads contain
+  # old_location filespecs.
+
+  # Validate arguments.
+  if [ $# -ne 2 ]; then
+    usage_error "migrate_dir_to_symlink() called with wrong number of"
+                "arguments; expected 2, got $#"
+    exit $SHELL_LIB_USAGE_ERROR
+  fi
+
+  # We could just use the positional parameters as-is, but that makes things
+  # harder to follow.
+  local new old
+
+  old="$1"
+  new="$2"
+
+  # Is old location a symlink?
+  if [ -L "$old" ]; then
+    # Does it already point to new location?
+    if [ "$(readlink "$old")" = "$new" ]; then
+      # Nothing to do; migration has already been done.
+      observe "migration of $old to $new already done"
+      return 0
+    else
+      # Back it up.
+      warn "backing up symbolic link $old as $old.dpkg-old"
+      mv -b "$old" "$old.dpkg-old"
+    fi
+  fi
+
+  # Does old location exist, but is not a directory?
+  if [ -e "$old" ] && ! [ -d "$old" ]; then
+      # Back it up.
+      warn "backing up non-directory $old as $old.dpkg-old"
+      mv -b "$old" "$old.dpkg-old"
+  fi
+
+  observe "migrating $old to $new"
+
+  # Is new location a symlink?
+  if [ -L "$new" ]; then
+    # Does it point the wrong way, i.e., back to where we're migrating from?
+    if [ "$(readlink "$new")" = "$old" ]; then
+      # Get rid of it.
+      observe "removing symbolic link $new which points to $old"
+      rm "$new"
+    else
+      # Back it up.
+      warn "backing up symbolic link $new as $new.dpkg-old"
+      mv -b "$new" "$new.dpkg-old"
+    fi
+  fi
+
+  # Does new location exist, but is not a directory?
+  if [ -e "$new" ] && ! [ -d "$new" ]; then
+    warn "backing up non-directory $new as $new.dpkg-old"
+    mv -b "$new" "$new.dpkg-old"
+  fi
+
+  # Create new directory if it does not yet exist.
+  if ! [ -e "$new" ]; then
+    observe "creating $new"
+    mkdir -p "$new"
+  fi
+
+  # Copy files in old location to new location.  Back up any filenames that
+  # already exist in the new location with the extension ".dpkg-old".
+  observe "copying files from $old to $new"
+  if ! (cd "$old" && cp -a -b -S ".dpkg-old" . "$new"); then
+    die "error(s) encountered while copying files from $old to $new"
+  fi
+
+  # Remove files at old location.
+  observe "removing $old"
+  rm -r "$old"
+
+  # Create symlink from old location to new location.
+  make_symlink_sane "$old" "$new"
+}
+
+# vim:set ai et sw=2 ts=2 tw=80:
+
+# GOBSTOPPER: The X Strike Force shell library ends here.
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100755 (executable)
index 0000000..12a3c6e
--- /dev/null
@@ -0,0 +1,64 @@
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. 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 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.
+#
+
+if ENABLE_DOCS
+doc_sources = SMlib.xml xsmp.xml
+dist_doc_DATA = $(doc_sources)
+
+if HAVE_XMLTO
+doc_DATA = $(doc_sources:.xml=.html)
+
+if HAVE_FOP
+doc_DATA += $(doc_sources:.xml=.ps) $(doc_sources:.xml=.pdf)
+endif
+
+if HAVE_XMLTO_TEXT
+doc_DATA += $(doc_sources:.xml=.txt)
+endif
+
+if HAVE_STYLESHEETS
+XMLTO_FLAGS = -m $(XSL_STYLESHEET)
+
+doc_DATA += xorg.css
+xorg.css: $(STYLESHEET_SRCDIR)/xorg.css
+       $(AM_V_GEN)cp -pf $(STYLESHEET_SRCDIR)/xorg.css $@
+endif
+
+CLEANFILES = $(doc_DATA)
+
+SUFFIXES = .xml .ps .pdf .txt .html
+
+.xml.txt:
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $<
+
+.xml.html:
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $<
+
+.xml.pdf:
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $<
+
+.xml.ps:
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop ps $<
+
+endif HAVE_XMLTO
+endif ENABLE_DOCS
diff --git a/doc/SMlib.xml b/doc/SMlib.xml
new file mode 100755 (executable)
index 0000000..fd84f1a
--- /dev/null
@@ -0,0 +1,3230 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+
+
+<!-- lifted from troff+ms+XMan by doclifter -->
+<book id="smlibms">
+
+<bookinfo>
+   <title>X Session Management Library</title>
+   <subtitle>X Consortium Standard</subtitle>
+   <releaseinfo>X Version 11, Release 6.4</releaseinfo>
+   <authorgroup>
+      <author>
+         <firstname>Ralph</firstname><surname>Mor</surname>
+      </author>
+   </authorgroup>
+   <corpname>X Consortium Standard</corpname>
+   <copyright>
+     <year>1993</year><year>1994</year>
+     <holder>X Consortium</holder>
+   </copyright>
+   <releaseinfo>Version 1.0</releaseinfo>
+   <affiliation><orgname>X Consortium</orgname></affiliation>
+   <productnumber>X Version 11, Release 7</productnumber>
+
+   <legalnotice>
+     <para>
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+&ldquo;Software&rdquo;), 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:
+     </para>
+
+     <para>
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+     </para>
+
+     <para>
+THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+AND NONINFRINGEMENT.  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+     </para>
+
+     <para>
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+     </para>
+
+     <para>
+X Window System is a trademark of The Open Group.
+     </para>
+   </legalnotice>
+
+</bookinfo>
+
+<chapter id="overview_of_session_management">
+  <title>Overview of Session Management</title>
+
+  <abstract>
+    <para>
+The purpose of the X Session Management Protocol (<acronym>XSMP</acronym>)
+is to provide a uniform mechanism for users to save and restore their
+sessions.  A <firstterm>session</firstterm> is a group of clients,
+each of which has a particular state.  The session is controlled by a
+network service called the <firstterm>session manager</firstterm>.
+The session manager issues commands to its clients on behalf of the
+user.  These commands may cause clients to save their state or to
+terminate.  It is expected that the client will save its state in such
+a way that the client can be restarted at a later time and resume its
+operation as if it had never been terminated.  A client's state might
+include information about the file currently being edited, the current
+position of the insertion point within the file, or the start of an
+uncommitted transaction.  The means by which clients are restarted is
+unspecified by this protocol.
+    </para>
+
+    <para>
+For purposes of this protocol, a <firstterm>client</firstterm> of the
+session manager is defined as a connection to the session manager.  A
+client is typically, though not necessarily, a process running an
+application program connected to an X display.  However, a client may
+be connected to more than one X display or not be connected to any X
+displays at all.
+    </para>
+  </abstract>
+</chapter>
+
+<chapter id='the_session_management_library'>
+  <title>The Session Management Library</title>
+  <abstract>
+    <para>
+The Session Management Library (<abbrev>SMlib</abbrev>) is a low-level
+"C" language interface to XSMP.  It is expected that higher level
+toolkits, such as Xt, will hide many of the details of session
+management from clients.  Higher level toolkits might also be developed
+for session managers to use, but no such effort is currently under way.
+    </para>
+  </abstract>
+
+  <para>
+    SMlib has two parts to it:
+    <itemizedlist mark='bullet'>
+      <listitem><para>One set of functions for clients that want to be part of a session</para></listitem>
+      <listitem><para>One set of functions for session managers to call</para></listitem>
+    </itemizedlist>
+  </para>
+
+  <para>
+Some applications will use both sets of functions and act as
+<firstterm>nested session managers</firstterm>.  That is, they will be
+both a session manager and a client of another session.  An example is
+a mail program that could start a text editor for editing the text of
+a mail message.  The mail program is part of a regular session and, at
+the same time, is also acting as a session manager to the editor.
+  </para>
+
+  <para>
+Clients initialize by connecting to the session manager and obtaining
+a <firstterm>client-ID</firstterm> that uniquely identifies them in
+the session.  The session manager maintains a list of properties for
+each client in the session.  These properties describe the client's
+environment and, most importantly, describe how the client can be
+restarted (via an <property>SmRestartCommand</property>). Clients are
+expected to save their state in such a way as to allow multiple
+instantiations of themselves to be managed independently.  For
+example, clients may use their client-ID as part of a filename in
+which to store the state for a particular instantiation.  The
+client-ID should be saved as part of the <property>SmRestartCommand</property>
+so that the client will retain the same ID after it is restarted.
+  </para>
+
+  <para>
+Once the client initializes itself with the session manager, it must
+be ready to respond to messages from the session manager.  For
+example, it might be asked to save its state or to terminate.  In the
+case of a shutdown, the session manager might give each client a
+chance to interact with the user and cancel the shutdown.
+  </para>
+</chapter>
+
+<chapter id='understanding_smlibs_dependence_on_ice'>
+  <title>Understanding SMlib's Dependence on ICE</title>
+
+  <para>
+The X Session Management Protocol is layered on top of the
+Inter-Client Exchange (<acronym>ICE</acronym>) Protocol.  The ICE
+protocol is designed to multiplex several protocols over a single
+connection.  As a result, working with SMlib requires a little
+knowledge of how the ICE library works.
+  </para>
+
+  <para>
+The ICE library utilizes callbacks to process messages.  When a client
+detects that there is data to read on an ICE connection, it should
+call the <function>IceProcessMessages</function> function.
+<function>IceProcessMessages</function> will read the message header
+and look at the major opcode in order to determine which protocol the
+message was intended for.  The appropriate protocol library will then
+be triggered to unpack the message and hand it off to the client via a
+callback.
+  </para>
+
+  <para>
+The main point to be aware of is that an application using SMlib must
+have some code that detects when there is data to read on an ICE
+connection.  This can be done via a <function>select</function> call
+on the file descriptor for the ICE connection, but more
+typically, <function>XtAppAddInput</function> will be used to register
+a callback that will invoke <function>IceProcessMessages</function>
+each time there is data to read on the ICE connection.
+  </para>
+
+  <para>
+To further complicate things, knowing which file descriptors to
+call <function>select</function> on requires an understanding of how
+ICE connections are created.  On the client side, a call must be made
+to <function>SmcOpenConnection</function> in order to open a connection
+with a session manager.  <function>SmcOpenConnection</function> will
+internally makea call into <function>IceOpenConnection</function>
+which will, in turn, determine if an ICE connection already exists
+between the client and session manager.  Most likely, a connection
+will not already exist and a new ICE connection will be created.  The
+main point to be aware of is that, on the client side, it is not
+obvious when ICE connections get created or destroyed, because
+connections are shared when possible.  To deal with this, the ICE
+library lets the application register watch procedures that will be
+invoked each time an ICE connection is opened or closed.  These watch
+procedures could be used to add or remove ICE file descriptors from
+the list of descriptors to call <function>select</function> on.
+  </para>
+
+  <para>
+On the session manager side, things work a bit differently.  The
+session manager has complete control over the creation of ICE
+connections.  The session manager has to first
+call <function>IceListenForConnections</function> in order to start
+listening for connections from clients.  Once a connection attempt is
+detected, <function>IceAcceptConnection</function> must be called, and
+the session manager can simply add the new ICE file descriptor to the
+list of descriptors to call <function>select</function> on.
+
+  </para>
+
+  <para>
+For further information on the library functions related to ICE connections,
+see the <citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+  </para>
+</chapter>
+
+<chapter id='header_files_and_library_name'>
+<title>Header Files and Library Name</title>
+
+  <para>
+Applications (both session managers and clients) should include the
+header file &lt;<filename class='headerfile'>X11/SM/SMlib.h</filename>&gt;.
+This header file defines all of the SMlib data structures and function
+prototypes.  <filename class='headerfile'>SMlib.h</filename> includes the
+header file &lt;<filename class='headerfile'>X11/SM/SM.h</filename>&gt;,
+which defines all of the SMlib constants.
+  </para>
+
+  <para>
+Because SMlib is dependent on ICE, applications should link against
+SMlib and ICElib by using
+<quote><option>-lSM</option> <option>-lICE</option></quote>.
+  </para>
+</chapter>
+
+<chapter id='session_management_client'>
+  <title>Session Management Client (<acronym>Smc</acronym>) Functions</title>
+
+  <para>
+    This section discusses how Session Management clients:
+    <itemizedlist mark='bullet'>
+      <listitem><para>Connect to the Session Manager</para></listitem>
+      <listitem><para>Close the connection</para></listitem>
+      <listitem><para>Modify callbacks</para></listitem>
+      <listitem><para>Set, delete, and retrieve Session Manager properties</para></listitem>
+      <listitem><para>Interact with the user</para></listitem>
+      <listitem><para>Request a &ldquo;Save Yourself&rdquo;</para></listitem>
+      <listitem><para>Request a &ldquo;Save Yourself Phase 2&rdquo;</para></listitem>
+      <listitem><para>Complete a &ldquo;Save Yourself&rdquo;</para></listitem>
+      <listitem><para>Use Smc informational functions</para></listitem>
+      <listitem><para>Handle Errors</para></listitem>
+    </itemizedlist>
+  </para>
+
+  <sect1 id='connecting_to_the_session_manager'>
+    <title>Connecting to the Session Manager</title>
+
+    <para>
+To open a connection with a session manager,
+use <function>SmcOpenConnection</function>
+    </para>
+
+    <funcsynopsis>
+      <funcprototype>
+       <funcdef>SmcConn <function>SmcOpenConnection</function></funcdef>
+       <paramdef>char *<parameter>network_ids_list</parameter></paramdef>
+       <paramdef>SmPointer <parameter>context</parameter></paramdef>
+       <paramdef>int <parameter>xsmp_major_rev</parameter></paramdef>
+       <paramdef>int <parameter>xsmp_minor_rev</parameter></paramdef>
+       <paramdef>unsigned long <parameter>mask</parameter></paramdef>
+       <paramdef>SmcCallbacks *<parameter>callbacks</parameter></paramdef>
+       <paramdef>char *<parameter>previous_id</parameter></paramdef>
+       <paramdef>char **<parameter>client_id_ret</parameter></paramdef>
+       <paramdef>int <parameter>error_length</parameter></paramdef>
+       <paramdef>char *<parameter>error_string_ret</parameter></paramdef>
+      </funcprototype>
+    </funcsynopsis>
+
+    <variablelist remap='IP'>
+      <varlistentry>
+       <term><parameter>network_ids_list</parameter></term>
+       <listitem><para>Specifies the network ID(s) of the session manager.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>context</parameter></term>
+       <listitem><para>
+A pointer to an opaque object or <constant>NULL</constant>.  Used to determine
+if an ICE connection can be shared
+(see <link linkend='context_sharing'>below</link>).
+     </para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>xsmp_major_rev</parameter></term>
+       <listitem><para>
+The highest major version of the XSMP the application supports.
+       </para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>xsmp_minor_rev</parameter></term>
+       <listitem><para>
+The highest minor version of the XSMP the application supports (for
+the specified <parameter>xsmp_major_rev</parameter>).
+       </para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>mask</parameter></term>
+       <listitem><para>A mask indicating which callbacks to register.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>callbacks</parameter></term>
+       <listitem><para>
+The callbacks to register.  These callbacks are used to respond to
+messages from the session manager.
+       </para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>previous_id</parameter></term>
+       <listitem><para>The client ID from the previous session.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>client_id_ret</parameter></term>
+       <listitem><para>The client ID for the current session is returned.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>error_length</parameter></term>
+       <listitem><para>Length of the <parameter>error_string_ret</parameter> argument passed in.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>error_string_ret</parameter></term>
+       <listitem><para>
+Returns a null-terminated error message, if any.
+The <parameter>error_string_ret</parameter> argument points to user supplied
+memory.  No more than <parameter>error_length</parameter> bytes are used.
+       </para></listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>
+The <parameter>network_ids_list</parameter> argument is a
+null-terminated string containing a list of network IDs for the session
+manager, separated by commas. If <parameter>network_ids_list</parameter>
+is <constant>NULL</constant>, the value of
+the <envar>SESSION_MANAGER</envar> environment variable will be used.
+Each network ID has the following format:
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='3' align='center'>
+    <colspec colname='c1'/>
+    <colspec colname='c2'/>
+    <colspec colname='c3'/>
+    <tbody>
+      <row>
+        <entry align='left'></entry>
+        <entry align='left'><literal>tcp/</literal><parameter>&lt;hostname&gt;</parameter><literal>:</literal><parameter>&lt;portnumber&gt;</parameter></entry>
+        <entry align='left'>or</entry>
+      </row>
+      <row>
+        <entry align='left'></entry>
+        <entry align='left'><literal>decnet/</literal><parameter>&lt;hostname&gt;</parameter><literal>::</literal><parameter>&lt;objname&gt;</parameter></entry>
+        <entry align='left'>or</entry>
+      </row>
+      <row>
+        <entry align='left'></entry>
+        <entry align='left'><literal>local/</literal><parameter>&lt;hostname&gt;</parameter><literal>:</literal><parameter>&lt;path&gt;</parameter></entry>
+        <entry align='left'></entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+    </para>
+
+    <para>
+An attempt will be made to use the first network ID.  If that fails,
+an attempt will be made using the second network ID, and so on.
+    </para>
+
+    <para>
+After the connection is established, <function>SmcOpenConnection</function>
+registers the client with the session manager.  If the client is being
+restarted from a previous session, <parameter>previous_id</parameter>
+should contain a null terminated string representing the client ID from the
+previous session.  If the client is first joining the session,
+<parameter>previous_id</parameter> should be set to <constant>NULL</constant>.
+If <parameter>previous_id</parameter> is specified but is determined
+to be invalid by the session manager, SMlib will re-register the
+client with <parameter>previous_id</parameter> set to <constant>NULL</constant>.
+    </para>
+
+    <para>
+If <function>SmcOpenConnection</function> succeeds, it returns an
+opaque connection pointer of type <function>SmcConn</function> and the
+<parameter>client_id_ret</parameter> argument contains the client ID to be
+used for this session.  The <parameter>client_id_ret</parameter> should be
+freed with a call to <function>free</function> when no longer needed.  On
+failure, <function>SmcOpenConnection</function> returns
+<constant>NULL</constant>, and the reason for failure is returned in
+<parameter>error_string_ret</parameter>.
+    </para>
+
+    <para>
+Note that SMlib uses the ICE protocol to establish a connection with
+the session manager.  If an ICE connection already exists between the
+client and session manager, it might be possible for the same ICE
+connection to be used for session management.
+    </para>
+
+    <para id='context_sharing'>
+The context argument indicates how willing the client is to share the
+ICE connection with other protocols.  If context is <constant>NULL</constant>,
+then the caller is always willing to share the connection.  If context is not
+<constant>NULL</constant>, then the caller is not willing to use a previously
+opened ICE connection that has a different non-<constant>NULL</constant>
+context associated with it.
+    </para>
+
+    <para>
+As previously discussed
+(<link linkend='understanding_smlibs_dependence_on_ice'>section 3,
+&ldquo;Understanding SMlib's Dependence on ICE&rdquo;</link>), the
+client will have to keep track of when ICE connections are created or
+destroyed (using <function>IceAddConnectionWatch</function>
+and <function>IceRemoveConnectionWatch</function> and will have to
+call <function>IceProcessMessages</function> each time
+a <function>select</function> shows that there is data to read on an
+ICE connection.  For further information, see the
+<citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+    </para>
+
+    <para>
+The callbacks argument contains a set of callbacks used to respond to
+session manager events.  The mask argument specifies which callbacks
+are set.  All of the callbacks specified in this version of SMlib are
+mandatory.  The mask argument is necessary in order to maintain
+backwards compatibility in future versions of the library.
+    </para>
+
+    <para>
+The following values may be ORed together to obtain a
+<parameter>mask</parameter> value:
+
+      <simplelist type='vert'>
+       <member><constant>SmcSaveYourselfProcMask</constant></member>
+       <member><constant>SmcDieProcMask</constant></member>
+       <member><constant>SmcSaveCompleteProcMask</constant></member>
+       <member><constant>SmcShutdownCancelledProcMask</constant></member>
+      </simplelist>
+    </para>
+
+    <para>
+For each callback, the client can register a pointer to client data.
+When SMlib invokes the callback, it will pass the client data pointer.
+    </para>
+
+<!-- .ne 4  IGNORED -->
+
+<synopsis>
+typedef struct {
+
+       struct {
+               SmcSaveYourselfProc callback;
+               SmPointer client_data;
+       } save_yourself;
+
+       struct {
+               SmcDieProc callback;
+               SmPointer client_data;
+       } die;
+
+       struct {
+               SmcSaveCompleteProc callback;
+               SmPointer client_data;
+       } save_complete;
+
+       struct {
+               SmcShutdownCancelledProc callback;
+               SmPointer client_data;
+       } shutdown_cancelled;
+
+} SmcCallbacks;
+</synopsis>
+
+    <sect2 id='the_save_yourself_callback'>
+      <title>The Save Yourself Callback</title>
+
+      <para>
+The Save Yourself callback is of type <function>SmcSaveYourselfProc</function>
+      </para>
+
+<funcsynopsis>
+<funcprototype>
+  <funcdef>typedef void (*<function>SaveYourselfProc</function>)</funcdef>
+    <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+    <paramdef>SmcConn <parameter>client_data</parameter></paramdef>
+    <paramdef>int <parameter>save_type</parameter></paramdef>
+    <paramdef>Bool <parameter>shutdown</parameter></paramdef>
+    <paramdef>int <parameter>interact_style</parameter></paramdef>
+    <paramdef>Bool <parameter>fast</parameter></paramdef>
+</funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>Client data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>save_type</parameter></term>
+    <listitem><para>Specifies the type of information that should be saved.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>shut_down</parameter></term>
+    <listitem><para>Specifies if a shutdown is taking place.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>interact_style</parameter></term>
+    <listitem><para>The type of interaction allowed with the user.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>fast</parameter></term>
+    <listitem><para>if <symbol>True</symbol>, then client should save its state as quickly as possible.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+The session manager sends a &ldquo;Save Yourself&rdquo; message to a
+client either to checkpoint it or just before termination so that it
+can save its state.  The client responds with zero or more calls
+to <function>SmcSetProperties</function> to update the properties
+indicating how to restart the client.  When all the properties have
+been set, the client calls <function>SmcSaveYourselfDone</function>
+      </para>
+
+      <para>
+If <parameter>interact_style</parameter> is
+<constant>SmInteractStyleNone</constant> the
+client must not interact with the user while saving state.
+If <parameter>interact_style</parameter> is
+<constant>SmInteractStyleErrors</constant> the
+client may interact with the user only if an error condition arises.
+If <parameter>interact_style</parameter> is
+<constant>SmInteractStyleAny</constant> then the
+client may interact with the user for any purpose.  Because only one
+client can interact with the user at a time, the client must
+call <function>SmcInteractRequest</function> and wait for an
+&ldquo;Interact&rdquo; message from the session manager.  When the
+client is done interacting with the user, it
+calls <function>SmcInteractDone</function> The client may only
+call <function>SmcInteractRequest</function> after it receives a
+&ldquo;Save Yourself&rdquo; message and before it
+calls <function>SmcSaveYourselfDone</function>
+      </para>
+
+      <para>
+If <parameter>save_type</parameter> is <constant>SmSaveLocal</constant> the
+client must update the properties to reflect its current state.  Specifically,
+it should save enough information to restore the state as seen by the
+user of this client.  It should not affect the state as seen by other users.
+If <parameter>save_type</parameter> is <constant>SmSaveGlobal</constant>
+the user wants the client to commit all of its data to permanent, globally
+accessible storage.
+If <parameter>save_type</parameter> is <constant>SmSaveBoth</constant>
+the client should do both of these (it should first commit the data to
+permanent storage before updating its properties).
+      </para>
+
+      <para>
+Some examples are as follows:
+
+        <itemizedlist mark='bullet'>
+         <listitem><para>
+If a word processor were sent a &ldquo;Save Yourself&rdquo; with a
+type of <constant>SmSaveLocal</constant> it could create a temporary
+file that included the current contents of the file, the location of
+the cursor, and other aspects of the current editing session.  It
+would then update its <property>SmRestartCommand</property> property with
+enough information to find this temporary file.
+         </para></listitem>
+         <listitem><para>
+If a word processor were sent a &ldquo;Save Yourself&rdquo; with a
+type of <constant>SmSaveGlobal</constant> it would simply save the
+currently edited file.
+         </para></listitem>
+         <listitem><para>
+If a word processor were sent a &ldquo;Save Yourself&rdquo; with a
+type of <constant>SmSaveBoth</constant> it would first save the
+currently edited file.  It would then create a temporary file with
+information such as the current position of the cursor and what file
+is being edited.  Finally, it would update its
+<property>SmRestartCommand</property> property with enough information
+to find the temporary file.
+         </para></listitem>
+       </itemizedlist>
+      </para>
+
+      <para>
+The <parameter>shutdown</parameter> argument specifies whether the
+system is being shut down.
+The interaction is different depending on whether or not shutdown is
+set.  If not shutting down, the client should save its state and wait
+for a &ldquo;Save Complete&rdquo; message.  If shutting down, the
+client must save state and then prevent interaction until it receives
+either a &ldquo;Die&rdquo; or a &ldquo;Shutdown Cancelled.&rdquo;
+      </para>
+
+      <para>
+The <parameter>fast</parameter> argument specifies that the client
+should save its state as quickly as possible.  For example, if the
+session manager knows that power is about to fail, it would
+set <parameter>fast</parameter> to <constant>True</constant>.
+      </para>
+    </sect2>
+
+    <sect2 id='the_die_callback'>
+      <title>The Die Callback</title>
+
+      <para>
+The Die callback is of type <function>SmcDieProc</function>
+      </para>
+
+<funcsynopsis>
+<funcprototype>
+  <funcdef>typedef void (*<function>SmcDieProc</function>)</funcdef>
+    <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+    <paramdef>SmcConn <parameter>client_data</parameter></paramdef>
+</funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>Client data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+
+      <para>
+The session manager sends a &ldquo;Die&rdquo; message to a client when
+it wants it to die.  The client should respond by calling
+<function>SmcCloseConnection</function>.  A session manager that
+behaves properly will send a &ldquo;Save Yourself&rdquo; message
+before the &ldquo;Die&rdquo; message.
+      </para>
+    </sect2>
+
+    <sect2 id='the_save_complete_callback'>
+      <title>The Save Complete Callback</title>
+
+      <para>
+The Save Complete callback is of type <function>SmcSaveCompleteProc</function>
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmcSaveCompleteProc</function>)</funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>Client data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+</variablelist>
+    </sect2>
+
+
+    <sect2 id='the_shutdown_cancelled_callback'>
+      <title>The Shutdown Cancelled Callback</title>
+
+      <para>
+The Shutdown Cancelled callback is of type
+<function>SmcShutdownCancelledProc</function>
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmcShutdownCancelledProc</function>)</funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>Client data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+The session manager sends a &ldquo;Shutdown Cancelled&rdquo; message
+when the user cancelled the shutdown during an interaction
+(see <link linkend='interacting_with_the_user'>section 5.5,
+&ldquo;Interacting With the User&rdquo;</link>).  The client can now
+continue as if the shutdown had never happened.  If the client has not
+called <function>SmcSaveYourselfDone</function> yet, it can either
+abort the save and then call <function>SmcSaveYourselfDone</function>
+with the success argument set to <constant>False</constant> or it can
+continue with the save and then call <function>SmcSaveYourselfDone</function>
+with the <parameter>success</parameter> argument set to reflect the outcome
+of the save.
+      </para>
+    </sect2>
+  </sect1>
+
+  <sect1 id='closing_the_connection'><title>Closing the Connection</title>
+
+    <para>
+To close a connection with a session manager,
+use <function>SmcCloseConnection</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>SmcCloseStatus <function>SmcCloseConnection</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>int <parameter>count</parameter></paramdef>
+      <paramdef>char **<parameter>reason_msgs</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>count</parameter></term>
+    <listitem><para>The number of reasons for closing the connection.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>reason_msgs</parameter></term>
+    <listitem><para>The reasons for closing the connection.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The <parameter>reason_msgs</parameter> argument will most likely be
+<constant>NULL</constant> if resignation is expected by the client.
+Otherwise, it contains a list of null-terminated Compound Text strings
+representing the reason for termination.  The session manager should
+display these reason messages to the user.
+    </para>
+
+    <para>
+Note that SMlib used the ICE protocol to establish a connection with
+the session manager, and various protocols other than session
+management may be active on the ICE connection.
+When <function>SmcCloseConnection</function> is called, the ICE
+connection will be closed only if all protocols have been shutdown on
+the connection.  Check the ICElib standard
+for <function>IceAddConnectionWatch</function>
+and <function>IceRemoveConnectionWatch</function> to learn how to set
+up a callback to be invoked each time an ICE connection is opened or
+closed.  Typically this callback adds/removes the ICE file descriptor
+from the list of active descriptors to call <function>select</function> on
+(or calls <function>XtAppAddInput</function> or
+<function>XtRemoveInput</function>).
+    </para>
+
+
+    <para>
+<function>SmcCloseConnection</function> returns one of the following values:
+
+      <itemizedlist mark='bullet'>
+       <listitem><para>
+<constant>SmcClosedNow</constant> - the ICE connection was closed at
+this time, the watch procedures were invoked, and the connection was freed.
+       </para></listitem>
+       <listitem><para>
+<constant>SmcClosedASAP</constant> - an IO error had occurred on the
+connection, but <function>SmcCloseConnection</function> is being
+called within a nested <function>IceProcessMessages</function> The
+watch procedures have been invoked at this time, but the connection
+will be freed as soon as possible (when the nesting level reaches zero
+and <function>IceProcessMessages</function> returns a status
+of <function>IceProcessMessagesConnectionClosed</function>
+       </para> </listitem>
+       <listitem><para>
+<constant>SmcConnectionInUse</constant> - the connection was not closed at
+this time, because it is being used by other active protocols.
+       </para> </listitem>
+      </itemizedlist>
+    </para>
+  </sect1>
+
+
+  <sect1 id='modifying_callbacks'>
+    <title>Modifying Callbacks</title>
+
+    <para>
+To modify callbacks set up in <function>SmcOpenConnection</function>
+use <function>SmcModifyCallbacks</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmcModifyCallbacks</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>unsigned long <parameter>mask</parameter></paramdef>
+      <paramdef>SmcCallbacks *<parameter>callbacks</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>mask</parameter></term>
+    <listitem><para>A mask indicating which callbacks to modify.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>callbacks</parameter></term>
+    <listitem><para>The new callbacks.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+When specifying a value for the <parameter>mask</parameter> argument,
+the following values may be ORed together:
+
+      <simplelist type='vert'>
+       <member><constant>SmcSaveYourselfProcMask</constant></member>
+       <member><constant>SmcDieProcMask</constant></member>
+       <member><constant>SmcSaveCompleteProcMask</constant></member>
+       <member><constant>SmcShutdownCancelledProcMask</constant></member>
+      </simplelist>
+    </para>
+  </sect1>
+
+  <sect1 id='setting_deleting_and_retrieving_session_management_properties'>
+    <title>Setting, Deleting, and Retrieving Session Management Properties</title>
+
+    <para>
+To set session management properties for this client,
+use <function>SmcSetProperties</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmcSetProperties</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>int <parameter>num_props</parameter></paramdef>
+      <paramdef>SmProp **<parameter>props</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>num_props</parameter></term>
+    <listitem><para>The number of properties.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>props</parameter></term>
+    <listitem><para>The list of properties to set.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+
+    <para>
+The properties are specified as an array of property pointers.
+Previously set property values may be over-written using
+the <function>SmcSetProperties</function> function.  Note that the
+session manager is not expected to restore property values when the
+session is restarted.  Because of this, clients should not try to use
+the session manager as a database for storing application specific state.
+    </para>
+
+    <para>
+For a description of session management properties and
+the <structname>SmProp</structname> structure,
+see <link linkend='session_management_properties'>section 7,
+&ldquo;Session Management Properties.&rdquo;</link>
+    </para>
+
+
+    <para>
+To delete properties previously set by the client,
+use <function>SmcDeleteProperties</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmcDeleteProperties</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>int <parameter>num_props</parameter></paramdef>
+      <paramdef>char **<parameter>prop_names</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>num_props</parameter></term>
+    <listitem><para>The number of properties.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>prop_names</parameter></term>
+    <listitem><para>The list of properties to set.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+To get properties previously stored by the client,
+use <function>SmcGetProperties</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>Status <function>SmcGetProperties</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>SmcPropReplyProc <parameter>prop_reply_proc</parameter></paramdef>
+      <paramdef>SmPointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>prop_reply_proc</parameter></term>
+    <listitem><para>The callback to be invoked when the properties reply comes back.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>This pointer to client data will be passed to the <function>SmcPropReplyProc</function> callback.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The return value of <function>SmcGetProperties</function> is zero for
+failure and a positive value for success.
+    </para>
+
+    <para>
+Note that the library does not block until the properties reply comes
+back.  Rather, a callback of type <function>SmcPropReplyProc</function>
+is invoked when the data is ready.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmcPropReplyProc</function>)</funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>client_data</parameter></paramdef>
+      <paramdef>int <parameter>num_props</parameter></paramdef>
+      <paramdef>SmProp **<parameter>props</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>This pointer to client data will be passed to the <function>SmcPropReplyProc</function> callback.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>num_props</parameter></term>
+    <listitem><para>The number of properties returned.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>props</parameter></term>
+    <listitem><para>The list of properties returned.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+To free each property, use <function>SmFreeProperty</function>
+(see <link linkend='freeing_data'>section 8, &ldquo;Freeing
+Data&rdquo;</link>).  To free the actual array of pointers,
+use <function>free</function>
+    </para>
+  </sect1>
+
+  <sect1 id='interacting_with_the_user'>
+    <title>Interacting With the User</title>
+
+    <para>
+After receiving a &ldquo;Save Yourself&rdquo; message with an
+<parameter>interact_style</parameter> of
+<constant>SmInteractStyleErrors</constant>
+or <constant>SmInteractStyleAny</constant> the client may choose to
+interact with the user.  Because only one client can interact with the
+user at a time, the client must call <function>SmcInteractRequest</function>
+and wait for an &ldquo;Interact&rdquo; message from the session manager.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>Status <function>SmcInteractRequest</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>int <parameter>dialog_type</parameter></paramdef>
+      <paramdef>SmcInteractProc <parameter>interact_proc</parameter></paramdef>
+      <paramdef>SmPointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>dialog_type</parameter></term>
+    <listitem><para>The type of dialog the client wishes to present to the user.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>interact_proc</parameter></term>
+    <listitem><para>The callback to be invoked when the &ldquo;Interact&rdquo; message arrives from the session manager.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>
+This pointer to client data will be passed to
+the <function>SmcInteractProc</function> callback when the
+&ldquo;Interact&rdquo; message arrives.
+    </para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The return value of <function>SmcInteractRequest</function> is zero
+for failure and a positive value for success.
+    </para>
+
+    <para>
+The <parameter>dialog_type</parameter> argument specifies
+either <constant>SmDialogError</constant> indicating that the client
+wants to start an error dialog, or <constant>SmDialogNormal</constant>
+meaning that the client wishes to start a nonerror dialog.
+    </para>
+
+    <para>
+Note that if a shutdown is in progress, the user may have the option
+of cancelling the shutdown.  If the shutdown is cancelled, the clients
+that have not interacted yet with the user will receive a
+&ldquo;Shutdown Cancelled&rdquo; message instead of the
+&ldquo;Interact&rdquo; message.
+    </para>
+
+    <para>
+The <function>SmcInteractProc</function> callback will be invoked when
+the &ldquo;Interact&rdquo; message arrives from the session manager.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmcInteractProc</function>)</funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>Client data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+After interacting with the user (in response to an &ldquo;Interact&rdquo;
+message), you should call <function>SmcInteractDone</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmcInteractDone</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>Bool <parameter>cancel_shutdown</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>cancel_shutdown</parameter></term>
+    <listitem><para>If <constant>True</constant>, indicates that the user requests that the entire shutdown be cancelled.</para></listitem>
+  </varlistentry>
+</variablelist>
+    <para>
+The <parameter>cancel_shutdown</parameter> argument may only be
+<constant>True</constant> if the corresponding &ldquo;Save Yourself&rdquo;
+specified <constant>True</constant> for shutdown
+and <constant>SmInteractStyleErrors</constant>
+or <constant>SmInteractStyleAny</constant> for
+the <parameter>interact_style</parameter>.
+    </para>
+  </sect1>
+
+  <sect1 id='requesting_a_save_yourself'>
+    <title>Requesting a Save Yourself</title>
+
+    <para>
+To request a checkpoint from the session manager,
+use <function>SmcRequestSaveYourself</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmcRequestSaveYourself</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>int <parameter>save_type</parameter></paramdef>
+      <paramdef>Bool <parameter>shutdown</parameter></paramdef>
+      <paramdef>int <parameter>interact_style</parameter></paramdef>
+      <paramdef>Bool <parameter>fast</parameter></paramdef>
+      <paramdef>Bool <parameter>global</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>save_type</parameter></term>
+    <listitem><para>Specifies the type of information that should be saved.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>shutdown</parameter></term>
+    <listitem><para>Specifies if a shutdown is taking place.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>interact_style</parameter></term>
+    <listitem><para>The type of interaction allowed with the user.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>fast</parameter></term>
+    <listitem><para>If <constant>True</constant> the client should save its state as quickly as possible.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>global</parameter></term>
+    <listitem><para>Controls who gets the &ldquo;Save Yourself.&rdquo;</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The <parameter>save_type</parameter>, <parameter>shutdown</parameter>,
+<parameter>interact_style</parameter>, and <parameter>fast</parameter>
+arguments are discussed in more detail in
+<link linkend='the_save_yourself_callback'>section 5.1.1,
+&ldquo;The Save Yourself Callback.&rdquo;</link>
+    </para>
+
+    <para>
+If <parameter>global</parameter> is set to <constant>True</constant> then
+the resulting &ldquo;Save Yourself&rdquo; should be sent to all clients in the
+session.  For example, a vendor of a Uninterruptible Power Supply
+(<acronym>UPS</acronym>) might include a Session Management client
+that would monitor the status of the UPS and generate a fast shutdown
+if the power is about to be lost.
+    </para>
+
+    <para>
+If global is set to <constant>False</constant> then the &ldquo;Save
+Yourself&rdquo; should only be sent to the client that requested it.
+    </para>
+  </sect1>
+
+  <sect1 id='requesting_a_save_yourself_phase_2'>
+    <title>Requesting a Save Yourself Phase 2</title>
+
+    <para>
+In response to a &ldquo;Save Yourself&rdquo;, the client may request to be
+informed when all the other clients are quiescent so that it can save their
+state.  To do so, use <function>SmcRequestSaveYourselfPhase2</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>Status <function>SmcRequestSaveYourselfPhase2</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>SmcSaveYourselfPhase2Proc <parameter>save_yourself_phase2_proc</parameter></paramdef>
+      <paramdef>SmPointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>save_type_phase2_proc</parameter></term>
+    <listitem><para>The callback to be invoked when the &ldquo;Save Yourself Phase 2&rdquo; message arrives from the session manager.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>This pointer to client data will be passed to the <function>SmcSaveYourselfPhase2Proc</function> callback when the &ldquo;Save Yourself Phase 2&rdquo; message arrives.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The return value of <function>SmcRequestSaveYourselfPhase2</function>
+is zero for failure and a positive value for success.
+    </para>
+
+    <para>
+This request is needed by clients that manage other clients (for
+example, window managers, workspace managers, and so on).  The manager
+must make sure that all of the clients that are being managed are in
+an idle state so that their state can be saved.
+    </para>
+  </sect1>
+
+  <sect1 id='completing_a_save_yourself'>
+    <title>Completing a Save Yourself</title>
+
+    <para>
+After saving state in response to a &ldquo;Save Yourself&rdquo;
+message, you should call <function>SmcSaveYourselfDone</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmcSaveYourselfDone</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>Bool <parameter>success</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>success</parameter></term>
+    <listitem><para>If <constant>True</constant> the &ldquo;Save Yourself&rdquo; operation was completed successfully.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+Before calling <function>SmcSaveYourselfDone</function> the client
+must have set each required property at least once since the client
+registered with the session manager.
+    </para>
+  </sect1>
+
+  <sect1 id='using_smc_informational_functions'>
+    <title>Using Smc Informational Functions</title>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>int <function>SmcProtocolVersion</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmcProtocolVersion</function> returns the major version of
+the session management protocol associated with this session.
+    </para>
+
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>int <function>SmcProtocolRevision</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmcProtocolRevision</function> returns the minor version of
+the session management protocol associated with this session.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>char *<function>SmcVendor</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmcVendor</function> returns a string that provides some
+identification of the owner of the session manager.  The string should
+be freed with a call to <function>free</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>char *<function>SmcRelease</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmcRelease</function> returns a string that provides the
+release number of the session manager.  The string should be freed
+with a call to <function>free</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>char *<function>SmcClientID</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmcClientID</function> returns a null-terminated string for
+the client ID associated with this connection.  This information was
+also returned in <function>SmcOpenConnection</function> (it is
+provided here for convenience).  Call <function>free</function> on
+this pointer when the client ID is no longer needed.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>IceConn <function>SmcGetIceConnection</function></funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmcGetIceConnection</function> returns the ICE connection
+object associated with this session management connection object.  The
+ICE connection object can be used to get some additional information
+about the connection.  Some of the more useful functions which can be
+used on the IceConn are <function>IceConnectionNumber</function>,
+<function>IceConnectionString</function>,
+<function>IceLastSentSequenceNumber</function>,
+<function>IceLastReceivedSequenceNumber</function>,
+and <function>IcePing</function>. For further information, see
+the <citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+    </para>
+  </sect1>
+
+  <sect1 id='error_handling'>
+    <title>Error Handling</title>
+
+    <para>
+If the client receives an unexpected protocol error from the session
+manager, an error handler is invoked by SMlib.  A default error
+handler exists that simply prints the error message
+to <varname>stderr</varname> and exits if the severity of the error
+is fatal.  The client can change this error handler by calling
+the <function>SmcSetErrorHandler</function> function.
+    </para>
+
+<funcsynopsis>
+  <funcprototype>
+      <funcdef>SmcErrorHandler <function>SmcSetErrorHandler</function></funcdef>
+      <paramdef>SmcErrorHandler <parameter>handler</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+The error handler.  You should pass <constant>NULL</constant> to
+restore the default handler.
+    </para>
+
+
+    <para>
+<function>SmcSetErrorHandler</function> returns the previous error handler.
+    </para>
+
+    <para>
+The <function>SmcErrorHandler</function> has the following type:
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmcErrorHandler</function>)</funcdef>
+      <paramdef>SmcConn <parameter>smc_conn</parameter></paramdef>
+      <paramdef>Bool <parameter>swap</parameter></paramdef>
+      <paramdef>int <parameter>offending_minor_opcode</parameter></paramdef>
+      <paramdef>unsigned long <parameter>offending_sequence_num</parameter></paramdef>
+      <paramdef>int <parameter>error_class</parameter></paramdef>
+      <paramdef>int <parameter>severity</parameter></paramdef>
+      <paramdef>IcePointer <parameter>values</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>smc_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+     <term><parameter>swap</parameter></term>
+     <listitem><para>A flag that indicates if the specified values need byte swapping.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+     <term><parameter>offending_minor_opcode</parameter></term>
+     <listitem><para>The minor opcode of the offending message.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+     <term><parameter>offending_sequence_num</parameter></term>
+     <listitem><para>The sequence number of the offending message.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+     <term><parameter>error_class</parameter></term>
+     <listitem><para>The error class of the offending message.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+     <term><parameter>severity</parameter></term>
+     <listitem><para><constant>IceCanContinue</constant>,
+        <constant>IceFatalToProtocol</constant>, or
+        <constant>IceFatalToConnection</constant>
+     </para></listitem>
+  </varlistentry>
+  <varlistentry>
+     <term><parameter>values</parameter></term>
+     <listitem><para>Any additional error values specific to the minor opcode and class.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+Note that this error handler is invoked for protocol related errors.
+To install an error handler to be invoked when an IO error occurs, use
+<function>IceSetIOErrorHandler</function> For further information, see
+the <citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+    </para>
+  </sect1>
+</chapter>
+
+<chapter id='session_management_server'>
+  <title>Session Management Server (<acronym>Sms</acronym>) Functions</title>
+
+  <para>
+This section discusses how Session Management servers:
+
+    <itemizedlist mark='bullet'>
+      <listitem><para>Initialize the library</para></listitem>
+      <listitem><para>Register the client</para></listitem>
+      <listitem><para>Send a &ldquo;Save Yourself&rdquo; message</para></listitem>
+      <listitem><para>Send a &ldquo;Save Yourself Phase 2&rdquo; message</para></listitem>
+      <listitem><para>Send an &ldquo;Interact&rdquo; message</para></listitem>
+      <listitem><para>Send a &ldquo;Save Complete&rdquo; message</para></listitem>
+      <listitem><para>Send a &ldquo;Die&rdquo; message</para></listitem>
+      <listitem><para>Cancel a shutdown</para></listitem>
+      <listitem><para>Return properties</para></listitem>
+      <listitem><para>Ping a client</para></listitem>
+      <listitem><para>Clean up after a client disconnects</para></listitem>
+      <listitem><para>Use Sms informational functions</para></listitem>
+      <listitem><para>Handle errors</para></listitem>
+    </itemizedlist>
+  </para>
+
+  <sect1 id='initializing_the_library'>
+    <title>Initializing the Library</title>
+
+    <para>
+<function>SmsInitialize</function> is the first SMlib function that
+should be called by a session manager.  It provides information about
+the session manager and registers a callback that will be invoked each
+time a new client connects to the session manager.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>Status <function>SmsInitialize</function></funcdef>
+      <paramdef>char *<parameter>vendor</parameter></paramdef>
+      <paramdef>char *<parameter>release</parameter></paramdef>
+      <paramdef>SmsNewClientProc <parameter>new_client_proc</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>IceHostBasedAuthProc <parameter>host_based_auth_proc</parameter></paramdef>
+      <paramdef>int <parameter>error_length</parameter></paramdef>
+      <paramdef>char *<parameter>error_string_ret</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>vendor</parameter></term>
+    <listitem><para>A string specifying the session manager vendor.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>release</parameter></term>
+    <listitem><para>A string specifying the session manager release number.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>new_client_proc</parameter></term>
+    <listitem><para>Callback to be invoked each time a new client connects to the session manager.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>When the <function>SmsNewClientProc</function> callback is invoked, this pointer to manager data will be passed.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>host_based_auth_proc</parameter></term>
+    <listitem><para>Host based authentication callback.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>error_length</parameter></term>
+    <listitem><para>Length of the <parameter>error_string_ret</parameter> argument passed in.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>error_string_ret</parameter></term>
+    <listitem><para>
+Returns a null-terminated error message, if any.
+The <parameter>error_string_ret</parameter> points to user supplied memory.
+No more than <parameter>error_length</parameter> bytes are used.
+    </para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+After the <function>SmsInitialize</function> function is called, the
+session manager should call the <function>IceListenForConnections</function>
+function to listen for new connections.  Afterwards, each time a
+client connects, the session manager should
+call <function>IceAcceptConnection</function>
+    </para>
+
+    <para>
+See <link linkend='authentication_of_clients'>section 9,
+&ldquo;Authentication of Clients,&rdquo;</link> for more details on
+authentication (including host based authentication).  Also see
+the <citetitle pubwork='article'>Inter-Client Exchange
+Library</citetitle> standard for further details on listening for and
+accepting ICE connections.
+    </para>
+
+    <para>
+Each time a new client connects to the session manager,
+the <function>SmsNewClientProc</function> callback is invoked.  The
+session manager obtains a new opaque connection object that it should
+use for all future interaction with the client.  At this time, the
+session manager must also register a set of callbacks to respond to
+the different messages that the client might send.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef Status (*<function>SmsNewClientProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>unsigned long *<parameter>mask_ret</parameter></paramdef>
+      <paramdef>SmsCallbacks *<parameter>callbacks_ret</parameter></paramdef>
+      <paramdef>char **<parameter>failure_reason_ret</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>A new opaque connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>mask_ret</parameter></term>
+    <listitem><para>On return, indicates which callbacks were set by the session manager.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>callbacks_ret</parameter></term>
+    <listitem><para>On return, contains the callbacks registered by the session manager.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>failure_reason_ret</parameter></term>
+    <listitem><para>Failure reason returned.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+If a failure occurs, the <function>SmsNewClientProc</function> should
+return a zero status as well as allocate and return a failure reason
+string in <parameter>failure_reason_ret</parameter>.
+SMlib will be responsible for freeing this memory.
+    </para>
+
+    <para>
+The session manager must register a set of callbacks to respond to
+client events.  The <parameter>mask_ret</parameter> argument specifies
+which callbacks are set.  All of the callbacks specified in this version of
+SMlib are mandatory.  The <parameter>mask_ret</parameter> argument is
+necessary in order to maintain backwards compatibility in future versions
+of the library.
+    </para>
+
+    <para>
+The following values may be ORed together to obtain a mask value:
+
+      <simplelist type='vert'>
+       <member><constant>SmsRegisterClientProcMask</constant></member>
+       <member><constant>SmsInteractRequestProcMask</constant></member>
+       <member><constant>SmsInteractDoneProcMask</constant></member>
+       <member><constant>SmsSaveYourselfRequestProcMask</constant></member>
+       <member><constant>SmsSaveYourselfP2RequestProcMask</constant></member>
+       <member><constant>SmsSaveYourselfDoneProcMask</constant></member>
+       <member><constant>SmsCloseConnectionProcMask</constant></member>
+       <member><constant>SmsSetPropertiesProcMask</constant></member>
+       <member><constant>SmsDeletePropertiesProcMask</constant></member>
+       <member><constant>SmsGetPropertiesProcMask</constant></member>
+      </simplelist>
+    </para>
+
+    <para>
+For each callback, the session manager can register a pointer to
+manager data specific to that callback.  This pointer will be passed
+to the callback when it is invoked by SMlib.
+    </para>
+
+<synopsis>
+typedef struct {
+       struct {
+               SmsRegisterClientProc callback;
+               SmPointer manager_data;
+       } register_client;
+
+       struct {
+               SmsInteractRequestProc callback;
+               SmPointer manager_data;
+       } interact_request;
+
+       struct {
+               SmsInteractDoneProc callback;
+               SmPointer manager_data;
+       } interact_done;
+
+       struct {
+               SmsSaveYourselfRequestProc callback;
+               SmPointer manager_data;
+       } save_yourself_request;
+
+       struct {
+               SmsSaveYourselfPhase2RequestProc callback;
+               SmPointer manager_data;
+       } save_yourself_phase2_request;
+
+       struct {
+               SmsSaveYourselfDoneProc callback;
+               SmPointer manager_data;
+       } save_yourself_done;
+
+       struct {
+               SmsCloseConnectionProc callback;
+               SmPointer manager_data;
+       } close_connection;
+
+       struct {
+               SmsSetPropertiesProc callback;
+               SmPointer manager_data;
+       } set_properties;
+
+       struct {
+               SmsDeletePropertiesProc callback;
+               SmPointer manager_data;
+       } delete_properties;
+
+       struct {
+               SmsGetPropertiesProc callback;
+               SmPointer manager_data;
+       } get_properties;
+
+} SmsCallbacks;
+</synopsis>
+
+    <sect2 id='the_register_client_callback'>
+      <title>The Register Client Callback</title>
+
+      <para>
+The Register Client callback is the first callback that will be
+invoked after the client connects to the session manager.  Its type
+is <function>SmsRegisterClientProc</function>
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef Status (*<function>SmsRegisterClientProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>char *<parameter>previous_id</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>previous_id</parameter></term>
+    <listitem><para>The client ID from the previous session.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+Before any further interaction takes place with the client, the client
+must be registered with the session manager.
+      </para>
+
+      <para>
+If the client is being restarted from a previous session,
+<parameter>previous_id</parameter> will contain a null-terminated string
+representing the client ID from the previous session.
+Call <function>free</function> on the <parameter>previous_id</parameter>
+pointer when it is no longer needed.  If the client is first joining the
+session, <parameter>previous_id</parameter> will be <constant>NULL</constant>.
+      </para>
+
+      <para>
+If <parameter>previous_id</parameter> is invalid, the session manager should
+not register the client at this time.  This callback should return a status
+of zero, which will cause an error message to be sent to the client.  The
+client should re-register with previous_id set to <constant>NULL</constant>.
+      </para>
+
+      <para>
+Otherwise, the session manager should register the client with a unique
+client ID by calling the <function>SmsRegisterClientReply</function>
+function (to be discussed shortly), and the
+<function>SmsRegisterClientProc</function> callback should return a
+status of one.
+      </para>
+    </sect2>
+
+    <sect2 id='the_interact_request_callback'>
+      <title>The Interact Request Callback</title>
+
+      <para>
+The Interact Request callback is of
+type <function>SmsInteractRequestProc</function>
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsInteractRequestProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>int <parameter>dialog_type</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>dialog_type</parameter></term>
+    <listitem><para>The type of dialog the client wishes to present to the user.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+When a client receives a &ldquo;Save Yourself&rdquo; message with an
+<parameter>interact_style</parameter> of
+<constant>SmInteractStyleErrors</constant>
+or <constant>SmInteractStyleAny</constant> the client may choose to
+interact with the user.  Because only one client can interact with the
+user at a time, the client must request to interact with the user.
+The session manager should keep a queue of all clients wishing to
+interact.  It should send an &ldquo;Interact&rdquo; message to one
+client at a time and wait for an &ldquo;Interact Done&rdquo; message
+before continuing with the next client.
+      </para>
+
+      <para>
+The <parameter>dialog_type</parameter> argument specifies
+either <constant>SmDialogError</constant> indicating that the client
+wants to start an error dialog, or <constant>SmDialogNormal</constant>
+meaning that the client wishes to start a nonerror dialog.
+      </para>
+
+      <para>
+If a shutdown is in progress, the user may have the option of
+cancelling the shutdown.  If the shutdown is cancelled (specified in
+the &ldquo;Interact Done&rdquo; message), the session manager should
+send a &ldquo;Shutdown Cancelled&rdquo; message to each client that
+requested to interact.
+      </para>
+    </sect2>
+
+    <sect2 id='the_interact_done_callback'>
+      <title>The Interact Done Callback</title>
+
+      <para>
+When the client is done interacting with the user,
+the <function>SmsInteractDoneProc</function> callback will be invoked.
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsInteractDoneProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>Bool <parameter>cancel_shutdown</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>cancel_shutdown</parameter></term>
+    <listitem><para>Specifies if the user requests that the entire shutdown be cancelled.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+Note that the shutdown can be cancelled only if the corresponding
+&ldquo;Save Yourself&rdquo; specified <constant>True</constant> for
+shutdown and <constant>SmInteractStyleErrors</constant>
+or <constant>SmInteractStyleAny</constant> for the
+<parameter>interact_style</parameter>.
+      </para>
+    </sect2>
+
+
+    <sect2 id='the_save_yourself_request_callback'>
+      <title>The Save Yourself Request Callback</title>
+
+      <para>
+The Save Yourself Request callback is of
+type <function>SmsSaveYourselfRequestProc</function>
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SaveYourselfRequestProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>int <parameter>save_type</parameter></paramdef>
+      <paramdef>Bool <parameter>shutdown</parameter></paramdef>
+      <paramdef>int <parameter>interact_style</parameter></paramdef>
+      <paramdef>Bool <parameter>fast</parameter></paramdef>
+      <paramdef>Bool <parameter>global</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>save_type</parameter></term>
+    <listitem><para>Specifies the type of information that should be saved.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>shutdown</parameter></term>
+    <listitem><para>Specifies if a shutdown is taking place.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>interact_style</parameter></term>
+    <listitem><para>The type of interaction allowed with the user.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>fast</parameter></term>
+    <listitem><para>If <constant>True</constant> the client should save its state as quickly as possible.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>global</parameter></term>
+    <listitem><para>Controls who gets the &ldquo;Save Yourself.&rdquo;</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+The Save Yourself Request prompts the session manager to initiate a
+checkpoint or shutdown.  For information on the
+<parameter>save_type</parameter>, <parameter>shutdown</parameter>,
+<parameter>interact_style</parameter>, and <parameter>fast</parameter>
+arguments, see <link linkend='sending_a_save_yourself_message'>section 6.3,
+&ldquo;Sending a Save Yourself Message.&rdquo;</link>
+      </para>
+
+      <para>
+If <parameter>global</parameter> is set to <constant>True</constant> then the
+resulting &ldquo;Save Yourself&rdquo; should be sent to all applications.
+If <parameter>global</parameter> is set to <constant>False</constant> then the
+&ldquo;Save Yourself&rdquo; should only be sent to the client that requested it.
+      </para>
+    </sect2>
+
+    <sect2 id='the_save_yourself_phase_2_request_callback'>
+      <title>The Save Yourself Phase 2 Request Callback</title>
+
+      <para>
+The Save Yourself Phase 2 Request callback is of
+type <function>SmsSaveYourselfPhase2RequestProc</function>
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsSaveYourselfPhase2RequestProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+This request is sent by clients that manage other clients (for
+example, window managers, workspace managers, and so on).  Such
+managers must make sure that all of the clients that are being managed
+are in an idle state so that their state can be saved.
+      </para>
+    </sect2>
+
+    <sect2 id='the_save_yourself_done_callback'>
+      <title>The Save Yourself Done Callback</title>
+
+      <para>
+When the client is done saving its state in response to a
+&ldquo;Save Yourself&rdquo; message,
+the <function>SmsSaveYourselfDoneProc</function> will be invoked.
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SaveYourselfDoneProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>Bool <parameter>success</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>success</parameter></term>
+    <listitem><para>If <constant>True</constant> the Save Yourself operation was completed successfully.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+Before the &ldquo;Save Yourself Done&rdquo; was sent, the client must
+have set each required property at least once since it registered with
+the session manager.
+      </para>
+    </sect2>
+
+    <sect2 id='the_connection_closed_callback'>
+      <title>The Connection Closed Callback</title>
+
+      <para>
+If the client properly terminates (that is, it
+calls <function>SmcCloseConnection</function>,
+the <function>SmsCloseConnectionProc</function> callback is invoked.
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsCloseConnectionProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>int <parameter>count</parameter></paramdef>
+      <paramdef>char **<parameter>reason_msgs</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+<varlistentry>
+  <term><parameter>manager_data</parameter></term>
+  <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>count</parameter></term>
+    <listitem><para>The number of reason messages.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>reason_msgs</parameter></term>
+    <listitem><para>The reasons for closing the connection.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+The <parameter>reason_msgs</parameter> argument will most likely
+be <constant>NULL</constant> and the <parameter>count</parameter>
+argument zero (0) if resignation is expected by the user.  Otherwise,
+it contains a list of null-terminated Compound Text strings
+representing the reason for termination.  The session manager should
+display these reason messages to the user.
+      </para>
+
+      <para>
+Call <function>SmFreeReasons</function> to free the reason messages.
+For further information, see
+<link linkend='freeing_data'>section 8, &ldquo;Freeing Data&rdquo;</link>
+      </para>
+    </sect2>
+
+    <sect2 id='the_set_properties_callback'>
+      <title>The Set Properties Callback</title>
+
+      <para>
+When the client sets session management properties,
+the <function>SmsSetPropertiesProc</function> callback will be invoked.
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsSetPropertiesProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>int <parameter>num_props</parameter></paramdef>
+      <paramdef>SmProp **<parameter>props</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>num_props</parameter></term>
+    <listitem><para>The number of properties.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>props</parameter></term>
+    <listitem><para>The list of properties to set.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+The properties are specified as an array of property pointers.  For a
+description of session management properties and
+the <structname>SmProp</structname> structure,
+see <link linkend='session_management_properties'>section 7,
+&ldquo;Session Management Properties.&rdquo;</link>
+      </para>
+
+      <para>
+Previously set property values may be over-written.  Some properties
+have predefined semantics.  The session manager is required to store
+nonpredefined properties.
+      </para>
+
+      <para>
+To free each property, use <function>SmFreeProperty</function>.
+For further information, see <link linkend='freeing_data'>section 8,
+&ldquo;Freeing Data&rdquo;</link> You should free the actual array of
+pointers with a call to <function>free</function>
+      </para>
+    </sect2>
+
+    <sect2 id='the_delete_properties_callback'>
+      <title>The Delete Properties Callback</title>
+
+      <para>
+When the client deletes session management properties,
+the <function>SmsDeletePropertiesProc</function> callback will be invoked.
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsDeletePropertiesProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+      <paramdef>int <parameter>num_props</parameter></paramdef>
+      <paramdef>char **<parameter>prop_names</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>num_props</parameter></term>
+    <listitem><para>The number of properties.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>prop_names</parameter></term>
+    <listitem><para>The list of properties to delete.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+The properties are specified as an array of strings.  For a
+description of session management properties and
+the <structname>SmProp</structname> structure,
+see <link linkend='session_management_properties'>section 7,
+&ldquo;Session Management Properties.&rdquo;</link>
+      </para>
+    </sect2>
+
+    <sect2 id='the_get_properties_callback'>
+      <title>The Get Properties Callback</title>
+
+      <para>
+The <function>SmsGetPropertiesProc</function> callback is invoked when
+the client wants to retrieve properties it set.
+      </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsGetPropertiesProc</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>SmPointer <parameter>manager_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>manager_data</parameter></term>
+    <listitem><para>Manager data specified when the callback was registered.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+      <para>
+The session manager should respond by
+calling <function>SmsReturnProperties</function>.
+All of the properties set for this client should be returned.
+      </para>
+    </sect2>
+  </sect1>
+
+  <sect1 id='registering_the_client'>
+    <title>Registering the Client</title>
+
+    <para>
+To register a client (in response to
+a <function>SmsRegisterClientProc</function> callback),
+use <function>SmsRegisterClientReply</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>Status <function>SmsRegisterClientReply</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>char *<parameter>client_id</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_id</parameter></term>
+    <listitem><para>A null-terminated string representing a unique client ID.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The return value of <function>SmsRegisterClientReply</function> is
+zero for failure and a positive value for success.  Failure will occur
+if SMlib can not allocate memory to hold a copy of the client ID for
+it's own internal needs.
+    </para>
+
+    <para>
+If a non-<constant>NULL</constant> <parameter>previous_id</parameter> was
+specified when the client registered itself, <parameter>client_id</parameter>
+should be identical to <parameter>previous_id</parameter>.
+    </para>
+
+    <para>
+Otherwise, <parameter>client_id</parameter> should be a unique ID freshly
+generated by the session manager.  In addition, the session manager should
+send a &ldquo;Save Yourself&rdquo; message with
+<parameter>type</parameter> = <constant>Local</constant>,
+<parameter>shutdown</parameter> = <constant>False</constant>,
+<parameter>interact-style</parameter> = <constant>None</constant>,
+and <parameter>fast</parameter> = <constant>False</constant>
+immediately after registering the client.
+    </para>
+
+    <para>
+Note that once a client ID has been assigned to the client, the client
+keeps this ID indefinitely.  If the client is terminated and
+restarted, it will be reassigned the same ID.  It is desirable to be
+able to pass client IDs around from machine to machine, from user to
+user, and from session manager to session manager, while retaining the
+identity of the client.  This, combined with the indefinite
+persistence of client IDs, means that client IDs need to be globally
+unique.
+    </para>
+
+    <para>
+You should call the <function>SmsGenerateClientID</function> function
+to generate a globally unique client ID.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>char *<function>SmsGenerateClientID</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+
+    <para>
+<constant>NULL</constant> will be returned if the ID could not be generated.
+Otherwise, the return value of the function is the client ID.
+It should be freed with a call to <function>free</function> when
+no longer needed.
+    </para>
+  </sect1>
+
+  <sect1 id='sending_a_save_yourself_message'>
+    <title>Sending a Save Yourself Message</title>
+
+    <para>
+To send a &ldquo;Save Yourself&rdquo; to a client,
+use <function>SmsSaveYourself</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsSaveYourself</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>int <parameter>save_type</parameter></paramdef>
+      <paramdef>Bool <parameter>shutdown</parameter></paramdef>
+      <paramdef>int <parameter>interact_style</parameter></paramdef>
+      <paramdef>Bool <parameter>fast</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>save_type</parameter></term>
+    <listitem><para>Specifies the type of information that should be saved.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>shutdown</parameter></term>
+    <listitem><para>Specifies if a shutdown is taking place.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>interact_style</parameter></term>
+    <listitem><para>The type of interaction allowed with the user.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>fast</parameter></term>
+    <listitem><para>If <constant>True</constant> the client should save its state as quickly as possible.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+
+    <para>
+The session manager sends a &ldquo;Save Yourself&rdquo; message to a
+client either to checkpoint it or just before termination so that it
+can save its state.  The client responds with zero or more &ldquo;Set
+Properties&rdquo; messages to update the properties indicating how to
+restart the client.  When all the properties have been set, the client
+sends a &ldquo;Save Yourself Done&rdquo; message.
+    </para>
+
+    <para>
+If <parameter>interact_style</parameter>
+is <constant>SmInteractStyleNone</constant> the
+client must not interact with the user while saving state.
+If <parameter>interact_style</parameter>
+is <constant>SmInteractStyleErrors</constant> the
+client may interact with the user only if an error condition arises.
+If <parameter>interact_style</parameter>
+is <constant>SmInteractStyleAny</constant> then the
+client may interact with the user for any purpose.  The client must
+send an &ldquo;Interact Request&rdquo; message and wait for an
+&ldquo;Interact&rdquo; message from the session manager before it can
+interact with the user.  When the client is done interacting with the
+user, it should send an &ldquo;Interact Done&rdquo; message.  The
+&ldquo;Interact Request&rdquo; message can be sent any time after a
+&ldquo;Save Yourself&rdquo; and before a &ldquo;Save Yourself
+Done.&rdquo;
+    </para>
+
+    <para>
+If <parameter>save_type</parameter> is <constant>SmSaveLocal</constant>
+the client must update the properties to reflect its current state.
+Specifically, it should save enough information to restore the state as
+seen by the user of this client.  It should not affect the state as seen
+by other users.
+If <parameter>save_type</parameter> is <constant>SmSaveGlobal</constant>
+the user wants the client to commit all of its data to permanent, globally
+accessible storage.
+If <parameter>save_type</parameter> is <constant>SmSaveBoth</constant>
+the client should do both of these (it should first commit the data to
+permanent storage before updating its properties).
+    </para>
+
+    <para>
+The <parameter>shutdown</parameter> argument specifies whether the session
+is being shut down.  The interaction is different depending on whether or not
+shutdown is set.  If not shutting down, then the client can save and
+resume normal operation.  If shutting down, the client must save and
+then must prevent interaction until it receives either a
+&ldquo;Die&rdquo; or a &ldquo;Shutdown Cancelled,&rdquo; because
+anything the user does after the save will be lost.
+    </para>
+
+    <para>
+The <parameter>fast</parameter> argument specifies that the client should
+save its state as quickly as possible.  For example, if the session manager
+knows that power is about to fail, it should set <parameter>fast</parameter>
+to <constant>True</constant>.
+    </para>
+  </sect1>
+
+  <sect1 id='sending_a_save_yourself_phase_2_message'>
+    <title>Sending a Save Yourself Phase 2 Message</title>
+
+    <para>
+In order to send a &ldquo;Save Yourself Phase 2&rdquo; message to a
+client, use <function>SmsSaveYourselfPhase2</function>
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsSaveYourselfPhase2</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The session manager sends this message to a client that has previously
+sent a &ldquo;Save Yourself Phase 2 Request&rdquo; message.  This
+message informs the client that all other clients are in a fixed state
+and this client can save state that is associated with other clients.
+    </para>
+  </sect1>
+
+  <sect1 id='sending_an_interact_message'>
+    <title>Sending an Interact Message</title>
+
+    <para>
+To send an &ldquo;Interact&rdquo; message to a client,
+use <function>SmsInteract</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsInteract</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The &ldquo;Interact&rdquo; message grants the client the privilege of
+interacting with the user.  When the client is done interacting with
+the user, it must send an &ldquo;Interact Done&rdquo; message to the
+session manager.
+    </para>
+  </sect1>
+
+  <sect1 id='sending_a_save_complete_message'>
+    <title>Sending a Save Complete Message</title>
+
+    <para>
+To send a &ldquo;Save Complete&rdquo; message to a client,
+use <function>SmsSaveComplete</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsSaveComplete</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The session manager sends this message when it is done with a
+checkpoint.  The client is then free to change its state.
+    </para>
+  </sect1>
+
+  <sect1 id='sending_a_die_message'>
+    <title>Sending a Die Message</title>
+
+    <para>
+To send a &ldquo;Die&rdquo; message to a client,
+use <function>SmsDie</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsDie</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+Before the session manager terminates, it should wait for a
+&ldquo;Connection Closed&rdquo; message from each client that it sent
+a &ldquo;Die&rdquo; message to, timing out appropriately.
+    </para>
+  </sect1>
+
+  <sect1 id='cancelling_a_shutdown'>
+    <title>Cancelling a Shutdown</title>
+
+    <para>
+To cancel a shutdown, use <function>SmsShutdownCancelled</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsShutdownCancelled</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The client can now continue as if the shutdown had never happened.  If
+the client has not sent a &ldquo;Save Yourself Done&rdquo; message
+yet, it can either abort the save and send a &ldquo;Save Yourself
+Done&rdquo; with the success argument set to <constant>False</constant>
+or it can continue with the save and send a &ldquo;Save Yourself Done&rdquo;
+with the <parameter>success</parameter> argument set to reflect the outcome
+of the save.
+    </para>
+  </sect1>
+<!-- aaaaaaaaaaaaaaaaa -->
+
+  <sect1 id='returning_properties'>
+    <title>Returning Properties</title>
+
+    <para>
+In response to a &ldquo;Get Properties&rdquo; message, the session
+manager should call <function>SmsReturnProperties</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsReturnProperties</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>int <parameter>num_props</parameter></paramdef>
+      <paramdef>SmProp **<parameter>props</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>num_props</parameter></term>
+    <listitem><para>The number of properties.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>props</parameter></term>
+    <listitem><para>The list of properties to return to the client.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+The properties are returned as an array of property pointers.  For a
+description of session management properties and
+the <structname>SmProp</structname> structure,
+see <link linkend='session_management_properties'>section 7,
+&ldquo;Session Management Properties.&rdquo;</link>
+    </para>
+  </sect1>
+
+  <sect1 id='pinging_a_client'>
+    <title>Pinging a Client</title>
+
+    <para>
+To check that a client is still alive, you should use
+the <function>IcePing</function> function provided by the ICE library.
+To do so, the ICE connection must be obtained using
+the <function>SmsGetIceConnection</function>
+(see <link linkend='using_sms_informational_functions'>section 6.12,
+&ldquo;Using Sms Informational Functions&rdquo;</link>).
+    </para>
+
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>IcePing</function></funcdef>
+      <paramdef>IceConn <parameter>ice_conn</parameter></paramdef>
+      <paramdef>IcePingReplyProc <parameter>ping_reply_proc</parameter></paramdef>
+      <paramdef>IcePointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>ice_conn</parameter></term>
+    <listitem><para>A valid ICE connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>ping_reply_proc</parameter></term>
+    <listitem><para>The callback to invoke when the Ping reply arrives.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>This pointer will be passed to the <function>IcePingReplyProc</function> callback.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+
+    <para>
+When the Ping reply is ready (if ever),
+the <function>IcePingReplyProc</function> callback will be invoked.  A
+session manager should have some sort of timeout period, after which
+it assumes the client has unexpectedly died.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>IcePingReplyProc</function>)</funcdef>
+      <paramdef>IceConn <parameter>ice_conn</parameter></paramdef>
+      <paramdef>IcePointer <parameter>client_data</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>ice_conn</parameter></term>
+    <listitem><para>A valid ICE connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>client_data</parameter></term>
+    <listitem><para>The client data specified in the call to <function>IcePing</function></para></listitem>
+  </varlistentry>
+</variablelist>
+
+  </sect1>
+
+  <sect1 id='cleaning_up_after_a_client_disconnects'>
+    <title>Cleaning Up After a Client Disconnects</title>
+
+    <para>
+When the session manager receives a &ldquo;Connection Closed&rdquo;
+message or otherwise detects that the client aborted the connection,
+it should call the <function>SmsCleanUp</function> function in order
+to free up the connection object.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmsCleanUp</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+  </sect1>
+
+  <sect1 id='using_sms_informational_functions'>
+    <title>Using Sms Informational Functions</title>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>int <function>SmsProtocolVersion</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmsProtocolVersion</function> returns the major version of
+the session management protocol associated with this session.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>int <function>SmsProtocolRevision</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmsProtocolRevision</function> returns the minor version of
+the session management protocol associated with this session.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>char *<function>SmsClientID</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmsClientID</function> returns a null-terminated string for
+the client ID associated with this connection.  You should
+call <function>free</function> on this pointer when the client ID is
+no longer needed.
+    </para>
+
+
+    <para>
+To obtain the host name of a client,
+use <function>SmsClientHostName</function>.
+This host name will be needed to restart the client.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>char *<function>SmsClientHostName</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+The string returned is of the form
+<parameter>protocol</parameter><literal>/</literal><parameter>hostname</parameter>,
+where <parameter>protocol</parameter> is one of
+{<literal>tcp</literal>, <literal>decnet</literal>, <literal>local</literal>}.
+You should call <function>free</function> on the string returned when
+it is no longer needed.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>IceConn <function>SmsGetIceConnection</function></funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+<function>SmsGetIceConnection</function> returns the ICE connection
+object associated with this session management connection object.  The
+ICE connection object can be used to get some additional information
+about the connection.  Some of the more useful functions which can be
+used on the IceConn are <function>IceConnectionNumber</function>
+and <function>IceLastSequenceNumber</function>.
+For further information, see the
+<citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+    </para>
+  </sect1>
+
+  <sect1 id='error_handling2'>
+    <title>Error Handling</title>
+
+    <para>
+If the session manager receives an unexpected protocol error from a
+client, an error handler is invoked by SMlib.  A default error handler
+exists which simply prints the error message (it does not exit).  The
+session manager can change this error handler by
+calling <function>SmsSetErrorHandler</function>.
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>SmsErrorHandler <function>SmsSetErrorHandler</function></funcdef>
+      <paramdef>SmsErrorHandler <parameter>handler</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+    <para>
+The error handler.  You should pass <constant>NULL</constant>
+to restore the default handler.
+    </para>
+
+    <para>
+<function>SmsSetErrorHandler</function> returns the previous error handler.
+The <function>SmsErrorHandler</function> has the following type:
+    </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>typedef void (*<function>SmsErrorHandler</function>)</funcdef>
+      <paramdef>SmsConn <parameter>sms_conn</parameter></paramdef>
+      <paramdef>Bool <parameter>swap</parameter></paramdef>
+      <paramdef>int <parameter>offending_minor_opcode</parameter></paramdef>
+      <paramdef>unsigned long <parameter>offending_sequence_num</parameter></paramdef>
+      <paramdef>int <parameter>error_class</parameter></paramdef>
+      <paramdef>int <parameter>severity</parameter></paramdef>
+      <paramdef>IcePointer <parameter>values</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>sms_conn</parameter></term>
+    <listitem><para>The session management connection object.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>swap</parameter></term>
+    <listitem><para>A flag which indicates if the specified values need byte swapping.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>offending_minor_opcode</parameter></term>
+    <listitem><para>The minor opcode of the offending message.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>offending_sequence_num</parameter></term>
+    <listitem><para>The sequence number of the offending message.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>error_class</parameter></term>
+    <listitem><para>The error class of the offending message.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>severity</parameter></term>
+    <listitem><para>
+       <constant>IceCanContinue</constant>,
+       <constant>IceFatalToProtocol</constant>, or
+       <constant>IceFatalToConnection</constant>
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>values</parameter></term>
+    <listitem><para>Any additional error values specific to the minor opcode and class.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+    <para>
+Note that this error handler is invoked for protocol related errors.
+To install an error handler to be invoked when an IO error occurs,
+use <function>IceSetIOErrorHandler</function>.
+For further information, see the
+<citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+    </para>
+  </sect1>
+</chapter>
+
+<chapter id='session_management_properties'>
+  <title>Session Management Properties</title>
+
+  <para>
+Each property is defined by the <structname>SmProp</structname> structure:
+
+<synopsis>
+typedef struct {
+       char *name;     /* name of property */
+       char *type;     /* type of property */
+       int num_vals;   /* number of values */
+       SmPropValue *vals;      /* the list of values */
+} SmProp;
+
+typedef struct {
+       int length;     /* the length of the value */
+       SmPointer value;        /* the value */
+} SmPropValue;
+</synopsis>
+  </para>
+
+  <para>
+The X Session Management Protocol defines a list of predefined
+properties, several of which are required to be set by the client.
+The following table specifies the predefined properties and indicates
+which ones are required.  Each property has a type associated with it.
+  </para>
+
+  <para>
+A type of <type>SmCARD8</type> indicates that there is a single 1-byte value.
+A type of <type>SmARRAY8</type> indicates that there is a single array of bytes.
+A type of <type>SmLISTofARRAY8</type> indicates that there is a list of array of
+bytes.
+  </para>
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='4' align='center'>
+    <colspec colname='c1'/>
+    <colspec colname='c2'/>
+    <colspec colname='c3'/>
+    <colspec colname='c4'/>
+    <thead>
+      <row>
+        <entry align='left'>Name</entry>
+        <entry align='left'>Type</entry>
+        <entry align='left'><acronym>POSIX</acronym> Type</entry>
+        <entry align='center'>Required</entry>
+      </row>
+    </thead>
+    <tbody>
+      <row>
+        <entry align='left'><property>SmCloneCommand</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmLISTofARRAY8</type></entry>
+        <entry align='center'>Yes</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmCurrentDirectory</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmARRAY8</type></entry>
+        <entry align='center'>No</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmDiscardCommand</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmLISTofARRAY8</type></entry>
+        <entry align='center'>No*</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmEnvironment</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmLISTofARRAY8</type></entry>
+        <entry align='center'>No</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmProcessID</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmARRAY8</type></entry>
+        <entry align='center'>No</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmProgram</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmARRAY8</type></entry>
+        <entry align='center'>Yes</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmRestartCommand</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmLISTofARRAY8</type></entry>
+        <entry align='center'>Yes</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmResignCommand</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmLISTofARRAY8</type></entry>
+        <entry align='center'>No</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmRestartStyleHint</property></entry>
+        <entry align='left'><type>SmCARD8</type></entry>
+        <entry align='left'><type>SmCARD8</type></entry>
+        <entry align='center'>No</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmShutdownCommand</property></entry>
+        <entry align='left'>OS-specific</entry>
+        <entry align='left'><type>SmLISTofARRAY8</type></entry>
+        <entry align='center'>No</entry>
+      </row>
+      <row>
+        <entry align='left'><property>SmUserID</property></entry>
+        <entry align='left'><type>SmARRAY8</type></entry>
+        <entry align='left'><type>SmARRAY8</type></entry>
+        <entry align='center'>Yes</entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+
+  <para>
+* Required if any state is stored in an external repository (for
+example, state file).
+  </para>
+
+  <itemizedlist mark='bullet'>
+    <listitem><para><property>SmCloneCommand</property></para>
+      <para>
+This is like the <property>SmRestartCommand</property>, except it restarts a
+copy of the application.  The only difference is that the application does not
+supply its client ID at register time.  On <acronym>POSIX</acronym> systems,
+this should be of type <type>SmLISTofARRAY8</type>.
+    </para></listitem>
+    <listitem><para><property>SmCurrentDirectory</property></para>
+      <para>
+On <acronym>POSIX</acronym>-based systems, this specifies the value of the
+current directory that needs to be set up prior to starting the
+<property>SmProgram</property> and should of type <type>SmARRAY8</type>.
+    </para></listitem>
+    <listitem><para><property>SmDiscardCommand</property></para>
+      <para>
+The discard command contains a command that when delivered to the host
+that the client is running on (determined from the connection), will
+cause it to discard any information about the current state.  If this
+command is not specified, the Session Manager will assume that all of
+the client's state is encoded in the <property>SmRestartCommand</property>.
+On <acronym>POSIX</acronym> systems, the type should be
+<type>SmLISTofARRAY8</type>.
+    </para></listitem>
+    <listitem><para><property>SmEnvironment</property></para>
+      <para>
+On <acronym>POSIX</acronym> based systems, this will be of type
+<type>SmLISTofARRAY8</type>, where the <type>ARRAY8</type>s alternate between
+environment variable name and environment variable value.
+    </para></listitem>
+    <listitem><para><property>SmProcessID</property></para>
+      <para>
+This specifies an OS-specific identifier for the process.
+On <acronym>POSIX</acronym> systems, this should contain the return value
+of <function>getpid</function> turned into a Latin-1 (decimal) string.
+    </para></listitem>
+    <listitem><para><property>SmProgram</property></para>
+      <para>
+This is the name of the program that is running.  On <acronym>POSIX</acronym>
+systems, this should be first parameter passed to <function>execve</function>
+and should be of type <type>SmARRAY8</type>.
+    </para></listitem>
+    <listitem><para><property>SmRestartCommand</property></para>
+      <para>
+The restart command contains a command that, when delivered to the
+host that the client is running on (determined from the connection),
+will cause the client to restart in its current state.
+On <acronym>POSIX</acronym>-based systems, this is of
+type <type>SmLISTofARRAY8</type>, and each of the elements in
+the array represents an element in the <varname>argv</varname>
+array.  This restart command should ensure that the client restarts
+with the specified client-ID.
+    </para></listitem>
+    <listitem><para><property>SmResignCommand</property></para>
+      <para>
+A client that sets the <property>SmRestartStyleHint</property>
+to <constant>SmRestartAnyway</constant> uses this property to specify a
+command that undoes the effect of the client and removes any saved state.
+As an example, consider a user that runs <command>xmodmap</command> which
+registers with the Session Manager,
+sets <property>SmRestartStyleHint</property>
+to <constant>SmRestartAnyway</constant>, and then
+terminates.  To allow the Session Manager (at the user's request) to
+undo this, <command>xmodmap</command> would register a
+<property>SmResignCommand</property> that undoes the effects of
+the <command>xmodmap</command>.
+    </para></listitem>
+    <listitem><para><property>SmRestartStyleHint</property></para>
+      <para>
+If the <property>SmRestartStyleHint</property> is present, it will contain the
+style of restarting the client prefers.  If this style is not specified,
+<constant>SmRestartIfRunning</constant> is assumed.
+The possible values are as follows:
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='2' align='center'>
+    <colspec colname='c1'/>
+    <colspec colname='c2'/>
+    <thead>
+      <row>
+        <entry align='left'>Name</entry>
+        <entry align='right'>Value</entry>
+      </row>
+    </thead>
+    <tbody>
+      <row>
+        <entry align='left'><constant>SmRestartIfRunning</constant></entry>
+        <entry align='right'>0</entry>
+      </row>
+      <row>
+        <entry align='left'><constant>SmRestartAnyway</constant></entry>
+        <entry align='right'>1</entry>
+      </row>
+      <row>
+        <entry align='left'><constant>SmRestartImmediately</constant></entry>
+        <entry align='right'>2</entry>
+      </row>
+      <row>
+        <entry align='left'><constant>SmRestartNever</constant></entry>
+        <entry align='right'>3</entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+      </para>
+
+      <para>
+The <constant>SmRestartIfRunning</constant> style is used in the usual case.
+The client should be restarted in the next session if it was running at
+the end of the current session.
+      </para>
+
+      <para>
+The <constant>SmRestartAnyway</constant> style is used to tell the Session
+Manager that the application should be restarted in the next session even if
+it exits before the current session is terminated.  It should be noted that
+this is only a hint and the Session Manager will follow the policies
+specified by its users in determining what applications to restart.
+      </para>
+
+      <para>
+A client that uses <constant>SmRestartAnyway</constant> should also set the
+<property>SmResignCommand</property> and <property>SmShutdownCommand</property>
+properties to commands that undo the state of the client after it exits.
+      </para>
+
+      <para>
+The SmRestartImmediately style is like SmRestartAnyway, but, in addition, the client is meant to run continuously.  If the client exits, the Session Manager should try to restart it in the current session.
+      </para>
+
+      <para>
+<constant>SmRestartNever</constant> style specifies that the client does not
+wish to be restarted in the next session.
+      </para>
+    </listitem>
+    <listitem><para><property>SmShutdownCommand</property></para>
+      <para>
+This command is executed at shutdown time to clean up after a client
+that is no longer running but retained its state by setting
+<property>SmRestartStyleHint</property> to
+<constant>SmRestartAnyway</constant>.  The client must not remove any saved
+state as the client is still part of the session.  As an
+example, consider a client that turns on a camera at start up time.
+This client then exits.  At session shutdown, the user wants the
+camera turned off.  This client would set the
+<property>SmRestartStyleHint</property> to
+<constant>SmRestartAnyway</constant> and would register
+a <property>SmShutdownCommand</property> that would turn off the camera.
+    </para></listitem>
+    <listitem><para><property>SmUserID</property></para>
+      <para>
+Specifies the user ID.  On <acronym>POSIX</acronym>-based systems, this will
+contain the user's name (the <structfield>pw_name</structfield> member of
+<structname>struct passwd</structname>).
+    </para></listitem>
+  </itemizedlist>
+</chapter>
+
+<chapter id='freeing_data'>
+  <title>Freeing Data</title>
+
+  <para>
+To free an individual property, use <function>SmFreeProperty</function>
+  </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmFreeProperty</function></funcdef>
+      <paramdef>SmProp *<parameter>prop</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>prop</parameter></term>
+    <listitem><para>The property to free.</para></listitem>
+  </varlistentry>
+</variablelist>
+
+  <para>
+To free the reason strings from
+the <function>SmsCloseConnectionProc</function> callback,
+use <function>SmFreeReasons</function>
+  </para>
+
+<funcsynopsis>
+   <funcprototype>
+      <funcdef>void <function>SmFreeReasons</function></funcdef>
+      <paramdef>int <parameter>count</parameter></paramdef>
+      <paramdef>char **<parameter>reasons</parameter></paramdef>
+  </funcprototype>
+</funcsynopsis>
+
+<variablelist remap='IP'>
+  <varlistentry>
+    <term><parameter>count</parameter></term>
+    <listitem><para>The number of reason strings.</para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><parameter>reasons</parameter></term>
+    <listitem><para>The list of reason strings to free.</para></listitem>
+  </varlistentry>
+</variablelist>
+</chapter>
+
+<chapter id='authentication_of_clients'>
+  <title>Authentication of Clients</title>
+
+  <para>
+As stated earlier, the session management protocol is layered on top
+of ICE.  Authentication occurs at two levels in the ICE protocol:
+
+<itemizedlist mark='bullet'>
+    <listitem><para>The first is when an ICE connection is opened.</para></listitem>
+    <listitem><para>The second is when a Protocol Setup occurs on an ICE connection.</para></listitem>
+</itemizedlist>
+  </para>
+
+  <para>
+The authentication methods that are available are
+implementation-dependent (that is., dependent on the ICElib and SMlib
+implementations in use).  For further information, see the
+<citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+  </para>
+</chapter>
+
+<chapter id='working_in_a_multithreaded_environment'>
+  <title>Working in a Multi-Threaded Environment</title>
+
+  <para>
+To declare that multiple threads in an application will be using SMlib
+(or any other library layered on top of ICElib), you should
+call <function>IceInitThreads</function>.
+For further information, see the
+<citetitle pubwork='article'>Inter-Client Exchange Library</citetitle>
+standard.
+  </para>
+</chapter>
+
+<chapter id='acknowledgements'>
+  <title>Acknowledgements</title>
+
+  <para>
+Thanks to the following people for their participation in the
+X Session Management design: Jordan Brown, Ellis Cohen, Donna Converse,
+Stephen Gildea, Vania Joloboff, Stuart Marks, Bob Scheifler, Ralph Swick,
+and Mike Wexler.
+  </para>
+
+</chapter>
+</book>
diff --git a/doc/xsmp.xml b/doc/xsmp.xml
new file mode 100755 (executable)
index 0000000..c90a45c
--- /dev/null
@@ -0,0 +1,2274 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+
+
+<!-- lifted from troff+ms+XMan by doclifter -->
+<book id="xsmpms">
+
+<bookinfo>
+   <title>X Session Management Protocol</title>
+   <subtitle>X Consortium Standard</subtitle>
+   <releaseinfo>X Version 11, Release 7</releaseinfo>
+   <authorgroup>
+      <author>
+         <firstname>Mike</firstname><surname>Wexler</surname>
+      </author>
+   </authorgroup>
+   <corpname>Kubota Pacific Computer, Inc</corpname>
+   <copyright>
+     <year>1992</year><year>1993</year><year>1994</year><year>2002</year>
+     <holder>The Open Group</holder>
+   </copyright>
+   <releaseinfo>Version 1.0</releaseinfo>
+   <affiliation><orgname>X Consortium</orgname></affiliation>
+   <productnumber>X Version 11, Release 7</productnumber>
+
+   <legalnotice>
+     <para>
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation files
+(the &ldquo;Software&rdquo;), 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:
+     </para>
+
+     <para>
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+     </para>
+
+     <para>
+THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY
+OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT.  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+     </para>
+
+     <para>
+Except as contained in this notice, the name of the X Consortium
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+from the X Consortium.
+     </para>
+
+     <para>
+X Window System is a trademark of The Open Group.
+     </para>
+   </legalnotice>
+
+   <abstract>
+     <para>
+This document specifies a protocol that facilitates the management of
+groups of client applications by a session manager.  The session
+manager can cause clients to save their state, to shut down, and to be
+restarted into a previously saved state.  This protocol is layered on
+top of the X.Org <acronym>ICE</acronym> protocol.
+     </para>
+   </abstract>
+
+</bookinfo>
+
+<chapter id="acknowledgments">
+  <title>Acknowledgments</title>
+
+  <para>
+First I would like to thank the entire <acronym>ICCCM</acronym> and Intrinsics
+working groups for the comments and suggestions. I would like to make special
+thanks to the following people (in alphabetical order), Jordan Brown,
+Ellis Cohen, Donna Converse, Vania Joloboff, Stuart Marks, Ralph Mor
+and Bob Scheifler.
+  </para>
+</chapter>
+
+<chapter id="definitions_and_goals">
+  <title>Definitions and Goals</title>
+
+  <para>
+The purpose of the X Session Management Protocol (<acronym>XSMP</acronym>) is
+to provide a uniform mechanism for users to save and restore their sessions.
+A <firstterm>session</firstterm> is a group of clients, each
+of which has a particular state.  The session is controlled by a
+network service called the <firstterm>session manager</firstterm>.
+The session manager issues commands to its
+clients on behalf of the user.  These commands may cause clients to
+save their state or to terminate.  It is expected that the client will
+save its state in such a way that the client can be restarted at a
+later time and resume its operation as if it had never been
+terminated.  A client's state might include information about the file
+currently being edited, the current position of the insertion point
+within the file, or the start of an uncommitted transaction.  The
+means by which clients are restarted is unspecified by this
+protocol.
+  </para>
+
+  <para>
+For purposes of this protocol, a <firstterm>client</firstterm>
+of the session manager is defined as a connection to the session
+manager.  A client is typically, though not necessarily, a process
+running an application program connected to an X Window System
+display.  However, a client may be connected to more than one X
+display or not be connected to any X displays at all.
+  </para>
+
+  <para>
+This protocol is layered on top of the X Consortium's <acronym>ICE</acronym> protocol and
+relies on the <acronym>ICE</acronym> protocol to handle connection management and authentication.
+  </para>
+
+</chapter>
+
+<chapter id="overview_of_the_protocol">
+  <title>Overview of the Protocol</title>
+
+  <para>
+Clients use XSMP to register themselves with the session manager (SM).
+When a client starts up, it should connect to the SM.  The client
+should remain connected for as long as it runs.  A client may resign
+from the session by issuing the proper protocol messages before
+disconnecting.  Termination of the connection without notice will be
+taken as an indication that the client died unexpectedly.
+  </para>
+
+  <para>
+Clients are expected to save their state in such a way as to allow
+multiple instantiations of themselves to be managed independently.  A
+unique value called a <firstterm>client-ID</firstterm> is
+provided by the protocol for the purpose of disambiguating multiple
+instantiations of clients.  Clients may use this ID, for example, as
+part of a filename in which to store the state for a particular
+instantiation.  The client-ID should be saved as part of the command
+used to restart this client
+(the <property>RestartCommand</property>) so that the client
+will retain the same ID after it is restarted.  Certain small pieces
+of state might also be stored in the RestartCommand.  For example, an
+X11 client might place a '-twoWindow' option in its RestartCommand to
+indicate that it should start up in two window mode when it is
+restarted.
+  </para>
+
+  <para>
+The client finds the network address of the SM in a system-dependent
+way.  On <acronym>POSIX</acronym> systems an environment
+variable called <envar>SESSION_MANAGER</envar>
+will contain a list of network IDs.  Each id will contain the
+transport name followed by a slash and the (transport-specific)
+address.  A TCP/IP address would look like this:
+    <informalexample><para>
+      <literal>tcp/</literal><replaceable>hostname</replaceable><literal>:</literal><replaceable>portnumber</replaceable>
+    </para></informalexample>
+where the hostname is a fully qualified domain name.
+A Unix Domain address looks like this:
+    <informalexample><para>
+       <literal>local/</literal><replaceable>hostname</replaceable><literal>:</literal><replaceable>path</replaceable>
+    </para></informalexample>
+A DECnet address would look like this:
+    <informalexample><para>
+       <literal>decnet/</literal><replaceable>nodename</replaceable><literal>::</literal><replaceable>objname</replaceable>
+    </para></informalexample>
+  </para>
+
+  <para>
+If multiple network IDs are specified, they should be separated by commas.
+  </para>
+
+  <note><title>Rationale</title>
+    <para>
+There was much discussion over whether the XSMP protocol should use X
+as the transport protocol or whether it should use its own independent
+transport.  It was decided that it would use an independent protocol
+for several reasons.  First, the Session Manager should be able to
+manage programs that do not maintain an X connection.  Second, the X
+protocol is not appropriate to use as a general-purpose transport
+protocol.  Third, a session might span multiple displays.
+    </para>
+
+    <para>
+The protocol is connection based, because there is no other way for
+the SM to determine reliably when clients terminate.
+    </para>
+
+    <para>
+It should be noted that this protocol introduces another single point
+of failure into the system.  Although it is possible for clients to
+continue running after the SM has exited, this will probably not be
+the case in normal practice.  Normally the program that starts the SM
+will consider the session to be terminated when the SM exits (either
+normally or abnormally).
+    </para>
+
+    <para>
+To get around this would require some sort of rendezvous server that
+would also introduce a single point of failure.  In the absence of a
+generally available rendezvous server, XSMP is kept simple in the
+hopes of making simple reliable SMs.
+    </para>
+  </note>
+
+  <para>
+Some clients may wish to manage the programs they start.  For example,
+a mail program could start a text editor for editing the text of a
+mail message.  A client that does this is a session manager itself; it
+should supply the clients it starts with the appropriate connection
+information (i.e., the <envar>SESSION_MANAGER</envar> environment variable)
+that specifies a connection to itself instead of to the top level session
+manager.
+  </para>
+
+  <para>
+Each client has associated with it a list of properties.  A property
+set by one client is not visible to any other client.  These
+properties are used for the client to inform the SM of the client's
+current state.  When a client initially connects to the SM, there are
+no properties set.
+  </para>
+</chapter>
+
+<chapter id="data_types">
+  <title>Data Types</title>
+
+  <para>
+XSMP messages contain several types of data.  Both the SM and the
+client always send messages in their native byte order.  Thus, both
+sides may need to byte-swap the messages received.  The need to do
+byte-swapping is determined at run-time by the <acronym>ICE</acronym> protocol.
+  </para>
+
+  <para>
+If an invalid value is specified for a field of any of the enumerated
+types, a <errorname>BadValue</errorname> error message must be sent by
+the receiver of the message to the sender of the message.
+  </para>
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='2' align='left'>
+    <colspec colname='c1'/>
+    <colspec colname='c2'/>
+    <thead>
+      <row>
+        <entry>Type Name</entry>
+        <entry>Description</entry>
+      </row>
+    </thead>
+    <tbody>
+      <row>
+        <entry>BOOL</entry>
+        <entry><para><constant>False</constant> or <constant>True</constant></para></entry>
+      </row>
+      <row>
+        <entry>INTERACT_STYLE</entry>
+        <entry><function>None</function> <function>Errors</function> or <function>Any</function></entry>
+      </row>
+      <row>
+        <entry>DIALOG_TYPE</entry>
+        <entry><function>Error</function> or <function>Normal</function></entry>
+      </row>
+      <row>
+        <entry>SAVE_TYPE</entry>
+        <entry><function>Global</function> <function>Local</function> or <function>Both</function></entry>
+      </row>
+      <row>
+        <entry>CARD8</entry>
+        <entry>a one-byte unsigned integer</entry>
+      </row>
+      <row>
+        <entry>CARD16</entry>
+        <entry>a two-byte unsigned integer</entry>
+      </row>
+      <row>
+        <entry>CARD32</entry>
+        <entry>a four-byte unsigned integer</entry>
+      </row>
+      <row>
+        <entry>ARRAY8</entry>
+        <entry>a sequence of CARD8s</entry>
+      </row>
+      <row>
+        <entry>LISTofARRAY8</entry>
+        <entry>a sequence of ARRAY8s</entry>
+      </row>
+      <row>
+        <entry>PROPERTY</entry>
+        <entry>a property name (an ARRAY8), a type name, and a value of that type</entry>
+      </row>
+      <row>
+        <entry>LISTofPROPERTY</entry>
+        <entry>a counted collection of &shy;PROPERTYs.</entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+
+</chapter>
+
+<chapter id="protocol_setup_and_message_format">
+  <title>Protocol Setup and Message Format</title>
+
+  <para>
+To start the XSMP protocol, the client sends the server an
+<acronym>ICE</acronym> <function>ProtocolSetup</function> message.  All XSMP messages are
+in the standard <acronym>ICE</acronym> message format.  The message's major opcode is
+assigned to XSMP by <acronym>ICE</acronym> at run-time.  The different parties (client
+and SM) may be assigned different major opcodes for XSMP.  Once
+assigned, all XSMP messages issued by this party will use the same
+major opcode.  The message's minor opcode specifies which protocol
+message this message contains.
+  </para>
+</chapter>
+
+<chapter id="client_identification_string">
+  <title>Client Identification String</title>
+  <para>
+A client ID is a string of XPCS characters encoded in ISO Latin 1 (ISO
+8859-1).  No null characters are allowed in this string.  The client
+ID string is used in the <function>Register&shy;Client</function>
+and <function>Register&shy;ClientReply</function> messages.
+  </para>
+
+  <para>
+Client IDs consist of the pieces described below.  The ID is formed by
+concatenating the pieces in sequence, without separator characters.
+All pieces are padded on the left with '<literal>0</literal>'
+characters so as to fill the specified length.  Decimal numbers are
+encoded using the characters '<literal>0</literal>' through
+'<literal>9</literal>', and hexadecimal numbers using the characters
+'<literal>0</literal>' through '<literal>9</literal>' and
+'<literal>A</literal>' through '<literal>F</literal>'.
+  </para>
+
+  <itemizedlist mark='bullet'>
+     <listitem><para>
+Version.  This is currently the character '<literal>1</literal>'.
+     </para></listitem>
+     <listitem>
+       <para>Address type and address.  The address type will be one of
+<literallayout remap='DS'>
+     '<literal>1</literal>'     a 4-byte IPv4 address encoded as 8 hexadecimal digits
+     '<literal>2</literal>'     a 6-byte DECNET address encoded as 12 hexadecimal digits
+     '<literal>6</literal>'     a 16-byte IPv6 address encoded as 32 hexadecimal digits
+</literallayout>
+       </para>
+
+       <para>
+The address is the one of the network addresses of the machine where
+the session manager (not the client) is running.  For example, the IP
+address 198.112.45.11 would be encoded as the string
+"<literal>QC6702D0B</literal>".
+       </para>
+     </listitem>
+     <listitem><para>
+        Time stamp.  A 13-digit decimal number specifying
+        the number of milliseconds since 00:00:00 UTC, January 1, 1970.
+     </para></listitem>
+     <listitem>
+       <para>
+       Process-ID type and process-ID.  The process-ID type will be one of
+<literallayout remap='DS'>
+     '<literal>1</literal>'    a <acronym>POSIX</acronym> process-ID encoded as a 10-digit decimal number.
+</literallayout>
+       </para>
+       <para>
+The process-ID is the process-ID of the session manager, not of a client.
+       </para>
+     </listitem>
+     <listitem>
+       <para>
+Sequence number.  This is a four-digit decimal number.  It is
+incremented every time the session manager creates an ID.  After
+reaching "Q9999" it wraps to "Q0000".
+       </para>
+       <note><title>Rationale</title>
+        <para>
+Once a client ID has been assigned to the client, the client keeps
+this ID indefinitely.  If the client is terminated and restarted, it
+will be reassigned the same ID.  It is desirable to be able to pass
+client IDs around from machine to machine, from user to user, and from
+session manager to session manager, while retaining the identity of
+the client.  This, combined with the indefinite persistence of client
+IDs, means that client IDs need to be globally unique.  The
+construction specified above will ensure that any client ID created by
+any user, session manager, and machine will be different from any other.
+        </para>
+       </note>
+     </listitem>
+  </itemizedlist>
+</chapter>
+
+<chapter id="protocol">
+  <title>Protocol</title>
+  <para>
+The protocol consists of a sequence of messages as described below.
+Each message type is specified by an <acronym>ICE</acronym> minor opcode.  A given
+message type is sent either from a client to the session manager or
+from the session manager to a client; the appropriate direction is
+listed with each message's description.  For each message type, the
+set of valid responses and possible error messages are listed.  The
+<acronym>ICE</acronym> severity is given in parentheses following each error class.
+  </para>
+
+  <synopsis>
+<function>RegisterClient</function> [Client &rarr; SM]
+
+  <parameter>previous-ID</parameter>: ARRAY8
+
+  Valid Responses: <function>RegisterClientReply</function>
+
+  Possible Errors: <errorname>BadValue</errorname> (<symbol role='Pn'>CanContinue</symbol>)
+  </synopsis>
+
+  <para>
+The client must send this message to the SM to register the client's
+existence.  If a client is being restarted from a previous session,
+the <parameter>previous-ID</parameter> field must contain the client
+ID from the previous session.  For new clients, 
+<parameter>previous-ID</parameter> should be of zero length.
+  </para>
+
+  <para>
+If <parameter>previous-ID</parameter> is not valid, 
+the SM will send a <errorname>BadValue</errorname>
+error message to the client.  At this point the SM reverts to the
+register state and waits for another <function>RegisterClient</function>
+The client should then send a <function>RegisterClient</function> with a
+null <parameter>previous-ID</parameter> field.
+  </para>
+
+  <synopsis>
+<function>RegisterClientReply</function> [Client &larr; SM]
+
+  <parameter>client-ID</parameter>: <type>ARRAY8</type>
+  </synopsis>
+
+  <para>
+The <parameter>client-ID</parameter> specifies a unique identification
+for this client.  If the client had specified an ID in the 
+<parameter>previous-ID</parameter> field of the 
+<function>RegisterClient</function> message, 
+<parameter>client-ID</parameter> will be identical to the previously
+specified ID.  If <parameter>previous-ID</parameter> was null,
+<parameter>client-ID</parameter> will be a unique ID freshly generated
+by the SM.  The <parameter>client-ID</parameter> format is specified in
+<link linkend="client_identification_string">section 6</link>.
+  </para>
+
+  <para>
+If the client didn't supply a <parameter>previous-ID</parameter> field to
+the <function>Register&shy;Client</function> message, the SM must send
+a <function>SaveYourself</function> message with type = Local,
+shutdown = False, interact-style = None, and fast = False immediately
+after the <function>RegisterClientReply</function> The client should
+respond to this like any other <function>Save&shy;Yourself</function>
+message.
+  </para>
+
+  <synopsis>
+<function>SaveYourself</function> [Client &larr; SM]
+
+  <parameter>type</parameter>: <type>SAVE_TYPE</type>
+  <parameter>shutdown</parameter>: <type>BOOL</type>
+  <parameter>interact-style</parameter>: <type>INTERACT_STYLE</type>
+  <parameter>fast</parameter>: <type>BOOL</type>
+
+  Valid Responses:
+    <function>SetProperties</function>
+    <function>DeleteProperties</function>
+    <function>GetProperties</function>
+    <function>SaveYourselfDone</function>
+    <function>SaveYourselfPhase2Request</function>
+    <function>InteractRequest</function>
+  </synopsis>
+
+  <para>
+The SM sends this message to a client to ask it to save its state.
+The client writes a state file, if necessary, and, if necessary,
+uses <function>SetProperties</function> to inform the SM of how to
+restart it and how to discard the saved state.  During this process it
+can, if allowed by <parameter>interact-style</parameter>, request permission
+to interact with
+the user by sending an <function>InteractRequest</function> message.
+After the state has been saved, or if it cannot be successfully saved,
+and the properties are appropriately set, the client sends
+a <function>SaveYourselfDone</function> message.  If the client wants
+to save additional information after all the other clients have
+finished changing their own state, the client should
+send <function>SaveYourselfPhase2Request</function> instead
+of <function>SaveYourselfDone</function> The client must then freeze
+interaction with the user and wait until it receives
+a <function>SaveComplete</function> <function>Die</function> or
+a <function>ShutdownCancelled</function> message.
+  </para>
+
+  <para>
+If <parameter>interact-style</parameter> is <function>None</function> the
+client must not interact with the user while saving state.  If the
+<parameter>interact-style</parameter>
+is <function>Errors</function> the client may interact with the user
+only if an error condition arises.  If <parameter>interact-style</parameter>
+is <function>Any</function> then the client may interact with the user
+for any purpose.  This is done by sending
+an <function>Interact&shy;Request</function> message.  The SM will
+send an <function>Interact</function> message to each client that sent
+an <function>Interact&shy;Request</function> The client must postpone
+all interaction until it gets the <function>Interact</function>
+message.  When the client is done interacting it should send the SM
+an <function>Interact&shy;Done</function> message.
+The <function>Interact&shy;Request</function> message can be sent any
+time after a <function>Save&shy;Yourself</function> and before
+a <function>Save&shy;Yourself&shy;Done</function>
+  </para>
+
+  <para>
+Unusual circumstances may dictate multiple interactions.  The client
+may initiate as many <function>Interact&shy;Request</function>
+- <function>Interact</function> - <function>InteractDone</function>
+sequences as it needs before it sends <function>SaveYourselfDone</function>
+  </para>
+
+  <para>
+When a client receives <function>Save&shy;Yourself</function> and has
+not yet responded <function>Save&shy;Yourself&shy;Done</function> to a
+previous <function>Save&shy;Yourself</function> it must send
+a <function>Save&shy;Yourself&shy;Done</function> and may then begin
+responding as appropriate to the newly received
+<function>Save&shy;Yourself</function>
+</para>
+
+  <para>
+The <parameter>type</parameter> field specifies the type of information that
+should be saved: <function>Global</function> <function>Local</function>
+or <function>Both</function> The <function>Local</function> type
+indicates that the application must update the properties to reflect
+its current state, send
+a <function>Save&shy;Yourself&shy;Done</function> and continue.
+Specifically it should save enough information to restore the state as
+seen by the user of this client.  It should not affect the state as
+seen by other users.  The <function>Global</function> type indicates
+that the user wants the client to commit all of its data to permanent,
+globally-accessible storage.  <function>Both</function> indicates that
+the client should do both of these.  If <function>Both</function> is
+specified, the client should first commit the data to permanent
+storage before updating its SM properties.
+  </para>
+
+  <note><title>Examples</title>
+    <para>
+If a word processor was sent a <function>SaveYourself</function> with
+a type of <function>Local</function> it could create a temporary file
+that included the current contents of the file, the location of the
+cursor, and other aspects of the current editing session.  It would
+then update its <function>Restart&shy;Command</function> property with
+enough information to find the temporary file, and
+its <function>Discard&shy;Command</function> with enough information
+to remove it.
+    </para>
+
+    <para>
+If a word processor was sent a <function>SaveYourself</function> with
+a type of <function>Global</function> it would simply save the
+currently edited file.
+    </para>
+
+    <para>
+If a word processor was sent a <function>SaveYourself</function> with
+a type of <function>Both</function> it would first save the currently
+edited file.  It would then create a temporary file with information
+such as the current position of the cursor and what file is being
+edited.  It would then update
+its <function>Restart&shy;Command</function> property with enough
+information to find the temporary file, and
+its <function>Discard&shy;Command</function> with enough information
+to remove it.
+    </para>
+
+    <para>
+Once the SM has send <function>SaveYourself</function> to a client, it
+can't send another <function>SaveYourself</function> to that client until
+the client either responds with a <function>SaveYourselfDone</function> or
+the SM sends a <function>ShutdownCancelled</function>
+    </para>
+  </note>
+
+  <note><title>Advice to Implementors</title>
+    <para>
+If the client stores local any state in a file or similar "external"
+storage, it must create a distinct copy in response to
+each <function>SaveYourself</function> message.
+It <emphasis remap='I'>must not</emphasis> simply refer to a previous
+copy, because the SM may discard that previous saved state using
+a <function>DiscardCommand</function> without knowing that it is
+needed for the new checkpoint.
+    </para>
+  </note>
+
+  <para>
+The <parameter>shutdown</parameter> field specifies whether the system is
+being shut down.
+  </para>
+
+  <note><title>Rationale</title>
+    <para>
+The interaction may be different depending on whether or not shutdown is set.
+    </para>
+  </note>
+
+  <para>
+The client must save and then must prevent interaction until it
+receives a <function>SaveComplete</function> <function>Die</function>
+or a <function>Shutdown&shy;Cancelled</function> because anything the
+user does after the save will be lost.
+  </para>
+
+  <para>
+The <parameter>fast</parameter> field specifies whether or not the client
+should save its state as quickly as possible.  For example, if the SM knows
+that power is about to fail, it should set the <parameter>fast</parameter>
+field to <constant>True</constant>.
+  </para>
+
+  <synopsis>
+<function>SaveYourselfPhase2</function> [Client &rarr; SM]
+
+  Valid Responses:
+    <function>SetProperties</function>
+    <function>DeleteProperties</function>
+    <function>GetProperties</function>
+    <function>SaveYourselfDone</function>
+    <function>InteractRequest</function>
+  </synopsis>
+
+  <para>
+The SM sends this message to a client that has previously sent
+a <function>SaveYourselfPhase2Request</function> message.  This
+message informs the client that all other clients are in a fixed state
+and this client can save state that is associated with other clients.
+  </para>
+
+  <note><title>Rationale</title>
+    <para>
+Clients that manager other clients (window managers, workspace
+managers, etc) need to know when all clients they are managing are
+idle, so that the manager can save state related to each of the
+clients without being concerned with that state changing.
+    </para>
+  </note>
+  <para>
+The client writes a state file, if necessary, and, if necessary,
+uses <function>SetProperties</function> to inform the SM of how to
+restart it and how to discard the saved state.  During this process it
+can request permission to interact with the user by sending
+an <function>InteractRequest</function> message.  This should only be
+done if an error occurs that requires user interaction to resolve.
+After the state has been saved, or if it cannot be successfully saved,
+and the properties are appropriately set, the client sends
+a <function>SaveYourselfDone</function> message.
+  </para>
+
+  <synopsis>
+<function>SaveYourselfRequest</function> [Client &rarr; SM]
+
+  <parameter>type</parameter>: <type>SAVE_TYPE</type>
+  <parameter>shutdown</parameter>: <type>BOOL</type>
+  <parameter>interact-style</parameter>: <type>INTERACT_STYLE</type>
+  <parameter>fast</parameter>: <type>BOOL</type>
+  <parameter>global</parameter>: <type>BOOL</type>
+
+  Valid Responses: <function>SaveYourself</function>
+  </synopsis>
+
+  <para>
+An application sends this to the SM to request a checkpoint.  When the
+SM receives this request it may generate a <function>SaveYourself</function>
+message in response and it may leave the fields intact.
+  </para>
+
+  <note><title>Example</title> <para>
+A vendor of a <acronym>UPS</acronym> (Uninterruptible Power Supply)
+might include an SM client that would monitor the status of
+the <acronym>UPS</acronym> and generate a fast shutdown if the power
+is about to be lost.
+  </para></note>
+
+  <para>
+If <parameter>global</parameter> is set to <constant>True</constant> then the
+resulting <function>SaveYourself</function> should be sent to all
+applications.  If <parameter>global</parameter> is set to
+<constant>False</constant> then the
+resulting <function>SaveYourself</function> should be sent to the
+application that sent the <function>Save&shy;Yourself&shy;Request</function>
+  </para>
+
+  <synopsis>
+<function>InteractRequest</function> [Client &rarr; SM]
+
+  <parameter>dialog-type</parameter>: <type>DIALOG_TYPE</type>
+
+  Valid Responses: <function>Interact</function> <function>ShutdownCancelled</function>
+
+  Possible Errors: <errorname>BadState</errorname> (<symbol role='Pn'>CanContinue</symbol>)
+  </synopsis>
+
+  <para>
+During a checkpoint or session-save operation, only one client at a
+time might be granted the privilege of interacting with the user.
+The <function>InteractRequest</function> message causes the SM to emit
+an <function>Interact</function> message at some later time if the
+shutdown is not cancelled by another client first.
+  </para>
+
+  <para>
+The <parameter>dialog-type</parameter> field specifies either
+<function>Errors</function> indicating that the client wants to start an
+error dialog or <function>Normal</function> meaning the client wishes
+to start a non-error dialog.
+  </para>
+
+  <synopsis>
+<function>Interact</function> [Client &larr; SM]
+
+  Valid Responses: <function>InteractDone</function>
+  </synopsis>
+
+  <para>
+This message grants the client the privilege of interacting with the
+user.  When the client is done interacting with the user it must send
+an <function>InteractDone</function> message to the SM unless a
+shutdown cancel is received.
+  </para>
+  <note><title>Advice to Implementors</title>
+    <para>If a client receives a ShutdownCancelled
+after receiving an <function>Interact</function> message, but before
+sending a <function>InteractDone</function> the client should abort
+the interaction and send a <function>SaveYourselfDone</function>
+  </para></note>
+
+  <synopsis>
+<function>InteractDone</function> [Client &rarr; SM]
+
+  <parameter>cancel-shutdown</parameter>: <type>BOOL</type>
+
+  Valid Responses: <function>ShutdownCancelled</function>
+  </synopsis>
+
+  <para>
+This message is used by a client to notify the SM that it is done interacting.
+  </para>
+
+  <para>
+Setting the <parameter>cancel-shutdown</parameter> field to <constant>True</constant>
+indicates that the user has requested that the entire shutdown be
+cancelled.  <parameter>Cancel-shutdown</parameter> may only be <constant>True</constant> if
+the corresponding <function>SaveYourself</function> message
+specified <constant>True</constant> for the shutdown field
+and <function>Any</function> or <function>Errors</function> for the
+<parameter>interact-style</parameter> field.  Otherwise,
+<parameter>cancel-shutdown</parameter> must be <constant>False</constant>.
+  </para>
+
+  <synopsis>
+<function>SaveYourselfDone</function> [Client &rarr; SM]
+
+  <parameter>success</parameter>: <type>BOOL</type>
+
+  Valid Responses:
+    <function>SaveComplete</function>
+    <function>Die</function>
+    <function>ShutdownCancelled</function>
+  
+  </synopsis>
+
+  <para>
+This message is sent by a client to indicate that all of the
+properties representing its state have been updated.  After
+sending <function>SaveYourselfDone</function> the client must wait for
+a <function>SaveComplete</function> <function>ShutdownCancelled</function>
+or <function>Die</function> message before changing its state.  If
+the <function>SaveYourself</function> operation was successful, then
+the client should set the <parameter>success</parameter> field to
+<constant>True</constant> otherwise the client should set it to
+<constant>False</constant>.
+  </para>
+
+  <note><title>Example</title>
+    <para>
+If a client tries to save its state and runs out of disk space, it
+should return <constant>False</constant> in the <parameter>success</parameter>
+field of the <function>SaveYourselfDone</function> message.
+    </para>
+  </note>
+
+  <synopsis>
+<function>SaveYourselfPhase2Request</function> [Client &rarr; SM]
+
+  Valid Responses:
+    <function>ShutdownCancelled</function>
+    <function>SaveYourselfPhase2</function>
+  
+  </synopsis>
+
+  <para>
+This message is sent by a client to indicate that it needs to be informed
+when all the other clients are quiescent, so it can continue its state.
+  </para>
+
+  <synopsis>
+<function>Die</function> [Client &larr; SM]
+
+  Valid Responses: <function>ConnectionClosed</function>
+  </synopsis>
+
+  <para>
+When the SM wants a client to die it sends a <function>Die</function>
+message.  Before the client dies it responds by sending
+a <function>ConnectionClosed</function> message and may then close its
+connection to the SM at any time.
+  </para>
+
+  <synopsis>
+<function>SaveComplete</function> [Client &rarr; SM]
+
+  Valid Responses:
+  </synopsis>
+
+  <para>
+When the SM is done with a checkpoint, it will send each of the
+clients a <function>SaveComplete</function> message.  The client is
+then free to change its state.
+  </para>
+
+  <synopsis>
+<function>ShutdownCancelled</function> [Client &larr; SM]
+  </synopsis>
+
+  <para>
+The shutdown currently in process has been aborted.  The client can
+now continue as if the shutdown had never happened.  If the client has
+not sent <function>SaveYourselfDone</function> yet, the client can
+either abort the save and send <function>SaveYourselfDone</function>
+with the success field set to <constant>False</constant> or it can
+continue with the save and send a <function>SaveYourselfDone</function>
+with the success field set to reflect the outcome of the save.
+  </para>
+
+  <synopsis>
+<function>ConnectionClosed</function> [Client &rarr; SM]
+
+  <parameter>reason</parameter>: <type>LISTofARRAY8</type>
+  </synopsis>
+
+  <para>
+Specifies that the client has decided to terminate.  It should be
+immediately followed by closing the connection.
+  </para>
+
+  <para>
+The <parameter>reason</parameter> field specifies why the client is resigning
+from the session.  It is encoded as an array of Compound Text strings.  If the
+resignation is expected by the user, there will typically be zero
+ARRAY8s here.  But if the client encountered an unexpected fatal
+error, the error message (which might otherwise be printed on stderr
+on a <acronym>POSIX</acronym> system) should be forwarded to the SM here, one ARRAY8 per
+line of the message.  It is the responsibility of the SM to display
+this reason to the user.
+  </para>
+
+  <para>
+After sending this message, the client must not send any additional
+XSMP messages to the SM.
+  </para>
+  <note><title>Advice to Implementors</title><para>
+If additional messages are received, they should be discarded.
+  </para></note>
+  <note><title>Rationale</title><para>
+The reason for sending the <function>ConnectionClosed</function>
+message before actually closing the connections is that some transport
+protocols will not provide immediate notification of connection
+closure.
+  </para></note>
+
+  <synopsis>
+<function>SetProperties</function> [Client &rarr; SM]
+
+  <parameter>properties</parameter>: <type>LISTofPROPERTY</type>
+  </synopsis>
+
+  <para>
+Sets the specified <parameter>properties</parameter> to the specified values.
+Existing
+properties not specified in the <function>Set&shy;Properties</function>
+message are unaffected. Some properties have predefined semantics.
+See <link linkend='predefined_properties'>section 11, 
+&ldquo;Predefined Properties.&rdquo;</link>
+  </para>
+
+  <para>
+The protocol specification recommends that property names used for
+properties not defined by the standard should begin with an
+underscore.  To prevent conflicts among organizations, additional
+prefixes should be chosen (for example, _KPC_FAST_SAVE_OPTION).  The
+organizational prefixes should be registered with the X Registry.  The
+XSMP reserves all property names not beginning with an underscore for
+future use.
+  </para>
+
+  <synopsis>
+<function>DeleteProperties</function> [Client &rarr; SM]
+
+  <parameter>property-names</parameter>: <type>LISTofARRAY8</type>
+  </synopsis>
+
+  <para>Removes the named properties.</para>
+
+  <synopsis>
+<function>GetProperties</function> [Client &rarr; SM]
+
+  Valid Responses: <function>GetPropertiesReply</function>
+  </synopsis>
+
+  <para>
+Requests that the SM respond with the values of all the properties for
+this client.
+  </para>
+
+  <synopsis>
+<function>GetPropertiesReply</function> [Client &larr; SM]
+
+  <parameter>values</parameter>: <type>LISTofPROPERTY</type>
+  </synopsis>
+
+  <para>
+This message is sent in reply to a <function>GetProperties</function>
+message and includes the <parameter>values</parameter> of all the properties.
+  </para>
+</chapter>
+
+<chapter id="errors">
+  <title>Errors</title>
+
+  <para>
+When the receiver of a message detects an error condition, the
+receiver sends an <acronym>ICE</acronym> error message to the sender.  There are only two
+types of errors that are used by the XSMP:
+<errorname>BadValue</errorname> and <errorname>BadState</errorname>
+These are both defined in the <acronym>ICE</acronym> protocol.
+  </para>
+
+  <para>
+Any message received out-of-sequence will generate
+a <errorname>BadState</errorname> error message.
+  </para>
+</chapter>
+
+<chapter id="state_diagrams">
+  <title>State Diagrams</title>
+  <para>
+These state diagrams are designed to cover all actions of both the
+client and the SM.
+  </para>
+
+  <sect1 id='client_state_diagram'>
+    <title>Client State Diagram</title>
+
+<!-- <literallayout remap='DS'> -->
+<literallayout>
+<emphasis remap='I'>start:</emphasis>
+     <acronym>ICE</acronym> protocol setup complete &rarr; <emphasis remap='C'>register</emphasis></literallayout>
+
+<literallayout>
+<emphasis remap='I'>register:</emphasis>
+     send <emphasis remap='B'>RegisterClient</emphasis> &rarr; <emphasis remap='C'>collect-id</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>collect-id:</emphasis>
+     receive <emphasis remap='B'>RegisterClientReply</emphasis> &rarr; <emphasis remap='C'>idle</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>shutdown-cancelled:</emphasis>
+     send <emphasis remap='B'>SaveYourselfDone</emphasis> &rarr; <emphasis remap='C'>idle</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>idle:</emphasis> [Undoes any freeze of interaction with user.]
+     receive <emphasis remap='B'>Die</emphasis> &rarr; <emphasis remap='C'>die</emphasis>
+     receive <emphasis remap='B'>SaveYourself</emphasis> &rarr; <emphasis remap='C'>freeze-interaction</emphasis>
+     send <emphasis remap='B'>GetProperties</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     receive <emphasis remap='B'>GetPropertiesReply</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     send <emphasis remap='B'>SetProperties</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     send <emphasis remap='B'>DeleteProperties</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     send <emphasis remap='B'>ConnectionClosed</emphasis> &rarr; <emphasis remap='C'>connection-closed</emphasis>
+     send <emphasis remap='B'>SaveYourselfRequest</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+</literallayout> <!-- remap='DE' -->
+
+<literallayout remap='DS'>
+<emphasis remap='I'>die:</emphasis>
+     send <emphasis remap='B'>ConnectionClosed</emphasis> &rarr; <emphasis remap='C'>connection-closed</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>freeze-interaction:</emphasis>
+     freeze interaction with user &rarr; <emphasis remap='C'>save-yourself</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>save-yourself:</emphasis>
+     receive <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>shutdown-cancelled</emphasis>
+     send <emphasis remap='B'>SetProperties</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     send <emphasis remap='B'>DeleteProperties</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     send <emphasis remap='B'>GetProperties</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     receive <emphasis remap='B'>GetPropertiesReply</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     send <emphasis remap='B'>InteractRequest</emphasis> &rarr; <emphasis remap='C'>interact-request</emphasis>
+     send <emphasis remap='B'>SaveYourselfPhase2Request</emphasis> &rarr; waiting-for-phase2
+
+<emphasis remap='I'>save-yourself:</emphasis>
+     if shutdown mode:
+          send <emphasis remap='B'>SaveYourselfDone</emphasis> &rarr; <emphasis remap='C'>save-yourself-done</emphasis>
+     otherwise:
+          send <emphasis remap='B'>SaveYourselfDone</emphasis> &rarr; <emphasis remap='C'>idle</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>waiting-for-phase2:</emphasis>
+     receive <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>shutdown-cancelled</emphasis>
+     receive <emphasis remap='B'>SaveYourselfPhase2</emphasis> &rarr; <emphasis remap='C'>phase2</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>phase2:</emphasis>
+     receive <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>shutdown-cancelled</emphasis>
+     send <emphasis remap='B'>SetProperties</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     send <emphasis remap='B'>DeleteProperties</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     send <emphasis remap='B'>GetProperties</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     receive <emphasis remap='B'>GetPropertiesReply</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     send <emphasis remap='B'>InteractRequest</emphasis> &rarr; <emphasis remap='C'>interact-request</emphasis> (errors only)
+     if shutdown mode:
+          send <emphasis remap='B'>SaveYourselfDone</emphasis> &rarr; <emphasis remap='C'>save-yourself-done</emphasis>
+     otherwise:
+          send <emphasis remap='B'>SaveYourselfDone</emphasis> &rarr; <emphasis remap='C'>idle</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>interact-request:</emphasis>
+     receive <emphasis remap='B'>Interact</emphasis> &rarr; <emphasis remap='C'>interact</emphasis>
+     receive <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>shutdown-cancelled</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>interact:</emphasis>
+     send <emphasis remap='B'>InteractDone</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     receive <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>shutdown-cancelled</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>save-yourself-done:</emphasis> (changing state is forbidden)
+     receive <emphasis remap='B'>SaveComplete</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     receive <emphasis remap='B'>Die</emphasis> &rarr; <emphasis remap='C'>die</emphasis>
+     receive <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>idle</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>connection-closed:</emphasis>
+     client stops participating in session </literallayout>
+</sect1>
+
+<sect1 id='session_manager_state_diagram'>
+<title>Session Manager State Diagram</title>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>start:</emphasis>
+     receive <emphasis remap='B'>ProtocolSetup</emphasis> &rarr; <emphasis remap='C'>protocol-setup</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>protocol-setup:</emphasis>
+     send <emphasis remap='B'>ProtocolSetupReply</emphasis> &rarr; <emphasis remap='C'>register</emphasis></literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>register:</emphasis>
+     receive <emphasis remap='B'>RegisterClient</emphasis> &rarr; <emphasis remap='C'>acknowledge-register</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>acknowledge-register:</emphasis>
+     send <emphasis remap='B'>RegisterClientReply</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>idle:</emphasis>
+     receive <emphasis remap='B'>SetProperties</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     receive <emphasis remap='B'>DeleteProperties</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     receive <emphasis remap='B'>ConnectionClosed</emphasis> &rarr; <emphasis remap='C'>start</emphasis>
+     receive <emphasis remap='B'>GetProperties</emphasis> &rarr; <emphasis remap='C'>get-properties</emphasis>
+     receive <emphasis remap='B'>SaveYourselfRequest</emphasis> &rarr; <emphasis remap='C'>save-yourself</emphasis>
+     send <emphasis remap='B'>SaveYourself</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>save-yourself:</emphasis>
+     send <emphasis remap='B'>SaveYourself</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>get-properties:</emphasis>
+     send <emphasis remap='B'>GetPropertiesReply</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>saving-get-properties:</emphasis>
+     send <emphasis remap='B'>GetPropertiesReply</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>saving-yourself:</emphasis>
+     receive <emphasis remap='B'>InteractRequest</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     send <emphasis remap='B'>Interact</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     send <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     receive <emphasis remap='B'>InteractDone</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     receive <emphasis remap='B'>SetProperties</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+      receive <emphasis remap='B'>DeleteProperties</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     receive <emphasis remap='B'>GetProperties</emphasis> &rarr; <emphasis remap='C'>saving-get-properties</emphasis>
+     receive <emphasis remap='B'>SaveYourselfPhase2Request</emphasis> &rarr; <emphasis remap='C'>start-phase2</emphasis>
+     receive <emphasis remap='B'>SaveYourselfDone</emphasis> &rarr; <emphasis remap='C'>save-yourself-done</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>start-phase2:</emphasis>
+     If all clients have sent either SaveYourselfPhase2Request or SaveYourselfDone:
+          send <emphasis remap='B'>SaveYourselfPhase2</emphasis> &rarr; <emphasis remap='C'>phase2</emphasis>
+     else
+          &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>phase2:</emphasis>
+     receive <emphasis remap='B'>InteractRequest</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     send <emphasis remap='B'>Interact</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     send <emphasis remap='B'>ShutdownCancelled</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+     receive <emphasis remap='B'>InteractDone</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     receive <emphasis remap='B'>SetProperties</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+      receive <emphasis remap='B'>DeleteProperties</emphasis> &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+     receive <emphasis remap='B'>GetProperties</emphasis> &rarr; <emphasis remap='C'>saving-get-properties</emphasis>
+     receive <emphasis remap='B'>SaveYourselfDone</emphasis> &rarr; <emphasis remap='C'>save-yourself-done</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>save-yourself-done:</emphasis>
+     If all clients are saved:
+          If shutting down:
+               send <emphasis remap='B'>Die</emphasis> &rarr; <emphasis remap='C'>die</emphasis>
+          otherwise
+               send <emphasis remap='B'>SaveComplete</emphasis> &rarr; <emphasis remap='C'>idle</emphasis>
+
+     If some clients are not saved:
+     &rarr; <emphasis remap='C'>saving-yourself</emphasis>
+</literallayout>
+
+<literallayout remap='DS'>
+<emphasis remap='I'>die:</emphasis>
+     SM stops accepting connections
+</literallayout>
+  </sect1>
+</chapter>
+
+<chapter id='protocol_encoding'>
+  <title>Protocol Encoding</title>
+  <sect1 id="types">
+    <title>Types</title>
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='4'>
+    <colspec colwidth='0.5in' colname='c0'/>
+    <colspec colwidth='1.0in' colname='c1'/>
+    <colspec colwidth='1.0in' colname='c2'/>
+    <colspec colwidth='1.0in' colname='c3'/>
+    <spanspec spanname="typename" namest="c0" nameend="c3" />
+    <tbody>
+      <row>
+        <entry spanname="typename"><emphasis role="bold">BOOL</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">0</entry>
+        <entry namest="c2">False</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">True</entry>
+      </row>
+
+      <row>
+        <entry spanname="typename"><emphasis role="bold">INTERACT_STYLE</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">0</entry>
+        <entry namest="c2">None</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">Errors</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2">Any</entry>
+      </row>
+
+      <row>
+        <entry spanname="typename"><emphasis role="bold">DIALOG_TYPE</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">0</entry>
+        <entry namest="c2">Error</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">Normal</entry>
+      </row>
+
+      <row>
+        <entry spanname="typename"><emphasis role="bold">SAVE_TYPE</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">0</entry>
+        <entry namest="c2">Global</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">Local</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2">Both</entry>
+      </row>
+
+      <row>
+        <entry spanname="typename"><emphasis role="bold">ARRAY8</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">CARD32</entry>
+        <entry namest="c3">length</entry>
+      </row>
+      <row>
+        <entry namest="c1">n</entry>
+        <entry namest="c2">ListofCARD8, the array</entry>
+        <entry namest="c3">p = pad (4 + n, 8)</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2">Both</entry>
+      </row>
+
+      <row>
+        <entry spanname="typename"><emphasis role="bold">LISTofARRAY8</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">CARD32</entry>
+        <entry namest="c3">count</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">ARRAY8</entry>
+        <entry namest="c3">first array</entry>
+      </row>
+      <row>
+        <entry namest="c1">b</entry>
+        <entry namest="c2">ARRAY8</entry>
+        <entry namest="c3">second array</entry>
+      </row>
+      <row>
+        <entry namest="c1">.</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3"></entry>
+      </row>
+      <row>
+        <entry namest="c1">.</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3"></entry>
+      </row>
+      <row>
+        <entry namest="c1">.</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3"></entry>
+      </row>
+      <row>
+        <entry namest="c1">q</entry>
+        <entry namest="c2">ARRAY8</entry>
+        <entry namest="c3">last array</entry>
+      </row>
+
+      <row>
+        <entry spanname="typename"><emphasis role="bold">PROPERTY</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">ARRAY8</entry>
+        <entry namest="c3">name</entry>
+      </row>
+      <row>
+        <entry namest="c1">b</entry>
+        <entry namest="c2">ARRAY8</entry>
+        <entry namest="c3">type (XPCS encoded in Latin-1, case sensitive)</entry>
+      </row>
+      <row>
+        <entry namest="c1">c</entry>
+        <entry namest="c2">LISTofARRAY8</entry>
+        <entry namest="c3">values</entry>
+      </row>
+
+      <row>
+        <entry spanname="typename"><emphasis role="bold">LISTofPROPERTY</emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">CARD32</entry>
+        <entry namest="c3">count</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">PROPERTY</entry>
+        <entry namest="c3">first property</entry>
+      </row>
+      <row>
+        <entry namest="c1">b</entry>
+        <entry namest="c2">PROPERTY</entry>
+        <entry namest="c3">second property</entry>
+      </row>
+      <row>
+        <entry namest="c1">.</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3"></entry>
+      </row>
+      <row>
+        <entry namest="c1">.</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3"></entry>
+      </row>
+      <row>
+        <entry namest="c1">.</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3"></entry>
+      </row>
+      <row>
+        <entry namest="c1">q</entry>
+        <entry namest="c2">PROPERTY</entry>
+        <entry namest="c3">last property</entry>
+      </row>
+     </tbody>
+  </tgroup>
+</informaltable>
+
+  </sect1>
+
+  <sect1 id='messages'>
+    <title>Messages</title>
+    <para>
+XSMP is a sub-protocol of <acronym>ICE</acronym>.  The major opcode is
+assigned at run-time by <acronym>ICE</acronym> and is represented here
+by '<literal>?</literal>'.
+    </para>
+
+    <para>
+To start the XSMP protocol, the client sends the server an
+<acronym>ICE</acronym> <function>ProtocolSetup</function> message.
+The protocol-name field should be specified as "<literal>XSMP</literal>",
+the major version of the protocol is 1, the minor version is 0.  These
+values may change if the protocol is revised.  The minor version
+number will be incremented if the change is compatible, otherwise the
+major version number will be incremented.
+    </para>
+
+    <para>
+In <function>ProtocolReply</function> message sent by the session
+manager, the XSMP protocol defines the vendor parameter as product
+identification of the session manager, and defines the release
+parameter as the software release identification of the session
+manager.  The session manager should supply this information in the
+<acronym>ICE</acronym> <function>ProtocolReply</function> message.
+    </para>
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='4' align='left'>
+    <colspec  colwidth='0.5in' colname='c0'/>
+    <colspec  colwidth='0.5in' colname='c1'/>
+    <colspec  colwidth='1.1in' colname='c2'/>
+    <colspec  colwidth='1.0in' colname='c3'/>
+    <spanspec spanname="messagename" namest="c0" nameend="c3" />
+    <tbody>
+      <row>
+       <entry spanname="messagename"><emphasis role="bold"><function>RegisterClient</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">1</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">a/8</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">ARRAY8</entry>
+        <entry namest="c3">previous-ID</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>RegisterClientReply</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">2</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">a/8</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">ARRAY8</entry>
+        <entry namest="c3">client-ID</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>SaveYourself</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">3</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">1</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">SAVE_TYPE</entry>
+        <entry namest="c3">type</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">BOOL</entry>
+        <entry namest="c3">shutdown</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">INTERACT_STYLE</entry>
+        <entry namest="c3">interact-style</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">BOOL</entry>
+        <entry namest="c3">fast</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>SaveYourselfRequest</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">4</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">1</entry>
+        <entry namest="c3">length of remainning data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">SAVE_TYPE</entry>
+        <entry namest="c3">type</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">BOOL</entry>
+        <entry namest="c3">shutdown</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">INTERACT_STYLE</entry>
+        <entry namest="c3">interact-style</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">BOOL</entry>
+        <entry namest="c3">fast</entry>
+      </row>
+      <row>
+        <entry namest="c1">3</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>InteractRequest</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">5</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">DIALOG_TYPE</entry>
+        <entry namest="c3">dialog type</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>Interact</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">6</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>InteractDone</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">7</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">BOOL</entry>
+        <entry namest="c3">cancel-shutdown</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>InteractDone</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">7</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">BOOL</entry>
+        <entry namest="c3">cancel-shutdown</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>SaveYourselfDone</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">8</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">BOOL</entry>
+        <entry namest="c3">success</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>Die</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">9</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>ShutdownCancelled</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">10</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>ConnectionClosed</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">11</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">a/8</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">LISTofARRAY8</entry>
+        <entry namest="c3">reason</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>SetProperties</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">12</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">a/8</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">LISTofPROPERTY</entry>
+        <entry namest="c3">properties</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>DeleteProperties</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">13</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">a/8</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">LISTofPROPERTY</entry>
+        <entry namest="c3">properties</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>GetProperties</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">14</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>GetPropertiesReply</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">15</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">a/8</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+      <row>
+        <entry namest="c1">a</entry>
+        <entry namest="c2">LISTofPROPERTY</entry>
+        <entry namest="c3">properties</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>SaveYourselfPhase2Request</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">16</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>SaveYourselfPhase2</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">17</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+
+      <row>
+        <entry spanname="messagename"><emphasis role="bold"><function>SaveComplete</function></emphasis></entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">?</entry>
+        <entry namest="c3">XSMP</entry>
+      </row>
+      <row>
+        <entry namest="c1">1</entry>
+        <entry namest="c2">18</entry>
+        <entry namest="c3">opcode</entry>
+      </row>
+      <row>
+        <entry namest="c1">2</entry>
+        <entry namest="c2"></entry>
+        <entry namest="c3">unused</entry>
+      </row>
+      <row>
+        <entry namest="c1">4</entry>
+        <entry namest="c2">0</entry>
+        <entry namest="c3">length of remaining data in 8-byte units</entry>
+      </row>
+     </tbody>
+  </tgroup>
+</informaltable>
+
+  </sect1>
+</chapter>
+
+<chapter id='predefined_properties'>
+  <title>Predefined Properties</title>
+  <para>
+All property values are stored in a LISTofARRAY8.  If the type of the
+property is CARD8, the value is stored as a LISTofARRAY8 with one
+ARRAY8 that is one byte long.  That single byte contains the CARD8.
+If the type of the property is ARRAY8, the value is stored in the
+first element of a single element LISTofARRAY8.
+  </para>
+
+  <para>
+The required properties must be set each time a client connects with
+the SM.  The properties must be set after the client
+sends <function>RegisterClient</function> and before the client
+sends <function>SaveYourselfDone</function> Otherwise, the behavior of
+the session manager is not defined.
+  </para>
+
+  <para>
+Clients may set, get, and delete nonstandard properties.  The lifetime
+of stored properties does not extend into subsequent sessions.
+  </para>
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='4'>
+    <colspec colname='c1' align='left'  />
+    <colspec colname='c2' align='left'  />
+    <colspec colname='c3' align='left'  />
+    <colspec colname='c4' align='center'/>
+    <thead>
+      <row>
+        <entry>Name</entry>
+        <entry>Type</entry>
+        <entry>Posix Type</entry>
+        <entry>Required?</entry>
+      </row>
+    </thead>
+    <tbody>
+      <row>
+        <entry>CloneCommand</entry>
+        <entry>OS-specific</entry>
+        <entry>LISTofARRAY8</entry>
+        <entry>Yes</entry>
+      </row>
+      <row>
+        <entry>CurrentDirectory</entry>
+        <entry>OS-specific</entry>
+        <entry>ARRAY8</entry>
+        <entry>No</entry>
+      </row>
+      <row>
+        <entry>DiscardCommand</entry>
+        <entry>OS-specific</entry>
+        <entry>LISTofARRAY8</entry>
+        <entry>No*</entry>
+      </row>
+      <row>
+        <entry>Environment</entry>
+        <entry>OS-specific</entry>
+        <entry>LISTofARRAY8</entry>
+        <entry>No</entry>
+      </row>
+      <row>
+        <entry>ProcessID</entry>
+        <entry>OS-specific</entry>
+        <entry>ARRAY8</entry>
+        <entry>No</entry>
+      </row>
+      <row>
+        <entry>Program</entry>
+        <entry>OS-specific</entry>
+        <entry>ARRAY8</entry>
+        <entry>Yes</entry>
+      </row>
+      <row>
+        <entry>RestartCommand</entry>
+        <entry>OS-specific</entry>
+        <entry>LISTofARRAY8</entry>
+        <entry>Yes</entry>
+      </row>
+      <row>
+        <entry>ResignCommand</entry>
+        <entry>OS-specific</entry>
+        <entry>LISTofARRAY8</entry>
+        <entry>No</entry>
+      </row>
+      <row>
+        <entry>RestartStyleHint</entry>
+        <entry>CARD8</entry>
+        <entry>CARD8</entry>
+        <entry>No</entry>
+      </row>
+      <row>
+        <entry>ShutdownCommand</entry>
+        <entry>OS-specific</entry>
+        <entry>LISTofARRAY8</entry>
+        <entry>No</entry>
+      </row>
+      <row>
+        <entry>UserID</entry>
+        <entry>ARRAY8</entry>
+        <entry>ARRAY8</entry>
+        <entry>Yes</entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+
+  <para>
+* Required if any state is stored in an external repository (e.g., state file).
+  </para>
+
+  <variablelist remap='IP'>
+    <varlistentry>
+      <term>CloneCommand</term>
+      <listitem> <para>
+This is like the <function>RestartCommand</function> except it
+restarts a copy of the application.  The only difference is that the
+application doesn't supply its client id at register time.  On <acronym>POSIX</acronym>
+systems the type should be a LISTofARRAY8.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>CurrentDirectory</term>
+      <listitem><para>
+On <acronym>POSIX</acronym>-based systems specifies the value of the current directory that
+needs to be set up prior to starting the program and should be of type ARRAY8.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>DiscardCommand</term>
+      <listitem><para>
+The discard command contains a command that when delivered to the host
+that the client is running on (determined from the connection), will
+cause it to discard any information about the current state.  If this
+command is not specified, the SM will assume that all of the client's
+state is encoded in the <function>Restart&shy;Command</function> On
+<acronym>POSIX</acronym> systems the type should be LISTofARRAY8.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>Environment</term>
+      <listitem><para>
+On <acronym>POSIX</acronym> based systems, this will be of type LISTofARRAY8 where the
+ARRAY8s alternate between environment variable name and environment
+variable value.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>ProcessID</term>
+      <listitem><para>
+This specifies an OS-specific identifier for the process.  On <acronym>POSIX</acronym>
+systems this should of type ARRAY8 and contain the return value of
+getpid() turned into a Latin-1 (decimal) string.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>Program</term>
+      <listitem><para>
+The name of the program that is running.  On <acronym>POSIX</acronym> systems this should
+be the first parameter passed to execve and should be of type ARRAY8.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>RestartCommand</term>
+      <listitem><para>
+The restart command contains a command that when delivered to the host
+that the client is running on (determined from the connection), will
+cause the client to restart in its current state.  On <acronym>POSIX</acronym>-based
+systems this is of type LISTofARRAY8 and each of the elements in the
+array represents an element in the argv array.  This restart command
+should ensure that the client restarts with the specified
+client-ID.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>ResignCommand</term>
+      <listitem>
+       <para>
+A client that sets the <function>RestartStyleHint</function>
+to <function>RestartAnyway</function> uses this property to specify a
+command that undoes the effect of the client and removes any saved
+state.
+       </para>
+       <note><title>Example</title><para>
+A user runs xmodmap.  xmodmap registers with the SM,
+sets <function>Restart&shy;Style&shy;Hint</function>
+to <function>Restart&shy;Anyway</function> and then terminates.  In
+order to allow the SM (at the user's request) to undo this, xmodmap
+would register a <function>Resign&shy;Command</function> that undoes
+the effects of the xmodmap.
+       </para></note>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>RestartStyleHint</term>
+      <listitem>
+       <para>
+If the RestartStyleHint property is present, it will contain the style
+of restarting the client prefers.  If this flag isn't
+specified, <function>RestartIfRunning</function> is assumed.  The
+possible values are as follows:
+       </para>
+
+<informaltable pgwide='0' frame='none'>
+  <tgroup cols='2'>
+    <colspec colname='c1' align='left'/>
+    <colspec colname='c2' align='right'/>
+    <thead>
+      <row>
+        <entry namest="c1">Name</entry>
+        <entry namest="c2">Value</entry>
+      </row>
+    </thead>
+    <tbody>
+      <row>
+        <entry namest="c1">RestartIfRunning</entry>
+        <entry namest="c2">0</entry>
+      </row>
+      <row>
+        <entry namest="c1">RestartAnyway</entry>
+        <entry namest="c2">1</entry>
+      </row>
+      <row>
+        <entry namest="c1">RestartImmediately</entry>
+        <entry namest="c2">2</entry>
+      </row>
+      <row>
+        <entry namest="c1">RestartNever</entry>
+        <entry namest="c2">3</entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+
+       <para>
+The <function>RestartIfRunning</function> style is used in the usual
+case.  The client should be restarted in the next session if it is
+connected to the session manager at the end of the current session.
+       </para>
+
+       <para>
+The <function>RestartAnyway</function> style is used to tell the SM
+that the application should be restarted in the next session even if
+it exits before the current session is terminated.  It should be noted
+that this is only a hint and the SM will follow the policies specified
+by its users in determining what applications to restart.
+       </para>
+
+       <note><title>Rationale</title><para>
+This can be specified by a client which supports (as MS-Windows
+clients do) a means for the user to indicate while exiting that
+restarting is desired.  It can also be used for clients that spawn
+other clients and then go away, but which want to be restarted.
+       </para></note>
+
+       <para>
+A client that uses <function>RestartAnyway</function> should also set
+the <function>ResignCommand</function> and <function>ShutdownCommand</function>
+properties to commands that undo the state of the client after it exits.
+       </para>
+
+       <para>
+The <function>RestartImmediately</function> style is
+like <function>RestartAnyway</function> but in addition, the client is
+meant to run continuously.  If the client exits, the SM should try to
+restart it in the current session.
+       </para>
+
+       <note><title>Advice to Implementors</title><para>
+It would be wise to sanity-check the frequency which
+which <function>RestartImmediately</function> clients are restarted,
+to avoid a sick client being restarted continuously.
+       </para></note>
+
+       <para>
+The <function>RestartNever</function> style specifies that the client
+does not wish to be restarted in the next session.
+       </para>
+
+       <note><title>Advice to Implementors</title> <para>
+This should be used rarely, if at all.  It will cause the client to be
+silently left out of sessions when they are restarted and will
+probably be confusing to users.
+       </para></note> <!-- remap='NE' -->
+       <!-- .RE -->
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>ShutdownCommand</term>
+      <listitem>
+       <para>
+This command is executed at shutdown time to clean up after a client
+that is no longer running but retained its state by
+setting <function>RestartStyleHint</function>
+to <function>RestartAnyway</function> The command must not remove any
+saved state as the client is still part of the session.
+       </para>
+       <note><title>Example</title><para>
+A client is run at start up time that turns on a camera.  This client
+then exits.  At session shutdown, the user wants the camera turned
+off.  This client would set the <function>Restart&shy;Style&shy;Hint</function>
+to <function>Restart&shy;Anyway</function> and would register a
+<function>Shutdown&shy;Command</function> that would turn off the camera.
+       </para></note>
+      </listitem>
+    </varlistentry>
+    <varlistentry>
+      <term>UserID</term>
+    <listitem><para>
+Specifies the user's ID.  On <acronym>POSIX</acronym>-based systems
+this will contain the the user's name (the <structfield>pw_name</structfield>
+field of <structname>struct passwd</structname>).
+    </para></listitem>
+    </varlistentry>
+  </variablelist>
+</chapter>
+</book>
diff --git a/include/X11/SM/SM.h b/include/X11/SM/SM.h
new file mode 100755 (executable)
index 0000000..1af5ae8
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifndef _SM_H_
+#define _SM_H_
+
+/*
+ * Protocol Version
+ */
+
+#define SmProtoMajor   1
+#define SmProtoMinor   0
+
+
+/*
+ * Interact Style
+ */
+
+#define SmInteractStyleNone    0
+#define SmInteractStyleErrors  1
+#define SmInteractStyleAny     2
+
+
+/*
+ * Dialog Type
+ */
+
+#define SmDialogError          0
+#define SmDialogNormal         1
+
+
+/*
+ * Save Type
+ */
+
+#define SmSaveGlobal   0
+#define SmSaveLocal    1
+#define SmSaveBoth     2
+
+
+/*
+ * Restart Style Hints
+ */
+
+#define SmRestartIfRunning     0
+#define SmRestartAnyway                1
+#define SmRestartImmediately   2
+#define SmRestartNever         3
+
+
+/*
+ * Property names
+ */
+
+#define SmCloneCommand         "CloneCommand"
+#define SmCurrentDirectory     "CurrentDirectory"
+#define SmDiscardCommand       "DiscardCommand"
+#define SmEnvironment          "Environment"
+#define SmProcessID            "ProcessID"
+#define SmProgram              "Program"
+#define SmRestartCommand       "RestartCommand"
+#define SmResignCommand                "ResignCommand"
+#define SmRestartStyleHint     "RestartStyleHint"
+#define SmShutdownCommand      "ShutdownCommand"
+#define SmUserID               "UserID"
+
+
+/*
+ * Property types
+ */
+
+#define SmCARD8                        "CARD8"
+#define SmARRAY8               "ARRAY8"
+#define SmLISTofARRAY8         "LISTofARRAY8"
+
+
+/*
+ * SM minor opcodes
+ */
+
+#define SM_Error                       0
+#define SM_RegisterClient              1
+#define SM_RegisterClientReply                 2
+#define SM_SaveYourself                3
+#define SM_SaveYourselfRequest                 4
+#define SM_InteractRequest             5
+#define SM_Interact                    6
+#define SM_InteractDone                7
+#define SM_SaveYourselfDone            8
+#define SM_Die                                 9
+#define SM_ShutdownCancelled           10
+#define SM_CloseConnection             11
+#define SM_SetProperties               12
+#define SM_DeleteProperties            13
+#define SM_GetProperties               14
+#define SM_PropertiesReply             15
+#define SM_SaveYourselfPhase2Request   16
+#define SM_SaveYourselfPhase2          17
+#define SM_SaveComplete                        18
+
+#endif /* _SM_H_ */
diff --git a/include/X11/SM/SMlib.h b/include/X11/SM/SMlib.h
new file mode 100755 (executable)
index 0000000..86be664
--- /dev/null
@@ -0,0 +1,543 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifndef _SMLIB_H_
+#define _SMLIB_H_
+
+#include <X11/SM/SM.h>
+#include <X11/ICE/ICElib.h>
+
+
+/*
+ * Generic SM pointer
+ */
+
+typedef IcePointer SmPointer;
+
+
+/*
+ * Connection objects.  Defined in SMlibint.h
+ */
+
+typedef struct _SmcConn *SmcConn;
+typedef struct _SmsConn *SmsConn;
+
+
+/*
+ * Session Management property
+ */
+
+typedef struct {
+    int                length;         /* length (in bytes) of the value */
+    SmPointer   value;         /* the value */
+} SmPropValue;
+
+typedef struct {
+    char       *name;          /* name of property */
+    char       *type;          /* type of property */
+    int                num_vals;       /* number of values in property */
+    SmPropValue *vals;         /* the values */
+} SmProp;
+
+
+\f
+/*
+ * SmcCloseConnection status return
+ */
+
+typedef enum {
+    SmcClosedNow,
+    SmcClosedASAP,
+    SmcConnectionInUse
+} SmcCloseStatus;
+
+
+\f
+/*
+ * Client callbacks
+ */
+
+typedef void (*SmcSaveYourselfProc) (
+    SmcConn            /* smcConn */,
+    SmPointer          /* clientData */,
+    int                /* saveType */,
+    Bool               /* shutdown */,
+    int                        /* interactStyle */,
+    Bool               /* fast */
+);
+
+typedef void (*SmcSaveYourselfPhase2Proc) (
+    SmcConn            /* smcConn */,
+    SmPointer          /* clientData */
+);
+
+typedef void (*SmcInteractProc) (
+    SmcConn            /* smcConn */,
+    SmPointer          /* clientData */
+);
+
+typedef void (*SmcDieProc) (
+    SmcConn            /* smcConn */,
+    SmPointer          /* clientData */
+);
+
+typedef void (*SmcShutdownCancelledProc) (
+    SmcConn            /* smcConn */,
+    SmPointer          /* clientData */
+);
+
+typedef void (*SmcSaveCompleteProc) (
+    SmcConn            /* smcConn */,
+    SmPointer          /* clientData */
+);
+
+typedef void (*SmcPropReplyProc) (
+    SmcConn            /* smcConn */,
+    SmPointer          /* clientData */,
+    int                        /* numProps */,
+    SmProp **          /* props */
+);
+
+
+/*
+ * Callbacks set up at SmcOpenConnection time
+ */
+
+typedef struct {
+
+    struct {
+       SmcSaveYourselfProc      callback;
+       SmPointer                client_data;
+    } save_yourself;
+
+    struct {
+       SmcDieProc               callback;
+       SmPointer                client_data;
+    } die;
+
+    struct {
+       SmcSaveCompleteProc      callback;
+       SmPointer                client_data;
+    } save_complete;
+
+    struct {
+       SmcShutdownCancelledProc callback;
+       SmPointer                client_data;
+    } shutdown_cancelled;
+
+} SmcCallbacks;
+
+#define SmcSaveYourselfProcMask                (1L << 0)
+#define SmcDieProcMask                 (1L << 1)
+#define SmcSaveCompleteProcMask                (1L << 2)
+#define SmcShutdownCancelledProcMask   (1L << 3)
+
+
+\f
+/*
+ * Session manager callbacks
+ */
+
+typedef Status (*SmsRegisterClientProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    char *             /* previousId */                                     
+);
+
+typedef void (*SmsInteractRequestProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    int                        /* dialogType */
+);
+
+typedef void (*SmsInteractDoneProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    Bool               /* cancelShutdown */
+);
+
+typedef void (*SmsSaveYourselfRequestProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    int                /* saveType */,
+    Bool               /* shutdown */,
+    int                        /* interactStyle */,
+    Bool               /* fast */,
+    Bool               /* global */
+);
+
+typedef void (*SmsSaveYourselfPhase2RequestProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */
+);
+
+typedef void (*SmsSaveYourselfDoneProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    Bool               /* success */
+);
+
+typedef void (*SmsCloseConnectionProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    int                        /* count */,
+    char **            /* reasonMsgs */
+);
+
+typedef void (*SmsSetPropertiesProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    int                        /* numProps */,
+    SmProp **          /* props */
+);
+
+typedef void (*SmsDeletePropertiesProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    int                        /* numProps */,
+    char **            /* propNames */
+);
+
+typedef void (*SmsGetPropertiesProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */
+);
+
+
+/*
+ * Callbacks set up by a session manager when a new client connects.
+ */
+
+typedef struct {
+
+    struct {
+       SmsRegisterClientProc   callback;
+       SmPointer               manager_data;
+    } register_client;
+
+    struct {
+       SmsInteractRequestProc  callback;
+       SmPointer               manager_data;
+    } interact_request;
+
+    struct {
+       SmsInteractDoneProc     callback;
+       SmPointer               manager_data;
+    } interact_done;
+
+    struct {
+       SmsSaveYourselfRequestProc      callback;
+       SmPointer                       manager_data;
+    } save_yourself_request;
+
+    struct {
+       SmsSaveYourselfPhase2RequestProc        callback;
+       SmPointer                               manager_data;
+    } save_yourself_phase2_request;
+
+    struct {
+       SmsSaveYourselfDoneProc callback;
+       SmPointer               manager_data;
+    } save_yourself_done;
+
+    struct {
+       SmsCloseConnectionProc  callback;
+       SmPointer               manager_data;
+    } close_connection;
+
+    struct {
+       SmsSetPropertiesProc    callback;
+       SmPointer               manager_data;
+    } set_properties;
+
+    struct {
+       SmsDeletePropertiesProc callback;
+       SmPointer               manager_data;
+    } delete_properties;
+
+    struct {
+       SmsGetPropertiesProc    callback;
+       SmPointer               manager_data;
+    } get_properties;
+
+} SmsCallbacks;
+
+
+#define SmsRegisterClientProcMask              (1L << 0)
+#define SmsInteractRequestProcMask             (1L << 1)
+#define SmsInteractDoneProcMask                        (1L << 2)
+#define SmsSaveYourselfRequestProcMask         (1L << 3)
+#define SmsSaveYourselfP2RequestProcMask       (1L << 4)
+#define SmsSaveYourselfDoneProcMask            (1L << 5)
+#define SmsCloseConnectionProcMask             (1L << 6)
+#define SmsSetPropertiesProcMask               (1L << 7)
+#define SmsDeletePropertiesProcMask            (1L << 8)
+#define SmsGetPropertiesProcMask               (1L << 9)
+
+
+
+typedef Status (*SmsNewClientProc) (
+    SmsConn            /* smsConn */,
+    SmPointer          /* managerData */,
+    unsigned long *    /* maskRet */,
+    SmsCallbacks *     /* callbacksRet */,
+    char **            /* failureReasonRet */
+);
+
+
+\f
+/*
+ * Error handlers
+ */
+
+typedef void (*SmcErrorHandler) (
+    SmcConn            /* smcConn */,
+    Bool               /* swap */,
+    int                        /* offendingMinorOpcode */,
+    unsigned long      /* offendingSequence */,
+    int                /* errorClass */,
+    int                        /* severity */,
+    SmPointer          /* values */
+);
+
+typedef void (*SmsErrorHandler) (
+    SmsConn            /* smsConn */,
+    Bool               /* swap */,
+    int                        /* offendingMinorOpcode */,
+    unsigned long      /* offendingSequence */,
+    int                /* errorClass */,
+    int                        /* severity */,
+    SmPointer          /* values */
+);
+
+
+\f
+/*
+ * Function Prototypes
+ */
+
+_XFUNCPROTOBEGIN
+
+extern SmcConn SmcOpenConnection (
+    char *             /* networkIdsList */,
+    SmPointer          /* context */,
+    int                        /* xsmpMajorRev */,
+    int                        /* xsmpMinorRev */,
+    unsigned long      /* mask */,
+    SmcCallbacks *     /* callbacks */,
+    char *             /* previousId */,
+    char **            /* clientIdRet */,
+    int                        /* errorLength */,
+    char *             /* errorStringRet */
+);
+
+extern SmcCloseStatus SmcCloseConnection (
+    SmcConn            /* smcConn */,
+    int                        /* count */,
+    char **            /* reasonMsgs */
+);
+
+extern void SmcModifyCallbacks (
+    SmcConn            /* smcConn */,
+    unsigned long      /* mask */,
+    SmcCallbacks *     /* callbacks */
+);
+
+extern void SmcSetProperties (
+    SmcConn            /* smcConn */,
+    int                /* numProps */,
+    SmProp **          /* props */
+);
+
+extern void SmcDeleteProperties (
+    SmcConn            /* smcConn */,
+    int                /* numProps */,
+    char **            /* propNames */
+);
+
+extern Status SmcGetProperties (
+    SmcConn            /* smcConn */,
+    SmcPropReplyProc   /* propReplyProc */,
+    SmPointer          /* clientData */
+);
+
+extern Status SmcInteractRequest (
+    SmcConn            /* smcConn */,
+    int                        /* dialogType */,
+    SmcInteractProc    /* interactProc */,
+    SmPointer          /* clientData */
+);
+
+extern void SmcInteractDone (
+    SmcConn            /* smcConn */,
+    Bool               /* cancelShutdown */
+);
+
+extern void SmcRequestSaveYourself (
+    SmcConn            /* smcConn */,
+    int                        /* saveType */,
+    Bool               /* shutdown */,
+    int                        /* interactStyle */,
+    Bool               /* fast */,
+    Bool               /* global */
+);
+
+extern Status SmcRequestSaveYourselfPhase2 (
+    SmcConn                    /* smcConn */,
+    SmcSaveYourselfPhase2Proc  /* saveYourselfPhase2Proc */,
+    SmPointer                  /* clientData */
+);
+
+extern void SmcSaveYourselfDone (
+    SmcConn            /* smcConn */,
+    Bool               /* success */
+);
+
+extern int SmcProtocolVersion (
+    SmcConn            /* smcConn */
+);
+
+extern int SmcProtocolRevision (
+    SmcConn            /* smcConn */
+);
+
+extern char *SmcVendor (
+    SmcConn            /* smcConn */
+);
+
+extern char *SmcRelease (
+    SmcConn            /* smcConn */
+);
+
+extern char *SmcClientID (
+    SmcConn            /* smcConn */
+);
+
+extern IceConn SmcGetIceConnection (
+    SmcConn            /* smcConn */
+);
+
+extern Status SmsInitialize (
+    char *                     /* vendor */,
+    char *                     /* release */,
+    SmsNewClientProc           /* newClientProc */,
+    SmPointer                  /* managerData */,
+    IceHostBasedAuthProc       /* hostBasedAuthProc */,
+    int                                /* errorLength */,
+    char *                     /* errorStringRet */
+);
+
+extern char *SmsClientHostName (
+    SmsConn            /* smsConn */
+);
+
+extern char *SmsGenerateClientID (
+    SmsConn            /* smsConn */
+);
+
+extern Status SmsRegisterClientReply (
+    SmsConn            /* smsConn */,
+    char *             /* clientId */
+);
+
+extern void SmsSaveYourself (
+    SmsConn            /* smsConn */,
+    int                        /* saveType */,
+    Bool               /* shutdown */,
+    int                        /* interactStyle */,
+    Bool               /* fast */
+);
+
+extern void SmsSaveYourselfPhase2 (
+    SmsConn            /* smsConn */
+);
+
+extern void SmsInteract (
+    SmsConn            /* smsConn */
+);
+
+extern void SmsDie (
+    SmsConn            /* smsConn */
+);
+
+extern void SmsSaveComplete (
+    SmsConn            /* smsConn */
+);
+
+extern void SmsShutdownCancelled (
+    SmsConn            /* smsConn */
+);
+
+extern void SmsReturnProperties (
+    SmsConn            /* smsConn */,
+    int                        /* numProps */,
+    SmProp **          /* props */
+);
+
+extern void SmsCleanUp (
+    SmsConn            /* smsConn */
+);
+
+extern int SmsProtocolVersion (
+    SmsConn            /* smsConn */
+);
+
+extern int SmsProtocolRevision (
+    SmsConn            /* smsConn */
+);
+
+extern char *SmsClientID (
+    SmsConn            /* smsConn */
+);
+
+extern IceConn SmsGetIceConnection (
+    SmsConn            /* smsConn */
+);
+
+extern SmcErrorHandler SmcSetErrorHandler (
+    SmcErrorHandler    /* handler */
+);
+
+extern SmsErrorHandler SmsSetErrorHandler (
+    SmsErrorHandler    /* handler */
+);
+
+extern void SmFreeProperty (
+    SmProp *           /* prop */
+);
+
+extern void SmFreeReasons (
+    int                        /* count */,
+    char **            /* reasonMsgs */
+);
+
+_XFUNCPROTOEND
+
+#endif /* _SMLIB_H_ */
diff --git a/include/X11/SM/SMproto.h b/include/X11/SM/SMproto.h
new file mode 100755 (executable)
index 0000000..228e0ce
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifndef _SMPROTO_H_
+#define _SMPROTO_H_
+
+#include <X11/Xmd.h>
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+    /* n       ARRAY8          previousId */
+} smRegisterClientMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+    /* n       ARRAY8          clientId */
+} smRegisterClientReplyMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused1[2];
+    CARD32     length B32;
+    CARD8      saveType;
+    CARD8      shutdown;
+    CARD8      interactStyle;
+    CARD8      fast;
+    CARD8      unused2[4];
+} smSaveYourselfMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused1[2];
+    CARD32     length B32;
+    CARD8      saveType;
+    CARD8      shutdown;
+    CARD8      interactStyle;
+    CARD8      fast;
+    CARD8      global;
+    CARD8      unused2[3];
+} smSaveYourselfRequestMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      dialogType;
+    CARD8      unused;
+    CARD32     length B32;
+} smInteractRequestMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+} smInteractMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      cancelShutdown;
+    CARD8      unused;
+    CARD32     length B32;
+} smInteractDoneMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8       success;
+    CARD8      unused;
+    CARD32     length B32;
+} smSaveYourselfDoneMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+} smDieMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+} smShutdownCancelledMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+    /* b       LISTofARRAY8    reasons */
+} smCloseConnectionMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+    /* a       LISTofPROPERTY  properties */
+} smSetPropertiesMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+    /* a       LISTofARRAY8    property names */
+} smDeletePropertiesMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+} smGetPropertiesMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+    /* a       LISTofPROPERTY  properties */
+} smPropertiesReplyMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+} smSaveYourselfPhase2RequestMsg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+} smSaveYourselfPhase2Msg;
+
+typedef struct {
+    CARD8      majorOpcode;
+    CARD8      minorOpcode;
+    CARD8      unused[2];
+    CARD32     length B32;
+} smSaveCompleteMsg;
+
+
+/*
+ * SIZEOF values.  These better be multiples of 8.
+ */
+
+#define sz_smRegisterClientMsg                         8
+#define sz_smRegisterClientReplyMsg            8
+#define sz_smSaveYourselfMsg                   16
+#define sz_smSaveYourselfRequestMsg            16
+#define sz_smInteractRequestMsg                8
+#define sz_smInteractMsg                       8
+#define sz_smInteractDoneMsg                   8
+#define sz_smSaveYourselfDoneMsg               8
+#define sz_smDieMsg                            8
+#define sz_smShutdownCancelledMsg              8
+#define sz_smCloseConnectionMsg                8
+#define sz_smSetPropertiesMsg                  8
+#define sz_smDeletePropertiesMsg               8
+#define sz_smGetPropertiesMsg                  8
+#define sz_smPropertiesReplyMsg                8
+#define sz_smSaveYourselfPhase2RequestMsg      8
+#define sz_smSaveYourselfPhase2Msg             8
+#define sz_smSaveCompleteMsg                   8
+
+#endif /* _SMPROTO_H_ */
diff --git a/packaging/libSM.spec b/packaging/libSM.spec
new file mode 100644 (file)
index 0000000..c3aa585
--- /dev/null
@@ -0,0 +1,75 @@
+
+Name:       libSM
+Summary:    X.Org X11 libSM runtime library
+Version:    1.2.0
+Release:    1
+Group:      System/Libraries
+License:    MIT
+URL:        http://www.x.org
+Source0:    http://xorg.freedesktop.org/releases/individual/lib/%{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  pkgconfig(uuid)
+BuildRequires:  pkgconfig(xtrans)
+BuildRequires:  pkgconfig(ice)
+BuildRequires:  pkgconfig(xproto)
+BuildRequires:  pkgconfig(xorg-macros)
+
+
+%description
+X11 Session Management library.
+
+
+%package devel
+Summary:    X.Org X11 libSM development package
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+The X.org X11 SM  development package.
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+
+%build
+
+%reconfigure --disable-static \
+    --with-libuuid
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+
+
+
+%files
+%defattr(-,root,root,-)
+%doc AUTHORS COPYING README
+%{_libdir}/libSM.so.6
+%{_libdir}/libSM.so.6.0.1
+%exclude /usr/share/doc/libSM/SMlib.xml
+%exclude /usr/share/doc/libSM/xsmp.xml
+
+
+%files devel
+%defattr(-,root,root,-)
+%dir %{_includedir}/X11/SM
+%{_includedir}/X11/SM/SM.h
+%{_includedir}/X11/SM/SMlib.h
+%{_includedir}/X11/SM/SMproto.h
+%{_libdir}/libSM.so
+%{_libdir}/pkgconfig/sm.pc
+
diff --git a/sm.pc.in b/sm.pc.in
new file mode 100644 (file)
index 0000000..ab1261e
--- /dev/null
+++ b/sm.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: SM
+Description: X Session Management Library
+Version: @PACKAGE_VERSION@
+Requires: ice xproto
+Requires.private: ice
+Cflags: -I${includedir}
+Libs: -L${libdir} -lSM
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100755 (executable)
index 0000000..1098679
--- /dev/null
@@ -0,0 +1,31 @@
+lib_LTLIBRARIES=libSM.la
+
+AM_CFLAGS= $(CWARNFLAGS) -I${top_srcdir}/include $(SM_CFLAGS) $(XTRANS_CFLAGS)
+
+if WITH_LIBUUID
+AM_CFLAGS += $(LIBUUID_CFLAGS) -DHAVE_LIBUUID
+endif
+
+libSM_la_LDFLAGS = -version-number 6:0:1 -no-undefined
+
+libSM_la_LIBADD = $(SM_LIBS) $(XTRANS_LIBS)
+
+if WITH_LIBUUID
+libSM_la_LIBADD += $(LIBUUID_LIBS)
+endif
+
+libSM_la_SOURCES = \
+       SMlibint.h \
+       sm_auth.c \
+       sm_client.c \
+       sm_error.c \
+       sm_genid.c \
+       sm_manager.c \
+       sm_misc.c \
+       sm_process.c
+
+smincludedir=$(includedir)/X11/SM
+sminclude_HEADERS=\
+       $(top_srcdir)/include/X11/SM/SM.h \
+       $(top_srcdir)/include/X11/SM/SMlib.h \
+       $(top_srcdir)/include/X11/SM/SMproto.h
diff --git a/src/SMlibint.h b/src/SMlibint.h
new file mode 100755 (executable)
index 0000000..a478b48
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifndef _SMLIBINT_H_
+#define _SMLIBINT_H_
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xmd.h>
+#include <X11/ICE/ICEmsg.h>
+#include <X11/ICE/ICEproto.h>
+#include <X11/SM/SMproto.h>
+
+#include <stdlib.h>
+
+#ifndef NULL
+#include <stddef.h>
+#endif
+
+
+/*
+ * Vendor & Release
+ */
+
+#define SmVendorString "MIT"
+#define SmReleaseString        "1.0"
+
+
+/*
+ * Pad to a 64 bit boundary
+ */
+
+#define PAD64(_bytes) ((8 - ((unsigned int) (_bytes) % 8)) % 8)
+
+#define PADDED_BYTES64(_bytes) (_bytes + PAD64 (_bytes))
+
+
+/*
+ * Pad to 32 bit boundary
+ */
+
+#define PAD32(_bytes) ((4 - ((unsigned int) (_bytes) % 4)) % 4)
+
+#define PADDED_BYTES32(_bytes) (_bytes + PAD32 (_bytes))
+
+
+/*
+ * Number of 8 byte units in _bytes.
+ */
+
+#define WORD64COUNT(_bytes) (((unsigned int) ((_bytes) + 7)) >> 3)
+
+
+/*
+ * Compute the number of bytes for an ARRAY8 representation
+ */
+
+#define ARRAY8_BYTES(_len) (4 + _len + PAD64 (4 + _len))
+
+
+
+/*
+ * Byte swapping
+ */
+
+/* byte swap a long literal */
+#define lswapl(_val) ((((_val) & 0xff) << 24) |\
+                  (((_val) & 0xff00) << 8) |\
+                  (((_val) & 0xff0000) >> 8) |\
+                  (((_val) >> 24) & 0xff))
+
+/* byte swap a short literal */
+#define lswaps(_val) ((((_val) & 0xff) << 8) | (((_val) >> 8) & 0xff))
+
+
+/*
+ * STORE macros
+ */
+
+#ifndef WORD64
+
+#define STORE_CARD32(_pBuf, _val) \
+{ \
+    *((CARD32 *) _pBuf) = _val; \
+    _pBuf += 4; \
+}
+
+#else /* WORD64 */
+
+#define STORE_CARD32(_pBuf, _val) \
+{ \
+    struct { \
+        int value   :32; \
+    } _d; \
+    _d.value = _val; \
+    memcpy (_pBuf, &_d, 4); \
+    _pBuf += 4; \
+}
+
+#endif /* WORD64 */
+
+
+/*
+ * EXTRACT macros
+ */
+
+#ifndef WORD64
+
+#define EXTRACT_CARD16(_pBuf, _swap, _val) \
+{ \
+    _val = *((CARD16 *) _pBuf); \
+    _pBuf += 2; \
+    if (_swap) \
+        _val = lswaps (_val); \
+}
+
+#define EXTRACT_CARD32(_pBuf, _swap, _val) \
+{ \
+    _val = *((CARD32 *) _pBuf); \
+    _pBuf += 4; \
+    if (_swap) \
+        _val = lswapl (_val); \
+}
+
+#else /* WORD64 */
+
+#define EXTRACT_CARD16(_pBuf, _swap, _val) \
+{ \
+    _val = *(_pBuf + 0) & 0xff;        /* 0xff incase _pBuf is signed */ \
+    _val <<= 8; \
+    _val |= *(_pBuf + 1) & 0xff;\
+    _pBuf += 2; \
+    if (_swap) \
+        _val = lswaps (_val); \
+}
+
+#define EXTRACT_CARD32(_pBuf, _swap, _val) \
+{ \
+    _val = *(_pBuf + 0) & 0xff;        /* 0xff incase _pBuf is signed */ \
+    _val <<= 8; \
+    _val |= *(_pBuf + 1) & 0xff;\
+    _val <<= 8; \
+    _val |= *(_pBuf + 2) & 0xff;\
+    _val <<= 8; \
+    _val |= *(_pBuf + 3) & 0xff;\
+    _pBuf += 4; \
+    if (_swap) \
+        _val = lswapl (_val); \
+}
+
+#endif /* WORD64 */
+
+
+/*
+ * Compute the number of bytes for a LISTofPROPERTY representation
+ */
+
+#define LISTOF_PROP_BYTES(_numProps, _props, _bytes) \
+{ \
+    int _i, _j; \
+    _bytes = 8; \
+    for (_i = 0; _i < _numProps; _i++) \
+    { \
+       _bytes += (8 + ARRAY8_BYTES (strlen (_props[_i]->name)) + \
+           ARRAY8_BYTES (strlen (_props[_i]->type))); \
+\
+       for (_j = 0; _j < _props[_i]->num_vals; _j++) \
+           _bytes += ARRAY8_BYTES (_props[_i]->vals[_j].length); \
+    } \
+}
+
+
+/*
+ * STORE FOO
+ */
+
+#define STORE_ARRAY8(_pBuf, _len, _array8) \
+{ \
+    STORE_CARD32 (_pBuf, _len); \
+    if (_len) \
+        memcpy (_pBuf, _array8, _len); \
+    _pBuf += _len + PAD64 (4 + _len); \
+}
+
+#define STORE_LISTOF_PROPERTY(_pBuf, _count, _props) \
+{ \
+    int _i, _j; \
+    STORE_CARD32 (_pBuf, _count); \
+    _pBuf += 4; \
+    for (_i = 0; _i < _count; _i++) \
+    { \
+        STORE_ARRAY8 (_pBuf, strlen (_props[_i]->name), _props[_i]->name); \
+        STORE_ARRAY8 (_pBuf, strlen (_props[_i]->type), _props[_i]->type); \
+        STORE_CARD32 (_pBuf, _props[_i]->num_vals); \
+        _pBuf += 4; \
+        for (_j = 0; _j < _props[_i]->num_vals; _j++) \
+       { \
+            STORE_ARRAY8 (_pBuf, _props[_i]->vals[_j].length, \
+               (char *) _props[_i]->vals[_j].value); \
+       } \
+    } \
+}
+
+
+/*
+ * EXTRACT FOO
+ */
+
+#define EXTRACT_ARRAY8(_pBuf, _swap, _len, _array8) \
+{ \
+    EXTRACT_CARD32 (_pBuf, _swap, _len); \
+    _array8 = (char *) malloc (_len + 1); \
+    memcpy (_array8, _pBuf, _len); \
+    _array8[_len] = '\0'; \
+    _pBuf += _len + PAD64 (4 + _len); \
+}
+
+#define EXTRACT_ARRAY8_AS_STRING(_pBuf, _swap, _string) \
+{ \
+    CARD32 _len; \
+    EXTRACT_CARD32 (_pBuf, _swap, _len); \
+    _string = (char *) malloc (_len + 1); \
+    memcpy (_string, _pBuf, _len); \
+    _string[_len] = '\0'; \
+    _pBuf += _len + PAD64 (4 + _len); \
+}
+
+#define EXTRACT_LISTOF_PROPERTY(_pBuf, _swap, _count, _props) \
+{ \
+    int _i, _j; \
+    EXTRACT_CARD32 (_pBuf, _swap, _count); \
+    _pBuf += 4; \
+    _props = (SmProp **) malloc (_count * sizeof (SmProp *)); \
+    for (_i = 0; _i < _count; _i++) \
+    { \
+        _props[_i] = (SmProp *) malloc (sizeof (SmProp)); \
+        EXTRACT_ARRAY8_AS_STRING (_pBuf, _swap, _props[_i]->name); \
+        EXTRACT_ARRAY8_AS_STRING (_pBuf, _swap, _props[_i]->type); \
+        EXTRACT_CARD32 (_pBuf, _swap, _props[_i]->num_vals); \
+        _pBuf += 4; \
+        _props[_i]->vals = (SmPropValue *) malloc ( \
+           _props[_i]->num_vals * sizeof (SmPropValue)); \
+        for (_j = 0; _j < _props[_i]->num_vals; _j++) \
+       { \
+           char *_temp; \
+            EXTRACT_ARRAY8 (_pBuf, _swap, _props[_i]->vals[_j].length, _temp);\
+           _props[_i]->vals[_j].value = (SmPointer) _temp; \
+       } \
+    } \
+}
+
+
+#define SKIP_ARRAY8(_pBuf, _swap) \
+{ \
+    CARD32 _len; \
+    EXTRACT_CARD32 (_pBuf, _swap, _len); \
+    _pBuf += _len + PAD64 (4 + _len); \
+}
+
+#define SKIP_LISTOF_PROPERTY(_pBuf, _swap) \
+{ \
+    int _i, _j; \
+    CARD32 _count; \
+    EXTRACT_CARD32 (_pBuf, _swap, _count); \
+    _pBuf += 4; \
+    for (_i = 0; _i < _count; _i++) \
+    { \
+        CARD32 _numvals; \
+        SKIP_ARRAY8 (_pBuf, _swap); \
+        SKIP_ARRAY8 (_pBuf, _swap); \
+        EXTRACT_CARD32 (_pBuf, _swap, _numvals); \
+        _pBuf += 4; \
+        for (_j = 0; _j < _numvals; _j++) \
+            SKIP_ARRAY8 (_pBuf, _swap);\
+    } \
+}
+
+
+/*
+ * Client replies not processed by callbacks (we block for them).
+ */
+
+typedef struct {
+    Status     status;         /* if 1, client successfully registered */
+    char       *client_id;
+} _SmcRegisterClientReply;
+
+
+/*
+ * Waiting for Interact
+ */
+
+typedef struct _SmcInteractWait {
+    SmcInteractProc            interact_proc;
+    SmPointer                  client_data;
+    struct _SmcInteractWait    *next;
+} _SmcInteractWait;
+
+
+/*
+ * Waiting for SaveYourselfPhase2
+ */
+
+typedef struct _SmcPhase2Wait {
+    SmcSaveYourselfPhase2Proc  phase2_proc;
+    SmPointer                  client_data;
+} _SmcPhase2Wait;
+
+
+/*
+ * Waiting for Properties Reply
+ */
+
+typedef struct _SmcPropReplyWait {
+    SmcPropReplyProc           prop_reply_proc;
+    SmPointer                  client_data;
+    struct _SmcPropReplyWait   *next;
+} _SmcPropReplyWait;
+
+
+
+/*
+ * Client connection object
+ */
+
+struct _SmcConn {
+
+    /*
+     * Some state.
+     */
+
+    unsigned int save_yourself_in_progress : 1;
+    unsigned int shutdown_in_progress : 1;
+    unsigned int unused1 : 6;               /* future use */
+    unsigned int unused2 : 8;               /* future use */
+
+
+    /*
+     * We use ICE to esablish a connection with the SM.
+     */
+
+    IceConn            iceConn;
+
+
+    /*
+     * Major and minor versions of the XSMP.
+     */
+
+    int                        proto_major_version;
+    int                        proto_minor_version;
+
+
+    /*
+     * The session manager vendor and release number.
+     */
+
+    char               *vendor;
+    char               *release;
+
+
+    /*
+     * The Client Id uniquely identifies this client to the session manager.
+     */
+
+    char               *client_id;
+
+
+    /*
+     * Callbacks to be invoked when messages arrive from the session manager.
+     * These callbacks are specified at SmcOpenConnection time.
+     */
+
+    SmcCallbacks       callbacks;
+
+
+    /*
+     * We keep track of all Interact Requests sent by the client.  When the
+     * Interact message arrives, we remove it from the list (a FIFO list
+     * is maintained).
+     */
+
+    _SmcInteractWait   *interact_waits;
+
+
+    /*
+     * If we send a SaveYourselfPhase2Request, we wait for SaveYourselfPhase2.
+     */
+
+    _SmcPhase2Wait     *phase2_wait;
+
+
+    /*
+     * We keep track of all Get Properties sent by the client.  When the
+     * Properties Reply arrives, we remove it from the list (a FIFO list
+     * is maintained).
+     */
+
+    _SmcPropReplyWait  *prop_reply_waits;
+};
+
+
+
+/*
+ * Session manager connection object
+ */
+
+struct _SmsConn {
+
+    /*
+     * Some state.
+     */
+
+    unsigned int save_yourself_in_progress : 1;
+    unsigned int can_cancel_shutdown : 1;
+    unsigned int interact_in_progress : 1;
+    unsigned int unused1 : 5;               /* future use */
+    unsigned int unused2 : 8;               /* future use */
+
+
+    /*
+     * We use ICE to esablish a connection with the client.
+     */
+
+    IceConn            iceConn;
+
+
+    /*
+     * Major and minor versions of the XSMP.
+     */
+
+    int                        proto_major_version;
+    int                        proto_minor_version;
+
+
+    /*
+     * The Client Id uniquely identifies this client to the session manager.
+     */
+
+    char               *client_id;
+
+
+    /*
+     * Callbacks to be invoked when messages arrive from the client.
+     */
+
+    SmsCallbacks       callbacks;
+
+
+    /*
+     * What type of interaction is allowed - SmInteractStyle{None,Errors,Any}
+     */
+
+    char               interaction_allowed;
+};
+
+
+
+/*
+ * Extern declarations
+ */
+extern void
+_SmcProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
+                  unsigned long length, Bool swap,
+                  IceReplyWaitInfo *replyWait, Bool *replyReadyRet);
+
+extern void
+_SmsProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
+                  unsigned long length, Bool swap);
+
+extern void
+_SmcDefaultErrorHandler(SmcConn smcConn, Bool swap, int offendingMinorOpcode,
+                       unsigned long offendingSequence, int errorClass,
+                       int severity, SmPointer values);
+
+extern void
+_SmsDefaultErrorHandler(SmsConn smsConn, Bool swap, int offendingMinorOpcode,
+                       unsigned long offendingSequence, int errorClass,
+                       int severity, SmPointer values);
+
+extern int     _SmcOpcode;
+extern int     _SmsOpcode;
+
+extern SmsNewClientProc        _SmsNewClientProc;
+extern SmPointer       _SmsNewClientData;
+
+extern SmcErrorHandler _SmcErrorHandler;
+extern SmsErrorHandler _SmsErrorHandler;
+
+#endif /* _SMLIBINT_H_ */
diff --git a/src/sm_auth.c b/src/sm_auth.c
new file mode 100755 (executable)
index 0000000..fcc180a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+
+#ifdef __UNIXOS2__
+static char dummy;
+#endif
+
+/*
+ * For now, SMlib just supports MIT-MAGIC-COOKIE-1 (defined in ICElib).
+ */
+
+
diff --git a/src/sm_client.c b/src/sm_client.c
new file mode 100644 (file)
index 0000000..a5c714f
--- /dev/null
@@ -0,0 +1,608 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+
+int    _SmcOpcode = 0;
+int    _SmsOpcode = 0;
+
+#ifndef __UNIXOS2__
+SmsNewClientProc _SmsNewClientProc;
+SmPointer        _SmsNewClientData;
+#else
+SmsNewClientProc _SmsNewClientProc = 0;
+SmPointer        _SmsNewClientData = 0;
+#endif
+
+SmcErrorHandler _SmcErrorHandler = _SmcDefaultErrorHandler;
+SmsErrorHandler _SmsErrorHandler = _SmsDefaultErrorHandler;
+
+
+static void
+set_callbacks(SmcConn smcConn, unsigned long mask, SmcCallbacks *callbacks);
+
+\f
+SmcConn
+SmcOpenConnection(char *networkIdsList, SmPointer context,
+                 int xsmpMajorRev, int xsmpMinorRev,
+                 unsigned long mask, SmcCallbacks *callbacks,
+                 char *previousId, char **clientIdRet,
+                 int errorLength, char *errorStringRet)
+{
+    SmcConn                    smcConn;
+    IceConn                    iceConn;
+    char                       *ids;
+    IceProtocolSetupStatus     setupstat;
+    int                                majorVersion;
+    int                                minorVersion;
+    char                       *vendor = NULL;
+    char                       *release = NULL;
+    smRegisterClientMsg        *pMsg;
+    char                       *pData;
+    int                                extra, len;
+    IceReplyWaitInfo           replyWait;
+    _SmcRegisterClientReply    reply;
+    Bool                       gotReply, ioErrorOccured;
+
+    const char *auth_names[] = {"MIT-MAGIC-COOKIE-1"};
+    IcePoAuthProc auth_procs[] = {_IcePoMagicCookie1Proc};
+    int auth_count = 1;
+
+    IcePoVersionRec versions[] = {
+        {SmProtoMajor, SmProtoMinor, _SmcProcessMessage}
+    };
+    int version_count = 1;
+
+
+    *clientIdRet = NULL;
+
+    if (errorStringRet && errorLength > 0)
+       *errorStringRet = '\0';
+
+    if (!_SmcOpcode)
+    {
+       /*
+        * For now, there is only one version of XSMP, so we don't
+        * have to check {xsmpMajorRev, xsmpMinorRev}.  In the future,
+        * we will check against versions and generate the list
+        * of versions the application actually supports.
+        */
+
+       if ((_SmcOpcode = IceRegisterForProtocolSetup ("XSMP",
+           SmVendorString, SmReleaseString, version_count, versions,
+            auth_count, auth_names, auth_procs, NULL)) < 0)
+       {
+           if (errorStringRet && errorLength > 0) {
+               strncpy (errorStringRet,
+                        "Could not register XSMP protocol with ICE",
+                        errorLength);
+               errorStringRet[errorLength - 1] = '\0';
+           }
+
+           return (NULL);
+       }
+    }
+
+    if (networkIdsList == NULL || *networkIdsList == '\0')
+    {
+       if ((ids = (char *) getenv ("SESSION_MANAGER")) == NULL)
+       {
+           if (errorStringRet && errorLength > 0) {
+               strncpy (errorStringRet,
+                        "SESSION_MANAGER environment variable not defined",
+                        errorLength);
+               errorStringRet[errorLength - 1] = '\0';
+           }
+           return (NULL);
+       }
+    }
+    else
+    {
+       ids = networkIdsList;
+    }
+
+    if ((iceConn = IceOpenConnection (
+       ids, context, 0, _SmcOpcode, errorLength, errorStringRet)) == NULL)
+    {
+       return (NULL);
+    }
+
+    if ((smcConn = (SmcConn) malloc (sizeof (struct _SmcConn))) == NULL)
+    {
+       if (errorStringRet && errorLength > 0) {
+           strncpy (errorStringRet, "Can't malloc", errorLength);
+           errorStringRet[errorLength - 1] = '\0';
+       }
+       IceCloseConnection (iceConn);
+       return (NULL);
+    }
+
+    setupstat = IceProtocolSetup (iceConn, _SmcOpcode,
+       (IcePointer) smcConn,
+       False /* mustAuthenticate */,
+       &majorVersion, &minorVersion,
+       &vendor, &release, errorLength, errorStringRet);
+
+    if (setupstat == IceProtocolSetupFailure ||
+       setupstat == IceProtocolSetupIOError)
+    {
+       IceCloseConnection (iceConn);
+       free ((char *) smcConn);
+       return (NULL);
+    }
+    else if (setupstat == IceProtocolAlreadyActive)
+    {
+       /*
+        * This case should never happen, because when we called
+        * IceOpenConnection, we required that the ICE connection
+        * may not already have XSMP active on it.
+        */
+
+       free ((char *) smcConn);
+       if (errorStringRet && errorLength > 0) {
+           strncpy (errorStringRet, "Internal error in IceOpenConnection",
+                    errorLength);
+           errorStringRet[errorLength - 1] = '\0';
+       }
+       return (NULL);
+    }
+
+    smcConn->iceConn = iceConn;
+    smcConn->proto_major_version = majorVersion;
+    smcConn->proto_minor_version = minorVersion;
+    smcConn->vendor = vendor;
+    smcConn->release = release;
+    smcConn->client_id = NULL;
+
+    bzero ((char *) &smcConn->callbacks, sizeof (SmcCallbacks));
+    set_callbacks (smcConn, mask, callbacks);
+
+    smcConn->interact_waits = NULL;
+    smcConn->phase2_wait = NULL;
+    smcConn->prop_reply_waits = NULL;
+
+    smcConn->save_yourself_in_progress = False;
+    smcConn->shutdown_in_progress = False;
+
+
+    /*
+     * Now register the client
+     */
+
+    if (!previousId)
+       previousId = "";
+    len = strlen (previousId);
+    extra = ARRAY8_BYTES (len);
+
+    IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+       SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+       smRegisterClientMsg, pMsg, pData);
+
+    STORE_ARRAY8 (pData, len, previousId);
+
+    IceFlush (iceConn);
+
+    replyWait.sequence_of_request = IceLastSentSequenceNumber (iceConn);
+    replyWait.major_opcode_of_request = _SmcOpcode;
+    replyWait.minor_opcode_of_request = SM_RegisterClient;
+    replyWait.reply = (IcePointer) &reply;
+
+    gotReply = False;
+    ioErrorOccured = False;
+
+    while (!gotReply && !ioErrorOccured)
+    {
+       ioErrorOccured = (IceProcessMessages (
+           iceConn, &replyWait, &gotReply) == IceProcessMessagesIOError);
+
+       if (ioErrorOccured)
+       {
+           if (errorStringRet && errorLength > 0) {
+               strncpy (errorStringRet, "IO error occured opening connection",
+                        errorLength);
+               errorStringRet[errorLength - 1] = '\0';
+           }
+           free (smcConn->vendor);
+           free (smcConn->release);
+           free ((char *) smcConn);
+
+           return (NULL);
+       }
+       else if (gotReply)
+       {
+           if (reply.status == 1)
+           {
+               /*
+                * The client successfully registered.
+                */
+
+               *clientIdRet = reply.client_id;
+
+               smcConn->client_id = (char *) malloc (
+                   strlen (*clientIdRet) + 1);
+
+               strcpy (smcConn->client_id, *clientIdRet);
+           }
+           else
+           {
+               /*
+                * Could not register the client because the previous ID
+                * was bad.  So now we register the client with the
+                * previous ID set to NULL.
+                */
+
+               extra = ARRAY8_BYTES (0);
+
+               IceGetHeaderExtra (iceConn, _SmcOpcode, SM_RegisterClient,
+                   SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
+                   smRegisterClientMsg, pMsg, pData);
+
+               STORE_ARRAY8 (pData, 0, "");
+
+               IceFlush (iceConn);
+
+               replyWait.sequence_of_request =
+                   IceLastSentSequenceNumber (iceConn);
+
+               gotReply = False;
+           }
+       }
+    }
+
+    return (smcConn);
+}
+
+
+\f
+SmcCloseStatus
+SmcCloseConnection(SmcConn smcConn, int count, char **reasonMsgs)
+{
+    IceConn                    iceConn = smcConn->iceConn;
+    smCloseConnectionMsg       *pMsg;
+    char                       *pData;
+    int                                extra, i;
+    IceCloseStatus             closeStatus;
+    SmcCloseStatus             statusRet;
+
+    extra = 8;
+
+    for (i = 0; i < count; i++)
+       extra += ARRAY8_BYTES (strlen (reasonMsgs[i]));
+
+    IceGetHeaderExtra (iceConn, _SmcOpcode, SM_CloseConnection,
+       SIZEOF (smCloseConnectionMsg), WORD64COUNT (extra),
+       smCloseConnectionMsg, pMsg, pData);
+
+    STORE_CARD32 (pData, count);
+    pData += 4;
+
+    for (i = 0; i < count; i++)
+       STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]); 
+
+    IceFlush (iceConn);
+
+    IceProtocolShutdown (iceConn, _SmcOpcode);
+    IceSetShutdownNegotiation (iceConn, False);
+    closeStatus = IceCloseConnection (iceConn);
+
+    if (smcConn->vendor)
+       free (smcConn->vendor);
+
+    if (smcConn->release)
+       free (smcConn->release);
+
+    if (smcConn->client_id)
+       free (smcConn->client_id);
+
+    if (smcConn->prop_reply_waits)
+    {
+       _SmcPropReplyWait *ptr = smcConn->prop_reply_waits;
+       _SmcPropReplyWait *next;
+
+       while (ptr)
+       {
+           next = ptr->next;
+           free ((char *) ptr);
+           ptr = next;
+       }
+       
+    }
+
+    free ((char *) smcConn);
+
+    if (closeStatus == IceClosedNow)
+       statusRet = SmcClosedNow;
+    else if (closeStatus == IceClosedASAP)
+       statusRet = SmcClosedASAP;
+    else
+       statusRet = SmcConnectionInUse;
+
+    return (statusRet);
+}
+
+
+\f
+void
+SmcModifyCallbacks(SmcConn smcConn, unsigned long mask, SmcCallbacks *callbacks)
+{
+    set_callbacks (smcConn, mask, callbacks);
+}
+
+
+\f
+void
+SmcSetProperties(SmcConn smcConn, int numProps, SmProp **props)
+{
+    IceConn            iceConn = smcConn->iceConn;
+    smSetPropertiesMsg *pMsg;
+    char               *pBuf;
+    char               *pStart;
+    int                        bytes;
+
+    IceGetHeader (iceConn, _SmcOpcode, SM_SetProperties,
+       SIZEOF (smSetPropertiesMsg), smSetPropertiesMsg, pMsg);
+
+    LISTOF_PROP_BYTES (numProps, props, bytes);
+    pMsg->length += WORD64COUNT (bytes);
+
+    pBuf = pStart = IceAllocScratch (iceConn, bytes);
+    memset(pStart, 0, bytes);
+
+    STORE_LISTOF_PROPERTY (pBuf, numProps, props);
+
+    IceWriteData (iceConn, bytes, pStart);
+    IceFlush (iceConn);
+}
+
+
+\f
+void
+SmcDeleteProperties(SmcConn smcConn, int numProps, char **propNames)
+{
+    IceConn                    iceConn = smcConn->iceConn;
+    smDeletePropertiesMsg      *pMsg;
+    char                       *pData;
+    int                                extra, i;
+
+    extra = 8;
+
+    for (i = 0; i < numProps; i++)
+       extra += ARRAY8_BYTES (strlen (propNames[i]));
+
+    IceGetHeaderExtra (iceConn, _SmcOpcode, SM_DeleteProperties,
+       SIZEOF (smDeletePropertiesMsg), WORD64COUNT (extra),
+       smDeletePropertiesMsg, pMsg, pData);
+
+    STORE_CARD32 (pData, numProps);
+    pData += 4;
+
+    for (i = 0; i < numProps; i++)
+       STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]); 
+
+    IceFlush (iceConn);
+}
+
+
+\f
+Status
+SmcGetProperties(SmcConn smcConn, SmcPropReplyProc propReplyProc,
+                SmPointer clientData)
+{
+    IceConn            iceConn = smcConn->iceConn;
+    _SmcPropReplyWait  *wait, *ptr;
+
+    if ((wait = (_SmcPropReplyWait *) malloc (
+       sizeof (_SmcPropReplyWait))) == NULL)
+    {
+       return (0);
+    }
+
+    wait->prop_reply_proc = propReplyProc;
+    wait->client_data = clientData;
+    wait->next = NULL;
+
+    ptr = smcConn->prop_reply_waits;
+    while (ptr && ptr->next)
+       ptr = ptr->next;
+
+    if (ptr == NULL)
+       smcConn->prop_reply_waits = wait;
+    else
+       ptr->next = wait;
+
+    IceSimpleMessage (iceConn, _SmcOpcode, SM_GetProperties);
+    IceFlush (iceConn);
+
+    return (1);
+}
+
+
+\f
+Status
+SmcInteractRequest(SmcConn smcConn, int dialogType,
+                  SmcInteractProc interactProc, SmPointer clientData)
+{
+    IceConn                    iceConn = smcConn->iceConn;
+    smInteractRequestMsg       *pMsg;
+    _SmcInteractWait           *wait, *ptr;
+
+    if ((wait = (_SmcInteractWait *) malloc (
+       sizeof (_SmcInteractWait))) == NULL)
+    {
+       return (0);
+    }
+
+    wait->interact_proc = interactProc;
+    wait->client_data = clientData;
+    wait->next = NULL;
+
+    ptr = smcConn->interact_waits;
+    while (ptr && ptr->next)
+       ptr = ptr->next;
+
+    if (ptr == NULL)
+       smcConn->interact_waits = wait;
+    else
+       ptr->next = wait;
+
+    IceGetHeader (iceConn, _SmcOpcode, SM_InteractRequest,
+       SIZEOF (smInteractRequestMsg), smInteractRequestMsg, pMsg);
+
+    pMsg->dialogType = dialogType;
+
+    IceFlush (iceConn);
+
+    return (1);
+}
+
+
+\f
+void
+SmcInteractDone(SmcConn smcConn, Bool cancelShutdown)
+{
+    IceConn            iceConn = smcConn->iceConn;
+    smInteractDoneMsg  *pMsg;
+
+    IceGetHeader (iceConn, _SmcOpcode, SM_InteractDone,
+       SIZEOF (smInteractDoneMsg), smInteractDoneMsg, pMsg);
+
+    pMsg->cancelShutdown = cancelShutdown;
+
+    IceFlush (iceConn);
+}
+
+
+\f
+void
+SmcRequestSaveYourself(SmcConn smcConn, int saveType, Bool shutdown,
+                      int interactStyle, Bool fast, Bool global)
+{
+    IceConn                    iceConn = smcConn->iceConn;
+    smSaveYourselfRequestMsg   *pMsg;
+
+    IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfRequest,
+       SIZEOF (smSaveYourselfRequestMsg), smSaveYourselfRequestMsg, pMsg);
+
+    pMsg->saveType = saveType;
+    pMsg->shutdown = shutdown;
+    pMsg->interactStyle = interactStyle;
+    pMsg->fast = fast;
+    pMsg->global = global;
+
+    IceFlush (iceConn);
+}
+
+
+\f
+Status
+SmcRequestSaveYourselfPhase2(SmcConn smcConn,
+                            SmcSaveYourselfPhase2Proc saveYourselfPhase2Proc,
+                            SmPointer clientData)
+{
+    IceConn            iceConn = smcConn->iceConn;
+    _SmcPhase2Wait     *wait;
+
+    if (smcConn->phase2_wait)
+       wait = smcConn->phase2_wait;
+    else
+    {
+       if ((wait = (_SmcPhase2Wait *) malloc (
+           sizeof (_SmcPhase2Wait))) == NULL)
+       {
+           return (0);
+       }
+    }
+
+    wait->phase2_proc = saveYourselfPhase2Proc;
+    wait->client_data = clientData;
+
+    smcConn->phase2_wait = wait;
+
+    IceSimpleMessage (iceConn, _SmcOpcode, SM_SaveYourselfPhase2Request);
+    IceFlush (iceConn);
+
+    return (1);
+}
+
+
+\f
+void
+SmcSaveYourselfDone(SmcConn smcConn, Bool success)
+{
+    IceConn                    iceConn = smcConn->iceConn;
+    smSaveYourselfDoneMsg      *pMsg;
+
+    IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfDone,
+       SIZEOF (smSaveYourselfDoneMsg), smSaveYourselfDoneMsg, pMsg);
+
+    pMsg->success = success;
+
+    IceFlush (iceConn);
+}
+
+
+\f
+static void
+set_callbacks(SmcConn smcConn, unsigned long mask, SmcCallbacks *callbacks)
+{
+    if (mask & SmcSaveYourselfProcMask)
+    {
+       smcConn->callbacks.save_yourself.callback =
+           callbacks->save_yourself.callback;
+       smcConn->callbacks.save_yourself.client_data =
+           callbacks->save_yourself.client_data;
+    }
+
+    if (mask & SmcDieProcMask)
+    {
+       smcConn->callbacks.die.callback = callbacks->die.callback;
+       smcConn->callbacks.die.client_data = callbacks->die.client_data;
+    }
+
+    if (mask & SmcSaveCompleteProcMask)
+    {
+       smcConn->callbacks.save_complete.callback =
+           callbacks->save_complete.callback;
+       smcConn->callbacks.save_complete.client_data =
+           callbacks->save_complete.client_data;
+    }
+
+    if (mask & SmcShutdownCancelledProcMask)
+    {
+       smcConn->callbacks.shutdown_cancelled.callback =
+           callbacks->shutdown_cancelled.callback;
+       smcConn->callbacks.shutdown_cancelled.client_data =
+           callbacks->shutdown_cancelled.client_data;
+    }
+}
diff --git a/src/sm_error.c b/src/sm_error.c
new file mode 100755 (executable)
index 0000000..0714943
--- /dev/null
@@ -0,0 +1,314 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include <stdio.h>
+
+
+\f
+/*
+ * Default Smc error handler.
+ */
+
+void
+_SmcDefaultErrorHandler(SmcConn smcConn, Bool swap, int offendingMinorOpcode,
+                       unsigned long offendingSequence, int errorClass,
+                       int severity, SmPointer values)
+{
+    char *pData = (char *) values;
+    const char *str;
+
+    switch (offendingMinorOpcode)
+    {
+        case SM_RegisterClient:
+            str = "RegisterClient";
+           break;
+        case SM_InteractRequest:
+            str = "InteractRequest";
+           break;
+        case SM_InteractDone:
+            str = "InteractDone";
+           break;
+        case SM_SaveYourselfDone:
+            str = "SaveYourselfDone";
+           break;
+        case SM_CloseConnection:
+            str = "CloseConnection";
+           break;
+        case SM_SetProperties:
+            str = "SetProperties";
+           break;
+        case SM_GetProperties:
+            str = "GetProperties";
+           break;
+       default:
+           str = "";
+       }
+
+    fprintf (stderr, "\n");
+
+    fprintf (stderr, "XSMP error:  Offending minor opcode    = %d (%s)\n",
+       offendingMinorOpcode, str);
+
+    fprintf (stderr, "             Offending sequence number = %ld\n",
+       offendingSequence);
+
+    switch (errorClass)
+    {
+        case IceBadMinor:
+            str = "BadMinor";
+            break;
+        case IceBadState:
+            str = "BadState";
+            break;
+        case IceBadLength:
+            str = "BadLength";
+            break;
+        case IceBadValue:
+            str = "BadValue";
+            break;
+       default:
+           str = "???";
+    }
+
+    fprintf (stderr, "             Error class               = %s\n", str);
+
+    if (severity == IceCanContinue)
+       str = "CanContinue";
+    else if (severity == IceFatalToProtocol)
+       str = "FatalToProtocol";
+    else if (severity == IceFatalToConnection)
+       str = "FatalToConnection";
+    else
+       str = "???";
+
+    fprintf (stderr, "             Severity                  = %s\n", str);
+
+    switch (errorClass)
+    {
+        case IceBadValue:
+        {
+           int offset, length, val;
+
+           EXTRACT_CARD32 (pData, swap, offset);
+           EXTRACT_CARD32 (pData, swap, length);
+
+           fprintf (stderr,
+               "             BadValue Offset           = %d\n", offset);
+           fprintf (stderr,
+               "             BadValue Length           = %d\n", length);
+
+           if (length <= 4)
+           {
+               if (length == 1)
+                   val = (int) *pData;
+               else if (length == 2)
+               {
+                   EXTRACT_CARD16 (pData, swap, val);
+               }
+               else
+               {
+                   EXTRACT_CARD32 (pData, swap, val);
+               }
+
+               fprintf (stderr,
+                   "             BadValue                  = %d\n", val);
+           }
+            break;
+       }
+
+       default:
+           break;
+    }
+
+    fprintf (stderr, "\n");
+
+    if (severity != IceCanContinue)
+       exit (1);
+}
+
+
+\f
+/*
+ * Default Sms error handler.
+ */
+
+void
+_SmsDefaultErrorHandler(SmsConn smsConn, Bool swap, int offendingMinorOpcode,
+                       unsigned long offendingSequence, int errorClass,
+                       int severity, SmPointer values)
+{
+    char *pData = (char *) values;
+    const char *str;
+
+    switch (offendingMinorOpcode)
+    {
+        case SM_SaveYourself:
+            str = "SaveYourself";
+           break;
+        case SM_Interact:
+            str = "Interact";
+           break;
+        case SM_Die:
+            str = "Die";
+           break;
+        case SM_ShutdownCancelled:
+            str = "ShutdownCancelled";
+           break;
+       default:
+           str = "";
+       }
+
+    fprintf (stderr, "\n");
+
+    fprintf (stderr, "XSMP error:  Offending minor opcode    = %d (%s)\n",
+       offendingMinorOpcode, str);
+
+    fprintf (stderr, "             Offending sequence number = %ld\n",
+       offendingSequence);
+
+    switch (errorClass)
+    {
+        case IceBadMinor:
+            str = "BadMinor";
+            break;
+        case IceBadState:
+            str = "BadState";
+            break;
+        case IceBadLength:
+            str = "BadLength";
+            break;
+        case IceBadValue:
+            str = "BadValue";
+            break;
+       default:
+           str = "???";
+    }
+
+    fprintf (stderr, "             Error class               = %s\n", str);
+
+    if (severity == IceCanContinue)
+       str = "CanContinue";
+    else if (severity == IceFatalToProtocol)
+       str = "FatalToProtocol";
+    else if (severity == IceFatalToConnection)
+       str = "FatalToConnection";
+    else
+       str = "???";
+
+    fprintf (stderr, "             Severity                  = %s\n", str);
+
+    switch (errorClass)
+    {
+        case IceBadValue:
+        {
+           int offset, length, val;
+
+           EXTRACT_CARD32 (pData, swap, offset);
+           EXTRACT_CARD32 (pData, swap, length);
+
+           fprintf (stderr,
+               "             BadValue Offset           = %d\n", offset);
+           fprintf (stderr,
+               "             BadValue Length           = %d\n", length);
+
+           if (length <= 4)
+           {
+               if (length == 1)
+                   val = (int) *pData;
+               else if (length == 2)
+               {
+                   EXTRACT_CARD16 (pData, swap, val);
+               }
+               else
+               {
+                   EXTRACT_CARD32 (pData, swap, val);
+               }
+
+               fprintf (stderr,
+                   "             BadValue                  = %d\n", val);
+           }
+            break;
+       }
+
+       default:
+           break;
+    }
+
+    fprintf (stderr, "\n\n");
+
+    /* don't exit() - that would kill the SM - pretty devastating */
+}
+
+
+\f
+/* 
+ * This procedure sets the Smc error handler to be the specified
+ * routine.  If NULL is passed in the default error handler is restored.
+ * The function's return value is the previous error handler.
+ */
+SmcErrorHandler
+SmcSetErrorHandler(SmcErrorHandler handler)
+{
+    SmcErrorHandler oldHandler = _SmcErrorHandler;
+
+    if (handler != NULL)
+       _SmcErrorHandler = handler;
+    else
+       _SmcErrorHandler = _SmcDefaultErrorHandler;
+
+    return (oldHandler);
+}
+
+
+\f
+/* 
+ * This procedure sets the Sms error handler to be the specified
+ * routine.  If NULL is passed in the default error handler is restored.
+ * The function's return value is the previous error handler.
+ */
+SmsErrorHandler
+SmsSetErrorHandler(SmsErrorHandler handler)
+{
+    SmsErrorHandler oldHandler = _SmsErrorHandler;
+
+    if (handler != NULL)
+       _SmsErrorHandler = handler;
+    else
+       _SmsErrorHandler = _SmsDefaultErrorHandler;
+
+    return (oldHandler);
+}
diff --git a/src/sm_genid.c b/src/sm_genid.c
new file mode 100755 (executable)
index 0000000..2cd6d26
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+
+Copyright Â© 2002 Sun Microsystems, Inc.  All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (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 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.
+
+*/
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef WIN32
+#define _WILLWINSOCK_
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#include <stdio.h>
+
+#include <time.h>
+#define Time_t time_t
+
+#ifndef WIN32
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#define XOS_USE_NO_LOCKING
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+#endif
+
+#else /* WIN32 */
+
+#include <X11/Xwinsock.h>
+#include <X11/Xw32defs.h>
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_MTSAFE_NETDBAPI
+#include <X11/Xos_r.h>
+
+#endif /* WIN32 */
+
+#ifdef MNX_TCPCONN
+#include <net/gen/netdb.h>
+
+#define TCPCONN
+#endif
+
+#if defined(HAVE_UUID_CREATE)
+#include <uuid.h>
+#elif defined(HAVE_LIBUUID)
+#include <uuid/uuid.h>
+#endif
+
+\f
+char *
+SmsGenerateClientID(SmsConn smsConn)
+{
+#if defined(HAVE_UUID_CREATE)
+    char *id;
+    char **temp;
+    uuid_t uuid;
+    uint32_t status;
+
+    uuid_create(&uuid, &status);
+
+    uuid_to_string(&uuid, &temp, &status);
+
+    if ((id = malloc (strlen (temp) + 2)) != NULL)
+    {
+        id[0] = '2';
+        strcpy (id+1, temp);
+    }
+
+    free(temp);
+
+    return id;
+#elif defined(HAVE_LIBUUID)
+    char *id;
+    char temp[256];
+    uuid_t uuid;
+
+    uuid_generate(uuid);
+
+    temp[0] = '2';
+    temp[1] = '\0';
+    uuid_unparse_lower(uuid, &temp[1]);
+
+    if ((id = malloc (strlen (temp) + 1)) != NULL)
+       strcpy (id, temp);
+
+    return id;
+#else
+#if defined(TCPCONN) || defined(STREAMSCONN)
+    static const char hex[] = "0123456789abcdef";
+    char hostname[256];
+    char address[64], *addr_ptr = address;
+    char temp[256];
+    char *id;
+    static int sequence = 0;
+
+    if (gethostname (hostname, sizeof (hostname)))
+       return (NULL);
+
+    {
+    char* inet_addr;
+    char temp[4], *ptr1, *ptr2;
+    unsigned char decimal[4];
+    int i, len;
+    struct in_addr *haddr = NULL;
+#if defined(IPv6) && defined(AF_INET6)
+    struct addrinfo *ai, *first_ai;
+    if (getaddrinfo(hostname,NULL,NULL,&ai) != 0)
+       return NULL;
+
+    for (first_ai = ai; ai != NULL; ai = ai->ai_next) {
+       if ( (ai->ai_family == AF_INET) || (ai->ai_family == AF_INET6) ) 
+           break;
+    }
+    if (ai == NULL) {
+       freeaddrinfo(first_ai);
+       return NULL;
+    } 
+
+    if (ai->ai_family == AF_INET6) {
+       unsigned char *cp = (unsigned char *) &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr.s6_addr;
+       
+       *addr_ptr++ = '6';      /* IPv6 address code */
+
+       for (i = 0 ; i < 16 ; i++) {
+            *addr_ptr++ = hex[cp[i] >> 4];
+            *addr_ptr++ = hex[cp[i] & 0x0f];
+       }
+
+        *addr_ptr++ = '\0';
+
+    } else { /* Fall through to IPv4 address handling */
+       haddr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr;
+#else
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+    _Xgethostbynameparams hparams;
+#endif
+    struct hostent *hostp;
+
+    if ((hostp = _XGethostbyname (hostname,hparams)) != NULL)
+       haddr = (struct in_addr *)(hostp->h_addr);
+    else
+       return NULL;
+#endif
+
+    inet_addr = inet_ntoa (*haddr);
+    for (i = 0, ptr1 = inet_addr; i < 3; i++)
+    {
+       ptr2 = strchr (ptr1, '.');
+       len = ptr2 - ptr1;
+       if (!ptr2 || len > 3) {
+#if defined(IPv6) && defined(AF_INET6)
+           freeaddrinfo(first_ai);
+#endif
+           return (NULL);
+       }
+       strncpy (temp, ptr1, len);
+       temp[len] = '\0';
+       decimal[i] = atoi (temp);
+       ptr1 = ptr2 + 1;
+    }
+
+    decimal[3] = atoi (ptr1);
+
+    *addr_ptr++ = '1';
+
+    for (i = 0; i < 4; i++) {
+        *addr_ptr++ = hex[decimal[i] >> 4];
+        *addr_ptr++ = hex[decimal[i] & 0x0f];
+    }
+
+    *addr_ptr++ = '\0';
+
+#if defined(IPv6) && defined(AF_INET6)
+    }
+    freeaddrinfo(first_ai);
+#endif
+    }
+
+    sprintf (temp, "1%s%.13ld%.10ld%.4d", address, (long)time((Time_t*)0),
+            (long)getpid(), sequence);
+
+    if (++sequence > 9999)
+       sequence = 0;
+
+    if ((id = malloc (strlen (temp) + 1)) != NULL)
+       strcpy (id, temp);
+
+    return (id);
+#else
+    return (NULL);
+#endif
+#endif
+}
diff --git a/src/sm_manager.c b/src/sm_manager.c
new file mode 100755 (executable)
index 0000000..14b2bea
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include <X11/Xtrans/Xtrans.h>
+
+#ifdef __UNIXWARE__
+#undef shutdown
+#endif
+
+\f
+
+static Status
+_SmsProtocolSetupProc (IceConn    iceConn,
+                      int majorVersion,
+                      int minorVersion,
+                      char *vendor,
+                      char *release,
+                      IcePointer *clientDataRet,
+                      char **failureReasonRet)
+{
+    SmsConn            smsConn;
+    unsigned long      mask;
+    Status             status;
+
+    /*
+     * vendor/release are undefined for ProtocolSetup in XSMP.
+     */
+
+    if (vendor)
+       free (vendor);
+    if (release)
+       free (release);
+
+
+    /*
+     * Allocate new SmsConn.
+     */
+
+    if ((smsConn = (SmsConn) malloc (sizeof (struct _SmsConn))) == NULL)
+    {
+       const char *str = "Memory allocation failed";
+
+       if ((*failureReasonRet = (char *) malloc (strlen (str) + 1)) != NULL)
+           strcpy (*failureReasonRet, str);
+
+       return (0);
+    }
+
+    smsConn->iceConn = iceConn;
+    smsConn->proto_major_version = majorVersion;
+    smsConn->proto_minor_version = minorVersion;
+    smsConn->client_id = NULL;
+
+    smsConn->save_yourself_in_progress = False;
+    smsConn->interaction_allowed = SmInteractStyleNone;
+    smsConn->can_cancel_shutdown = False;
+    smsConn->interact_in_progress = False;
+
+    *clientDataRet = (IcePointer) smsConn;
+
+
+    /*
+     * Now give the session manager the new smsConn and get back the
+     * callbacks to invoke when messages arrive from the client.
+     *
+     * In the future, we can use the mask return value to check
+     * if the SM is expecting an older rev of SMlib.
+     */
+
+    bzero ((char *) &smsConn->callbacks, sizeof (SmsCallbacks));
+
+    status = (*_SmsNewClientProc) (smsConn, _SmsNewClientData,
+       &mask, &smsConn->callbacks, failureReasonRet);
+
+    return (status);
+}
+
+
+\f
+
+Status
+SmsInitialize(char *vendor, char *release, SmsNewClientProc newClientProc,
+             SmPointer managerData, IceHostBasedAuthProc hostBasedAuthProc,
+             int errorLength, char *errorStringRet)
+{
+    const char *auth_names[] = {"MIT-MAGIC-COOKIE-1"};
+    IcePaAuthProc auth_procs[] = {_IcePaMagicCookie1Proc};
+    int auth_count = 1;
+
+    IcePaVersionRec versions[] = {
+        {SmProtoMajor, SmProtoMinor, _SmsProcessMessage}
+    };
+    int version_count = 1;
+
+    if (errorStringRet && errorLength > 0)
+       *errorStringRet = '\0';
+
+    if (!newClientProc)
+    {
+       if (errorStringRet && errorLength > 0) {
+           strncpy (errorStringRet,
+                    "The SmsNewClientProc callback can't be NULL",
+                    errorLength);
+           errorStringRet[errorLength - 1] = '\0';
+       }
+
+       return (0);
+    }
+
+    if (!_SmsOpcode)
+    {
+
+       if ((_SmsOpcode = IceRegisterForProtocolReply ("XSMP",
+           vendor, release, version_count, versions,
+           auth_count, auth_names, auth_procs, hostBasedAuthProc,
+           _SmsProtocolSetupProc,
+           NULL,       /* IceProtocolActivateProc - we don't care about
+                          when the Protocol Reply is sent, because the
+                          session manager can not immediately send a
+                          message - it must wait for RegisterClient. */
+           NULL        /* IceIOErrorProc */
+            )) < 0)
+       {
+           if (errorStringRet && errorLength > 0) {
+               strncpy (errorStringRet,
+                        "Could not register XSMP protocol with ICE",
+                        errorLength);
+               errorStringRet[errorLength - 1] = '\0';
+           }
+           return (0);
+       }
+    }
+
+    _SmsNewClientProc = newClientProc;
+    _SmsNewClientData = managerData;
+
+    return (1);
+}
+
+
+\f
+char *
+SmsClientHostName(SmsConn smsConn)
+{
+    return (IceGetPeerName (smsConn->iceConn));
+}
+
+
+\f
+Status
+SmsRegisterClientReply(SmsConn smsConn, char *clientId)
+{
+    IceConn                    iceConn = smsConn->iceConn;
+    int                                extra;
+    smRegisterClientReplyMsg   *pMsg;
+    char                       *pData;
+
+    if ((smsConn->client_id = (char *) malloc (strlen (clientId) + 1)) == NULL)
+    {
+       return (0);
+    }
+
+    strcpy (smsConn->client_id, clientId);
+
+    extra = ARRAY8_BYTES (strlen (clientId));
+
+    IceGetHeaderExtra (iceConn, _SmsOpcode, SM_RegisterClientReply,
+       SIZEOF (smRegisterClientReplyMsg), WORD64COUNT (extra),
+       smRegisterClientReplyMsg, pMsg, pData);
+
+    STORE_ARRAY8 (pData, strlen (clientId), clientId);
+
+    IceFlush (iceConn);
+
+    return (1);
+}
+
+
+\f
+void
+SmsSaveYourself(SmsConn smsConn, int saveType, Bool shutdown,
+               int interactStyle, Bool fast)
+{
+    IceConn            iceConn = smsConn->iceConn;
+    smSaveYourselfMsg  *pMsg;
+
+    IceGetHeader (iceConn, _SmsOpcode, SM_SaveYourself,
+       SIZEOF (smSaveYourselfMsg), smSaveYourselfMsg, pMsg);
+
+    pMsg->saveType = saveType;
+    pMsg->shutdown = shutdown;
+    pMsg->interactStyle = interactStyle;
+    pMsg->fast = fast;
+
+    IceFlush (iceConn);
+
+    smsConn->save_yourself_in_progress = True;
+
+    if (interactStyle == SmInteractStyleNone ||
+       interactStyle == SmInteractStyleErrors ||
+       interactStyle == SmInteractStyleAny)
+    {
+       smsConn->interaction_allowed = interactStyle;
+    }
+    else
+    {
+       smsConn->interaction_allowed = SmInteractStyleNone;
+    }
+
+    smsConn->can_cancel_shutdown = shutdown &&
+       (interactStyle == SmInteractStyleAny ||
+       interactStyle == SmInteractStyleErrors);
+}
+
+
+\f
+void
+SmsSaveYourselfPhase2(SmsConn smsConn)
+{
+    IceConn    iceConn = smsConn->iceConn;
+
+    IceSimpleMessage (iceConn, _SmsOpcode, SM_SaveYourselfPhase2);
+    IceFlush (iceConn);
+}
+
+
+\f
+void
+SmsInteract(SmsConn smsConn)
+{
+    IceConn    iceConn = smsConn->iceConn;
+
+    IceSimpleMessage (iceConn, _SmsOpcode, SM_Interact);
+    IceFlush (iceConn);
+
+    smsConn->interact_in_progress = True;
+}
+
+
+\f
+void
+SmsDie(SmsConn smsConn)
+{
+    IceConn    iceConn = smsConn->iceConn;
+
+    IceSimpleMessage (iceConn, _SmsOpcode, SM_Die);
+    IceFlush (iceConn);
+}
+
+
+\f
+void
+SmsSaveComplete(SmsConn smsConn)
+{
+    IceConn    iceConn = smsConn->iceConn;
+
+    IceSimpleMessage (iceConn, _SmsOpcode, SM_SaveComplete);
+    IceFlush (iceConn);
+}
+
+
+\f
+void
+SmsShutdownCancelled(SmsConn smsConn)
+{
+    IceConn    iceConn = smsConn->iceConn;
+
+    IceSimpleMessage (iceConn, _SmsOpcode, SM_ShutdownCancelled);
+    IceFlush (iceConn);
+
+    smsConn->can_cancel_shutdown = False;
+}
+
+
+\f
+void
+SmsReturnProperties(SmsConn smsConn, int numProps, SmProp **props)
+{
+    IceConn                    iceConn = smsConn->iceConn;
+    int                        bytes;
+    smPropertiesReplyMsg       *pMsg;
+    char                       *pBuf;
+    char                       *pStart;
+
+    IceGetHeader (iceConn, _SmsOpcode, SM_PropertiesReply,
+       SIZEOF (smPropertiesReplyMsg), smPropertiesReplyMsg, pMsg);
+
+    LISTOF_PROP_BYTES (numProps, props, bytes);
+    pMsg->length += WORD64COUNT (bytes);
+
+    pBuf = pStart = IceAllocScratch (iceConn, bytes);
+
+    STORE_LISTOF_PROPERTY (pBuf, numProps, props);
+
+    IceWriteData (iceConn, bytes, pStart);
+    IceFlush (iceConn);
+}
+
+
+\f
+void
+SmsCleanUp(SmsConn smsConn)
+{
+    IceProtocolShutdown (smsConn->iceConn, _SmsOpcode);
+
+    if (smsConn->client_id)
+       free (smsConn->client_id);
+
+    free ((char *) smsConn);
+}
diff --git a/src/sm_misc.c b/src/sm_misc.c
new file mode 100755 (executable)
index 0000000..bdef3dd
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+#include <stdio.h>
+
+/*
+ * Free property
+ */
+
+void
+SmFreeProperty(SmProp *prop)
+{
+    if (prop)
+    {
+       int i;
+
+       if (prop->name)
+           free (prop->name);
+       if (prop->type)
+           free (prop->type);
+       if (prop->vals)
+       {
+           for (i = 0; i < prop->num_vals; i++)
+               if (prop->vals[i].value)
+                   free ((char *) prop->vals[i].value);
+           free ((char *) prop->vals);
+       }
+
+       free ((char *) prop);
+    }
+}
+
+
+/*
+ * Free reason messages
+ */
+
+void
+SmFreeReasons(int count, char **reasonMsgs)
+{
+    if (reasonMsgs)
+    {
+       int i;
+
+       for (i = 0; i < count; i++)
+           free (reasonMsgs[i]);
+
+       free ((char *) reasonMsgs);
+    }
+}
+
+
+\f
+/*
+ * Smc informational functions
+ */
+
+int
+SmcProtocolVersion(SmcConn smcConn)
+{
+    return (smcConn->proto_major_version);
+}
+
+
+int
+SmcProtocolRevision(SmcConn smcConn)
+{
+    return (smcConn->proto_minor_version);
+}
+
+
+char *
+SmcVendor(SmcConn smcConn)
+{
+    char *string = (char *) malloc (strlen (smcConn->vendor) + 1);
+
+    strcpy (string, smcConn->vendor);
+
+    return (string);
+}
+
+
+char *
+SmcRelease(SmcConn smcConn)
+{
+    char *string = (char *) malloc (strlen (smcConn->release) + 1);
+
+    strcpy (string, smcConn->release);
+
+    return (string);
+}
+
+
+char *
+SmcClientID(SmcConn smcConn)
+{
+    char *clientId = (char *) malloc (strlen (smcConn->client_id) + 1);
+
+    strcpy (clientId, smcConn->client_id);
+
+    return (clientId);
+}
+
+
+IceConn
+SmcGetIceConnection(SmcConn smcConn)
+{
+    return (smcConn->iceConn);
+}
+
+
+\f
+/*
+ * Sms informational functions
+ */
+
+int
+SmsProtocolVersion(SmsConn smsConn)
+{
+    return (smsConn->proto_major_version);
+}
+
+
+int
+SmsProtocolRevision(SmsConn smsConn)
+{
+    return (smsConn->proto_minor_version);
+}
+
+
+char *
+SmsClientID(SmsConn smsConn)
+{
+    char *clientId = (char *) malloc (strlen (smsConn->client_id) + 1);
+
+    strcpy (clientId, smsConn->client_id);
+
+    return (clientId);
+}
+
+
+IceConn
+SmsGetIceConnection(SmsConn smsConn)
+{
+    return (smsConn->iceConn);
+}
diff --git a/src/sm_process.c b/src/sm_process.c
new file mode 100755 (executable)
index 0000000..c7c7abe
--- /dev/null
@@ -0,0 +1,872 @@
+/*
+
+Copyright 1993, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Ralph Mor, X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/SM/SMlib.h>
+#include "SMlibint.h"
+
+
+/*
+ * Check for bad length
+ */
+
+#define CHECK_SIZE_MATCH(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _severity) \
+    if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) != _expected_len) \
+    { \
+       _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \
+       return; \
+    }
+
+#define CHECK_AT_LEAST_SIZE(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _severity) \
+    if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) > _expected_len) \
+    { \
+       _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \
+       return; \
+    }
+
+#define CHECK_COMPLETE_SIZE(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _pStart, _severity) \
+    if (((PADDED_BYTES64((_actual_len)) - SIZEOF (iceMsg)) >> 3) \
+        != _expected_len) \
+    { \
+       _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \
+       IceDisposeCompleteMessage (iceConn, _pStart); \
+       return; \
+    }
+
+
+\f
+void
+_SmcProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
+                  unsigned long length, Bool swap,
+                  IceReplyWaitInfo *replyWait, Bool *replyReadyRet)
+{
+    SmcConn    smcConn = (SmcConn) clientData;
+
+    if (replyWait)
+       *replyReadyRet = False;
+
+    if (!smcConn->client_id &&
+        opcode != SM_RegisterClientReply && opcode != SM_Error)
+    {
+       _IceReadSkip (iceConn, length << 3);
+
+       _IceErrorBadState (iceConn, _SmcOpcode, opcode, IceFatalToProtocol);
+       return;
+    }
+
+    switch (opcode)
+    {
+    case SM_Error:
+    {
+       iceErrorMsg     *pMsg;
+       char            *pData;
+
+       CHECK_AT_LEAST_SIZE (iceConn, _SmcOpcode, opcode,
+           length, SIZEOF (iceErrorMsg), IceFatalToProtocol);
+
+       IceReadCompleteMessage (iceConn, SIZEOF (iceErrorMsg),
+           iceErrorMsg, pMsg, pData);
+
+       if (!IceValidIO (iceConn))
+       {
+           IceDisposeCompleteMessage (iceConn, pData);
+           return;
+       }
+
+       if (swap)
+       {
+           pMsg->errorClass = lswaps (pMsg->errorClass);
+           pMsg->offendingSequenceNum = lswapl (pMsg->offendingSequenceNum);
+       }
+
+       if (replyWait &&
+           replyWait->minor_opcode_of_request == SM_RegisterClient &&
+            pMsg->errorClass == IceBadValue &&
+           pMsg->offendingMinorOpcode == SM_RegisterClient &&
+           pMsg->offendingSequenceNum == replyWait->sequence_of_request)
+       {
+           /*
+            * For Register Client, the previous ID was bad.
+            */
+
+           _SmcRegisterClientReply *reply =
+               (_SmcRegisterClientReply *) (replyWait->reply);
+
+           reply->status = 0;
+
+           *replyReadyRet = True;
+       }
+       else
+       {
+           (*_SmcErrorHandler) (smcConn, swap,
+               pMsg->offendingMinorOpcode,
+               pMsg->offendingSequenceNum,
+               pMsg->errorClass, pMsg->severity,
+               (SmPointer) pData);
+       }
+
+       IceDisposeCompleteMessage (iceConn, pData);
+       break;
+    }
+
+    case SM_RegisterClientReply:
+
+       if (!replyWait ||
+           replyWait->minor_opcode_of_request != SM_RegisterClient)
+       {
+           _IceReadSkip (iceConn, length << 3);
+
+           _IceErrorBadState (iceConn, _SmcOpcode,
+               SM_RegisterClientReply, IceFatalToProtocol);
+       }
+        else
+       {
+           smRegisterClientReplyMsg    *pMsg;
+           char                        *pData, *pStart;
+           _SmcRegisterClientReply     *reply = 
+               (_SmcRegisterClientReply *) (replyWait->reply);
+
+#if 0 /* No-op */
+           CHECK_AT_LEAST_SIZE (iceConn, _SmcOpcode, opcode,
+               length, SIZEOF (smRegisterClientReplyMsg), IceFatalToProtocol);
+#endif
+
+           IceReadCompleteMessage (iceConn, SIZEOF (smRegisterClientReplyMsg),
+               smRegisterClientReplyMsg, pMsg, pStart);
+
+           if (!IceValidIO (iceConn))
+           {
+               IceDisposeCompleteMessage (iceConn, pStart);
+               return;
+           }
+
+           pData = pStart;
+
+           SKIP_ARRAY8 (pData, swap);          /* client id */
+
+           CHECK_COMPLETE_SIZE (iceConn, _SmcOpcode, opcode,
+               length, pData - pStart + SIZEOF (smRegisterClientReplyMsg),
+               pStart, IceFatalToProtocol);
+
+           pData = pStart;
+
+           EXTRACT_ARRAY8_AS_STRING (pData, swap, reply->client_id);
+
+           reply->status = 1;
+           *replyReadyRet = True;
+
+           IceDisposeCompleteMessage (iceConn, pStart);
+       }
+       break;
+
+    case SM_SaveYourself:
+    {
+       smSaveYourselfMsg       *pMsg;
+       unsigned char           errVal;
+       int                     errOffset = -1;
+
+       CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+           length, SIZEOF (smSaveYourselfMsg),
+           IceFatalToProtocol);
+
+       IceReadMessageHeader (iceConn, SIZEOF (smSaveYourselfMsg),
+           smSaveYourselfMsg, pMsg);
+
+       if (!IceValidIO (iceConn))
+       {
+           return;
+       }
+
+       if (pMsg->saveType != SmSaveGlobal &&
+           pMsg->saveType != SmSaveLocal &&
+           pMsg->saveType != SmSaveBoth)
+       {
+           errVal = pMsg->saveType;
+           errOffset = 8;
+       }
+       else if (pMsg->shutdown != 1 && pMsg->shutdown != 0)
+       {
+           errVal = pMsg->shutdown;
+           errOffset = 9;
+       }
+       else if (pMsg->interactStyle != SmInteractStyleNone &&
+           pMsg->interactStyle != SmInteractStyleErrors &&
+           pMsg->interactStyle != SmInteractStyleAny)
+       {
+           errVal = pMsg->interactStyle;
+           errOffset = 10;
+       }
+       else if (pMsg->fast != 1 && pMsg->fast != 0)
+       {
+           errVal = pMsg->fast;
+           errOffset = 11;
+       }
+
+       if (errOffset >= 0)
+       {
+           _IceErrorBadValue (iceConn, _SmcOpcode,
+               SM_SaveYourself, errOffset, 1, (IcePointer) &errVal);
+       }
+       else
+       {
+           (*smcConn->callbacks.save_yourself.callback) (smcConn,
+               smcConn->callbacks.save_yourself.client_data,
+                pMsg->saveType, pMsg->shutdown,
+               pMsg->interactStyle, pMsg->fast);
+
+           smcConn->save_yourself_in_progress = True;
+
+           if (pMsg->shutdown)
+               smcConn->shutdown_in_progress = True;
+       }
+       break;
+    }
+
+    case SM_SaveYourselfPhase2:
+
+       if (!smcConn->phase2_wait)
+       {
+           _IceErrorBadState (iceConn, _SmcOpcode,
+               SM_SaveYourselfPhase2, IceCanContinue);
+       }
+        else
+       {
+           CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+               length, SIZEOF (smSaveYourselfPhase2Msg),
+               IceFatalToProtocol);
+
+           (*smcConn->phase2_wait->phase2_proc) (smcConn,
+               smcConn->phase2_wait->client_data);
+
+           free ((char *) smcConn->phase2_wait);
+           smcConn->phase2_wait  = NULL;
+       }
+       break;
+
+    case SM_Interact:
+
+        if (!smcConn->interact_waits)
+       {
+           _IceErrorBadState (iceConn, _SmcOpcode,
+               SM_Interact, IceCanContinue);
+       }
+        else
+       {
+           _SmcInteractWait *next = smcConn->interact_waits->next;
+
+           CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+               length, SIZEOF (smInteractMsg),
+               IceFatalToProtocol);
+
+           (*smcConn->interact_waits->interact_proc) (smcConn,
+               smcConn->interact_waits->client_data);
+
+           free ((char *) smcConn->interact_waits);
+           smcConn->interact_waits = next;
+       }
+       break;
+
+    case SM_SaveComplete:
+
+       if (!smcConn->save_yourself_in_progress)
+       {
+           _IceErrorBadState (iceConn, _SmcOpcode,
+               SM_SaveComplete, IceCanContinue);
+       }
+       else
+       {
+           CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+               length, SIZEOF (smSaveCompleteMsg),
+               IceFatalToProtocol);
+
+           smcConn->save_yourself_in_progress = False;
+
+           (*smcConn->callbacks.save_complete.callback) (smcConn,
+               smcConn->callbacks.save_complete.client_data);
+       }
+       break;
+
+    case SM_Die:
+
+       CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+           length, SIZEOF (smDieMsg),
+           IceFatalToProtocol);
+
+       (*smcConn->callbacks.die.callback) (smcConn,
+           smcConn->callbacks.die.client_data);
+       break;
+
+    case SM_ShutdownCancelled:
+
+       if (!smcConn->shutdown_in_progress)
+       {
+           _IceErrorBadState (iceConn, _SmcOpcode,
+               SM_ShutdownCancelled, IceCanContinue);
+       }
+       else
+       {
+           CHECK_SIZE_MATCH (iceConn, _SmcOpcode, opcode,
+               length, SIZEOF (smShutdownCancelledMsg),
+               IceFatalToProtocol);
+
+           smcConn->shutdown_in_progress = False;
+
+           (*smcConn->callbacks.shutdown_cancelled.callback) (smcConn,
+               smcConn->callbacks.shutdown_cancelled.client_data);
+       }
+       break;
+
+    case SM_PropertiesReply:
+
+        if (!smcConn->prop_reply_waits)
+       {
+           _IceReadSkip (iceConn, length << 3);
+
+           _IceErrorBadState (iceConn, _SmcOpcode,
+               SM_PropertiesReply, IceCanContinue);
+       }
+        else
+       {
+           smPropertiesReplyMsg        *pMsg;
+           char                        *pData, *pStart;
+           int                         numProps;
+           SmProp                      **props = NULL;
+           _SmcPropReplyWait           *next;
+
+#if 0 /* No-op */
+           CHECK_AT_LEAST_SIZE (iceConn, _SmcOpcode, opcode,
+               length, SIZEOF (smPropertiesReplyMsg), IceFatalToProtocol);
+#endif
+
+           IceReadCompleteMessage (iceConn, SIZEOF (smPropertiesReplyMsg),
+               smPropertiesReplyMsg, pMsg, pStart);
+
+           if (!IceValidIO (iceConn))
+           {
+               IceDisposeCompleteMessage (iceConn, pStart);
+               return;
+           }
+
+           pData = pStart;
+
+           SKIP_LISTOF_PROPERTY (pData, swap);
+
+           CHECK_COMPLETE_SIZE (iceConn, _SmcOpcode, opcode,
+               length, pData - pStart + SIZEOF (smPropertiesReplyMsg),
+               pStart, IceFatalToProtocol);
+
+           pData = pStart;
+
+           EXTRACT_LISTOF_PROPERTY (pData, swap, numProps, props);
+
+           next = smcConn->prop_reply_waits->next;
+
+           (*smcConn->prop_reply_waits->prop_reply_proc) (smcConn,
+               smcConn->prop_reply_waits->client_data, numProps, props);
+
+           free ((char *) smcConn->prop_reply_waits);
+           smcConn->prop_reply_waits = next;
+
+           IceDisposeCompleteMessage (iceConn, pStart);
+       }
+       break;
+
+    default:
+    {
+       _IceErrorBadMinor (iceConn, _SmcOpcode, opcode, IceCanContinue);
+       _IceReadSkip (iceConn, length << 3);
+       break;
+    }
+    }
+}
+
+
+\f
+void
+_SmsProcessMessage(IceConn iceConn, IcePointer clientData, int opcode,
+                  unsigned long length, Bool swap)
+{
+    SmsConn    smsConn = (SmsConn) clientData;
+
+    if (!smsConn->client_id &&
+        opcode != SM_RegisterClient && opcode != SM_Error)
+    {
+       _IceReadSkip (iceConn, length << 3);
+
+       _IceErrorBadState (iceConn, _SmsOpcode, opcode, IceFatalToProtocol);
+
+       return;
+    }
+
+    switch (opcode)
+    {
+    case SM_Error:
+    {
+       iceErrorMsg     *pMsg;
+       char            *pData;
+
+       CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+           length, SIZEOF (iceErrorMsg), IceFatalToProtocol);
+
+       IceReadCompleteMessage (iceConn, SIZEOF (iceErrorMsg),
+           iceErrorMsg, pMsg, pData);
+
+       if (!IceValidIO (iceConn))
+       {
+           IceDisposeCompleteMessage (iceConn, pData);
+           return;
+       }
+
+       if (swap)
+       {
+           pMsg->errorClass = lswaps (pMsg->errorClass);
+           pMsg->offendingSequenceNum = lswapl (pMsg->offendingSequenceNum);
+       }
+
+       (*_SmsErrorHandler) (smsConn, swap,
+           pMsg->offendingMinorOpcode,
+           pMsg->offendingSequenceNum,
+           pMsg->errorClass, pMsg->severity,
+            (SmPointer) pData);
+
+       IceDisposeCompleteMessage (iceConn, pData);
+       break;
+    }
+
+    case SM_RegisterClient:
+    {
+       smRegisterClientMsg     *pMsg;
+       char                    *pData, *pStart;
+       char                    *previousId;
+       int                      idLen;
+
+#if 0 /* No-op */
+       CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+           length, SIZEOF (smRegisterClientMsg), IceFatalToProtocol);
+#endif
+
+       IceReadCompleteMessage (iceConn, SIZEOF (smRegisterClientMsg),
+           smRegisterClientMsg, pMsg, pStart);
+
+       if (!IceValidIO (iceConn))
+       {
+           IceDisposeCompleteMessage (iceConn, pStart);
+           return;
+       }
+
+       pData = pStart;
+
+       SKIP_ARRAY8 (pData, swap);      /* previous id */
+
+       CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+          length, pData - pStart + SIZEOF (smRegisterClientMsg),
+          pStart, IceFatalToProtocol);
+
+       pData = pStart;
+
+       EXTRACT_ARRAY8 (pData, swap, idLen, previousId);
+
+       if (*previousId == '\0')
+       {
+           free (previousId);
+           previousId = NULL;
+       }
+
+       if (!(*smsConn->callbacks.register_client.callback) (smsConn,
+            smsConn->callbacks.register_client.manager_data, previousId))
+       {
+           /*
+            * The previoudId was bad.  Generate BadValue error.
+            */
+
+           _IceErrorBadValue (smsConn->iceConn, _SmsOpcode, SM_RegisterClient,
+               8, ARRAY8_BYTES (idLen), (IcePointer) pStart);
+       }
+
+       IceDisposeCompleteMessage (iceConn, pStart);
+       break;
+    }
+
+    case SM_InteractRequest:
+
+        if (!smsConn->save_yourself_in_progress ||
+           smsConn->interaction_allowed == SmInteractStyleNone)
+       {
+           _IceErrorBadState (iceConn, _SmsOpcode,
+               SM_InteractRequest, IceCanContinue);
+       }
+        else
+       {
+           smInteractRequestMsg        *pMsg;
+
+           CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+               length, SIZEOF (smInteractRequestMsg),
+               IceFatalToProtocol);
+
+           IceReadSimpleMessage (iceConn, smInteractRequestMsg, pMsg);
+
+           if (pMsg->dialogType != SmDialogNormal &&
+               pMsg->dialogType != SmDialogError)
+           {
+               unsigned char errVal = pMsg->dialogType;
+
+               _IceErrorBadValue (iceConn, _SmsOpcode,
+                   SM_InteractRequest, 2, 1, (IcePointer) &errVal);
+           }
+           else if (pMsg->dialogType == SmDialogNormal &&
+               smsConn->interaction_allowed != SmInteractStyleAny)
+           {
+               _IceErrorBadState (iceConn, _SmsOpcode,
+                   SM_InteractRequest, IceCanContinue);
+           }
+           else
+           {
+               (*smsConn->callbacks.interact_request.callback) (smsConn,
+                   smsConn->callbacks.interact_request.manager_data,
+                   pMsg->dialogType);
+           }
+       }
+       break;
+
+    case SM_InteractDone:
+
+        if (!smsConn->interact_in_progress)
+       {
+           _IceErrorBadState (iceConn, _SmsOpcode,
+               SM_InteractDone, IceCanContinue);
+       }
+        else
+       {
+           smInteractDoneMsg   *pMsg;
+
+           CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+               length, SIZEOF (smInteractDoneMsg),
+               IceFatalToProtocol);
+
+           IceReadSimpleMessage (iceConn, smInteractDoneMsg, pMsg);
+
+           if (pMsg->cancelShutdown != 1 &&
+               pMsg->cancelShutdown != 0)
+           {
+               unsigned char errVal = pMsg->cancelShutdown;
+
+               _IceErrorBadValue (iceConn, _SmsOpcode,
+                   SM_InteractDone, 2, 1, (IcePointer) &errVal);
+           }
+           else if (pMsg->cancelShutdown && !smsConn->can_cancel_shutdown)
+           {
+               _IceErrorBadState (iceConn, _SmsOpcode,
+                   SM_InteractDone, IceCanContinue);
+           }
+           else
+           {
+               smsConn->interact_in_progress = False;
+
+               (*smsConn->callbacks.interact_done.callback) (smsConn,
+                   smsConn->callbacks.interact_done.manager_data,
+                   pMsg->cancelShutdown);
+           }
+       }
+       break;
+
+    case SM_SaveYourselfRequest:
+    {
+       smSaveYourselfRequestMsg        *pMsg;
+       unsigned char                   errVal;
+       int                             errOffset = -1;
+
+       CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+           length, SIZEOF (smSaveYourselfRequestMsg),
+           IceFatalToProtocol);
+
+       IceReadMessageHeader (iceConn, SIZEOF (smSaveYourselfRequestMsg),
+           smSaveYourselfRequestMsg, pMsg);
+
+       if (!IceValidIO (iceConn))
+       {
+           IceDisposeCompleteMessage (iceConn, pMsg);
+           return;
+       }
+
+       if (pMsg->saveType != SmSaveGlobal &&
+           pMsg->saveType != SmSaveLocal &&
+           pMsg->saveType != SmSaveBoth)
+       {
+           errVal = pMsg->saveType;
+           errOffset = 8;
+       }
+       else if (pMsg->shutdown != 1 && pMsg->shutdown != 0)
+       {
+           errVal = pMsg->shutdown;
+           errOffset = 9;
+       }
+       else if (pMsg->interactStyle != SmInteractStyleNone &&
+           pMsg->interactStyle != SmInteractStyleErrors &&
+           pMsg->interactStyle != SmInteractStyleAny)
+       {
+           errVal = pMsg->interactStyle;
+           errOffset = 10;
+       }
+       else if (pMsg->fast != 1 && pMsg->fast != 0)
+       {
+           errVal = pMsg->fast;
+           errOffset = 11;
+       }
+       else if (pMsg->global != 1 && pMsg->global != 0)
+       {
+           errVal = pMsg->fast;
+           errOffset = 11;
+       }
+
+       if (errOffset >= 0)
+       {
+           _IceErrorBadValue (iceConn, _SmsOpcode,
+               SM_SaveYourselfRequest, errOffset, 1, (IcePointer) &errVal);
+       }
+       else
+       {
+           (*smsConn->callbacks.save_yourself_request.callback) (smsConn,
+               smsConn->callbacks.save_yourself_request.manager_data,
+                pMsg->saveType, pMsg->shutdown, pMsg->interactStyle,
+               pMsg->fast, pMsg->global);
+       }
+       break;
+    }
+
+    case SM_SaveYourselfPhase2Request:
+
+        if (!smsConn->save_yourself_in_progress)
+       {
+           _IceErrorBadState (iceConn, _SmsOpcode,
+               SM_SaveYourselfPhase2Request, IceCanContinue);
+       }
+        else
+       {
+           CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+               length, SIZEOF (smSaveYourselfPhase2RequestMsg),
+               IceFatalToProtocol);
+
+           (*smsConn->callbacks.save_yourself_phase2_request.callback) (
+               smsConn, smsConn->callbacks.
+               save_yourself_phase2_request.manager_data);
+       }
+       break;
+
+    case SM_SaveYourselfDone:
+
+        if (!smsConn->save_yourself_in_progress)
+       {
+           _IceErrorBadState (iceConn, _SmsOpcode,
+               SM_SaveYourselfDone, IceCanContinue);
+       }
+        else
+       {
+           smSaveYourselfDoneMsg       *pMsg;
+
+           CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+               length, SIZEOF (smSaveYourselfDoneMsg),
+               IceFatalToProtocol);
+
+           IceReadSimpleMessage (iceConn, smSaveYourselfDoneMsg, pMsg);
+
+           if (pMsg->success != 1 && pMsg->success != 0)
+           {
+               unsigned char errVal = pMsg->success;
+
+               _IceErrorBadValue (iceConn, _SmsOpcode,
+                   SM_SaveYourselfDone, 2, 1, (IcePointer) &errVal);
+           }
+           else
+           {
+               smsConn->save_yourself_in_progress = False;
+               smsConn->interaction_allowed = SmInteractStyleNone;
+
+               (*smsConn->callbacks.save_yourself_done.callback) (smsConn,
+                   smsConn->callbacks.save_yourself_done.manager_data,
+                   pMsg->success);
+           }
+       }
+       break;
+
+    case SM_CloseConnection:
+    {
+       smCloseConnectionMsg    *pMsg;
+       char                    *pData, *pStart;
+       int                     count, i;
+       char                    **reasonMsgs = NULL;
+
+#if 0 /* No-op */
+       CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+           length, SIZEOF (smCloseConnectionMsg), IceFatalToProtocol);
+#endif
+
+       IceReadCompleteMessage (iceConn, SIZEOF (smCloseConnectionMsg),
+           smCloseConnectionMsg, pMsg, pStart);
+
+       if (!IceValidIO (iceConn))
+       {
+           IceDisposeCompleteMessage (iceConn, pStart);
+           return;
+       }
+
+       pData = pStart;
+
+       EXTRACT_CARD32 (pData, swap, count);
+       pData += 4;
+
+       for (i = 0; i < count; i++)
+           SKIP_ARRAY8 (pData, swap);
+
+       CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+          length, pData - pStart + SIZEOF (smCloseConnectionMsg),
+          pStart, IceFatalToProtocol);
+
+       pData = pStart + 8;
+
+       reasonMsgs = (char **) malloc (count * sizeof (char *));
+       for (i = 0; i < count; i++)
+           EXTRACT_ARRAY8_AS_STRING (pData, swap, reasonMsgs[i]);
+
+       IceDisposeCompleteMessage (iceConn, pStart);
+
+       (*smsConn->callbacks.close_connection.callback) (smsConn,
+           smsConn->callbacks.close_connection.manager_data,
+           count, reasonMsgs);
+       break;
+    }
+
+    case SM_SetProperties:
+    {
+       smSetPropertiesMsg      *pMsg;
+       char                    *pData, *pStart;
+       SmProp                  **props = NULL;
+       int                     numProps;
+       
+#if 0 /* No-op */
+       CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+           length, SIZEOF (smSetPropertiesMsg), IceFatalToProtocol);
+#endif
+
+       IceReadCompleteMessage (iceConn, SIZEOF (smSetPropertiesMsg),
+           smSetPropertiesMsg, pMsg, pStart);
+
+       if (!IceValidIO (iceConn))
+       {
+           IceDisposeCompleteMessage (iceConn, pStart);
+           return;
+       }
+
+       pData = pStart;
+
+       SKIP_LISTOF_PROPERTY (pData, swap);
+
+       CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+          length, pData - pStart + SIZEOF (smSetPropertiesMsg),
+          pStart, IceFatalToProtocol);
+
+       pData = pStart;
+
+       EXTRACT_LISTOF_PROPERTY (pData, swap, numProps, props);
+
+       (*smsConn->callbacks.set_properties.callback) (smsConn,
+           smsConn->callbacks.set_properties.manager_data, numProps, props);
+
+       IceDisposeCompleteMessage (iceConn, pStart);
+       break;
+    }
+
+    case SM_DeleteProperties:
+    {
+       smDeletePropertiesMsg   *pMsg;
+       char                    *pData, *pStart;
+       int                     count, i;
+       char                    **propNames = NULL;
+
+#if 0 /* No-op */
+       CHECK_AT_LEAST_SIZE (iceConn, _SmsOpcode, opcode,
+           length, SIZEOF (smDeletePropertiesMsg), IceFatalToProtocol);
+#endif
+
+       IceReadCompleteMessage (iceConn, SIZEOF (smDeletePropertiesMsg),
+           smDeletePropertiesMsg, pMsg, pStart);
+
+       if (!IceValidIO (iceConn))
+       {
+           IceDisposeCompleteMessage (iceConn, pStart);
+           return;
+       }
+
+       pData = pStart;
+
+       EXTRACT_CARD32 (pData, swap, count);
+       pData += 4;
+
+       for (i = 0; i < count; i++)
+           SKIP_ARRAY8 (pData, swap);  /* prop names */
+
+       CHECK_COMPLETE_SIZE (iceConn, _SmsOpcode, opcode,
+          length, pData - pStart + SIZEOF (smDeletePropertiesMsg),
+          pStart, IceFatalToProtocol);
+
+       pData = pStart + 8;
+
+       propNames = (char **) malloc (count * sizeof (char *));
+       for (i = 0; i < count; i++)
+           EXTRACT_ARRAY8_AS_STRING (pData, swap, propNames[i]);
+
+       IceDisposeCompleteMessage (iceConn, pStart);
+
+       (*smsConn->callbacks.delete_properties.callback) (smsConn,
+           smsConn->callbacks.delete_properties.manager_data,
+           count, propNames);
+
+       break;
+    }
+
+    case SM_GetProperties:
+
+       CHECK_SIZE_MATCH (iceConn, _SmsOpcode, opcode,
+           length, SIZEOF (smGetPropertiesMsg),
+           IceFatalToProtocol);
+
+       (*smsConn->callbacks.get_properties.callback) (smsConn,
+           smsConn->callbacks.get_properties.manager_data);
+       break;
+
+    default:
+    {
+       _IceErrorBadMinor (iceConn, _SmsOpcode, opcode, IceCanContinue);
+       _IceReadSkip (iceConn, length << 3);
+       break;
+    }
+    }
+}