diff --git a/src/main.c b/src/main.c index cecd183a..90f2638e 100644 --- a/src/main.c +++ b/src/main.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "civetweb.h" @@ -76,10 +77,10 @@ extern char *_getcwd(char *buf, size_t size); #define MAX_CONF_FILE_LINE_SIZE (8 * 1024) static int exit_flag; -static char server_name[40]; /* Set by init_server_name() */ -static char config_file[PATH_MAX] = ""; /* Set by - process_command_line_arguments() */ -static struct mg_context *ctx; /* Set by start_civetweb() */ +static char server_base_name[40]; /* Set by init_server_name() */ +static char *server_name; /* Set by init_server_name() */ +static char config_file[PATH_MAX] = ""; /* Set by process_command_line_arguments() */ +static struct mg_context *ctx; /* Set by start_civetweb() */ #if !defined(CONFIG_FILE) #define CONFIG_FILE "civetweb.conf" @@ -360,8 +361,10 @@ static void process_command_line_arguments(char *argv[], char **options) static void init_server_name(void) { - snprintf(server_name, sizeof(server_name), "Civetweb v%s", + assert((strlen(mg_version())+12)cy = ((nelems + 1) / 2 + 1) * HEIGHT + 30; DialogBoxIndirectParam(NULL, dia, NULL, DlgProc, (LPARAM) NULL); @@ -879,7 +893,7 @@ static void show_settings_dialog() static int manage_service(int action) { - static const char *service_name = "Civetweb"; + static const char *service_name = "Civetweb"; /* TODO: check using server_name instead of service_name */ SC_HANDLE hSCM = NULL, hService = NULL; SERVICE_DESCRIPTION descr = {server_name}; char path[PATH_MAX + 20] = "";/* Path to executable plus magic argument */ @@ -924,16 +938,16 @@ static int manage_service(int action) static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - static SERVICE_TABLE_ENTRY service_table[] = { - {server_name, (LPSERVICE_MAIN_FUNCTION) ServiceMain}, - {NULL, NULL} - }; + static SERVICE_TABLE_ENTRY service_table[2] = {0}; int service_installed; char buf[200], *service_argv[] = {__argv[0], NULL}; POINT pt; HMENU hMenu; static UINT s_uTaskbarRestart; /* for taskbar creation */ + service_table[0].lpServiceName = server_name; + service_table[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain; + switch (msg) { case WM_CREATE: if (__argv[1] != NULL &&