From: Tony Cook Date: Mon, 13 Aug 2012 08:17:07 +0000 (+1000) Subject: add i_errors()/im_errors() to the API X-Git-Tag: v0.92_01~16 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/fa56d5a9d74064bd5a109a9e1262d0a080c95934 add i_errors()/im_errors() to the API --- diff --git a/error.c b/error.c index 4b3faf2c..03f5bef8 100644 --- a/error.c +++ b/error.c @@ -150,21 +150,21 @@ i_failed_cb i_set_failed_cb(i_failed_cb cb) { #endif /* -=item i_errors() +=item im_errors(ctx) +=synopsis i_errmsg *errors = im_errors(aIMCTX); +=synopsis i_errmsg *errors = i_errors(); Returns a pointer to the first element of an array of error messages, terminated by a NULL pointer. The highest level message is first. +Also callable as C. + =cut */ i_errmsg *im_errors(im_context_t ctx) { return ctx->error_stack + ctx->error_sp; } -i_errmsg *i_errors(void) { - return im_errors(im_get_context()); -} - /* =back diff --git a/imdatatypes.h b/imdatatypes.h index b56b43f1..32c92d14 100644 --- a/imdatatypes.h +++ b/imdatatypes.h @@ -694,6 +694,13 @@ enum { #include "iolayert.h" +/* error message information returned by im_errors() */ + +typedef struct { + char *msg; + int code; +} i_errmsg; + typedef struct i_render_tag i_render; #ifdef IMAGER_FORMAT_ATTR diff --git a/imerror.h b/imerror.h index 11f55ded..e1cfc943 100644 --- a/imerror.h +++ b/imerror.h @@ -5,18 +5,13 @@ see error.c for documentation the error information is currently global */ -typedef struct { - char *msg; - int code; -} i_errmsg; - typedef void (*i_error_cb)(int code, char const *msg); typedef void (*i_failed_cb)(i_errmsg *msgs); extern i_error_cb i_set_error_cb(i_error_cb); extern i_failed_cb i_set_failed_cb(i_failed_cb); extern void i_set_argv0(char const *); extern int i_set_errors_fatal(int new_fatal); -extern i_errmsg *i_errors(void); +extern i_errmsg *im_errors(pIMCTX); extern void im_push_error(pIMCTX, int code, char const *msg); #ifndef IMAGER_NO_CONTEXT diff --git a/imext.c b/imext.c index 245d5f28..3f191231 100644 --- a/imext.c +++ b/imext.c @@ -160,7 +160,8 @@ im_ext_funcs imager_function_table = im_lhead, im_loog, im_context_refinc, - im_context_refdec + im_context_refdec, + im_errors }; /* in general these functions aren't called by Imager internally, but diff --git a/imexttypes.h b/imexttypes.h index 8329f1e9..6bdc35ee 100644 --- a/imexttypes.h +++ b/imexttypes.h @@ -227,6 +227,7 @@ typedef struct { void (*f_im_loog)(im_context_t, int level,const char *msg, ... ) I_FORMAT_ATTR(3,4); void (*f_im_context_refinc)(im_context_t, const char *where); void (*f_im_context_refdec)(im_context_t, const char *where); + i_errmsg *(*f_im_errors)(im_context_t); } im_ext_funcs; #define PERL_FUNCTION_TABLE_NAME "Imager::__ext_func_table" diff --git a/immacros.h b/immacros.h index c7a13c8b..0dbe5e5a 100644 --- a/immacros.h +++ b/immacros.h @@ -155,6 +155,7 @@ returns -1 and pushes an error. #define i_clear_error() im_clear_error(aIMCTX) #define i_push_errorvf(code, fmt, args) im_push_errorvf(aIMCTX, code, fmt, args) #define i_push_error(code, msg) im_push_error(aIMCTX, code, msg) +#define i_errors() im_errors(aIMCTX) #define io_new_fd(fd) im_io_new_fd(aIMCTX, (fd)) #define io_new_bufchain() im_io_new_bufchain(aIMCTX)