Add all debug functions to debug.h 56/232156/6
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 28 Apr 2020 15:33:44 +0000 (17:33 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Fri, 26 Jun 2020 15:36:20 +0000 (17:36 +0200)
Add translate_error that was not available.
Move others from internal.
Include debug.h in internal.h.

The reason for that is to make it easier to test debug functions by
only including debug.h. internal.h is not includable by C++ code.

Both those headers are internal and nothing changes in terms of public
API.

Change-Id: Ica6886c9253d45a5f131a36b457044132daee14a

src/debug.c
src/debug.h
src/internal.h

index e6e2d06440c497881eb49d18eee726a5b72c4065..e23214b01d32f50b7c236f493acd003923373f4f 100644 (file)
@@ -34,6 +34,7 @@
 #include "internal.h"
 #include "debug.h"
 
+
 // TODO any better idea than to use __thread?
 static __thread yaca_error_cb error_cb = NULL;
 static bool error_strings_loaded = false;
index e6b5902b39f7286db4f50f7f555a7156f41bdfae..8a268fdad0f78dcf512e9b496ee34448fc9bd493 100644 (file)
 #ifndef YACA_DEBUG_H
 #define YACA_DEBUG_H
 
+
+#include <openssl/err.h>
+
+#include <yaca_error.h>
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
 typedef void (*yaca_error_cb)(const char*);
-
 void yaca_debug_set_error_cb(yaca_error_cb cb);
 
+const char *yaca_debug_translate_error(yaca_error_e err);
+
+#define ERROR_CLEAR() ERR_clear_error()
+
+void error_dump(const char *file, int line, const char *function, int code);
+#define ERROR_DUMP(code) error_dump(__FILE__, __LINE__, __func__, (code))
+
+/**
+ * Function responsible for translating the openssl error to yaca error and
+ * clearing/dumping the openssl error queue. Use only after openssl function
+ * failure.
+ *
+ * The function checks only first error in the queue. If the function doesn't
+ * find any error in openssl queue or is not able to translate it, it will
+ * return YACA_ERROR_INTERNAL and dump openssl errors if any. If the
+ * translation succeeds the function will clear the error queue and return the
+ * result of translation.
+ */
+int error_handle(const char *file, int line, const char *function);
+#define ERROR_HANDLE() error_handle(__FILE__, __LINE__, __func__)
+
 
 #ifdef __cplusplus
 } /* extern */
 #endif
 
+
 #endif /* YACA_DEBUG_H */
index c6b933ca8c5cbe6a607ba0aede364c4209af0a28..a020d0389a20ca073bc26db1a8608f602fff7a35 100644 (file)
 #ifndef YACA_INTERNAL_H
 #define YACA_INTERNAL_H
 
+
 #include <stddef.h>
 #include <stdbool.h>
 
 #include <openssl/ossl_typ.h>
-#include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/opensslv.h>
 #include <openssl/rand.h>
 
 #include <yaca_types.h>
 
+#include "debug.h"
+
+
 #define API __attribute__ ((visibility("default")))
 #define UNUSED __attribute__((unused))
 
@@ -161,24 +164,7 @@ struct yaca_key_evp_s *key_get_evp(const yaca_key_h key);
 
 yaca_key_h key_copy(const yaca_key_h key);
 
-void error_dump(const char *file, int line, const char *function, int code);
-#define ERROR_DUMP(code) error_dump(__FILE__, __LINE__, __func__, (code))
-#define ERROR_CLEAR() ERR_clear_error()
-
-/**
- * Function responsible for translating the openssl error to yaca error and
- * clearing/dumping the openssl error queue. Use only after openssl function
- * failure.
- *
- * The function checks only first error in the queue. If the function doesn't
- * find any error in openssl queue or is not able to translate it, it will
- * return YACA_ERROR_INTERNAL and dump openssl errors if any. If the
- * translation succeeds the function will clear the error queue and return the
- * result of translation.
- */
-int error_handle(const char *file, int line, const char *function);
-#define ERROR_HANDLE() error_handle(__FILE__, __LINE__, __func__)
-
 int rsa_padding2openssl(yaca_padding_e padding);
 
+
 #endif /* YACA_INTERNAL_H */