diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-12-04 19:21:09 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-02-28 19:23:05 +0100 |
commit | 388cf5fcb33f24bc04f79cd1fbea980214518d54 (patch) | |
tree | 1b57874287d02a1fe339f035ba84a54d3bf1f408 /NK_C_API.cc | |
parent | 2faa8f6782a2e6294ed8849048a281d12d60da1c (diff) | |
download | libnitrokey-388cf5fcb33f24bc04f79cd1fbea980214518d54.tar.gz libnitrokey-388cf5fcb33f24bc04f79cd1fbea980214518d54.tar.bz2 |
List devices by unique SC:SD id
Add C API and tests
Add mutexes
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r-- | NK_C_API.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc index f881caf..59247ba 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -608,6 +608,27 @@ extern "C" { }); } + NK_C_API const char* NK_list_devices_by_cpuID() { + auto nm = NitrokeyManager::instance(); + return get_with_string_result([&]() { + auto v = nm->list_devices_by_cpuID(); + std::string res; + for (const auto a : v){ + res += a+";"; + } + if (res.size()>0) res.pop_back(); // remove last delimeter char + return strndup(res.c_str(), 4096); + }); + } + + NK_C_API int NK_connect_with_ID(const char* id) { + auto m = NitrokeyManager::instance(); + return get_with_result([&]() { + return m->connect_with_ID(id) ? 1 : 0; + }); + } + + #ifdef __cplusplus } |