diff options
Diffstat (limited to 'src/errors.c')
-rw-r--r-- | src/errors.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/errors.c b/src/errors.c index c9886d36..c01a4925 100644 --- a/src/errors.c +++ b/src/errors.c @@ -114,6 +114,7 @@ xmlSecErrorsShutdown(void) { void xmlSecErrorsSetCallback(xmlSecErrorsCallback callback) { xmlSecErrorsClbk = callback; + xmlSecErrorsDefaultCallbackEnableOutput(0); } /** @@ -144,7 +145,7 @@ xmlSecErrorsDefaultCallback(const char* file, int line, const char* func, } } xmlGenericError(xmlGenericErrorContext, - "func=%s:file=%s:line=%d:obj=%s:subj=%s:error=%d:%s:%s\n", + "func=%s:file=%s:line=%d:obj=%s:subj=%s:error=%d:<%s>:<%s>\n", (func != NULL) ? func : "unknown", (file != NULL) ? file : "unknown", line, @@ -220,23 +221,38 @@ xmlSecErrorsGetMsg(xmlSecSize pos) { * function. */ void -xmlSecError(const char* file, int line, const char* func, - const char* errorObject, const char* errorSubject, - int reason, const char* msg, ...) { +xmlSecError(const char* file, int line, const char* func, + const char* errorObject, const char* errorSubject, + int reason, const char* msg, ...) { if(xmlSecErrorsClbk != NULL) { - xmlChar error_msg[XMLSEC_ERRORS_BUFFER_SIZE]; + xmlChar error_msg[XMLSEC_ERRORS_BUFFER_SIZE] = {'\0',}; + const char* e_msg = NULL; + xmlSecSize i; + int len = 0; + + if(xmlSecPrintErrorMessages == 0) { + if(reason != XMLSEC_ERRORS_MAX_NUMBER) { + for(i = 0; (i < XMLSEC_ERRORS_MAX_NUMBER) && (xmlSecErrorsGetMsg(i) != NULL); ++i) { + if(xmlSecErrorsGetCode(i) == reason) { + e_msg = xmlSecErrorsGetMsg(i); + sprintf(error_msg , "%s] [", e_msg); + len = strlen(error_msg); + break; + } + } + } + } if(msg != NULL) { va_list va; - va_start(va, msg); - xmlSecStrVPrintf(error_msg, sizeof(error_msg), BAD_CAST msg, va); + xmlSecStrVPrintf(error_msg + len, sizeof(error_msg) - len, BAD_CAST msg, va); error_msg[sizeof(error_msg) - 1] = '\0'; va_end(va); } else { error_msg[0] = '\0'; } - xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, (char*)error_msg); - } + + xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, (char*)error_msg); } } |