capture errors from libxml2

fixes #4
This commit is contained in:
Ross Kinder
2015-12-23 17:17:48 -05:00
parent c095422255
commit dc37ddb368
6 changed files with 48 additions and 25 deletions

View File

@@ -1,13 +1,31 @@
package xmlsec
// onError_cgo is a C function that can be passed to xmlSecErrorsSetCallback which
// in turn invokes the go function onError which captures errors generated by
// libxmlsec.
// #include <stdio.h>
// #include <stdarg.h>
// #include <libxml/parser.h>
// #include <libxml/parserInternals.h>
// #include <libxml/xmlmemory.h>
// #include <xmlsec/xmlsec.h>
// #include <xmlsec/errors.h>
//
// For reasons I do not completely understand, it must be defined in a different
// file from onError.
// void onError_cgo(char *file, int line, char *funcName, char *errorObject, char *errorSubject, int reason, char *msg) {
// onError(file, line, funcName, errorObject, errorSubject, reason, msg);
// void onXmlError(const char *msg); // implemented in go
// void onXmlsecError(const char *file, int line, const char *funcName, const char *errorObject, const char *errorSubject, int reason, const char *msg); // implemented in go
//
// static void onXmlGenericError_cgo(void *ctx, const char *format, ...) {
// char buffer[256];
// va_list args;
// va_start(args, format);
// vsnprintf(buffer, 256, format, args);
// va_end (args);
// onXmlError(buffer);
// }
//
// static void onXmlsecError_cgo(const char *file, int line, const char *funcName, const char *errorObject, const char *errorSubject, int reason, const char *msg) {
// onXmlsecError(file, line, funcName, errorObject, errorSubject, reason, msg);
// }
//
// void captureXmlErrors() {
// xmlSecErrorsSetCallback(onXmlsecError_cgo);
// xmlSetGenericErrorFunc(NULL, onXmlGenericError_cgo);
// }
import "C"