From 183f55122a85d30d56bdff8c56857f84ffe30efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lais=20Frig=C3=A9rio?= <lfs@inf.ufpr.br> Date: Fri, 13 Jan 2017 10:59:33 -0200 Subject: [PATCH] Deleting update directory --- update/agent/CMakeLists.txt | 25 --- update/agent/conf/datasid-conf.json | 11 - .../agent/include/agent/linux/datasid-agent.h | 48 ----- .../include/agent/linux/datasid-common.h | 28 --- .../agent/include/agent/linux/datasid-conf.h | 62 ------ .../agent/include/agent/linux/datasid-parse.h | 34 --- .../agent/include/agent/linux/datasid-proxy.h | 47 ---- update/agent/include/agent/main.h | 13 -- update/agent/src/linux/datasid-agent.cpp | 113 ---------- update/agent/src/linux/datasid-common.cpp | 63 ------ update/agent/src/linux/datasid-conf.cpp | 156 -------------- update/agent/src/linux/datasid-parse.cpp | 202 ------------------ update/agent/src/linux/datasid-proxy.cpp | 96 --------- update/agent/src/main.cpp | 26 --- 14 files changed, 924 deletions(-) delete mode 100644 update/agent/CMakeLists.txt delete mode 100644 update/agent/conf/datasid-conf.json delete mode 100644 update/agent/include/agent/linux/datasid-agent.h delete mode 100644 update/agent/include/agent/linux/datasid-common.h delete mode 100644 update/agent/include/agent/linux/datasid-conf.h delete mode 100644 update/agent/include/agent/linux/datasid-parse.h delete mode 100644 update/agent/include/agent/linux/datasid-proxy.h delete mode 100644 update/agent/include/agent/main.h delete mode 100644 update/agent/src/linux/datasid-agent.cpp delete mode 100644 update/agent/src/linux/datasid-common.cpp delete mode 100644 update/agent/src/linux/datasid-conf.cpp delete mode 100644 update/agent/src/linux/datasid-parse.cpp delete mode 100644 update/agent/src/linux/datasid-proxy.cpp delete mode 100644 update/agent/src/main.cpp diff --git a/update/agent/CMakeLists.txt b/update/agent/CMakeLists.txt deleted file mode 100644 index c8f56b35..00000000 --- a/update/agent/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required( VERSION 2.6 ) - -project( datasid-agent ) - -# version number -set ( VERSION_MAJOR 0 ) -set ( VERSION_MINOR 0 ) - -# cpr requires c++11 -set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" ) - -# src : main -file ( GLOB SOURCES src/*.cpp ) - -# src : collect functions - depend on OS -if ( WIN32 ) - file ( GLOB SOURCES ${SOURCES} src/windows/*.cpp ) -else () # if( UNIX ) - file ( GLOB SOURCES ${SOURCES} src/linux/*.cpp ) -endif () - -# compile -set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin" ) -add_executable ( datasid-v${VERSION_MAJOR}.${VERSION_MINOR} ${SOURCES} ) - diff --git a/update/agent/conf/datasid-conf.json b/update/agent/conf/datasid-conf.json deleted file mode 100644 index 224b9fa8..00000000 --- a/update/agent/conf/datasid-conf.json +++ /dev/null @@ -1,11 +0,0 @@ -{ -"dataDir" : "/data", -"logDir" : "/log", -"proxyConf" : "/conf/proxy.json", -"delay" : "86400", // 24 hours -"daysToExpireLog" : "31", // 1 month -"updateTries" : "3", -"updateTimeOut":"100", -"webService": "http://simmc.c3sl.ufpr.br/axis2/services/DataSID" -} - diff --git a/update/agent/include/agent/linux/datasid-agent.h b/update/agent/include/agent/linux/datasid-agent.h deleted file mode 100644 index b2a9c552..00000000 --- a/update/agent/include/agent/linux/datasid-agent.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#pragma once -#include <iostream> - -class Agent{ - private: - std::string confDir; - std::string defaultConf; - std::string logFile; - std::string prefix; - std::string version; - - public: - void setConfDir(std::string); - void setDefaultConf(std::string); - void setLogFile(std::string, std::string); - void setPrefix(std::string, int); - void setVersion(std::string); - - std::string getConfDir() const; - std::string getDefaultConf() const; - std::string getLogFile() const; - std::string getPrefix() const; - std::string getVersion() const; - }; - -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 deleted file mode 100644 index 60dd76b2..00000000 --- a/update/agent/include/agent/linux/datasid-common.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#pragma once -#include <sys/stat.h> -#include "datasid-agent.h" -#include "datasid-conf.h" -#include "datasid-proxy.h" - -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 deleted file mode 100644 index 4864c0e7..00000000 --- a/update/agent/include/agent/linux/datasid-conf.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#pragma once -#include <map> -#include "datasid-agent.h" -#include "datasid-parse.h" - -class Conf{ - private: - std::string dataDir; - std::string logDir; - std::string proxyConf; - std::string webService; - - int delay; - int daysToExpireLog; - int updateTries; - int updateTimeOut; - - public: - void setDataDir(std::string); - void setLogDir(std::string); - void setProxyConf(std::string); - void setWebService(std::string); - - void setDelay(int); - void setDaysToExpireLog(int); - void setUpdateTries(int); - void setUpdatTimeOut(int); - - std::string getDataDir() const; - std::string getLogDir() const; - std::string getProxyConf() const; - std::string getWebService() const; - - int getDelay() const; - int getDaysToExpireLog() const; - int getUpdateTries() const; - int getUpdateTimeOut() const; - - }; - -void datasid_conf(Agent* agent, Conf* conf); -bool setConf(Conf* conf, Agent* agent, std::map<std::string, std::string>* content); diff --git a/update/agent/include/agent/linux/datasid-parse.h b/update/agent/include/agent/linux/datasid-parse.h deleted file mode 100644 index d82dc76f..00000000 --- a/update/agent/include/agent/linux/datasid-parse.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#pragma once -#include <cstring> -#include <cstdlib> -#include <fstream> -#include <iostream> -#include <locale> -#include <map> - -bool isValid(std::string * line); -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); diff --git a/update/agent/include/agent/linux/datasid-proxy.h b/update/agent/include/agent/linux/datasid-proxy.h deleted file mode 100644 index ab7ca1bc..00000000 --- a/update/agent/include/agent/linux/datasid-proxy.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#pragma once -#include <map> -#include "datasid-agent.h" -#include "datasid-conf.h" -#include "datasid-parse.h" - -class Proxy{ - private: - std::string host; - std::string port; - std::string user; - std::string password; - - public: - void setHost(std::string); - void setPort(std::string); - void setUser(std::string); - void setPassword(std::string); - - std::string getHost() const; - std::string getPort() const; - std::string getUser() const; - std::string getPassword() const; - }; - -void datasid_proxy(Conf* conf, Proxy* proxy); -bool setProxy(Proxy* proxy, std::map<std::string, std::string>* content); diff --git a/update/agent/include/agent/main.h b/update/agent/include/agent/main.h deleted file mode 100644 index 45dd1eb1..00000000 --- a/update/agent/include/agent/main.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __main__ -#define __main__ -#include <cstring> -#include <fstream> -#include <iostream> -#include "linux/datasid-proxy.h" -#include "linux/datasid-common.h" -#include "linux/datasid-agent.h" -#include "linux/datasid-conf.h" - -bool fileExist(const std::string& file); -int main(); -#endif diff --git a/update/agent/src/linux/datasid-agent.cpp b/update/agent/src/linux/datasid-agent.cpp deleted file mode 100644 index 3d71b94e..00000000 --- a/update/agent/src/linux/datasid-agent.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#include <string> -#include "../../include/agent/main.h" - -/* - * set Functions - */ - -void Agent::setConfDir(std::string dir) { - this->confDir = this->prefix + dir; -} - -void Agent::setDefaultConf(std::string defaultConf) { - this->defaultConf = this->prefix + defaultConf; -} - -void Agent::setLogFile(std::string logDir, std::string file) { - this->logFile = logDir + file; -} - -void Agent::setPrefix(std::string p, int t) { - this->prefix = getAbsolutePath(p, t); -} - -void Agent::setVersion(std::string v) { - this->version = v; -} - -/* - * get Functions - */ - -std::string Agent::getConfDir() const { - return this->confDir; -} - -std::string Agent::getDefaultConf() const { - return this->defaultConf; -} - -std::string Agent::getLogFile() const { - return this->logFile; -} - -std::string Agent::getPrefix() const { - return this->prefix; -} - -std::string Agent::getVersion() const { - return this->version; -} - -/* - * getAbsolutePath Function: - * get the absolute path of the agent - */ - -std::string getAbsolutePath(std::string str, int tot) { - int i = str.size(), count = 0; - while (i-->-1) - if (str[i] == '/') - if (++count == tot) - break; - return str.substr(0, i); -} - -/* - * prefixIsSet Function - * Check if the absolute path of agent was setted. - */ - -bool prefixIsSet(std::string prefix) { - if (prefix.size() == 0) - throw " ERROR: Prefix not set. "; - return true; -} - -int datasid_agent() { - Agent agent; - Conf conf; - Proxy proxy; - - /* Set agent prefix */ - agent.setPrefix(__FILE__, 3); - - /* Set confif file */ - agent.setDefaultConf("/conf/datasid-conf.json"); - - /* Run datasid-common.cpp */ - if (!datasid_common(&conf, &proxy, &agent)) - exit(1); - - return 1; -} diff --git a/update/agent/src/linux/datasid-common.cpp b/update/agent/src/linux/datasid-common.cpp deleted file mode 100644 index bf89b085..00000000 --- a/update/agent/src/linux/datasid-common.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#include "../../include/agent/linux/datasid-common.h" - -/* - * fileExist Function - * verify if a file exist - */ - -bool fileExist(const std::string& file) { - std::ifstream myFile(file.c_str(), std::ifstream::in); - if (myFile.is_open()) { - myFile.close(); - return true; - } - myFile.close(); - return false; -} - - -bool datasid_common(Conf* conf, Proxy* proxy, Agent* agent) { - try { - prefixIsSet(agent->getPrefix()); - } catch (const char* msg) { - std::cout << __DATE__ << msg << std::endl; - return false; - } - - /* Read config file and declare only valid variables */ - - if (!fileExist(agent->getDefaultConf())) { - std::cout << __DATE__ << "- ERROR: Config file not found. " << std::endl; - return false; - } else - datasid_conf(agent, conf); - - /* Read proxy file and declare only valid variables */ - - if (!fileExist(conf->getProxyConf())) - std::cout << __DATE__ << "- WARNING: Proxy file not found. " << std::endl; - else - datasid_proxy(conf, proxy); - - return true; -} diff --git a/update/agent/src/linux/datasid-conf.cpp b/update/agent/src/linux/datasid-conf.cpp deleted file mode 100644 index 99f967bc..00000000 --- a/update/agent/src/linux/datasid-conf.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#include <cstdlib> -#include <cstring> -#include <iostream> -#include <locale> -#include <sstream> -#include "../../include/agent/linux/datasid-conf.h" -/* - * set Functions - */ - -void Conf::setDataDir(std::string data) { - this->dataDir = data; -} - -void Conf::setLogDir(std::string log) { - this->logDir = log; -} - -void Conf::setProxyConf(std::string p) { - this->proxyConf = p; -} - -void Conf::setWebService(std::string web) { - this->webService = web; -} - -void Conf::setDelay(int d) { - this->delay = d; -} - -void Conf::setDaysToExpireLog(int d) { - this->daysToExpireLog = d; -} - -void Conf::setUpdateTries(int u) { - this->updateTries = u; -} - -void Conf::setUpdatTimeOut(int u) { - this->updateTimeOut = u; -} - -/* - * get Functions - */ - -std::string Conf::getDataDir() const { - return this->dataDir; -} - -std::string Conf::getLogDir() const { - return this->logDir; -} - -std::string Conf::getProxyConf() const { - return this->proxyConf; -} - -std::string Conf::getWebService() const { - return this->webService; -} - -int Conf::getDelay() const { - return this->delay; -} - -int Conf::getDaysToExpireLog() const { - return this->daysToExpireLog; -} - -int Conf::getUpdateTries() const { - return this->updateTries; -} - -int Conf::getUpdateTimeOut() const { - return this->updateTimeOut; -} - -/* - * setConf Function - * If variables from config file setted, - * then set the conf object - */ - -bool setConf(Conf* conf, Agent* agent, std::map<std::string, std::string>* content) { - if (content->count("DATADIR") == 0 || - content->count("LOGDIR") == 0 || - content->count("PROXYCONF") == 0 || - content->count("WEBSERVICE") == 0|| - content->count("DELAY") == 0 || - content->count("DAYSTOEXPIRELOG") == 0 || - content->count("UPDATETRIES") == 0 || - content->count("UPDATETIMEOUT") == 0 ) - return false; - - /* - * agent.getPrefix() contains the absolute path of the agent. - */ - - std::string dataDir = agent->getPrefix() + (*content)["DATADIR"]; - std::string dataLog = agent->getPrefix() + (*content)["LOGDIR"]; - std::string proxyConf = agent->getPrefix() + (*content)["PROXYCONF"]; - std::string webService = (*content)["WEBSERVICE"]; - - int delay = atoi((*content)["DELAY"].c_str()); - int daysToExpireLog = atoi((*content)["DAYSTOEXPIRELOG"].c_str()); - int updateTries = atoi((*content)["UPDATETRIES"].c_str()); - int updateTimeOut = atoi((*content)["UPDATETIMEOUT"].c_str()); - - conf->setDataDir(dataDir); - conf->setLogDir(dataLog); - conf->setProxyConf(proxyConf); - conf->setWebService(webService); - - conf->setDelay(delay); - conf->setDaysToExpireLog(daysToExpireLog); - conf->setUpdateTries(updateTries); - conf->setUpdatTimeOut(updateTimeOut); - - return true; -} - -void datasid_conf(Agent* agent, Conf* conf) { - std::map<std::string, std::string> 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 { - 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 deleted file mode 100644 index 86fd337e..00000000 --- a/update/agent/src/linux/datasid-parse.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#include <regex> -#include "../../include/agent/linux/datasid-parse.h" - -/* - * trim Function - * Erases leading tabs, leading spaces; trailing tabs, trailing spaces. - */ - -void trim(std::string* str) { - int i = 0; - - while (i < static_cast<int>(str->length()) && ((*str)[i] == ' ' - || (*str)[i] == '\t')) - ++i; - - if (i > 0) - str->erase(0, i); - - int j = i = str->length(); - - while (i > 0 && ((*str)[i - 1] == ' ' || (*str)[i - 1] == '\t')) - --i; - - if (i < j) - str->erase(i, j); -} - -/* - * normalize Function - * Erases tabs and spaces between the variable's name and its value. - */ - -void normalize(std::string* str) { - size_t i, j; - i = j = 0; - - trim(str); - - while (i < str->length()) { - - if ((*str)[i] == ' ' || (*str)[i] == '\t') { - j = i + 1; - - while (j < str->length() && ((*str)[j] == ' ' || (*str)[j] == '\t')) - ++j; - - if (j == i) - str->erase(i, 1); - else - str->erase(i, j - i); - } else - ++i; - } -} - -/* - * spaceOnly Functio - * Check if a line consists only of spaces and tabs - */ - -bool spaceOnly(const std::string* line) { - for (int i = 0, j = line->length(); i < j; ++i) - if ((*line)[i] != ' ' && (*line)[i] != '\t') - return false; - return true; -} - -/* - * isValid Function - * Check if a line is valid - * The line is valide when has "key":"value"; - */ - -bool isValid(std::string* line) { - std::string e = *line; - int i = 0; - - normalize(line); - - /* if the line is a comment */ - - if (std::regex_match((*line), std::regex("((\\/\\/)|(\\/\\*)|(\\#))(.*)"))) - return false; - - /* if the line start with a different character than quote */ - - if (!std::regex_match((*line), std::regex("(\")(.*)"))) - return false; - - /* - * if the line start with quote, - * but is not a pattern : "key":"value" - */ - - if ((*line)[i] = '"') { - - int n = std::count((*line).begin(), (*line).end(), '"'); - - /* if the line doesn't has four quotes */ - if (n < 4) - return false; - - /* if the second character is quote. */ - - if ((*line)[i+1] == '"') - return false; - - n = line->find_last_of('"'); - - /* if the second to last character is quote. */ - - if ((*line)[n-1] == '"') - return false; - - n = line->find_last_of(':'); - - /* if the line doesn't has the colon character. */ - - if (n == -1) - return false; - - /* if the position of the colon character is string ends. */ - - if (n == (line->length())-1) - return false; - - } - - return true; -} - -/* - * parse Function - * After check if the line is valid, - * than parse the "key":"value" to a map. - */ - -void parse(std::string* line, std::map<std::string, std::string>* content) { - std::locale loc; - - /* if the line is a "key":"value" */ - - 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); - - std::string value = line->substr(line->find(':')+2); - value = value.substr(0, value.find('"')); - - (*content)[name] = value; - } -} - -/* - * readFile Function - * read a file (config or proxy file) - * Than check if the line is valid. - * Case is valid, parse the "key":"value" to a map. - * After all, get de value by key and "initialize" - * a conf or proxy object. - */ - -bool readFile(const std::string file, std::map<std::string, std::string>* content) { - content->clear(); - - std::ifstream config(file.c_str(), std::ifstream::in); - - if (!config.is_open()) - return false; - - std::string buffer; - - while (getline(config, buffer, '\n')) { - if (!spaceOnly(&buffer)) - if (isValid(&buffer)) - parse(&buffer, content); - } - - return true; -} diff --git a/update/agent/src/linux/datasid-proxy.cpp b/update/agent/src/linux/datasid-proxy.cpp deleted file mode 100644 index 1e78cf9f..00000000 --- a/update/agent/src/linux/datasid-proxy.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#include <iostream> -#include "../../include/agent/linux/datasid-proxy.h" - -/* - * set Functions - */ - -void Proxy::setHost(std::string h) { - this->host = h; -} - -void Proxy::setPort(std::string p) { - this->port = p; -} - -void Proxy::setUser(std::string u) { - this->user = u; -} - -void Proxy::setPassword(std::string p) { - this->password = p; -} - -/* - * get Functions - */ - -std::string Proxy::getHost() const { - return this->host; -} - -std::string Proxy::getPort() const { - return this->port; -} - -std::string Proxy::getUser() const { - return this->user; -} - -std::string Proxy::getPassword() const { - return this->password; -} - -/* - * setProxy Function - * If variables from proxy file setted, - * then set the proxy object - */ - -bool setProxy(Proxy* proxy, std::map<std::string, std::string>* content) { - if (content->count("PROXYHOST") == 0 || - content->count("PROXYPORT") == 0 || - content->count("PROXYUSER") == 0 || - content->count("PROXYPASSWORD") == 0) - return false; - - proxy->setHost((*content)["PROXYHOST"]); - proxy->setPort((*content)["PROXYPORT"]); - proxy->setUser((*content)["PROXYUSER"]); - proxy->setPassword((*content)["PROXYPASSWORD"]); - - return true; -} - -void datasid_proxy(Conf* conf, Proxy* proxy) { - std::map<std::string, std::string> 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 - std::cout << __DATE__ << " WARNING: proxy file not found." << std::endl; -} diff --git a/update/agent/src/main.cpp b/update/agent/src/main.cpp deleted file mode 100644 index b0ddb53f..00000000 --- a/update/agent/src/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of datasid - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#include "../include/agent/main.h" - -int main(){ - datasid_agent(); - return 0; -} \ No newline at end of file -- GitLab