aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.c')
-rw-r--r--src/error.c118
1 files changed, 59 insertions, 59 deletions
diff --git a/src/error.c b/src/error.c
index 49d8c72..15b2aeb 100644
--- a/src/error.c
+++ b/src/error.c
@@ -13,13 +13,13 @@
#include <stdlib.h>
#include <string.h>
-static void aesni_fill_string(char* dest, size_t dest_size, const char* src)
+static void aes_fill_string(char* dest, size_t dest_size, const char* src)
{
strncpy(dest, src, dest_size);
dest[dest_size - 1] = '\0';
}
-static const char* aesni_strerror_messages[] =
+static const char* aes_strerror_messages[] =
{
"Success",
"Invalid argument value NULL",
@@ -30,28 +30,28 @@ static const char* aesni_strerror_messages[] =
"Couldn't allocate memory",
};
-const char* aesni_strerror(AesNI_StatusCode ec)
+const char* aes_strerror(AES_StatusCode ec)
{
- return aesni_strerror_messages[ec];
+ return aes_strerror_messages[ec];
}
-static size_t aesni_format_error_strerror(
- const AesNI_ErrorDetails* err_details,\
+static size_t aes_format_error_strerror(
+ const AES_ErrorDetails* err_details,\
char* dest,
size_t dest_size)
{
- const AesNI_StatusCode ec = aesni_get_error_code(err_details);
- const char* const msg = aesni_strerror(ec);
+ const AES_StatusCode ec = aes_get_error_code(err_details);
+ const char* const msg = aes_strerror(ec);
if (dest == NULL)
return strlen(msg) + 1;
- aesni_fill_string(dest, dest_size, msg);
+ aes_fill_string(dest, dest_size, msg);
return strlen(dest);
}
-static size_t aesni_format_null_argument_error(
- const AesNI_ErrorDetails* err_details,
+static size_t aes_format_null_argument_error(
+ const AES_ErrorDetails* err_details,
char* dest,
size_t dest_size)
{
@@ -65,8 +65,8 @@ static size_t aesni_format_null_argument_error(
return strlen(dest);
}
-static size_t aesni_format_parse_error(
- const AesNI_ErrorDetails* err_details,
+static size_t aes_format_parse_error(
+ const AES_ErrorDetails* err_details,
char* dest,
size_t dest_size)
{
@@ -81,8 +81,8 @@ static size_t aesni_format_parse_error(
return strlen(dest);
}
-static size_t aesni_format_not_implemented_error(
- const AesNI_ErrorDetails* err_details,
+static size_t aes_format_not_implemented_error(
+ const AES_ErrorDetails* err_details,
char* dest,
size_t dest_size)
{
@@ -96,21 +96,21 @@ static size_t aesni_format_not_implemented_error(
return strlen(dest);
}
-typedef size_t (*AesNI_ErrorFormatter)(const AesNI_ErrorDetails*, char*, size_t);
+typedef size_t (*AES_ErrorFormatter)(const AES_ErrorDetails*, char*, size_t);
-static AesNI_ErrorFormatter err_formatters[] =
+static AES_ErrorFormatter err_formatters[] =
{
- &aesni_format_error_strerror,
- &aesni_format_null_argument_error,
- &aesni_format_parse_error,
- &aesni_format_error_strerror,
- &aesni_format_not_implemented_error,
- &aesni_format_error_strerror,
- &aesni_format_error_strerror,
+ &aes_format_error_strerror,
+ &aes_format_null_argument_error,
+ &aes_format_parse_error,
+ &aes_format_error_strerror,
+ &aes_format_not_implemented_error,
+ &aes_format_error_strerror,
+ &aes_format_error_strerror,
};
-size_t aesni_format_error(
- const AesNI_ErrorDetails* err_details,
+size_t aes_format_error(
+ const AES_ErrorDetails* err_details,
char* dest,
size_t dest_size)
{
@@ -122,63 +122,63 @@ size_t aesni_format_error(
#ifdef WIN32
#include <Windows.h>
-static void aesni_collect_call_stack(AesNI_ErrorDetails* err_details)
+static void aes_collect_call_stack(AES_ErrorDetails* err_details)
{
- err_details->call_stack_size = CaptureStackBackTrace(1, AESNI_MAX_CALL_STACK_LENGTH, err_details->call_stack, NULL);
+ err_details->call_stack_size = CaptureStackBackTrace(1, AES_MAX_CALL_STACK_LENGTH, err_details->call_stack, NULL);
}
#else
-static void aesni_collect_call_stack(AesNI_ErrorDetails* err_details)
+static void aes_collect_call_stack(AES_ErrorDetails* err_details)
{
err_details->call_stack_size = 0;
}
#endif
-static AesNI_StatusCode aesni_make_error(
- AesNI_ErrorDetails* err_details,
- AesNI_StatusCode ec)
+static AES_StatusCode aes_make_error(
+ AES_ErrorDetails* err_details,
+ AES_StatusCode ec)
{
if (err_details == NULL)
return ec;
- if (aesni_is_error(ec))
- aesni_collect_call_stack(err_details);
+ if (aes_is_error(ec))
+ aes_collect_call_stack(err_details);
return err_details->ec = ec;
}
-AesNI_StatusCode aesni_success(
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_success(
+ AES_ErrorDetails* err_details)
{
- return aesni_make_error(err_details, AESNI_SUCCESS);
+ return aes_make_error(err_details, AES_SUCCESS);
}
-AesNI_StatusCode aesni_error_null_argument(
- AesNI_ErrorDetails* err_details,
+AES_StatusCode aes_error_null_argument(
+ AES_ErrorDetails* err_details,
const char* param_name)
{
- AesNI_StatusCode status = aesni_make_error(err_details, AESNI_NULL_ARGUMENT_ERROR);
+ AES_StatusCode status = aes_make_error(err_details, AES_NULL_ARGUMENT_ERROR);
if (err_details != NULL)
- aesni_fill_string(
+ aes_fill_string(
err_details->params.null_arg.param_name,
sizeof(err_details->params.null_arg.param_name), param_name);
return status;
}
-AesNI_StatusCode aesni_error_parse(
- AesNI_ErrorDetails* err_details,
+AES_StatusCode aes_error_parse(
+ AES_ErrorDetails* err_details,
const char* src,
const char* what)
{
- AesNI_StatusCode status = aesni_make_error(err_details, AESNI_PARSE_ERROR);
+ AES_StatusCode status = aes_make_error(err_details, AES_PARSE_ERROR);
if (err_details != NULL)
{
- aesni_fill_string(
+ aes_fill_string(
err_details->params.parse_error.src,
sizeof(err_details->params.parse_error.src), src);
- aesni_fill_string(
+ aes_fill_string(
err_details->params.parse_error.what,
sizeof(err_details->params.parse_error.what), what);
}
@@ -186,34 +186,34 @@ AesNI_StatusCode aesni_error_parse(
return status;
}
-AesNI_StatusCode aesni_error_invalid_pkcs7_padding(
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_error_invalid_pkcs7_padding(
+ AES_ErrorDetails* err_details)
{
- return aesni_make_error(err_details, AESNI_INVALID_PKCS7_PADDING_ERROR);
+ return aes_make_error(err_details, AES_INVALID_PKCS7_PADDING_ERROR);
}
-AesNI_StatusCode aesni_error_not_implemented(
- AesNI_ErrorDetails* err_details,
+AES_StatusCode aes_error_not_implemented(
+ AES_ErrorDetails* err_details,
const char* what)
{
- AesNI_StatusCode status = aesni_make_error(err_details, AESNI_NOT_IMPLEMENTED_ERROR);
+ AES_StatusCode status = aes_make_error(err_details, AES_NOT_IMPLEMENTED_ERROR);
if (err_details != NULL)
- aesni_fill_string(
+ aes_fill_string(
err_details->params.not_implemented.what,
sizeof(err_details->params.not_implemented.what), what);
return status;
}
-AesNI_StatusCode aesni_error_missing_padding(
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_error_missing_padding(
+ AES_ErrorDetails* err_details)
{
- return aesni_make_error(err_details, AESNI_MISSING_PADDING_ERROR);
+ return aes_make_error(err_details, AES_MISSING_PADDING_ERROR);
}
-AesNI_StatusCode aesni_error_memory_allocation(
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_error_memory_allocation(
+ AES_ErrorDetails* err_details)
{
- return aesni_make_error(err_details, AESNI_MEMORY_ALLOCATION_ERROR);
+ return aes_make_error(err_details, AES_MEMORY_ALLOCATION_ERROR);
}