components/openssl: refacetor the SSL debug function

Add the "ssl_opt.h" file to make user able t add its platform interface
This commit is contained in:
Dong Heng
2016-11-01 14:59:50 +08:00
parent 8d1f360ca6
commit bc710e5b88
3 changed files with 20 additions and 10 deletions

View File

@@ -38,10 +38,17 @@
#define SSL_DEBUG_LOCATION_ENABLE 0
#endif
#ifndef SSL_PRINT
#include "stdio.h"
extern int printf(const char *fmt, ...);
#define SSL_PRINT printf
#if SSL_DEBUG_ENBALE
#ifndef SSL_PRINT
#include "stdio.h"
extern int printf(const char *fmt, ...);
#define SSL_PRINT printf
#endif
#else
#ifdef SSL_PRINT
#undef SSL_PRINT
#define SSL_PRINT(...)
#endif
#endif
#if SSL_DEBUG_LOCATION_ENABLE
@@ -56,11 +63,11 @@
#define SSL_ASSERT(s)
#endif
#define SSL_ERR(err, go, ...) { SSL_DEBUG_LOCATION(); SSL_PRINT(__VA_ARGS__); ret = err; goto go; }
#define SSL_ERR(err, go, fmt, ...) { SSL_DEBUG_LOCATION(); SSL_PRINT(fmt, ##__VA_ARGS__); ret = err; goto go; }
#define SSL_RET(go, ...) { SSL_DEBUG_LOCATION(); SSL_PRINT(__VA_ARGS__); goto go; }
#define SSL_RET(go, fmt, ...) { SSL_DEBUG_LOCATION(); SSL_PRINT(fmt, ##__VA_ARGS__); goto go; }
#define SSL_DEBUG(level, ...) { if (level > SSL_DEBUG_LEVEL) {SSL_PRINT(__VA_ARGS__);} }
#define SSL_DEBUG(level, fmt, ...) { if (level > SSL_DEBUG_LEVEL) {SSL_PRINT(fmt, ##__VA_ARGS__);} }
#ifdef __cplusplus
}