From eac41a26484feaf205de15320321b4e4c4914a50 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Mon, 19 Nov 2012 19:33:51 +1100 Subject: [PATCH] restore ABI level 5 compatibility --- apidocs.perl | 2 +- imext.c | 156 +++++++++++++++++++++++++++++++++++++++++++++------ imexttypes.h | 59 ++++++++++++------- 3 files changed, 179 insertions(+), 38 deletions(-) diff --git a/apidocs.perl b/apidocs.perl index b96c7277..1a6ed077 100644 --- a/apidocs.perl +++ b/apidocs.perl @@ -193,7 +193,7 @@ sub make_func_list { my $in_struct; while () { /^typedef struct/ && ++$in_struct; - if ($in_struct && /\(\*f_(i[om]?_\w+)/) { + if ($in_struct && !/SKIP/ && /\(\*f_(i[om]?_\w+)/) { my $name = $1; $name =~ s/_imp$//; push @funcs, $name; diff --git a/imext.c b/imext.c index 9b85350e..4471afe9 100644 --- a/imext.c +++ b/imext.c @@ -3,6 +3,26 @@ #include "imio.h" static im_context_t get_context(void); +static i_img *mathom_i_img_8_new(i_img_dim, i_img_dim, int); +static i_img *mathom_i_img_16_new(i_img_dim, i_img_dim, int); +static i_img *mathom_i_img_double_new(i_img_dim, i_img_dim, int); +static i_img *mathom_i_img_pal_new(i_img_dim, i_img_dim, int, int); +static void mathom_i_clear_error(void); +static void mathom_i_push_error(int, const char *); +static void mathom_i_push_errorvf(int, const char *, va_list); +static int mathom_i_set_image_file_limits(i_img_dim, i_img_dim, size_t); +static int mathom_i_get_image_file_limits(i_img_dim*, i_img_dim*, size_t*); +static int +mathom_i_int_check_image_file_limits(i_img_dim, i_img_dim, int, size_t); +static i_img *mathom_i_img_alloc(void); +static void mathom_i_img_init(i_img *); +static i_io_glue_t *mathom_io_new_fd(int); +static i_io_glue_t *mathom_io_new_bufchain(void); +static i_io_glue_t * +mathom_io_new_buffer(const char *data, size_t, i_io_closebufp_t, void *); +static i_io_glue_t * +mathom_io_new_cb(void *, i_io_readl_t, i_io_writel_t, i_io_seekl_t, + i_io_closel_t, i_io_destroyl_t); /* DON'T ADD CASTS TO THESE @@ -20,10 +40,10 @@ im_ext_funcs imager_function_table = myfree_file_line, myrealloc_file_line, - im_img_8_new, - im_img_16_new, - im_img_double_new, - im_img_pal_new, + mathom_i_img_8_new, + mathom_i_img_16_new, + mathom_i_img_double_new, + mathom_i_img_pal_new, i_img_destroy, i_sametype, i_sametype_chans, @@ -60,10 +80,10 @@ im_ext_funcs imager_function_table = i_quant_translate, i_quant_transparent, - im_clear_error, - im_push_error, + mathom_i_clear_error, + mathom_i_push_error, i_push_errorf, - im_push_errorvf, + mathom_i_push_errorvf, i_tags_new, i_tags_set, @@ -101,9 +121,9 @@ im_ext_funcs imager_function_table = i_rubthru, /* IMAGER_API_LEVEL 2 functions */ - im_set_image_file_limits, - im_get_image_file_limits, - im_int_check_image_file_limits, + mathom_i_set_image_file_limits, + mathom_i_get_image_file_limits, + mathom_i_int_check_image_file_limits, i_flood_fill_border, i_flood_cfill_border, @@ -118,8 +138,8 @@ im_ext_funcs imager_function_table = i_loog, /* IMAGER_API_LEVEL 4 functions */ - im_img_alloc, - im_img_init, + mathom_i_img_alloc, + mathom_i_img_init, /* IMAGER_API_LEVEL 5 functions */ i_img_is_monochrome, @@ -147,16 +167,32 @@ im_ext_funcs imager_function_table = i_io_close, i_io_set_buffered, i_io_gets, - im_io_new_fd, - im_io_new_bufchain, - im_io_new_buffer, - im_io_new_cb, + mathom_io_new_fd, + mathom_io_new_bufchain, + mathom_io_new_buffer, + mathom_io_new_cb, io_slurp, io_glue_destroy, /* level 8 */ - get_context, + im_img_8_new, + im_img_16_new, + im_img_double_new, + im_img_pal_new, + im_clear_error, + im_push_error, + im_push_errorvf, im_push_errorf, + im_set_image_file_limits, + im_get_image_file_limits, + im_int_check_image_file_limits, + im_img_alloc, + im_img_init, + im_io_new_fd, + im_io_new_bufchain, + im_io_new_buffer, + im_io_new_cb, + get_context, im_lhead, im_loog, im_context_refinc, @@ -585,3 +621,89 @@ static im_context_t get_context(void) { return im_get_context(); } + +static i_img * +mathom_i_img_8_new(i_img_dim xsize, i_img_dim ysize, int channels) { + return i_img_8_new(xsize, ysize, channels); +} + +static i_img * +mathom_i_img_16_new(i_img_dim xsize, i_img_dim ysize, int channels) { + return i_img_16_new(xsize, ysize, channels); +} + +static i_img * +mathom_i_img_double_new(i_img_dim xsize, i_img_dim ysize, int channels) { + return i_img_double_new(xsize, ysize, channels); +} + +static i_img * +mathom_i_img_pal_new(i_img_dim xsize, i_img_dim ysize, int channels, + int maxpal) { + return i_img_pal_new(xsize, ysize, channels, maxpal); +} + +static void +mathom_i_clear_error(void) { + i_clear_error(); +} + +static void +mathom_i_push_error(int code, const char *msg) { + i_push_error(code, msg); +} + +static void +mathom_i_push_errorvf(int code, const char *fmt, va_list args) { + i_push_errorvf(code, fmt, args); +} + +static int +mathom_i_set_image_file_limits(i_img_dim max_width, i_img_dim max_height, + size_t max_bytes) { + return i_set_image_file_limits(max_width, max_height, max_bytes); +} + +static int +mathom_i_get_image_file_limits(i_img_dim *pmax_width, i_img_dim *pmax_height, + size_t *pmax_bytes) { + return i_get_image_file_limits(pmax_width, pmax_height, pmax_bytes); +} + +static int +mathom_i_int_check_image_file_limits(i_img_dim width, i_img_dim height, + int channels, size_t sample_size) { + return i_int_check_image_file_limits(width, height, channels, sample_size); +} + +static i_img * +mathom_i_img_alloc(void) { + return i_img_alloc(); +} + +static void +mathom_i_img_init(i_img *im) { + i_img_init(im); +} + +static i_io_glue_t * +mathom_io_new_fd(int fd) { + return io_new_fd(fd); +} +static i_io_glue_t * +mathom_io_new_bufchain(void) { + return io_new_bufchain(); +} + +static i_io_glue_t * +mathom_io_new_buffer(const char *data, size_t size, i_io_closebufp_t closefp, + void *close_data) { + return io_new_buffer(data, size, closefp, close_data); +} + +static i_io_glue_t * +mathom_io_new_cb(void *p, i_io_readl_t readcb, i_io_writel_t writecb, + i_io_seekl_t seekcb, i_io_closel_t closecb, + i_io_destroyl_t destroycb) { + return io_new_cb(p, readcb, writecb, seekcb, closecb, destroycb); +} diff --git a/imexttypes.h b/imexttypes.h index 673aded2..ae3bc002 100644 --- a/imexttypes.h +++ b/imexttypes.h @@ -25,10 +25,8 @@ Version 5 changed the return types of i_get_file_background() and i_get_file_backgroundf() from void to int. - Version 6 added - */ -#define IMAGER_API_VERSION 6 +#define IMAGER_API_VERSION 5 /* IMAGER_API_LEVEL is the level of the structure. New function pointers @@ -36,7 +34,7 @@ will result in an increment of IMAGER_API_LEVEL. */ -#define IMAGER_API_LEVEL 7 +#define IMAGER_API_LEVEL 8 typedef struct { int version; @@ -50,10 +48,10 @@ typedef struct { void (*f_myfree_file_line)(void *p, char*file, int line); void* (*f_myrealloc_file_line)(void *p, size_t newsize, char* file,int line); - i_img *(*f_im_img_8_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels); - i_img *(*f_im_img_16_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels); - i_img *(*f_im_img_double_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels); - i_img *(*f_im_img_pal_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels, int maxpal); + i_img *(*f_i_img_8_new)(i_img_dim xsize, i_img_dim ysize, int channels); /* SKIP */ + i_img *(*f_i_img_16_new)(i_img_dim xsize, i_img_dim ysize, int channels); /* SKIP */ + i_img *(*f_i_img_double_new)(i_img_dim xsize, i_img_dim ysize, int channels); /* SKIP */ + i_img *(*f_i_img_pal_new)(i_img_dim xsize, i_img_dim ysize, int channels, int maxpal); /* SKIP */ void (*f_i_img_destroy)(i_img *im); i_img *(*f_i_sametype)(i_img *im, i_img_dim xsize, i_img_dim ysize); i_img *(*f_i_sametype_chans)(i_img *im, i_img_dim xsize, i_img_dim ysize, int channels); @@ -104,10 +102,10 @@ typedef struct { void (*f_i_quant_transparent)(i_quantize *quant, i_palidx *indices, i_img *img, i_palidx trans_index); - void (*f_im_clear_error)(im_context_t ctx); - void (*f_im_push_error)(im_context_t ctx, int code, char const *msg); + void (*f_i_clear_error)(void); /* SKIP */ + void (*f_i_push_error)(int code, char const *msg); /* SKIP */ void (*f_i_push_errorf)(int code, char const *fmt, ...); - void (*f_im_push_errorvf)(im_context_t ctx, int code, char const *fmt, va_list); + void (*f_i_push_errorvf)(int code, char const *fmt, va_list); /* SKIP */ void (*f_i_tags_new)(i_img_tags *tags); int (*f_i_tags_set)(i_img_tags *tags, char const *name, char const *data, @@ -154,9 +152,9 @@ typedef struct { int (*f_i_rubthru)(i_img *im, i_img *src, i_img_dim tx, i_img_dim ty, i_img_dim src_minx, i_img_dim src_miny, i_img_dim src_maxx, i_img_dim src_maxy); /* IMAGER_API_LEVEL 2 functions */ - int (*f_im_set_image_file_limits)(im_context_t ctx, i_img_dim width, i_img_dim height, size_t bytes); - int (*f_im_get_image_file_limits)(im_context_t ctx, i_img_dim *width, i_img_dim *height, size_t *bytes); - int (*f_im_int_check_image_file_limits)(im_context_t ctx, i_img_dim width, i_img_dim height, int channels, size_t sample_size); + int (*f_i_set_image_file_limits)(i_img_dim width, i_img_dim height, size_t bytes); /* SKIP */ + int (*f_i_get_image_file_limits)(i_img_dim *width, i_img_dim *height, size_t *bytes); /* SKIP */ + int (*f_i_int_check_image_file_limits)(i_img_dim width, i_img_dim height, int channels, size_t sample_size); /* SKIP */ int (*f_i_flood_fill_border)(i_img *im, i_img_dim seedx, i_img_dim seedy, const i_color *dcol, const i_color *border); int (*f_i_flood_cfill_border)(i_img *im, i_img_dim seedx, i_img_dim seedy, i_fill_t *fill, const i_color *border); @@ -170,8 +168,8 @@ typedef struct { void (*f_i_loog)(int level, const char *msg, ...); /* IMAGER_API_LEVEL 4 functions will be added here */ - i_img *(*f_im_img_alloc)(im_context_t ctx); - void (*f_im_img_init)(im_context_t ctx, i_img *); + i_img *(*f_i_img_alloc)(void); /* SKIP */ + void (*f_i_img_init)(i_img *); /* SKIP */ /* IMAGER_API_LEVEL 5 functions will be added here */ /* added i_psampf?_bits macros */ @@ -212,17 +210,38 @@ typedef struct { int (*f_i_io_set_buffered)(io_glue *ig, int buffered); ssize_t (*f_i_io_gets)(io_glue *ig, char *, size_t, int); + i_io_glue_t *(*f_io_new_fd)(int fd); /* SKIP */ + i_io_glue_t *(*f_io_new_bufchain)(void); /* SKIP */ + i_io_glue_t *(*f_io_new_buffer)(const char *data, size_t len, i_io_closebufp_t closecb, void *closedata); /* SKIP */ + i_io_glue_t *(*f_io_new_cb)(void *p, i_io_readl_t readcb, i_io_writel_t writecb, i_io_seekl_t seekcb, i_io_closel_t closecb, i_io_destroyl_t destroycb); /* SKIP */ + size_t (*f_io_slurp)(i_io_glue_t *ig, unsigned char **c); + void (*f_io_glue_destroy)(i_io_glue_t *ig); + + /* IMAGER_API_LEVEL 8 functions will be added here */ + i_img *(*f_im_img_8_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels); + i_img *(*f_im_img_16_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels); + i_img *(*f_im_img_double_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels); + i_img *(*f_im_img_pal_new)(im_context_t ctx, i_img_dim xsize, i_img_dim ysize, int channels, int maxpal); + + void (*f_im_clear_error)(im_context_t ctx); + void (*f_im_push_error)(im_context_t ctx, int code, char const *msg); + void (*f_im_push_errorvf)(im_context_t ctx, int code, char const *fmt, va_list); + void (*f_im_push_errorf)(im_context_t , int code, char const *fmt, ...); + + int (*f_im_set_image_file_limits)(im_context_t ctx, i_img_dim width, i_img_dim height, size_t bytes); + int (*f_im_get_image_file_limits)(im_context_t ctx, i_img_dim *width, i_img_dim *height, size_t *bytes); + int (*f_im_int_check_image_file_limits)(im_context_t ctx, i_img_dim width, i_img_dim height, int channels, size_t sample_size); + + i_img *(*f_im_img_alloc)(im_context_t ctx); + void (*f_im_img_init)(im_context_t ctx, i_img *); + i_io_glue_t *(*f_im_io_new_fd)(im_context_t ctx, int fd); i_io_glue_t *(*f_im_io_new_bufchain)(im_context_t ctx); i_io_glue_t *(*f_im_io_new_buffer)(im_context_t ctx, const char *data, size_t len, i_io_closebufp_t closecb, void *closedata); i_io_glue_t *(*f_im_io_new_cb)(im_context_t ctx, void *p, i_io_readl_t readcb, i_io_writel_t writecb, i_io_seekl_t seekcb, i_io_closel_t closecb, i_io_destroyl_t destroycb); - size_t (*f_io_slurp)(i_io_glue_t *ig, unsigned char **c); - void (*f_io_glue_destroy)(i_io_glue_t *ig); - /* IMAGER_API_LEVEL 8 functions will be added here */ im_context_t (*f_im_get_context)(void); - void (*f_im_push_errorf)(im_context_t , int code, char const *fmt, ...); void (*f_im_lhead)( im_context_t, const char *file, int line ); 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); -- 2.39.5