Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pcloudcom committed Feb 18, 2020
1 parent a740fb8 commit 2ecb7c9
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 145 deletions.
47 changes: 22 additions & 25 deletions pCloudCC/control_tools.cpp
Expand Up @@ -28,49 +28,44 @@ enum command_ids_ {
ADDSYNC,
STOPSYNC
};


int start_crypto(const char * pass){
int start_crypto(const char * pass) {
int ret;
char* errm=NULL;
if(SendCall(STARTCRYPTO, pass, &ret, &errm))
std::cout << "Start Crypto failed. return is " << ret << " and message is "<<errm << std::endl;
char* errm;
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;
if(errm)
free(errm);
free(errm);
}

int stop_crypto(){
int ret;
char* errm=NULL;
char* errm;
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;
if (errm)
free(errm);
free(errm);
}

int finalize(){
int ret;
char* errm=NULL;
char* errm;
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;
if (errm)
free(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 @@ -86,11 +81,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 @@ -99,9 +94,10 @@ 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 @@ -110,9 +106,10 @@ int daemonize(bool do_commands) {

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

}

}

1 comment on commit 2ecb7c9

@glenndm1000
Copy link

@glenndm1000 glenndm1000 commented on 2ecb7c9 Feb 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the modifications. The compile and build on debian buster is now succesful.
best regards

Please sign in to comment.