Commit 9a5f96e7 authored by valenok's avatar valenok

Win32 compilation fixed

parent f9456c4d
...@@ -48,21 +48,23 @@ solaris: ...@@ -48,21 +48,23 @@ solaris:
### WINDOWS build: Using Visual Studio or Mingw ### WINDOWS build: Using Visual Studio or Mingw
########################################################################## ##########################################################################
# Using Visual Studio Express # Using Visual Studio 6.0
# 1. Download and install Visual Studio Express 2008 to c:\msvc8 # Assuming that studio is installed in d:\vc6, change VC variable below to
# 2. Download and install Windows SDK to c:\sdk # the correct path on your system. Run "d:\vc6\bin\nmake windows"
# 3. Go to c:\msvc8\vc\bin and start "VIsual Studio 2008 Command prompt"
# (or Itanium/amd64 command promt to build x64 version)
# 4. In the command prompt, go to mongoose directory and do "nmake windows"
VC= d:\vc2010\vc
#VC= d:\vc6
SDK= d:\sdk\v7.1
#WINDBG= /Zi /DDEBUG /Od /DDEBUG #WINDBG= /Zi /DDEBUG /Od /DDEBUG
WINDBG= /DNDEBUG /Os WINDBG= /DNDEBUG /Os
WINFLAGS= /MT /TC /nologo /W4 $(WINDBG) WINFLAGS= /MT /TC /nologo /W4 $(WINDBG) /I $(VC)/include \
/I $(SDK)\include /link /incremental:no /libpath:$(VC)\lib \
/libpath:$(SDK)/lib ws2_32.lib
windows: windows:
cl $(WINFLAGS) mongoose.c /link /incremental:no /DLL \ $(VC)\bin\cl.exe mongoose.c $(WINFLAGS) \
/DEF:win32\dll.def /out:_$(PROG).dll ws2_32.lib /DLL /DEF:win32\dll.def /out:_$(PROG).dll
cl $(WINFLAGS) mongoose.c main.c /link /incremental:no \ $(VC)\bin\cl.exe mongoose.c main.c $(WINFLAGS) /out:$(PROG).exe
/out:$(PROG).exe ws2_32.lib
# Build for Windows under MinGW # Build for Windows under MinGW
#MINGWDBG= -DDEBUG -O0 #MINGWDBG= -DDEBUG -O0
......
...@@ -87,9 +87,11 @@ typedef long off_t; ...@@ -87,9 +87,11 @@ typedef long off_t;
#define STR(x) STRX(x) #define STR(x) STRX(x)
#define __func__ "line " STR(__LINE__) #define __func__ "line " STR(__LINE__)
#define strtoull(x, y, z) strtoul(x, y, z) #define strtoull(x, y, z) strtoul(x, y, z)
#define strtoll(x, y, z) strtol(x, y, z)
#else #else
#define __func__ __FUNCTION__ #define __func__ __FUNCTION__
#define strtoull(x, y, z) _strtoui64(x, y, z) #define strtoull(x, y, z) _strtoui64(x, y, z)
#define strtoll(x, y, z) _strtoi64(x, y, z)
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#define ERRNO GetLastError() #define ERRNO GetLastError()
...@@ -99,7 +101,9 @@ typedef long off_t; ...@@ -99,7 +101,9 @@ typedef long off_t;
#define DIRSEP '\\' #define DIRSEP '\\'
#define IS_DIRSEP_CHAR(c) ((c) == '/' || (c) == '\\') #define IS_DIRSEP_CHAR(c) ((c) == '/' || (c) == '\\')
#define O_NONBLOCK 0 #define O_NONBLOCK 0
#if !defined(EWOULDBLOCK)
#define EWOULDBLOCK WSAEWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK
#endif /* !EWOULDBLOCK */
#define _POSIX_ #define _POSIX_
#define INT64_FMT "I64d" #define INT64_FMT "I64d"
...@@ -125,6 +129,7 @@ typedef long off_t; ...@@ -125,6 +129,7 @@ typedef long off_t;
#endif /* !fileno MINGW #defines fileno */ #endif /* !fileno MINGW #defines fileno */
typedef HANDLE pthread_mutex_t; typedef HANDLE pthread_mutex_t;
typedef HANDLE pthread_rwlock_t;
typedef HANDLE pthread_cond_t; typedef HANDLE pthread_cond_t;
typedef DWORD pthread_t; typedef DWORD pthread_t;
#define pid_t HANDLE /* MINGW typedefs pid_t to int. Using #define here. */ #define pid_t HANDLE /* MINGW typedefs pid_t to int. Using #define here. */
...@@ -136,6 +141,14 @@ struct timespec { ...@@ -136,6 +141,14 @@ struct timespec {
static int pthread_mutex_lock(pthread_mutex_t *); static int pthread_mutex_lock(pthread_mutex_t *);
static int pthread_mutex_unlock(pthread_mutex_t *); static int pthread_mutex_unlock(pthread_mutex_t *);
static FILE *mg_fopen(const char *path, const char *mode);
/* TODO(lsm): Implement these */
#define pthread_rwlock_init pthread_mutex_init
#define pthread_rwlock_destroy pthread_mutex_destroy
#define pthread_rwlock_rdlock pthread_mutex_lock
#define pthread_rwlock_wrlock pthread_mutex_lock
#define pthread_rwlock_unlock pthread_mutex_unlock
#if defined(HAVE_STDINT) #if defined(HAVE_STDINT)
#include <stdint.h> #include <stdint.h>
...@@ -1500,7 +1513,7 @@ url_decode(const char *src, size_t src_len, char *dst, size_t dst_len, ...@@ -1500,7 +1513,7 @@ url_decode(const char *src, size_t src_len, char *dst, size_t dst_len,
isxdigit(* (unsigned char *) (src + i + 2))) { isxdigit(* (unsigned char *) (src + i + 2))) {
a = tolower(* (unsigned char *) (src + i + 1)); a = tolower(* (unsigned char *) (src + i + 1));
b = tolower(* (unsigned char *) (src + i + 2)); b = tolower(* (unsigned char *) (src + i + 2));
dst[j] = ((HEXTOI(a) << 4) | HEXTOI(b)) & 0xff; dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
i += 2; i += 2;
} else if (is_form_url_encoded && src[i] == '+') { } else if (is_form_url_encoded && src[i] == '+') {
dst[j] = ' '; dst[j] = ' ';
...@@ -2931,7 +2944,6 @@ static bool_t ...@@ -2931,7 +2944,6 @@ static bool_t
is_not_modified(const struct mg_connection *conn, const struct mgstat *stp) is_not_modified(const struct mg_connection *conn, const struct mgstat *stp)
{ {
const char *ims = mg_get_header(conn, "If-Modified-Since"); const char *ims = mg_get_header(conn, "If-Modified-Since");
return FALSE;
return (ims != NULL && stp->mtime <= date_to_epoch(ims)); return (ims != NULL && stp->mtime <= date_to_epoch(ims));
} }
...@@ -3457,7 +3469,7 @@ send_ssi_file(struct mg_connection *conn, const char *path, FILE *fp, ...@@ -3457,7 +3469,7 @@ send_ssi_file(struct mg_connection *conn, const char *path, FILE *fp,
while ((ch = fgetc(fp)) != EOF) { while ((ch = fgetc(fp)) != EOF) {
if (in_ssi_tag && ch == '>') { if (in_ssi_tag && ch == '>') {
in_ssi_tag = FALSE; in_ssi_tag = FALSE;
buf[len++] = ch & 0xff; buf[len++] = (char) ch;
buf[len] = '\0'; buf[len] = '\0';
assert(len <= (int) sizeof(buf)); assert(len <= (int) sizeof(buf));
if (len < 6 || memcmp(buf, "<!--#", 5) != 0) { if (len < 6 || memcmp(buf, "<!--#", 5) != 0) {
......
...@@ -4,17 +4,13 @@ EXPORTS ...@@ -4,17 +4,13 @@ EXPORTS
mg_stop mg_stop
mg_get_option mg_get_option
mg_set_option mg_set_option
mg_set_uri_callback mg_set_callback
mg_set_error_callback
mg_set_auth_callback
mg_set_ssl_password_callback
mg_set_log_callback
mg_write mg_write
mg_printf mg_printf
mg_get_header mg_get_header
mg_authorize
mg_get_var mg_get_var
mg_free
mg_version mg_version
mg_show_usage_string mg_show_usage_string
mg_modify_passwords_file mg_modify_passwords_file
mg_md5
mg_get_cookie
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