|
@@ -157,12 +157,14 @@ static struct mg_option main_config_options[] = {
|
|
{"icon", CONFIG_TYPE_STRING, NULL},
|
|
{"icon", CONFIG_TYPE_STRING, NULL},
|
|
{NULL, CONFIG_TYPE_UNKNOWN, NULL}};
|
|
{NULL, CONFIG_TYPE_UNKNOWN, NULL}};
|
|
|
|
|
|
|
|
+
|
|
static void WINCDECL
|
|
static void WINCDECL
|
|
signal_handler(int sig_num)
|
|
signal_handler(int sig_num)
|
|
{
|
|
{
|
|
g_exit_flag = sig_num;
|
|
g_exit_flag = sig_num;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static NO_RETURN void
|
|
static NO_RETURN void
|
|
die(const char *fmt, ...)
|
|
die(const char *fmt, ...)
|
|
{
|
|
{
|
|
@@ -183,10 +185,12 @@ die(const char *fmt, ...)
|
|
exit(EXIT_FAILURE);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
static int MakeConsole(void);
|
|
static int MakeConsole(void);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
show_server_name(void)
|
|
show_server_name(void)
|
|
{
|
|
{
|
|
@@ -197,6 +201,7 @@ show_server_name(void)
|
|
fprintf(stderr, "CivetWeb v%s, built on %s\n", mg_version(), __DATE__);
|
|
fprintf(stderr, "CivetWeb v%s, built on %s\n", mg_version(), __DATE__);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static NO_RETURN void
|
|
static NO_RETURN void
|
|
show_usage_and_exit(const char *exeName)
|
|
show_usage_and_exit(const char *exeName)
|
|
{
|
|
{
|
|
@@ -246,6 +251,7 @@ show_usage_and_exit(const char *exeName)
|
|
exit(EXIT_FAILURE);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
#if defined(_WIN32) || defined(USE_COCOA)
|
|
#if defined(_WIN32) || defined(USE_COCOA)
|
|
static const char *config_file_top_comment =
|
|
static const char *config_file_top_comment =
|
|
"# Civetweb web server configuration file.\n"
|
|
"# Civetweb web server configuration file.\n"
|
|
@@ -286,6 +292,7 @@ get_url_to_first_open_port(const struct mg_context *ctx)
|
|
return url;
|
|
return url;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
#ifdef ENABLE_CREATE_CONFIG_FILE
|
|
#ifdef ENABLE_CREATE_CONFIG_FILE
|
|
static void
|
|
static void
|
|
create_config_file(const struct mg_context *ctx, const char *path)
|
|
create_config_file(const struct mg_context *ctx, const char *path)
|
|
@@ -314,6 +321,7 @@ create_config_file(const struct mg_context *ctx, const char *path)
|
|
#endif
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+
|
|
static char *
|
|
static char *
|
|
sdup(const char *str)
|
|
sdup(const char *str)
|
|
{
|
|
{
|
|
@@ -327,6 +335,7 @@ sdup(const char *str)
|
|
return p;
|
|
return p;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static const char *
|
|
static const char *
|
|
get_option(char **options, const char *option_name)
|
|
get_option(char **options, const char *option_name)
|
|
{
|
|
{
|
|
@@ -350,6 +359,7 @@ get_option(char **options, const char *option_name)
|
|
return opt_value;
|
|
return opt_value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static int
|
|
static int
|
|
set_option(char **options, const char *name, const char *value)
|
|
set_option(char **options, const char *name, const char *value)
|
|
{
|
|
{
|
|
@@ -428,6 +438,7 @@ set_option(char **options, const char *name, const char *value)
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
read_config_file(const char *config_file, char **options)
|
|
read_config_file(const char *config_file, char **options)
|
|
{
|
|
{
|
|
@@ -498,6 +509,7 @@ read_config_file(const char *config_file, char **options)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
process_command_line_arguments(char *argv[], char **options)
|
|
process_command_line_arguments(char *argv[], char **options)
|
|
{
|
|
{
|
|
@@ -564,6 +576,7 @@ process_command_line_arguments(char *argv[], char **options)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
init_server_name(int argc, const char *argv[])
|
|
init_server_name(int argc, const char *argv[])
|
|
{
|
|
{
|
|
@@ -594,6 +607,7 @@ init_server_name(int argc, const char *argv[])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static int
|
|
static int
|
|
log_message(const struct mg_connection *conn, const char *message)
|
|
log_message(const struct mg_connection *conn, const char *message)
|
|
{
|
|
{
|
|
@@ -609,6 +623,7 @@ log_message(const struct mg_connection *conn, const char *message)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static int
|
|
static int
|
|
is_path_absolute(const char *path)
|
|
is_path_absolute(const char *path)
|
|
{
|
|
{
|
|
@@ -623,6 +638,7 @@ is_path_absolute(const char *path)
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
verify_existence(char **options, const char *option_name, int must_be_dir)
|
|
verify_existence(char **options, const char *option_name, int must_be_dir)
|
|
{
|
|
{
|
|
@@ -659,6 +675,7 @@ verify_existence(char **options, const char *option_name, int must_be_dir)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
set_absolute_path(char *options[],
|
|
set_absolute_path(char *options[],
|
|
const char *option_name,
|
|
const char *option_name,
|
|
@@ -697,6 +714,7 @@ set_absolute_path(char *options[],
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
#ifdef USE_LUA
|
|
#ifdef USE_LUA
|
|
|
|
|
|
#include "civetweb_lua.h"
|
|
#include "civetweb_lua.h"
|
|
@@ -755,6 +773,7 @@ run_lua(const char *file_name)
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+
|
|
#ifdef USE_DUKTAPE
|
|
#ifdef USE_DUKTAPE
|
|
|
|
|
|
#include "duktape.h"
|
|
#include "duktape.h"
|
|
@@ -787,11 +806,13 @@ finished:
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+
|
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
|
/* For __MINGW32/64_MAJOR/MINOR_VERSION define */
|
|
/* For __MINGW32/64_MAJOR/MINOR_VERSION define */
|
|
#include <_mingw.h>
|
|
#include <_mingw.h>
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
start_civetweb(int argc, char *argv[])
|
|
start_civetweb(int argc, char *argv[])
|
|
{
|
|
{
|
|
@@ -1042,6 +1063,7 @@ start_civetweb(int argc, char *argv[])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
stop_civetweb(void)
|
|
stop_civetweb(void)
|
|
{
|
|
{
|
|
@@ -1050,6 +1072,7 @@ stop_civetweb(void)
|
|
g_user_data.first_message = NULL;
|
|
g_user_data.first_message = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
enum {
|
|
enum {
|
|
ID_ICON = 100,
|
|
ID_ICON = 100,
|
|
@@ -1081,12 +1104,14 @@ enum {
|
|
text box ID. */
|
|
text box ID. */
|
|
ID_FILE_BUTTONS_DELTA = 1000
|
|
ID_FILE_BUTTONS_DELTA = 1000
|
|
};
|
|
};
|
|
|
|
+
|
|
static HICON hIcon;
|
|
static HICON hIcon;
|
|
static SERVICE_STATUS ss;
|
|
static SERVICE_STATUS ss;
|
|
static SERVICE_STATUS_HANDLE hStatus;
|
|
static SERVICE_STATUS_HANDLE hStatus;
|
|
static const char *service_magic_argument = "--";
|
|
static const char *service_magic_argument = "--";
|
|
static NOTIFYICONDATA TrayIcon;
|
|
static NOTIFYICONDATA TrayIcon;
|
|
|
|
|
|
|
|
+
|
|
static void WINAPI
|
|
static void WINAPI
|
|
ControlHandler(DWORD code)
|
|
ControlHandler(DWORD code)
|
|
{
|
|
{
|
|
@@ -1097,6 +1122,7 @@ ControlHandler(DWORD code)
|
|
SetServiceStatus(hStatus, &ss);
|
|
SetServiceStatus(hStatus, &ss);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void WINAPI
|
|
static void WINAPI
|
|
ServiceMain(void)
|
|
ServiceMain(void)
|
|
{
|
|
{
|
|
@@ -1117,6 +1143,7 @@ ServiceMain(void)
|
|
SetServiceStatus(hStatus, &ss);
|
|
SetServiceStatus(hStatus, &ss);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
show_error(void)
|
|
show_error(void)
|
|
{
|
|
{
|
|
@@ -1131,6 +1158,7 @@ show_error(void)
|
|
MessageBox(NULL, buf, "Error", MB_OK);
|
|
MessageBox(NULL, buf, "Error", MB_OK);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void *
|
|
static void *
|
|
align(void *ptr, DWORD alig)
|
|
align(void *ptr, DWORD alig)
|
|
{
|
|
{
|
|
@@ -1140,6 +1168,7 @@ align(void *ptr, DWORD alig)
|
|
return ((void *)ul);
|
|
return ((void *)ul);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
save_config(HWND hDlg, FILE *fp)
|
|
save_config(HWND hDlg, FILE *fp)
|
|
{
|
|
{
|
|
@@ -1170,6 +1199,7 @@ save_config(HWND hDlg, FILE *fp)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static INT_PTR CALLBACK
|
|
static INT_PTR CALLBACK
|
|
SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
{
|
|
@@ -1323,11 +1353,13 @@ SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
return FALSE;
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
struct tstring_input_buf {
|
|
struct tstring_input_buf {
|
|
unsigned buflen;
|
|
unsigned buflen;
|
|
char *buffer;
|
|
char *buffer;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+
|
|
static INT_PTR CALLBACK
|
|
static INT_PTR CALLBACK
|
|
InputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP)
|
|
InputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP)
|
|
{
|
|
{
|
|
@@ -1376,6 +1408,7 @@ InputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP)
|
|
return FALSE;
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
suggest_passwd(char *passwd)
|
|
suggest_passwd(char *passwd)
|
|
{
|
|
{
|
|
@@ -1399,6 +1432,7 @@ suggest_passwd(char *passwd)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void add_control(unsigned char **mem,
|
|
static void add_control(unsigned char **mem,
|
|
DLGTEMPLATE *dia,
|
|
DLGTEMPLATE *dia,
|
|
WORD type,
|
|
WORD type,
|
|
@@ -1410,6 +1444,7 @@ static void add_control(unsigned char **mem,
|
|
short cy,
|
|
short cy,
|
|
const char *caption);
|
|
const char *caption);
|
|
|
|
|
|
|
|
+
|
|
static int
|
|
static int
|
|
get_password(const char *user,
|
|
get_password(const char *user,
|
|
const char *realm,
|
|
const char *realm,
|
|
@@ -1572,6 +1607,7 @@ get_password(const char *user,
|
|
#undef LABEL_WIDTH
|
|
#undef LABEL_WIDTH
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static INT_PTR CALLBACK
|
|
static INT_PTR CALLBACK
|
|
PasswordDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP)
|
|
PasswordDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP)
|
|
{
|
|
{
|
|
@@ -1641,6 +1677,7 @@ PasswordDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP)
|
|
return FALSE;
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
add_control(unsigned char **mem,
|
|
add_control(unsigned char **mem,
|
|
DLGTEMPLATE *dia,
|
|
DLGTEMPLATE *dia,
|
|
@@ -1683,6 +1720,7 @@ add_control(unsigned char **mem,
|
|
*mem = (unsigned char *)p;
|
|
*mem = (unsigned char *)p;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
show_settings_dialog()
|
|
show_settings_dialog()
|
|
{
|
|
{
|
|
@@ -1858,6 +1896,7 @@ show_settings_dialog()
|
|
#undef LABEL_WIDTH
|
|
#undef LABEL_WIDTH
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static void
|
|
static void
|
|
change_password_file()
|
|
change_password_file()
|
|
{
|
|
{
|
|
@@ -2063,6 +2102,7 @@ change_password_file()
|
|
#undef LABEL_WIDTH
|
|
#undef LABEL_WIDTH
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static int
|
|
static int
|
|
manage_service(int action)
|
|
manage_service(int action)
|
|
{
|
|
{
|
|
@@ -2235,6 +2275,7 @@ WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
static int
|
|
static int
|
|
MakeConsole(void)
|
|
MakeConsole(void)
|
|
{
|
|
{
|
|
@@ -2270,6 +2311,7 @@ MakeConsole(void)
|
|
return ok;
|
|
return ok;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
int WINAPI
|
|
int WINAPI
|
|
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|
{
|
|
{
|
|
@@ -2277,7 +2319,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|
HWND hWnd;
|
|
HWND hWnd;
|
|
MSG msg;
|
|
MSG msg;
|
|
|
|
|
|
-
|
|
|
|
int i;
|
|
int i;
|
|
int dataLen = 4;
|
|
int dataLen = 4;
|
|
char data[256] = {0};
|
|
char data[256] = {0};
|
|
@@ -2324,7 +2365,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|
return state[index];
|
|
return state[index];
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
uint32_t x, y, z, w;
|
|
uint32_t x, y, z, w;
|
|
|
|
|
|
uint32_t xorshift128(void)
|
|
uint32_t xorshift128(void)
|
|
@@ -2336,12 +2376,10 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|
return w = w ^ (w >> 19) ^ t ^ (t >> 8);
|
|
return w = w ^ (w >> 19) ^ t ^ (t >> 8);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
static uint64_t lfsr = 1;
|
|
static uint64_t lfsr = 1;
|
|
static uint64_t lcg = 0;
|
|
static uint64_t lcg = 0;
|
|
uint64_t r = 0;
|
|
uint64_t r = 0;
|
|
|
|
|
|
-
|
|
|
|
do {
|
|
do {
|
|
lfsr = (lfsr >> 1)
|
|
lfsr = (lfsr >> 1)
|
|
| ((((lfsr >> 0) ^ (lfsr >> 1) ^ (lfsr >> 3) ^ (lfsr >> 4)) & 1)
|
|
| ((((lfsr >> 0) ^ (lfsr >> 1) ^ (lfsr >> 3) ^ (lfsr >> 4)) & 1)
|
|
@@ -2350,7 +2388,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|
++r;
|
|
++r;
|
|
} while (lcg != 0);
|
|
} while (lcg != 0);
|
|
|
|
|
|
-
|
|
|
|
fprintf(stdout, "lfsr = %I64u, lcg = %i64u, r = %i64u\n", lfsr, lcg, r);
|
|
fprintf(stdout, "lfsr = %I64u, lcg = %i64u, r = %i64u\n", lfsr, lcg, r);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -2409,6 +2446,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|
return (int)msg.wParam;
|
|
return (int)msg.wParam;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
int
|
|
int
|
|
main(int argc, char *argv[])
|
|
main(int argc, char *argv[])
|
|
{
|
|
{
|
|
@@ -2418,6 +2456,7 @@ main(int argc, char *argv[])
|
|
return WinMain(0, 0, 0, 0);
|
|
return WinMain(0, 0, 0, 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
#elif defined(USE_COCOA)
|
|
#elif defined(USE_COCOA)
|
|
#import <Cocoa/Cocoa.h>
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|