diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-20 18:06:42 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-20 18:06:42 +0200 |
commit | 84f69d7aacef531c0ad809d7511c7ab7bce7469c (patch) | |
tree | 5e2aad8ec1c4d577d5bf15aa37560d3f14578d21 /src | |
parent | 89551ddfc2879530981eba3db9ab857b88409ad8 (diff) | |
download | mad-84f69d7aacef531c0ad809d7511c7ab7bce7469c.tar mad-84f69d7aacef531c0ad809d7511c7ab7bce7469c.zip |
/proc/meminfo ohne regul?re Ausdr?cke verarbeiten
Diffstat (limited to 'src')
-rw-r--r-- | src/Client/Makefile.in | 2 | ||||
-rw-r--r-- | src/Client/Requests/Makefile.in | 2 | ||||
-rw-r--r-- | src/Common/Backends/Makefile.in | 2 | ||||
-rw-r--r-- | src/Common/Backends/SystemBackendProc.cpp | 29 | ||||
-rw-r--r-- | src/Common/Makefile.in | 2 | ||||
-rw-r--r-- | src/Common/RequestHandlers/Makefile.in | 2 | ||||
-rw-r--r-- | src/Common/Requests/Makefile.in | 2 | ||||
-rw-r--r-- | src/Core/Makefile.in | 2 | ||||
-rw-r--r-- | src/Core/RequestHandlers/Makefile.in | 2 | ||||
-rw-r--r-- | src/Core/Requests/Makefile.in | 2 | ||||
-rw-r--r-- | src/Daemon/Makefile.in | 2 | ||||
-rw-r--r-- | src/Daemon/RequestHandlers/Makefile.in | 2 | ||||
-rw-r--r-- | src/Daemon/Requests/Makefile.in | 2 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/Makefile.in | 11 | ||||
-rw-r--r-- | src/Net/Makefile.in | 2 | ||||
-rw-r--r-- | src/Net/Packets/Makefile.in | 2 |
17 files changed, 20 insertions, 52 deletions
diff --git a/src/Client/Makefile.in b/src/Client/Makefile.in index 1005783..fffe601 100644 --- a/src/Client/Makefile.in +++ b/src/Client/Makefile.in @@ -131,8 +131,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Client/Requests/Makefile.in b/src/Client/Requests/Makefile.in index 49f8198..fef781d 100644 --- a/src/Client/Requests/Makefile.in +++ b/src/Client/Requests/Makefile.in @@ -122,8 +122,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Common/Backends/Makefile.in b/src/Common/Backends/Makefile.in index d943c5e..f8f56a7 100644 --- a/src/Common/Backends/Makefile.in +++ b/src/Common/Backends/Makefile.in @@ -122,8 +122,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Common/Backends/SystemBackendProc.cpp b/src/Common/Backends/SystemBackendProc.cpp index 51e14f8..e8c7357 100644 --- a/src/Common/Backends/SystemBackendProc.cpp +++ b/src/Common/Backends/SystemBackendProc.cpp @@ -19,8 +19,8 @@ #include "SystemBackendProc.h" -#include <pcrecpp.h> #include <cstdio> +#include <cstring> namespace Mad { namespace Common { @@ -58,26 +58,25 @@ SystemBackend::MemoryInfo SystemBackendProc::getMemoryInfo() { if(!meminfoFile.good()) return memInfo; - pcrecpp::RE re("(.+):\\s*(\\d+).*"); - while(!meminfoFile.eof() && meminfoFile.good()) { std::string line; std::getline(meminfoFile, line); - std::string name; + char *name = new char[line.length()+1]; // is always long enough unsigned long value; - if(!re.FullMatch(line, &name, &value)) - continue; - - if(name == "MemTotal") - memInfo.totalMem = value; - else if(name == "MemFree") - memInfo.freeMem = value; - else if(name == "SwapTotal") - memInfo.totalSwap = value; - else if(name == "SwapFree") - memInfo.freeSwap = value; + if(std::sscanf(line.c_str(), "%s %lu", name, &value) == 2) { + if(std::strcmp(name, "MemTotal:") == 0) + memInfo.totalMem = value; + else if(std::strcmp(name, "MemFree:") == 0) + memInfo.freeMem = value; + else if(std::strcmp(name, "SwapTotal:") == 0) + memInfo.totalSwap = value; + else if(std::strcmp(name, "SwapFree:") == 0) + memInfo.freeSwap = value; + } + + delete [] name; if(memInfo.totalMem && memInfo.freeMem && memInfo.totalSwap && memInfo.freeSwap) break; diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in index 06e237f..02b537b 100644 --- a/src/Common/Makefile.in +++ b/src/Common/Makefile.in @@ -133,8 +133,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Common/RequestHandlers/Makefile.in b/src/Common/RequestHandlers/Makefile.in index 905ea56..cca1c8e 100644 --- a/src/Common/RequestHandlers/Makefile.in +++ b/src/Common/RequestHandlers/Makefile.in @@ -122,8 +122,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Common/Requests/Makefile.in b/src/Common/Requests/Makefile.in index 6d7b433..194a294 100644 --- a/src/Common/Requests/Makefile.in +++ b/src/Common/Requests/Makefile.in @@ -121,8 +121,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Core/Makefile.in b/src/Core/Makefile.in index bd255ba..e65b77f 100644 --- a/src/Core/Makefile.in +++ b/src/Core/Makefile.in @@ -132,8 +132,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Core/RequestHandlers/Makefile.in b/src/Core/RequestHandlers/Makefile.in index 8bdbda5..4c5679e 100644 --- a/src/Core/RequestHandlers/Makefile.in +++ b/src/Core/RequestHandlers/Makefile.in @@ -123,8 +123,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Core/Requests/Makefile.in b/src/Core/Requests/Makefile.in index 5624f06..b5e5438 100644 --- a/src/Core/Requests/Makefile.in +++ b/src/Core/Requests/Makefile.in @@ -121,8 +121,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Daemon/Makefile.in b/src/Daemon/Makefile.in index df55b09..02bd3f5 100644 --- a/src/Daemon/Makefile.in +++ b/src/Daemon/Makefile.in @@ -130,8 +130,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Daemon/RequestHandlers/Makefile.in b/src/Daemon/RequestHandlers/Makefile.in index b393cf1..7f55925 100644 --- a/src/Daemon/RequestHandlers/Makefile.in +++ b/src/Daemon/RequestHandlers/Makefile.in @@ -117,8 +117,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Daemon/Requests/Makefile.in b/src/Daemon/Requests/Makefile.in index bdfcab1..1742a3a 100644 --- a/src/Daemon/Requests/Makefile.in +++ b/src/Daemon/Requests/Makefile.in @@ -121,8 +121,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Makefile.am b/src/Makefile.am index d2822a3..7860ab7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,10 +3,10 @@ SUBDIRS = Common Client Core Daemon Net bin_PROGRAMS = mad madc mad-core mad_SOURCES = mad.cpp -mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) +mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) madc_SOURCES = madc.cpp madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS) mad_core_SOURCES = mad-core.cpp -mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) $(GSSAPI_LIBS) +mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(GSSAPI_LIBS) diff --git a/src/Makefile.in b/src/Makefile.in index 992e747..5356c80 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -50,13 +50,12 @@ am_mad_OBJECTS = mad.$(OBJEXT) mad_OBJECTS = $(am_mad_OBJECTS) am__DEPENDENCIES_1 = mad_DEPENDENCIES = Daemon/libdaemon.la Common/libcommon.la \ - Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) + Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_mad_core_OBJECTS = mad-core.$(OBJEXT) mad_core_OBJECTS = $(am_mad_core_OBJECTS) mad_core_DEPENDENCIES = Core/libcore.la Common/libcommon.la \ Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) am_madc_OBJECTS = madc.$(OBJEXT) madc_OBJECTS = $(am_madc_OBJECTS) madc_DEPENDENCIES = Client/libclient.la Common/libcommon.la \ @@ -145,8 +144,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ @@ -211,11 +208,11 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = Common Client Core Daemon Net mad_SOURCES = mad.cpp -mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) +mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) madc_SOURCES = madc.cpp madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS) mad_core_SOURCES = mad-core.cpp -mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) $(GSSAPI_LIBS) +mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(GSSAPI_LIBS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive diff --git a/src/Net/Makefile.in b/src/Net/Makefile.in index 3cf8ff9..2f0149e 100644 --- a/src/Net/Makefile.in +++ b/src/Net/Makefile.in @@ -132,8 +132,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Net/Packets/Makefile.in b/src/Net/Packets/Makefile.in index 8344b8e..3e73a99 100644 --- a/src/Net/Packets/Makefile.in +++ b/src/Net/Packets/Makefile.in @@ -122,8 +122,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ |