diff --git a/update/agent/include/agent/linux/datasid-agent.h b/update/agent/include/agent/linux/datasid-agent.h index 9c6674dbd80b21dbb4c29661e47aa7542e11f0db..b2a9c552d2e131185c34997f415c1915837ebc23 100644 --- a/update/agent/include/agent/linux/datasid-agent.h +++ b/update/agent/include/agent/linux/datasid-agent.h @@ -43,6 +43,6 @@ class Agent{ std::string getVersion() const; }; -std::string getAbsolutePath( std::string str, int tot); int datasid_agent(); +std::string getAbsolutePath( std::string str, int tot); bool prefixIsSet(std::string prefix); diff --git a/update/agent/include/agent/linux/datasid-common.h b/update/agent/include/agent/linux/datasid-common.h index 9093bf9508e63dc8f45c072050773a1639dd69a4..60dd76b2bf27df538811552bb875c2fec81ea157 100644 --- a/update/agent/include/agent/linux/datasid-common.h +++ b/update/agent/include/agent/linux/datasid-common.h @@ -24,6 +24,5 @@ #include "datasid-conf.h" #include "datasid-proxy.h" -bool fileExist(const char * file); bool datasid_common(Conf* conf, Proxy* proxy, Agent* agent); - +bool fileExist(const char * file); diff --git a/update/agent/include/agent/linux/datasid-conf.h b/update/agent/include/agent/linux/datasid-conf.h index 7327e9c16188be9335ca2ba015f7a75e0432b0da..4864c0e723d3280f0f5040b3d6db6961a0474b95 100644 --- a/update/agent/include/agent/linux/datasid-conf.h +++ b/update/agent/include/agent/linux/datasid-conf.h @@ -58,5 +58,5 @@ class Conf{ }; +void datasid_conf(Agent* agent, Conf* conf); bool setConf(Conf* conf, Agent* agent, std::map<std::string, std::string>* content); -void datasid_conf(Agent* agent, Conf* conf); \ No newline at end of file diff --git a/update/agent/include/agent/linux/datasid-parse.h b/update/agent/include/agent/linux/datasid-parse.h index b5888e5a2c5c096b301784ee4f3ef0d05d359a93..d82dc76f2a51c2eda28c482ab8268d95b3d81bd7 100644 --- a/update/agent/include/agent/linux/datasid-parse.h +++ b/update/agent/include/agent/linux/datasid-parse.h @@ -31,4 +31,4 @@ void normalize(std::string * str); void parse(std::string * line, std::map<std::string, std::string> * content); bool readFile(const std::string file, std::map<std::string, std::string> * content); bool spaceOnly(const std::string * line); -void trim(std::string& str); \ No newline at end of file +void trim(std::string& str); diff --git a/update/agent/include/agent/linux/datasid-proxy.h b/update/agent/include/agent/linux/datasid-proxy.h index 32f00bc7b595f96086fd5a962fa606aecb4c03fe..ab7ca1bc09d24b04a7cbd814e5728d964fb8dfd5 100644 --- a/update/agent/include/agent/linux/datasid-proxy.h +++ b/update/agent/include/agent/linux/datasid-proxy.h @@ -43,5 +43,5 @@ class Proxy{ std::string getPassword() const; }; -bool setProxy(Proxy* proxy, std::map<std::string, std::string>* content); void datasid_proxy(Conf* conf, Proxy* proxy); +bool setProxy(Proxy* proxy, std::map<std::string, std::string>* content); diff --git a/update/agent/src/linux/datasid-conf.cpp b/update/agent/src/linux/datasid-conf.cpp index 4dac53e9cdea0c773577681502aff4104e55fbbd..99f967bc59b9e09ca36020dca7acaadf1b61760f 100644 --- a/update/agent/src/linux/datasid-conf.cpp +++ b/update/agent/src/linux/datasid-conf.cpp @@ -18,9 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. */ -#include <iostream> -#include <cstring> #include <cstdlib> +#include <cstring> +#include <iostream> #include <locale> #include <sstream> #include "../../include/agent/linux/datasid-conf.h" @@ -143,13 +143,13 @@ bool setConf(Conf* conf, Agent* agent, std::map<std::string, std::string>* conte void datasid_conf(Agent* agent, Conf* conf) { std::map<std::string, std::string> content; - if (readFile(agent->getDefaultConf(), &content)) + if (readFile(agent->getDefaultConf(), &content)) { if (!setConf(conf, agent, &content)) { std::cout << __DATE__ << " ERROR: to parse variables " << "from config file." << std::endl; exit(1); } - else { + } else { std::cout << __DATE__ << " ERROR: config file not found." << std::endl; exit(1); } diff --git a/update/agent/src/linux/datasid-parse.cpp b/update/agent/src/linux/datasid-parse.cpp index 13557967007249cd3b8e9230ec0c99b66cac0816..86fd337e00dc8c4ba5e6a46999ae3d1c0873f68c 100644 --- a/update/agent/src/linux/datasid-parse.cpp +++ b/update/agent/src/linux/datasid-parse.cpp @@ -51,12 +51,13 @@ void trim(std::string* str) { */ void normalize(std::string* str) { - trim(str); - size_t i, j; i = j = 0; + + trim(str); while (i < str->length()) { + if ((*str)[i] == ' ' || (*str)[i] == '\t') { j = i + 1; @@ -67,9 +68,8 @@ void normalize(std::string* str) { str->erase(i, 1); else str->erase(i, j - i); - } else { + } else ++i; - } } } @@ -93,9 +93,10 @@ bool spaceOnly(const std::string* line) { bool isValid(std::string* line) { std::string e = *line; - normalize(line); int i = 0; + normalize(line); + /* if the line is a comment */ if (std::regex_match((*line), std::regex("((\\/\\/)|(\\/\\*)|(\\#))(.*)"))) @@ -161,6 +162,7 @@ void parse(std::string* line, std::map<std::string, std::string>* content) { if ((*line)[0] == '"') { std::string name = line->substr(1, line->find(':')-2); + for (int i = 0; i < name.length(); i++) name[i] = toupper(name[i], loc); diff --git a/update/agent/src/linux/datasid-proxy.cpp b/update/agent/src/linux/datasid-proxy.cpp index 2c4d6f06bf5a1c1959d53f95217ec111a108000b..1e78cf9fb2e06dbc68b8759ad2ade9fb270a8024 100644 --- a/update/agent/src/linux/datasid-proxy.cpp +++ b/update/agent/src/linux/datasid-proxy.cpp @@ -85,12 +85,12 @@ bool setProxy(Proxy* proxy, std::map<std::string, std::string>* content) { void datasid_proxy(Conf* conf, Proxy* proxy) { std::map<std::string, std::string> content; - if (readFile(conf->getProxyConf(), &content)) + if (readFile(conf->getProxyConf(), &content)) { if (!setProxy(proxy, &content)) { std::cout << __DATE__ << " ERROR: to parse variables" << " from proxy file." << std::endl; exit(1); } - else + } else std::cout << __DATE__ << " WARNING: proxy file not found." << std::endl; }