vcpkg/ports/libwebsockets/0001-Fix-UWP.patch

100 lines
2.6 KiB
Diff
Raw Normal View History

2018-01-19 13:11:48 +08:00
diff --git a/lib/plat/lws-plat-win.c b/lib/plat/lws-plat-win.c
2017-01-13 01:20:32 +08:00
index dd3e95a..eb1690a 100644
2018-01-19 13:11:48 +08:00
--- a/lib/plat/lws-plat-win.c
+++ b/lib/plat/lws-plat-win.c
@@ -157,7 +157,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
2017-01-13 01:20:32 +08:00
{
2018-01-19 13:11:48 +08:00
struct lws_context_per_thread *pt;
2017-01-13 01:20:32 +08:00
WSANETWORKEVENTS networkevents;
- struct lws_pollfd *pfd;
+ struct lws_pollfd *pfd = NULL;
struct lws *wsi;
unsigned int i;
DWORD ev;
2018-01-19 13:11:48 +08:00
@@ -591,6 +591,7 @@ lws_plat_inet_pton(int af, const char *src, void *dst)
return ok ? 1 : -1;
2017-01-13 01:20:32 +08:00
}
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
2018-01-19 13:11:48 +08:00
LWS_VISIBLE lws_fop_fd_t
_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,
const char *vpath, lws_fop_flags_t *flags)
@@ -631,6 +632,49 @@ _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,
bail:
return NULL;
2017-01-13 01:20:32 +08:00
}
+#else
2018-01-19 13:11:48 +08:00
+LWS_VISIBLE lws_fop_fd_t
+_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,
+ const char *vpath, lws_fop_flags_t *flags)
2017-01-13 01:20:32 +08:00
+{
2018-01-19 13:11:48 +08:00
+ HANDLE ret;
+ WCHAR buf[MAX_PATH];
+ lws_fop_fd_t fop_fd;
+ LARGE_INTEGER llFileSize = {0};
+
+ MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, ARRAY_SIZE(buf));
+ if (((*flags) & 7) == _O_RDONLY) {
+ ret = CreateFile2(buf, GENERIC_READ, FILE_SHARE_READ,
+ OPEN_EXISTING, NULL);
+ } else {
+ lwsl_err("%s: open for write not implemented\n", __func__);
+ *filelen = 0;
+ ret = LWS_INVALID_FILE;
+ }
+
+ if (ret == LWS_INVALID_FILE)
+ goto bail;
+
+ fop_fd = malloc(sizeof(*fop_fd));
+ if (!fop_fd)
+ goto bail;
+
+ fop_fd->fops = fops;
+ fop_fd->fd = ret;
+ fop_fd->filesystem_priv = NULL; /* we don't use it */
+ fop_fd->flags = *flags;
+ fop_fd->len = GetFileSize(ret, NULL);
+ if(GetFileSizeEx(ret, &llFileSize))
+ fop_fd->len = llFileSize.QuadPart;
2017-01-13 01:20:32 +08:00
+
2018-01-19 13:11:48 +08:00
+ fop_fd->pos = 0;
2017-01-13 01:20:32 +08:00
+
2018-01-19 13:11:48 +08:00
+ return fop_fd;
2017-01-13 01:20:32 +08:00
+
2018-01-19 13:11:48 +08:00
+bail:
+ return NULL;
2017-01-13 01:20:32 +08:00
+}
+#endif
2018-01-19 13:11:48 +08:00
LWS_VISIBLE int
_lws_plat_file_close(lws_fop_fd_t *fop_fd)
2017-01-13 01:20:32 +08:00
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 23f8f4d..bc32aef 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
2018-01-19 13:11:48 +08:00
@@ -111,12 +111,23 @@
#define WIN32_LEAN_AND_MEAN
2017-01-13 01:20:32 +08:00
#endif
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
2018-01-19 13:11:48 +08:00
+#ifndef WINVER
+#define WINVER 0x0602
+#define _WIN32_WINNT WINVER
+#endif
2017-01-13 01:20:32 +08:00
+
2018-01-19 13:11:48 +08:00
+#define getenv(x) NULL
+#define _WINSOCK_DEPRECATED_NO_WARNINGS
2017-01-13 01:20:32 +08:00
+#else
+
#if (WINVER < 0x0501)
2018-01-19 13:11:48 +08:00
#undef WINVER
#undef _WIN32_WINNT
#define WINVER 0x0501
#define _WIN32_WINNT WINVER
2017-01-13 01:20:32 +08:00
#endif
2018-01-19 13:11:48 +08:00
+#endif
2017-01-13 01:20:32 +08:00
#define LWS_NO_DAEMONIZE
#define LWS_ERRNO WSAGetLastError()
#define LWS_EAGAIN WSAEWOULDBLOCK