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)
#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
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);
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;
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;
}
char path[256];
void *v;
int m;
+ int pofs = 0;
+
+#if defined(__MINGW32__) || !defined(WIN32)
+ pofs = 3;
+#endif
if (!plugin)
return 0;
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;
exit(1);
}
}
-
+#ifndef _WIN32
/*
* We leave our original process up permanently, because that
* suits systemd.
// !!! implemenation needed
#endif
}
-
+#endif
/* child process */
#ifndef _WIN32
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';
* 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;
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);
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;
/* 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:
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;
}