switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / Daemon / Daemon.hh
index 747120f..3e15903 100644 (file)
@@ -2,23 +2,28 @@
 //
 // Copyright (C) 2007
 // Fraunhofer Institute for Open Communication Systems (FOKUS)
-// Competence Center NETwork research (NET), St. Augustin, GERMANY
-//     Stefan Bund <g0dil@berlios.de>
 //
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// The contents of this file are subject to the Fraunhofer FOKUS Public License
+// Version 1.0 (the "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at 
+// http://senf.berlios.de/license.html
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// The Fraunhofer FOKUS Public License Version 1.0 is based on, 
+// but modifies the Mozilla Public License Version 1.1.
+// See the full license text for the amendments.
 //
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the
-// Free Software Foundation, Inc.,
-// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+// Software distributed under the License is distributed on an "AS IS" basis, 
+// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
+// for the specific language governing rights and limitations under the License.
+//
+// The Original Code is Fraunhofer FOKUS code.
+//
+// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
+// (registered association), Hansastraße 27 c, 80686 Munich, Germany.
+// All Rights Reserved.
+//
+// Contributor(s):
+//   Stefan Bund <g0dil@berlios.de>
 
 /** \file
     \brief Daemon public header */
 #define HH_SENF_Utils_Daemon_Daemon_ 1
 
 // Custom includes
-#include <boost/utility.hpp>
 #include <senf/Utils/Logger/SenfLog.hh>
 
 //#include "Daemon.mpp"
-///////////////////////////////hh.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 
 namespace senf {
 
     /** \brief %Daemon process
 
-        The %Daemon class provides simple management for daemon processes. Specifically, it implements
+        The %Daemon class provides simple management for daemon processes. Specifically, it
+        implements
         \li <i>Safe startup.</i> If the startup fails, the foreground process which launches the
             daemon will terminate with an appropriate error exit code.
         \li <i>Straight forward application initialization.</i> The daemon process is forked before
-            even initializing the application. The initialization procedure must not cater for a
-            later fork().
-        \li <i>Automatic pid file management.</i> The daemon will not be started, if a valid pid file is
-            found. Stale pid files are automatically removed.
-        \li <i>Console log management.</i> It is possible, to redirect standard output and error to
-            one or two log files. Messages pertaining to application initialization will be written
-            to both the console and the log file whereas later messages will be directed to the log
+            even initializing the application. The initialization procedure doesn't need to cater
+            for a later fork().
+        \li <i>Automatic pid file management.</i> The daemon will not be started, if a valid pid
+            file is found. Stale pid files are automatically removed.
+        \li <i>Console %log management.</i> It is possible, to redirect standard output and error to
+            one or two %log files. Messages pertaining to application initialization will be written
+            to both the %console and the %log file whereas later messages will be directed to the log
             file only.
         \li <i>Optional foreground execution.</i> The daemon may be started in the foreground for
-            debugging purposes. In this case, the console log file(s) is/are automatically
+            debugging purposes. In this case, the %console %log file(s) is/are automatically
             suppressed.
 
         Starting the daemon process proceeds along the following steps:
@@ -58,7 +63,7 @@ namespace senf {
             normally happens from the \c main() function generated by \ref SENF_DAEMON_MAIN().
         \li configure() is called. This (virtual) member configures the daemon manager by calling
             the Daemon class parameter members.
-        \li The log files are opened, \c fork() is called and the pid file is checked and
+        \li The %log files are opened, \c fork() is called and the pid file is checked and
             created. The parent (foreground) process keeps running overseeing the daemon process.
         \li main() is called. This virtual member may optionally be overridden in the derived
             class. Here we assume, main() is not overridden so the default implementation is used.
@@ -80,11 +85,11 @@ namespace senf {
         <tr><td><tt>--no-daemon</tt></td><td>Run in foreground</td></tr>
 
         <tr><td><tt>--console-log=</tt><i>stdout</i>[<tt>,</tt><i>stderr</i>]</td><td>Set the
-        console log file(s). If only \a stdout is specified (with no comma), the same log file
+        %console %log file(s). If only \a stdout is specified (with no comma), the same %log file
         configuration will be applied to the standard output and error stream. Otherwise each stream
-        is assigned it's own log file. If either log file name is empty, the command will not change
-        the log file of that stream, the default log file will be used. If the log file name is set
-        to 'none', the log file will be disabled.</td></tr>
+        is assigned it's own %log file. If either %log file name is empty, the command will not change
+        the %log file of that stream, the default %log file will be used. If the %log file name is set
+        to 'none', the %log file will be disabled.</td></tr>
 
         <tr><td><tt>--pid-file=</tt><i>pidfile</i></td><td>Set pid file path</td></tr>
 
@@ -93,9 +98,9 @@ namespace senf {
         The default configure() implementation will use whatever parameters have been set beforehand
         as default values. These default values should be set in a derived class configure()
         implementation. After setting the default values, the configure() implementation may choose
-        to call this default configure() implementation to scan for command line parmeters.  The
+        to call this default configure() implementation to scan for command line parameters.  The
         default configure() implementation does \e not completely parse the command line
-        arguments. It just checks, if any of above arguments are present and precesses them. Other
+        arguments. It just checks, if any of above arguments are present and processes them. Other
         arguments are completely ignored. The command line parameters should be completely processed
         within init().
 
@@ -105,7 +110,7 @@ namespace senf {
     public:
         SENF_LOG_CLASS_AREA();
 
-        ///////////////////////////////////////////////////////////////////////////
+        //-/////////////////////////////////////////////////////////////////////////
         // Types
 
         /// Select standard stream to redirect
@@ -115,27 +120,27 @@ namespace senf {
         ,   Both    /** Both, standard output and error stream */
         };
 
