Module: check_mk
Branch: master
Commit: 20fb7c75464df1a1d7241eda4af0ea9ee9acf859
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=20fb7c75464df1…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Mon Oct 9 16:33:52 2017 +0200
Fix wmitest to use refactored WinApi
wmitest was broken through the refactoring done in
d0e60a30a20ed75349ea192a6200fc0c7501dc1a.
Change-Id: Id97205ff5ae13aa8f3889571d59ea0cc83909646
---
agents/windows/CONTENTS | 1 +
agents/windows/Makefile | 4 ++--
agents/windows/wmitest.cc | 11 ++++++++---
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/agents/windows/CONTENTS b/agents/windows/CONTENTS
index 3326f14..2fa0aae 100644
--- a/agents/windows/CONTENTS
+++ b/agents/windows/CONTENTS
@@ -71,3 +71,4 @@ win_error.h (hide)
wmiHelper.cc (hide)
wmiHelper.h (hide)
wmitest.cc (hide)
+wmitest.exe (hide)
diff --git a/agents/windows/Makefile b/agents/windows/Makefile
index 5efcb04..74ba3e9 100644
--- a/agents/windows/Makefile
+++ b/agents/windows/Makefile
@@ -82,8 +82,8 @@ fix_linebreaks:
-include wmitest.d
-include stringutil.d
-include wmiHelper.d
-wmitest.exe: wmitest.o stringutil.o wmiHelper.o
- $(CXX) $(COMMON_OPTS) $^ -o $@ -lwsock32 -lole32 -loleaut32 -lwbemuuid
+wmitest.exe: wmitest.o stringutil.o WinApi.o wmiHelper.o
+ $(CXX) $(COMMON_OPTS) $^ -o $@ -lwsock32 -lws2_32 -lole32 -loleaut32 -lwbemuuid -lpsapi
-lshlwapi -limagehlp -lntdll
# -----------------------------------------------------------------------------
# 1. Create ressource files with version and product information. Note: That file
diff --git a/agents/windows/wmitest.cc b/agents/windows/wmitest.cc
index f35751b..1492d89 100644
--- a/agents/windows/wmitest.cc
+++ b/agents/windows/wmitest.cc
@@ -1,8 +1,13 @@
#include <algorithm>
#include <string>
#include "stringutil.h"
+#include "WinApi.h"
#include "wmiHelper.h"
+namespace {
+WinApi winapi;
+}
+
void print_usage(const char *exe_name) {
printf(
"Usage: %s action [action specific parameters]"
@@ -13,7 +18,7 @@ void print_usage(const char *exe_name) {
}
void print_namespace(const std::wstring &path, int depth = 0) {
- wmi::Helper helper(path.c_str());
+ wmi::Helper helper(winapi, path.c_str());
std::string offset = std::string(depth * 2, ' ');
{
@@ -43,7 +48,7 @@ void print_namespace(const std::wstring &path, int depth = 0) {
}
void print_table(const std::string &ns, const std::string &pattern) {
- wmi::Helper helper(to_utf16(ns.c_str()).c_str());
+ wmi::Helper helper(winapi, to_utf16(ns.c_str(), winapi).c_str());
wmi::Result result = helper.query(L"SELECT * FROM meta_class");
bool more = result.valid();
@@ -98,7 +103,7 @@ int main(int argc, char **argv) {
if (argc < 3) {
print_namespace(L"Root");
} else {
- print_namespace(to_utf16(argv[2]).c_str());
+ print_namespace(to_utf16(argv[2], winapi).c_str());
}
}