2006-06-20 19:05:19 +02:00
|
|
|
/* Misc utils for strings.
|
2020-11-27 13:52:35 +01:00
|
|
|
Copyright (c) 2006-2021 Artica ST.
|
2006-06-20 19:05:19 +02:00
|
|
|
Written by Esteban Sanchez.
|
|
|
|
|
|
|
|
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pandora.h"
|
|
|
|
#include "pandora_strutils.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <cstring> // for strchr
|
|
|
|
|
|
|
|
using namespace Pandora;
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Removes heading and tailing blank spaces from a string.
|
|
|
|
*
|
|
|
|
* The blank spaces removed are " ", "\t", "\r" and "\n".
|
|
|
|
*
|
|
|
|
* @param str String to be trimmed.
|
|
|
|
*
|
|
|
|
* @return The trimmed string.
|
|
|
|
*/
|
2006-06-20 19:05:19 +02:00
|
|
|
string
|
|
|
|
Pandora_Strutils::trim (const string str) {
|
2009-09-22 Ramon Novoa <rnovoa@artica.es>
* debug_new.h, fast_mutex.h,
debug_new.cpp, static_assert.h: Added to repository. Wu Yongwei's
memory leak detection tool (part of Nvwa). Only compiled when
debugging is enabled.
* bin/util/tentacle_client.exe: Added to repository. Tentacle client
needed to build the installer.
* installer/pandora_2.0.mpi: moved to installer/pandora.mpi. Updated.
The installer can now be built directly from the installer
subdirectory.
* configure.in, Makefile.am, autogen.sh: Created a proper
configure.in and Makefile.am. The agent can now be cross-compiled
from Linux :-D
* bin/pandora_agent.conf: Fixed. A local configuration had been
uploaded.
* pandora_windows_service.h,pandora_windows_service.cc,
udp_server/udp_server.cc, udp_server/udp_server.h: Properly shutdown
the UDP server.
* modules/pandora_module_regexp.cc,
modules/pandora_module_inventory.cc,
modules/pandora_module_factory.cc,
modules/pandora_module.cc, pandora_strutils.cc,
pandora.h, pandora.cc: Fixed a couple of memory leaks. Small changes
to avoid compile warnings when cross-compiling from Linux.
* windows_service.cc: Removed the interactive service flag to avoid
'black windows'.
* main.cc: Include the memory leak detection tool if debugging is
enabled.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1966 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-22 13:48:25 +02:00
|
|
|
const char * delims = " \t\r\n";
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
string result = str;
|
|
|
|
string::size_type index = result.find_last_not_of (delims);
|
|
|
|
|
|
|
|
if (index != string::npos) {
|
|
|
|
result.erase (++index);
|
|
|
|
}
|
|
|
|
|
|
|
|
index = result.find_first_not_of (delims);
|
|
|
|
if (index != std::string::npos) {
|
|
|
|
result.erase (0, index);
|
|
|
|
} else {
|
|
|
|
result.erase ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2006-06-20 19:05:19 +02:00
|
|
|
}
|
|
|
|
|
2008-07-09 14:46:22 +02:00
|
|
|
/**
|
|
|
|
* Convert an unicode string to a ANSI string.
|
|
|
|
*
|
|
|
|
* @param s String to convert
|
|
|
|
*
|
|
|
|
* @return String converted into ANSI code
|
|
|
|
*/
|
2013-06-20 10:37:35 +02:00
|
|
|
string
|
2008-07-09 14:46:22 +02:00
|
|
|
Pandora_Strutils::strUnicodeToAnsi (LPCWSTR s) {
|
2013-06-20 10:37:35 +02:00
|
|
|
string output;
|
|
|
|
|
2008-07-09 14:46:22 +02:00
|
|
|
if (s == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int cw = lstrlenW (s);
|
|
|
|
if (cw == 0) {
|
2013-06-20 10:37:35 +02:00
|
|
|
return output;
|
2008-07-09 14:46:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int cc = WideCharToMultiByte (CP_ACP,0, s, cw, NULL, 0, NULL, NULL);
|
2013-06-20 10:37:35 +02:00
|
|
|
if (cc==0) {
|
|
|
|
return output;
|
|
|
|
}
|
2008-07-09 14:46:22 +02:00
|
|
|
|
|
|
|
CHAR *psz = new CHAR[cc+1];
|
|
|
|
cc = WideCharToMultiByte (CP_ACP, 0, s, cw, psz, cc, NULL, NULL);
|
|
|
|
if (cc == 0) {
|
|
|
|
delete[] psz;
|
2013-06-20 10:37:35 +02:00
|
|
|
return output;
|
2008-07-09 14:46:22 +02:00
|
|
|
}
|
|
|
|
psz[cc]='\0';
|
2013-06-20 10:37:35 +02:00
|
|
|
output = psz;
|
|
|
|
delete[] psz;
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert an ANSI string to a unicode string. Do not forget to
|
|
|
|
* delete the returned string!
|
|
|
|
*
|
|
|
|
* @param s String to convert
|
|
|
|
*
|
|
|
|
* @return String converted to Unicode
|
|
|
|
*/
|
|
|
|
wstring
|
|
|
|
Pandora_Strutils::strAnsiToUnicode (LPCSTR s) {
|
|
|
|
LPWSTR output;
|
|
|
|
wstring w_output;
|
|
|
|
|
|
|
|
int lenW = MultiByteToWideChar(CP_ACP, 0, s, -1, NULL, 0);
|
|
|
|
if (lenW <= 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
output = new wchar_t[lenW];
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, s, -1, output, lenW);
|
|
|
|
|
|
|
|
w_output = output;
|
|
|
|
delete[] output;
|
2008-07-09 14:46:22 +02:00
|
|
|
|
2013-06-20 10:37:35 +02:00
|
|
|
return w_output;
|
2008-07-09 14:46:22 +02:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Transform an integer variable into a string.
|
|
|
|
*
|
|
|
|
* @param i Integer to transform.
|
|
|
|
*
|
|
|
|
* @return A string with the integer value.
|
|
|
|
*/
|
2006-06-20 19:05:19 +02:00
|
|
|
string
|
|
|
|
Pandora_Strutils::inttostr (const int i) {
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
return longtostr (i);
|
2006-07-11 11:41:22 +02:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Transform a long variable into a string.
|
|
|
|
*
|
|
|
|
* @param i Long variable to transform
|
|
|
|
*
|
|
|
|
* @return A string with the long value.
|
|
|
|
*/
|
2006-07-11 11:41:22 +02:00
|
|
|
string
|
|
|
|
Pandora_Strutils::longtostr (const long i) {
|
|
|
|
std::ostringstream o;
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
|
|
|
|
o << i;
|
|
|
|
|
|
|
|
return o.str();
|
2006-06-20 19:05:19 +02:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Transform a long variable into hexadecimal.
|
|
|
|
*
|
|
|
|
* @param i Long variable to transform.
|
|
|
|
*
|
|
|
|
* @return The hexadecimal value of the long variable.
|
|
|
|
*/
|
2006-06-20 19:05:19 +02:00
|
|
|
string
|
|
|
|
Pandora_Strutils::longtohex (const long i) {
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
std::ostringstream o;
|
|
|
|
o << std::hex << i;
|
|
|
|
|
|
|
|
return o.str();
|
2006-06-20 19:05:19 +02:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Tranform a string into a integer.
|
|
|
|
*
|
|
|
|
* @param str String to convert.
|
|
|
|
*
|
|
|
|
* @return The integer value of the string.
|
|
|
|
*
|
|
|
|
* @exception Invalid_Conversion throwed if the string has non-
|
|
|
|
* decimal values.
|
|
|
|
*/
|
2006-06-20 19:05:19 +02:00
|
|
|
int
|
|
|
|
Pandora_Strutils::strtoint (const string str) {
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
int result;
|
|
|
|
|
|
|
|
if (! std::sscanf (str.c_str (), "%d", &result)) {
|
|
|
|
throw Invalid_Conversion ();
|
|
|
|
}
|
|
|
|
return result;
|
2006-06-20 19:05:19 +02:00
|
|
|
}
|
|
|
|
|
2008-06-11 12:10:48 +02:00
|
|
|
/**
|
|
|
|
* Returns the double precision floating-point value of a given string.
|
|
|
|
*
|
|
|
|
* @param str The string.
|
|
|
|
*
|
|
|
|
* @return The double precision floating-point value of the string.
|
|
|
|
*
|
|
|
|
* @exception Invalid_Conversion thrown on error.
|
|
|
|
*/
|
|
|
|
double
|
|
|
|
Pandora_Strutils::strtodouble (const string str) {
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
double result;
|
|
|
|
|
|
|
|
if (! std::sscanf (str.c_str (), "%le", &result)) {
|
|
|
|
throw Invalid_Conversion ();
|
|
|
|
}
|
|
|
|
return result;
|
2008-06-11 12:10:48 +02:00
|
|
|
}
|
|
|
|
|
2006-11-24 12:46:31 +01:00
|
|
|
/**
|
|
|
|
* Tranform a string into a long integer.
|
|
|
|
*
|
|
|
|
* @param str String to convert.
|
|
|
|
*
|
|
|
|
* @return The long integer value of the string.
|
|
|
|
*
|
|
|
|
* @exception Invalid_Conversion throwed if the string has non-
|
|
|
|
* decimal values.
|
|
|
|
*/
|
2006-11-27 12:59:52 +01:00
|
|
|
unsigned long long
|
2006-11-24 12:46:31 +01:00
|
|
|
Pandora_Strutils::strtoulong (const string str) {
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
unsigned long long result;
|
2006-11-24 12:46:31 +01:00
|
|
|
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
if (! std::sscanf (str.c_str (), "%I64d", &result)) {
|
|
|
|
throw Invalid_Conversion ();
|
|
|
|
}
|
2006-11-24 12:46:31 +01:00
|
|
|
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
return result;
|
2006-11-24 12:46:31 +01:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Replace every occurence of a pattern in a string with other substring.
|
|
|
|
*
|
|
|
|
* @param in Objective string.
|
|
|
|
* @param pattern Pattern to be replaced.
|
|
|
|
* @param rep Substring that replace every occurence of the pattern.
|
|
|
|
*
|
|
|
|
* @return The input string with all pattern occurence replaced.
|
|
|
|
*/
|
2006-06-20 19:05:19 +02:00
|
|
|
string
|
|
|
|
Pandora_Strutils::strreplace (string in, string pattern, string rep) {
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
int i = in.find (pattern);
|
|
|
|
int j;
|
|
|
|
|
|
|
|
if (i < 0) {
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
int plen = pattern.length ();
|
|
|
|
int rlen = rep.length ();
|
|
|
|
|
|
|
|
do {
|
|
|
|
in.replace(i, plen, rep);
|
|
|
|
i += rlen;
|
|
|
|
string rest = in.substr (i, in.length () - i);
|
|
|
|
j = rest.find (pattern);
|
|
|
|
i += j;
|
|
|
|
} while (j >= 0);
|
|
|
|
|
|
|
|
return in;
|
2006-06-20 19:05:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
isseparator (char c, char const * const wstr) {
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
return (strchr (wstr, c) != NULL);
|
2006-06-20 19:05:19 +02:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Split a string into diferent tokens, divided by one or many
|
|
|
|
* field separators.
|
|
|
|
*
|
|
|
|
* @param l Returned string list with every tokens. Must be initialized
|
|
|
|
* before calling the function.
|
|
|
|
* @param s Input string.
|
|
|
|
* @param separators Field separators string. I.e. " \t" will separate
|
|
|
|
* with every " " and "\t". Can be ommited and will be " \t\n".
|
|
|
|
*/
|
2006-06-20 19:05:19 +02:00
|
|
|
void
|
|
|
|
Pandora_Strutils::stringtok (list<string> &l, string const &s,
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
char const * const separators) {
|
2006-06-20 19:05:19 +02:00
|
|
|
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
const string::size_type strsize = s.size();
|
|
|
|
string::size_type i = 0;
|
|
|
|
|
|
|
|
while (i < strsize) {
|
|
|
|
/* eat leading whitespace */
|
|
|
|
while ((i < strsize) && (isseparator (s[i], separators))) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (i == strsize) {
|
|
|
|
return; /* nothing left but WS */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find end of word */
|
|
|
|
string::size_type j = i + 1;
|
|
|
|
while ((j < strsize) && (!isseparator (s[j], separators))) {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add word */
|
|
|
|
l.push_back (s.substr (i, j - i));
|
|
|
|
|
|
|
|
/* set up for next loop */
|
|
|
|
i = j + 1;
|
|
|
|
}
|
2006-06-20 19:05:19 +02:00
|
|
|
}
|