diff --git a/README.build.md b/README.build.md index 8cac4033..ca9c528e 100644 --- a/README.build.md +++ b/README.build.md @@ -176,7 +176,7 @@ cmake from scratch. 2. Fix up MinGW headers - a) Add the following lines to C:\MinGW\include\winsock2.h: + a) If still necessary, sdd the following lines to C:\MinGW\include\winsock2.h: ``` #if(_WIN32_WINNT >= 0x0600) @@ -192,9 +192,16 @@ cmake from scratch. #endif // (_WIN32_WINNT >= 0x0600) ``` + + Update crtdefs.h line 47 to say: + +``` + typedef __int64 ssize_t; +``` + b) Create C:\MinGW\include\mstcpip.h and copy and paste the content from following link into it: - - http://wine-unstable.sourcearchive.com/documentation/1.1.32/mstcpip_8h-source.html + + https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-headers/include/mstcpip.h 3. Install CMake 2.6 or greater: http://cmake.org/cmake/resources/software.html diff --git a/lib/libuv.c b/lib/libuv.c index 3cbc1fad..ee6b6e16 100644 --- a/lib/libuv.c +++ b/lib/libuv.c @@ -331,7 +331,7 @@ lws_libuv_accept(struct lws *wsi, lws_sock_file_fd_type desc) wsi->w_read.context = context; if (wsi->mode == LWSCM_RAW_FILEDESC) uv_poll_init(pt->io_loop_uv, &wsi->w_read.uv_watcher, - desc.filefd); + (int)desc.filefd); else uv_poll_init_socket(pt->io_loop_uv, &wsi->w_read.uv_watcher, desc.sockfd); @@ -541,6 +541,11 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d) char path[256]; uv_loop_t loop; uv_lib_t lib; + int pofs = 0; + +#if defined(__MINGW32__) || !defined(WIN32) + pofs = 3; +#endif lib.errmsg = NULL; lib.handle = NULL; @@ -570,19 +575,21 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d) lwsl_err("Error loading DSO: %s\n", lib.errmsg); goto bail; } + /* we could open it, can we get his init function? */ -#if !defined(WIN32) + +#if !defined(WIN32) && !defined(__MINGW32__) m = lws_snprintf(path, sizeof(path) - 1, "init_%s", - dent.name + 3 /* snip lib... */); + dent.name + pofs /* snip lib... */); path[m - 3] = '\0'; /* snip the .so */ #else m = lws_snprintf(path, sizeof(path) - 1, "init_%s", - dent.name); + dent.name + pofs); path[m - 4] = '\0'; /* snip the .dll */ #endif if (uv_dlsym(&lib, path, &v)) { uv_dlerror(&lib); - lwsl_err("Failed to get init on %s: %s", + lwsl_err("Failed to get %s on %s: %s", path, dent.name, lib.errmsg); goto bail; } @@ -633,6 +640,11 @@ lws_plat_plugins_destroy(struct lws_context *context) char path[256]; void *v; int m; + int pofs = 0; + +#if defined(__MINGW32__) || !defined(WIN32) + pofs = 3; +#endif if (!plugin) return 0; @@ -641,17 +653,18 @@ lws_plat_plugins_destroy(struct lws_context *context) while (plugin) { p = plugin; -#if !defined(WIN32) - m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + 3); + +#if !defined(WIN32) && !defined(__MINGW32__) + m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + pofs); path[m - 3] = '\0'; #else - m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name); + m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + pofs); path[m - 4] = '\0'; #endif if (uv_dlsym(&plugin->lib, path, &v)) { uv_dlerror(&plugin->lib); - lwsl_err("Failed to get init on %s: %s", + lwsl_err("Failed to get %s on %s: %s", path, plugin->name, plugin->lib.errmsg); } else { func = (lws_plugin_destroy_func)v; diff --git a/lwsws/main.c b/lwsws/main.c index f23c24ac..1af5f1b2 100644 --- a/lwsws/main.c +++ b/lwsws/main.c @@ -223,7 +223,7 @@ int main(int argc, char **argv) exit(1); } } - +#ifndef _WIN32 /* * We leave our original process up permanently, because that * suits systemd. @@ -267,7 +267,7 @@ int main(int argc, char **argv) // !!! implemenation needed #endif } - +#endif /* child process */ #ifndef _WIN32 diff --git a/plugins/protocol_lws_server_status.c b/plugins/protocol_lws_server_status.c index 0b34c160..fb6d13f6 100644 --- a/plugins/protocol_lws_server_status.c +++ b/plugins/protocol_lws_server_status.c @@ -95,7 +95,7 @@ uv_timeout_cb_server_status(uv_timer_t *w l -= n; } fd = open(fp->filepath, LWS_O_RDONLY); - if (fd != LWS_INVALID_FILE) { + if (fd >= 0) { n = read(fd, contents, sizeof(contents) - 1); if (n >= 0) { contents[n] = '\0'; diff --git a/plugins/protocol_post_demo.c b/plugins/protocol_post_demo.c index bd9bef65..7560bf5a 100644 --- a/plugins/protocol_post_demo.c +++ b/plugins/protocol_post_demo.c @@ -74,7 +74,7 @@ file_upload_cb(void *data, const char *name, const char *filename, * simple demo use a fixed name so we don't have to deal with * attacks */ #if !defined(LWS_WITH_ESP8266) - pss->fd = open("/tmp/post-file", + pss->fd = (lws_filefd_type)open("/tmp/post-file", O_CREAT | O_TRUNC | O_RDWR, 0600); #endif break; @@ -88,7 +88,7 @@ file_upload_cb(void *data, const char *name, const char *filename, return 1; #if !defined(LWS_WITH_ESP8266) - n = write(pss->fd, buf, len); + n = write((int)pss->fd, buf, len); lwsl_notice("%s: write %d says %d\n", __func__, len, n); #else lwsl_notice("%s: Received chunk size %d\n", __func__, len); @@ -97,7 +97,7 @@ file_upload_cb(void *data, const char *name, const char *filename, if (state == LWS_UFS_CONTENT) break; #if !defined(LWS_WITH_ESP8266) - close(pss->fd); + close((int)pss->fd); pss->fd = LWS_INVALID_FILE; #endif break; diff --git a/test-server/test-server-http.c b/test-server/test-server-http.c index 9c122b70..eeda0f09 100644 --- a/test-server/test-server-http.c +++ b/test-server/test-server-http.c @@ -147,7 +147,7 @@ file_upload_cb(void *data, const char *name, const char *filename, /* we get the original filename in @filename arg, but for * simple demo use a fixed name so we don't have to deal with * attacks */ - pss->post_fd = open("/tmp/post-file", + pss->post_fd = (lws_filefd_type)open("/tmp/post-file", O_CREAT | O_TRUNC | O_RDWR, 0600); break; case LWS_UFS_FINAL_CONTENT: @@ -159,12 +159,12 @@ file_upload_cb(void *data, const char *name, const char *filename, if (pss->file_length > 100000) return 1; - n = write(pss->post_fd, buf, len); + n = write((int)pss->post_fd, buf, len); lwsl_notice("%s: write %d says %d\n", __func__, len, n); } if (state == LWS_UFS_CONTENT) break; - close(pss->post_fd); + close((int)pss->post_fd); pss->post_fd = LWS_INVALID_FILE; break; }