From: Simon Lukasik <slukasik(a)redhat.com>
---
CMakeLists.txt | 2 +-
include/APIHelpers.h | 15 +++++++++++++++
src/APIHelpers.cpp | 17 +++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 59b0366..6454f2c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ endif()
# custom openscap parameters.
if (NOT DEFINED OPENSCAP_LIBRARIES OR NOT DEFINED OPENSCAP_INCLUDE_DIRS)
include("${CMAKE_ROOT}/Modules/FindPkgConfig.cmake")
- pkg_check_modules(OPENSCAP REQUIRED libopenscap>=1.0.4)
+ pkg_check_modules(OPENSCAP REQUIRED libopenscap>=1.0.5)
endif()
# This is optional, only required if user wants documentation rebuilt
diff --git a/include/APIHelpers.h b/include/APIHelpers.h
index cf8f2a2..e1face5 100644
--- a/include/APIHelpers.h
+++ b/include/APIHelpers.h
@@ -29,6 +29,7 @@
extern "C"
{
#include <xccdf_benchmark.h>
+#include <xccdf_policy.h>
}
/**
@@ -39,6 +40,20 @@ extern "C"
QString oscapTextIteratorGetPreferred(struct oscap_text_iterator* it, const QString&
lang = "");
/**
+ * Get human readable title of the given XCCDF Item. The title is selected based on the
given
+ * preferred language and then the the XCCDF Substitution is resolved in accordance with
given
+ * XCCDF policy.
+ */
+QString oscapItemGetReadableTitle(struct xccdf_item *item, struct xccdf_policy *policy,
const QString& lang = "");
+
+/**
+ * Get human readable description of the given XCCDF Item. The description is selected
based
+ * on the given preferred language and then the the XCCDF Substitution is resolved in
accordance
+ * with given XCCDF policy.
+ */
+QString oscapItemGetReadableDescription(struct xccdf_item *item, struct xccdf_policy
*policy, const QString& lang = "");
+
+/**
* Returns QString containing utf8 contents of oscap_err_desc()
*/
QString oscapErrDesc();
diff --git a/src/APIHelpers.cpp b/src/APIHelpers.cpp
index c553ba5..8f1f057 100644
--- a/src/APIHelpers.cpp
+++ b/src/APIHelpers.cpp
@@ -24,6 +24,7 @@
extern "C"
{
#include <oscap_error.h>
+#include <xccdf_policy.h>
}
QString oscapTextIteratorGetPreferred(struct oscap_text_iterator* it, const QString&
lang)
@@ -36,6 +37,22 @@ QString oscapTextIteratorGetPreferred(struct oscap_text_iterator* it,
const QStr
return ret;
}
+QString oscapItemGetReadableTitle(struct xccdf_item *item, struct xccdf_policy *policy,
const QString& lang)
+{
+ char* readable_s = xccdf_policy_get_readable_item_title(policy, item, lang.isEmpty()
? NULL : lang.toUtf8().constData());
+ const QString ret(readable_s != NULL ? QString::fromUtf8(readable_s) :
"(none)");
+ free(readable_s);
+ return ret;
+}
+
+QString oscapItemGetReadableDescription(struct xccdf_item *item, struct xccdf_policy
*policy, const QString& lang)
+{
+ char* readable_s = xccdf_policy_get_readable_item_description(policy, item,
lang.isEmpty() ? NULL : lang.toUtf8().constData());
+ const QString ret(readable_s != NULL ? QString::fromUtf8(readable_s) :
"(none)");
+ free(readable_s);
+ return ret;
+}
+
QString oscapErrDesc()
{
return QString::fromUtf8(oscap_err_desc());
--
1.8.5.3