Commit c9cc29eb authored by mr-ti's avatar mr-ti
Browse files

No commit message

No commit message
parent d313bc3d
#include <unicomctrl/cuniconffile.h>
#include <unicomctrl/cuniconfreg.h>
#include <unicomctrl/cunithreadmanager.h>
#include <string>
#include <signal.h>
#include "csvnmanagercl.h"
CUniThreadManager thList;
void quit(int sig){
//Arrêt des clients.
thList.breakWait();
}
int main(int argc, char **argv) {
//Initialisation.
CUniSocket::init();
#ifdef WIN32
CUniConfReg config("Software\\UniComPl\\svnmanager",CUniConfReg::REG_LM);
#else
CUniConfFile config("/etc/unicomctrl/svnmanager.conf");
#endif
// Niveau bavard
string value=config.getValue("verbose_level");
if(value=="verbose")
CUniIO::globalIO.setLevel(CUniIO::LONG);
else if(value=="short")
CUniIO::globalIO.setLevel(CUniIO::SHORT);
else if(value=="quiet")
CUniIO::globalIO.setLevel(CUniIO::QUIET);
else
CUniObj::printc("AuthManager","Configuration file >> Bade value for the parameter \"verbose_level\"\n"
"Possible values are :\n\t* verbose\n\t* short\n\t* quiet\n"
"You must correct this error in the configuration file.\n");
CUniSvnManager::svn=new CUniSvnManager(&config);
//Lancement des clients
CUniDB *db=CUniSvnManager::svn->getDB();
db->setSQL("SELECT id_svn_parent,ref,path FROM svn_parent");
if(!db->execAndOpen()){
CUniObj::printc("AuthManager","Fatal DB error !\n");
exit(EXIT_FAILURE);
}
CSVNManagerCl *thread;
string server=config.getValue("server");
string user=config.getValue("user");
string passwd=config.getValue("passwd");
string name=config.getValue("name");
thList.addTypeToManage("CSVNManagerCl");
while(db->next()){
thread=new CSVNManagerCl(server,db->extractRow(0),db->extractRow(2));
if(!thread->isConnected()){
thread->printc("Connection failed !\n");
exit(EXIT_FAILURE);
}
//Démarrage du client.
thread->start();
//Identification et insertion du plugin auprès du serveur.
if(!thread->query(NULL,"connect '"+user+"' '"+passwd+"'")
|| !thread->query(NULL,"insert '"+name+" "+db->extractRow(1)+"'")){
thread->printc("Failed to record : "+thread->getLastError()+"\n");
exit(EXIT_FAILURE);
}
}
db->close();
//Paramétrage de l'interruption.
signal(SIGTERM,quit);
signal(SIGINT,quit);
thList.waitJoin();
thList.killall();
delete CUniSvnManager::svn;
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment