From 76e22972cf64eac4a3640833181a445e4cb3f050 Mon Sep 17 00:00:00 2001 From: darode Date: Tue, 13 Jul 2010 17:24:00 +0000 Subject: [PATCH] 2010-07-13 Dario Rodriguez * pandora_agent_conf.cc: Added support to parse collections * pandora_agent_conf.h: Added support to parse collections git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3002 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/win32/ChangeLog | 5 +++++ pandora_agents/win32/pandora_agent_conf.cc | 22 ++++++++++++++++++++++ pandora_agents/win32/pandora_agent_conf.h | 1 + 3 files changed, 28 insertions(+) diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index 94a73c827b..09d621eea0 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,8 @@ +2010-07-13 Dario Rodriguez + + * pandora_agent_conf.cc: Added support to parse collections + * pandora_agent_conf.h: Added support to parse collections + 2010-07-12 Ramon Novoa * modules/pandora_module.h, modules/pandora_module_factory.cc, diff --git a/pandora_agents/win32/pandora_agent_conf.cc b/pandora_agents/win32/pandora_agent_conf.cc index bef09e8eda..f3694202c6 100644 --- a/pandora_agents/win32/pandora_agent_conf.cc +++ b/pandora_agents/win32/pandora_agent_conf.cc @@ -20,15 +20,19 @@ #include #include "pandora_agent_conf.h" +#include "pandora_strutils.h" +#include #include "pandora.h" using namespace std; using namespace Pandora; +using namespace Pandora_Strutils; #define MAX_KEYS 100 Pandora::Pandora_Agent_Conf::Pandora_Agent_Conf () { this->key_values = NULL; + this->collection_list = NULL; } /** @@ -36,6 +40,7 @@ Pandora::Pandora_Agent_Conf::Pandora_Agent_Conf () { */ Pandora::Pandora_Agent_Conf::~Pandora_Agent_Conf () { delete key_values; + delete collection_list; } Pandora_Agent_Conf * @@ -68,6 +73,10 @@ Pandora::Pandora_Agent_Conf::setFile (string filename) { if (this->key_values) delete this->key_values; this->key_values = new list (); + + if (this->collection_list) + delete this->collection_list; + this->collection_list = new list (); if (!file.is_open ()) { return; @@ -80,6 +89,19 @@ Pandora::Pandora_Agent_Conf::setFile (string filename) { /* Ignore blank or commented lines */ if (buffer[0] != '#' && buffer[0] != '\n' && buffer[0] != '\0') { + /*Check if is a collection*/ + pos = buffer.find("file_collection"); + if(pos != string::npos) { + string collection_name, trimmed_str; + + /*Add collection to collection_list*/ + /*The number 15 is the number of character of string file_collection*/ + collection_name = buffer.substr(pos+15); + trimmed_str = trim (collection_name); + collection_list->push_back (trimmed_str); + continue; + } + /*Check if is a module*/ pos = buffer.find ("module_"); if (pos == string::npos) { Key_Value kv; diff --git a/pandora_agents/win32/pandora_agent_conf.h b/pandora_agents/win32/pandora_agent_conf.h index 3bff0d1080..165dcaaf32 100644 --- a/pandora_agents/win32/pandora_agent_conf.h +++ b/pandora_agents/win32/pandora_agent_conf.h @@ -38,6 +38,7 @@ namespace Pandora { class Pandora_Agent_Conf { private: list *key_values; + list *collection_list; Pandora_Agent_Conf (); public: