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

No commit message

No commit message
parent bed1c177
......@@ -28,7 +28,7 @@ IF(NOT DEFINED project_WC_REVISION)
SET(project_WC_REVISION ${Default_Project_WC_REVISION})
ENDIF(NOT DEFINED project_WC_REVISION)
SET(global_unicomctrl_DEFS ${global_unicomctrl_DEFS} -D_UNI_REVISION="\\"${project_WC_REVISION}\\"" -D_UNI_VERSION="\\"0.7.2b0\\"")
SET(global_unicomctrl_DEFS ${global_unicomctrl_DEFS} -D_UNI_REVISION="\\"${project_WC_REVISION}\\"" -D_UNI_VERSION="\\"0.7.3b0\\"")
MESSAGE("DDnsSync Project revision ${project_WC_REVISION}")
SUBDIRS(ddnssbase ddnssync ddnssplugins)
......@@ -56,7 +56,7 @@ void DdnssHttpCl::get(string &result, const string &url){
curl_easy_setopt(handle,CURLOPT_WRITEDATA,&result);
CURLcode code = curl_easy_perform(handle);
if(code != CURLE_OK){
throw Exception(code,curl_easy_strerror(code));
throw Exception(curl_easy_strerror(code));
}
}
......@@ -72,7 +72,7 @@ void DdnssHttpCl::post(string &result, const string &url){
curl_easy_setopt(handle,CURLOPT_URL,urlTmp.c_str());
CURLcode code = curl_easy_perform(handle);
if(code != CURLE_OK){
throw Exception(code,curl_easy_strerror(code));
throw Exception(curl_easy_strerror(code));
}
}
......
......@@ -7,7 +7,7 @@ extern "C"
{
void exec(const string& request){
if(equ(request,"HELP"))
throw Exception(0,"dyndns <domaine name> <IP> <login> <password>");
throw Exception("dyndns <domaine name> <IP> <login> <password>");
// Découpage de la requête
Regex regex("'([^']+)'|(([^[:space:]]+))");
......@@ -19,7 +19,7 @@ extern "C"
if(elts.size()!=4){
string err="Wrong dyndns plugin use !\nUse : dyndns <domaine name> <IP> <login> <password>";
soute << err << endlIO;
throw Exception(0,err);
throw Exception(err);
}
soutd << "Request >> \""+request+"\"\n" << endIO;
......@@ -36,11 +36,11 @@ extern "C"
}else if(res=="nochg "+newIp){
string err="Warning >> Duplicate updates for the same host/ip, you should verify client settings...";
soutn << err << endlIO;
throw Exception(0,err);
throw Exception(err);
}else{
string err="FATAL ERROR >> See logs for more details, you must verify client settings...";
soute << err << "\nRequest result : \n" << res << endlIO;
throw Exception(0,err);
throw Exception(err);
}
}
}
......@@ -8,7 +8,7 @@ extern "C"
{
void exec(const string& request){
if(equ(request,"HELP"))
throw Exception(0,"zoneedit <domaine name> <login> <password>");
throw Exception("zoneedit <domaine name> <login> <password>");
// Découpage de la requête
Regex regex("'([^']+)'|(([^[:space:]]+))");
......@@ -20,7 +20,7 @@ extern "C"
if(elts.size()!=3){
string err="Wrong zoneedit plugin use !\nUse : zoneedit <domaine name> <login> <password>";
soute << err << endlIO;
throw Exception(0,err);
throw Exception(err);
}
soutd << "Request >> \"" << request << "\"\n" << endIO;
......@@ -43,9 +43,9 @@ extern "C"
"Code : " << scanRes.getCurMatch(2) <<
"\nText : " << scanRes.getCurMatch(3) <<
"\nZone : " << scanRes.getCurMatch(4) << endlIO;
throw Exception(0,scanRes.getCurMatch(3));
throw Exception(scanRes.getCurMatch(3));
}
}
throw FatalErrorException(0,"Result scan failed !");
throw FatalErrorException("Result scan failed !");
}
}
......@@ -24,27 +24,27 @@ DDnsSPlList::DDnsSPlList(Settings &config):Object() {
StringList list=config.getListValue("plugin_list");
Plugin *plugin;
string plugPath;
void *handle;
DLib *lib;
ExecFct exec;
char *tmp;
for(StringList::iterator it=list.begin();it!=list.end();it++){
plugPath=dirPath+"/lib"+*it+".so";
handle = dlopen (plugPath.c_str(), RTLD_LAZY|RTLD_GLOBAL);
if (!handle) {
oute << "dlopen() >> " << dlerror() << endlIO;
}else{
exec=(ExecFct)dlsym(handle, "exec");
if ((tmp = dlerror()) != NULL) {
oute << "dlsym() >> " << tmp << endlIO;
dlclose(handle);
}else{
plugin=(Plugin *)malloc(sizeof(Plugin));
plugin->handle=handle;
plugin->exec=exec;
plugList[*it]=plugin;
outd << "DDnsSPlList() >> plugin \"" << *it << "\" loaded.\n" << endIO;
lib = new DLib(plugPath);
try{
lib->load();
try{
exec=(ExecFct)lib->getSymbol("exec");
}catch(...){
lib->unload();
delete lib;
throw;
}
}
plugin=(Plugin *)malloc(sizeof(Plugin));
plugin->lib=lib;
plugin->exec=exec;
plugList[*it]=plugin;
outd << "DDnsSPlList() >> plugin \"" << *it << "\" loaded.\n" << endIO;
}catch(...){}
}
}else{
oute << "The \"plugin_dir_path\" is empty !\n" << endIO;
......@@ -56,7 +56,8 @@ DDnsSPlList::DDnsSPlList(Settings &config):Object() {
*/
DDnsSPlList::~DDnsSPlList() {
for(map<string,Plugin *>::iterator it=plugList.begin();it!=plugList.end();it++){
dlclose(it->second->handle);
it->second->lib->unload();
delete it->second->lib;
delete it->second;
outd << "~DDnsSPlList() >> plugin \"" << it->first << "\" unloaded.\n" << endIO;
}
......
......@@ -22,6 +22,7 @@
#include <unicomctrl/settings.h>
#include <unicomctrl/lib.h>
#include <unicomctrl/dlib.h>
#include <map>
using namespace unicomctrl;
......@@ -44,7 +45,7 @@ public:
private:
typedef void (*ExecFct)(const string&);
typedef struct Plugin{
void *handle;
DLib *lib;
ExecFct exec;
}Plugin;
map<string,Plugin *> plugList;
......
......@@ -49,7 +49,7 @@ void DDnsSReqAnalyzer::exec(const string& request) {
" * BUILD; Get the build date.\nPlugins :\n"+DDnsSPlList::pList->getHelps()+
" NB:\n{choice|other choice} => choice or other choice.\n[Option] => this is an option.\n");
} else {
throw Exception(0,"HELP request error.");
throw Exception("HELP request error.");
}
} else if (equ(elts.at(0),"VERSION")) { // KW
checkNb("VERSION",1);
......@@ -68,7 +68,7 @@ void DDnsSReqAnalyzer::exec(const string& request) {
returnMessage("Success.");
}
} else if (elts.size()==0) {
throw Exception(0,"Empty request.");
throw Exception("Empty request.");
}
} catch (Exception e) {
returnError(e.getMsg());
......
Supports Markdown
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