From 4f716e2b9abebd9ded7b3f0252e05b2000fa72b1 Mon Sep 17 00:00:00 2001 From: valenok Date: Thu, 26 Aug 2010 00:55:03 +0100 Subject: [PATCH] fixed win32 build --- Makefile | 22 +++++++++++----------- mongoose.c | 22 ++++++++++++++-------- win32/dll.def | 8 +++----- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 5b38fe36..7256d23e 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ all: # -DNO_CGI - disable CGI support (-5kb) # -DNO_SSL - disable SSL functionality (-2kb) # -DCONFIG_FILE=\"file\" - use `file' as the default config file -# -DNO_SSI - disable SSI support (-4kb) # -DHAVE_STRTOUI64 - use system strtoui64() function for strtoull() @@ -54,19 +53,20 @@ solaris: # 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 +VC= q:\vc6 +OUT= c:\out #WINDBG= /Zi /DDEBUG /Od /DDEBUG -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 +WINDBG= /DNDEBUG #/Os +CLFLAGS= /MD /TC /nologo /W4 /c $(WINDBG) /I $(VC)/include +LINKFLAGS= /incremental:no /libpath:$(VC)\lib ws2_32.lib windows: - $(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 + $(VC)\bin\cl main.c $(CLFLAGS) /Fo$(OUT)\main.obj + $(VC)\bin\cl mongoose.c $(CLFLAGS) /Fo$(OUT)\mongoose.obj + $(VC)\bin\link $(OUT)\mongoose.obj $(LINKFLAGS) \ + /DLL /DEF:win32\dll.def /out:$(OUT)\_$(PROG).dll + $(VC)\bin\link $(OUT)\main.obj $(OUT)\mongoose.obj $(LINKFLAGS) \ + /out:$(OUT)\$(PROG).exe # Build for Windows under MinGW #MINGWDBG= -DDEBUG -O0 diff --git a/mongoose.c b/mongoose.c index c61bf8c0..36a491a7 100644 --- a/mongoose.c +++ b/mongoose.c @@ -66,10 +66,10 @@ typedef long off_t; #define strerror(x) _ultoa(x, (char *) _alloca(sizeof(x) *3 ), 10) #endif // _WIN32_WCE -#define EPOCH_DIFF 0x019DB1DED53E8000ULL // 116444736000000000 nsecs -#define RATE_DIFF 10000000 // 100 nsecs #define MAKEUQUAD(lo, hi) ((uint64_t)(((uint32_t)(lo)) | \ ((uint64_t)((uint32_t)(hi))) << 32)) +#define RATE_DIFF 10000000 // 100 nsecs +#define EPOCH_DIFF MAKEUQUAD(0xd53e8000, 0x019db1de) #define SYS2UNIX_TIME(lo, hi) \ (time_t) ((MAKEUQUAD((lo), (hi)) - EPOCH_DIFF) / RATE_DIFF) @@ -651,6 +651,10 @@ static int pthread_cond_signal(pthread_cond_t *cv) { return SetEvent(*cv) == 0 ? -1 : 0; } +static int pthread_cond_broadcast(pthread_cond_t *cv) { + return PulseEvent(*cv) == 0 ? -1 : 0; +} + static int pthread_cond_destroy(pthread_cond_t *cv) { return CloseHandle(*cv) == 0 ? -1 : 0; } @@ -804,7 +808,7 @@ static int mg_stat(const char *path, struct mgstat *stp) { if (GetFileAttributesExW(wbuf, GetFileExInfoStandard, &info) != 0) { stp->size = MAKEUQUAD(info.nFileSizeLow, info.nFileSizeHigh); stp->mtime = SYS2UNIX_TIME(info.ftLastWriteTime.dwLowDateTime, - info.ftLastWriteTime.dwHighDateTime); + info.ftLastWriteTime.dwHighDateTime); stp->is_directory = info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; ok = 0; // Success @@ -916,16 +920,17 @@ static int start_thread(struct mg_context *ctx, mg_thread_func_t func, return hThread == NULL ? -1 : 0; } +#if 0 static HANDLE dlopen(const char *dll_name, int flags) { wchar_t wbuf[PATH_MAX]; - flags = 0; // Unused to_unicode(dll_name, wbuf, ARRAY_SIZE(wbuf)); - return LoadLibraryW(wbuf); } +#endif #if !defined(NO_CGI) +#define SIGKILL 0 static int kill(pid_t pid, int sig_num) { (void) TerminateProcess(pid, sig_num); (void) CloseHandle(pid); @@ -958,7 +963,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog, &si.hStdOutput, 0, MG_TRUE, DUPLICATE_SAME_ACCESS); // If CGI file is a script, try to read the interpreter line - interp = conn->ctx->options[OPT_CGI_INTERPRETER]; + interp = conn->ctx->config->cgi_interpreter; if (interp == NULL) { line[2] = '\0'; (void) mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%c%s", @@ -982,7 +987,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog, } (void) mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%s%s", - interp, interp[0] == '\0' ? "" : " ", prog); + interp, interp[0] == '\0' ? "" : " ", prog); (void) mg_snprintf(conn, line, sizeof(line), "%s", dir); change_slashes_to_backslashes(line); @@ -2325,8 +2330,9 @@ static void handle_file_request(struct mg_connection *conn, const char *path, conn->request_info.status_code, msg, date, lm, etag, mime_vec.len, mime_vec.ptr, cl, range); - if (strcmp(conn->request_info.request_method, "HEAD") != 0) + if (strcmp(conn->request_info.request_method, "HEAD") != 0) { send_file_data(conn, fp, cl); + } (void) fclose(fp); } diff --git a/win32/dll.def b/win32/dll.def index 09365fef..98bb6e9b 100644 --- a/win32/dll.def +++ b/win32/dll.def @@ -2,15 +2,13 @@ LIBRARY EXPORTS mg_start mg_stop - mg_get_option - mg_set_option - mg_set_callback + mg_read mg_write mg_printf mg_get_header mg_get_var + mg_get_qsvar + mg_get_cookie mg_version - mg_show_usage_string mg_modify_passwords_file mg_md5 - mg_get_cookie