From 86ad7922b073c26717521319cdc89fe6a3540438 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 21 Mar 2015 11:04:57 +0100 Subject: [PATCH 1/2] OS2 and Android NDK fixes Note that in Android NDK st_mtime is long unsigned int --- mongoose.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index 1373303f..d85f6ff3 100644 --- a/mongoose.c +++ b/mongoose.c @@ -67,6 +67,10 @@ #define NS_DISABLE_THREADS #endif +#ifdef __OS2__ +#define _MMAP_DECLARED // Prevent dummy mmap() declaration in stdio.h +#endif + #include #include #include @@ -3353,7 +3357,8 @@ static void open_file_endpoint(struct connection *conn, const char *path, // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 gmt_time_string(date, sizeof(date), &curtime); - gmt_time_string(lm, sizeof(lm), &st->st_mtime); + time_t t = st->st_mtime; + gmt_time_string(lm, sizeof(lm), &t); construct_etag(etag, sizeof(etag), st); n = mg_snprintf(headers, sizeof(headers), @@ -3573,7 +3578,8 @@ static void print_dir_entry(const struct dir_entry *de) { mg_snprintf(size, sizeof(size), "%.1fG", (double) fsize / 1073741824); } } - strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M", localtime(&de->st.st_mtime)); + time_t t = de->st.st_mtime; + 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_printf_data(&de->conn->mg_conn, "%s%s" @@ -3644,8 +3650,8 @@ static void send_directory_listing(struct connection *conn, const char *dir) { static void print_props(struct connection *conn, const char *uri, file_stat_t *stp) { char mtime[64]; - - gmt_time_string(mtime, sizeof(mtime), &stp->st_mtime); + time_t t = stp->st_mtime; + gmt_time_string(mtime, sizeof(mtime), &t); mg_printf(&conn->mg_conn, "" "%s" From f2b40e5faed3bd75157ec93dd55299ee7024327a Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 22 Mar 2015 17:56:22 +0100 Subject: [PATCH 2/2] added comment for time_t change --- mongoose.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mongoose.c b/mongoose.c index d85f6ff3..0c7d55c2 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3357,7 +3357,7 @@ static void open_file_endpoint(struct connection *conn, const char *path, // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 gmt_time_string(date, sizeof(date), &curtime); - time_t t = st->st_mtime; + time_t t = st->st_mtime; // store in local variable for NDK compile gmt_time_string(lm, sizeof(lm), &t); construct_etag(etag, sizeof(etag), st); @@ -3578,7 +3578,7 @@ static void print_dir_entry(const struct dir_entry *de) { mg_snprintf(size, sizeof(size), "%.1fG", (double) fsize / 1073741824); } } - time_t t = de->st.st_mtime; + time_t t = de->st.st_mtime; // store in local variable for NDK compile 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_printf_data(&de->conn->mg_conn, @@ -3650,7 +3650,7 @@ static void send_directory_listing(struct connection *conn, const char *dir) { static void print_props(struct connection *conn, const char *uri, file_stat_t *stp) { char mtime[64]; - time_t t = stp->st_mtime; + time_t t = stp->st_mtime; // store in local variable for NDK compile gmt_time_string(mtime, sizeof(mtime), &t); mg_printf(&conn->mg_conn, ""