diff options
Diffstat (limited to 'src/gnutls/globals.h')
-rw-r--r-- | src/gnutls/globals.h | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/src/gnutls/globals.h b/src/gnutls/globals.h index 1f9f35c0..09cb251f 100644 --- a/src/gnutls/globals.h +++ b/src/gnutls/globals.h @@ -21,11 +21,74 @@ #define IN_XMLSEC_CRYPTO #define XMLSEC_PRIVATE -#define XMLSEC_GNUTLS_GCRYPT_REPORT_ERROR(err) \ - "error code=%d; error message='%s'", \ - (int)err, xmlSecErrorsSafeString(gcry_strerror((err))) -#define XMLSEC_GNUTLS_REPORT_ERROR(err) \ - "error code=%d; error message='%s'", \ - (int)err, xmlSecErrorsSafeString(gnutls_strerror((err))) +/* Include common error helper macros. */ +#include "../errors_helpers.h" +/** + * xmlSecGnuTLSGCryptError: + * @errorFunction: the failed function name. + * @errCode: the GCrypt error code. + * @errorObject: the error specific error object (e.g. transform, key data, etc). + * + * Macro. The XMLSec library macro for reporting GnuTLS-GCrypt errors. + */ +#define xmlSecGnuTLSGCryptError(errorFunction, errCode, errorObject) \ + { \ + const char* source = gcry_strsource((errCode)); \ + const char* message = gcry_strerror((errCode)); \ + xmlSecError(XMLSEC_ERRORS_HERE, \ + (const char*)(errorObject), \ + (errorFunction), \ + XMLSEC_ERRORS_R_CRYPTO_FAILED, \ + "gcrypt error: %ld: %s: %s", \ + (long)(errCode), \ + xmlSecErrorsSafeString(source), \ + xmlSecErrorsSafeString(message) \ + ); \ + } + +/** + * xmlSecGnuTLSError: + * @errorFunction: the failed function name. + * @errCode: the GnuTLS error code. + * @errorObject: the error specific error object (e.g. transform, key data, etc). + * + * Macro. The XMLSec library macro for reporting GnuTLS errors. + */ +#define xmlSecGnuTLSError(errorFunction, errCode, errorObject) \ + { \ + const char* message = gnutls_strerror((errCode)); \ + xmlSecError(XMLSEC_ERRORS_HERE, \ + (const char*)(errorObject), \ + (errorFunction), \ + XMLSEC_ERRORS_R_CRYPTO_FAILED, \ + "gnutls error: %ld: %s", \ + (long)(errCode), \ + xmlSecErrorsSafeString(message) \ + ); \ + } + +/** + * xmlSecGnuTLSError2: + * @errorFunction: the failed function name. + * @errCode: the GnuTLS error code. + * @errorObject: the error specific error object (e.g. transform, key data, etc). + * @msg: the extra message. + * @param: the extra message param. + * + * Macro. The XMLSec library macro for reporting GnuTLS errors. + */ +#define xmlSecGnuTLSError2(errorFunction, errCode, errorObject, msg, param) \ + { \ + const char* message = gnutls_strerror((errCode)); \ + xmlSecError(XMLSEC_ERRORS_HERE, \ + (const char*)(errorObject), \ + (errorFunction), \ + XMLSEC_ERRORS_R_CRYPTO_FAILED, \ + msg "gnutls error: %ld: %s", \ + (param), \ + (long)(errCode), \ + xmlSecErrorsSafeString(message) \ + ); \ + } #endif /* ! __XMLSEC_GLOBALS_H__ */ |