projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed type to avoid warning
[yaz-moved-to-github.git]
/
src
/
sc.c
diff --git
a/src/sc.c
b/src/sc.c
index
27df88a
..
797f9a2
100644
(file)
--- a/
src/sc.c
+++ b/
src/sc.c
@@
-3,6
+3,11
@@
* See the file LICENSE for details.
*/
* See the file LICENSE for details.
*/
+/**
+ * \file sc.c
+ * \brief Windows Service Control
+ */
+
#ifdef WIN32
#include <windows.h>
#include <tchar.h>
#ifdef WIN32
#include <windows.h>
#include <tchar.h>
@@
-25,6
+30,8
@@
struct sc_s {
char *display_name;
int (*sc_main)(yaz_sc_t s, int argc, char **argv);
void (*sc_stop)(yaz_sc_t s);
char *display_name;
int (*sc_main)(yaz_sc_t s, int argc, char **argv);
void (*sc_stop)(yaz_sc_t s);
+ int argc;
+ char **argv;
#ifdef WIN32
SERVICE_STATUS_HANDLE gSvcStatusHandle;
SERVICE_STATUS gSvcStatus;
#ifdef WIN32
SERVICE_STATUS_HANDLE gSvcStatusHandle;
SERVICE_STATUS gSvcStatus;
@@
-34,7
+41,7
@@
struct sc_s {
yaz_sc_t yaz_sc_create(const char *service_name, const char *display_name)
{
yaz_sc_t yaz_sc_create(const char *service_name, const char *display_name)
{
- yaz_sc_t s = xmalloc(sizeof(*s));
+ yaz_sc_t s = (yaz_sc_t) xmalloc(sizeof(*s));
s->service_name = service_name ? xstrdup(service_name) : 0;
s->display_name = display_name ? xstrdup(display_name) : 0;
s->service_name = service_name ? xstrdup(service_name) : 0;
s->display_name = display_name ? xstrdup(display_name) : 0;
@@
-91,11
+98,13
@@
static void parse_args(yaz_sc_t s, int *argc_p, char ***argv_p)
break;
}
}
break;
}
}
- *argc_p -= skip_opt;
+ *argc_p = *argc_p - skip_opt;
for (; i < *argc_p; i++)
(*argv_p)[i] = (*argv_p)[i + skip_opt];
for (; i < *argc_p; i++)
(*argv_p)[i] = (*argv_p)[i + skip_opt];
+ /* now look for the service arguments */
/* we must have a YAZ log file to work with */
/* we must have a YAZ log file to work with */
+ skip_opt = 0;
for (i = 1; i < *argc_p; i++)
{
const char *opt = (*argv_p)[i];
for (i = 1; i < *argc_p; i++)
{
const char *opt = (*argv_p)[i];
@@
-127,8
+136,10
@@
static void parse_args(yaz_sc_t s, int *argc_p, char ***argv_p)
}
if (s->run_flag)
{ /* remove -l logfile for a running service */
}
if (s->run_flag)
{ /* remove -l logfile for a running service */
+ *argc_p = *argc_p - skip_opt;
for (; i < *argc_p; i++)
(*argv_p)[i] = (*argv_p)[i + skip_opt];
for (; i < *argc_p; i++)
(*argv_p)[i] = (*argv_p)[i + skip_opt];
+
}
}
}
}
@@
-203,7
+214,7
@@
static void WINAPI sc_service_main(DWORD argc, char **argv)
sc_ReportSvcStatus(s, SERVICE_START_PENDING, NO_ERROR, 3000);
sc_ReportSvcStatus(s, SERVICE_START_PENDING, NO_ERROR, 3000);
- ret_code = s->sc_main(s, argc, argv);
+ ret_code = s->sc_main(s, s->argc, s->argv);
sc_ReportSvcStatus(s, SERVICE_STOPPED,
ret_code ? ERROR_SERVICE_SPECIFIC_ERROR : NO_ERROR, ret_code);
sc_ReportSvcStatus(s, SERVICE_STOPPED,
ret_code ? ERROR_SERVICE_SPECIFIC_ERROR : NO_ERROR, ret_code);
@@
-337,6
+348,8
@@
int yaz_sc_program(yaz_sc_t s, int argc, char **argv,
dt[1].lpServiceName = 0;
dt[1].lpServiceProc = 0;
dt[1].lpServiceName = 0;
dt[1].lpServiceProc = 0;
+ s->argc = argc;
+ s->argv = argv;
if (!StartServiceCtrlDispatcher(dt))
{
yaz_log(YLOG_FATAL|YLOG_ERRNO, "Service %s could not be controlled",
if (!StartServiceCtrlDispatcher(dt))
{
yaz_log(YLOG_FATAL|YLOG_ERRNO, "Service %s could not be controlled",