diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-09 15:15:17 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-09 18:34:00 +0200 |
commit | 9d6e045a3143f8eb31c5033c9c4be59cc2f73336 (patch) | |
tree | cdda7d8d8866ae2c63aba812cbb2efe2f2b657b0 /NK_C_API.cc | |
parent | 0f2965f5808386f9dd89209d754fd827ef2b27bd (diff) | |
download | libnitrokey-9d6e045a3143f8eb31c5033c9c4be59cc2f73336.tar.gz libnitrokey-9d6e045a3143f8eb31c5033c9c4be59cc2f73336.tar.bz2 |
Return error for too long string
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, 18 insertions, 3 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc index 577f2d6..4ba29ab 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -1,5 +1,7 @@ #include <cstring> #include "NK_C_API.h" +#include "include/TooLongStringException.h" + using namespace nitrokey; static uint8_t NK_last_command_status = 0; @@ -20,8 +22,11 @@ uint8_t * get_with_array_result(T func){ } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; - return nullptr; } + catch (TooLongStringException & longStringException){ + NK_last_command_status = TooLongStringException::exception_id; + } + return nullptr; } template <typename T> @@ -32,8 +37,11 @@ const char* get_with_string_result(T func){ } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; - return ""; } + catch (TooLongStringException & longStringException){ + NK_last_command_status = TooLongStringException::exception_id; + } + return ""; } template <typename T> @@ -44,8 +52,11 @@ auto get_with_result(T func){ } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; - return static_cast<decltype(func())>(0); } + catch (TooLongStringException & longStringException){ + NK_last_command_status = TooLongStringException::exception_id; + } + return static_cast<decltype(func())>(0); } template <typename T> @@ -59,6 +70,10 @@ uint8_t get_without_result(T func){ NK_last_command_status = commandFailedException.last_command_status; return commandFailedException.last_command_status; } + catch (TooLongStringException & longStringException){ + NK_last_command_status = TooLongStringException::exception_id; + return NK_last_command_status; + } } extern "C" |