Module: check_mk
Branch: master
Commit: 4ce27781846d3af69629cfc0138d7930b1622461
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4ce27781846d3a…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Mar 23 16:11:52 2018 +0100
Win-agent: use strongly typed enums, part 3
Convert file_encoding in SectionLogwatch.*.
---
agents/windows/build_version | 2 +-
agents/windows/sections/SectionLogwatch.cc | 16 ++++++++--------
agents/windows/sections/SectionLogwatch.h | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 7127a37..3771b21 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-3204
+3206
diff --git a/agents/windows/sections/SectionLogwatch.cc
b/agents/windows/sections/SectionLogwatch.cc
index f9cd456..9d44b5f 100644
--- a/agents/windows/sections/SectionLogwatch.cc
+++ b/agents/windows/sections/SectionLogwatch.cc
@@ -67,7 +67,7 @@ file_encoding determine_encoding(const logwatch_textfile &textfile)
{
ifstream ifs(textfile.paths.front(), ifstream::in | ifstream::binary);
if (ifs.fail()) {
- return UNDEF;
+ return file_encoding::UNDEF;
}
std::array<char, 2> bytes;
@@ -75,24 +75,24 @@ file_encoding determine_encoding(const logwatch_textfile
&textfile) {
if (ifs.read(bytes.data(), bytes.size()) &&
static_cast<unsigned char>(bytes[0]) == 0xFF &&
static_cast<unsigned char>(bytes[1]) == 0xFE) {
- return UNICODE;
+ return file_encoding::UNICODE;
} else {
- return DEFAULT;
+ return file_encoding::DEFAULT;
}
}
ifstream open_logfile(logwatch_textfile &textfile) {
ifstream result;
- if ((textfile.encoding == UNDEF) || (textfile.offset == 0)) {
+ if ((textfile.encoding == file_encoding::UNDEF) || (textfile.offset == 0)) {
textfile.encoding = determine_encoding(textfile);
}
- if (textfile.encoding == UNDEF) {
+ if (textfile.encoding == file_encoding::UNDEF) {
result.setstate(std::ios_base::badbit);
} else {
auto mode = ifstream::in;
- if (textfile.encoding == UNICODE) {
+ if (textfile.encoding == file_encoding::UNICODE) {
mode |= ifstream::binary;
}
result.open(textfile.paths.front(), mode);
@@ -103,7 +103,7 @@ ifstream open_logfile(logwatch_textfile &textfile) {
uint64_t logfile_offset(const logwatch_textfile &textfile) {
uint64_t offset = textfile.offset;
- if ((offset == 0) && (textfile.encoding == UNICODE)) {
+ if ((offset == 0) && (textfile.encoding == file_encoding::UNICODE)) {
offset = 2;
}
return offset;
@@ -425,7 +425,7 @@ SectionLogwatch::ProcessTextfileResponse
SectionLogwatch::processTextfile(
// Necessary as reading UTF-16 file sets some fail bit(s) at the end.
file.clear();
file.seekg(logfile_offset(textfile));
- if (textfile.encoding == UNICODE)
+ if (textfile.encoding == file_encoding::UNICODE)
return processTextfileUnicode(file, textfile, out, write_output);
else
return processTextfileDefault(file, textfile, out, write_output);
diff --git a/agents/windows/sections/SectionLogwatch.h
b/agents/windows/sections/SectionLogwatch.h
index d6e7d91..bf63762 100644
--- a/agents/windows/sections/SectionLogwatch.h
+++ b/agents/windows/sections/SectionLogwatch.h
@@ -31,7 +31,7 @@
typedef struct _BY_HANDLE_FILE_INFORMATION BY_HANDLE_FILE_INFORMATION;
-enum file_encoding {
+enum class file_encoding {
UNDEF,
DEFAULT,
UNICODE,
@@ -81,7 +81,7 @@ struct logwatch_textfile {
bool missing{false}; // file no longer exists
bool nocontext; // do not report ignored lines
bool rotated; // assume the logfile is a rotating log
- file_encoding encoding{UNDEF};
+ file_encoding encoding{file_encoding::UNDEF};
std::reference_wrapper<const condition_patterns_t>
patterns; // glob patterns applying for this file
};