summaryrefslogtreecommitdiff
path: root/NK_C_API.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 16:01:24 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 16:01:24 +0100
commit3f3fdebbc795dc3805cd5be105ce994286598f16 (patch)
tree4614c7e129f842606078a9ae47e494101e623cb5 /NK_C_API.cc
parent0a359ceaa7cc08d5e7069729c0501931e0dbeb82 (diff)
parent46a94679152da263e3e805ec2073359ae60ce6ab (diff)
downloadlibnitrokey-3f3fdebbc795dc3805cd5be105ce994286598f16.tar.gz
libnitrokey-3f3fdebbc795dc3805cd5be105ce994286598f16.tar.bz2
Merge branch 'pr_145' into contributions
Add NK_get_SD_usage_data function to C API Fixes #145
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r--NK_C_API.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index aa2d452..a780acf 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -687,6 +687,23 @@ extern "C" {
return 0;
}
+ NK_C_API int NK_get_SD_usage_data(struct NK_SD_usage_data* out) {
+ if (out == nullptr)
+ return -1;
+ auto m = NitrokeyManager::instance();
+ auto result = get_with_status([&]() {
+ return m->get_SD_usage_data();
+ }, std::make_pair<uint8_t, uint8_t>(0, 0));
+ auto error_code = std::get<0>(result);
+ if (error_code != 0)
+ return error_code;
+
+ auto data = std::get<1>(result);
+ out->write_level_min = std::get<0>(data);
+ out->write_level_max = std::get<1>(data);
+
+ return 0;
+ }
NK_C_API char* NK_get_SD_usage_data_as_string() {
auto m = NitrokeyManager::instance();