]> granicus.if.org Git - pdns/commitdiff
wimpie
authorBert Hubert <bert.hubert@netherlabs.nl>
Fri, 29 Nov 2002 22:15:43 +0000 (22:15 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Fri, 29 Nov 2002 22:15:43 +0000 (22:15 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@33 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/ntservice.hh [new file with mode: 0644]

diff --git a/pdns/ntservice.hh b/pdns/ntservice.hh
new file mode 100644 (file)
index 0000000..e77f61d
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+    PowerDNS Versatile Database Driven Nameserver
+    Copyright (C) 2002  PowerDNS.COM BV
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+\r
+/*!\r
+\file ntservice.hh\r
+\brief This file contains the NTService class specification.\r
+*/\r
+\r
+#ifndef NTSERVICE_HH\r
+#define NTSERVICE_HH\r
+\r
+#define WINDOWS_LEAN_AND_MEAN\r
+#include <windows.h>\r
+\r
+#include <string>\r
+#include "singleton.hh"\r
+\r
+\r
+//! The NTService class is responsible for giving the program NT Service characteristics.\r
+class NTService : public Singleton< NTService >\r
+{\r
+private:\r
+  //! Is the program running as a NT Service?\r
+  bool m_runningAsService;\r
+  \r
+  //! Service status handle.\r
+  SERVICE_STATUS_HANDLE m_serviceStatusHandle;\r
+  \r
+protected:\r
+  //! Status code.\r
+  DWORD m_statusCode;\r
+\r
+  //! Error code.\r
+  DWORD m_errorCode;\r
+\r
+  //! Main function.\r
+  virtual int main( int argc, char *argv[] )\r
+  {\r
+    return 0;\r
+  }\r
+\r
+  //! Control handler.\r
+  virtual void ctrlHandler( DWORD controlCode )\r
+  {\r
+  }\r
+\r
+  //! Sets the service's status and error codes.\r
+  void setStatus( DWORD status, DWORD error = 0 );\r
+  \r
+public:\r
+  //! Default constructor.\r
+  NTService( void );\r
+\r
+  //! Destructor.\r
+  virtual ~NTService( void );\r
+\r
+  //! Starts the service.\r
+  int start( int argc, char *argv[], bool asService = true );\r
+\r
+  //! Control handler (calls NTService::ctrlHandler()).\r
+  static void WINAPI s_ctrlHandler( DWORD controlCode );\r
+  \r
+  //! Service main (calls NTService::main()).\r
+  static void WINAPI s_serviceMain( DWORD argc, LPTSTR *argv );\r
+  \r
+  //! Returns the name of the service.\r
+  virtual std::string getServiceName( void )\r
+  {\r
+    return "NTService";\r
+  }\r
+\r
+  //! Returns whether the program is running as a service or not.\r
+  bool isRunningAsService( void );\r
+  \r
+  //! Registers the service with the system.\r
+  bool registerService( const std::string & description, bool registerLog = true );\r
+\r
+  //! Unregisters the service.\r
+  bool unregisterService( void );\r
+  \r
+  //! Stops the service.\r
+  bool stop( void );\r
+\r
+};\r
+\r
+\r
+#endif // NTSERVICE_H\r
+\r