From c65547879e4e894f65efcc720ae46739d4407644 Mon Sep 17 00:00:00 2001 From: darode Date: Fri, 16 Sep 2011 12:35:18 +0000 Subject: [PATCH] 2011-09-16 Dario Rodriguez * win32/pandora_agent_conf.cc: Fixed a problem generating broker conf files with wrong agent names. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4966 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/ChangeLog | 5 +++++ pandora_agents/win32/pandora_agent_conf.cc | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index 58fcc1f6a8..e58777fad2 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,8 @@ +2011-09-16 Dario Rodriguez + + * win32/pandora_agent_conf.cc: Fixed a problem generating broker conf + files with wrong agent names. + 2011-09-15 Vanessa Gil * win32/pandora_windows_service.cc: Fixed problem sending xml file. diff --git a/pandora_agents/win32/pandora_agent_conf.cc b/pandora_agents/win32/pandora_agent_conf.cc index f09b4e01bf..d0a76da4e0 100644 --- a/pandora_agents/win32/pandora_agent_conf.cc +++ b/pandora_agents/win32/pandora_agent_conf.cc @@ -113,7 +113,9 @@ writeBrokerConf(string path_broker, string filename, string name_broker){ string buffer; string comp; unsigned int pos; - + int i; + int ok; + /* Read and set the file */ while (!file_conf.eof ()) { /* Set the value from each line */ @@ -121,11 +123,19 @@ writeBrokerConf(string path_broker, string filename, string name_broker){ pos = buffer.find("agent_name"); if (pos != string::npos){ - comp = buffer.substr (0,12); - if (comp == "# agent_name"){ + ok = 1; + + for(i=0; i < pos; i++) { + + if(buffer[i] != ' ' && buffer[i] != '\t' && buffer[i] != '#') { + ok = 0; + } + } + + if (ok) { buffer = "agent_name "+name_broker+"\n"; - } - } + } + } pos = buffer.find("broker_agent"); if (pos != string::npos){