move windows service cruft into service.c
diff --git a/src/main.cpp b/src/main.cpp
index d1035a6..834277c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -288,114 +288,6 @@
     thread_destroy( );
 } // end cleanup
 
-#ifdef WIN32
-/*--------------------------------------------------------------------
- * ServiceStart
- *
- * each time starting the service, this is the entry point of the service.
- * Start the service, certainly it is on server-mode
- * 
- *-------------------------------------------------------------------- */
-VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv) {
-    
-    // report the status to the service control manager.
-    //
-    if ( !ReportStatusToSCMgr(
-                             SERVICE_START_PENDING, // service state
-                             NO_ERROR,              // exit code
-                             3000) )                 // wait hint
-        goto clean;
-
-    thread_Settings* ext_gSettings = new thread_Settings;
-
-    // Initialize settings to defaults
-    Settings_Initialize( ext_gSettings );
-    // read settings from environment variables
-    Settings_ParseEnvironment( ext_gSettings );
-    // read settings from command-line parameters
-    Settings_ParseCommandLine( dwArgc, lpszArgv, ext_gSettings );
-
-    // report the status to the service control manager.
-    //
-    if ( !ReportStatusToSCMgr(
-                             SERVICE_START_PENDING, // service state
-                             NO_ERROR,              // exit code
-                             3000) )                 // wait hint
-        goto clean;
-
-    // if needed, redirect the output into a specified file
-    if ( !isSTDOUT( ext_gSettings ) ) {
-        redirect( ext_gSettings->mOutputFileName );
-    }
-
-    // report the status to the service control manager.
-    //
-    if ( !ReportStatusToSCMgr(
-                             SERVICE_START_PENDING, // service state
-                             NO_ERROR,              // exit code
-                             3000) )                 // wait hint
-        goto clean;
-    
-    // initialize client(s)
-    if ( ext_gSettings->mThreadMode == kMode_Client ) {
-        client_init( ext_gSettings );
-    }
-
-    // start up the reporter and client(s) or listener
-    {
-        thread_Settings *into = NULL;
-#ifdef HAVE_THREAD
-        Settings_Copy( ext_gSettings, &into );
-        into->mThreadMode = kMode_Reporter;
-        into->runNow = ext_gSettings;
-#else
-        into = ext_gSettings;
-#endif
-        thread_start( into );
-    }
-    
-    // report the status to the service control manager.
-    //
-    if ( !ReportStatusToSCMgr(
-                             SERVICE_RUNNING,       // service state
-                             NO_ERROR,              // exit code
-                             0) )                    // wait hint
-        goto clean;
-
-    clean:
-    // wait for other (client, server) threads to complete
-    thread_joinall();
-}
-
-
-//
-//  FUNCTION: ServiceStop
-//
-//  PURPOSE: Stops the service
-//
-//  PARAMETERS:
-//    none
-//
-//  RETURN VALUE:
-//    none
-//
-//  COMMENTS:
-//    If a ServiceStop procedure is going to
-//    take longer than 3 seconds to execute,
-//    it should spawn a thread to execute the
-//    stop code, and return.  Otherwise, the
-//    ServiceControlManager will believe that
-//    the service has stopped responding.
-//    
-VOID ServiceStop() {
-#ifdef HAVE_THREAD
-    Sig_Interupt( 1 );
-#else
-    sig_exit(1);
-#endif
-}
-
-#endif
 
 
 
diff --git a/src/service.c b/src/service.c
index 1b9a057..3b9e8eb 100644
--- a/src/service.c
+++ b/src/service.c
@@ -492,4 +492,110 @@
     return lpszBuf;
 }
 
+/*--------------------------------------------------------------------
+ * ServiceStart
+ *
+ * each time starting the service, this is the entry point of the service.
+ * Start the service, certainly it is on server-mode
+ * 
+ *-------------------------------------------------------------------- */
+VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv) {
+    
+    // report the status to the service control manager.
+    //
+    if ( !ReportStatusToSCMgr(
+                             SERVICE_START_PENDING, // service state
+                             NO_ERROR,              // exit code
+                             3000) )                 // wait hint
+        goto clean;
+
+    thread_Settings* ext_gSettings = new thread_Settings;
+
+    // Initialize settings to defaults
+    Settings_Initialize( ext_gSettings );
+    // read settings from environment variables
+    Settings_ParseEnvironment( ext_gSettings );
+    // read settings from command-line parameters
+    Settings_ParseCommandLine( dwArgc, lpszArgv, ext_gSettings );
+
+    // report the status to the service control manager.
+    //
+    if ( !ReportStatusToSCMgr(
+                             SERVICE_START_PENDING, // service state
+                             NO_ERROR,              // exit code
+                             3000) )                 // wait hint
+        goto clean;
+
+    // if needed, redirect the output into a specified file
+    if ( !isSTDOUT( ext_gSettings ) ) {
+        redirect( ext_gSettings->mOutputFileName );
+    }
+
+    // report the status to the service control manager.
+    //
+    if ( !ReportStatusToSCMgr(
+                             SERVICE_START_PENDING, // service state
+                             NO_ERROR,              // exit code
+                             3000) )                 // wait hint
+        goto clean;
+    
+    // initialize client(s)
+    if ( ext_gSettings->mThreadMode == kMode_Client ) {
+        client_init( ext_gSettings );
+    }
+
+    // start up the reporter and client(s) or listener
+    {
+        thread_Settings *into = NULL;
+#ifdef HAVE_THREAD
+        Settings_Copy( ext_gSettings, &into );
+        into->mThreadMode = kMode_Reporter;
+        into->runNow = ext_gSettings;
+#else
+        into = ext_gSettings;
+#endif
+        thread_start( into );
+    }
+    
+    // report the status to the service control manager.
+    //
+    if ( !ReportStatusToSCMgr(
+                             SERVICE_RUNNING,       // service state
+                             NO_ERROR,              // exit code
+                             0) )                    // wait hint
+        goto clean;
+
+    clean:
+    // wait for other (client, server) threads to complete
+    thread_joinall();
+}
+
+
+//
+//  FUNCTION: ServiceStop
+//
+//  PURPOSE: Stops the service
+//
+//  PARAMETERS:
+//    none
+//
+//  RETURN VALUE:
+//    none
+//
+//  COMMENTS:
+//    If a ServiceStop procedure is going to
+//    take longer than 3 seconds to execute,
+//    it should spawn a thread to execute the
+//    stop code, and return.  Otherwise, the
+//    ServiceControlManager will believe that
+//    the service has stopped responding.
+//    
+VOID ServiceStop() {
+#ifdef HAVE_THREAD
+    Sig_Interupt( 1 );
+#else
+    sig_exit(1);
+#endif
+}
+
 #endif