|
|
@@ -44,12 +44,21 @@ void IZ_WSServerLoadConfig(IZ_WSServerState* state, const char* config_path, u8 |
|
|
|
} |
|
|
|
|
|
|
|
if ((cmdline_buffer = IZ_ConfigGetCommandlineOption(argc, argv, "-n"))) { |
|
|
|
sprintf_s(state->config.server_name, 64, "%s Dedicated Server [%s]", IZ_APP_NAME, cmdline_buffer); |
|
|
|
} else { |
|
|
|
sprintf_s(state->config.server_name, 128, "%s Dedicated Server", IZ_APP_NAME); |
|
|
|
memcpy_s(state->config.server_name, 64, cmdline_buffer, 64); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const char* IZ_WSServerTestPath(const char* base_dir, const char* file) { |
|
|
|
static char test_path[32]; |
|
|
|
sprintf_s(test_path, 32, "%s/%s", base_dir, file); |
|
|
|
struct stat stats; |
|
|
|
stat(test_path, &stats); |
|
|
|
if (stats.st_mode & S_IREAD) { |
|
|
|
return file; |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
IZ_ProcedureResult IZ_WSServerInitialize(IZ_WSServerState* state, void* userdata, const char* config_path, u8 argc, const char* argv[]) { |
|
|
|
IZ_WSServerLoadConfig(state, config_path, argc, argv); |
|
|
|
state->userdata = userdata; |
|
|
@@ -57,9 +66,15 @@ IZ_ProcedureResult IZ_WSServerInitialize(IZ_WSServerState* state, void* userdata |
|
|
|
struct lws_context_creation_info info; |
|
|
|
memset(&info, 0, sizeof info); |
|
|
|
info.port = state->config.port; |
|
|
|
// char server_string[64]; |
|
|
|
// if (*state->config.server_name) { |
|
|
|
// sprintf_s(server_string, 64, "%s Dedicated Server [%s]", IZ_APP_NAME, state->config.server_name); |
|
|
|
// } else { |
|
|
|
// sprintf_s(server_string, 64, "%s Dedicated Server", IZ_APP_NAME, state->config.server_name); |
|
|
|
// } |
|
|
|
// info.server_string = server_string; |
|
|
|
|
|
|
|
const char* origin = "./public"; |
|
|
|
|
|
|
|
struct stat stats; |
|
|
|
stat(origin, &stats); |
|
|
|
if (S_ISDIR(stats.st_mode)) { |
|
|
@@ -67,7 +82,7 @@ IZ_ProcedureResult IZ_WSServerInitialize(IZ_WSServerState* state, void* userdata |
|
|
|
.mount_next = NULL, /* linked-list "next" */ |
|
|
|
.mountpoint = "/", /* mountpoint URL */ |
|
|
|
.origin = NULL, /* serve from dir */ |
|
|
|
.def = "index.html", /* default filename */ |
|
|
|
.def = "index.htm", /* default filename */ |
|
|
|
.protocol = "http", |
|
|
|
.cgienv = NULL, |
|
|
|
.extra_mimetypes = NULL, |
|
|
@@ -83,6 +98,19 @@ IZ_ProcedureResult IZ_WSServerInitialize(IZ_WSServerState* state, void* userdata |
|
|
|
.basic_auth_login_file = NULL, |
|
|
|
}; |
|
|
|
mount.origin = origin; |
|
|
|
const char* (alt_test_paths[]) = { |
|
|
|
"index.html", |
|
|
|
}; |
|
|
|
const char* default_filename; |
|
|
|
u8 i; |
|
|
|
for (i = 0; i < 1; i += 1) { |
|
|
|
default_filename = IZ_WSServerTestPath(origin, alt_test_paths[i]); |
|
|
|
} |
|
|
|
|
|
|
|
if (default_filename) { |
|
|
|
mount.def = default_filename; |
|
|
|
} |
|
|
|
|
|
|
|
info.mounts = &mount; |
|
|
|
} |
|
|
|
|