summaryrefslogtreecommitdiff
path: root/NK_C_API.cc
diff options
context:
space:
mode:
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r--NK_C_API.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index 77bd181..7de5bbd 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -5,6 +5,17 @@ using namespace nitrokey;
static uint8_t NK_last_command_status = 0;
+template <typename T>
+auto get_with_result(T func){
+ try {
+ return func();
+ }
+ catch (CommandFailedException & commandFailedException){
+ NK_last_command_status = commandFailedException.last_command_status;
+ return commandFailedException.last_command_status;
+ }
+}
+
extern "C"
{
extern uint8_t NK_get_last_command_status(){
@@ -211,7 +222,7 @@ extern int NK_enable_password_safe(const char *user_pin){
extern int NK_get_password_safe_slot_status(){
auto m = NitrokeyManager::instance();
try {
- m->get_password_safe_slot_status();
+ m->get_password_safe_slot_status(); //TODO FIXME
}
catch (CommandFailedException & commandFailedException){
NK_last_command_status = commandFailedException.last_command_status;
@@ -220,4 +231,20 @@ extern int NK_get_password_safe_slot_status(){
return 0;
}
-} \ No newline at end of file
+extern uint8_t NK_get_user_retry_count(){
+ auto m = NitrokeyManager::instance();
+ return get_with_result([&](){
+ return m->get_user_retry_count();
+ });
+}
+
+extern uint8_t NK_get_admin_retry_count(){
+ auto m = NitrokeyManager::instance();
+ return get_with_result([&](){
+ return m->get_admin_retry_count();
+ });
+}
+
+
+}
+