Module: check_mk
Branch: master
Commit: 6503810d95eddff68cd9c7faabe8d64c15c5cc02
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6503810d95eddf…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Tue Feb 13 12:05:06 2018 +0100
Windows agent: remove unused code in stringutil.*
---
agents/windows/build_version | 2 +-
agents/windows/sections/SectionMRPE.cc | 8 ++--
agents/windows/stringutil.cc | 86 ----------------------------------
agents/windows/stringutil.h | 10 ----
4 files changed, 5 insertions(+), 101 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 4fb7d0e..d9d811c 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-3098
+3100
diff --git a/agents/windows/sections/SectionMRPE.cc
b/agents/windows/sections/SectionMRPE.cc
index e528eb9..d6d756a 100644
--- a/agents/windows/sections/SectionMRPE.cc
+++ b/agents/windows/sections/SectionMRPE.cc
@@ -115,10 +115,10 @@ bool SectionMRPE::produceOutputInner(std::ostream &out) {
}
command.readStdout(pos, buffer.size() - (pos - buf_start), false);
- char *output_end = rstrip(&buffer[0]);
- char *plugin_output = lstrip(&buffer[0]);
+ rtrim(buffer);
+ ltrim(buffer);
// replace newlines
- std::transform(plugin_output, output_end, plugin_output,
+ std::transform(buffer.cbegin(), buffer.cend(), buffer.begin(),
[](char ch) {
if (ch == '\n') return '\1';
if (ch == '\r')
@@ -127,7 +127,7 @@ bool SectionMRPE::produceOutputInner(std::ostream &out) {
return ch;
});
int nagios_code = command.exitCode();
- out << nagios_code << " " << plugin_output
<< "\n";
+ out << nagios_code << " " << buffer <<
"\n";
Debug(_logger) << "Script finished";
} catch (const std::exception &e) {
Error(_logger) << "mrpe failed: " << e.what();
diff --git a/agents/windows/stringutil.cc b/agents/windows/stringutil.cc
index 3b06e5e..85d76af 100644
--- a/agents/windows/stringutil.cc
+++ b/agents/windows/stringutil.cc
@@ -12,73 +12,6 @@
using std::string;
using std::wstring;
-char *lstrip(char *s) {
- while (isspace(*s)) s++;
- return s;
-}
-
-const char *lstrip(const char *s) {
- while (isspace(*s)) s++;
- return s;
-}
-
-char *rstrip(char *s) {
- char *end = s + strlen(s); // point one beyond last character
- while (end > s && isspace(*(end - 1))) {
- end--;
- }
- *end = 0;
- return end;
-}
-
-char *strip(char *s) {
- rstrip(s);
- return lstrip(s);
-}
-
-std::vector<const char *> split_line(char *pos, int (*split_pred)(int)) {
- std::vector<const char *> result;
-
- char *current_word = pos;
- while (*pos != '\0') {
- if (split_pred(*pos)) {
- *pos = '\0';
- const char *trimmed = strip(current_word);
- if (*trimmed != '\0') {
- result.push_back(trimmed);
- }
- current_word = pos + 1;
- }
- ++pos;
- }
- const char *trimmed = strip(current_word);
- if (*trimmed != '\0') {
- result.push_back(trimmed);
- }
- return result;
-}
-
-char *next_word(char **line) {
- if (*line == 0) // allow subsequent calls without checking
- return 0;
-
- char *end = *line + strlen(*line);
- char *value = *line;
- while (value < end) {
- value = lstrip(value);
- char *s = value;
- while (*s && !isspace(*s)) s++;
- *s = 0;
- *line = s + 1;
- rstrip(value);
- if (strlen(value) > 0)
- return value;
- else
- return 0;
- }
- return 0;
-}
-
template <>
std::regex possiblyQuotedRegex<char>() {
return std::regex{"(\"([^\"]+)\"|'([^']+)'|[^\"
\\t]+)"};
@@ -89,25 +22,6 @@ std::wregex possiblyQuotedRegex<wchar_t>() {
return
std::wregex{L"(\"([^\"]+)\"|'([^']+)'|[^\"
\\t]+)"};
}
-unsigned long long string_to_llu(const char *s) {
- unsigned long long value = 0;
- unsigned long long mult = 1;
- const char *e = s + strlen(s);
- while (e > s) {
- --e;
- value += mult * (*e - '0');
- mult *= 10;
- }
- return value;
-}
-
-void lowercase(char *s) {
- while (*s) {
- *s = tolower(*s);
- s++;
- }
-}
-
int parse_boolean(const char *value) {
if (!strcmp(value, "yes"))
return 1;
diff --git a/agents/windows/stringutil.h b/agents/windows/stringutil.h
index 15901db..77e4cd3 100644
--- a/agents/windows/stringutil.h
+++ b/agents/windows/stringutil.h
@@ -41,11 +41,6 @@ using std::sregex_token_iterator;
class WinApiAdaptor;
-char *lstrip(char *s);
-const char *lstrip(const char *s);
-char *rstrip(char *s);
-char *strip(char *s);
-
inline void ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.cbegin(), s.cend(),
[](int ch) { return !std::isspace(ch); }));
@@ -58,9 +53,6 @@ inline void rtrim(std::string &s) {
s.end());
}
-std::vector<const char *> split_line(char *pos, int (*split_pred)(int));
-char *next_word(char **line);
-
template <typename CharT>
inline std::vector<std::basic_string<CharT>> tokenizeBase(
const std::basic_string<CharT> &input, const std::basic_regex<CharT>
&re,
@@ -126,8 +118,6 @@ inline std::vector<std::basic_string<CharT>>
tokenizePossiblyQuoted(
unsigned long long string_to_llu(const char *s);
-void lowercase(char *s);
-
int parse_boolean(const char *value);
inline std::string to_utf8(const std::wstring &input) {