From 9a5f96e7557a635bceb12df28b7aff56d71dd442 Mon Sep 17 00:00:00 2001 From: valenok Date: Tue, 15 Jun 2010 12:49:52 +0300 Subject: [PATCH] Win32 compilation fixed --- Makefile | 26 ++++++++++++++------------ mongoose.c | 18 +++++++++++++++--- win32/dll.def | 10 +++------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index a395e020..7e267fb9 100644 --- a/Makefile +++ b/Makefile @@ -48,21 +48,23 @@ solaris: ### WINDOWS build: Using Visual Studio or Mingw ########################################################################## -# Using Visual Studio Express -# 1. Download and install Visual Studio Express 2008 to c:\msvc8 -# 2. Download and install Windows SDK to c:\sdk -# 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" +# Using Visual Studio 6.0 +# Assuming that studio is installed in d:\vc6, change VC variable below to +# the correct path on your system. Run "d:\vc6\bin\nmake windows" +VC= d:\vc2010\vc +#VC= d:\vc6 +SDK= d:\sdk\v7.1 #WINDBG= /Zi /DDEBUG /Od /DDEBUG -WINDBG= /DNDEBUG /Os -WINFLAGS= /MT /TC /nologo /W4 $(WINDBG) +WINDBG= /DNDEBUG /Os +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: - cl $(WINFLAGS) mongoose.c /link /incremental:no /DLL \ - /DEF:win32\dll.def /out:_$(PROG).dll ws2_32.lib - cl $(WINFLAGS) mongoose.c main.c /link /incremental:no \ - /out:$(PROG).exe ws2_32.lib + $(VC)\bin\cl.exe mongoose.c $(WINFLAGS) \ + /DLL /DEF:win32\dll.def /out:_$(PROG).dll + $(VC)\bin\cl.exe mongoose.c main.c $(WINFLAGS) /out:$(PROG).exe # Build for Windows under MinGW #MINGWDBG= -DDEBUG -O0 diff --git a/mongoose.c b/mongoose.c index 61b9458c..40494923 100644 --- a/mongoose.c +++ b/mongoose.c @@ -87,9 +87,11 @@ typedef long off_t; #define STR(x) STRX(x) #define __func__ "line " STR(__LINE__) #define strtoull(x, y, z) strtoul(x, y, z) +#define strtoll(x, y, z) strtol(x, y, z) #else #define __func__ __FUNCTION__ #define strtoull(x, y, z) _strtoui64(x, y, z) +#define strtoll(x, y, z) _strtoi64(x, y, z) #endif /* _MSC_VER */ #define ERRNO GetLastError() @@ -99,7 +101,9 @@ typedef long off_t; #define DIRSEP '\\' #define IS_DIRSEP_CHAR(c) ((c) == '/' || (c) == '\\') #define O_NONBLOCK 0 +#if !defined(EWOULDBLOCK) #define EWOULDBLOCK WSAEWOULDBLOCK +#endif /* !EWOULDBLOCK */ #define _POSIX_ #define INT64_FMT "I64d" @@ -125,6 +129,7 @@ typedef long off_t; #endif /* !fileno MINGW #defines fileno */ typedef HANDLE pthread_mutex_t; +typedef HANDLE pthread_rwlock_t; typedef HANDLE pthread_cond_t; typedef DWORD pthread_t; #define pid_t HANDLE /* MINGW typedefs pid_t to int. Using #define here. */ @@ -136,6 +141,14 @@ struct timespec { static int pthread_mutex_lock(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) #include @@ -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))) { a = tolower(* (unsigned char *) (src + i + 1)); 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; } else if (is_form_url_encoded && src[i] == '+') { dst[j] = ' '; @@ -2931,7 +2944,6 @@ static bool_t is_not_modified(const struct mg_connection *conn, const struct mgstat *stp) { const char *ims = mg_get_header(conn, "If-Modified-Since"); - return FALSE; 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, while ((ch = fgetc(fp)) != EOF) { if (in_ssi_tag && ch == '>') { in_ssi_tag = FALSE; - buf[len++] = ch & 0xff; + buf[len++] = (char) ch; buf[len] = '\0'; assert(len <= (int) sizeof(buf)); if (len < 6 || memcmp(buf, "