]> git.imager.perl.org - imager.git/commitdiff
add i_errors()/im_errors() to the API
authorTony Cook <tony@develop-help.com>
Mon, 13 Aug 2012 08:17:07 +0000 (18:17 +1000)
committerTony Cook <tony@develop-help.com>
Sat, 24 Nov 2012 03:59:24 +0000 (14:59 +1100)
error.c
imdatatypes.h
imerror.h
imext.c
imexttypes.h
immacros.h

diff --git a/error.c b/error.c
index 4b3faf2c9918d2fafdba2bd5e09b0027efc924d0..03f5bef8629e0d3fe1ba1cdc1b53d24c6cfc9b7a 100644 (file)
--- 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<i_errors()>.
+
 =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
 
index b56b43f18c6aa46bd0decc4c6e578e0ba03eed21..32c92d14e78acbe810f1d01810074443a15c778b 100644 (file)
@@ -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
index 11f55ded7e394e3519007fb0a805ab5dc77f48b9..e1cfc943e79f3d76b8a7016d1f5f92b5db05e79c 100644 (file)
--- 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 245d5f28a4cc2b670bb0396a258906675c94ba28..3f19123198b5f57cf1383dea2e31ff11f2b74794 100644 (file)
--- 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
index 8329f1e95b62472891e75d58b81d72103574ddd6..6bdc35ee26552639092ea3fca835521e4d95d0c5 100644 (file)
@@ -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"
index c7a13c8be8a88822058474129eb0a03f45fd81fd..0dbe5e5a6f6d87ee1cfa77344c2b406b98fcddd6 100644 (file)
@@ -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)