Commit 36d95e23 authored by Sergey Lyubka's avatar Sergey Lyubka

Fix win32 build

parent 8a27a95a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# All rights reserved # All rights reserved
PROG = web_server PROG = web_server
CFLAGS = -W -Wall -I../.. -pthread -g -O0 -DMONGOOSE_ENABLE_THREADS $(CFLAGS_EXTRA) CFLAGS = -W -Wall -I../.. -g -O0 $(CFLAGS_EXTRA)
SOURCES = $(PROG).c ../../mongoose.c SOURCES = $(PROG).c ../../mongoose.c
OPENSSL_FLAGS = -DNS_ENABLE_SSL -lssl OPENSSL_FLAGS = -DNS_ENABLE_SSL -lssl
...@@ -13,7 +13,10 @@ SOURCES_POLAR = $(SOURCES) $(POLARSSLCOMPAT_PATH)/polarssl_compat.c ...@@ -13,7 +13,10 @@ SOURCES_POLAR = $(SOURCES) $(POLARSSLCOMPAT_PATH)/polarssl_compat.c
INCDIR_POLAR = -I$(POLARSSLCOMPAT_PATH) -I$(POLARSSL_PATH)/include INCDIR_POLAR = -I$(POLARSSLCOMPAT_PATH) -I$(POLARSSL_PATH)/include
LDFLAGS_POLAR = -L$(POLARSSL_PATH)/lib -lmbedtls LDFLAGS_POLAR = -L$(POLARSSL_PATH)/lib -lmbedtls
CFLAGS_POLAR = $(CFLAGS) $(INCDIR_POLAR) -DNS_ENABLE_SSL CFLAGS_POLAR = $(CFLAGS) $(INCDIR_POLAR) -DNS_ENABLE_SSL
#
$(PROG).exe: $(SOURCES)
cl -Fo $(PROG) $(SOURCES) -nologo -MD -I../..
$(PROG): $(SOURCES) $(PROG): $(SOURCES)
$(CC) -o $(PROG) $(SOURCES) $(CFLAGS) $(CC) -o $(PROG) $(SOURCES) $(CFLAGS)
...@@ -23,6 +26,6 @@ openssl: ...@@ -23,6 +26,6 @@ openssl:
polarssl: polarssl:
$(CC) -o $(PROG) $(SOURCES_POLAR) $(LDFLAGS_POLAR) $(CFLAGS_POLAR) $(CC) -o $(PROG) $(SOURCES_POLAR) $(LDFLAGS_POLAR) $(CFLAGS_POLAR)
clean: clean:
rm -rf $(PROG) *.exe *.dSYM *.obj *.exp .*o *.lib rm -rf $(PROG) *.exe *.dSYM *.obj *.exp .*o *.lib
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
#pragma warning (disable : 4204) // missing c99 support #pragma warning (disable : 4204) // missing c99 support
#endif #endif
#if defined(_WIN32) && !defined(MONGOOSE_NO_CGI)
#define MONGOOSE_ENABLE_THREADS /* Windows uses stdio threads for CGI */
#endif
#ifndef MONGOOSE_ENABLE_THREADS #ifndef MONGOOSE_ENABLE_THREADS
#define NS_DISABLE_THREADS #define NS_DISABLE_THREADS
#endif #endif
...@@ -3327,7 +3331,7 @@ static void open_file_endpoint(struct connection *conn, const char *path, ...@@ -3327,7 +3331,7 @@ static void open_file_endpoint(struct connection *conn, const char *path,
file_stat_t *st, const char *extra_headers) { file_stat_t *st, const char *extra_headers) {
char date[64], lm[64], etag[64], range[64], headers[1000]; char date[64], lm[64], etag[64], range[64], headers[1000];
const char *msg = "OK", *hdr; const char *msg = "OK", *hdr;
time_t curtime = time(NULL); time_t t, curtime = time(NULL);
int64_t r1, r2; int64_t r1, r2;
struct vec mime_vec; struct vec mime_vec;
int n; int n;
...@@ -3357,7 +3361,7 @@ static void open_file_endpoint(struct connection *conn, const char *path, ...@@ -3357,7 +3361,7 @@ static void open_file_endpoint(struct connection *conn, const char *path,
// Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
gmt_time_string(date, sizeof(date), &curtime); gmt_time_string(date, sizeof(date), &curtime);
time_t t = st->st_mtime; // store in local variable for NDK compile t = st->st_mtime; // store in local variable for NDK compile
gmt_time_string(lm, sizeof(lm), &t); gmt_time_string(lm, sizeof(lm), &t);
construct_etag(etag, sizeof(etag), st); construct_etag(etag, sizeof(etag), st);
...@@ -3562,6 +3566,7 @@ static void print_dir_entry(const struct dir_entry *de) { ...@@ -3562,6 +3566,7 @@ static void print_dir_entry(const struct dir_entry *de) {
int64_t fsize = de->st.st_size; int64_t fsize = de->st.st_size;
int is_dir = S_ISDIR(de->st.st_mode); int is_dir = S_ISDIR(de->st.st_mode);
const char *slash = is_dir ? "/" : ""; const char *slash = is_dir ? "/" : "";
time_t t;
if (is_dir) { if (is_dir) {
mg_snprintf(size, sizeof(size), "%s", "[DIRECTORY]"); mg_snprintf(size, sizeof(size), "%s", "[DIRECTORY]");
...@@ -3578,7 +3583,7 @@ static void print_dir_entry(const struct dir_entry *de) { ...@@ -3578,7 +3583,7 @@ static void print_dir_entry(const struct dir_entry *de) {
mg_snprintf(size, sizeof(size), "%.1fG", (double) fsize / 1073741824); mg_snprintf(size, sizeof(size), "%.1fG", (double) fsize / 1073741824);
} }
} }
time_t t = de->st.st_mtime; // store in local variable for NDK compile t = de->st.st_mtime; // store in local variable for NDK compile
strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M", localtime(&t)); strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M", localtime(&t));
mg_url_encode(de->file_name, strlen(de->file_name), href, sizeof(href)); mg_url_encode(de->file_name, strlen(de->file_name), href, sizeof(href));
mg_printf_data(&de->conn->mg_conn, mg_printf_data(&de->conn->mg_conn,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment