From cd28f4b7bab152f07d55780ef4435cfac3f65870 Mon Sep 17 00:00:00 2001 From: Sehong Na Date: Sat, 31 May 2014 12:45:57 +0900 Subject: [PATCH] Initialize Tizen 2.3 --- AUTHORS | 8 + COPYING | 43 + ChangeLog | 1241 ++++++++++++++++++ INSTALL | 291 +++++ Makefile.am | 16 + README | 25 + configure.ac | 50 + doc/Makefile.am | 13 + doc/SMlib.xml | 3230 ++++++++++++++++++++++++++++++++++++++++++++++ doc/xsmp.xml | 2499 +++++++++++++++++++++++++++++++++++ docbook.am | 105 ++ include/X11/SM/SM.h | 128 ++ include/X11/SM/SMlib.h | 543 ++++++++ include/X11/SM/SMproto.h | 206 +++ packaging/libSM.spec | 74 ++ sm.pc.in | 12 + src/Makefile.am | 32 + src/SMlibint.h | 516 ++++++++ src/sm_auth.c | 45 + src/sm_client.c | 602 +++++++++ src/sm_error.c | 314 +++++ src/sm_genid.c | 248 ++++ src/sm_manager.c | 340 +++++ src/sm_misc.c | 162 +++ src/sm_process.c | 872 +++++++++++++ 25 files changed, 11615 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 README create mode 100644 configure.ac create mode 100644 doc/Makefile.am create mode 100644 doc/SMlib.xml create mode 100644 doc/xsmp.xml create mode 100644 docbook.am create mode 100644 include/X11/SM/SM.h create mode 100644 include/X11/SM/SMlib.h create mode 100644 include/X11/SM/SMproto.h create mode 100644 packaging/libSM.spec create mode 100644 sm.pc.in create mode 100644 src/Makefile.am create mode 100644 src/SMlibint.h create mode 100644 src/sm_auth.c create mode 100644 src/sm_client.c create mode 100644 src/sm_error.c create mode 100644 src/sm_genid.c create mode 100644 src/sm_manager.c create mode 100644 src/sm_misc.c create mode 100644 src/sm_process.c diff --git a/AUTHORS b/AUTHORS new file mode 100644 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 100644 index 0000000..11e2436 --- /dev/null +++ b/COPYING @@ -0,0 +1,43 @@ +Copyright (c) 2002, 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. + + +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 100644 index 0000000..6195413 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,1241 @@ +commit b3d1f4896cab54717acd691b62b7fa3122a5fd8c +Author: Alan Coopersmith +Date: Fri Mar 2 20:53:41 2012 -0800 + + libSM 1.2.1 + + Signed-off-by: Alan Coopersmith + +commit 6475d9eff0bfbb6446eff205fd52c5ba82c5819c +Author: Matt Dew +Date: Wed Jan 11 20:33:41 2012 -0700 + + informaltable cleanup + + On certain tables, add top and bottom borders to table + header and a bottom border to the table. This matches + what those tables in the old pdfs looked like. + + the prevents tables from + splitting across pages. Useful for tiny tables. + + Converting the colwidth to a floating point, + IE, 1* -> 1.0* cleans up these build errors: + WARNING: table-layout="fixed" and column-width unspecified + => falling back to proportional-column-width(1) + + Signed-off-by: Matt Dew + +commit 3ca545c7835b71b63f8c5a8f758b08418a65a5bb +Author: Alan Coopersmith +Date: Mon Dec 5 20:04:51 2011 -0800 + + unifdef -ULynx + + Signed-off-by: Alan Coopersmith + Reviewed-by: Mark Kettenis + Reviewed-by: James Cloos + +commit 4af9e4a71f7c07da86ef1940cba69e92b11ba337 +Author: Alan Coopersmith +Date: Sat Nov 19 11:33:30 2011 -0800 + + SmsInitialize: Mark vendor & release args as const char * + + Needed to fix gcc -Wwrite-strings arguments in callers such as xsm. + + Signed-off-by: Alan Coopersmith + Reviewed-by: James Cloos + +commit e77dd2e4bc8227ebdab70b4233cb33ed690fa264 +Author: Alan Coopersmith +Date: Sat Nov 19 10:33:15 2011 -0800 + + Remove a bunch of unnecessary casts with malloc & free calls + + With modern compilers and headers, they cause more problems than they + solve and just hide real issues. + + Signed-off-by: Alan Coopersmith + Reviewed-by: Mark Kettenis + Reviewed-by: James Cloos + +commit 46f3ef4460aa2c1c2cba22897694a1cea572d506 +Author: Alan Coopersmith +Date: Sat Nov 19 10:23:24 2011 -0800 + + Replace malloc(strlen) + strcpy sets with strdup calls + + Signed-off-by: Alan Coopersmith + Reviewed-by: Mark Kettenis + Reviewed-by: James Cloos + +commit fb3ef5844d392f70cc6bd9b0d8770ca17bde1428 +Author: Alan Coopersmith +Date: Sat Nov 19 10:13:02 2011 -0800 + + Reindent IPv4 code to match IPv6 code + + Takes care of the other block of code confusingly sharing indent levels + + Signed-off-by: Alan Coopersmith + Reviewed-by: James Cloos + +commit 638496507882f0afe506fe294f68ad5290ef95db +Author: Alan Coopersmith +Date: Sat Nov 19 10:07:32 2011 -0800 + + Move variable declarations to get rid of unnecessary scope brackets + + Gets rid of one of the multiple levels of bracketing that confusingly + shared the same indent level. + + Signed-off-by: Alan Coopersmith + Reviewed-by: James Cloos + +commit 9f350d75a4553d8e2bc365f8de4110bb79ec7b32 +Author: Alan Coopersmith +Date: Sat Nov 19 10:01:50 2011 -0800 + + Move and rename temp[4] definition to reduce confusion with temp[256] + + Both variables were locals in different scope levels of the same + function, leading to both confusing code and gcc -Wshadow warnings: + + sm_genid.c: In function 'SmsGenerateClientID': + sm_genid.c:160:10: warning: declaration of 'temp' shadows a previous local + + Signed-off-by: Alan Coopersmith + Reviewed-by: James Cloos + +commit 079de6fd4bd0423e20e472d7342f919eebce0517 +Author: Alan Coopersmith +Date: Sat Nov 19 09:52:17 2011 -0800 + + Use imdent to make multiple levels of nested #if easier to follow + + Signed-off-by: Alan Coopersmith + Reviewed-by: James Cloos + +commit 79c785adf86ef06f09910b68019bc8a1e6fcb122 +Author: Matt Dew +Date: Tue Oct 4 22:42:05 2011 -0600 + + Cleanup IDs and links in doc + + 1 - fix the capitalization of the ID attributes to match either the + or <funcdef> string it goes with. + 2 - fix any <linkend>'s that were affected by 1. + 3 - any <function> in the docs that has an actual funcdef, + will become an olink. + + Signed-off-by: Matt Dew <marcoz@osource.org> + +commit 4708d636de50281ab2c52c32b81b7ecb67657820 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Fri Sep 16 22:03:00 2011 -0700 + + Strip trailing whitespace + + Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' + git diff -w & git diff -b show no diffs from this change + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit 44eecd93986368e71c404d8faa264a514bf88ab1 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Wed Sep 14 14:59:27 2011 -0400 + + docs: fix author affiliation + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 7ed7ef36b7e1fdd29554db122e4eb07323e27dee +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Mon Sep 12 16:54:45 2011 -0400 + + docs: use the &fullrelvers; entity to set X11 release information + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 7601182a252b44d0b04435f1eb4d574dfcf5fabb +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Sep 11 19:49:53 2011 -0400 + + docs: remove <productnumber> which is not used by default + + This element is not rendered by default on the title. A template + customization is required to display it. + X Window System does not have a product number. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit cbca5fad657122d1a9f370d0640acb66ef80aaef +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Thu Sep 8 20:00:00 2011 -0400 + + docbook.am: embed css styles inside the HTML HEAD element + + Rather than referring to the external xorg.css stylesheet, embed the content + of the file in the html output produced. This is accomplished by using + version 1.10 of xorg-xhtml.xsl. + + This makes the whole html docs tree much more relocatable. + In addition, it eliminates xorg.css as a runtime file which makes + xorg-sgml-doctools a build time only package. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit b88a9949fa6e1b12348541c6293535cc7ff931f4 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Wed Sep 7 10:31:04 2011 -0400 + + docbook.am: global maintenance update - entities, images and olinking + + Adding support in libX11 for html chunking caused a reorg of docbook.am + as well as the xorg-sgml-doctools masterdb for olinking. + The parameter img.src.path is added for pdf images. + A searchpath to the root builddir is added for local entities, if present. + + The docbook.am makefile hides all the details and is identical for + all 22 modules having DocBook documentation. It is included by a thin + Makefile.am which requires no docbook knowledge. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 64e002e55555205fdcdb9e6d78d6eadd4136cb7a +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Jun 12 17:54:50 2011 -0400 + + Install xml versions of specs even if HAVE_XMLTO is false + + DocBook/XML input source is also a usefull output format that can be viewed + with an XML viewer or editor and by some O/S help system. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit bef231eefedae448255b705aa2f687f49e371b71 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Jun 5 16:27:36 2011 -0400 + + Install target dbs alongside generated documents + + This matches a change in xorg-sgml-docs whereby the masterdb will look for + the target dbs into the same location as the generated documents. + + The target dbs are now installed alongside the generated documents. + Previously they are installed in $prefix/sgml/X11/dbs alongside masterdb which + has the potential of installing outside the package prefix and cause + distcheck to fail when user does not have write permission in this package. + + Requires XORG_CHECK_SGML_DOCTOOLS(1.8) which was released 2011-06-11 + +commit f7473da7b1ff6a5295a145f808c327e655e574a9 +Author: Matt Dew <marcoz@osource.org> +Date: Wed May 25 23:46:36 2011 -0600 + + add id attributes to funcsynopsis to allow other docs to olink to them. + + Signed-off-by: Matt Dew <marcoz@osource.org> + Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Gaetan Nadon <memsize@videotron.ca> + +commit 8683bdd74d3e40c7db92efd25acf345f6331b252 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Feb 27 15:06:18 2011 -0500 + + Documentation: add Docbook external references support + + When writing technical documentation, it is often necessary to cross + reference to other information. When that other information is not in the + current document, additional support is needed, namely <olink>. + + A new feature with version 1.7 of xorg-sgml-doctools adds references to + other documents within or outside this package. + + This patch adds technical support for this feature but does not change + the content of the documentation as seen by the end user. + + Each book or article must generate a database containing the href + of sections that can be referred to from another document. This database + is installed in DATAROOTDIR/sgml/X11/dbs. There is a requirement that + the value of DATAROOTDIR for xorg-sgml-doctools and for the package + documentation is the same. This forms a virtual document tree. + + This database is consulted by other documents while they are being generated + in order to fulfill the missing information for linking. + Refer to the xorg-sgml-doctools for further technical information. + + Co-authored-by: Matt Dew <marcoz@osource.org> + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 252f6d2add7c926cdcf0cea43da04f182720b0b4 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Fri Feb 25 09:04:45 2011 -0500 + + Docbook: change the book id to match the xml file basename + + This is required for the up-coming external references support. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 2cd30c36c080217c20addf311510881c8eecf374 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Wed Feb 2 19:25:52 2011 -0500 + + config: splitting SM and XTRANS compiler options is not required + + Simplify configuration by using a single PKG_CHECK_MODULES statement. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 3c923881f415651d75434efd209003d602253437 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Wed Feb 2 11:43:40 2011 -0500 + + config: comment, minor upgrade, quote and layout configure.ac + + Group statements per section as per Autoconf standard layout + Quote statements where appropriate. + Autoconf recommends not using dnl instead of # for comments + + Use AC_CONFIG_FILES to replace the deprecated AC_OUTPUT with parameters. + + This helps automated maintenance and release activities. + Details can be found in http://wiki.x.org/wiki/NewModuleGuidelines + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit b29f5c9f3a728c5b7673cf54ad60d988b5dd93e7 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Thu Jan 27 22:05:40 2011 -0800 + + Bug 33390 - sm.pc: don't export a dependency on ice + + https://bugs.freedesktop.org/show_bug.cgi?id=33390 + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> + +commit fe43b6de5bb4423ce99d2df1ab37ea8ece39a9fa +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Fri Jan 28 16:07:07 2011 -0500 + + config: replace deprecated AC_HELP_STRING with AS_HELP_STRING + + This silences an Automake warning. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 57b6f700378a001e1aff9b83f6cb396c7c4a7368 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Fri Jan 28 14:59:04 2011 -0500 + + config: remove unrequired AC_HEADER_STDC + + Autoconf says: + "This macro is obsolescent, as current systems have conforming + header files. New programs need not use this macro". + +commit 8f9878c06e359d21715a3e4358895b589466bc46 +Author: Paulo Zanoni <pzanoni@mandriva.com> +Date: Thu Dec 16 14:03:06 2010 -0200 + + Use docbookx.dtd version 4.3 for all docs + + Signed-off-by: Paulo Zanoni <pzanoni@mandriva.com> + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit 6d093e2397ecdbbba044fe7ef2fd922c8c8261de +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sun Nov 21 11:19:45 2010 -0800 + + config: replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS + + Regroup AC statements under the Autoconf initialization section. + Regroup AM statements under the Automake initialization section. + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit b8ef6cea0ccae4d88a9cb91cd836188ae781cda8 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sun Nov 21 11:17:25 2010 -0800 + + config: Remove unnecessary calls from configure.ac + + AC_PROG_CC are provided by XORG_DEFAULT_OPTIONS now + PKG_CONFIG_MODULES handles AC_SUBST of the CFLAGS & LIBS variables + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit 15dc32dd7b57315f9e319f3e346ba28a1e69c646 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sun Nov 21 11:16:14 2010 -0800 + + Sun's copyrights belong to Oracle now + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit 8480764c94d15673c884b90c7a10bc86635dec63 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Tue Nov 9 13:04:40 2010 -0500 + + config: HTML file generation: use the installed copy of xorg.css + + Currenlty the xorg.css file is copied in each location + where a DocBook/XML file resides. This produces about + 70 copies in the $(docdir) install tree. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +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 → & ← + + 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 “ 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/INSTALL b/INSTALL new file mode 100644 index 0000000..8b82ade --- /dev/null +++ b/INSTALL @@ -0,0 +1,291 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008 Free Software Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `<wchar.h>' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *Note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..9cbf83d --- /dev/null +++ b/Makefile.am @@ -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/README b/README new file mode 100644 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/configure.ac b/configure.ac new file mode 100644 index 0000000..6d578e6 --- /dev/null +++ b/configure.ac @@ -0,0 +1,50 @@ + +# Initialize Autoconf +AC_PREREQ(2.60) +AC_INIT([libSM], [1.2.1], + [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libSM]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([config.h]) + +# Initialize Automake +AM_INIT_AUTOMAKE([foreign dist-bzip2]) +AM_MAINTAINER_MODE + +# Initialize libtool +AC_PROG_LIBTOOL + +# Require xorg-macros minimum of 1.12 for DocBook external references +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.12) +XORG_DEFAULT_OPTIONS +XORG_ENABLE_DOCS +XORG_WITH_XMLTO(0.0.22) +XORG_WITH_FOP +XORG_WITH_XSLTPROC +XORG_CHECK_SGML_DOCTOOLS(1.8) + +# Obtain compiler/linker options for depedencies +PKG_CHECK_MODULES(SM, [ice >= 1.0.5] xproto xtrans) + +# Needed to check for TCP & IPv6 support and set flags appropriately +XTRANS_CONNECTION_FLAGS + +AC_ARG_WITH(libuuid, AS_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_CONFIG_FILES([Makefile + doc/Makefile + src/Makefile + sm.pc]) +AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..d8a2ad0 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,13 @@ + +if ENABLE_DOCS + +# Main DocBook/XML files (DOCTYPE book) +docbook = SMlib.xml xsmp.xml + +# The location where the DocBook/XML files and their generated formats are installed +shelfdir = $(docdir) + +# Generate DocBook/XML output formats with or without stylesheets +include $(top_srcdir)/docbook.am + +endif ENABLE_DOCS diff --git a/doc/SMlib.xml b/doc/SMlib.xml new file mode 100644 index 0000000..43579f9 --- /dev/null +++ b/doc/SMlib.xml @@ -0,0 +1,3230 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" +[ +<!ENTITY % defs SYSTEM "defs.ent"> %defs; +]> + + +<!-- lifted from troff+ms+XMan by doclifter --> +<book id="SMlib"> + +<bookinfo> + <title>X Session Management Library + X Consortium Standard + X Version 11, Release &fullrelvers; + + + RalphMor + X Consortium + + + + 19931994 + X Consortium + + Version 1.0 + + + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +“Software”), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + + + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + + + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE +AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + + +X Window System is a trademark of The Open Group. + + + + + + + Overview of Session Management + + + +The purpose of the X Session Management Protocol (XSMP) +is to provide a uniform mechanism for users to save and restore their +sessions. A session is a group of clients, +each of which has a particular state. The session is controlled by a +network service called the session manager. +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. + + + +For purposes of this protocol, a client 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. + + + + + + The Session Management Library + + +The Session Management Library (SMlib) 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. + + + + + SMlib has two parts to it: + + One set of functions for clients that want to be part of a session + One set of functions for session managers to call + + + + +Some applications will use both sets of functions and act as +nested session managers. 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. + + + +Clients initialize by connecting to the session manager and obtaining +a client-ID 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 SmRestartCommand). 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 SmRestartCommand +so that the client will retain the same ID after it is restarted. + + + +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. + + + + + Understanding SMlib's Dependence on ICE + + +The X Session Management Protocol is layered on top of the +Inter-Client Exchange (ICE) 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. + + + +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 IceProcessMessages function. +IceProcessMessages 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. + + + +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 select call +on the file descriptor for the ICE connection, but more +typically, XtAppAddInput will be used to register +a callback that will invoke IceProcessMessages +each time there is data to read on the ICE connection. + + + +To further complicate things, knowing which file descriptors to +call select on requires an understanding of how +ICE connections are created. On the client side, a call must be made +to in order to open a connection +with a session manager. will +internally makea call into IceOpenConnection +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 select on. + + + +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 IceListenForConnections in order to start +listening for connections from clients. Once a connection attempt is +detected, IceAcceptConnection must be called, and +the session manager can simply add the new ICE file descriptor to the +list of descriptors to call select on. + + + + +For further information on the library functions related to ICE connections, +see the Inter-Client Exchange Library +standard. + + + + +Header Files and Library Name + + +Applications (both session managers and clients) should include the +header file <X11/SM/SMlib.h>. +This header file defines all of the SMlib data structures and function +prototypes. SMlib.h includes the +header file <X11/SM/SM.h>, +which defines all of the SMlib constants. + + + +Because SMlib is dependent on ICE, applications should link against +SMlib and ICElib by using + . + + + + + Session Management Client (<acronym>Smc</acronym>) Functions + + + This section discusses how Session Management clients: + + Connect to the Session Manager + Close the connection + Modify callbacks + Set, delete, and retrieve Session Manager properties + Interact with the user + Request a “Save Yourself” + Request a “Save Yourself Phase 2” + Complete a “Save Yourself” + Use Smc informational functions + Handle Errors + + + + +Connecting to the Session Manager + + +To open a connection with a session manager, +use + + + + + SmcConn SmcOpenConnection + char *network_ids_list + SmPointer context + int xsmp_major_rev + int xsmp_minor_rev + unsigned long mask + SmcCallbacks *callbacks + char *previous_id + char **client_id_ret + int error_length + char *error_string_ret + + + + + + network_ids_list + Specifies the network ID(s) of the session manager. + + + context + +A pointer to an opaque object or NULL. Used to determine +if an ICE connection can be shared +(see below). + + + + xsmp_major_rev + +The highest major version of the XSMP the application supports. + + + + xsmp_minor_rev + +The highest minor version of the XSMP the application supports (for +the specified xsmp_major_rev). + + + + mask + A mask indicating which callbacks to register. + + + callbacks + +The callbacks to register. These callbacks are used to respond to +messages from the session manager. + + + + previous_id + The client ID from the previous session. + + + client_id_ret + The client ID for the current session is returned. + + + error_length + Length of the error_string_ret argument passed in. + + + error_string_ret + +Returns a null-terminated error message, if any. +The error_string_ret argument points to user supplied +memory. No more than error_length bytes are used. + + + + + +The network_ids_list argument is a +null-terminated string containing a list of network IDs for the session +manager, separated by commas. If network_ids_list +is NULL, the value of +the SESSION_MANAGER environment variable will be used. +Each network ID has the following format: + + + + + + + + + tcp/<hostname>:<portnumber> + or + + + decnet/<hostname>::<objname> + or + + + local/<hostname>:<path> + + + + + + + + +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. + + + +After the connection is established, +registers the client with the session manager. If the client is being +restarted from a previous session, previous_id +should contain a null terminated string representing the client ID from the +previous session. If the client is first joining the session, +previous_id should be set to NULL. +If previous_id is specified but is determined +to be invalid by the session manager, SMlib will re-register the +client with previous_id set to NULL. + + + +If succeeds, it returns an +opaque connection pointer of type SmcConn and the +client_id_ret argument contains the client ID to be +used for this session. The client_id_ret should be +freed with a call to free when no longer needed. On +failure, returns +NULL, and the reason for failure is returned in +error_string_ret. + + + +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. + + + +The context argument indicates how willing the client is to share the +ICE connection with other protocols. If context is NULL, +then the caller is always willing to share the connection. If context is not +NULL, then the caller is not willing to use a previously +opened ICE connection that has a different non-NULL +context associated with it. + + + +As previously discussed +(section 3, +“Understanding SMlib's Dependence on ICE”), the +client will have to keep track of when ICE connections are created or +destroyed (using IceAddConnectionWatch +and IceRemoveConnectionWatch and will have to +call IceProcessMessages each time +a select shows that there is data to read on an +ICE connection. For further information, see the +Inter-Client Exchange Library +standard. + + + +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. + + + +The following values may be ORed together to obtain a +mask value: + + + SmcSaveYourselfProcMask + SmcDieProcMask + SmcSaveCompleteProcMask + SmcShutdownCancelledProcMask + + + + +For each callback, the client can register a pointer to client data. +When SMlib invokes the callback, it will pass the client data pointer. + + + + + +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; + + + +The Save Yourself Callback + + +The Save Yourself callback is of type SmcSaveYourselfProc + + + + + typedef void (*SaveYourselfProc) + SmcConn smc_conn + SmcConn client_data + int save_type + Bool shutdown + int interact_style + Bool fast + + + + + + smc_conn + The session management connection object. + + + client_data + Client data specified when the callback was registered. + + + save_type + Specifies the type of information that should be saved. + + + shut_down + Specifies if a shutdown is taking place. + + + interact_style + The type of interaction allowed with the user. + + + fast + if True, then client should save its state as quickly as possible. + + + + +The session manager sends a “Save Yourself” 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 to update the properties +indicating how to restart the client. When all the properties have +been set, the client calls + + + +If interact_style is +SmInteractStyleNone the +client must not interact with the user while saving state. +If interact_style is +SmInteractStyleErrors the +client may interact with the user only if an error condition arises. +If interact_style is +SmInteractStyleAny 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 and wait for an +“Interact” message from the session manager. When the +client is done interacting with the user, it +calls The client may only +call after it receives a +“Save Yourself” message and before it +calls + + + +If save_type is SmSaveLocal 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 save_type is SmSaveGlobal +the user wants the client to commit all of its data to permanent, globally +accessible storage. +If save_type is SmSaveBoth +the client should do both of these (it should first commit the data to +permanent storage before updating its properties). + + + +Some examples are as follows: + + + +If a word processor were sent a “Save Yourself” with a +type of SmSaveLocal 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 SmRestartCommand property with +enough information to find this temporary file. + + +If a word processor were sent a “Save Yourself” with a +type of SmSaveGlobal it would simply save the +currently edited file. + + +If a word processor were sent a “Save Yourself” with a +type of SmSaveBoth 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 +SmRestartCommand property with enough information +to find the temporary file. + + + + + +The shutdown 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 “Save Complete” message. If shutting down, the +client must save state and then prevent interaction until it receives +either a “Die” or a “Shutdown Cancelled.” + + + +The fast 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 fast to True. + + + + +The Die Callback + + +The Die callback is of type + + + + + typedef void (*SmcDieProc) + SmcConn smc_conn + SmcConn client_data + + + + + + smc_conn + The session management connection object. + + + client_data + Client data specified when the callback was registered. + + + + + +The session manager sends a “Die” message to a client when +it wants it to die. The client should respond by calling +. A session manager that +behaves properly will send a “Save Yourself” message +before the “Die” message. + + + + +The Save Complete Callback + + +The Save Complete callback is of type + + + + + typedef void (*SmcSaveCompleteProc) + SmcConn smc_conn + SmPointer client_data + + + + + + smc_conn + The session management connection object. + + + client_data + Client data specified when the callback was registered. + + + + + + +The Shutdown Cancelled Callback + + +The Shutdown Cancelled callback is of type + + + + + + typedef void (*SmcShutdownCancelledProc) + SmcConn smc_conn + SmPointer client_data + + + + + + smc_conn + The session management connection object. + + + client_data + Client data specified when the callback was registered. + + + + +The session manager sends a “Shutdown Cancelled” message +when the user cancelled the shutdown during an interaction +(see section 5.5, +“Interacting With the User”). The client can now +continue as if the shutdown had never happened. If the client has not +called yet, it can either +abort the save and then call +with the success argument set to False or it can +continue with the save and then call +with the success argument set to reflect the outcome +of the save. + + + + + +Closing the Connection + + +To close a connection with a session manager, +use + + + + + SmcCloseStatus SmcCloseConnection + SmcConn smc_conn + int count + char **reason_msgs + + + + + smc_conn + The session management connection object. + + + count + The number of reasons for closing the connection. + + + reason_msgs + The reasons for closing the connection. + + + + +The reason_msgs argument will most likely be +NULL 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. + + + +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 is called, the ICE +connection will be closed only if all protocols have been shutdown on +the connection. Check the ICElib standard +for IceAddConnectionWatch +and IceRemoveConnectionWatch 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 select on +(or calls XtAppAddInput or +XtRemoveInput). + + + + + returns one of the following values: + + + +SmcClosedNow - the ICE connection was closed at +this time, the watch procedures were invoked, and the connection was freed. + + +SmcClosedASAP - an IO error had occurred on the +connection, but is being +called within a nested IceProcessMessages 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 IceProcessMessages returns a status +of IceProcessMessagesConnectionClosed + + +SmcConnectionInUse - the connection was not closed at +this time, because it is being used by other active protocols. + + + + + + + +Modifying Callbacks + + +To modify callbacks set up in +use + + + + + void SmcModifyCallbacks + SmcConn smc_conn + unsigned long mask + SmcCallbacks *callbacks + + + + + smc_conn + The session management connection object. + + + mask + A mask indicating which callbacks to modify. + + + callbacks + The new callbacks. + + + + +When specifying a value for the mask argument, +the following values may be ORed together: + + + SmcSaveYourselfProcMask + SmcDieProcMask + SmcSaveCompleteProcMask + SmcShutdownCancelledProcMask + + + + + +Setting, Deleting, and Retrieving Session Management Properties + + +To set session management properties for this client, +use + + + + + void SmcSetProperties + SmcConn smc_conn + int num_props + SmProp **props + + + + + + smc_conn + The session management connection object. + + + num_props + The number of properties. + + + props + The list of properties to set. + + + + + +The properties are specified as an array of property pointers. +Previously set property values may be over-written using +the 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. + + + +For a description of session management properties and +the SmProp structure, +see section 7, +“Session Management Properties.” + + + + +To delete properties previously set by the client, +use + + + + + void SmcDeleteProperties + SmcConn smc_conn + int num_props + char **prop_names + + + + + smc_conn + The session management connection object. + + + num_props + The number of properties. + + + prop_names + The list of properties to set. + + + + +To get properties previously stored by the client, +use + + + + + Status SmcGetProperties + SmcConn smc_conn + SmcPropReplyProc prop_reply_proc + SmPointer client_data + + + + + + smc_conn + The session management connection object. + + + prop_reply_proc + The callback to be invoked when the properties reply comes back. + + + client_data + This pointer to client data will be passed to the callback. + + + + +The return value of is zero for +failure and a positive value for success. + + + +Note that the library does not block until the properties reply comes +back. Rather, a callback of type +is invoked when the data is ready. + + + + + typedef void (*SmcPropReplyProc) + SmcConn smc_conn + SmPointer client_data + int num_props + SmProp **props + + + + + + smc_conn + The session management connection object. + + + client_data + This pointer to client data will be passed to the callback. + + + num_props + The number of properties returned. + + + props + The list of properties returned. + + + + +To free each property, use +(see section 8, “Freeing +Data”). To free the actual array of pointers, +use free + + + + +Interacting With the User + + +After receiving a “Save Yourself” message with an +interact_style of +SmInteractStyleErrors +or SmInteractStyleAny 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 +and wait for an “Interact” message from the session manager. + + + + + Status SmcInteractRequest + SmcConn smc_conn + int dialog_type + SmcInteractProc interact_proc + SmPointer client_data + + + + + + smc_conn + The session management connection object. + + + dialog_type + The type of dialog the client wishes to present to the user. + + + interact_proc + The callback to be invoked when the “Interact” message arrives from the session manager. + + + client_data + +This pointer to client data will be passed to +the callback when the +“Interact” message arrives. + + + + + +The return value of is zero +for failure and a positive value for success. + + + +The dialog_type argument specifies +either SmDialogError indicating that the client +wants to start an error dialog, or SmDialogNormal +meaning that the client wishes to start a nonerror dialog. + + + +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 +“Shutdown Cancelled” message instead of the +“Interact” message. + + + +The callback will be invoked when +the “Interact” message arrives from the session manager. + + + + + typedef void (*SmcInteractProc) + SmcConn smc_conn + SmPointer client_data + + + + + + smc_conn + The session management connection object. + + + client_data + Client data specified when the callback was registered. + + + + +After interacting with the user (in response to an “Interact” +message), you should call + + + + + void SmcInteractDone + SmcConn smc_conn + Bool cancel_shutdown + + + + + + smc_conn + The session management connection object. + + + cancel_shutdown + If True, indicates that the user requests that the entire shutdown be cancelled. + + + +The cancel_shutdown argument may only be +True if the corresponding “Save Yourself” +specified True for shutdown +and SmInteractStyleErrors +or SmInteractStyleAny for +the interact_style. + + + + +Requesting a Save Yourself + + +To request a checkpoint from the session manager, +use + + + + + void SmcRequestSaveYourself + SmcConn smc_conn + int save_type + Bool shutdown + int interact_style + Bool fast + Bool global + + + + + + + smc_conn + The session management connection object. + + + save_type + Specifies the type of information that should be saved. + + + shutdown + Specifies if a shutdown is taking place. + + + interact_style + The type of interaction allowed with the user. + + + fast + If True the client should save its state as quickly as possible. + + + global + Controls who gets the “Save Yourself.” + + + + +The save_type, shutdown, +interact_style, and fast +arguments are discussed in more detail in +section 5.1.1, +“The Save Yourself Callback.” + + + +If global is set to True then +the resulting “Save Yourself” should be sent to all clients in the +session. For example, a vendor of a Uninterruptible Power Supply +(UPS) 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. + + + +If global is set to False then the “Save +Yourself” should only be sent to the client that requested it. + + + + +Requesting a Save Yourself Phase 2 + + +In response to a “Save Yourself”, 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 + + + + + Status SmcRequestSaveYourselfPhase2 + SmcConn smc_conn + SmcSaveYourselfPhase2Proc save_yourself_phase2_proc + SmPointer client_data + + + + + + smc_conn + The session management connection object. + + + save_type_phase2_proc + The callback to be invoked when the “Save Yourself Phase 2” message arrives from the session manager. + + + client_data + This pointer to client data will be passed to the SmcSaveYourselfPhase2Proc callback when the “Save Yourself Phase 2” message arrives. + + + + +The return value of +is zero for failure and a positive value for success. + + + +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. + + + + +Completing a Save Yourself + + +After saving state in response to a “Save Yourself” +message, you should call + + + + + void SmcSaveYourselfDone + SmcConn smc_conn + Bool success + + + + + + smc_conn + The session management connection object. + + + success + If True the “Save Yourself” operation was completed successfully. + + + + +Before calling the client +must have set each required property at least once since the client +registered with the session manager. + + + + +Using Smc Informational Functions + + + + int SmcProtocolVersion + SmcConn smc_conn + + + + + returns the major version of +the session management protocol associated with this session. + + + + + + int SmcProtocolRevision + SmcConn smc_conn + + + + + returns the minor version of +the session management protocol associated with this session. + + + + + char *SmcVendor + SmcConn smc_conn + + + + + returns a string that provides some +identification of the owner of the session manager. The string should +be freed with a call to free + + + + + char *SmcRelease + SmcConn smc_conn + + + + + returns a string that provides the +release number of the session manager. The string should be freed +with a call to free + + + + + char *SmcClientID + SmcConn smc_conn + + + + + returns a null-terminated string for +the client ID associated with this connection. This information was +also returned in (it is +provided here for convenience). Call free on +this pointer when the client ID is no longer needed. + + + + + IceConn SmcGetIceConnection + SmcConn smc_conn + + + + + 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 IceConnectionNumber, +IceConnectionString, +IceLastSentSequenceNumber, +IceLastReceivedSequenceNumber, +and IcePing. For further information, see +the Inter-Client Exchange Library +standard. + + + + +Error Handling + + +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 stderr and exits if the severity of the error +is fatal. The client can change this error handler by calling +the function. + + + + + SmcErrorHandler SmcSetErrorHandler + SmcErrorHandler handler + + + + +The error handler. You should pass NULL to +restore the default handler. + + + + + returns the previous error handler. + + + +The has the following type: + + + + + typedef void (*SmcErrorHandler) + SmcConn smc_conn + Bool swap + int offending_minor_opcode + unsigned long offending_sequence_num + int error_class + int severity + IcePointer values + + + + + + smc_conn + The session management connection object. + + + swap + A flag that indicates if the specified values need byte swapping. + + + offending_minor_opcode + The minor opcode of the offending message. + + + offending_sequence_num + The sequence number of the offending message. + + + error_class + The error class of the offending message. + + + severity + IceCanContinue, + IceFatalToProtocol, or + IceFatalToConnection + + + + values + Any additional error values specific to the minor opcode and class. + + + + +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 +IceSetIOErrorHandler For further information, see +the Inter-Client Exchange Library +standard. + + + + + + Session Management Server (<acronym>Sms</acronym>) Functions + + +This section discusses how Session Management servers: + + + Initialize the library + Register the client + Send a “Save Yourself” message + Send a “Save Yourself Phase 2” message + Send an “Interact” message + Send a “Save Complete” message + Send a “Die” message + Cancel a shutdown + Return properties + Ping a client + Clean up after a client disconnects + Use Sms informational functions + Handle errors + + + + +Initializing the Library + + + 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. + + + + + Status SmsInitialize + const char *vendor + const char *release + SmsNewClientProc new_client_proc + SmPointer manager_data + IceHostBasedAuthProc host_based_auth_proc + int error_length + char *error_string_ret + + + + + + + + vendor + A string specifying the session manager vendor. + + + release + A string specifying the session manager release number. + + + new_client_proc + Callback to be invoked each time a new client connects to the session manager. + + + manager_data + When the callback is invoked, this pointer to manager data will be passed. + + + host_based_auth_proc + Host based authentication callback. + + + error_length + Length of the error_string_ret argument passed in. + + + error_string_ret + +Returns a null-terminated error message, if any. +The error_string_ret points to user supplied memory. +No more than error_length bytes are used. + + + + + +After the function is called, the +session manager should call the IceListenForConnections +function to listen for new connections. Afterwards, each time a +client connects, the session manager should +call IceAcceptConnection + + + +See section 9, +“Authentication of Clients,” for more details on +authentication (including host based authentication). Also see +the Inter-Client Exchange +Library standard for further details on listening for and +accepting ICE connections. + + + +Each time a new client connects to the session manager, +the 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. + + + + + typedef Status (*SmsNewClientProc) + SmsConn sms_conn + SmPointer manager_data + unsigned long *mask_ret + SmsCallbacks *callbacks_ret + char **failure_reason_ret + + + + + + sms_conn + A new opaque connection object. + + + manager_data + Manager data specified when the callback was registered. + + + mask_ret + On return, indicates which callbacks were set by the session manager. + + + callbacks_ret + On return, contains the callbacks registered by the session manager. + + + failure_reason_ret + Failure reason returned. + + + + +If a failure occurs, the should +return a zero status as well as allocate and return a failure reason +string in failure_reason_ret. +SMlib will be responsible for freeing this memory. + + + +The session manager must register a set of callbacks to respond to +client events. The mask_ret argument specifies +which callbacks are set. All of the callbacks specified in this version of +SMlib are mandatory. The mask_ret argument is +necessary in order to maintain backwards compatibility in future versions +of the library. + + + +The following values may be ORed together to obtain a mask value: + + + SmsRegisterClientProcMask + SmsInteractRequestProcMask + SmsInteractDoneProcMask + SmsSaveYourselfRequestProcMask + SmsSaveYourselfP2RequestProcMask + SmsSaveYourselfDoneProcMask + SmsCloseConnectionProcMask + SmsSetPropertiesProcMask + SmsDeletePropertiesProcMask + SmsGetPropertiesProcMask + + + + +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. + + + +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; + + + +The Register Client Callback + + +The Register Client callback is the first callback that will be +invoked after the client connects to the session manager. Its type +is + + + + + typedef Status (*SmsRegisterClientProc) + SmsConn sms_conn + SmPointer manager_data + char *previous_id + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + previous_id + The client ID from the previous session. + + + + +Before any further interaction takes place with the client, the client +must be registered with the session manager. + + + +If the client is being restarted from a previous session, +previous_id will contain a null-terminated string +representing the client ID from the previous session. +Call free on the previous_id +pointer when it is no longer needed. If the client is first joining the +session, previous_id will be NULL. + + + +If previous_id 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 NULL. + + + +Otherwise, the session manager should register the client with a unique +client ID by calling the +function (to be discussed shortly), and the + callback should return a +status of one. + + + + +The Interact Request Callback + + +The Interact Request callback is of +type + + + + + typedef void (*SmsInteractRequestProc) + SmsConn sms_conn + SmPointer manager_data + int dialog_type + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + dialog_type + The type of dialog the client wishes to present to the user. + + + + +When a client receives a “Save Yourself” message with an +interact_style of +SmInteractStyleErrors +or SmInteractStyleAny 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 “Interact” message to one +client at a time and wait for an “Interact Done” message +before continuing with the next client. + + + +The dialog_type argument specifies +either SmDialogError indicating that the client +wants to start an error dialog, or SmDialogNormal +meaning that the client wishes to start a nonerror dialog. + + + +If a shutdown is in progress, the user may have the option of +cancelling the shutdown. If the shutdown is cancelled (specified in +the “Interact Done” message), the session manager should +send a “Shutdown Cancelled” message to each client that +requested to interact. + + + + +The Interact Done Callback + + +When the client is done interacting with the user, +the callback will be invoked. + + + + + typedef void (*SmsInteractDoneProc) + SmsConn sms_conn + SmPointer manager_data + Bool cancel_shutdown + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + cancel_shutdown + Specifies if the user requests that the entire shutdown be cancelled. + + + + +Note that the shutdown can be cancelled only if the corresponding +“Save Yourself” specified True for +shutdown and SmInteractStyleErrors +or SmInteractStyleAny for the +interact_style. + + + + + +The Save Yourself Request Callback + + +The Save Yourself Request callback is of +type SmsSaveYourselfRequestProc + + + + + typedef void (*SaveYourselfRequestProc) + SmsConn sms_conn + SmPointer manager_data + int save_type + Bool shutdown + int interact_style + Bool fast + Bool global + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + save_type + Specifies the type of information that should be saved. + + + shutdown + Specifies if a shutdown is taking place. + + + interact_style + The type of interaction allowed with the user. + + + fast + If True the client should save its state as quickly as possible. + + + global + Controls who gets the “Save Yourself.” + + + + +The Save Yourself Request prompts the session manager to initiate a +checkpoint or shutdown. For information on the +save_type, shutdown, +interact_style, and fast +arguments, see section 6.3, +“Sending a Save Yourself Message.” + + + +If global is set to True then the +resulting “Save Yourself” should be sent to all applications. +If global is set to False then the +“Save Yourself” should only be sent to the client that requested it. + + + + +The Save Yourself Phase 2 Request Callback + + +The Save Yourself Phase 2 Request callback is of +type + + + + + typedef void (*SmsSaveYourselfPhase2RequestProc) + SmsConn sms_conn + SmPointer manager_data + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + + +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. + + + + +The Save Yourself Done Callback + + +When the client is done saving its state in response to a +“Save Yourself” message, +the SmsSaveYourselfDoneProc will be invoked. + + + + + typedef void (*SaveYourselfDoneProc) + SmsConn sms_conn + SmPointer manager_data + Bool success + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + success + If True the Save Yourself operation was completed successfully. + + + + +Before the “Save Yourself Done” was sent, the client must +have set each required property at least once since it registered with +the session manager. + + + + +The Connection Closed Callback + + +If the client properly terminates (that is, it +calls , +the callback is invoked. + + + + + typedef void (*SmsCloseConnectionProc) + SmsConn sms_conn + SmPointer manager_data + int count + char **reason_msgs + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + count + The number of reason messages. + + + reason_msgs + The reasons for closing the connection. + + + + +The reason_msgs argument will most likely +be NULL and the count +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. + + + +Call to free the reason messages. +For further information, see +section 8, “Freeing Data” + + + + +The Set Properties Callback + + +When the client sets session management properties, +the callback will be invoked. + + + + + typedef void (*SmsSetPropertiesProc) + SmsConn sms_conn + SmPointer manager_data + int num_props + SmProp **props + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + num_props + The number of properties. + + + props + The list of properties to set. + + + + +The properties are specified as an array of property pointers. For a +description of session management properties and +the SmProp structure, +see section 7, +“Session Management Properties.” + + + +Previously set property values may be over-written. Some properties +have predefined semantics. The session manager is required to store +nonpredefined properties. + + + +To free each property, use . +For further information, see section 8, +“Freeing Data” You should free the actual array of +pointers with a call to free + + + + +The Delete Properties Callback + + +When the client deletes session management properties, +the callback will be invoked. + + + + + typedef void (*SmsDeletePropertiesProc) + SmsConn sms_conn + SmPointer manager_data + int num_props + char **prop_names + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + num_props + The number of properties. + + + prop_names + The list of properties to delete. + + + + +The properties are specified as an array of strings. For a +description of session management properties and +the SmProp structure, +see section 7, +“Session Management Properties.” + + + + +The Get Properties Callback + + +The callback is invoked when +the client wants to retrieve properties it set. + + + + + typedef void (*SmsGetPropertiesProc) + SmsConn sms_conn + SmPointer manager_data + + + + + + sms_conn + The session management connection object. + + + manager_data + Manager data specified when the callback was registered. + + + + +The session manager should respond by +calling . +All of the properties set for this client should be returned. + + + + + +Registering the Client + + +To register a client (in response to +a callback), +use . + + + + + Status SmsRegisterClientReply + SmsConn sms_conn + char *client_id + + + + + + sms_conn + The session management connection object. + + + client_id + A null-terminated string representing a unique client ID. + + + + +The return value of 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. + + + +If a non-NULL previous_id was +specified when the client registered itself, client_id +should be identical to previous_id. + + + +Otherwise, client_id should be a unique ID freshly +generated by the session manager. In addition, the session manager should +send a “Save Yourself” message with +type = Local, +shutdown = False, +interact-style = None, +and fast = False +immediately after registering the client. + + + +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. + + + +You should call the function +to generate a globally unique client ID. + + + + + char *SmsGenerateClientID + SmsConn sms_conn + + + + + + sms_conn + The session management connection object. + + + + + +NULL 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 free when +no longer needed. + + + + +Sending a Save Yourself Message + + +To send a “Save Yourself” to a client, +use . + + + + + void SmsSaveYourself + SmsConn sms_conn + int save_type + Bool shutdown + int interact_style + Bool fast + + + + + + sms_conn + The session management connection object. + + + save_type + Specifies the type of information that should be saved. + + + shutdown + Specifies if a shutdown is taking place. + + + interact_style + The type of interaction allowed with the user. + + + fast + If True the client should save its state as quickly as possible. + + + + + +The session manager sends a “Save Yourself” 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 “Set +Properties” messages to update the properties indicating how to +restart the client. When all the properties have been set, the client +sends a “Save Yourself Done” message. + + + +If interact_style +is SmInteractStyleNone the +client must not interact with the user while saving state. +If interact_style +is SmInteractStyleErrors the +client may interact with the user only if an error condition arises. +If interact_style +is SmInteractStyleAny then the +client may interact with the user for any purpose. The client must +send an “Interact Request” message and wait for an +“Interact” 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 “Interact Done” message. The +“Interact Request” message can be sent any time after a +“Save Yourself” and before a “Save Yourself +Done.” + + + +If save_type is SmSaveLocal +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 save_type is SmSaveGlobal +the user wants the client to commit all of its data to permanent, globally +accessible storage. +If save_type is SmSaveBoth +the client should do both of these (it should first commit the data to +permanent storage before updating its properties). + + + +The shutdown 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 +“Die” or a “Shutdown Cancelled,” because +anything the user does after the save will be lost. + + + +The fast 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 fast +to True. + + + + +Sending a Save Yourself Phase 2 Message + + +In order to send a “Save Yourself Phase 2” message to a +client, use + + + + + void SmsSaveYourselfPhase2 + SmsConn sms_conn + + + + + + sms_conn + The session management connection object. + + + + +The session manager sends this message to a client that has previously +sent a “Save Yourself Phase 2 Request” 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. + + + + +Sending an Interact Message + + +To send an “Interact” message to a client, +use . + + + + + void SmsInteract + SmsConn sms_conn + + + + + + sms_conn + The session management connection object. + + + + +The “Interact” message grants the client the privilege of +interacting with the user. When the client is done interacting with +the user, it must send an “Interact Done” message to the +session manager. + + + + +Sending a Save Complete Message + + +To send a “Save Complete” message to a client, +use . + + + + + void SmsSaveComplete + SmsConn sms_conn + + + + + + sms_conn + The session management connection object. + + + + +The session manager sends this message when it is done with a +checkpoint. The client is then free to change its state. + + + + +Sending a Die Message + + +To send a “Die” message to a client, +use . + + + + + void SmsDie + SmsConn sms_conn + + + + + + sms_conn + The session management connection object. + + + + +Before the session manager terminates, it should wait for a +“Connection Closed” message from each client that it sent +a “Die” message to, timing out appropriately. + + + + +Cancelling a Shutdown + + +To cancel a shutdown, use . + + + + + void SmsShutdownCancelled + SmsConn sms_conn + + + + + + sms_conn + The session management connection object. + + + + +The client can now continue as if the shutdown had never happened. If +the client has not sent a “Save Yourself Done” message +yet, it can either abort the save and send a “Save Yourself +Done” with the success argument set to False +or it can continue with the save and send a “Save Yourself Done” +with the success argument set to reflect the outcome +of the save. + + + + + +Returning Properties + + +In response to a “Get Properties” message, the session +manager should call . + + + + + void SmsReturnProperties + SmsConn sms_conn + int num_props + SmProp **props + + + + + + sms_conn + The session management connection object. + + + num_props + The number of properties. + + + props + The list of properties to return to the client. + + + + +The properties are returned as an array of property pointers. For a +description of session management properties and +the SmProp structure, +see section 7, +“Session Management Properties.” + + + + +Pinging a Client + + +To check that a client is still alive, you should use +the IcePing function provided by the ICE library. +To do so, the ICE connection must be obtained using +the +(see section 6.12, +“Using Sms Informational Functions”). + + + + + + void IcePing + IceConn ice_conn + IcePingReplyProc ping_reply_proc + IcePointer client_data + + + + + + ice_conn + A valid ICE connection object. + + + ping_reply_proc + The callback to invoke when the Ping reply arrives. + + + client_data + This pointer will be passed to the callback. + + + + + +When the Ping reply is ready (if ever), +the callback will be invoked. A +session manager should have some sort of timeout period, after which +it assumes the client has unexpectedly died. + + + + + typedef void (*IcePingReplyProc) + IceConn ice_conn + IcePointer client_data + + + + + + ice_conn + A valid ICE connection object. + + + client_data + The client data specified in the call to IcePing + + + + + + +Cleaning Up After a Client Disconnects + + +When the session manager receives a “Connection Closed” +message or otherwise detects that the client aborted the connection, +it should call the function in order +to free up the connection object. + + + + + void SmsCleanUp + SmsConn sms_conn + + + + + + sms_conn + The session management connection object. + + + + + + +Using Sms Informational Functions + + + + int SmsProtocolVersion + SmsConn sms_conn + + + + + returns the major version of +the session management protocol associated with this session. + + + + + int SmsProtocolRevision + SmsConn sms_conn + + + + + returns the minor version of +the session management protocol associated with this session. + + + + + char *SmsClientID + SmsConn sms_conn + + + + + returns a null-terminated string for +the client ID associated with this connection. You should +call free on this pointer when the client ID is +no longer needed. + + + + +To obtain the host name of a client, +use . +This host name will be needed to restart the client. + + + + + char *SmsClientHostName + SmsConn sms_conn + + + + +The string returned is of the form +protocol/hostname, +where protocol is one of +{tcp, decnet, local}. +You should call free on the string returned when +it is no longer needed. + + + + + IceConn SmsGetIceConnection + SmsConn sms_conn + + + + + 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 IceConnectionNumber +and IceLastSequenceNumber. +For further information, see the +Inter-Client Exchange Library +standard. + + + + +Error Handling + + +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 . + + + + + SmsErrorHandler SmsSetErrorHandler + SmsErrorHandler handler + + + + +The error handler. You should pass NULL +to restore the default handler. + + + + returns the previous error handler. +The has the following type: + + + + + typedef void (*SmsErrorHandler) + SmsConn sms_conn + Bool swap + int offending_minor_opcode + unsigned long offending_sequence_num + int error_class + int severity + IcePointer values + + + + + + sms_conn + The session management connection object. + + + swap + A flag which indicates if the specified values need byte swapping. + + + offending_minor_opcode + The minor opcode of the offending message. + + + offending_sequence_num + The sequence number of the offending message. + + + error_class + The error class of the offending message. + + + severity + + IceCanContinue, + IceFatalToProtocol, or + IceFatalToConnection + + + + values + Any additional error values specific to the minor opcode and class. + + + + +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 IceSetIOErrorHandler. +For further information, see the +Inter-Client Exchange Library +standard. + + + + + + Session Management Properties + + +Each property is defined by the SmProp structure: + + +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; + + + + +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. + + + +A type of SmCARD8 indicates that there is a single 1-byte value. +A type of SmARRAY8 indicates that there is a single array of bytes. +A type of SmLISTofARRAY8 indicates that there is a list of array of +bytes. + + + + + + + + + + + Name + Type + POSIX Type + Required + + + + + SmCloneCommand + OS-specific + SmLISTofARRAY8 + Yes + + + SmCurrentDirectory + OS-specific + SmARRAY8 + No + + + SmDiscardCommand + OS-specific + SmLISTofARRAY8 + No* + + + SmEnvironment + OS-specific + SmLISTofARRAY8 + No + + + SmProcessID + OS-specific + SmARRAY8 + No + + + SmProgram + OS-specific + SmARRAY8 + Yes + + + SmRestartCommand + OS-specific + SmLISTofARRAY8 + Yes + + + SmResignCommand + OS-specific + SmLISTofARRAY8 + No + + + SmRestartStyleHint + SmCARD8 + SmCARD8 + No + + + SmShutdownCommand + OS-specific + SmLISTofARRAY8 + No + + + SmUserID + SmARRAY8 + SmARRAY8 + Yes + + + + + + +* Required if any state is stored in an external repository (for +example, state file). + + + + SmCloneCommand + +This is like the SmRestartCommand, 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 POSIX systems, +this should be of type SmLISTofARRAY8. + + SmCurrentDirectory + +On POSIX-based systems, this specifies the value of the +current directory that needs to be set up prior to starting the +SmProgram and should of type SmARRAY8. + + SmDiscardCommand + +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 SmRestartCommand. +On POSIX systems, the type should be +SmLISTofARRAY8. + + SmEnvironment + +On POSIX based systems, this will be of type +SmLISTofARRAY8, where the ARRAY8s alternate between +environment variable name and environment variable value. + + SmProcessID + +This specifies an OS-specific identifier for the process. +On POSIX systems, this should contain the return value +of getpid turned into a Latin-1 (decimal) string. + + SmProgram + +This is the name of the program that is running. On POSIX +systems, this should be first parameter passed to execve +and should be of type SmARRAY8. + + SmRestartCommand + +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 POSIX-based systems, this is of +type SmLISTofARRAY8, 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. + + SmResignCommand + +A client that sets the SmRestartStyleHint +to SmRestartAnyway 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 xmodmap which +registers with the Session Manager, +sets SmRestartStyleHint +to SmRestartAnyway, and then +terminates. To allow the Session Manager (at the user's request) to +undo this, xmodmap would register a +SmResignCommand that undoes the effects of +the xmodmap. + + SmRestartStyleHint + +If the SmRestartStyleHint is present, it will contain the +style of restarting the client prefers. If this style is not specified, +SmRestartIfRunning is assumed. +The possible values are as follows: + + + + + + + + + Name + Value + + + + + SmRestartIfRunning + 0 + + + SmRestartAnyway + 1 + + + SmRestartImmediately + 2 + + + SmRestartNever + 3 + + + + + + + +The SmRestartIfRunning 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. + + + +The SmRestartAnyway 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. + + + +A client that uses SmRestartAnyway should also set the +SmResignCommand and SmShutdownCommand +properties to commands that undo the state of the client after it exits. + + + +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. + + + +SmRestartNever style specifies that the client does not +wish to be restarted in the next session. + + + SmShutdownCommand + +This command is executed at shutdown time to clean up after a client +that is no longer running but retained its state by setting +SmRestartStyleHint to +SmRestartAnyway. 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 +SmRestartStyleHint to +SmRestartAnyway and would register +a SmShutdownCommand that would turn off the camera. + + SmUserID + +Specifies the user ID. On POSIX-based systems, this will +contain the user's name (the pw_name member of +struct passwd). + + + + + + Freeing Data + + +To free an individual property, use + + + + + void SmFreeProperty + SmProp *prop + + + + + + prop + The property to free. + + + + +To free the reason strings from +the callback, +use + + + + + void SmFreeReasons + int count + char **reasons + + + + + + count + The number of reason strings. + + + reasons + The list of reason strings to free. + + + + + + Authentication of Clients + + +As stated earlier, the session management protocol is layered on top +of ICE. Authentication occurs at two levels in the ICE protocol: + + + The first is when an ICE connection is opened. + The second is when a Protocol Setup occurs on an ICE connection. + + + + +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 +Inter-Client Exchange Library +standard. + + + + + Working in a Multi-Threaded Environment + + +To declare that multiple threads in an application will be using SMlib +(or any other library layered on top of ICElib), you should +call IceInitThreads. +For further information, see the +Inter-Client Exchange Library +standard. + + + + + Acknowledgements + + +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. + + + + diff --git a/doc/xsmp.xml b/doc/xsmp.xml new file mode 100644 index 0000000..d962fcb --- /dev/null +++ b/doc/xsmp.xml @@ -0,0 +1,2499 @@ + + %defs; +]> + + + + + + + X Session Management Protocol + X Consortium Standard + X Version 11, Release &fullrelvers; + Version 1.0 + + + MikeWexler + Kubota Pacific Computer, Inc + + + + 1992199319942002 + The Open Group + + + + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation files +(the “Software”), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + + + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + + + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY +OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +Except as contained in this notice, the name of the X Consortium +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +from the X Consortium. + + + +X Window System is a trademark of The Open Group. + + + + + +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 ICE protocol. + + + + + + + Acknowledgments + + +First I would like to thank the entire ICCCM 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. + + + + + Definitions and Goals + + +The purpose of the X Session Management Protocol (XSMP) is +to provide a uniform mechanism for users to save and restore their sessions. +A session is a group of clients, each +of which has a particular state. The session is controlled by a +network service called the session manager. +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. + + + +For purposes of this protocol, a client +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. + + + +This protocol is layered on top of the X Consortium's ICE protocol and +relies on the ICE protocol to handle connection management and authentication. + + + + + + Overview of the Protocol + + +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. + + + +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 client-ID 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 RestartCommand) 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. + + + +The client finds the network address of the SM in a system-dependent +way. On POSIX systems an environment +variable called SESSION_MANAGER +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: + + tcp/hostname:portnumber + +where the hostname is a fully qualified domain name. +A Unix Domain address looks like this: + + local/hostname:path + +A DECnet address would look like this: + + decnet/nodename::objname + + + + +If multiple network IDs are specified, they should be separated by commas. + + + Rationale + +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. + + + +The protocol is connection based, because there is no other way for +the SM to determine reliably when clients terminate. + + + +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). + + + +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. + + + + +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 SESSION_MANAGER environment variable) +that specifies a connection to itself instead of to the top level session +manager. + + + +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. + + + + + Data Types + + +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 ICE protocol. + + + +If an invalid value is specified for a field of any of the enumerated +types, a BadValue error message must be sent by +the receiver of the message to the sender of the message. + + + + + + + + + Type Name + Description + + + + + BOOL + False or True + + + INTERACT_STYLE + None Errors or Any + + + DIALOG_TYPE + Error or Normal + + + SAVE_TYPE + Global Local or Both + + + CARD8 + a one-byte unsigned integer + + + CARD16 + a two-byte unsigned integer + + + CARD32 + a four-byte unsigned integer + + + ARRAY8 + a sequence of CARD8s + + + LISTofARRAY8 + a sequence of ARRAY8s + + + PROPERTY + a property name (an ARRAY8), a type name, and a value of that type + + + LISTofPROPERTY + a counted collection of ­PROPERTYs. + + + + + + + + + Protocol Setup and Message Format + + +To start the XSMP protocol, the client sends the server an +ICE ProtocolSetup message. All XSMP messages are +in the standard ICE message format. The message's major opcode is +assigned to XSMP by ICE 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. + + + + + Client Identification String + +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 Register­Client +and Register­ClientReply messages. + + + +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 '0' +characters so as to fill the specified length. Decimal numbers are +encoded using the characters '0' through +'9', and hexadecimal numbers using the characters +'0' through '9' and +'A' through 'F'. + + + + +Version. This is currently the character '1'. + + + Address type and address. The address type will be one of + + '1' a 4-byte IPv4 address encoded as 8 hexadecimal digits + '2' a 6-byte DECNET address encoded as 12 hexadecimal digits + '6' a 16-byte IPv6 address encoded as 32 hexadecimal digits + + + + +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 +"QC6702D0B". + + + + Time stamp. A 13-digit decimal number specifying + the number of milliseconds since 00:00:00 UTC, January 1, 1970. + + + + Process-ID type and process-ID. The process-ID type will be one of + + '1' a POSIX process-ID encoded as a 10-digit decimal number. + + + +The process-ID is the process-ID of the session manager, not of a client. + + + + +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". + + Rationale + +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. + + + + + + + + Protocol + +The protocol consists of a sequence of messages as described below. +Each message type is specified by an ICE 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 +ICE severity is given in parentheses following each error class. + + + +RegisterClient [Client → SM] + + previous-ID: ARRAY8 + + Valid Responses: RegisterClientReply + + Possible Errors: BadValue (CanContinue) + + + +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 previous-ID field must contain the client +ID from the previous session. For new clients, +previous-ID should be of zero length. + + + +If previous-ID is not valid, +the SM will send a BadValue +error message to the client. At this point the SM reverts to the +register state and waits for another RegisterClient +The client should then send a RegisterClient with a +null previous-ID field. + + + +RegisterClientReply [Client ← SM] + + client-ID: ARRAY8 + + + +The client-ID specifies a unique identification +for this client. If the client had specified an ID in the +previous-ID field of the +RegisterClient message, +client-ID will be identical to the previously +specified ID. If previous-ID was null, +client-ID will be a unique ID freshly generated +by the SM. The client-ID format is specified in +section 6. + + + +If the client didn't supply a previous-ID field to +the Register­Client message, the SM must send +a SaveYourself message with type = Local, +shutdown = False, interact-style = None, and fast = False immediately +after the RegisterClientReply The client should +respond to this like any other Save­Yourself +message. + + + +SaveYourself [Client ← SM] + + type: SAVE_TYPE + shutdown: BOOL + interact-style: INTERACT_STYLE + fast: BOOL + + Valid Responses: + SetProperties + DeleteProperties + GetProperties + SaveYourselfDone + SaveYourselfPhase2Request + InteractRequest + + + +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 SetProperties to inform the SM of how to +restart it and how to discard the saved state. During this process it +can, if allowed by interact-style, request permission +to interact with +the user by sending an InteractRequest message. +After the state has been saved, or if it cannot be successfully saved, +and the properties are appropriately set, the client sends +a SaveYourselfDone message. If the client wants +to save additional information after all the other clients have +finished changing their own state, the client should +send SaveYourselfPhase2Request instead +of SaveYourselfDone The client must then freeze +interaction with the user and wait until it receives +a SaveComplete Die or +a ShutdownCancelled message. + + + +If interact-style is None the +client must not interact with the user while saving state. If the +interact-style +is Errors the client may interact with the user +only if an error condition arises. If interact-style +is Any then the client may interact with the user +for any purpose. This is done by sending +an Interact­Request message. The SM will +send an Interact message to each client that sent +an Interact­Request The client must postpone +all interaction until it gets the Interact +message. When the client is done interacting it should send the SM +an Interact­Done message. +The Interact­Request message can be sent any +time after a Save­Yourself and before +a Save­Yourself­Done + + + +Unusual circumstances may dictate multiple interactions. The client +may initiate as many Interact­Request +- Interact - InteractDone +sequences as it needs before it sends SaveYourselfDone + + + +When a client receives Save­Yourself and has +not yet responded Save­Yourself­Done to a +previous Save­Yourself it must send +a Save­Yourself­Done and may then begin +responding as appropriate to the newly received +Save­Yourself + + + +The type field specifies the type of information that +should be saved: Global Local +or Both The Local type +indicates that the application must update the properties to reflect +its current state, send +a Save­Yourself­Done 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 Global type indicates +that the user wants the client to commit all of its data to permanent, +globally-accessible storage. Both indicates that +the client should do both of these. If Both is +specified, the client should first commit the data to permanent +storage before updating its SM properties. + + + Examples + +If a word processor was sent a SaveYourself with +a type of Local 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 Restart­Command property with +enough information to find the temporary file, and +its Discard­Command with enough information +to remove it. + + + +If a word processor was sent a SaveYourself with +a type of Global it would simply save the +currently edited file. + + + +If a word processor was sent a SaveYourself with +a type of Both 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 Restart­Command property with enough +information to find the temporary file, and +its Discard­Command with enough information +to remove it. + + + +Once the SM has send SaveYourself to a client, it +can't send another SaveYourself to that client until +the client either responds with a SaveYourselfDone or +the SM sends a ShutdownCancelled + + + + Advice to Implementors + +If the client stores local any state in a file or similar "external" +storage, it must create a distinct copy in response to +each SaveYourself message. +It must not simply refer to a previous +copy, because the SM may discard that previous saved state using +a DiscardCommand without knowing that it is +needed for the new checkpoint. + + + + +The shutdown field specifies whether the system is +being shut down. + + + Rationale + +The interaction may be different depending on whether or not shutdown is set. + + + + +The client must save and then must prevent interaction until it +receives a SaveComplete Die +or a Shutdown­Cancelled because anything the +user does after the save will be lost. + + + +The fast 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 fast +field to True. + + + +SaveYourselfPhase2 [Client → SM] + + Valid Responses: + SetProperties + DeleteProperties + GetProperties + SaveYourselfDone + InteractRequest + + + +The SM sends this message to a client that has previously sent +a SaveYourselfPhase2Request 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. + + + Rationale + +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. + + + +The client writes a state file, if necessary, and, if necessary, +uses SetProperties 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 InteractRequest 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 SaveYourselfDone message. + + + +SaveYourselfRequest [Client → SM] + + type: SAVE_TYPE + shutdown: BOOL + interact-style: INTERACT_STYLE + fast: BOOL + global: BOOL + + Valid Responses: SaveYourself + + + +An application sends this to the SM to request a checkpoint. When the +SM receives this request it may generate a SaveYourself +message in response and it may leave the fields intact. + + + Example +A vendor of a UPS (Uninterruptible Power Supply) +might include an SM client that would monitor the status of +the UPS and generate a fast shutdown if the power +is about to be lost. + + + +If global is set to True then the +resulting SaveYourself should be sent to all +applications. If global is set to +False then the +resulting SaveYourself should be sent to the +application that sent the Save­Yourself­Request + + + +InteractRequest [Client → SM] + + dialog-type: DIALOG_TYPE + + Valid Responses: Interact ShutdownCancelled + + Possible Errors: BadState (CanContinue) + + + +During a checkpoint or session-save operation, only one client at a +time might be granted the privilege of interacting with the user. +The InteractRequest message causes the SM to emit +an Interact message at some later time if the +shutdown is not cancelled by another client first. + + + +The dialog-type field specifies either +Errors indicating that the client wants to start an +error dialog or Normal meaning the client wishes +to start a non-error dialog. + + + +Interact [Client ← SM] + + Valid Responses: InteractDone + + + +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 InteractDone message to the SM unless a +shutdown cancel is received. + + Advice to Implementors + If a client receives a ShutdownCancelled +after receiving an Interact message, but before +sending a InteractDone the client should abort +the interaction and send a SaveYourselfDone + + + +InteractDone [Client → SM] + + cancel-shutdown: BOOL + + Valid Responses: ShutdownCancelled + + + +This message is used by a client to notify the SM that it is done interacting. + + + +Setting the cancel-shutdown field to True +indicates that the user has requested that the entire shutdown be +cancelled. Cancel-shutdown may only be True if +the corresponding SaveYourself message +specified True for the shutdown field +and Any or Errors for the +interact-style field. Otherwise, +cancel-shutdown must be False. + + + +SaveYourselfDone [Client → SM] + + success: BOOL + + Valid Responses: + SaveComplete + Die + ShutdownCancelled + + + + +This message is sent by a client to indicate that all of the +properties representing its state have been updated. After +sending SaveYourselfDone the client must wait for +a SaveComplete ShutdownCancelled +or Die message before changing its state. If +the SaveYourself operation was successful, then +the client should set the success field to +True otherwise the client should set it to +False. + + + Example + +If a client tries to save its state and runs out of disk space, it +should return False in the success +field of the SaveYourselfDone message. + + + + +SaveYourselfPhase2Request [Client → SM] + + Valid Responses: + ShutdownCancelled + SaveYourselfPhase2 + + + + +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. + + + +Die [Client ← SM] + + Valid Responses: ConnectionClosed + + + +When the SM wants a client to die it sends a Die +message. Before the client dies it responds by sending +a ConnectionClosed message and may then close its +connection to the SM at any time. + + + +SaveComplete [Client → SM] + + Valid Responses: + + + +When the SM is done with a checkpoint, it will send each of the +clients a SaveComplete message. The client is +then free to change its state. + + + +ShutdownCancelled [Client ← SM] + + + +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 SaveYourselfDone yet, the client can +either abort the save and send SaveYourselfDone +with the success field set to False or it can +continue with the save and send a SaveYourselfDone +with the success field set to reflect the outcome of the save. + + + +ConnectionClosed [Client → SM] + + reason: LISTofARRAY8 + + + +Specifies that the client has decided to terminate. It should be +immediately followed by closing the connection. + + + +The reason 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 POSIX 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. + + + +After sending this message, the client must not send any additional +XSMP messages to the SM. + + Advice to Implementors +If additional messages are received, they should be discarded. + + Rationale +The reason for sending the ConnectionClosed +message before actually closing the connections is that some transport +protocols will not provide immediate notification of connection +closure. + + + +SetProperties [Client → SM] + + properties: LISTofPROPERTY + + + +Sets the specified properties to the specified values. +Existing +properties not specified in the Set­Properties +message are unaffected. Some properties have predefined semantics. +See section 11, +“Predefined Properties.” + + + +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. + + + +DeleteProperties [Client → SM] + + property-names: LISTofARRAY8 + + + Removes the named properties. + + +GetProperties [Client → SM] + + Valid Responses: GetPropertiesReply + + + +Requests that the SM respond with the values of all the properties for +this client. + + + +GetPropertiesReply [Client ← SM] + + values: LISTofPROPERTY + + + +This message is sent in reply to a GetProperties +message and includes the values of all the properties. + + + + + Errors + + +When the receiver of a message detects an error condition, the +receiver sends an ICE error message to the sender. There are only two +types of errors that are used by the XSMP: +BadValue and BadState +These are both defined in the ICE protocol. + + + +Any message received out-of-sequence will generate +a BadState error message. + + + + + State Diagrams + +These state diagrams are designed to cover all actions of both the +client and the SM. + + + +Client State Diagram + + + +start: + ICE protocol setup complete → register + + +register: + send RegisterClientcollect-id + + +collect-id: + receive RegisterClientReplyidle + + +shutdown-cancelled: + send SaveYourselfDoneidle + + +idle: [Undoes any freeze of interaction with user.] + receive Diedie + receive SaveYourselffreeze-interaction + send GetPropertiesidle + receive GetPropertiesReplyidle + send SetPropertiesidle + send DeletePropertiesidle + send ConnectionClosedconnection-closed + send SaveYourselfRequestidle + + + +die: + send ConnectionClosedconnection-closed + + +freeze-interaction: + freeze interaction with user → save-yourself + + +save-yourself: + receive ShutdownCancelledshutdown-cancelled + send SetPropertiessave-yourself + send DeletePropertiessave-yourself + send GetPropertiessave-yourself + receive GetPropertiesReplysave-yourself + send InteractRequestinteract-request + send SaveYourselfPhase2Request → waiting-for-phase2 + +save-yourself: + if shutdown mode: + send SaveYourselfDonesave-yourself-done + otherwise: + send SaveYourselfDoneidle + + +waiting-for-phase2: + receive ShutdownCancelledshutdown-cancelled + receive SaveYourselfPhase2phase2 + + +phase2: + receive ShutdownCancelledshutdown-cancelled + send SetPropertiessave-yourself + send DeletePropertiessave-yourself + send GetPropertiessave-yourself + receive GetPropertiesReplysave-yourself + send InteractRequestinteract-request (errors only) + if shutdown mode: + send SaveYourselfDonesave-yourself-done + otherwise: + send SaveYourselfDoneidle + + +interact-request: + receive Interactinteract + receive ShutdownCancelledshutdown-cancelled + + +interact: + send InteractDonesave-yourself + receive ShutdownCancelledshutdown-cancelled + + +save-yourself-done: (changing state is forbidden) + receive SaveCompleteidle + receive Diedie + receive ShutdownCancelledidle + + +connection-closed: + client stops participating in session + + + +Session Manager State Diagram + + +start: + receive ProtocolSetupprotocol-setup + + +protocol-setup: + send ProtocolSetupReplyregister + + +register: + receive RegisterClientacknowledge-register + + + +acknowledge-register: + send RegisterClientReplyidle + + + +idle: + receive SetPropertiesidle + receive DeletePropertiesidle + receive ConnectionClosedstart + receive GetPropertiesget-properties + receive SaveYourselfRequestsave-yourself + send SaveYourselfsaving-yourself + + + +save-yourself: + send SaveYourselfsaving-yourself + + + +get-properties: + send GetPropertiesReplyidle + + + +saving-get-properties: + send GetPropertiesReplysaving-yourself + + + +saving-yourself: + receive InteractRequestsaving-yourself + send Interactsaving-yourself + send ShutdownCancelledidle + receive InteractDonesaving-yourself + receive SetPropertiessaving-yourself + receive DeletePropertiessaving-yourself + receive GetPropertiessaving-get-properties + receive SaveYourselfPhase2Requeststart-phase2 + receive SaveYourselfDonesave-yourself-done + + + +start-phase2: + If all clients have sent either SaveYourselfPhase2Request or SaveYourselfDone: + send SaveYourselfPhase2phase2 + else + → saving-yourself + + + +phase2: + receive InteractRequestsaving-yourself + send Interactsaving-yourself + send ShutdownCancelledidle + receive InteractDonesaving-yourself + receive SetPropertiessaving-yourself + receive DeletePropertiessaving-yourself + receive GetPropertiessaving-get-properties + receive SaveYourselfDonesave-yourself-done + + + +save-yourself-done: + If all clients are saved: + If shutting down: + send Diedie + otherwise + send SaveCompleteidle + + If some clients are not saved: + → saving-yourself + + + +die: + SM stops accepting connections + + + + + + Protocol Encoding + +Types + + + + + + + + + BOOL + + + + + 0 + False + + + 1 + True + + + + + + + + + + INTERACT_STYLE + + + + + 0 + None + + + 1 + Errors + + + 2 + Any + + + + + + + + + + DIALOG_TYPE + + + + + 0 + Error + + + 1 + Normal + + + + + + + + + + SAVE_TYPE + + + + + 0 + Global + + + 1 + Local + + + 2 + Both + + + + + + + + + + + ARRAY8 + + + + + 4 + CARD32 + length + + + n + ListofCARD8, the array + p = pad (4 + n, 8) + + + 2 + Both + + + + + + + + + + + LISTofARRAY8 + + + + + 4 + CARD32 + count + + + 4 + + unused + + + a + ARRAY8 + first array + + + b + ARRAY8 + second array + + + . + + + + + . + + + + + . + + + + + q + ARRAY8 + last array + + + + + + + + + + + PROPERTY + + + + + a + ARRAY8 + name + + + b + ARRAY8 + type (XPCS encoded in Latin-1, case sensitive) + + + c + LISTofARRAY8 + values + + + + + + + + + + + LISTofPROPERTY + + + + + 4 + CARD32 + count + + + 4 + + unused + + + a + PROPERTY + first property + + + b + PROPERTY + second property + + + . + + + + + . + + + + + . + + + + + q + PROPERTY + last property + + + + + + + + +Messages + +XSMP is a sub-protocol of ICE. The major opcode is +assigned at run-time by ICE and is represented here +by '?'. + + + +To start the XSMP protocol, the client sends the server an +ICE ProtocolSetup message. +The protocol-name field should be specified as "XSMP", +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. + + + +In ProtocolReply 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 +ICE ProtocolReply message. + + + + + + + + + + + RegisterClient + + + + + 1 + ? + XSMP + + + 1 + 1 + opcode + + + 2 + + unused + + + 4 + a/8 + length of remaining data in 8-byte units + + + a + ARRAY8 + previous-ID + + + + + + + + + + + RegisterClientReply + + + + + 1 + ? + XSMP + + + 1 + 2 + opcode + + + 2 + + unused + + + 4 + a/8 + length of remaining data in 8-byte units + + + a + ARRAY8 + client-ID + + + + + + + + + + + SaveYourself + + + + + 1 + ? + XSMP + + + 1 + 3 + opcode + + + 2 + + unused + + + 4 + 1 + length of remaining data in 8-byte units + + + 1 + SAVE_TYPE + type + + + 1 + BOOL + shutdown + + + 1 + INTERACT_STYLE + interact-style + + + 1 + BOOL + fast + + + 4 + + unused + + + + + + + + + + + SaveYourselfRequest + + + + + 1 + ? + XSMP + + + 1 + 4 + opcode + + + 2 + + unused + + + 4 + 1 + length of remainning data in 8-byte units + + + 1 + SAVE_TYPE + type + + + 1 + BOOL + shutdown + + + 1 + INTERACT_STYLE + interact-style + + + 1 + BOOL + fast + + + 3 + + unused + + + + + + + + + + + InteractRequest + + + + + 1 + ? + XSMP + + + 1 + 5 + opcode + + + 1 + DIALOG_TYPE + dialog type + + + 1 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + Interact + + + + + 1 + ? + XSMP + + + 1 + 6 + opcode + + + 2 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + InteractDone + + + + + 1 + ? + XSMP + + + 1 + 7 + opcode + + + 1 + BOOL + cancel-shutdown + + + 1 + + unused + + + + + + + + + + + InteractDone + + + + + 1 + ? + XSMP + + + 1 + 7 + opcode + + + 1 + BOOL + cancel-shutdown + + + 1 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + SaveYourselfDone + + + + + 1 + ? + XSMP + + + 1 + 8 + opcode + + + 1 + BOOL + success + + + 1 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + Die + + + + + 1 + ? + XSMP + + + 1 + 9 + opcode + + + 1 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + ShutdownCancelled + + + + + 1 + ? + XSMP + + + 1 + 10 + opcode + + + 2 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + ConnectionClosed + + + + + 1 + ? + XSMP + + + 1 + 11 + opcode + + + 2 + + unused + + + 4 + a/8 + length of remaining data in 8-byte units + + + a + LISTofARRAY8 + reason + + + + + + + + + + + SetProperties + + + + + 1 + ? + XSMP + + + 1 + 12 + opcode + + + 2 + + unused + + + 4 + a/8 + length of remaining data in 8-byte units + + + a + LISTofPROPERTY + properties + + + + + + + + + + + DeleteProperties + + + + + 1 + ? + XSMP + + + 1 + 13 + opcode + + + 2 + + unused + + + 4 + a/8 + length of remaining data in 8-byte units + + + a + LISTofPROPERTY + properties + + + + + + + + + + + GetProperties + + + + + 1 + ? + XSMP + + + 1 + 14 + opcode + + + 2 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + GetPropertiesReply + + + + + 1 + ? + XSMP + + + 1 + 15 + opcode + + + 2 + + unused + + + 4 + a/8 + length of remaining data in 8-byte units + + + a + LISTofPROPERTY + properties + + + + + + + + + + + SaveYourselfPhase2Request + + + + + 1 + ? + XSMP + + + 1 + 16 + opcode + + + 2 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + SaveYourselfPhase2 + + + + + 1 + ? + XSMP + + + 1 + 17 + opcode + + + 2 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + + SaveComplete + + + + + 1 + ? + XSMP + + + 1 + 18 + opcode + + + 2 + + unused + + + 4 + 0 + length of remaining data in 8-byte units + + + + + + + + + + Predefined Properties + +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. + + + +The required properties must be set each time a client connects with +the SM. The properties must be set after the client +sends RegisterClient and before the client +sends SaveYourselfDone Otherwise, the behavior of +the session manager is not defined. + + + +Clients may set, get, and delete nonstandard properties. The lifetime +of stored properties does not extend into subsequent sessions. + + + + + + + + + + + Name + Type + Posix Type + Required? + + + + + CloneCommand + OS-specific + LISTofARRAY8 + Yes + + + CurrentDirectory + OS-specific + ARRAY8 + No + + + DiscardCommand + OS-specific + LISTofARRAY8 + No* + + + Environment + OS-specific + LISTofARRAY8 + No + + + ProcessID + OS-specific + ARRAY8 + No + + + Program + OS-specific + ARRAY8 + Yes + + + RestartCommand + OS-specific + LISTofARRAY8 + Yes + + + ResignCommand + OS-specific + LISTofARRAY8 + No + + + RestartStyleHint + CARD8 + CARD8 + No + + + ShutdownCommand + OS-specific + LISTofARRAY8 + No + + + UserID + ARRAY8 + ARRAY8 + Yes + + + + + + +* Required if any state is stored in an external repository (e.g., state file). + + + + + CloneCommand + +This is like the RestartCommand 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 POSIX +systems the type should be a LISTofARRAY8. + + + + CurrentDirectory + +On POSIX-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. + + + + DiscardCommand + +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 Restart­Command On +POSIX systems the type should be LISTofARRAY8. + + + + Environment + +On POSIX based systems, this will be of type LISTofARRAY8 where the +ARRAY8s alternate between environment variable name and environment +variable value. + + + + ProcessID + +This specifies an OS-specific identifier for the process. On POSIX +systems this should of type ARRAY8 and contain the return value of +getpid() turned into a Latin-1 (decimal) string. + + + + Program + +The name of the program that is running. On POSIX systems this should +be the first parameter passed to execve and should be of type ARRAY8. + + + + RestartCommand + +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 POSIX-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. + + + + ResignCommand + + +A client that sets the RestartStyleHint +to RestartAnyway uses this property to specify a +command that undoes the effect of the client and removes any saved +state. + + Example +A user runs xmodmap. xmodmap registers with the SM, +sets Restart­Style­Hint +to Restart­Anyway and then terminates. In +order to allow the SM (at the user's request) to undo this, xmodmap +would register a Resign­Command that undoes +the effects of the xmodmap. + + + + + RestartStyleHint + + +If the RestartStyleHint property is present, it will contain the style +of restarting the client prefers. If this flag isn't +specified, RestartIfRunning is assumed. The +possible values are as follows: + + + + + + + + + + Name + Value + + + + + RestartIfRunning + 0 + + + RestartAnyway + 1 + + + RestartImmediately + 2 + + + RestartNever + 3 + + + + + + +The RestartIfRunning 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. + + + +The RestartAnyway 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. + + + Rationale +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. + + + +A client that uses RestartAnyway should also set +the ResignCommand and ShutdownCommand +properties to commands that undo the state of the client after it exits. + + + +The RestartImmediately style is +like RestartAnyway 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. + + + Advice to Implementors +It would be wise to sanity-check the frequency which +which RestartImmediately clients are restarted, +to avoid a sick client being restarted continuously. + + + +The RestartNever style specifies that the client +does not wish to be restarted in the next session. + + + Advice to Implementors +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. + + + + + + ShutdownCommand + + +This command is executed at shutdown time to clean up after a client +that is no longer running but retained its state by +setting RestartStyleHint +to RestartAnyway The command must not remove any +saved state as the client is still part of the session. + + Example +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 Restart­Style­Hint +to Restart­Anyway and would register a +Shutdown­Command that would turn off the camera. + + + + + UserID + +Specifies the user's ID. On POSIX-based systems +this will contain the the user's name (the pw_name +field of struct passwd). + + + + + diff --git a/docbook.am b/docbook.am new file mode 100644 index 0000000..bba4d54 --- /dev/null +++ b/docbook.am @@ -0,0 +1,105 @@ +# +# Generate output formats for a single DocBook/XML with/without chapters +# +# Variables set by the calling Makefile: +# shelfdir: the location where the docs/specs are installed. Typically $(docdir) +# docbook: the main DocBook/XML file, no chapters, appendix or image files +# chapters: all files pulled in by an XInclude statement and images. +# + +# +# This makefile is intended for Users Documentation and Functional Specifications. +# Do not use for Developer Documentation which is not installed and does not require olink. +# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393 +# for an explanation on documents classification. +# + +# DocBook/XML generated output formats to be installed +shelf_DATA = + +# DocBook/XML file with chapters, appendix and images it includes +dist_shelf_DATA = $(docbook) $(chapters) + +if HAVE_XMLTO +if HAVE_STYLESHEETS + +XMLTO_SEARCHPATH_FLAGS = \ + --searchpath "$(XORG_SGML_PATH)/X11" \ + --searchpath "$(abs_top_builddir)" +XMLTO_HTML_OLINK_FLAGS = \ + --stringparam target.database.document=$(XORG_SGML_PATH)/X11/dbs/masterdb.html.xml \ + --stringparam current.docid="$(<:.xml=)" +XMLTO_HTML_STYLESHEET_FLAGS = -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl +XMLTO_HTML_FLAGS = \ + $(XMLTO_SEARCHPATH_FLAGS) \ + $(XMLTO_HTML_STYLESHEET_FLAGS) \ + $(XMLTO_HTML_OLINK_FLAGS) + +shelf_DATA += $(docbook:.xml=.html) +%.html: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_HTML_FLAGS) xhtml-nochunks $< + +if HAVE_XMLTO_TEXT + +shelf_DATA += $(docbook:.xml=.txt) +%.txt: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_HTML_FLAGS) txt $< +endif HAVE_XMLTO_TEXT + +if HAVE_FOP +XMLTO_FO_IMAGEPATH_FLAGS = --stringparam img.src.path=$(abs_builddir)/ +XMLTO_PDF_OLINK_FLAGS = \ + --stringparam target.database.document=$(XORG_SGML_PATH)/X11/dbs/masterdb.pdf.xml \ + --stringparam current.docid="$(<:.xml=)" +XMLTO_FO_STYLESHEET_FLAGS = -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl + +XMLTO_FO_FLAGS = \ + $(XMLTO_SEARCHPATH_FLAGS) \ + $(XMLTO_FO_STYLESHEET_FLAGS) \ + $(XMLTO_FO_IMAGEPATH_FLAGS) \ + $(XMLTO_PDF_OLINK_FLAGS) + +shelf_DATA += $(docbook:.xml=.pdf) +%.pdf: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_FO_FLAGS) --with-fop pdf $< + +shelf_DATA += $(docbook:.xml=.ps) +%.ps: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_FO_FLAGS) --with-fop ps $< +endif HAVE_FOP + +# Generate documents cross-reference target databases +if HAVE_XSLTPROC + +XSLT_SEARCHPATH_FLAGS = \ + --path "$(XORG_SGML_PATH)/X11" \ + --path "$(abs_top_builddir)" +XSLT_OLINK_FLAGS = \ + --stringparam targets.filename "$@" \ + --stringparam collect.xref.targets "only" \ + --stringparam olink.base.uri "$(@:.db=)" + +XSLT_HTML_FLAGS = \ + $(XSLT_SEARCHPATH_FLAGS) \ + $(XSLT_OLINK_FLAGS) \ + --nonet --xinclude \ + $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl +XSLT_PDF_FLAGS = \ + $(XSLT_SEARCHPATH_FLAGS) \ + $(XSLT_OLINK_FLAGS) \ + --nonet --xinclude \ + $(STYLESHEET_SRCDIR)/xorg-fo.xsl + +shelf_DATA += $(docbook:.xml=.html.db) +%.html.db: %.xml $(chapters) + $(AM_V_GEN)$(XSLTPROC) $(XSLT_HTML_FLAGS) $< + +shelf_DATA += $(docbook:.xml=.pdf.db) +%.pdf.db: %.xml $(chapters) + $(AM_V_GEN)$(XSLTPROC) $(XSLT_PDF_FLAGS) $< + +endif HAVE_XSLTPROC +endif HAVE_STYLESHEETS +endif HAVE_XMLTO + +CLEANFILES = $(shelf_DATA) diff --git a/include/X11/SM/SM.h b/include/X11/SM/SM.h new file mode 100644 index 0000000..1af5ae8 --- /dev/null +++ b/include/X11/SM/SM.h @@ -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 100644 index 0000000..9645295 --- /dev/null +++ b/include/X11/SM/SMlib.h @@ -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 +#include + + +/* + * Generic SM pointer + */ + +typedef IcePointer SmPointer; + + +/* + * Connection objects. Defined in SMlibint.h + */ + +typedef struct _SmcConn *SmcConn; +typedef struct _SmsConn *SmsConn; + + +/* + * Session Management property + */ + +typedef struct { + int length; /* length (in bytes) of the value */ + SmPointer value; /* the value */ +} SmPropValue; + +typedef struct { + char *name; /* name of property */ + char *type; /* type of property */ + int num_vals; /* number of values in property */ + SmPropValue *vals; /* the values */ +} SmProp; + + + +/* + * SmcCloseConnection status return + */ + +typedef enum { + SmcClosedNow, + SmcClosedASAP, + SmcConnectionInUse +} SmcCloseStatus; + + + +/* + * Client callbacks + */ + +typedef void (*SmcSaveYourselfProc) ( + SmcConn /* smcConn */, + SmPointer /* clientData */, + int /* saveType */, + Bool /* shutdown */, + int /* interactStyle */, + Bool /* fast */ +); + +typedef void (*SmcSaveYourselfPhase2Proc) ( + SmcConn /* smcConn */, + SmPointer /* clientData */ +); + +typedef void (*SmcInteractProc) ( + SmcConn /* smcConn */, + SmPointer /* clientData */ +); + +typedef void (*SmcDieProc) ( + SmcConn /* smcConn */, + SmPointer /* clientData */ +); + +typedef void (*SmcShutdownCancelledProc) ( + SmcConn /* smcConn */, + SmPointer /* clientData */ +); + +typedef void (*SmcSaveCompleteProc) ( + SmcConn /* smcConn */, + SmPointer /* clientData */ +); + +typedef void (*SmcPropReplyProc) ( + SmcConn /* smcConn */, + SmPointer /* clientData */, + int /* numProps */, + SmProp ** /* props */ +); + + +/* + * Callbacks set up at SmcOpenConnection time + */ + +typedef struct { + + struct { + SmcSaveYourselfProc callback; + SmPointer client_data; + } save_yourself; + + struct { + SmcDieProc callback; + SmPointer client_data; + } die; + + struct { + SmcSaveCompleteProc callback; + SmPointer client_data; + } save_complete; + + struct { + SmcShutdownCancelledProc callback; + SmPointer client_data; + } shutdown_cancelled; + +} SmcCallbacks; + +#define SmcSaveYourselfProcMask (1L << 0) +#define SmcDieProcMask (1L << 1) +#define SmcSaveCompleteProcMask (1L << 2) +#define SmcShutdownCancelledProcMask (1L << 3) + + + +/* + * Session manager callbacks + */ + +typedef Status (*SmsRegisterClientProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + char * /* previousId */ +); + +typedef void (*SmsInteractRequestProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + int /* dialogType */ +); + +typedef void (*SmsInteractDoneProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + Bool /* cancelShutdown */ +); + +typedef void (*SmsSaveYourselfRequestProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + int /* saveType */, + Bool /* shutdown */, + int /* interactStyle */, + Bool /* fast */, + Bool /* global */ +); + +typedef void (*SmsSaveYourselfPhase2RequestProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */ +); + +typedef void (*SmsSaveYourselfDoneProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + Bool /* success */ +); + +typedef void (*SmsCloseConnectionProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + int /* count */, + char ** /* reasonMsgs */ +); + +typedef void (*SmsSetPropertiesProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + int /* numProps */, + SmProp ** /* props */ +); + +typedef void (*SmsDeletePropertiesProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + int /* numProps */, + char ** /* propNames */ +); + +typedef void (*SmsGetPropertiesProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */ +); + + +/* + * Callbacks set up by a session manager when a new client connects. + */ + +typedef struct { + + struct { + SmsRegisterClientProc callback; + SmPointer manager_data; + } register_client; + + struct { + SmsInteractRequestProc callback; + SmPointer manager_data; + } interact_request; + + struct { + SmsInteractDoneProc callback; + SmPointer manager_data; + } interact_done; + + struct { + SmsSaveYourselfRequestProc callback; + SmPointer manager_data; + } save_yourself_request; + + struct { + SmsSaveYourselfPhase2RequestProc callback; + SmPointer manager_data; + } save_yourself_phase2_request; + + struct { + SmsSaveYourselfDoneProc callback; + SmPointer manager_data; + } save_yourself_done; + + struct { + SmsCloseConnectionProc callback; + SmPointer manager_data; + } close_connection; + + struct { + SmsSetPropertiesProc callback; + SmPointer manager_data; + } set_properties; + + struct { + SmsDeletePropertiesProc callback; + SmPointer manager_data; + } delete_properties; + + struct { + SmsGetPropertiesProc callback; + SmPointer manager_data; + } get_properties; + +} SmsCallbacks; + + +#define SmsRegisterClientProcMask (1L << 0) +#define SmsInteractRequestProcMask (1L << 1) +#define SmsInteractDoneProcMask (1L << 2) +#define SmsSaveYourselfRequestProcMask (1L << 3) +#define SmsSaveYourselfP2RequestProcMask (1L << 4) +#define SmsSaveYourselfDoneProcMask (1L << 5) +#define SmsCloseConnectionProcMask (1L << 6) +#define SmsSetPropertiesProcMask (1L << 7) +#define SmsDeletePropertiesProcMask (1L << 8) +#define SmsGetPropertiesProcMask (1L << 9) + + + +typedef Status (*SmsNewClientProc) ( + SmsConn /* smsConn */, + SmPointer /* managerData */, + unsigned long * /* maskRet */, + SmsCallbacks * /* callbacksRet */, + char ** /* failureReasonRet */ +); + + + +/* + * Error handlers + */ + +typedef void (*SmcErrorHandler) ( + SmcConn /* smcConn */, + Bool /* swap */, + int /* offendingMinorOpcode */, + unsigned long /* offendingSequence */, + int /* errorClass */, + int /* severity */, + SmPointer /* values */ +); + +typedef void (*SmsErrorHandler) ( + SmsConn /* smsConn */, + Bool /* swap */, + int /* offendingMinorOpcode */, + unsigned long /* offendingSequence */, + int /* errorClass */, + int /* severity */, + SmPointer /* values */ +); + + + +/* + * Function Prototypes + */ + +_XFUNCPROTOBEGIN + +extern SmcConn SmcOpenConnection ( + char * /* networkIdsList */, + SmPointer /* context */, + int /* xsmpMajorRev */, + int /* xsmpMinorRev */, + unsigned long /* mask */, + SmcCallbacks * /* callbacks */, + char * /* previousId */, + char ** /* clientIdRet */, + int /* errorLength */, + char * /* errorStringRet */ +); + +extern SmcCloseStatus SmcCloseConnection ( + SmcConn /* smcConn */, + int /* count */, + char ** /* reasonMsgs */ +); + +extern void SmcModifyCallbacks ( + SmcConn /* smcConn */, + unsigned long /* mask */, + SmcCallbacks * /* callbacks */ +); + +extern void SmcSetProperties ( + SmcConn /* smcConn */, + int /* numProps */, + SmProp ** /* props */ +); + +extern void SmcDeleteProperties ( + SmcConn /* smcConn */, + int /* numProps */, + char ** /* propNames */ +); + +extern Status SmcGetProperties ( + SmcConn /* smcConn */, + SmcPropReplyProc /* propReplyProc */, + SmPointer /* clientData */ +); + +extern Status SmcInteractRequest ( + SmcConn /* smcConn */, + int /* dialogType */, + SmcInteractProc /* interactProc */, + SmPointer /* clientData */ +); + +extern void SmcInteractDone ( + SmcConn /* smcConn */, + Bool /* cancelShutdown */ +); + +extern void SmcRequestSaveYourself ( + SmcConn /* smcConn */, + int /* saveType */, + Bool /* shutdown */, + int /* interactStyle */, + Bool /* fast */, + Bool /* global */ +); + +extern Status SmcRequestSaveYourselfPhase2 ( + SmcConn /* smcConn */, + SmcSaveYourselfPhase2Proc /* saveYourselfPhase2Proc */, + SmPointer /* clientData */ +); + +extern void SmcSaveYourselfDone ( + SmcConn /* smcConn */, + Bool /* success */ +); + +extern int SmcProtocolVersion ( + SmcConn /* smcConn */ +); + +extern int SmcProtocolRevision ( + SmcConn /* smcConn */ +); + +extern char *SmcVendor ( + SmcConn /* smcConn */ +); + +extern char *SmcRelease ( + SmcConn /* smcConn */ +); + +extern char *SmcClientID ( + SmcConn /* smcConn */ +); + +extern IceConn SmcGetIceConnection ( + SmcConn /* smcConn */ +); + +extern Status SmsInitialize ( + const char * /* vendor */, + const 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 100644 index 0000000..228e0ce --- /dev/null +++ b/include/X11/SM/SMproto.h @@ -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 + +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 index 0000000..231cc0e --- /dev/null +++ b/packaging/libSM.spec @@ -0,0 +1,74 @@ +Summary: X.Org X11 SM runtime library +Name: libSM +Version: 1.2.1 +Release: 1 +License: MIT +Group: System Environment/Libraries +URL: http://www.x.org + +Source0: %{name}-%{version}.tar.gz + +BuildRequires: pkgconfig +BuildRequires: pkgconfig(xproto) +BuildRequires: pkgconfig(xorg-macros) +BuildRequires: xorg-x11-xtrans-devel >= 1.0.3-4 +BuildRequires: libICE-devel +BuildRequires: libuuid-devel + +%description +The X.Org X11 SM (Session Management) runtime library. + +%package devel +Summary: X.Org X11 SM development package +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: libICE-devel + +%description devel +The X.Org X11 SM (Session Management) development package. + +%prep +%setup -q + +%build + +%reconfigure --with-libuuid --disable-static \ + LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed" +make %{?jobs:-j%jobs} + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p %{buildroot}/usr/share/license +cp -af COPYING %{buildroot}/usr/share/license/%{name} +make install DESTDIR=$RPM_BUILD_ROOT + +# We intentionally don't ship *.la files +rm -f $RPM_BUILD_ROOT%{_libdir}/*.la + +# we %%doc these ourselves, later, and only the text versions +rm -rf $RPM_BUILD_ROOT%{_docdir} + +%remove_docs + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root,-) +/usr/share/license/%{name} +#%doc AUTHORS COPYING ChangeLog +%{_libdir}/libSM.so.6 +%{_libdir}/libSM.so.6.* + +%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 index 0000000..3c82387 --- /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: +Requires.private: ice xproto +Cflags: -I${includedir} +Libs: -L${libdir} -lSM diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..a094ccc --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,32 @@ +lib_LTLIBRARIES=libSM.la + +AM_CPPFLAGS = -I${top_srcdir}/include +AM_CFLAGS = $(CWARNFLAGS) $(SM_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) + +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 100644 index 0000000..c788739 --- /dev/null +++ b/src/SMlibint.h @@ -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 +#include +#include +#include +#include +#include + +#include + +#ifndef NULL +#include +#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 = 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 = 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 = malloc (_count * sizeof (SmProp *)); \ + for (_i = 0; _i < _count; _i++) \ + { \ + _props[_i] = 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 = 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 100644 index 0000000..fcc180a --- /dev/null +++ b/src/sm_auth.c @@ -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 +#endif +#include +#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 index 0000000..23d8e32 --- /dev/null +++ b/src/sm_client.c @@ -0,0 +1,602 @@ +/* + +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 +#endif +#include +#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); + + +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 = 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 (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 (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 (smcConn); + + return (NULL); + } + else if (gotReply) + { + if (reply.status == 1) + { + /* + * The client successfully registered. + */ + + *clientIdRet = reply.client_id; + + smcConn->client_id = strdup (*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); +} + + + +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 (ptr); + ptr = next; + } + + } + + free (smcConn); + + if (closeStatus == IceClosedNow) + statusRet = SmcClosedNow; + else if (closeStatus == IceClosedASAP) + statusRet = SmcClosedASAP; + else + statusRet = SmcConnectionInUse; + + return (statusRet); +} + + + +void +SmcModifyCallbacks(SmcConn smcConn, unsigned long mask, SmcCallbacks *callbacks) +{ + set_callbacks (smcConn, mask, callbacks); +} + + + +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); +} + + + +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); +} + + + +Status +SmcGetProperties(SmcConn smcConn, SmcPropReplyProc propReplyProc, + SmPointer clientData) +{ + IceConn iceConn = smcConn->iceConn; + _SmcPropReplyWait *wait, *ptr; + + if ((wait = malloc (sizeof (_SmcPropReplyWait))) == NULL) + { + return (0); + } + + wait->prop_reply_proc = propReplyProc; + wait->client_data = clientData; + wait->next = NULL; + + ptr = smcConn->prop_reply_waits; + while (ptr && ptr->next) + ptr = ptr->next; + + if (ptr == NULL) + smcConn->prop_reply_waits = wait; + else + ptr->next = wait; + + IceSimpleMessage (iceConn, _SmcOpcode, SM_GetProperties); + IceFlush (iceConn); + + return (1); +} + + + +Status +SmcInteractRequest(SmcConn smcConn, int dialogType, + SmcInteractProc interactProc, SmPointer clientData) +{ + IceConn iceConn = smcConn->iceConn; + smInteractRequestMsg *pMsg; + _SmcInteractWait *wait, *ptr; + + if ((wait = malloc (sizeof (_SmcInteractWait))) == NULL) + { + return (0); + } + + wait->interact_proc = interactProc; + wait->client_data = clientData; + wait->next = NULL; + + ptr = smcConn->interact_waits; + while (ptr && ptr->next) + ptr = ptr->next; + + if (ptr == NULL) + smcConn->interact_waits = wait; + else + ptr->next = wait; + + IceGetHeader (iceConn, _SmcOpcode, SM_InteractRequest, + SIZEOF (smInteractRequestMsg), smInteractRequestMsg, pMsg); + + pMsg->dialogType = dialogType; + + IceFlush (iceConn); + + return (1); +} + + + +void +SmcInteractDone(SmcConn smcConn, Bool cancelShutdown) +{ + IceConn iceConn = smcConn->iceConn; + smInteractDoneMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_InteractDone, + SIZEOF (smInteractDoneMsg), smInteractDoneMsg, pMsg); + + pMsg->cancelShutdown = cancelShutdown; + + IceFlush (iceConn); +} + + + +void +SmcRequestSaveYourself(SmcConn smcConn, int saveType, Bool shutdown, + int interactStyle, Bool fast, Bool global) +{ + IceConn iceConn = smcConn->iceConn; + smSaveYourselfRequestMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfRequest, + SIZEOF (smSaveYourselfRequestMsg), smSaveYourselfRequestMsg, pMsg); + + pMsg->saveType = saveType; + pMsg->shutdown = shutdown; + pMsg->interactStyle = interactStyle; + pMsg->fast = fast; + pMsg->global = global; + + IceFlush (iceConn); +} + + + +Status +SmcRequestSaveYourselfPhase2(SmcConn smcConn, + SmcSaveYourselfPhase2Proc saveYourselfPhase2Proc, + SmPointer clientData) +{ + IceConn iceConn = smcConn->iceConn; + _SmcPhase2Wait *wait; + + if (smcConn->phase2_wait) + wait = smcConn->phase2_wait; + else + { + if ((wait = malloc (sizeof (_SmcPhase2Wait))) == NULL) + { + return (0); + } + } + + wait->phase2_proc = saveYourselfPhase2Proc; + wait->client_data = clientData; + + smcConn->phase2_wait = wait; + + IceSimpleMessage (iceConn, _SmcOpcode, SM_SaveYourselfPhase2Request); + IceFlush (iceConn); + + return (1); +} + + + +void +SmcSaveYourselfDone(SmcConn smcConn, Bool success) +{ + IceConn iceConn = smcConn->iceConn; + smSaveYourselfDoneMsg *pMsg; + + IceGetHeader (iceConn, _SmcOpcode, SM_SaveYourselfDone, + SIZEOF (smSaveYourselfDoneMsg), smSaveYourselfDoneMsg, pMsg); + + pMsg->success = success; + + IceFlush (iceConn); +} + + + +static void +set_callbacks(SmcConn 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 100644 index 0000000..29f6e45 --- /dev/null +++ b/src/sm_error.c @@ -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 +#endif +#include +#include "SMlibint.h" +#include + + + +/* + * 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); +} + + + +/* + * 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 */ +} + + + +/* + * 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); +} + + + +/* + * 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 100644 index 0000000..c6731d8 --- /dev/null +++ b/src/sm_genid.c @@ -0,0 +1,248 @@ +/* + +Copyright (c) 2002, 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. + +*/ +/* + +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 +#endif +#include +#include "SMlibint.h" +#ifdef XTHREADS +# include +#endif +#include + +#include +#define Time_t time_t + +#ifndef WIN32 + +# if defined(TCPCONN) || defined(STREAMSCONN) +# include +# include +# include +# define XOS_USE_NO_LOCKING +# define X_INCLUDE_NETDB_H +# include +# endif + +#else /* WIN32 */ + +# include +# include +# define X_INCLUDE_NETDB_H +# define XOS_USE_MTSAFE_NETDBAPI +# include + +#endif /* WIN32 */ + +#ifdef MNX_TCPCONN +# include + +# define TCPCONN +#endif + +#if defined(HAVE_UUID_CREATE) +# include +#elif defined(HAVE_LIBUUID) +# include +#endif + + +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]); + + id = strdup (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; + char* inet_addr; + char *ptr1; + unsigned char decimal[4]; + int i, len; + struct in_addr *haddr = NULL; +# if defined(IPv6) && defined(AF_INET6) + struct addrinfo *ai, *first_ai; +# endif + + if (gethostname (hostname, sizeof (hostname))) + return (NULL); + +# if defined(IPv6) && defined(AF_INET6) + 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++) + { + char temp4[4]; + char *ptr2 = strchr (ptr1, '.'); + + len = ptr2 - ptr1; + if (!ptr2 || len > 3) { +# if defined(IPv6) && defined(AF_INET6) + freeaddrinfo(first_ai); +# endif + return (NULL); + } + strncpy (temp4, ptr1, len); + temp4[len] = '\0'; + decimal[i] = atoi (temp4); + 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; + + id = strdup (temp); + + return (id); +# else + return (NULL); +# endif +#endif +} diff --git a/src/sm_manager.c b/src/sm_manager.c new file mode 100644 index 0000000..7a11a33 --- /dev/null +++ b/src/sm_manager.c @@ -0,0 +1,340 @@ +/* + +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 +#endif +#include +#include "SMlibint.h" +#include + +#ifdef __UNIXWARE__ +#undef shutdown +#endif + + + +static Status +_SmsProtocolSetupProc (IceConn iceConn, + int majorVersion, + int minorVersion, + char *vendor, + char *release, + IcePointer *clientDataRet, + char **failureReasonRet) +{ + SmsConn smsConn; + unsigned long mask; + Status status; + + /* + * vendor/release are undefined for ProtocolSetup in XSMP. + */ + + if (vendor) + free (vendor); + if (release) + free (release); + + + /* + * Allocate new SmsConn. + */ + + if ((smsConn = malloc (sizeof (struct _SmsConn))) == NULL) + { + const char *str = "Memory allocation failed"; + + *failureReasonRet = strdup (str); + + return (0); + } + + smsConn->iceConn = iceConn; + smsConn->proto_major_version = majorVersion; + smsConn->proto_minor_version = minorVersion; + smsConn->client_id = NULL; + + smsConn->save_yourself_in_progress = False; + smsConn->interaction_allowed = SmInteractStyleNone; + smsConn->can_cancel_shutdown = False; + smsConn->interact_in_progress = False; + + *clientDataRet = (IcePointer) smsConn; + + + /* + * Now give the session manager the new smsConn and get back the + * callbacks to invoke when messages arrive from the client. + * + * In the future, we can use the mask return value to check + * if the SM is expecting an older rev of SMlib. + */ + + bzero ((char *) &smsConn->callbacks, sizeof (SmsCallbacks)); + + status = (*_SmsNewClientProc) (smsConn, _SmsNewClientData, + &mask, &smsConn->callbacks, failureReasonRet); + + return (status); +} + + + + +Status +SmsInitialize(const char *vendor, const 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); +} + + + +char * +SmsClientHostName(SmsConn smsConn) +{ + return (IceGetPeerName (smsConn->iceConn)); +} + + + +Status +SmsRegisterClientReply(SmsConn smsConn, char *clientId) +{ + IceConn iceConn = smsConn->iceConn; + int extra; + smRegisterClientReplyMsg *pMsg; + char *pData; + + if ((smsConn->client_id = strdup (clientId)) == NULL) + { + return (0); + } + + extra = ARRAY8_BYTES (strlen (clientId)); + + IceGetHeaderExtra (iceConn, _SmsOpcode, SM_RegisterClientReply, + SIZEOF (smRegisterClientReplyMsg), WORD64COUNT (extra), + smRegisterClientReplyMsg, pMsg, pData); + + STORE_ARRAY8 (pData, strlen (clientId), clientId); + + IceFlush (iceConn); + + return (1); +} + + + +void +SmsSaveYourself(SmsConn smsConn, int saveType, Bool shutdown, + int interactStyle, Bool fast) +{ + IceConn iceConn = smsConn->iceConn; + smSaveYourselfMsg *pMsg; + + IceGetHeader (iceConn, _SmsOpcode, SM_SaveYourself, + SIZEOF (smSaveYourselfMsg), smSaveYourselfMsg, pMsg); + + pMsg->saveType = saveType; + pMsg->shutdown = shutdown; + pMsg->interactStyle = interactStyle; + pMsg->fast = fast; + + IceFlush (iceConn); + + smsConn->save_yourself_in_progress = True; + + if (interactStyle == SmInteractStyleNone || + interactStyle == SmInteractStyleErrors || + interactStyle == SmInteractStyleAny) + { + smsConn->interaction_allowed = interactStyle; + } + else + { + smsConn->interaction_allowed = SmInteractStyleNone; + } + + smsConn->can_cancel_shutdown = shutdown && + (interactStyle == SmInteractStyleAny || + interactStyle == SmInteractStyleErrors); +} + + + +void +SmsSaveYourselfPhase2(SmsConn smsConn) +{ + IceConn iceConn = smsConn->iceConn; + + IceSimpleMessage (iceConn, _SmsOpcode, SM_SaveYourselfPhase2); + IceFlush (iceConn); +} + + + +void +SmsInteract(SmsConn smsConn) +{ + IceConn iceConn = smsConn->iceConn; + + IceSimpleMessage (iceConn, _SmsOpcode, SM_Interact); + IceFlush (iceConn); + + smsConn->interact_in_progress = True; +} + + + +void +SmsDie(SmsConn smsConn) +{ + IceConn iceConn = smsConn->iceConn; + + IceSimpleMessage (iceConn, _SmsOpcode, SM_Die); + IceFlush (iceConn); +} + + + +void +SmsSaveComplete(SmsConn smsConn) +{ + IceConn iceConn = smsConn->iceConn; + + IceSimpleMessage (iceConn, _SmsOpcode, SM_SaveComplete); + IceFlush (iceConn); +} + + + +void +SmsShutdownCancelled(SmsConn smsConn) +{ + IceConn iceConn = smsConn->iceConn; + + IceSimpleMessage (iceConn, _SmsOpcode, SM_ShutdownCancelled); + IceFlush (iceConn); + + smsConn->can_cancel_shutdown = False; +} + + + +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); +} + + + +void +SmsCleanUp(SmsConn smsConn) +{ + IceProtocolShutdown (smsConn->iceConn, _SmsOpcode); + + if (smsConn->client_id) + free (smsConn->client_id); + + free (smsConn); +} diff --git a/src/sm_misc.c b/src/sm_misc.c new file mode 100644 index 0000000..83d1259 --- /dev/null +++ b/src/sm_misc.c @@ -0,0 +1,162 @@ +/* + +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 +#endif +#include +#include "SMlibint.h" +#include + +/* + * 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 (prop->vals[i].value); + free (prop->vals); + } + + free (prop); + } +} + + +/* + * Free reason messages + */ + +void +SmFreeReasons(int count, char **reasonMsgs) +{ + if (reasonMsgs) + { + int i; + + for (i = 0; i < count; i++) + free (reasonMsgs[i]); + + free (reasonMsgs); + } +} + + + +/* + * 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) +{ + return strdup(smcConn->vendor); +} + + +char * +SmcRelease(SmcConn smcConn) +{ + return strdup(smcConn->release); +} + + +char * +SmcClientID(SmcConn smcConn) +{ + return strdup(smcConn->client_id); +} + + +IceConn +SmcGetIceConnection(SmcConn smcConn) +{ + return (smcConn->iceConn); +} + + + +/* + * 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) +{ + return strdup(smsConn->client_id); +} + + +IceConn +SmsGetIceConnection(SmsConn smsConn) +{ + return (smsConn->iceConn); +} diff --git a/src/sm_process.c b/src/sm_process.c new file mode 100644 index 0000000..651ddef --- /dev/null +++ b/src/sm_process.c @@ -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 +#endif +#include +#include "SMlibint.h" + + +/* + * Check for bad length + */ + +#define CHECK_SIZE_MATCH(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _severity) \ + if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) != _expected_len) \ + { \ + _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \ + return; \ + } + +#define CHECK_AT_LEAST_SIZE(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _severity) \ + if ((((_actual_len) - SIZEOF (iceMsg)) >> 3) > _expected_len) \ + { \ + _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \ + return; \ + } + +#define CHECK_COMPLETE_SIZE(_iceConn, _majorOp, _minorOp, _expected_len, _actual_len, _pStart, _severity) \ + if (((PADDED_BYTES64((_actual_len)) - SIZEOF (iceMsg)) >> 3) \ + != _expected_len) \ + { \ + _IceErrorBadLength (_iceConn, _majorOp, _minorOp, _severity); \ + IceDisposeCompleteMessage (iceConn, _pStart); \ + return; \ + } + + + +void +_SmcProcessMessage(IceConn 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 (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 (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 (smcConn->prop_reply_waits); + smcConn->prop_reply_waits = next; + + IceDisposeCompleteMessage (iceConn, pStart); + } + break; + + default: + { + _IceErrorBadMinor (iceConn, _SmcOpcode, opcode, IceCanContinue); + _IceReadSkip (iceConn, length << 3); + break; + } + } +} + + + +void +_SmsProcessMessage(IceConn 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 = 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 = 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; + } + } +} -- 2.7.4