]> git.pond.sub.org Git - empserver/commitdiff
(service_main) [_WIN32]: Remove the command line processing.
authorRon Koenderink <rkoenderink@yahoo.ca>
Sun, 6 Mar 2005 20:58:48 +0000 (20:58 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sun, 6 Mar 2005 20:58:48 +0000 (20:58 +0000)
The secondary command line processing was adding significant
complexity for minimial gain.  Now all the command line arguments
can be prequalified during the installation of the service.

(service_main) [_WIN32]: Move the initialization (init_server())
so logerror() will go to the file instead of stderr.

src/lib/gen/service.c

index 00c943ca2c5bf3fac240289b574c5a24c8c03e2b..71ed1c5eae698702b77a8042f30d60d32b16f335 100644 (file)
@@ -36,7 +36,6 @@
 
 #include "prototypes.h"
 #include "service.h"
-#include "../gen/getopt.h"
 #include "optlist.h"
 
 int
@@ -203,30 +202,8 @@ service_ctrl_handler(DWORD Opcode)
 
 void WINAPI
 service_main(DWORD argc, LPTSTR *argv)
-{ 
-    int op;
-    s_char tbuf[256];
-    DWORD status;
-    char *config_file = NULL;
-
-    optind = 1;
-    opterr = 1;
-    while ((op = getopt(argc, argv, "D:e:")) != EOF) {
-       switch (op) {
-       case 'D':
-               datadir = optarg;
-               break;
-       case 'e':
-               config_file = optarg;
-               break;
-       }
-    }  
-
-    if (config_file == NULL) {
-       sprintf(tbuf, "%s/econfig", datadir);
-       config_file = tbuf;
-    }
-    emp_config(config_file);
+{
+    init_server(0);
 
     service_status.dwServiceType        = SERVICE_WIN32; 
     service_status.dwCurrentState       = SERVICE_START_PENDING; 
@@ -244,8 +221,6 @@ service_main(DWORD argc, LPTSTR *argv)
         return; 
     }
  
-    /* Initialization code goes here. */
-    init_server(0);
     start_server(0);
  
     /* Initialization complete - report running status. */
@@ -254,18 +229,17 @@ service_main(DWORD argc, LPTSTR *argv)
     service_status.dwWaitHint           = 0; 
  
     if (!SetServiceStatus (service_status_handle, &service_status)) { 
-        status = GetLastError();
-        logerror("SetServiceStatus error %ld\n",status);
+        logerror("SetServiceStatus error %ld\n", GetLastError());
     }
 
     empth_exit();
 
-/* We should never get here.  But, just in case... */
+    /* We should never get here.  But, just in case... */
     close_files();
 
     loc_NTTerm();
 
-    // This is where the service does its work.
+    /* This is where the service does its work. */
     logerror("Returning the Main Thread \n",0);
     return;
 }