Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Unable to compile #41 #71 #105

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
37 changes: 22 additions & 15 deletions pCloudCC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.8)
project(pcloudcc)

#INCLUDE(CPack)

set(CMAKE_BUILD_TYPE Release)

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
unset(Boost_INCLUDE_DIR CACHE)
Expand All @@ -13,10 +15,12 @@ include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
#set (CMAKE_CXX_FLAGS "-static -Wl,-Bstatic")
#set (CMAKE_CXX_FLAGS "-Wl,-Bstatic")
#set (CMAKE_CXX_FLAGS "-DP_CONSOLE_CLIENT")
set (CMAKE_C_FLAGS "-fPIC")
set (PCLSYNC_PATH ${CMAKE_SOURCE_DIR}/lib/pclsync)
set (MBEDTLS_PATH ${CMAKE_SOURCE_DIR}/lib/mbedtls)
set (SQLITE3_PATH ${CMAKE_SOURCE_DIR}/lib/sqlite)
set (PRJF_PATH ${CMAKE_SOURCE_DIR}/lib/prjf)

#add_subdirectory(${MBEDTLS_PATH})

Expand Down Expand Up @@ -46,30 +50,33 @@ add_custom_target(
WORKING_DIRECTORY ${MBEDTLS_PATH}
)

set (OVERLAY_CLENT_PATH ${CMAKE_SOURCE_DIR}/lib/poverlay_linux)
set(OVERLAY_CLENT_PATH ${CMAKE_SOURCE_DIR}/lib/poverlay_linux)
include_directories(${OVERLAY_CLENT_PATH})

add_library(sqlite3 STATIC ${SQLITE3_PATH}/sqlite3.c)
target_link_libraries(sqlite3 z dl)

add_library(pcloudcc_lib SHARED pclsync_lib_c.cpp pclsync_lib.cpp control_tools.cpp ${OVERLAY_CLENT_PATH}/overlay_client.c ${OVERLAY_CLENT_PATH}/debug.c )

target_link_libraries(pcloudcc_lib ${PCLSYNC_PATH}/libpsynclib.a ${MBEDTLS_PATH}/library/libmbedtls.a fuse pthread sqlite3
)
add_library(pcloudcc_lib SHARED pclsync_lib_c.cpp pclsync_lib.cpp control_tools.cpp ${OVERLAY_CLENT_PATH}/overlay_client.c ${OVERLAY_CLENT_PATH}/debug.c ${PRJF_PATH}/pRJF.c)
target_link_libraries(pcloudcc_lib ${PCLSYNC_PATH}/psynclib.a ${MBEDTLS_PATH}/library/libmbedtls.a fuse pthread sqlite3 udev)

add_executable(pcloudcc main.cpp)
file(GLOB_RECURSE INC_ALL "*.h" "*.hpp")
add_executable(pcloudcc main.cpp ${INC_ALL})

target_link_libraries(pcloudcc pcloudcc_lib)

target_link_libraries(pcloudcc ${Boost_LIBRARIES})

link_directories(${PCLSYNC_PATH} ${MBEDTLS_PATH}/library ${SQLITE3_PATH} ${OVERLAY_CLENT_PATH})

#add_dependencies(pclsync sqlite3_lib)

#add_dependencies(pcloudcc sqlite3_lib mbedtls pclsync )

install(TARGETS pcloudcc RUNTIME DESTINATION bin)
install(TARGETS pcloudcc_lib LIBRARY DESTINATION lib)


#add_dependencies(pcloudcc pcloudcc_lib)
#EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
#message( STATUS "Architecture: ${ARCHITECTURE}" )
#if(${ARCHITECTURE} STREQUAL "x86_64")
# set(LIB_DIR "/usr/lib64")
#else()
# set(LIB_DIR "/usr/lib")
#endif()

message(STATUS "System CPU: " ${CMAKE_SYSTEM_PROCESSOR})
install(TARGETS pcloudcc DESTINATION /usr/bin)
install(TARGETS pcloudcc_lib LIBRARY DESTINATION /usr/lib)
57 changes: 30 additions & 27 deletions pCloudCC/control_tools.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include "control_tools.h"
#include "pclsync_lib.h"
#include "overlay_client.h"

#include <iostream>

#include <sys/types.h>
Expand All @@ -16,6 +12,10 @@
#include <map>
#include <string>

#include "control_tools.h"
#include "pclsync_lib.h"
#include "overlay_client.h"

