(service_main) [_WIN32]: Remove the command line processing.
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.
This commit is contained in:
parent
46a11d0d93
commit
ab2bea5810
1 changed files with 5 additions and 31 deletions
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "../gen/getopt.h"
|
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -204,29 +203,7 @@ service_ctrl_handler(DWORD Opcode)
|
||||||
void WINAPI
|
void WINAPI
|
||||||
service_main(DWORD argc, LPTSTR *argv)
|
service_main(DWORD argc, LPTSTR *argv)
|
||||||
{
|
{
|
||||||
int op;
|
init_server(0);
|
||||||
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);
|
|
||||||
|
|
||||||
service_status.dwServiceType = SERVICE_WIN32;
|
service_status.dwServiceType = SERVICE_WIN32;
|
||||||
service_status.dwCurrentState = SERVICE_START_PENDING;
|
service_status.dwCurrentState = SERVICE_START_PENDING;
|
||||||
|
@ -244,8 +221,6 @@ service_main(DWORD argc, LPTSTR *argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialization code goes here. */
|
|
||||||
init_server(0);
|
|
||||||
start_server(0);
|
start_server(0);
|
||||||
|
|
||||||
/* Initialization complete - report running status. */
|
/* Initialization complete - report running status. */
|
||||||
|
@ -254,8 +229,7 @@ service_main(DWORD argc, LPTSTR *argv)
|
||||||
service_status.dwWaitHint = 0;
|
service_status.dwWaitHint = 0;
|
||||||
|
|
||||||
if (!SetServiceStatus (service_status_handle, &service_status)) {
|
if (!SetServiceStatus (service_status_handle, &service_status)) {
|
||||||
status = GetLastError();
|
logerror("SetServiceStatus error %ld\n", GetLastError());
|
||||||
logerror("SetServiceStatus error %ld\n",status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
empth_exit();
|
empth_exit();
|
||||||
|
@ -265,7 +239,7 @@ service_main(DWORD argc, LPTSTR *argv)
|
||||||
|
|
||||||
loc_NTTerm();
|
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);
|
logerror("Returning the Main Thread \n",0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue