From 36d850f8aa26222dce34aa3c991a4d5eed33be31 Mon Sep 17 00:00:00 2001
From: Constantin Papizh <p.const@bk.ru>
Date: Thu, 9 Sep 2021 16:00:06 +0300
Subject: [PATCH] windows build fixed

---
 3rdparty/cuttdb/src/cdb_bgtask.c            |  7 ------
 modules/chain/dap_chain_cell.c              | 25 ++++++++++-----------
 modules/channel/chain/dap_stream_ch_chain.c |  4 ++--
 modules/net/CMakeLists.txt                  |  2 +-
 4 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/3rdparty/cuttdb/src/cdb_bgtask.c b/3rdparty/cuttdb/src/cdb_bgtask.c
index 1d16c81a95..d12bd26e6c 100644
--- a/3rdparty/cuttdb/src/cdb_bgtask.c
+++ b/3rdparty/cuttdb/src/cdb_bgtask.c
@@ -16,14 +16,7 @@
 #include "cdb_bgtask.h"
 #include <stdlib.h>
 #include <errno.h>
-#if defined(DAP_OS_DARWIN)
 #include <signal.h>
-#elif defined(_WIN32)
-#include <sys/signal.h>
-#else
-#include <signal.h>
-#endif
-
 
 /* where thread begins */
 static void *_cdb_bgtask_func(void *arg);
diff --git a/modules/chain/dap_chain_cell.c b/modules/chain/dap_chain_cell.c
index 238e97a4a6..8e44c83674 100644
--- a/modules/chain/dap_chain_cell.c
+++ b/modules/chain/dap_chain_cell.c
@@ -115,14 +115,13 @@ void dap_chain_cell_delete(dap_chain_cell_t *a_cell)
 int dap_chain_cell_load(dap_chain_t * a_chain, const char * a_cell_file_path)
 {
     dap_chain_cell_t * l_cell = dap_chain_cell_create();
-
     l_cell->file_storage_path = dap_strdup( a_cell_file_path );
-
-    char *l_file_path = dap_strdup_printf("%s/%s", DAP_CHAIN_PVT (a_chain)->file_storage_dir,
-            l_cell->file_storage_path);
-
-    l_cell->file_storage = fopen(l_file_path,"rb");
-    DAP_DELETE(l_file_path);
+    {
+        char l_file_path[MAX_PATH] = {'\0'};
+        dap_snprintf(l_file_path, MAX_PATH, "%s/%s", DAP_CHAIN_PVT(a_chain)->file_storage_dir,
+                     l_cell->file_storage_path);
+        l_cell->file_storage = fopen(l_file_path,"rb");
+    }
     if ( l_cell->file_storage ){
         dap_chain_cell_file_header_t l_hdr = {0};
         if ( fread( &l_hdr,1,sizeof(l_hdr),l_cell->file_storage ) == sizeof (l_hdr) ) {
@@ -186,12 +185,12 @@ int dap_chain_cell_file_append( dap_chain_cell_t * a_cell, const void* a_atom, s
     size_t l_total_wrote_bytes = 0;
     // file need to be opened or created
     if(a_cell->file_storage == NULL) {
-        char *l_file_path = dap_strdup_printf("%s/%s", DAP_CHAIN_PVT ( a_cell->chain)->file_storage_dir,
-                a_cell->file_storage_path);
+        char l_file_path[MAX_PATH] = {'\0'};
+        dap_snprintf(l_file_path, MAX_PATH, "%s/%s", DAP_CHAIN_PVT(a_cell->chain)->file_storage_dir,
+                     a_cell->file_storage_path);
         a_cell->file_storage = fopen(l_file_path, "ab");
         if(a_cell->file_storage == NULL)
             a_cell->file_storage = fopen(l_file_path, "wb");
-        DAP_DELETE(l_file_path);
     }
     if(!a_cell->file_storage) {
         log_it(L_ERROR, "File \"%s\" not opened  for write cell 0x%016X",
@@ -255,10 +254,10 @@ int dap_chain_cell_file_update( dap_chain_cell_t * a_cell)
         return -1;
     }
     if(a_cell->file_storage == NULL ){ // File need to be created
-        char *l_file_path = dap_strdup_printf("%s/%s", DAP_CHAIN_PVT ( a_cell->chain)->file_storage_dir,
-                a_cell->file_storage_path);
+        char l_file_path[MAX_PATH] = {'\0'};
+        dap_snprintf(l_file_path, MAX_PATH, "%s/%s", DAP_CHAIN_PVT(a_cell->chain)->file_storage_dir,
+                     a_cell->file_storage_path);
         a_cell->file_storage = fopen(l_file_path, "wb");
-        DAP_DELETE(l_file_path);
         if(a_cell->file_storage) {
             dap_chain_cell_file_header_t l_hdr = {
                 .signature = DAP_CHAIN_CELL_FILE_SIGNATURE,
diff --git a/modules/channel/chain/dap_stream_ch_chain.c b/modules/channel/chain/dap_stream_ch_chain.c
index 7e6fd0b55d..08d7a94030 100644
--- a/modules/channel/chain/dap_stream_ch_chain.c
+++ b/modules/channel/chain/dap_stream_ch_chain.c
@@ -1040,8 +1040,8 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg)
 
         // Response with atom hashes and sizes
         case DAP_STREAM_CH_CHAIN_PKT_TYPE_UPDATE_CHAINS :{
-            uint l_count_added=0;
-            uint l_count_total=0;
+            unsigned int l_count_added=0;
+            unsigned int l_count_total=0;
 
             dap_chain_t * l_chain = dap_chain_find_by_id(l_chain_pkt->hdr.net_id, l_chain_pkt->hdr.chain_id);
             if (! l_chain){
diff --git a/modules/net/CMakeLists.txt b/modules/net/CMakeLists.txt
index 4085114464..4c05cea61e 100644
--- a/modules/net/CMakeLists.txt
+++ b/modules/net/CMakeLists.txt
@@ -37,7 +37,7 @@ endif()
 add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_NET_SRCS} ${DAP_CHAIN_NET_HEADERS} ${IPUTILS_SRCS} ${IPUTILS_HEADERS})
 
 if(WIN32)
-  target_link_libraries(dap_core dap_chain_net dap_crypto dap_client dap_server_core dap_stream_ch_chain dap_stream_ch_chain_net dap_stream_ch_chain_net_srv dap_chain dap_chain_wallet dap_chain_net_srv
+  target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_client dap_server_core dap_notify_srv dap_stream_ch_chain dap_stream_ch_chain_net dap_stream_ch_chain_net_srv dap_chain dap_chain_wallet dap_chain_net_srv
                             dap_chain_mempool dap_chain_global_db dap_chain_cs_none)
 endif()
 
-- 
GitLab