From ac28ab175dc4d3476cd0dc406fc50678553ee4c5 Mon Sep 17 00:00:00 2001
From: ANTA <arcticshine999@gmail.com>
Date: Tue, 16 Jul 2019 03:31:01 +0400
Subject: [PATCH] 1.1-11-Win

---
 CMakeLists.txt       | 11 +++++++++++
 dap_stream_ch.c      | 22 ++++++++++++++++++++--
 dap_stream_ch_pkt.c  | 23 +++++++++++++++++++++--
 dap_stream_ch_proc.c | 21 +++++++++++++++++++++
 4 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 815662d..6dfd4d1 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,17 @@ project (dap_stream_ch)
   
 set(DAP_STREAM_CH_SRCS dap_stream_ch.c dap_stream_ch_pkt.c dap_stream_ch_proc.c)
 
+if(WIN32)
+  include_directories(../libdap/src/win32/)
+  include_directories(../3rdparty/libmemcached/)
+  include_directories(../3rdparty/libmemcached/win32/)
+  include_directories(../3rdparty/wepoll/include/)
+  include_directories(../3rdparty/uthash/src/)
+  include_directories(../3rdparty/libjson-c/)
+  include_directories(../3rdparty/libmagic/src/)
+  include_directories(../3rdparty/curl/include/)
+endif()
+
 add_library(${PROJECT_NAME} STATIC ${DAP_STREAM_CH_SRCS})
 
 target_link_libraries(dap_stream_ch dap_core dap_crypto dap_stream)
diff --git a/dap_stream_ch.c b/dap_stream_ch.c
index 03d8b83..21258f8 100755
--- a/dap_stream_ch.c
+++ b/dap_stream_ch.c
@@ -18,11 +18,29 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "dap_common.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef WIN32
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#include <winsock2.h>
+#include <windows.h>
+#include <mswsock.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#include <wepoll.h>
+#endif
+
+#include <pthread.h>
 
+#include "dap_common.h"
 #include "dap_client_remote.h"
 #include "dap_http_client.h"
-
 #include "dap_stream.h"
 #include "dap_stream_ch.h"
 #include "dap_stream_ch_proc.h"
diff --git a/dap_stream_ch_pkt.c b/dap_stream_ch_pkt.c
index 69467e9..13f973f 100755
--- a/dap_stream_ch_pkt.c
+++ b/dap_stream_ch_pkt.c
@@ -18,8 +18,27 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <stdio.h>
+
+#include <stdlib.h>
 #include <stdarg.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef WIN32
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#include <winsock2.h>
+#include <windows.h>
+#include <mswsock.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#include <wepoll.h>
+#endif
+
+#include <pthread.h>
 
 #include "dap_common.h"
 #include "dap_enc.h"
@@ -105,7 +124,7 @@ size_t dap_stream_ch_pkt_write_f(struct dap_stream_ch * a_ch, uint8_t a_type, co
     char l_buf[4096];
     va_list ap;
     va_start(ap,a_str);
-    vsnprintf(l_buf,sizeof(l_buf),a_str,ap);
+    dap_vsnprintf(l_buf,sizeof(l_buf),a_str,ap);
     va_end(ap);
     size_t ret=dap_stream_ch_pkt_write(a_ch,a_type,l_buf,strlen(l_buf));
     return ret;
diff --git a/dap_stream_ch_proc.c b/dap_stream_ch_proc.c
index 48df97a..35c7cae 100755
--- a/dap_stream_ch_proc.c
+++ b/dap_stream_ch_proc.c
@@ -18,6 +18,27 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef WIN32
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#include <winsock2.h>
+#include <windows.h>
+#include <mswsock.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#include <wepoll.h>
+#endif
+
+#include <pthread.h>
+
 #include "dap_common.h"
 #include "dap_stream_ch_proc.h"
 
-- 
GitLab