namespace control_tools{

static const int STOP = 0;
Expand All @@ -28,44 +28,49 @@ enum command_ids_ {
ADDSYNC,
STOPSYNC
};


int start_crypto(const char * pass) {
int start_crypto(const char * pass){
int ret;
char* errm;
if (SendCall(STARTCRYPTO, pass, &ret, &errm))
std::cout << "Start Crypto failed. return is " << ret<< " and message is "<<errm << std::endl;
char* errm=NULL;
if(SendCall(STARTCRYPTO, pass, &ret, &errm))
std::cout << "Start Crypto failed. return is " << ret << " and message is "<<errm << std::endl;
else
std::cout << "Crypto started. "<< std::endl;
free(errm);
if(errm)
free(errm);
}

int stop_crypto(){
int ret;
char* errm;
char* errm=NULL;
if (SendCall(STOPCRYPTO, "", &ret, &errm))
std::cout << "Stop Crypto failed. return is " << ret<< " and message is "<<errm << std::endl;
std::cout << "Stop Crypto failed. return is " << ret << " and message is "<< errm << std::endl;
else
std::cout << "Crypto Stopped. "<< std::endl;
free(errm);
if (errm)
free(errm);
}

int finalize(){
int ret;
char* errm;
char* errm=NULL;
if (SendCall(FINALIZE, "", &ret, &errm))
std::cout << "Finalize failed. return is " << ret<< " and message is "<<errm << std::endl;
std::cout << "Finalize failed. return is " << ret<< " and message is "<< errm << std::endl;
else
std::cout << "Exiting ..."<< std::endl;

free(errm);
if (errm)
free(errm);
}

void process_commands()
{
std::cout<< "Supported commands are:" << std::endl << "startcrypto <crypto pass>, stopcrypto, finalize, q, quit" << std::endl;
std::cout<< "> " ;
for (std::string line; std::getline(std::cin, line);) {
if (!line.compare("finalize")) {
if (!line.compare("finalize")){
finalize();
break;}
break;
}
else if (!line.compare("stopcrypto"))
stop_crypto();
else if (!line.compare(0,11,"startcrypto",0,11) && (line.length() > 12))
Expand All @@ -81,11 +86,11 @@ int daemonize(bool do_commands) {
pid_t pid, sid;

pid = fork();
if (pid < 0)
if (pid<0)
exit(EXIT_FAILURE);
if (pid > 0) {
if (pid>0){
std::cout << "Daemon process created. Process id is: " << pid << std::endl;
if (do_commands) {
if (do_commands){
process_commands();
}
else
Expand All @@ -94,10 +99,9 @@ int daemonize(bool do_commands) {
}
umask(0);
/* Open any logs here */
sid = setsid();
sid=setsid();
if (sid < 0)
exit(EXIT_FAILURE);

if ((chdir("/")) < 0)
exit(EXIT_FAILURE);
close(STDIN_FILENO);
Expand All @@ -106,10 +110,9 @@ int daemonize(bool do_commands) {

if (console_client::clibrary::pclsync_lib::get_lib().init())
exit(EXIT_FAILURE);
while (1) {
while (1){
sleep(10);
}

}

}
}
7 changes: 4 additions & 3 deletions pCloudCC/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pcloudcc (2.0.1-1) trusty; urgency=low
pcloudcc (2.1.0-1) bionic; urgency=low

* Initial release
* Updated the sync library to v 1.5.0

-- Raycho Mukelov <[email protected]> Thu, 1 Aug 2019 16:53:02 +0300

-- Ivan Stoev <[email protected]> Tue, 05 Apr 2016 16:58:02 +0300
19 changes: 14 additions & 5 deletions pCloudCC/lib/pclsync/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#CC=cc
CC=gcc
AR=ar rcu
RANLIB=ranlib
#USESSL=openssl
USESSL=mbed

#CFLAGS=-Wall -Wpointer-arith -O2 -g -mtune=core2
CFLAGS=-Wall -Wpointer-arith -O2 -g -fno-stack-protector -fomit-frame-pointer -mtune=core2 -I../sqlite -DP_ELECTRON -fPIC

#CFLAGS=-Wall -Wpointer-arith -O2 -g -fsanitize=address -mtune=core2
CFLAGS=-Wall -Wpointer-arith -O2 -g -fno-stack-protector -fomit-frame-pointer -fPIC
#CFLAGS=-Wall -Wpointer-arith -O2 -g -fsanitize=address -mtune=core2 -I../sqlite
#CFLAGS=-Wall -Wpointer-arith -Os -g -mtune=core2 -I../sqlite -pg
#CFLAGS=-Wall -Wpointer-arith -O2 -g -fno-stack-protector -fomit-frame-pointer -mtune=core2 -I../sqlite/ -fPIC
#CFLAGS=-Wall -Wpointer-arith -O2 -g -mtune=core2 -I../sqlite -pg -m32 -D_FILE_OFFSET_BITS=64
#CFLAGS=-O2 -g -pg
#CFLAGS=-Wall -Wpointer-arith -O2 -g -mtune=core2 -I../../psync32/zlib -I../../psync32/sqlite -m32 -D_FILE_OFFSET_BITS=64

#CMAKE whants lib extension
LIB_A=libpsynclib.a
LIB_A=psynclib.a
#LIB_A=libpsynclib.a


ifeq ($(OS),Windows_NT)
Expand All @@ -23,7 +29,7 @@ else
UNAME_S := $(shell uname -s)
UNAME_V := $(shell uname -v)
ifeq ($(UNAME_S),Linux)
CFLAGS += -DP_OS_LINUX -I../sqlite
CFLAGS += -DP_OS_LINUX -D_FILE_OFFSET_BITS=64
ifneq (,$(findstring Debian,$(UNAME_V)))
CFLAGS += -DP_OS_DEBIAN
endif
Expand Down Expand Up @@ -72,6 +78,9 @@ fs: $(OBJ) $(OBJFS)
$(AR) $(LIB_A) $(OBJ) $(OBJFS)
$(RANLIB) $(LIB_A)

debugfs: fs
CFLAGS += -DDEBUG_LEVEL=${DEBUG}

cli: fs
$(CC) $(CFLAGS) -o cli cli.c $(LIB_A) $(LDFLAGS)

Expand Down
6 changes: 3 additions & 3 deletions pCloudCC/lib/pclsync/gitcommit.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _GITCOMMIT_H
#define _GITCOMMIT_H

#define GIT_PREV_COMMIT_ID "6339ebce20a8b853dd78b80e075ab25e1f413f73"
#define GIT_PREV_COMMIT_DATE "2018-03-15 15:36:43 +0200"
#define GIT_COMMIT_DATE "2018-03-26 18:43:25 +0300"
#define GIT_PREV_COMMIT_ID "17d868f376d826d6beeecb6c7d326f0fb119ff18"
#define GIT_PREV_COMMIT_DATE "2019-03-06 18:00:24 +0200"
#define GIT_COMMIT_DATE "2019-03-11 11:29:47 +0200"

#endif
17 changes: 17 additions & 0 deletions pCloudCC/lib/pclsync/papi.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,20 @@ const binresult *psync_do_check_result(const binresult *res, const char *name, u
}
return NULL;
}

const binresult *psync_do_get_result(const binresult *res, const char *name, const char *file, const char *function, int unsigned line){
uint32_t i;
if (unlikely(!res || res->type!=PARAM_HASH)){
if (D_CRITICAL<=DEBUG_LEVEL){
const char *nm="NULL";
if (res)
nm=type_names[res->type];
psync_debug(file, function, line, D_CRITICAL, "expecting hash as first parameter, got %s", nm);
}
return NULL;
}
for (i=0; i<res->length; i++)
if (!strcmp(res->hash[i].key, name))
return res->hash[i].value;
return NULL;
}
2 changes: 2 additions & 0 deletions pCloudCC/lib/pclsync/papi.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ typedef struct {

#define psync_find_result(res, name, type) psync_do_find_result(res, name, type, __FILE__, __FUNCTION__, __LINE__)
#define psync_check_result(res, name, type) psync_do_check_result(res, name, type, __FILE__, __FUNCTION__, __LINE__)
#define psync_get_result(res, name) psync_do_get_result(res, name, __FILE__, __FUNCTION__, __LINE__)

psync_socket *psync_api_connect(const char *hostname, int usessl);
void psync_api_conn_fail_inc();
Expand All @@ -116,5 +117,6 @@ unsigned char *do_prepare_command(const char *command, size_t cmdlen, const binp
binresult *do_send_command(psync_socket *sock, const char *command, size_t cmdlen, const binparam *params, size_t paramcnt, int64_t datalen, int readres) PSYNC_NONNULL(1, 2);
const binresult *psync_do_find_result(const binresult *res, const char *name, uint32_t type, const char *file, const char *function, int unsigned line) PSYNC_NONNULL(2) PSYNC_PURE;
const binresult *psync_do_check_result(const binresult *res, const char *name, uint32_t type, const char *file, const char *function, int unsigned line) PSYNC_NONNULL(2) PSYNC_PURE;
const binresult *psync_do_get_result(const binresult *res, const char *name, const char *file, const char *function, int unsigned line) PSYNC_NONNULL(2) PSYNC_PURE;

#endif
Loading