2006-11-24 Esteban Sánchez <estebans@artica.es>
* pandora_strutils.h, pandora_strutils.cc: Added strtoulong() to convert a string into a unsigned long integer. * wmi/pandora_wmi.h, pandora_wmi.cc: Modified getDisgkFreeSpace() to return a unsigned long integer. Used srttoulong() to transform the free disk into a log instead of an integer, that caused a negative value of free disk space when the amount was in the order of GB. * bin/PandoraAgent.exe: Updated to new commit. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@281 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8f694746a0
commit
12ddf6dc7d
|
@ -1,3 +1,15 @@
|
|||
2006-11-24 Esteban Sánchez <estebans@artica.es>
|
||||
|
||||
* pandora_strutils.h, pandora_strutils.cc: Added strtoulong() to
|
||||
convert a string into a unsigned long integer.
|
||||
|
||||
* wmi/pandora_wmi.h, pandora_wmi.cc: Modified getDisgkFreeSpace() to
|
||||
return a unsigned long integer. Used srttoulong() to transform the
|
||||
free disk into a log instead of an integer, that caused a negative
|
||||
value of free disk space when the amount was in the order of GB.
|
||||
|
||||
* bin/PandoraAgent.exe: Updated to new commit.
|
||||
|
||||
2006-11-21 Esteban Sánchez <estebans@artica.es>
|
||||
|
||||
* pandora_windows_service.cc: Changed the debug option of the
|
||||
|
|
Binary file not shown.
|
@ -119,6 +119,28 @@ Pandora_Strutils::strtoint (const string str) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
unsigned long
|
||||
Pandora_Strutils::strtoulong (const string str) {
|
||||
unsigned long result;
|
||||
|
||||
if (! std::sscanf (str.c_str (), "%uld", &result)) {
|
||||
throw Invalid_Conversion ();
|
||||
}
|
||||
printf ("%s - %u\n", str.c_str (), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace every occurence of a pattern in a string with other substring.
|
||||
*
|
||||
|
|
|
@ -41,15 +41,16 @@ namespace Pandora_Strutils {
|
|||
*/
|
||||
class Invalid_Conversion : Pandora_Strutils::String_Exception {};
|
||||
|
||||
string trim (const string str);
|
||||
string trim (const string str);
|
||||
|
||||
string inttostr (const int i);
|
||||
string longtostr (const long i);
|
||||
string longtohex (const long i);
|
||||
string inttostr (const int i);
|
||||
string longtostr (const long i);
|
||||
string longtohex (const long i);
|
||||
|
||||
int strtoint (const string str);
|
||||
int strtoint (const string str);
|
||||
unsigned long strtoulong (const string str);
|
||||
|
||||
string strreplace (string in, string pattern, string rep);
|
||||
string strreplace (string in, string pattern, string rep);
|
||||
|
||||
void
|
||||
stringtok (list<string> &l, string const &s,
|
||||
|
|
|
@ -153,12 +153,12 @@ Pandora_Wmi::isServiceRunning (string service_name) {
|
|||
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading
|
||||
* from WMI database.
|
||||
*/
|
||||
long
|
||||
unsigned long
|
||||
Pandora_Wmi::getDiskFreeSpace (string disk_id) {
|
||||
CDhInitialize init;
|
||||
CDispPtr wmi_svc, quickfixes;
|
||||
string id, space_str;
|
||||
int space;
|
||||
unsigned long space;
|
||||
|
||||
struct QFix {
|
||||
CDhStringA id, free_space;
|
||||
|
@ -185,7 +185,7 @@ Pandora_Wmi::getDiskFreeSpace (string disk_id) {
|
|||
space_str = fix.free_space;
|
||||
|
||||
try {
|
||||
space = Pandora_Strutils::strtoint (space_str);
|
||||
space = Pandora_Strutils::strtoulong (space_str);
|
||||
} catch (Pandora_Exception e) {
|
||||
throw Pandora_Wmi_Exception ();
|
||||
}
|
||||
|
|
|
@ -38,15 +38,15 @@ namespace Pandora_Wmi {
|
|||
*/
|
||||
class Pandora_Wmi_Exception : public Pandora_Exception { };
|
||||
|
||||
int isProcessRunning (string process_name);
|
||||
int isServiceRunning (string service_name);
|
||||
long getDiskFreeSpace (string disk_id);
|
||||
int getCpuUsagePercentage (int cpu_id);
|
||||
long getFreememory ();
|
||||
string getOSName ();
|
||||
string getOSVersion ();
|
||||
string getOSBuild ();
|
||||
string getSystemName ();
|
||||
int isProcessRunning (string process_name);
|
||||
int isServiceRunning (string service_name);
|
||||
unsigned long getDiskFreeSpace (string disk_id);
|
||||
int getCpuUsagePercentage (int cpu_id);
|
||||
long getFreememory ();
|
||||
string getOSName ();
|
||||
string getOSVersion ();
|
||||
string getOSBuild ();
|
||||
string getSystemName ();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue