Win32 compilation fixed

This commit is contained in:
valenok 2010-06-15 12:49:52 +03:00
parent f9456c4d76
commit 9a5f96e755
3 changed files with 32 additions and 22 deletions

View File

@ -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

View File

@ -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 <stdint.h>
@ -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, "<!--#", 5) != 0) {

View File

@ -4,17 +4,13 @@ EXPORTS
mg_stop
mg_get_option
mg_set_option
mg_set_uri_callback
mg_set_error_callback
mg_set_auth_callback
mg_set_ssl_password_callback
mg_set_log_callback
mg_set_callback
mg_write
mg_printf
mg_get_header
mg_authorize
mg_get_var
mg_free
mg_version
mg_show_usage_string
mg_modify_passwords_file
mg_md5
mg_get_cookie