-        ///////////////////////////////////////////////////////////////////////////
+        //-/////////////////////////////////////////////////////////////////////////
         ///\name Structors and default members
-        ///\{
+        //\{
 
         virtual ~Daemon();
 
-        ///\}
+        //\}
         ///\name Parameters
-        ///\{
+        //\{
 
         void daemonize(bool);           ///< Configure whether to run in fore- or background
         bool daemon();                  ///< \c true, if running as daemon
 
         void consoleLog(std::string const &, StdStream which = Both);
-                                        ///< Configure console log file
-                                        /**< May be called multiple times to set the log file
-                                             for stdout and stderr seperately. Any standard stream
-                                             not assigned to a log file will be redirected to
+                                        ///< Configure %console %log file
+                                        /**< May be called multiple times to set the %log file
+                                             for stdout and stderr separately. Any standard stream
+                                             not assigned to a %log file will be redirected to
                                              <tt>/dev/null</tt>.
 
-                                             When running in the foreground, the log files will be
+                                             When running in the foreground, the %log files will be
                                              ignored. */
 
         void pidFile(std::string const &); ///< Configure pid file
@@ -143,9 +148,9 @@ namespace senf {
                                              daemon startup. If another running instance of the
                                              daemon is detected, starting the daemon will fail. */
 
-        ///\}
+        //\}
         ///\name Auxiliary helpers
-        ///\{
+        //\{
 
         void detach();                  ///< Detach into background now
                                         /**< This is \e not the same as forking. The process will
@@ -161,11 +166,11 @@ namespace senf {
 
         static void exit(unsigned code=0); ///< Terminate daemon with failure
 
-        void logReopen();               ///< Reopen the log files
+        void logReopen();               ///< Reopen the %log files
                                         /**< This is used when rotating the logs. By default,
                                              SIGHUP calls logReopen. */
 
-        ///\}
+        //\}
 
         int start(int argc, char const ** argv); ///< Called from main() to launch daemon.
                                         /**< Normally not called directly but from the
@@ -241,7 +246,7 @@ namespace senf {
 
 }
 
-///////////////////////////////hh.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 #include "Daemon.cci"
 //#include "Daemon.ct"
 //#include "Daemon.cti"