aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--utils/install_service.cpp1
-rw-r--r--utils/libservice/include/libservice/common.hpp1
-rw-r--r--utils/libservice/include/libservice/interface.hpp1
-rw-r--r--utils/libservice/include/libservice/service.hpp3
-rw-r--r--utils/libservice/include/libservice/service_manager.hpp1
-rw-r--r--utils/libservice/include/libservice/singleton.hpp1
-rw-r--r--utils/libservice/include/libservice/windows_error.hpp1
-rw-r--r--utils/libservice/src/service.cpp31
-rw-r--r--utils/libservice/src/service_handle.cpp1
-rw-r--r--utils/libservice/src/service_manager.cpp1
-rw-r--r--utils/libservice/src/windows_error.cpp1
-rw-r--r--utils/libservice/test/windows_error.cpp1
-rw-r--r--utils/start_service.cpp1
-rw-r--r--utils/stop_service.cpp1
-rw-r--r--utils/uninstall_service.cpp1
15 files changed, 47 insertions, 0 deletions
diff --git a/utils/install_service.cpp b/utils/install_service.cpp
index f22311b..7bed0d5 100644
--- a/utils/install_service.cpp
+++ b/utils/install_service.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/include/libservice/common.hpp b/utils/libservice/include/libservice/common.hpp
index 32e2a50..3c32966 100644
--- a/utils/libservice/include/libservice/common.hpp
+++ b/utils/libservice/include/libservice/common.hpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/include/libservice/interface.hpp b/utils/libservice/include/libservice/interface.hpp
index 058470c..53751b2 100644
--- a/utils/libservice/include/libservice/interface.hpp
+++ b/utils/libservice/include/libservice/interface.hpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/include/libservice/service.hpp b/utils/libservice/include/libservice/service.hpp
index a14f0e2..d350c91 100644
--- a/utils/libservice/include/libservice/service.hpp
+++ b/utils/libservice/include/libservice/service.hpp
@@ -20,6 +20,9 @@ namespace libservice
class Service
{
public:
+ static bool does_exist(const ServiceManager&,
+ const std::string& name);
+
static Service open(const ServiceManager&,
const std::string& name);
static Service install(const ServiceManager&,
diff --git a/utils/libservice/include/libservice/service_manager.hpp b/utils/libservice/include/libservice/service_manager.hpp
index a2bb268..c39b99e 100644
--- a/utils/libservice/include/libservice/service_manager.hpp
+++ b/utils/libservice/include/libservice/service_manager.hpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/include/libservice/singleton.hpp b/utils/libservice/include/libservice/singleton.hpp
index bd137e7..a9d55ad 100644
--- a/utils/libservice/include/libservice/singleton.hpp
+++ b/utils/libservice/include/libservice/singleton.hpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/include/libservice/windows_error.hpp b/utils/libservice/include/libservice/windows_error.hpp
index 57730d5..907c7e7 100644
--- a/utils/libservice/include/libservice/windows_error.hpp
+++ b/utils/libservice/include/libservice/windows_error.hpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/src/service.cpp b/utils/libservice/src/service.cpp
index 1f7cbef..efe645f 100644
--- a/utils/libservice/src/service.cpp
+++ b/utils/libservice/src/service.cpp
@@ -95,6 +95,31 @@ namespace libservice
throw std::system_error(ec, WinErrorCategory::get(), LIBSERVICE_ERROR_PREFIX);
}
}
+
+ bool does_service_exist(const ServiceManager& mgr,
+ const std::string& name)
+ {
+ const auto raw = OpenService(static_cast<SC_HANDLE>(mgr),
+ name.c_str(),
+ SERVICE_QUERY_STATUS);
+
+ if (NULL != raw)
+ {
+ ServiceHandle handle(raw);
+ return true;
+ }
+
+ const auto ec = GetLastError();
+
+ switch (ec)
+ {
+ case ERROR_SERVICE_DOES_NOT_EXIST:
+ return false;
+
+ default:
+ throw std::system_error(ec, WinErrorCategory::get(), LIBSERVICE_ERROR_PREFIX);
+ }
+ }
SERVICE_STATUS_PROCESS query_service_status(const ServiceHandle& handle)
{
@@ -174,6 +199,12 @@ namespace libservice
return Service(install_service(mgr, name, bin_path));
}
+ bool Service::does_exist(const ServiceManager& mgr,
+ const std::string& name)
+ {
+ return does_service_exist(mgr, name);
+ }
+
void Service::start() const
{
const auto state = query_service_state(m_handle);
diff --git a/utils/libservice/src/service_handle.cpp b/utils/libservice/src/service_handle.cpp
index 5356b50..21fb78c 100644
--- a/utils/libservice/src/service_handle.cpp
+++ b/utils/libservice/src/service_handle.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/src/service_manager.cpp b/utils/libservice/src/service_manager.cpp
index 4888406..b3c0b96 100644
--- a/utils/libservice/src/service_manager.cpp
+++ b/utils/libservice/src/service_manager.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/src/windows_error.cpp b/utils/libservice/src/windows_error.cpp
index 6cc7302..1e28345 100644
--- a/utils/libservice/src/windows_error.cpp
+++ b/utils/libservice/src/windows_error.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/libservice/test/windows_error.cpp b/utils/libservice/test/windows_error.cpp
index f165681..461b4e6 100644
--- a/utils/libservice/test/windows_error.cpp
+++ b/utils/libservice/test/windows_error.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/start_service.cpp b/utils/start_service.cpp
index 15aaaed..05ddba2 100644
--- a/utils/start_service.cpp
+++ b/utils/start_service.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/stop_service.cpp b/utils/stop_service.cpp
index 928c12b..6f4a700 100644
--- a/utils/stop_service.cpp
+++ b/utils/stop_service.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
diff --git a/utils/uninstall_service.cpp b/utils/uninstall_service.cpp
index 1a6c44d..5929dfc 100644
--- a/utils/uninstall_service.cpp
+++ b/utils/uninstall_service.cpp
@@ -1,4 +1,5 @@
/**
+ * \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.