Updated copyright notice

This commit is contained in:
Martin 2014-02-22 15:22:42 +01:00
parent 3810a9507f
commit 81c2cef172
121 changed files with 2263 additions and 2268 deletions

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vld.h"
#include "Client.h"
@ -49,10 +49,10 @@ FCGIProtocolDriver * CClient::getFCGIProtocolDriver()
{
return driver;
}
#ifndef TCP_CORK
#define TCP_CORK TCP_NOPUSH
#endif
#ifndef TCP_CORK
#define TCP_CORK TCP_NOPUSH
#endif
void CClient::set(SOCKET ps, OutputCallback *poutput, FCGIProtocolDriver * pdriver )
{
@ -65,7 +65,7 @@ void CClient::set(SOCKET ps, OutputCallback *poutput, FCGIProtocolDriver * pdriv
#ifdef _WIN32
flag=1;
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
#else
#else
flag=0;
setsockopt(s, IPPROTO_TCP, TCP_CORK, (char *) &flag, sizeof(int));
#endif

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,22 +16,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Condition_boost.h"
#include "Mutex_boost.h"
#include "Server.h"
void CCondition::wait(IScopedLock *lock, int timems)
{
boost::recursive_mutex::scoped_lock *tl=((CLock*)lock->getLock())->getLock();
if(timems<0)
cond.wait(*tl);
else
{
cond.timed_wait(*tl, getWaitTime(timems));
}
}
#include "Condition_boost.h"
#include "Mutex_boost.h"
#include "Server.h"
void CCondition::wait(IScopedLock *lock, int timems)
{
boost::recursive_mutex::scoped_lock *tl=((CLock*)lock->getLock())->getLock();
if(timems<0)
cond.wait(*tl);
else
{
cond.timed_wait(*tl, getWaitTime(timems));
}
}
boost::xtime CCondition::getWaitTime(int timeoutms)
{
boost::xtime xt;
@ -43,14 +43,14 @@ boost::xtime CCondition::getWaitTime(int timeoutms)
}
xt.nsec+=timeoutms*1000000;
return xt;
}
void CCondition::notify_one(void)
{
cond.notify_one();
}
void CCondition::notify_all(void)
{
cond.notify_all();
}
void CCondition::notify_one(void)
{
cond.notify_one();
}
void CCondition::notify_all(void)
{
cond.notify_all();
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Interface/Types.h"
#include "Interface/Database.h"

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "FileSettingsReader.h"
#include "stringtools.h"
#include "Server.h"

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,26 +1,26 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "socket_header.h"
#include <string>
#ifndef _WIN32
#include <memory.h>
#endif
#ifndef _WIN32
#include <memory.h>
#endif
bool LookupBlocking(std::string pServer, in_addr *dest)
{

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -197,26 +197,26 @@ void CMemoryPipe::shutdown(void)
{
}
void CMemoryPipe::addThrottler(IPipeThrottler *throttler)
{
}
void CMemoryPipe::addOutgoingThrottler(IPipeThrottler *throttler)
{
}
void CMemoryPipe::addIncomingThrottler(IPipeThrottler *throttler)
{
void CMemoryPipe::addThrottler(IPipeThrottler *throttler)
{
}
_i64 CMemoryPipe::getTransferedBytes(void)
{
return 0;
}
void CMemoryPipe::resetTransferedBytes(void)
{
void CMemoryPipe::addOutgoingThrottler(IPipeThrottler *throttler)
{
}
void CMemoryPipe::addIncomingThrottler(IPipeThrottler *throttler)
{
}
_i64 CMemoryPipe::getTransferedBytes(void)
{
return 0;
}
void CMemoryPipe::resetTransferedBytes(void)
{
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "MemorySettingsReader.h"
#include "Server.h"
#include "stringtools.h"

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Mutex_boost.h"
CMutex::CMutex(void)

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "OutputStream.h"
#ifndef _WIN32

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -14,16 +14,16 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef NO_SQLITE
#include "SQLiteFactory.h"
#include "Database.h"
IDatabaseInt *SQLiteFactory::createDatabase(void)
{
return new CDatabase;
}
**************************************************************************/
#ifndef NO_SQLITE
#include "SQLiteFactory.h"
#include "Database.h"
IDatabaseInt *SQLiteFactory::createDatabase(void)
{
return new CDatabase;
}
#endif

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vld.h"
#include <deque>

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vld.h"
#ifdef _WIN32
#define _CRT_RAND_S
@ -23,7 +23,7 @@
#include <iostream>
#include <fstream>
#include <algorithm>
#include <algorithm>
#include <memory.h>
#ifndef _WIN32
#include <errno.h>
@ -81,13 +81,13 @@
# include <ctime>
# include <sys/time.h>
# include <unistd.h>
# include <sys/types.h>
# include <pwd.h>
# include <sys/types.h>
# include <pwd.h>
#endif
const size_t SEND_BLOCKSIZE=8192;
const size_t MAX_THREAD_ID=std::string::npos;
const size_t SEND_BLOCKSIZE=8192;
const size_t MAX_THREAD_ID=std::string::npos;
extern bool run;
CServer::CServer()
@ -136,7 +136,7 @@ void CServer::setup(void)
void CServer::destroyAllDatabases(void)
{
Log("Destroying all databases...", LL_DEBUG);
Log("Destroying all databases...", LL_DEBUG);
IScopedLock lock(db_mutex);
for(std::map<DATABASE_ID, SDatabase >::iterator i=databases.begin();
@ -414,7 +414,7 @@ void CServer::Log( const std::wstring &pStr, int LogLevel)
void CServer::setLogFile(const std::string &plf, std::string chown_user)
{
IScopedLock lock(log_mutex);
IScopedLock lock(log_mutex);
if(logfile_a)
{
logfile.close();
@ -426,17 +426,17 @@ void CServer::setLogFile(const std::string &plf, std::string chown_user)
#ifndef _WIN32
if(!chown_user.empty())
{
char buf[1000];
passwd pwbuf;
passwd *pw;
int rc=getpwnam_r(chown_user.c_str(), &pwbuf, buf, 1000, &pw);
if(pw!=NULL)
{
chown(plf.c_str(), pw->pw_uid, pw->pw_gid);
}
else
{
Server->Log("Unable to change logfile ownership", LL_ERROR);
char buf[1000];
passwd pwbuf;
passwd *pw;
int rc=getpwnam_r(chown_user.c_str(), &pwbuf, buf, 1000, &pw);
if(pw!=NULL)
{
chown(plf.c_str(), pw->pw_uid, pw->pw_gid);
}
else
{
Server->Log("Unable to change logfile ownership", LL_ERROR);
}
}
#endif
@ -812,8 +812,8 @@ IDatabase* CServer::getDatabase(THREAD_ID tid, DATABASE_ID pIdentifier)
Log("Database \""+database_iter->second.file+"\" couldn't be opened", LL_ERROR);
return NULL;
}
Log("Created new database connection for "+database_iter->second.file, LL_DEBUG);
Log("Created new database connection for "+database_iter->second.file, LL_DEBUG);
database_iter->second.tmap.insert( std::pair< THREAD_ID, IDatabaseInt* >( tid, db ) );
@ -967,10 +967,10 @@ IPipe* CServer::ConnectStream(std::string pServer, unsigned short pPort, unsigne
server.sin_family=AF_INET;
SOCKET s=socket(AF_INET, SOCK_STREAM, 0);
if(s==SOCKET_ERROR)
{
return NULL;
}
if(s==SOCKET_ERROR)
{
return NULL;
}
#ifdef _WIN32
u_long nonBlocking=1;
@ -1247,7 +1247,7 @@ void CServer::createThread(IThread *thread)
#endif
pthread_t t;
pthread_create(&t, &attr, &thread_helper_f, (void*)thread);
pthread_create(&t, &attr, &thread_helper_f, (void*)thread);
pthread_detach(t);
pthread_attr_destroy(&attr);
@ -1607,19 +1607,19 @@ void CServer::startupComplete(void)
IPipeThrottler* CServer::createPipeThrottler(size_t bps)
{
return new PipeThrottler(bps);
}
void CServer::shutdown(void)
{
run=false;
}
void CServer::initRandom(unsigned int seed)
{
init_genrand(seed);
}
}
void CServer::shutdown(void)
{
run=false;
}
void CServer::initRandom(unsigned int seed)
{
init_genrand(seed);
}
unsigned int CServer::getRandomNumber(void)
{
IScopedLock lock(rnd_mutex);
@ -1767,7 +1767,7 @@ void CServer::setLogCircularBufferSize(size_t size)
has_circular_log_buffer=size>0?true:false;
}
std::vector<SCircularLogEntry> CServer::getCicularLogBuffer( size_t minid )
std::vector<SCircularLogEntry> CServer::getCicularLogBuffer( size_t minid )
{
IScopedLock lock(log_mutex);

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vld.h"
#include <stdlib.h>
#include "SessionMgr.h"
@ -180,7 +180,7 @@ bool CSessionMgr::RemoveSession(const std::wstring &pSID)
{
iter->second->Remove();
}
delete i->second;
mSessions.erase(i);
return true;
@ -225,4 +225,4 @@ void CSessionMgr::operator()(void)
}
IScopedLock slock(stop_mutex);
stop_cond->notify_one();
}
}

View File

@ -1,26 +1,26 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "SettingsReader.h"
#include "stringtools.h"
#ifndef _WIN32
#include <stdlib.h>
#endif
#ifndef _WIN32
#include <stdlib.h>
#endif
std::string CSettingsReader::getValue(std::string key,std::string def)
{

View File

@ -1,30 +1,30 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifdef _WIN32
#include <winsock2.h>
#endif
#include "StreamPipe.h"
#ifndef _WIN32
#include <memory.h>
#endif
#include "Server.h"
#include "Interface/PipeThrottler.h"
#ifndef _WIN32
#include <memory.h>
#endif
#include "Server.h"
#include "Interface/PipeThrottler.h"
CStreamPipe::CStreamPipe( SOCKET pSocket)
: transfered_bytes(0)
@ -104,20 +104,20 @@ size_t CStreamPipe::Read(char *buffer, size_t bsize, int timeoutms)
if( rc>0 )
{
rc=recv(s, buffer, (int)bsize, MSG_NOSIGNAL);
if(rc<=0)
{
has_error=true;
return 0;
}
if(rc<=0)
{
has_error=true;
return 0;
}
}
if( rc>0 )
return rc;
else
{
if(rc<0)
{
if(rc<0)
{
has_error=true;
}
}
return 0;
}
}
@ -172,10 +172,10 @@ size_t CStreamPipe::Read(std::string *ret, int timeoutms)
ret->resize(l);
memcpy((char*)ret->c_str(), buffer, l);
}
else
{
return 0;
}
else
{
return 0;
}
return l;
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Table.h"
CRATable::~CRATable()

View File

@ -1,27 +1,27 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vld.h"
#include "Template.h"
#include "stringtools.h"
#include "Table.h"
#include "utf8/utf8.h"
#include "Server.h"
#include "Server.h"
#include "Interface/Database.h"
@ -199,18 +199,18 @@ std::string CTemplate::getData(void)
std::wstring output=data;
transform(output);
std::string ret;
try
{
if( sizeof(wchar_t)==2 )
try
{
if( sizeof(wchar_t)==2 )
utf8::utf16to8(output.begin(), output.end(), back_inserter(ret) );
else
utf8::utf32to8(output.begin(), output.end(), back_inserter(ret) );
}
catch(...)
{
Server->Log("Invalid UTF8!", LL_ERROR);
}
else
utf8::utf32to8(output.begin(), output.end(), back_inserter(ret) );
}
catch(...)
{
Server->Log("Invalid UTF8!", LL_ERROR);
}
return ret;
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Interface/Thread.h"
#include "ThreadPool.h"
@ -115,7 +115,7 @@ CThreadPool::~CThreadPool()
}
void CThreadPool::Shutdown(void)
{
{
bool do_leak_check=(Server->getServerParameter("leak_check")=="true");
IScopedLock lock(mutex);
for(size_t i=0;i<threads.size();++i)

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "AESEncryption.h"
#include "../Interface/Server.h"

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,28 +1,28 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../vld.h"
#ifdef _WIN32
#define DLLEXPORT extern "C" __declspec (dllexport)
#else
#define DLLEXPORT extern "C"
#define _exit exit
#include <unistd.h>
#define _exit exit
#include <unistd.h>
#endif
@ -108,5 +108,5 @@ DLLEXPORT void LoadActions(IServer* pServer)
DLLEXPORT void UnloadActions(void)
{
}
}

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,19 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../vld.h"
#include "pluginmgr.h"
#include "CryptoFactory.h"
#include "../stringtools.h"
IPlugin *CCryptoPluginMgr::createPluginInstance(str_map &params)
{
return new CryptoFactory();
}
void CCryptoPluginMgr::destroyPluginInstance(IPlugin *plugin)
{
CryptoFactory *s=(CryptoFactory*)plugin;
delete s;
}
#include "../vld.h"
#include "pluginmgr.h"
#include "CryptoFactory.h"
#include "../stringtools.h"
IPlugin *CCryptoPluginMgr::createPluginInstance(str_map &params)
{
return new CryptoFactory();
}
void CCryptoPluginMgr::destroyPluginInstance(IPlugin *plugin)
{
CryptoFactory *s=(CryptoFactory*)plugin;
delete s;
}

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,15 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "DownloadFactory.h"
#include "download2.h"
IFileDownload* DownloadFactory::createFileDownload(void)
{
return new CFileDownload();
}
void DownloadFactory::destroyFileDownload(IFileDownload* dl)
{
delete ((CFileDownload*)dl);
#include "DownloadFactory.h"
#include "download2.h"
IFileDownload* DownloadFactory::createFileDownload(void)
{
return new CFileDownload();
}
void DownloadFactory::destroyFileDownload(IFileDownload* dl)
{
delete ((CFileDownload*)dl);
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
//---------------------------------------------------------------------------
#include "DownloadThread.h"

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../vld.h"
#ifdef _WIN32
#define DLLEXPORT extern "C" __declspec (dllexport)
@ -30,11 +30,11 @@ IServer *Server;
#include "../Interface/Action.h"
#include "../Interface/File.h"
#include "../stringtools.h"
#include <stdlib.h>
#include <stdlib.h>
#include "pluginmgr.h"
CDownloadPluginMgr *downloadpluginmgr;
DLLEXPORT void LoadActions(IServer* pServer)

View File

@ -1,38 +1,38 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "socket_header.h"
#include "DownloadThread.h"
#include "../Interface/Server.h"
#include <fstream>
#include <memory.h>
#include <memory.h>
#include "../stringtools.h"
#include <stdlib.h>
#include <stdlib.h>
using namespace std;
in_addr getIP(std::string ip);
#define BUFFERSIZE 32768
#ifndef _WIN32
#define _unlink unlink
#endif
#ifndef _WIN32
#define _unlink unlink
#endif
in_addr getIP(string ip)
{
const char* host=ip.c_str();
@ -92,7 +92,7 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
if(pos>2) site+=url[i];
}
#ifdef _WIN32
#ifdef _WIN32
WSADATA wsa;
int rc = WSAStartup(MAKEWORD(2, 0), &wsa);
if(rc == SOCKET_ERROR)
@ -103,9 +103,9 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
pipe->Write(wd.getDataPtr(), wd.getDataSize());
return false;
}
#else
int rc;
#endif
#else
int rc;
#endif
Cs=(int)socket(AF_INET,SOCK_STREAM,0);
@ -131,13 +131,13 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
addr.sin_addr=getIP(proxy);
}
#ifdef _WIN32
#ifdef _WIN32
u_long nonBlocking=1;
ioctlsocket(Cs,FIONBIO,&nonBlocking);
#else
int flags=fcntl(Cs,F_GETFL,0);
fcntl(Cs, F_SETFL, flags|O_NONBLOCK);
#endif
#else
int flags=fcntl(Cs,F_GETFL,0);
fcntl(Cs, F_SETFL, flags|O_NONBLOCK);
#endif
int error;
connect(Cs,(sockaddr*)&addr,sizeof(sockaddr));
@ -220,10 +220,10 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
bool chunked=false;
int chunksize=-1;
bool exit=false;
#ifndef _WIN32
conn[0].events=POLLIN;
#endif
#ifndef _WIN32
conn[0].events=POLLIN;
#endif
while(bytes>0 && exit==false)
{
@ -307,9 +307,9 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
{
out.write(&tmpbuf[4+csize2.size()], tmpbuf.size()-4-csize2.size());
out.flush();
chunksize-=tmpbuf.size()-4-csize2.size();
chunksize-=tmpbuf.size()-4-csize2.size();
totalbytes+=(int)(tmpbuf.size()-4-csize2.size());
tmpbuf.clear();
tmpbuf.clear();
}
}
}
@ -386,7 +386,7 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
if( csize1!="" )
{
chunksize=hexToULong((char*)csize1.c_str() );
chunksize=(std::max)(-1, (std::min)(1048576,chunksize) );
chunksize=(std::max)(-1, (std::min)(1048576,chunksize) );
}
offadd+=csize1.size()+2;
}
@ -409,7 +409,7 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
if( ncsize!="" )
{
chunksize=hexToULong((char*)ncsize.c_str() );
chunksize=(std::max)(-1, (std::min)(1048576,chunksize) );
chunksize=(std::max)(-1, (std::min)(1048576,chunksize) );
off=4+ncsize.size();
offadd=0;
}
@ -423,9 +423,10 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std
{
out.write(&tmpbuf[off+offadd], tmpbuf.size()-off-offadd );
out.flush();
chunksize-=tmpbuf.size()-off-offadd;
chunksize-=tmpbuf.size()-off-offadd;
totalbytes+=(int)(tmpbuf.size()-off-offadd);
tmpbuf.clear();
tmpbuf.clear();
}
else if( chunksize==0 )
{
@ -543,14 +544,14 @@ uchar CFileDownload::download(int wait)
{
CRData rd(data.c_str(), data.size());
rd.getUChar(&id);
err1=id;
err1=id;
switch(id)
{
case DL2_ERROR:
{
uchar eid;
rd.getUChar(&eid);
err2=eid;
err2=eid;
if( eid==DL2_ERR_TIMEOUT )
{
@ -569,7 +570,7 @@ uchar CFileDownload::download(int wait)
{
uchar iid;
rd.getUChar(&iid);
err2=iid;
err2=iid;
if( iid==DL2_INFO_DOWNLOADING )
{
@ -581,7 +582,7 @@ uchar CFileDownload::download(int wait)
{
uchar b;
rd.getUChar(&b);
err2=b;
err2=b;
if( b==0 )
return FD_ERR_ERROR;
@ -637,13 +638,13 @@ std::string CFileDownload::getErrorString(uchar err)
ERR2STR(ERROR);
ERR2STR(CONTENT_LENGTH);
ERR2STR(QUEUE_ITEMS);
if(err1==DL2_ERROR && err2==DL2_ERR_COULDNOTOPENFILE )
{
errmsg+=" Could not open destination file. Check rights please. Filename="+filename;
}
errmsg+=" ("+nconvert(err1)+", "+nconvert(err2)+") url="+url;
if(err1==DL2_ERROR && err2==DL2_ERR_COULDNOTOPENFILE )
{
errmsg+=" Could not open destination file. Check rights please. Filename="+filename;
}
errmsg+=" ("+nconvert(err1)+", "+nconvert(err2)+") url="+url;
return errmsg;
}

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,19 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../vld.h"
#include "pluginmgr.h"
#include "DownloadFactory.h"
#include "../stringtools.h"
IPlugin *CDownloadPluginMgr::createPluginInstance(str_map &params)
{
return new DownloadFactory();
}
void CDownloadPluginMgr::destroyPluginInstance(IPlugin *plugin)
{
DownloadFactory *s=(DownloadFactory*)plugin;
delete s;
}
#include "../vld.h"
#include "pluginmgr.h"
#include "DownloadFactory.h"
#include "../stringtools.h"
IPlugin *CDownloadPluginMgr::createPluginInstance(str_map &params)
{
return new DownloadFactory();
}
void CDownloadPluginMgr::destroyPluginInstance(IPlugin *plugin)
{
DownloadFactory *s=(DownloadFactory*)plugin;
delete s;
}

View File

@ -1,22 +1,22 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Server.h"
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Server.h"
#include "file.h"
#include "stringtools.h"

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -44,40 +44,40 @@ CriticalSection cs;
int curr_tid=0;
#ifdef _WIN32
bool isDirectory(const std::wstring &path)
{
DWORD attrib = GetFileAttributesW(path.c_str());
if ( attrib == 0xFFFFFFFF || !(attrib & FILE_ATTRIBUTE_DIRECTORY) )
{
return false;
}
else
{
return true;
}
bool isDirectory(const std::wstring &path)
{
DWORD attrib = GetFileAttributesW(path.c_str());
if ( attrib == 0xFFFFFFFF || !(attrib & FILE_ATTRIBUTE_DIRECTORY) )
{
return false;
}
else
{
return true;
}
}
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
bool isDirectory(const std::wstring &path)
{
struct stat64 f_info;
int rc=stat64(Server->ConvertToUTF8(path).c_str(), &f_info);
if(rc!=0)
{
return false;
}
if ( S_ISDIR(f_info.st_mode) )
{
return true;
}
else
{
return false;
}
bool isDirectory(const std::wstring &path)
{
struct stat64 f_info;
int rc=stat64(Server->ConvertToUTF8(path).c_str(), &f_info);
if(rc!=0)
{
return false;
}
if ( S_ISDIR(f_info.st_mode) )
{
return true;
}
else
{
return false;
}
}
#endif
@ -421,15 +421,15 @@ bool CClientThread::ProcessPacket(CRData *data)
}
#ifdef _WIN32
if(filename.size()>=2 && filename[0]=='\\' && filename[1]=='\\' )
{
if(filename.size()<3 || filename[2]!='?')
{
filename=L"\\\\?\\UNC"+filename.substr(1);
}
}
else
{
if(filename.size()>=2 && filename[0]=='\\' && filename[1]=='\\' )
{
if(filename.size()<3 || filename[2]!='?')
{
filename=L"\\\\?\\UNC"+filename.substr(1);
}
}
else
{
filename = L"\\\\?\\"+filename;
}
@ -1098,15 +1098,15 @@ bool CClientThread::GetFileBlockdiff(CRData *data)
hash_func.init();
#ifdef _WIN32
if(filename.size()>=2 && filename[0]=='\\' && filename[1]=='\\' )
{
if(filename.size()<3 || filename[2]!='?')
{
filename=L"\\\\?\\UNC"+filename.substr(1);
}
}
else
{
if(filename.size()>=2 && filename[0]=='\\' && filename[1]=='\\' )
{
if(filename.size()<3 || filename[2]!='?')
{
filename=L"\\\\?\\UNC"+filename.substr(1);
}
}
else
{
filename = L"\\\\?\\"+filename;
}
#endif

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -136,12 +136,12 @@ bool CTCPFileServ::Start(_u16 tcpport,_u16 udpport, std::string pServername)
getsockopt(mSocket, SOL_SOCKET, SO_SNDBUF,(char *) &window_size, &window_size_len );
Log("Info: Window size="+nconvert(window_size));
#endif
int optval=1;
rc=setsockopt(mSocket, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(int));
if(rc==SOCKET_ERROR)
{
Log("Failed setting SO_REUSEADDR in CTCPFileServ::Start", LL_ERROR);
return false;
int optval=1;
rc=setsockopt(mSocket, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(int));
if(rc==SOCKET_ERROR)
{
Log("Failed setting SO_REUSEADDR in CTCPFileServ::Start", LL_ERROR);
return false;
}
sockaddr_in addr;
@ -218,10 +218,10 @@ bool CTCPFileServ::TcpStep(void)
lon.tv_usec=0;
_i32 rc = select((int)mSocket+1, &fdset, 0, 0, &lon);
#else
pollfd conn[1];
conn[0].fd=mSocket;
conn[0].events=POLLIN;
conn[0].revents=0;
pollfd conn[1];
conn[0].fd=mSocket;
conn[0].events=POLLIN;
conn[0].revents=0;
int rc = poll(conn, 1, REFRESH_SECONDS*1000);
#endif

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -66,12 +66,12 @@ CUDPThread::CUDPThread(_u16 udpport,std::string servername)
{
udpsock=socket(AF_INET,SOCK_DGRAM,0);
int optval=1;
int rc=setsockopt(udpsock, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(int));
if(rc==SOCKET_ERROR)
{
Log("Failed setting SO_REUSEADDR in CUDPThread::CUDPThread", LL_ERROR);
return;
int optval=1;
int rc=setsockopt(udpsock, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(int));
if(rc==SOCKET_ERROR)
{
Log("Failed setting SO_REUSEADDR in CUDPThread::CUDPThread", LL_ERROR);
return;
}
sockaddr_in addr_udp;
@ -172,10 +172,10 @@ bool CUDPThread::UdpStep(void)
lon.tv_sec=60;
rc=select((int)udpsock+1, &fdset, 0, 0, &lon);
#else
pollfd conn[1];
conn[0].fd=udpsock;
conn[0].events=POLLIN;
conn[0].revents=0;
pollfd conn[1];
conn[0].fd=udpsock;
conn[0].events=POLLIN;
conn[0].revents=0;
rc = poll(conn, 1, 60*1000);
#endif
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "settings.h"
#ifdef CAMPUS

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "FileServ.h"
#include "map_buffer.h"
#include "../stringtools.h"
@ -74,11 +74,11 @@ void FileServ::addIdentity(const std::string &pIdentity)
void FileServ::init_mutex(void)
{
mutex=Server->createMutex();
}
void FileServ::destroy_mutex(void)
{
Server->destroy(mutex);
}
void FileServ::destroy_mutex(void)
{
Server->destroy(mutex);
}
bool FileServ::checkIdentity(const std::string &pIdentity)
@ -118,4 +118,4 @@ void FileServ::runClient(IPipe *cp)
{
CClientThread cc(cp, NULL);
cc();
}
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "FileServFactory.h"
#include "../Interface/Thread.h"
#include "../Interface/Server.h"

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "settings.h"
#ifdef CAMPUS
@ -31,7 +31,7 @@
#include <netdb.h>
#include <unistd.h>
#include <fcntl.h>
#include <memory.h>
#include <memory.h>
#define SOCKET_ERROR -1
#define closesocket close
#endif

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,19 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../vld.h"
#include "FileServFactory.h"
#include "pluginmgr.h"
#include "../stringtools.h"
IPlugin *CFileServPluginMgr::createPluginInstance(str_map &params)
{
return new FileServFactory();
}
void CFileServPluginMgr::destroyPluginInstance(IPlugin *plugin)
{
FileServFactory *s=(FileServFactory*)plugin;
delete s;
}
#include "../vld.h"
#include "FileServFactory.h"
#include "pluginmgr.h"
#include "../stringtools.h"
IPlugin *CFileServPluginMgr::createPluginInstance(str_map &params)
{
return new FileServFactory();
}
void CFileServPluginMgr::destroyPluginInstance(IPlugin *plugin)
{
FileServFactory *s=(FileServFactory*)plugin;
delete s;
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "FSImageFactory.h"
#include "../Interface/Server.h"
#include "../Interface/File.h"
@ -28,11 +28,11 @@
#include "fs/unknown.h"
#include "vhdfile.h"
#include "../stringtools.h"
#ifdef _WIN32
#include <Windows.h>
#else
#include <errno.h>
#endif
#ifdef _WIN32
#include <Windows.h>
#else
#include <errno.h>
#endif
void PrintInfo(IFilesystem *fs)

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../vld.h"
#ifdef _WIN32
#define DLLEXPORT extern "C" __declspec (dllexport)
@ -24,7 +24,7 @@
#endif
#include <iostream>
#include <memory.h>
#include <memory.h>
#define DEF_SERVER
#include "../Interface/Server.h"
@ -33,7 +33,7 @@ IServer *Server;
#include "../Interface/Action.h"
#include "../Interface/File.h"
#include "../stringtools.h"
#include "../urbackupcommon/sha2/sha2.h"
#include "../urbackupcommon/sha2/sha2.h"
#include <stdlib.h>
@ -220,7 +220,7 @@ DLLEXPORT void LoadActions(IServer* pServer)
std::string vhdinfo=Server->getServerParameter("vhdinfo");
if(!vhdinfo.empty())
{
std::cout << "--VHDINFO--" << std::endl;
std::cout << "--VHDINFO--" << std::endl;
VHDFile in(Server->ConvertToUnicode(vhdinfo), true,0);
if(in.isOpen()==false)
{
@ -248,7 +248,7 @@ DLLEXPORT void LoadActions(IServer* pServer)
}
std::cout << "Blocks: " << new_blocks << "/" << total_blocks << std::endl;
exit(3);
exit(3);
}
std::string vhd_verify=Server->getServerParameter("vhd_verify");
@ -304,7 +304,7 @@ DLLEXPORT void LoadActions(IServer* pServer)
bool has_dig_z=false;
for(;currpos<size;currpos+=blocksize)
{
in.Seek(currpos);
in.Seek(currpos);
bool has_sector=in.this_has_sector();
if(!has_sector && !has_dig_z)
@ -332,10 +332,10 @@ DLLEXPORT void LoadActions(IServer* pServer)
}
_u32 dr=hashfile->Read((char*)dig_f, 32);
if( dr!=32 )
{
Server->Log("Could not read hash from file", LL_ERROR);
}
if( dr!=32 )
{
Server->Log("Could not read hash from file", LL_ERROR);
}
sha256_final(&ctx, dig_r);
sha256_init(&ctx);
}
@ -437,9 +437,9 @@ DLLEXPORT void LoadActions(IServer* pServer)
unsigned char dig_f[32];
_u32 dr=hashfile->Read((char*)dig_f, 32);
if( dr!=32 )
{
Server->Log("Could not read hash from file", LL_ERROR);
if( dr!=32 )
{
Server->Log("Could not read hash from file", LL_ERROR);
}
sha256_final(&ctx, dig_r);

View File

@ -1,31 +1,31 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "filesystem.h"
#include "../Interface/Server.h"
#include "../Interface/File.h"
#include "../stringtools.h"
#include <memory.h>
#ifdef _WIN32
#include <Windows.h>
#else
#include <errno.h>
#endif
#include <memory.h>
#ifdef _WIN32
#include <Windows.h>
#else
#include <errno.h>
#endif
Filesystem::Filesystem(const std::wstring &pDev)
{

View File

@ -1,32 +1,32 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../../Interface/Server.h"
#include "../../stringtools.h"
#include "ntfs.h"
#include <math.h>
#include <memory.h>
#ifndef _WIN32
#define UD_UINT64 0xFFFFFFFFFFFFFFFFULL
#else
#define UD_UINT64 0xFFFFFFFFFFFFFFFF
#endif
#include <memory.h>
#ifndef _WIN32
#define UD_UINT64 0xFFFFFFFFFFFFFFFFULL
#else
#define UD_UINT64 0xFFFFFFFFFFFFFFFF
#endif
class MemFree
{

View File

@ -1,28 +1,28 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "unknown.h"
#include "../../Interface/Server.h"
#include <memory.h>
#ifdef _WIN32
#include <Windows.h>
#endif
#include <memory.h>
#ifdef _WIN32
#include <Windows.h>
#endif
#define DEF_BLOCKSIZE 4096

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,19 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../vld.h"
#include "pluginmgr.h"
#include "FSImageFactory.h"
#include "../stringtools.h"
IPlugin *CImagePluginMgr::createPluginInstance(str_map &params)
{
return new FSImageFactory();
}
void CImagePluginMgr::destroyPluginInstance(IPlugin *plugin)
{
FSImageFactory *s=(FSImageFactory*)plugin;
delete s;
}
#include "../vld.h"
#include "pluginmgr.h"
#include "FSImageFactory.h"
#include "../stringtools.h"
IPlugin *CImagePluginMgr::createPluginInstance(str_map &params)
{
return new FSImageFactory();
}
void CImagePluginMgr::destroyPluginInstance(IPlugin *plugin)
{
FSImageFactory *s=(FSImageFactory*)plugin;
delete s;
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vhdfile.h"
#include "../Interface/Server.h"
#include "../Interface/Types.h"
@ -26,8 +26,8 @@
#ifdef _WIN32
#include <windows.h>
#else
#include <errno.h>
#endif
#include <errno.h>
#endif
const uint64 def_header_offset=0;
const uint64 def_dynamic_header_offset=512;
@ -1142,56 +1142,56 @@ std::wstring VHDFile::getFilenameW(void)
return file->getFilenameW();
}
std::string VHDFile::Read(_u32 tr)
{
std::string ret;
ret.resize(4096);
size_t read;
bool b=Read((char*)ret.c_str(), 4096, read);
if(!b)
{
ret.clear();
return ret;
}
ret.resize(read);
return ret;
}
_u32 VHDFile::Read(char* buffer, _u32 bsize)
{
size_t read;
bool b=Read(buffer, bsize, read);
if(!b)
{
return 0;
}
else
{
return (_u32)read;
}
}
_u32 VHDFile::Write(const std::string &tw)
{
return Write(tw.c_str(), (_u32)tw.size());
}
_i64 VHDFile::Size(void)
{
return (_i64)getSize();
}
void VHDFile::addVolumeOffset(_i64 offset)
{
volume_offset=offset;
}
void VHDFile::print_last_error()
{
#ifdef _WIN32
Server->Log("Last error: "+nconvert((int)GetLastError()), LL_ERROR);
#else
Server->Log("Last error: "+nconvert(errno), LL_ERROR);
#endif
std::string VHDFile::Read(_u32 tr)
{
std::string ret;
ret.resize(4096);
size_t read;
bool b=Read((char*)ret.c_str(), 4096, read);
if(!b)
{
ret.clear();
return ret;
}
ret.resize(read);
return ret;
}
_u32 VHDFile::Read(char* buffer, _u32 bsize)
{
size_t read;
bool b=Read(buffer, bsize, read);
if(!b)
{
return 0;
}
else
{
return (_u32)read;
}
}
_u32 VHDFile::Write(const std::string &tw)
{
return Write(tw.c_str(), (_u32)tw.size());
}
_i64 VHDFile::Size(void)
{
return (_i64)getSize();
}
void VHDFile::addVolumeOffset(_i64 offset)
{
volume_offset=offset;
}
void VHDFile::print_last_error()
{
#ifdef _WIN32
Server->Log("Last error: "+nconvert((int)GetLastError()), LL_ERROR);
#else
Server->Log("Last error: "+nconvert(errno), LL_ERROR);
#endif
}

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "IndexFiles.h"
std::vector<std::string> IndexFiles::files;

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "MIMEType.h"
std::map<std::string, std::string> MIMEType::types;

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

254
main.cpp
View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vld.h"
#define DEF_SERVER
#include "Server.h"
@ -38,12 +38,12 @@
# include "win_service/nt_service.h"
using namespace nt;
#endif
#ifndef _WIN32
# include <sys/types.h>
# include <pwd.h>
# include <sys/wait.h>
#endif
#ifndef _WIN32
# include <sys/types.h>
# include <pwd.h>
# include <sys/wait.h>
#endif
CServer *Server=NULL;
@ -51,11 +51,11 @@ using namespace std;
bool run=true;
bool no_server=false;
namespace
{
std::string g_logfile;
std::string g_logfile_user;
}
namespace
{
std::string g_logfile;
std::string g_logfile_user;
}
void init_mutex_selthread(void);
void destroy_mutex_selthread(void);
@ -66,14 +66,14 @@ void termination_handler(int signum)
run=false;
Server->Log("Shutting down (Signal "+nconvert(signum)+")", LL_WARNING);
}
void hub_handler(int signum)
{
if(!g_logfile.empty())
{
void hub_handler(int signum)
{
if(!g_logfile.empty())
{
Server->setLogFile(g_logfile, g_logfile_user);
}
}
}
}
#endif
#ifdef AS_SERVICE
@ -167,8 +167,8 @@ int main_fkt(int argc, char *argv[])
std::string logfile;
std::string workingdir;
bool daemon=false;
std::string daemon_user;
std::string pidfile;
std::string daemon_user;
std::string pidfile;
for(int i=1;i<argc;++i)
{
@ -181,11 +181,11 @@ int main_fkt(int argc, char *argv[])
{
daemon=true;
}
else if( carg=="--user" || carg=="-u" )
{
daemon_user=narg;
++i;
}
else if( carg=="--user" || carg=="-u" )
{
daemon_user=narg;
++i;
}
else if( carg=="--workingdir" )
{
workingdir=narg;
@ -228,18 +228,18 @@ int main_fkt(int argc, char *argv[])
else if (carg=="--loglevel" || carg=="-ll" )
{
loglevel=strlower(narg);
++i;
++i;
}
else if (carg=="--logfile" || carg=="-lf" )
{
logfile=narg;
++i;
++i;
}
else if( carg=="--pidfile" )
{
pidfile=narg;
++i;
}
else if( carg=="--pidfile" )
{
pidfile=narg;
++i;
}
else
{
if( carg.size()>1 && carg[0]=='-' )
@ -248,8 +248,8 @@ int main_fkt(int argc, char *argv[])
if( carg[1]=='-' && carg.size()>2 )
p=carg.substr(2, carg.size()-2);
else
p=carg.substr(1, carg.size()-1);
p=carg.substr(1, carg.size()-1);
std::string v;
if( narg.size()>0 && narg[0]!='-' )
@ -264,10 +264,10 @@ int main_fkt(int argc, char *argv[])
{
v=p.substr(g+1);
p=p.substr(0,g);
}
else
{
v="true";
}
else
{
v="true";
}
}
@ -303,8 +303,8 @@ int main_fkt(int argc, char *argv[])
else
{
Server->setServerWorkingDir(Server->ConvertToUnicode(workingdir));
}
}
#ifndef _WIN32
if(daemon)
@ -329,33 +329,33 @@ int main_fkt(int argc, char *argv[])
{
int status;
waitpid(pid1, &status, 0);
exit(0);
}
exit(0);
}
chdir(Server->ConvertToUTF8(Server->getServerWorkingDir()).c_str());
if(pidfile.empty())
{
pidfile="/var/run/urbackup_srv.pid";
}
std::fstream pf;
pf.open(pidfile.c_str(), std::ios::out|std::ios::binary);
if(pf.is_open())
{
pf << getpid();
pf.close();
}
if(pidfile.empty())
{
pidfile="/var/run/urbackup_srv.pid";
}
std::fstream pf;
pf.open(pidfile.c_str(), std::ios::out|std::ios::binary);
if(pf.is_open())
{
pf << getpid();
pf.close();
}
}
#endif
#endif
if(!logfile.empty())
{
g_logfile=logfile;
g_logfile_user=daemon_user;
g_logfile=logfile;
g_logfile_user=daemon_user;
Server->setLogFile(logfile, daemon_user);
}
@ -370,51 +370,51 @@ int main_fkt(int argc, char *argv[])
Server->setLogLevel(LL_INFO);
else if(loglevel=="error")
Server->setLogLevel(LL_ERROR);
}
#ifndef _WIN32
if( !daemon_user.empty() && (getuid()==0 || geteuid()==0) )
{
Server->Log("Changing user...", LL_DEBUG);
char buf[1000];
passwd pwbuf;
passwd *pw;
int rc=getpwnam_r(daemon_user.c_str(), &pwbuf, buf, 1000, &pw);
if(pw!=NULL)
{
Server->Log("done.");
setgid(pw->pw_gid);
setuid(pw->pw_uid);
}
else
{
Server->Log("Unable to change user, probably because process uid is not root", LL_ERROR);
}
}
#endif
}
#ifndef _WIN32
if( !daemon_user.empty() && (getuid()==0 || geteuid()==0) )
{
Server->Log("Changing user...", LL_DEBUG);
char buf[1000];
passwd pwbuf;
passwd *pw;
int rc=getpwnam_r(daemon_user.c_str(), &pwbuf, buf, 1000, &pw);
if(pw!=NULL)
{
Server->Log("done.");
setgid(pw->pw_gid);
setuid(pw->pw_uid);
}
else
{
Server->Log("Unable to change user, probably because process uid is not root", LL_ERROR);
}
}
#endif
if( sqlite3_threadsafe()==0 )
{
Server->Log("SQLite3 wasn't compiled with the SQLITE_THREADSAFE. Exiting.", LL_ERROR);
return 43;
}
//sqlite3_enable_shared_cache(1);
{
str_nmap::iterator iter=srv_params.find("sqlite_tmpdir");
if(iter!=srv_params.end() && !iter->second.empty())
{
sqlite3_temp_directory=sqlite3_mprintf("%s", iter->second.c_str());
}
}
}
//sqlite3_enable_shared_cache(1);
{
str_nmap::iterator iter=srv_params.find("sqlite_tmpdir");
if(iter!=srv_params.end() && !iter->second.empty())
{
sqlite3_temp_directory=sqlite3_mprintf("%s", iter->second.c_str());
}
}
for( size_t i=0;i<plugins.size();++i)
{
if( !Server->LoadDLL(plugins[i]) )
{
Server->Log("Loading "+(std::string)plugins[i]+" failed", LL_ERROR);
}
}
}
CLoadbalancerClient *lbs=NULL;
if( loadbalancer!="" )
@ -427,16 +427,16 @@ int main_fkt(int argc, char *argv[])
#ifndef _WIN32
if (signal (SIGINT, termination_handler) == SIG_IGN)
signal (SIGINT, SIG_IGN);
/*if(!daemon)
{
/*if(!daemon)
{
if (signal (SIGHUP, termination_handler) == SIG_IGN)
signal (SIGHUP, SIG_IGN);
}
else*/
{
}
else*/
{
if (signal (SIGHUP, hub_handler) == SIG_IGN)
signal (SIGHUP, SIG_IGN);
}
}
if (signal (SIGTERM, termination_handler) == SIG_IGN)
signal (SIGTERM, SIG_IGN);
#endif
@ -449,11 +449,11 @@ int main_fkt(int argc, char *argv[])
{
init_mutex_selthread();
c_at=new CAcceptThread(workers, port);
if(c_at->has_error())
{
Server->Log("Error while starting listening to ports. Stopping server.", LL_ERROR);
run=false;
}
if(c_at->has_error())
{
Server->Log("Error while starting listening to ports. Stopping server.", LL_ERROR);
run=false;
}
#ifndef AS_SERVICE
while(run==true)
{
@ -611,4 +611,4 @@ int main(int argc, char *argv[])
service.start();
}
}
#endif
#endif

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../Interface/Thread.h"
#include "ThreadPool.h"
#include <windows.h>

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "vld.h"
#include <string>
@ -1038,41 +1038,41 @@ void transformHTML(std::string &str)
std::wstring EscapeSQLString(const std::wstring &pStr)
{
std::wstring ret;
std::wstring ret;
for(size_t i=0;i<pStr.size();++i)
{
if(pStr[i]=='\'')
{
ret+=L"''";
ret+=L"''";
}
else
{
ret+=pStr[i];
}
else
{
ret+=pStr[i];
}
}
return ret;
return ret;
}
std::string EscapeSQLString(const std::string &pStr)
{
std::string ret;
std::string ret;
for(size_t i=0;i<pStr.size();++i)
{
if(pStr[i]=='\'')
{
ret+="''";
}
else
{
ret+=pStr[i];
}
else
{
ret+=pStr[i];
}
}
return ret;
return ret;
}
std::string EscapeParamString(const std::string &pStr)
{
std::string ret;
std::string ret;
for(size_t i=0;i<pStr.size();++i)
{
if(pStr[i]=='&')
@ -1083,12 +1083,12 @@ std::string EscapeParamString(const std::string &pStr)
{
ret+="%24";
}
else
{
ret+=pStr[i];
}
else
{
ret+=pStr[i];
}
}
return ret;
return ret;
}
void EscapeCh(std::string &pStr, char ch)
@ -1121,36 +1121,36 @@ void EscapeCh(std::wstring &pStr, wchar_t ch)
std::string UnescapeSQLString(const std::string &pStr)
{
std::string ret;
std::string ret;
for(size_t i=0;i<pStr.size();++i)
{
if( i+1<pStr.size() && pStr[i]=='\'' && pStr[i+1]=='\'' )
{
ret+="'";
++i;
}
else
{
ret+=pStr[i];
}
{
ret+="'";
++i;
}
else
{
ret+=pStr[i];
}
}
return ret;
}
std::wstring UnescapeSQLString(const std::wstring &pStr)
{
std::wstring ret;
std::wstring ret;
for(size_t i=0;i<pStr.size();++i)
{
if( i+1<pStr.size() && pStr[i]=='\'' && pStr[i+1]=='\'' )
{
ret+=L"'";
++i;
}
else
{
ret+=pStr[i];
}
{
ret+=L"'";
++i;
}
else
{
ret+=pStr[i];
}
}
return ret;
}
@ -1313,7 +1313,7 @@ std::string hexToBytes(const std::string& data)
wstring htmldecode(string str, bool html, char xc)
{
std::string tmp;
std::string tmp;
for(size_t i=0;i<str.size();i++)
{
if(str[i]==xc && i+2<str.size())
@ -1326,19 +1326,19 @@ wstring htmldecode(string str, bool html, char xc)
tmp+="&#"+nconvert((s32)ch)+";";
else
{
tmp+=ch;
tmp+=ch;
}
}
else if( ch!=0 )
{
tmp+=ch;
}
i+=2;
i+=2;
}
else
{
tmp+=str[i];
}
else
{
tmp+=str[i];
}
}
std::wstring ret;
try
@ -1724,4 +1724,4 @@ std::string PrettyPrintTime(unsigned int ms)
}
return ret;
}
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "ChangeJournalWatcher.h"
#include "../urbackupcommon/os_functions.h"
#include "../Interface/Server.h"

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "ClientSend.h"
#include "../Interface/Mutex.h"
#include "../Interface/Condition.h"

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "DirectoryWatcherThread.h"
#include "../Interface/Server.h"
#include "../stringtools.h"
@ -33,12 +33,12 @@ const unsigned int mindifftime=120000;
DirectoryWatcherThread::DirectoryWatcherThread(const std::vector<std::wstring> &watchdirs)
{
do_stop=false;
watching=watchdirs;
for(size_t i=0;i<watching.size();++i)
{
watching[i]=strlower(addSlashIfMissing(watching[i]));
}
watching=watchdirs;
for(size_t i=0;i<watching.size();++i)
{
watching[i]=strlower(addSlashIfMissing(watching[i]));
}
}
void DirectoryWatcherThread::operator()(void)
@ -68,16 +68,17 @@ void DirectoryWatcherThread::operator()(void)
CDirectoryChangeWatcher dcw(false);
#endif
for(size_t i=0;i<watching.size();++i)
{
for(size_t i=0;i<watching.size();++i)
{
#ifndef CHANGE_JOURNAL
dcw.WatchDirectory(watching[i], FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME|FILE_NOTIFY_CHANGE_LAST_WRITE, &cl, TRUE);
#else
dcw.watchDir(watching[i]);
#endif
}
#endif
}
while(do_stop==false)
{
@ -470,9 +471,9 @@ void ChangeListener::On_DirRemoved(const std::wstring & strDirName)
std::wstring DirectoryWatcherThread::addSlashIfMissing(const std::wstring &strDirName)
{
if(!strDirName.empty() && strDirName[strDirName.size()-1]!=os_file_sep()[0])
{
return strDirName+os_file_sep();
if(!strDirName.empty() && strDirName[strDirName.size()-1]!=os_file_sep()[0])
{
return strDirName+os_file_sep();
}
return strDirName;
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "ServerIdentityMgr.h"
#include "../Interface/Server.h"
#include "../stringtools.h"
@ -28,23 +28,23 @@ IMutex *ServerIdentityMgr::mutex=NULL;
IFileServ *ServerIdentityMgr::filesrv=NULL;
std::vector<unsigned int> ServerIdentityMgr::online_identities;
std::vector<std::string> ServerIdentityMgr::new_identities;
#ifdef _WIN32
const std::string server_ident_file="server_idents.txt";
const std::string server_new_ident_file="new_server_idents.txt";
#else
const std::string server_ident_file="urbackup/server_idents.txt";
const std::string server_new_ident_file="urbackup/new_server_idents.txt";
#endif
#ifdef _WIN32
const std::string server_ident_file="server_idents.txt";
const std::string server_new_ident_file="new_server_idents.txt";
#else
const std::string server_ident_file="urbackup/server_idents.txt";
const std::string server_new_ident_file="urbackup/new_server_idents.txt";
#endif
void ServerIdentityMgr::init_mutex(void)
{
mutex=Server->createMutex();
}
void ServerIdentityMgr::destroy_mutex(void)
{
Server->destroy(mutex);
}
void ServerIdentityMgr::destroy_mutex(void)
{
Server->destroy(mutex);
}
void ServerIdentityMgr::addServerIdentity(const std::string &pIdentity)
@ -124,53 +124,53 @@ size_t ServerIdentityMgr::numServerIdentities(void)
{
IScopedLock lock(mutex);
return identities.size();
}
bool ServerIdentityMgr::isNewIdentity(const std::string &pIdentity)
{
IScopedLock lock(mutex);
if( std::find(new_identities.begin(), new_identities.end(), pIdentity)!=new_identities.end())
{
return false;
}
else
{
new_identities.push_back(pIdentity);
writeServerIdentities();
return true;
}
}
void ServerIdentityMgr::writeServerIdentities(void)
{
IScopedLock lock(mutex);
std::string idents;
for(size_t i=0;i<identities.size();++i)
{
if(!idents.empty()) idents+="\r\n";
idents+=identities[i];
}
writestring(idents, server_ident_file);
std::string new_idents;
for(size_t i=0;i<new_identities.size();++i)
{
if(!new_idents.empty()) new_idents+="\r\n";
new_idents+=new_identities[i];
}
writestring(new_idents, server_new_ident_file);
}
bool ServerIdentityMgr::hasOnlineServer(void)
{
IScopedLock lock(mutex);
unsigned int ctime=Server->getTimeMS();
for(size_t i=0;i<online_identities.size();++i)
{
if(online_identities[i]!=0 && ctime-online_identities[i]<ident_online_timeout)
{
return true;
}
}
return false;
}
}
bool ServerIdentityMgr::isNewIdentity(const std::string &pIdentity)
{
IScopedLock lock(mutex);
if( std::find(new_identities.begin(), new_identities.end(), pIdentity)!=new_identities.end())
{
return false;
}
else
{
new_identities.push_back(pIdentity);
writeServerIdentities();
return true;
}
}
void ServerIdentityMgr::writeServerIdentities(void)
{
IScopedLock lock(mutex);
std::string idents;
for(size_t i=0;i<identities.size();++i)
{
if(!idents.empty()) idents+="\r\n";
idents+=identities[i];
}
writestring(idents, server_ident_file);
std::string new_idents;
for(size_t i=0;i<new_identities.size();++i)
{
if(!new_idents.empty()) new_idents+="\r\n";
new_idents+=new_identities[i];
}
writestring(new_idents, server_new_ident_file);
}
bool ServerIdentityMgr::hasOnlineServer(void)
{
IScopedLock lock(mutex);
unsigned int ctime=Server->getTimeMS();
for(size_t i=0;i<online_identities.size();++i)
{
if(online_identities[i]!=0 && ctime-online_identities[i]<ident_online_timeout)
{
return true;
}
}
return false;
}

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <windows.h>
#include "CriticalSection.h"

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <string>
void unescapeMessage(std::string &msg)

View File

@ -1,27 +1,27 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "tcpstack.h"
#include "../../common/data.h"
#include "../../md5.h"
#include <memory.h>
#define SEND_TIMEOUT 10000
#include <memory.h>
#define SEND_TIMEOUT 10000
#define MAX_PACKET 4096
const unsigned int checksum_len=16;
@ -62,16 +62,16 @@ size_t CTCPStack::Send(IPipe* p, char* buf, size_t msglen)
MAX_PACKETSIZE len=(MAX_PACKETSIZE)msglen;
memcpy(&buffer[len_off], &len, sizeof(MAX_PACKETSIZE) );
if(msglen>0)
{
if(msglen>0)
{
memcpy(&buffer[msg_off], buf, msglen);
}
if(add_checksum)
{
MD5 md((unsigned char*)&buffer[len_off], (unsigned int)msglen+sizeof(MAX_PACKETSIZE));
memcpy(buffer, md.raw_digest_int(), checksum_len);
}
}
if(add_checksum)
{
MD5 md((unsigned char*)&buffer[len_off], (unsigned int)msglen+sizeof(MAX_PACKETSIZE));
memcpy(buffer, md.raw_digest_int(), checksum_len);
}
size_t currpos=0;
@ -184,4 +184,4 @@ size_t CTCPStack::getBuffersize()
void CTCPStack::setAddChecksum(bool b)
{
add_checksum=b;
}
}

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "../../Interface/Server.h"
#include "FileClient.h"
@ -27,11 +27,11 @@
#include <iostream>
#include <memory.h>
#include <algorithm>
#ifndef _WIN32
#include <errno.h>
#endif
#include <algorithm>
#ifndef _WIN32
#include <errno.h>
#endif
extern std::string server_identity;
@ -97,20 +97,20 @@ FileClient::FileClient(bool enable_find_servers, int protocol_version, bool inte
Tokenize(bcast_interfaces, bcast_filter, ";,");
}
ifaddrs *ifap;
int rc=getifaddrs(&ifap);
if(rc==0)
{
for(;ifap!=NULL;ifap=ifap->ifa_next)
{
bool found_name = bcast_filter.empty() || std::find(bcast_filter.begin(), bcast_filter.end(), ifap->ifa_name)!=bcast_filter.end();
ifaddrs *ifap;
int rc=getifaddrs(&ifap);
if(rc==0)
{
for(;ifap!=NULL;ifap=ifap->ifa_next)
{
bool found_name = bcast_filter.empty() || std::find(bcast_filter.begin(), bcast_filter.end(), ifap->ifa_name)!=bcast_filter.end();
if(found_name &&
!(ifap->ifa_flags & IFF_LOOPBACK)
&& !(ifap->ifa_flags & IFF_POINTOPOINT)
&& (ifap->ifa_flags & IFF_BROADCAST)
&& ifap->ifa_addr->sa_family == AF_INET )
{
&& (ifap->ifa_flags & IFF_BROADCAST)
&& ifap->ifa_addr->sa_family == AF_INET )
{
SOCKET udpsock=socket(AF_INET,SOCK_DGRAM,0);
if(udpsock==-1)
{
@ -133,39 +133,39 @@ FileClient::FileClient(bool enable_find_servers, int protocol_version, bool inte
Server->Log(std::string("Binding to interface ")+std::string(ifap->ifa_name)+" for broadcasting...", LL_DEBUG);
rc = bind(udpsock, (struct sockaddr *)&source_addr, sizeof(source_addr));
if(rc<0)
{
Server->Log(std::string("Binding UDP socket failed for interface ")+std::string(ifap->ifa_name), LL_ERROR);
}
rc = bind(udpsock, (struct sockaddr *)&source_addr, sizeof(source_addr));
if(rc<0)
{
Server->Log(std::string("Binding UDP socket failed for interface ")+std::string(ifap->ifa_name), LL_ERROR);
}
rc = setsockopt(udpsock, SOL_SOCKET, SO_BROADCAST, (char*)&val, sizeof(BOOL) );
if(rc<0)
{
Server->Log(std::string("Enabling SO_BROADCAST for UDP socket failed for interface ")+std::string(ifap->ifa_name), LL_ERROR);
closesocket(udpsock);
continue;
}
#if defined(__FreeBSD__)
int optval=1;
if(setsockopt(udpsock, IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(int))==-1)
{
Server->Log(std::string("Error setting IP_ONESBCAST for interface " )+std::string(ifap->ifa_name), LL_ERROR);
}
#endif
broadcast_addrs.push_back(*((struct sockaddr_in *)ifap->ifa_broadaddr));
udpsocks.push_back(udpsock);
}
}
freeifaddrs(ifap);
}
else
{
Server->Log("Getting interface ips failed. errno="+nconvert(errno)+
". Server may not listen properly on all network devices when discovering clients.", LL_ERROR);
rc = setsockopt(udpsock, SOL_SOCKET, SO_BROADCAST, (char*)&val, sizeof(BOOL) );
if(rc<0)
{
Server->Log(std::string("Enabling SO_BROADCAST for UDP socket failed for interface ")+std::string(ifap->ifa_name), LL_ERROR);
closesocket(udpsock);
continue;
}
#if defined(__FreeBSD__)
int optval=1;
if(setsockopt(udpsock, IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(int))==-1)
{
Server->Log(std::string("Error setting IP_ONESBCAST for interface " )+std::string(ifap->ifa_name), LL_ERROR);
}
#endif
broadcast_addrs.push_back(*((struct sockaddr_in *)ifap->ifa_broadaddr));
udpsocks.push_back(udpsock);
}
}
freeifaddrs(ifap);
}
else
{
Server->Log("Getting interface ips failed. errno="+nconvert(errno)+
". Server may not listen properly on all network devices when discovering clients.", LL_ERROR);
SOCKET udpsock=socket(AF_INET,SOCK_DGRAM,0);
if(udpsock==-1)
{
@ -186,21 +186,21 @@ FileClient::FileClient(bool enable_find_servers, int protocol_version, bool inte
source_addr.sin_family = AF_INET;
source_addr.sin_port = htons(UDP_SOURCE_PORT);
Server->Log("Binding to no interface for broadcasting. Entering IP on restore CD won't work.", LL_WARNING);
rc = setsockopt(udpsock, SOL_SOCKET, SO_BROADCAST, (char*)&val, sizeof(BOOL) );
if(rc<0)
{
Server->Log("Enabling SO_BROADCAST for UDP socket failed", LL_ERROR);
closesocket(udpsock);
}
else
{
udpsocks.push_back(udpsock);
source_addr.sin_addr.s_addr = INADDR_BROADCAST;
broadcast_addrs.push_back(source_addr);
}
}
Server->Log("Binding to no interface for broadcasting. Entering IP on restore CD won't work.", LL_WARNING);
rc = setsockopt(udpsock, SOL_SOCKET, SO_BROADCAST, (char*)&val, sizeof(BOOL) );
if(rc<0)
{
Server->Log("Enabling SO_BROADCAST for UDP socket failed", LL_ERROR);
closesocket(udpsock);
}
else
{
udpsocks.push_back(udpsock);
source_addr.sin_addr.s_addr = INADDR_BROADCAST;
broadcast_addrs.push_back(source_addr);
}
}
}
#else
char hostname[MAX_PATH];
@ -240,18 +240,18 @@ FileClient::FileClient(bool enable_find_servers, int protocol_version, bool inte
source_addr.sin_port = htons(UDP_SOURCE_PORT);
rc = bind(udpsock, (struct sockaddr *)&source_addr, sizeof(source_addr));
if(rc<0)
{
Server->Log("Binding UDP socket failed", LL_ERROR);
if(rc<0)
{
Server->Log("Binding UDP socket failed", LL_ERROR);
}
setSockP(udpsock);
BOOL val=TRUE;
rc=setsockopt(udpsock, SOL_SOCKET, SO_BROADCAST, (char*)&val, sizeof(BOOL) );
if(rc<0)
{
Server->Log("Failed setting SO_BROADCAST in FileClient", LL_ERROR);
if(rc<0)
{
Server->Log("Failed setting SO_BROADCAST in FileClient", LL_ERROR);
}
udpsocks.push_back(udpsock);
@ -302,79 +302,79 @@ _u32 FileClient::GetServers(bool start, const std::vector<in_addr> &addr_hints)
if(start==true)
{
max_version=0;
for(size_t i=0;i<udpsocks.size();++i)
{
sockaddr_in addr_udp;
addr_udp.sin_family=AF_INET;
addr_udp.sin_port=htons(UDP_PORT);
#ifdef __FreeBSD__
addr_udp.sin_addr.s_addr=broadcast_addrs[i].sin_addr.s_addr;
#else
addr_udp.sin_addr.s_addr=INADDR_BROADCAST;
#endif
memset(addr_udp.sin_zero,0, sizeof(addr_udp.sin_zero));
char ch=ID_PING;
int rc=sendto(udpsocks[i], &ch, 1, 0, (sockaddr*)&addr_udp, sizeof(sockaddr_in));
if(rc==-1)
{
Server->Log("Sending broadcast failed!", LL_ERROR);
}
}
if(!addr_hints.empty())
{
for(size_t i=0;i<udpsocks.size();++i)
{
int broadcast=0;
#ifdef _WIN32
#define SETSOCK_CAST (char*)
#else
#define SETSOCK_CAST
#endif
if(setsockopt(udpsocks[i], SOL_SOCKET, SO_BROADCAST, SETSOCK_CAST &broadcast, sizeof(int))==-1)
{
Server->Log("Error setting socket to not broadcast", LL_ERROR);
}
#if defined(__FreeBSD__)
int optval=0;
if(setsockopt(udpsocks[i], IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(int))==-1)
{
Server->Log(std::string("Error setting IP_ONESBCAST" ), LL_ERROR);
}
#endif
for(size_t i=0;i<udpsocks.size();++i)
{
sockaddr_in addr_udp;
addr_udp.sin_family=AF_INET;
addr_udp.sin_port=htons(UDP_PORT);
#ifdef __FreeBSD__
addr_udp.sin_addr.s_addr=broadcast_addrs[i].sin_addr.s_addr;
#else
addr_udp.sin_addr.s_addr=INADDR_BROADCAST;
#endif
memset(addr_udp.sin_zero,0, sizeof(addr_udp.sin_zero));
char ch=ID_PING;
int rc=sendto(udpsocks[i], &ch, 1, 0, (sockaddr*)&addr_udp, sizeof(sockaddr_in));
if(rc==-1)
{
Server->Log("Sending broadcast failed!", LL_ERROR);
}
}
if(!addr_hints.empty())
{
for(size_t i=0;i<udpsocks.size();++i)
{
int broadcast=0;
#ifdef _WIN32
#define SETSOCK_CAST (char*)
#else
#define SETSOCK_CAST
#endif
if(setsockopt(udpsocks[i], SOL_SOCKET, SO_BROADCAST, SETSOCK_CAST &broadcast, sizeof(int))==-1)
{
Server->Log("Error setting socket to not broadcast", LL_ERROR);
}
#if defined(__FreeBSD__)
int optval=0;
if(setsockopt(udpsocks[i], IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(int))==-1)
{
Server->Log(std::string("Error setting IP_ONESBCAST" ), LL_ERROR);
}
#endif
for(size_t j=0;j<addr_hints.size();++j)
{
char ch=ID_PING;
sockaddr_in addr_udp;
addr_udp.sin_family=AF_INET;
addr_udp.sin_port=htons(UDP_PORT);
char ch=ID_PING;
sockaddr_in addr_udp;
addr_udp.sin_family=AF_INET;
addr_udp.sin_port=htons(UDP_PORT);
addr_udp.sin_addr.s_addr=addr_hints[j].s_addr;
memset(addr_udp.sin_zero,0, sizeof(addr_udp.sin_zero));
sendto(udpsocks[i], &ch, 1, 0, (sockaddr*)&addr_udp, sizeof(sockaddr_in) );
}
broadcast=1;
if(setsockopt(udpsocks[i], SOL_SOCKET, SO_BROADCAST, SETSOCK_CAST &broadcast, sizeof(int))==-1)
{
Server->Log("Error setting socket to broadcast", LL_ERROR);
}
#undef SETSOCK_CAST
#if defined(__FreeBSD__)
optval=1;
if(setsockopt(udpsocks[i], IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(int))==-1)
{
Server->Log(std::string("Error setting IP_ONESBCAST" ), LL_ERROR);
}
#endif
}
}
}
broadcast=1;
if(setsockopt(udpsocks[i], SOL_SOCKET, SO_BROADCAST, SETSOCK_CAST &broadcast, sizeof(int))==-1)
{
Server->Log("Error setting socket to broadcast", LL_ERROR);
}
#undef SETSOCK_CAST
#if defined(__FreeBSD__)
optval=1;
if(setsockopt(udpsocks[i], IPPROTO_IP, IP_ONESBCAST, &optval, sizeof(int))==-1)
{
Server->Log(std::string("Error setting IP_ONESBCAST" ), LL_ERROR);
}
#endif
}
}
starttime=Server->getTimeMS();

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,20 +1,20 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "server_channel.h"
@ -31,7 +31,7 @@
#include "server_settings.h"
#include "../urbackupcommon/capa_bits.h"
#include "serverinterface/helper.h"
#include <memory.h>
#include <memory.h>
#include <algorithm>
#include <limits.h>
@ -82,7 +82,7 @@ server_get(pServer_get), clientid(clientid), settings(NULL), internet_mode(inter
ServerChannelThread::~ServerChannelThread(void)
{
delete settings;
delete settings;
Server->destroy(mutex);
}

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef CLIENT_ONLY
#include "server_cleanup.h"
@ -34,14 +34,14 @@
#include "snapshot_helper.h"
#include "apps/cleanup_cmd.h"
#include "dao/ServerCleanupDAO.h"
#include <stdio.h>
#include <algorithm>
#include <stdio.h>
#include <algorithm>
IMutex *ServerCleanupThread::mutex=NULL;
ICondition *ServerCleanupThread::cond=NULL;
bool ServerCleanupThread::update_stats=false;
IMutex *ServerCleanupThread::a_mutex=NULL;
bool ServerCleanupThread::update_stats_interruptible=false;
bool ServerCleanupThread::update_stats_interruptible=false;
volatile bool ServerCleanupThread::do_quit=false;
const unsigned int min_cleanup_interval=12*60*60;
@ -51,13 +51,13 @@ void ServerCleanupThread::initMutex(void)
mutex=Server->createMutex();
cond=Server->createCondition();
a_mutex=Server->createMutex();
}
void ServerCleanupThread::destroyMutex(void)
{
Server->destroy(mutex);
Server->destroy(cond);
Server->destroy(a_mutex);
}
void ServerCleanupThread::destroyMutex(void)
{
Server->destroy(mutex);
Server->destroy(cond);
Server->destroy(a_mutex);
}
ServerCleanupThread::ServerCleanupThread(CleanupAction cleanup_action)
@ -101,17 +101,17 @@ void ServerCleanupThread::operator()(void)
return;
}
unsigned int last_cleanup=0;
{
IScopedLock lock(mutex);
cond->wait(&lock, 60000);
if(do_quit)
{
delete this;
return;
}
unsigned int last_cleanup=0;
{
IScopedLock lock(mutex);
cond->wait(&lock, 60000);
if(do_quit)
{
delete this;
return;
}
}
{
@ -149,10 +149,10 @@ void ServerCleanupThread::operator()(void)
if(!update_stats)
{
cond->wait(&lock, 3600000);
}
if(do_quit)
{
return;
}
if(do_quit)
{
return;
}
if(update_stats)
{
@ -211,8 +211,8 @@ void ServerCleanupThread::operator()(void)
last_cleanup=Server->getTimeSeconds();
}
}
}
}
delete this;
}
@ -226,13 +226,13 @@ void ServerCleanupThread::updateStats(bool interruptible)
void ServerCleanupThread::do_cleanup(void)
{
db_results cache_res;
if(db->getEngineName()=="sqlite")
{
db_results cache_res;
if(db->getEngineName()=="sqlite")
{
cache_res=db->Read("PRAGMA cache_size");
ServerSettings server_settings(db);
db->Write("PRAGMA cache_size = -"+nconvert(server_settings.getSettings()->update_stats_cachesize));
}
}
removeerr.clear();
cleanup_images();
@ -246,7 +246,7 @@ void ServerCleanupThread::do_cleanup(void)
int64 amount=cleanup_amount(server_settings.getSettings()->global_soft_fs_quota, db);
if(amount<total_space)
{
Server->Log("Space to free: "+PrettyPrintBytes(total_space-amount), LL_INFO);
Server->Log("Space to free: "+PrettyPrintBytes(total_space-amount), LL_INFO);
cleanup_images(total_space-amount);
cleanup_files(total_space-amount);
}
@ -274,18 +274,18 @@ bool ServerCleanupThread::do_cleanup(int64 minspace, bool switch_to_wal)
ServerStatus::incrementServerNospcStalled(1);
IScopedLock lock(a_mutex);
db_results cache_res;
if(db->getEngineName()=="sqlite")
{
db_results cache_res;
if(db->getEngineName()=="sqlite")
{
cache_res=db->Read("PRAGMA cache_size");
ServerSettings server_settings(db);
db->Write("PRAGMA cache_size = -"+nconvert(server_settings.getSettings()->update_stats_cachesize));
}
if(minspace>0)
{
Server->Log("Space to free: "+PrettyPrintBytes(minspace), LL_INFO);
}
if(minspace>0)
{
Server->Log("Space to free: "+PrettyPrintBytes(minspace), LL_INFO);
}
removeerr.clear();
cleanup_images(minspace);
@ -478,7 +478,7 @@ int ServerCleanupThread::hasEnoughFreeSpace(int64 minspace, ServerSettings *sett
return 1;
}
}
Server->Log("Free space: "+PrettyPrintBytes(available_space), LL_DEBUG);
Server->Log("Free space: "+PrettyPrintBytes(available_space), LL_DEBUG);
}
return 0;
}
@ -564,7 +564,7 @@ bool ServerCleanupThread::cleanup_images_client(int clientid, int64 minspace, st
int r=hasEnoughFreeSpace(minspace, &settings);
if( r==-1 || r==1 )
return true;
full_image_num=(int)getImagesFullNum(clientid, backupid, notit);
}
@ -595,9 +595,9 @@ bool ServerCleanupThread::cleanup_images_client(int clientid, int64 minspace, st
if(is!=-1) corr+=is;
removeImage(assoc[i], false);
}
if(!removeImage(backupid, true, corr))
{
notit.push_back(backupid);
if(!removeImage(backupid, true, corr))
{
notit.push_back(backupid);
}
else
{
@ -613,8 +613,8 @@ bool ServerCleanupThread::cleanup_images_client(int clientid, int64 minspace, st
int r=hasEnoughFreeSpace(minspace, &settings);
if( r==-1 || r==1 )
return true;
incr_image_num=(int)getImagesIncrNum(clientid, backupid, notit);
incr_image_num=(int)getImagesIncrNum(clientid, backupid, notit);
}
return false;
@ -799,15 +799,15 @@ bool ServerCleanupThread::cleanup_one_filebackup_client(int clientid, int64 mins
}
bool b=deleteFileBackup(settings.getSettings()->backupfolder, clientid, backupid);
filebid=backupid;
Server->Log("Done.", LL_INFO);
Server->Log("Done.", LL_INFO);
if(b)
{
return true;
}
full_file_num=(int)getFilesFullNum(clientid, backupid);
if(b)
{
return true;
}
full_file_num=(int)getFilesFullNum(clientid, backupid);
}
int incr_file_num=(int)getFilesIncrNum(clientid, backupid);
@ -820,15 +820,15 @@ bool ServerCleanupThread::cleanup_one_filebackup_client(int clientid, int64 mins
{
Server->Log(L"Deleting incremental file backup ( id="+convert(res_info.id)+L", backuptime="+res_info.backuptime+L", path="+res_info.path+L" ) from client \""+clientname.value+L"\" ( id="+convert(clientid)+L" ) ...", LL_INFO);
}
bool b=deleteFileBackup(settings.getSettings()->backupfolder, clientid, backupid);
filebid=backupid;
Server->Log("Done.", LL_INFO);
bool b=deleteFileBackup(settings.getSettings()->backupfolder, clientid, backupid);
filebid=backupid;
if(b)
{
return true;
}
Server->Log("Done.", LL_INFO);
if(b)
{
return true;
}
incr_file_num=(int)getFilesIncrNum(clientid, backupid);
}
@ -874,21 +874,21 @@ size_t ServerCleanupThread::getFilesFullNum(int clientid, int &backupid_top)
{
std::vector<int> res=cleanupdao->getFullNumFiles(clientid);
std::vector<int> no_err_res;
if(!removeerr.empty())
{
for(size_t i=0;i<res.size();++i)
{
int bid=res[i];
if(std::find(removeerr.begin(), removeerr.end(), bid)==removeerr.end())
{
no_err_res.push_back(res[i]);
}
}
}
else
{
no_err_res=res;
}
if(!removeerr.empty())
{
for(size_t i=0;i<res.size();++i)
{
int bid=res[i];
if(std::find(removeerr.begin(), removeerr.end(), bid)==removeerr.end())
{
no_err_res.push_back(res[i]);
}
}
}
else
{
no_err_res=res;
}
if(!no_err_res.empty())
{
backupid_top=no_err_res[0];
@ -900,21 +900,21 @@ size_t ServerCleanupThread::getFilesIncrNum(int clientid, int &backupid_top)
{
std::vector<int> res=cleanupdao->getIncrNumFiles(clientid);
std::vector<int> no_err_res;
if(!removeerr.empty())
{
for(size_t i=0;i<res.size();++i)
{
int bid=res[i];
if(std::find(removeerr.begin(), removeerr.end(), bid)==removeerr.end())
{
no_err_res.push_back(res[i]);
}
}
}
else
{
no_err_res=res;
}
if(!removeerr.empty())
{
for(size_t i=0;i<res.size();++i)
{
int bid=res[i];
if(std::find(removeerr.begin(), removeerr.end(), bid)==removeerr.end())
{
no_err_res.push_back(res[i]);
}
}
}
else
{
no_err_res=res;
}
if(!no_err_res.empty())
{
backupid_top=no_err_res[0];
@ -989,34 +989,34 @@ bool ServerCleanupThread::deleteFileBackup(const std::wstring &backupfolder, int
b=os_remove_nonempty_dir(os_file_prefix(path));
}
bool del=true;
bool err=false;
bool del=true;
bool err=false;
if(!b)
{
if(!os_directory_exists(os_file_prefix(path)))
{
if(os_directory_exists(os_file_prefix(backupfolder)))
{
del=true;
}
Server->Log(L"Warning: Directory doesn't exist: \""+path+L"\"", LL_WARNING);
}
else
{
del=false;
removeerr.push_back(backupid);
if(!os_directory_exists(os_file_prefix(path)))
{
if(os_directory_exists(os_file_prefix(backupfolder)))
{
del=true;
}
Server->Log(L"Warning: Directory doesn't exist: \""+path+L"\"", LL_WARNING);
}
else
{
del=false;
removeerr.push_back(backupid);
Server->Log(L"Error removing directory \""+path+L"\"", LL_ERROR);
err=true;
}
}
if(os_directory_exists(os_file_prefix(path)) )
{
del=false;
Server->Log(L"Directory still exists. Deleting backup failed. Path: \""+path+L"\"", LL_ERROR);
err=true;
removeerr.push_back(backupid);
}
if(del || force_remove)
err=true;
}
}
if(os_directory_exists(os_file_prefix(path)) )
{
del=false;
Server->Log(L"Directory still exists. Deleting backup failed. Path: \""+path+L"\"", LL_ERROR);
err=true;
removeerr.push_back(backupid);
}
if(del || force_remove)
{
db->DetachDBs();
db->BeginTransaction();
@ -1028,8 +1028,8 @@ bool ServerCleanupThread::deleteFileBackup(const std::wstring &backupfolder, int
}
ServerStatus::updateActive();
return !err;
return !err;
}
void ServerCleanupThread::removeClient(int clientid)
@ -1190,12 +1190,12 @@ void ServerCleanupThread::backup_database(void)
BackupServerGet::sendMailToAdmins("Database integrity check failed", "Database integrity check failed before database backup. You should restore the UrBackup database from a backup or try to repair it.");
}
}
}
void ServerCleanupThread::doQuit(void)
{
do_quit=true;
cond->notify_all();
}
void ServerCleanupThread::doQuit(void)
{
do_quit=true;
cond->notify_all();
}
bool ServerCleanupThread::truncate_files_recurisve(std::wstring path)
@ -1239,9 +1239,9 @@ void ServerCleanupThread::removeUnknown(void)
void ServerCleanupThread::enforce_quotas(void)
{
db_results cache_res;
if(db->getEngineName()=="sqlite")
{
db_results cache_res;
if(db->getEngineName()=="sqlite")
{
cache_res=db->Read("PRAGMA cache_size");
ServerSettings server_settings(db);
db->Write("PRAGMA cache_size = -"+nconvert(server_settings.getSettings()->update_stats_cachesize));
@ -1307,7 +1307,7 @@ bool ServerCleanupThread::enforce_quota(int clientid, std::ostringstream& log)
log << "This requires enforcement of the quota." << std::endl;
}
did_remove_something=false;
did_remove_something=false;
int state=0;
int nopc=0;
while(used_storage.value>client_quota && nopc<2)
@ -1382,4 +1382,4 @@ bool ServerCleanupThread::enforce_quota(int clientid, std::ostringstream& log)
}
#endif //CLIENT_ONLY
#endif //CLIENT_ONLY

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,39 +1,39 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "server_get.h"
#include "../Interface/Server.h"
#include "mbr_code.h"
#include "server_log.h"
#include "server_update_stats.h"
#include "../stringtools.h"
#include "server_cleanup.h"
#include "../fsimageplugin/IVHDFile.h"
#include "../fsimageplugin/IFSImageFactory.h"
#include "server_writer.h"
#include "zero_hash.h"
#include "server_running.h"
#include "../md5.h"
#include <memory.h>
#include <stdlib.h>
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "server_get.h"
#include "../Interface/Server.h"
#include "mbr_code.h"
#include "server_log.h"
#include "server_update_stats.h"
#include "../stringtools.h"
#include "server_cleanup.h"
#include "../fsimageplugin/IVHDFile.h"
#include "../fsimageplugin/IFSImageFactory.h"
#include "server_writer.h"
#include "zero_hash.h"
#include "server_running.h"
#include "../md5.h"
#include <memory.h>
#include <stdlib.h>
const unsigned int stat_update_skip=20;
const unsigned int sector_size=512;
const unsigned int sha_size=32;
@ -152,7 +152,7 @@ bool BackupServerGet::doImage(const std::string &pLetter, const std::wstring &pP
}
std::wstring imagefn=constructImagePath(widen(sletter));
int64 free_space=os_free_space(os_file_prefix(ExtractFilePath(imagefn)));
if(free_space!=-1 && free_space<minfreespace_image)
{
@ -160,10 +160,10 @@ bool BackupServerGet::doImage(const std::string &pLetter, const std::wstring &pP
if(!ServerCleanupThread::cleanupSpace(minfreespace_image) )
{
ServerLogger::Log(clientid, "Could not free space for image. NOT ENOUGH FREE SPACE.", LL_ERROR);
Server->destroy(cc);
Server->destroy(cc);
return false;
}
}
}
{
std::string mbrd=getMBR(widen(sletter));
@ -177,24 +177,24 @@ bool BackupServerGet::doImage(const std::string &pLetter, const std::wstring &pP
else
{
IFile *mbr_file=Server->openFile(os_file_prefix(imagefn+L".mbr"), MODE_WRITE);
if(mbr_file!=NULL)
{
if(mbr_file!=NULL)
{
_u32 w=mbr_file->Write(mbrd);
if(w!=mbrd.size())
{
Server->Log("Error writing mbr data.", LL_ERROR);
Server->destroy(mbr_file);
Server->destroy(cc);
return false;
}
if(w!=mbrd.size())
{
Server->Log("Error writing mbr data.", LL_ERROR);
Server->destroy(mbr_file);
Server->destroy(cc);
return false;
}
Server->destroy(mbr_file);
}
else
{
Server->Log("Error creating file for writing MBR data.", LL_ERROR);
Server->destroy(cc);
return false;
}
}
else
{
Server->Log("Error creating file for writing MBR data.", LL_ERROR);
Server->destroy(cc);
return false;
}
}
}
@ -666,7 +666,7 @@ bool BackupServerGet::doImage(const std::string &pLetter, const std::wstring &pP
ServerStatus::setServerStatus(status);
if(vhdfile!=NULL)
{
{
vhdfile->doExit();
Server->getThreadPool()->waitFor(vhdfile_ticket);
vhdfile_err=vhdfile->hasError();
@ -687,10 +687,10 @@ bool BackupServerGet::doImage(const std::string &pLetter, const std::wstring &pP
q_update_images_size->Bind(clientid);
q_update_images_size->Write();
q_update_images_size->Reset();
if(vhdfile_err==false)
{
if(vhdfile_err==false)
{
setBackupImageComplete();
}
}
db->EndTransaction();
Server->destroy(t_file);
}
@ -852,16 +852,16 @@ bool BackupServerGet::doImage(const std::string &pLetter, const std::wstring &pP
}
ServerLogger::Log(clientid, "Timeout while transfering image data", LL_ERROR);
do_image_cleanup:
if(cc!=NULL)
{
if(cc!=NULL)
{
transferred_bytes+=cc->getTransferedBytes();
}
}
unsigned int passed_time=Server->getTimeMS()-image_backup_starttime;
if(passed_time==0) passed_time=1;
ServerLogger::Log(clientid, "Transferred "+PrettyPrintBytes(transferred_bytes)+" - Average speed: "+PrettyPrintSpeed((size_t)((transferred_bytes*1000)/(passed_time) )), LL_INFO );
if(cc!=NULL)
if(cc!=NULL)
Server->destroy(cc);
if(vhdfile!=NULL)
{
if(blockdata!=NULL)
@ -1023,4 +1023,4 @@ int64 BackupServerGet::updateNextblock(int64 nextblock, int64 currblock, sha256_
}
}
return nextblock+1;
}
}

View File

@ -1,20 +1,20 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "server_log.h"
#include "../stringtools.h"
@ -199,7 +199,7 @@ void ServerLogger::reset(int clientid)
}
}
std::vector<SCircularLogEntry> ServerLogger::getCircularLogdata( int clientid, size_t minid )
std::vector<SCircularLogEntry> ServerLogger::getCircularLogdata( int clientid, size_t minid )
{
IScopedLock lock(mutex);

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,21 +1,21 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef CLIENT_ONLY
#include "server_prepare_hash.h"
@ -27,16 +27,16 @@
#include "../urbackupcommon/os_functions.h"
#include "../fileservplugin/chunk_settings.h"
#include "../md5.h"
#include <memory.h>
#include <memory.h>
BackupServerPrepareHash::BackupServerPrepareHash(IPipe *pPipe, IPipe *pOutput, int pClientid)
{
pipe=pPipe;
output=pOutput;
clientid=pClientid;
working=false;
chunk_patcher.setCallback(this);
has_error=false;
working=false;
chunk_patcher.setCallback(this);
has_error=false;
}
BackupServerPrepareHash::~BackupServerPrepareHash(void)
@ -48,7 +48,7 @@ void BackupServerPrepareHash::operator()(void)
{
while(true)
{
working=false;
working=false;
std::string data;
size_t rc=pipe->Read(&data);
if(data=="exit")
@ -65,8 +65,8 @@ void BackupServerPrepareHash::operator()(void)
if(rc>0)
{
working=true;
working=true;
CRData rd(&data);
std::string temp_fn;
@ -333,9 +333,9 @@ bool BackupServerPrepareHash::writeFileRepeat(IFile *f, const char *buf, size_t
bool BackupServerPrepareHash::hasError(void)
{
volatile bool r=has_error;
has_error=false;
volatile bool r=has_error;
has_error=false;
return r;
}
#endif //CLIENT_ONLY
#endif //CLIENT_ONLY

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -646,31 +646,31 @@ std::string ServerSettings::generateRandomBinaryKey(void)
return key;
}
int ServerSettings::getUpdateFreqImageIncr()
{
updateInternal(NULL);
IScopedLock lock(g_mutex);
return settings_cache->settings->update_freq_image_incr;
}
int ServerSettings::getUpdateFreqImageIncr()
{
updateInternal(NULL);
IScopedLock lock(g_mutex);
return settings_cache->settings->update_freq_image_incr;
}
int ServerSettings::getUpdateFreqFileIncr()
{
updateInternal(NULL);
IScopedLock lock(g_mutex);
updateInternal(NULL);
IScopedLock lock(g_mutex);
return settings_cache->settings->update_freq_incr;
}
int ServerSettings::getUpdateFreqImageFull()
{
updateInternal(NULL);
IScopedLock lock(g_mutex);
return settings_cache->settings->update_freq_image_full;
}
int ServerSettings::getUpdateFreqImageFull()
{
updateInternal(NULL);
IScopedLock lock(g_mutex);
return settings_cache->settings->update_freq_image_full;
}
int ServerSettings::getUpdateFreqFileFull()
{
updateInternal(NULL);
IScopedLock lock(g_mutex);
updateInternal(NULL);
IScopedLock lock(g_mutex);
return settings_cache->settings->update_freq_full;
}

View File

@ -1,6 +1,6 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
* Copyright (C) 2011-2014 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

Some files were not shown because too many files have changed in this diff Show More