From 4120f7b2966ddb840d88359219c37815fdc449a7 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 28 Mar 2011 16:03:31 +0100 Subject: [PATCH] cleanup util just a few little things left, yay --- TODO | 5 + libvips/include/vips/dispatch.h | 2 +- libvips/include/vips/format.h | 2 +- libvips/include/vips/internal.h | 5 +- libvips/include/vips/object.h | 2 +- libvips/include/vips/util.h | 97 +++--- libvips/include/vips/vector.h | 2 +- libvips/include/vips/vips7compat.h | 47 +++ libvips/iofuncs/buf.c | 6 +- libvips/iofuncs/buffer.c | 4 +- libvips/iofuncs/generate.c | 24 +- libvips/iofuncs/header.c | 40 ++- libvips/iofuncs/image.c | 26 +- libvips/iofuncs/init.c | 40 +-- libvips/iofuncs/object.c | 10 +- libvips/iofuncs/sinkscreen.c | 4 +- libvips/iofuncs/util.c | 529 +++++++++++++++-------------- libvips/iofuncs/vector.c | 14 +- libvips/iofuncs/vips.c | 38 +-- libvips/iofuncs/window.c | 22 +- 20 files changed, 489 insertions(+), 430 deletions(-) diff --git a/TODO b/TODO index c1ecfda6..d7bb65d2 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,9 @@ - work though headers making sure old im_ stuff is gone + + especially internal.h / private.h seem to have a lot of junk in them + + im__tile_width etc. need moving, see init.c + - add MATLAB write diff --git a/libvips/include/vips/dispatch.h b/libvips/include/vips/dispatch.h index e9605601..5aade528 100644 --- a/libvips/include/vips/dispatch.h +++ b/libvips/include/vips/dispatch.h @@ -274,7 +274,7 @@ int im_close_plugins( void ); /* Loop over all loaded packages. */ -void *im_map_packages( VSListMap2Fn fn, void *a ); +void *im_map_packages( VipsSListMap2Fn fn, void *a ); /* Convenience functions for finding packages, functions, etc. */ diff --git a/libvips/include/vips/format.h b/libvips/include/vips/format.h index 6e814b55..193e83c2 100644 --- a/libvips/include/vips/format.h +++ b/libvips/include/vips/format.h @@ -108,7 +108,7 @@ GType vips_format_get_type( void ); /* Map over and find formats. This uses type introspection to loop over * subclasses of VipsFormat. */ -void *vips_format_map( VSListMap2Fn fn, void *a, void *b ); +void *vips_format_map( VipsSListMap2Fn fn, void *a, void *b ); VipsFormatClass *vips_format_for_file( const char *filename ); VipsFormatClass *vips_format_for_name( const char *filename ); diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index feb7d570..aba3fd8e 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -96,7 +96,6 @@ int vips__write_header_bytes( VipsImage *im, unsigned char *to ); int im__ftruncate( int fd, gint64 pos ); int im__seek( int fd, gint64 pos ); -int im__get_bytes( const char *filename, unsigned char buf[], int len ); int im__open_image_file( const char * ); void im__format_init( void ); @@ -125,7 +124,7 @@ VipsImage *im__convert_saveable( VipsImage *in, im__saveable_t saveable, int format_table[10] ); void vips__link_break_all( VipsImage *im ); -void *vips__link_map( VipsImage *im, VSListMap2Fn fn, void *a, void *b ); +void *vips__link_map( VipsImage *im, VipsSListMap2Fn fn, void *a, void *b ); GValue *im__gvalue_ref_string_new( const char *text ); void im__gslist_gvalue_free( GSList *list ); @@ -133,7 +132,7 @@ GSList *im__gslist_gvalue_copy( const GSList *list ); GSList *im__gslist_gvalue_merge( GSList *a, const GSList *b ); char *im__gslist_gvalue_get( const GSList *list ); -void im__buffer_init( void ); +void vips__buffer_init( void ); int im__bandup( const char *domain, VipsImage *in, VipsImage *out, int n ); int im__bandalike_vec( const char *domain, VipsImage **in, VipsImage **out, int n ); diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 91f1147d..73dd9d0c 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -276,7 +276,7 @@ VipsObject *vips_object_new( GType type, VipsObject *vips_object_new_from_string( const char *base, const char *str ); void vips_object_to_string( VipsObject *object, VipsBuf *buf ); -void *vips_object_map( VSListMap2Fn fn, void *a, void *b ); +void *vips_object_map( VipsSListMap2Fn fn, void *a, void *b ); typedef void *(*VipsTypeMap)( GType, void * ); typedef void *(*VipsTypeMap2)( GType, void *, void * ); diff --git a/libvips/include/vips/util.h b/libvips/include/vips/util.h index b34c0ccb..5d8a499a 100644 --- a/libvips/include/vips/util.h +++ b/libvips/include/vips/util.h @@ -162,57 +162,67 @@ G_STMT_START { \ (g_enum_get_value_by_nick( g_type_class_ref( ENUM ), STR ) || \ g_enum_get_value_by_name( g_type_class_ref( ENUM ), STR )) -/* strtok replacement. - */ -char *im__break_token( char *str, char *brk ); - /* Like GFunc, but return a value. */ -typedef void *(*VSListMap2Fn)( void *, void *, void * ); -typedef void *(*VSListMap4Fn)( void *, void *, void *, void *, void * ); -typedef void *(*VSListFold2Fn)( void *, void *, void *, void * ); +typedef void *(*VipsSListMap2Fn)( void *, void *, void * ); +typedef void *(*VipsSListMap4Fn)( void *, void *, void *, void *, void * ); +typedef void *(*VipsSListFold2Fn)( void *, void *, void *, void * ); -gboolean im_slist_equal( GSList *l1, GSList *l2 ); -void *im_slist_map2( GSList *list, VSListMap2Fn fn, void *a, void *b ); -void *im_slist_map2_rev( GSList *list, VSListMap2Fn fn, void *a, void *b ); -void *im_slist_map4( GSList *list, - VSListMap4Fn fn, void *a, void *b, void *c, void *d ); -void *im_slist_fold2( GSList *list, void *start, - VSListFold2Fn fn, void *a, void *b ); -GSList *im_slist_filter( GSList *list, VSListMap2Fn fn, void *a, void *b ); -void im_slist_free_all( GSList *list ); +gboolean vips_slist_equal( GSList *l1, GSList *l2 ); +void *vips_slist_map2( GSList *list, VipsSListMap2Fn fn, void *a, void *b ); +void *vips_slist_map2_rev( GSList *list, VipsSListMap2Fn fn, void *a, void *b ); +void *vips_slist_map4( GSList *list, + VipsSListMap4Fn fn, void *a, void *b, void *c, void *d ); +void *vips_slist_fold2( GSList *list, void *start, + VipsSListFold2Fn fn, void *a, void *b ); +GSList *vips_slist_filter( GSList *list, VipsSListMap2Fn fn, void *a, void *b ); +void vips_slist_free_all( GSList *list ); +void *vips_map_equal( void *a, void *b ); -void *im_map_equal( void *a, void *b ); +void *vips_hash_table_map( GHashTable *hash, VipsSListMap2Fn fn, void *a, void *b ); -void *im_hash_table_map( GHashTable *hash, VSListMap2Fn fn, void *a, void *b ); +char *vips_strncpy( char *dest, const char *src, int n ); +char *vips_strrstr( const char *haystack, const char *needle ); +gboolean vips_ispostfix( const char *a, const char *b ); +gboolean vips_isprefix( const char *a, const char *b ); +char *vips_break_token( char *str, const char *brk ); -char *im_strncpy( char *dest, const char *src, int n ); -char *im_strrstr( const char *haystack, const char *needle ); -gboolean im_ispostfix( const char *a, const char *b ); -gboolean im_isprefix( const char *a, const char *b ); -int im_vsnprintf( char *str, size_t size, const char *format, va_list ap ); -int im_snprintf( char *str, size_t size, const char *format, ... ) +int vips_vsnprintf( char *str, size_t size, const char *format, va_list ap ); +int vips_snprintf( char *str, size_t size, const char *format, ... ) __attribute__((format(printf, 3, 4))); -char *im_break_token( char *str, const char *brk ); -const char *im_skip_dir( const char *filename ); -void im_filename_split( const char *path, char *name, char *mode ); -void im_filename_suffix( const char *path, char *suffix ); -int im_filename_suffix_match( const char *path, const char *suffixes[] ); -char *im_getnextoption( char **in ); -char *im_getsuboption( const char *buf ); +void vips_filename_split( const char *path, char *name, char *mode ); +const char *vips_skip_dir( const char *filename ); +void vips_filename_suffix( const char *path, char *suffix ); +int vips_filename_suffix_match( const char *path, const char *suffixes[] ); +char *vips_getnextoption( char **in ); +char *vips_getsuboption( const char *buf ); -gint64 im_file_length( int fd ); -int im__write( int fd, const void *buf, size_t count ); +gint64 vips_file_length( int fd ); +int vips__write( int fd, const void *buf, size_t count ); -FILE *im__file_open_read( const char *filename, +FILE *vips__file_open_read( const char *filename, const char *fallback_dir, gboolean text_mode ); -FILE *im__file_open_write( const char *filename, +FILE *vips__file_open_write( const char *filename, gboolean text_mode ); -char *im__file_read( FILE *fp, const char *name, unsigned int *length_out ); -char *im__file_read_name( const char *name, const char *fallback_dir, +char *vips__file_read( FILE *fp, const char *name, unsigned int *length_out ); +char *vips__file_read_name( const char *name, const char *fallback_dir, unsigned int *length_out ); -int im__file_write( void *data, size_t size, size_t nmemb, FILE *stream ); +int vips__file_write( void *data, size_t size, size_t nmemb, FILE *stream ); +int vips__get_bytes( const char *filename, unsigned char buf[], int len ); + +GValue *vips__gvalue_ref_string_new( const char *text ); +void vips__gslist_gvalue_free( GSList *list ); +GSList *vips__gslist_gvalue_copy( const GSList *list ); +GSList *vips__gslist_gvalue_merge( GSList *a, const GSList *b ); +char *vips__gslist_gvalue_get( const GSList *list ); + +int vips__seek( int fd, gint64 pos ); +int vips__ftruncate( int fd, gint64 pos ); +int vips_existsf( const char *name, ... ) + __attribute__((format(printf, 1, 2))); +FILE *vips_popenf( const char *fmt, const char *mode, ... ) + __attribute__((format(printf, 1, 3))); typedef enum { VIPS_TOKEN_LEFT = 1, /* ({[ */ @@ -229,15 +239,10 @@ const char *vips__token_must( const char *buffer, VipsToken *token, const char *vips__token_need( const char *buffer, VipsToken need_token, char *string, int size ); -int im_existsf( const char *name, ... ) - __attribute__((format(printf, 1, 2))); -FILE *im_popenf( const char *fmt, const char *mode, ... ) - __attribute__((format(printf, 1, 3))); -int im_ispoweroftwo( int p ); -int im_isvips( const char *filename ); -int im_amiMSBfirst( void ); +int vips_ispoweroftwo( int p ); +int vips_amiMSBfirst( void ); -char *im__temp_name( const char *format ); +char *vips__temp_name( const char *format ); void vips__change_suffix( const char *name, char *out, int mx, const char *new_suff, const char **olds, int nolds ); diff --git a/libvips/include/vips/vector.h b/libvips/include/vips/vector.h index 9aeb6593..76ecad6b 100644 --- a/libvips/include/vips/vector.h +++ b/libvips/include/vips/vector.h @@ -97,7 +97,7 @@ typedef struct { /* Set from the command-line. */ -extern gboolean im__vector_enabled; +extern gboolean vips__vector_enabled; void vips_vector_init( void ); gboolean vips_vector_get_enabled( void ); diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 8ee4016d..bfefd691 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -426,6 +426,53 @@ int im_wrapmany( VipsImage **in, VipsImage *out, #define im__read_header_bytes vips__read_header_bytes #define im__write_header_bytes vips__write_header_bytes +#define VSListMap2Fn VipsSListMap2Fn +#define VSListMap4Fn VipsSListMap4Fn +#define VSListFold2Fn VipsSListFold2Fn + +#define im_slist_equal vips_slist_equal +#define im_slist_map2 vips_slist_map2 +#define im_slist_map2_rev vips_slist_map2_rev +#define im_slist_map4 vips_slist_map4 +#define im_slist_fold2 vips_slist_fold2 +#define im_slist_filter vips_slist_filter +#define im_slist_free_all vips_slist_free_all +#define im_map_equal vips_map_equal +#define im_hash_table_map vips_hash_table_map +#define im_strncpy vips_strncpy +#define im_strrstr vips_strrstr +#define im_ispostfix vips_ispostfix +#define im_isprefix vips_isprefix +#define im_break_token vips_break_token +#define im_vsnprintf vips_vsnprintf +#define im_snprintf vips_snprintf +#define im_filename_split vips_filename_split +#define im_skip_dir vips_skip_dir +#define im_filename_suffix vips_filename_suffix +#define im_filename_suffix_match vips_filename_suffix_match +#define im_getnextoption vips_getnextoption +#define im_getsuboption vips_getsuboption +#define im_file_length vips_file_length +#define im__write vips__write +#define im__file_open_read vips__file_open_read +#define im__file_open_write vips__file_open_write +#define im__file_read vips__file_read +#define im__file_read_name vips__file_read_name +#define im__file_write vips__file_write +#define im__get_bytes vips__get_bytes +#define im__gvalue_ref_string_new vips__gvalue_ref_string_new +#define im__gslist_gvalue_free vips__gslist_gvalue_free +#define im__gslist_gvalue_copy vips__gslist_gvalue_copy +#define im__gslist_gvalue_merge vips__gslist_gvalue_merge +#define im__gslist_gvalue_get vips__gslist_gvalue_get +#define im__seek vips__seek +#define im__ftruncate vips__ftruncate +#define im_existsf vips_existsf +#define im_popenf vips_popenf +#define im_ispoweroftwo vips_ispoweroftwo +#define im_amiMSBfirst vips_amiMSBfirst +#define im__temp_name vips__temp_name + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/iofuncs/buf.c b/libvips/iofuncs/buf.c index 86650f4a..a09d45f1 100644 --- a/libvips/iofuncs/buf.c +++ b/libvips/iofuncs/buf.c @@ -363,7 +363,7 @@ vips_buf_change( VipsBuf *buf, const char *old, const char *new ) /* Find pos of old. */ for( i = buf->i - olen; i > 0; i-- ) - if( im_isprefix( old, buf->base + i ) ) + if( vips_isprefix( old, buf->base + i ) ) break; g_assert( i >= 0 ); @@ -419,7 +419,7 @@ vips_buf_appendf( VipsBuf *buf, const char *fmt, ... ) va_list ap; va_start( ap, fmt ); - (void) im_vsnprintf( str, MAX_STRSIZE, fmt, ap ); + (void) vips_vsnprintf( str, MAX_STRSIZE, fmt, ap ); va_end( ap ); return( vips_buf_appends( buf, str ) ); @@ -440,7 +440,7 @@ vips_buf_vappendf( VipsBuf *buf, const char *fmt, va_list ap ) { char str[MAX_STRSIZE]; - (void) im_vsnprintf( str, MAX_STRSIZE, fmt, ap ); + (void) vips_vsnprintf( str, MAX_STRSIZE, fmt, ap ); return( vips_buf_appends( buf, str ) ); } diff --git a/libvips/iofuncs/buffer.c b/libvips/iofuncs/buffer.c index affe4f34..5da194fd 100644 --- a/libvips/iofuncs/buffer.c +++ b/libvips/iofuncs/buffer.c @@ -369,7 +369,7 @@ buffer_find( VipsImage *im, VipsRect *r ) p = cache_list ? cache_list->buffers : NULL; /* This needs to be quick :-( don't use - * im_slist_map2()/vips_rect_includesrect(), do the search inline. + * vips_slist_map2()/vips_rect_includesrect(), do the search inline. * * FIXME we return the first enclosing buffer, perhaps we should * search for the largest? @@ -479,7 +479,7 @@ vips_buffer_print( VipsBuffer *buffer ) /* Init the buffer cache system. */ void -im__buffer_init( void ) +vips__buffer_init( void ) { #ifdef HAVE_THREADS if( !thread_buffer_cache_key ) diff --git a/libvips/iofuncs/generate.c b/libvips/iofuncs/generate.c index 7da0dcd3..fc70787e 100644 --- a/libvips/iofuncs/generate.c +++ b/libvips/iofuncs/generate.c @@ -176,10 +176,10 @@ vips__link_break_rev( VipsImage *image_down, VipsImage *image_up ) void vips__link_break_all( VipsImage *image ) { - im_slist_map2( image->upstream, - (VSListMap2Fn) vips__link_break, image, NULL ); - im_slist_map2( image->downstream, - (VSListMap2Fn) vips__link_break_rev, image, NULL ); + vips_slist_map2( image->upstream, + (VipsSListMap2Fn) vips__link_break, image, NULL ); + vips_slist_map2( image->downstream, + (VipsSListMap2Fn) vips__link_break_rev, image, NULL ); g_assert( !image->upstream ); g_assert( !image->downstream ); @@ -187,7 +187,7 @@ vips__link_break_all( VipsImage *image ) static void * vips__link_mapp( VipsImage *image, - VSListMap2Fn fn, int *serial, void *a, void *b ) + VipsSListMap2Fn fn, int *serial, void *a, void *b ) { void *res; @@ -200,8 +200,8 @@ vips__link_mapp( VipsImage *image, if( (res = fn( image, a, b )) ) return( res ); - return( im_slist_map4( image->downstream, - (VSListMap4Fn) vips__link_mapp, fn, serial, a, b ) ); + return( vips_slist_map4( image->downstream, + (VipsSListMap4Fn) vips__link_mapp, fn, serial, a, b ) ); } static void * @@ -215,7 +215,7 @@ vips__link_map_cb( VipsImage *image, GSList **images ) /* Apply a function to an image and all downstream images, direct and indirect. */ void * -vips__link_map( VipsImage *image, VSListMap2Fn fn, void *a, void *b ) +vips__link_map( VipsImage *image, VipsSListMap2Fn fn, void *a, void *b ) { static int serial = 0; @@ -232,11 +232,11 @@ vips__link_map( VipsImage *image, VSListMap2Fn fn, void *a, void *b ) serial += 1; images = NULL; vips__link_mapp( image, - (VSListMap2Fn) vips__link_map_cb, &serial, &images, NULL ); + (VipsSListMap2Fn) vips__link_map_cb, &serial, &images, NULL ); for( p = images; p; p = p->next ) g_object_ref( p->data ); - result = im_slist_map2( images, fn, a, b ); + result = vips_slist_map2( images, fn, a, b ); for( p = images; p; p = p->next ) g_object_unref( p->data ); g_slist_free( images ); @@ -431,7 +431,7 @@ vips_stop_many( void *seq, void *a, void *b ) * Start function for many images in. @a is a pointer to * a %NULL-terminated array of input images. * - * See also: vips_image_generate(), im_allocate_input_array() + * See also: vips_image_generate(), vips_allocate_input_array() */ void * vips_start_many( VipsImage *out, void *a, void *b ) @@ -607,7 +607,7 @@ vips_image_generate( VipsImage *image, if( !image->hint_set ) { vips_error( "vips_image_generate", - "%s", _( "im_demand_hint() not set" ) ); + "%s", _( "demand hint not set" ) ); return( -1 ); } diff --git a/libvips/iofuncs/header.c b/libvips/iofuncs/header.c index 451702d1..7cdd353a 100644 --- a/libvips/iofuncs/header.c +++ b/libvips/iofuncs/header.c @@ -86,7 +86,7 @@ * fields (see image), then search for * a metadata field of that name (see * meta). - * Use im_header_get_typeof() to test for the + * Use vips_image_get_typeof() to test for the * existance and #GType * of a header field. * @@ -259,8 +259,8 @@ meta_sanity( const VipsImage *im ) if( im->meta ) g_hash_table_foreach( im->meta, (GHFunc) meta_sanity_on_traverse, (void *) im ); - im_slist_map2( im->meta_traverse, - (VSListMap2Fn) meta_sanity_on_hash, (void *) im, NULL ); + vips_slist_map2( im->meta_traverse, + (VipsSListMap2Fn) meta_sanity_on_hash, (void *) im, NULL ); } #endif /*DEBUG*/ @@ -491,8 +491,8 @@ meta_cp( VipsImage *dst, const VipsImage *src ) /* Loop, copying fields. */ meta_init( dst ); - im_slist_map2( src->meta_traverse, - (VSListMap2Fn) meta_cp_field, dst, NULL ); + vips_slist_map2( src->meta_traverse, + (VipsSListMap2Fn) meta_cp_field, dst, NULL ); } return( 0 ); @@ -557,8 +557,8 @@ vips_image_copy_fields_array( VipsImage *out, VipsImage *in[] ) /* Merge hists first to last. */ for( i = 0; in[i]; i++ ) - out->history_list = im__gslist_gvalue_merge( out->history_list, - in[i]->history_list ); + out->history_list = vips__gslist_gvalue_merge( + out->history_list, in[i]->history_list ); return( 0 ); } @@ -681,12 +681,12 @@ vips_image_set( VipsImage *image, const char *field, GValue *value ) * but uninitialised. * * This will return -1 and add a message to the error buffer if the field - * does not exist. Use im_header_get_typeof() to test for the + * does not exist. Use vips_image_get_typeof() to test for the * existence * of a field first if you are not certain it will be there. * * For example, to read a double from an image (though of course you would use - * im_header_double() in practice): + * vips_image_get_double() in practice): * * |[ * GValue value = { 0 }; @@ -906,8 +906,8 @@ vips_image_map( VipsImage *image, VipsImageMapFn fn, void *a ) } if( image->meta_traverse && - (result = im_slist_map2( image->meta_traverse, - (VSListMap2Fn) vips_image_map_fn, fn, a )) ) + (result = vips_slist_map2( image->meta_traverse, + (VipsSListMap2Fn) vips_image_map_fn, fn, a )) ) return( result ); return( NULL ); @@ -1114,7 +1114,7 @@ transform_area_g_string( const GValue *src_value, GValue *dest_value ) char buf[256]; area = g_value_get_boxed( src_value ); - im_snprintf( buf, 256, "VIPS_TYPE_AREA, count = %d, data = %p", + vips_snprintf( buf, 256, "VIPS_TYPE_AREA, count = %d, data = %p", area->count, area->data ); g_value_set_string( dest_value, buf ); } @@ -1417,7 +1417,7 @@ transform_blob_g_string( const GValue *src_value, GValue *dest_value ) char buf[256]; blob = vips_blob_get( src_value, &blob_length ); - im_snprintf( buf, 256, "VIPS_TYPE_BLOB, data = %p, length = %zd", + vips_snprintf( buf, 256, "VIPS_TYPE_BLOB, data = %p, length = %zd", blob, blob_length ); g_value_set_string( dest_value, buf ); } @@ -1815,7 +1815,7 @@ vips_image_get_as_string( VipsImage *image, const char *field, char **out ) /** * vips_image_history_printf: - * @image: add history liine to this image + * @image: add history line to this image * @format: printf() format string * @Varargs: arguments to format string * @@ -1841,8 +1841,6 @@ vips_image_get_as_string( VipsImage *image, const char *field, char **out ) * the application level might involve many VIPS operations. History must be * recorded by the application. * - * See also: im_updatehist(). - * * Returns: 0 on success, -1 on error. */ int @@ -1856,7 +1854,7 @@ vips_image_history_printf( VipsImage *image, const char *fmt, ... ) * a bit. */ va_start( args, fmt ); - (void) im_vsnprintf( line, 4096 - 40, fmt, args ); + (void) vips_vsnprintf( line, 4096 - 40, fmt, args ); va_end( args ); strcat( line, " # " ); @@ -1867,12 +1865,12 @@ vips_image_history_printf( VipsImage *image, const char *fmt, ... ) line[strlen( line ) - 1] = '\0'; #ifdef DEBUG - printf( "im_histlin: adding:\n\t%s\nto history on image %p\n", - line, image ); + printf( "vips_image_history_printf: " + "adding:\n\t%s\nto history on image %p\n", line, image ); #endif /*DEBUG*/ image->history_list = g_slist_append( image->history_list, - im__gvalue_ref_string_new( line ) ); + vips__gvalue_ref_string_new( line ) ); return( 0 ); } @@ -1933,7 +1931,7 @@ const char * vips_image_get_history( VipsImage *image ) { if( !image->Hist ) - image->Hist = im__gslist_gvalue_get( image->history_list ); + image->Hist = vips__gslist_gvalue_get( image->history_list ); return( image->Hist ? image->Hist : "" ); } diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index ce0b2b0c..8231f4db 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -415,7 +415,7 @@ vips_image_finalize( GObject *gobject ) VIPS_FREEF( g_mutex_free, image->sslock ); VIPS_FREE( image->Hist ); - VIPS_FREEF( im__gslist_gvalue_free, image->history_list ); + VIPS_FREEF( vips__gslist_gvalue_free, image->history_list ); vips__meta_destroy( image ); G_OBJECT_CLASS( vips_image_parent_class )->finalize( gobject ); @@ -537,11 +537,11 @@ vips_image_sanity( VipsObject *object, VipsBuf *buf ) vips_buf_appends( buf, "bad resolution\n" ); } - if( im_slist_map2( image->upstream, - (VSListMap2Fn) vips_image_sanity_upstream, image, NULL ) ) + if( vips_slist_map2( image->upstream, + (VipsSListMap2Fn) vips_image_sanity_upstream, image, NULL ) ) vips_buf_appends( buf, "upstream broken\n" ); - if( im_slist_map2( image->downstream, - (VSListMap2Fn) vips_image_sanity_downstream, image, NULL ) ) + if( vips_slist_map2( image->downstream, + (VipsSListMap2Fn) vips_image_sanity_downstream, image, NULL ) ) vips_buf_appends( buf, "downstream broken\n" ); VIPS_OBJECT_CLASS( vips_image_parent_class )->sanity( object, buf ); @@ -928,7 +928,7 @@ vips_image_build( VipsObject *object ) VipsFormatFlags flags = vips_format_get_flags( format, filename ); gboolean native = (flags & VIPS_FORMAT_BIGENDIAN) == - im_amiMSBfirst(); + vips_amiMSBfirst(); if( native ) { if( vips_image_open_input( image ) ) @@ -1008,7 +1008,7 @@ vips_image_build( VipsObject *object ) /* Read the real file length and check against what we think * the size should be. */ - if( (image->file_length = im_file_length( image->fd )) == -1 ) + if( (image->file_length = vips_file_length( image->fd )) == -1 ) return( -1 ); /* Very common, so a special message. @@ -1066,8 +1066,8 @@ vips_image_real_invalidate( VipsImage *image ) VIPS_DEBUG_MSG( "vips_image_real_invalidate: %p\n", image ); g_mutex_lock( image->sslock ); - (void) im_slist_map2( image->regions, - (VSListMap2Fn) vips_region_invalidate, NULL, NULL ); + (void) vips_slist_map2( image->regions, + (VipsSListMap2Fn) vips_region_invalidate, NULL, NULL ); g_mutex_unlock( image->sslock ); } @@ -1245,7 +1245,7 @@ vips_image_init( VipsImage *image ) { /* Default to native order. */ - image->magic = im_amiMSBfirst() ? VIPS_MAGIC_SPARC : VIPS_MAGIC_INTEL; + image->magic = vips_amiMSBfirst() ? VIPS_MAGIC_SPARC : VIPS_MAGIC_INTEL; image->Xres = 1.0; image->Yres = 1.0; @@ -1296,7 +1296,7 @@ void vips_image_invalidate_all( VipsImage *image ) { (void) vips__link_map( image, - (VSListMap2Fn) vips_image_invalidate_all_cb, NULL, NULL ); + (VipsSListMap2Fn) vips_image_invalidate_all_cb, NULL, NULL ); } /* Attach a new time struct, if necessary, and reset it. @@ -1463,7 +1463,7 @@ vips_image_temp_name( void ) static int serial = 0; static char name[256]; - im_snprintf( name, 256, "temp-%d", serial++ ); + vips_snprintf( name, 256, "temp-%d", serial++ ); return( name ); } @@ -1718,7 +1718,7 @@ vips_image_new_disc_temp( const char *format ) char *name; VipsImage *image; - if( !(name = im__temp_name( format )) ) + if( !(name = vips__temp_name( format )) ) return( NULL ); if( !(image = vips_image_new_from_file( name, "w" )) ) { diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index 9c43069a..263629af 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -205,7 +205,7 @@ vips_init( const char *argv0 ) /* Get i18n .mo files from $VIPSHOME/share/locale/. */ - im_snprintf( name, 256, + vips_snprintf( name, 256, "%s" G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S "locale", prefix ); bindtextdomain( GETTEXT_PACKAGE, name ); @@ -237,7 +237,7 @@ vips_init( const char *argv0 ) /* Start up the buffer cache. */ - im__buffer_init(); + vips__buffer_init(); /* Get the run-time compiler going. */ @@ -289,7 +289,7 @@ static GOptionEntry option_entries[] = { &im__disc_threshold, N_( "image size above which to decompress to disc" ), NULL }, { "vips-novector", 't', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, - &im__vector_enabled, + &vips__vector_enabled, N_( "disable vectorised versions of operations" ), NULL }, { NULL } }; @@ -369,31 +369,31 @@ extract_prefix( const char *dir, const char *name ) /* Is dir relative? Prefix with cwd. */ if( !g_path_is_absolute( dir ) ) { - im_snprintf( edir, PATH_MAX, "%s" G_DIR_SEPARATOR_S "%s", + vips_snprintf( edir, PATH_MAX, "%s" G_DIR_SEPARATOR_S "%s", get_current_dir(), dir ); } else { - im_strncpy( edir, dir, PATH_MAX ); + vips_strncpy( edir, dir, PATH_MAX ); } /* Chop off the trailing prog name, plus the trailing * G_DIR_SEPARATOR_S. */ - if( !im_ispostfix( edir, name ) ) + if( !vips_ispostfix( edir, name ) ) return( NULL ); - im_strncpy( vname, edir, PATH_MAX ); + vips_strncpy( vname, edir, PATH_MAX ); vname[strlen( edir ) - strlen( name ) - 1] = '\0'; /* Remove any "/./", any trailing "/.", any trailing "/". */ for( i = 0; i < (int) strlen( vname ); i++ ) - if( im_isprefix( G_DIR_SEPARATOR_S "." G_DIR_SEPARATOR_S, + if( vips_isprefix( G_DIR_SEPARATOR_S "." G_DIR_SEPARATOR_S, vname + i ) ) memcpy( vname + i, vname + i + 2, strlen( vname + i + 2 ) + 1 ); - if( im_ispostfix( vname, G_DIR_SEPARATOR_S "." ) ) + if( vips_ispostfix( vname, G_DIR_SEPARATOR_S "." ) ) vname[strlen( vname ) - 2] = '\0'; - if( im_ispostfix( vname, G_DIR_SEPARATOR_S ) ) + if( vips_ispostfix( vname, G_DIR_SEPARATOR_S ) ) vname[strlen( vname ) - 1] = '\0'; #ifdef DEBUG @@ -402,7 +402,7 @@ extract_prefix( const char *dir, const char *name ) /* Ought to be a "/bin" at the end now. */ - if( !im_ispostfix( vname, G_DIR_SEPARATOR_S "bin" ) ) + if( !vips_ispostfix( vname, G_DIR_SEPARATOR_S "bin" ) ) return( NULL ); vname[strlen( vname ) - strlen( G_DIR_SEPARATOR_S "bin" )] = '\0'; @@ -422,12 +422,12 @@ scan_path( char *path, const char *name ) char *prefix; for( p = path; - (q = im_break_token( p, G_SEARCHPATH_SEPARATOR_S )); p = q ) { + (q = vips_break_token( p, G_SEARCHPATH_SEPARATOR_S )); p = q ) { char str[PATH_MAX]; /* Form complete path. */ - im_snprintf( str, PATH_MAX, + vips_snprintf( str, PATH_MAX, "%s" G_DIR_SEPARATOR_S "%s", p, name ); #ifdef DEBUG @@ -435,7 +435,7 @@ scan_path( char *path, const char *name ) p, name ); #endif /*DEBUG*/ - if( im_existsf( "%s", str ) && + if( vips_existsf( "%s", str ) && (prefix = extract_prefix( str, name )) ) { return( prefix ); } @@ -463,10 +463,10 @@ find_file( const char *name ) #ifdef OS_WIN32 /* Windows always searches '.' first, so prepend cwd to path. */ - im_snprintf( full_path, PATH_MAX, "%s" G_SEARCHPATH_SEPARATOR_S "%s", + vips_snprintf( full_path, PATH_MAX, "%s" G_SEARCHPATH_SEPARATOR_S "%s", get_current_dir(), path ); #else /*!OS_WIN32*/ - im_strncpy( full_path, path, PATH_MAX ); + vips_strncpy( full_path, path, PATH_MAX ); #endif /*OS_WIN32*/ if( (prefix = scan_path( full_path, name )) ) @@ -517,8 +517,8 @@ guess_prefix( const char *argv0, const char *name ) char full_path[PATH_MAX]; char resolved[PATH_MAX]; - im_snprintf( full_path, PATH_MAX, "%s" G_DIR_SEPARATOR_S "%s", - get_current_dir(), argv0 ); + vips_snprintf( full_path, PATH_MAX, + "%s" G_DIR_SEPARATOR_S "%s", get_current_dir(), argv0 ); if( realpath( full_path, resolved ) ) { if( (prefix = extract_prefix( resolved, name )) ) { @@ -576,7 +576,7 @@ vips_guess_prefix( const char *argv0, const char *env_name ) /* Get the program name from argv0. */ - p = im_skip_dir( argv0 ); + p = vips_skip_dir( argv0 ); /* Add the exe suffix, if it's missing. */ @@ -586,7 +586,7 @@ vips_guess_prefix( const char *argv0, const char *env_name ) vips__change_suffix( p, name, PATH_MAX, IM_EXEEXT, olds, 1 ); } else - im_strncpy( name, p, PATH_MAX ); + vips_strncpy( name, p, PATH_MAX ); #ifdef DEBUG printf( "vips_guess_prefix: argv0 = %s\n", argv0 ); diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 9b9b8090..a3311dac 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -1212,7 +1212,7 @@ vips_object_to_string( VipsObject *object, VipsBuf *buf ) } typedef struct { - VSListMap2Fn fn; + VipsSListMap2Fn fn; void *a; void *b; void *result; @@ -1226,7 +1226,7 @@ vips_object_map_sub( VipsObject *object, VipsObjectMapArgs *args ) } void * -vips_object_map( VSListMap2Fn fn, void *a, void *b ) +vips_object_map( VipsSListMap2Fn fn, void *a, void *b ) { VipsObjectMapArgs args; @@ -1391,7 +1391,8 @@ vips_object_print_all_cb( VipsObject *object ) void vips_object_print_all( void ) { - vips_object_map( (VSListMap2Fn) vips_object_print_all_cb, NULL, NULL ); + vips_object_map( + (VipsSListMap2Fn) vips_object_print_all_cb, NULL, NULL ); } static void * @@ -1405,5 +1406,6 @@ vips_object_sanity_all_cb( VipsObject *object ) void vips_object_sanity_all( void ) { - vips_object_map( (VSListMap2Fn) vips_object_sanity_all_cb, NULL, NULL ); + vips_object_map( + (VipsSListMap2Fn) vips_object_sanity_all_cb, NULL, NULL ); } diff --git a/libvips/iofuncs/sinkscreen.c b/libvips/iofuncs/sinkscreen.c index 79a89cf3..f98ff038 100644 --- a/libvips/iofuncs/sinkscreen.c +++ b/libvips/iofuncs/sinkscreen.c @@ -235,7 +235,7 @@ render_free( Render *render ) g_mutex_free( render->ref_count_lock ); g_mutex_free( render->lock ); - im_slist_map2( render->all, (VSListMap2Fn) tile_free, NULL, NULL ); + vips_slist_map2( render->all, (VipsSListMap2Fn) tile_free, NULL, NULL ); VIPS_FREEF( g_slist_free, render->all ); render->ntiles = 0; VIPS_FREEF( g_slist_free, render->dirty ); @@ -537,7 +537,7 @@ render_thread_create( void ) render_thread_main, NULL, IM__DEFAULT_STACK_SIZE, TRUE, FALSE, G_THREAD_PRIORITY_NORMAL, NULL )) ) { - vips_error( "im_render", + vips_error( "sink_screen", "%s", _( "unable to create thread" ) ); return( -1 ); } diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index a03a069e..f3c8c7c4 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -67,7 +67,7 @@ /* Test two lists for eqality. */ gboolean -im_slist_equal( GSList *l1, GSList *l2 ) +vips_slist_equal( GSList *l1, GSList *l2 ) { while( l1 && l2 ) { if( l1->data != l2->data ) @@ -86,7 +86,7 @@ im_slist_equal( GSList *l1, GSList *l2 ) /* Map over an slist. _copy() the list in case the callback changes it. */ void * -im_slist_map2( GSList *list, VSListMap2Fn fn, void *a, void *b ) +vips_slist_map2( GSList *list, VipsSListMap2Fn fn, void *a, void *b ) { GSList *copy; GSList *i; @@ -101,28 +101,10 @@ im_slist_map2( GSList *list, VSListMap2Fn fn, void *a, void *b ) return( result ); } -void * -im_slist_map4( GSList *list, - VSListMap4Fn fn, void *a, void *b, void *c, void *d ) -{ - GSList *copy; - GSList *i; - void *result; - - copy = g_slist_copy( list ); - result = NULL; - for( i = copy; - i && !(result = fn( i->data, a, b, c, d )); i = i->next ) - ; - g_slist_free( copy ); - - return( result ); -} - /* Map backwards. We _reverse() rather than recurse and unwind to save stack. */ void * -im_slist_map2_rev( GSList *list, VSListMap2Fn fn, void *a, void *b ) +vips_slist_map2_rev( GSList *list, VipsSListMap2Fn fn, void *a, void *b ) { GSList *copy; GSList *i; @@ -139,16 +121,26 @@ im_slist_map2_rev( GSList *list, VSListMap2Fn fn, void *a, void *b ) } void * -im_map_equal( void *a, void *b ) +vips_slist_map4( GSList *list, + VipsSListMap4Fn fn, void *a, void *b, void *c, void *d ) { - if( a == b ) - return( a ); + GSList *copy; + GSList *i; + void *result; - return( NULL ); + copy = g_slist_copy( list ); + result = NULL; + for( i = copy; + i && !(result = fn( i->data, a, b, c, d )); i = i->next ) + ; + g_slist_free( copy ); + + return( result ); } void * -im_slist_fold2( GSList *list, void *start, VSListFold2Fn fn, void *a, void *b ) +vips_slist_fold2( GSList *list, void *start, + VipsSListFold2Fn fn, void *a, void *b ) { void *c; GSList *this, *next; @@ -163,25 +155,10 @@ im_slist_fold2( GSList *list, void *start, VSListFold2Fn fn, void *a, void *b ) return( c ); } -static void -im_slist_free_all_cb( void * thing, void * dummy ) -{ - vips_free( thing ); -} - -/* Free a g_slist of things which need vips_free()ing. - */ -void -im_slist_free_all( GSList *list ) -{ - g_slist_foreach( list, im_slist_free_all_cb, NULL ); - g_slist_free( list ); -} - /* Remove all occurences of an item from a list. */ GSList * -im_slist_filter( GSList *list, VSListMap2Fn fn, void *a, void *b ) +vips_slist_filter( GSList *list, VipsSListMap2Fn fn, void *a, void *b ) { GSList *tmp; GSList *prev; @@ -211,15 +188,39 @@ im_slist_filter( GSList *list, VSListMap2Fn fn, void *a, void *b ) return( list ); } +static void +vips_slist_free_all_cb( void * thing, void * dummy ) +{ + vips_free( thing ); +} + +/* Free a g_slist of things which need vips_free()ing. + */ +void +vips_slist_free_all( GSList *list ) +{ + g_slist_foreach( list, vips_slist_free_all_cb, NULL ); + g_slist_free( list ); +} + +void * +vips_map_equal( void *a, void *b ) +{ + if( a == b ) + return( a ); + + return( NULL ); +} + typedef struct { void *a; void *b; - VSListMap2Fn fn; + VipsSListMap2Fn fn; void *result; } Pair; static gboolean -im_hash_table_predicate( const char *key, void *value, Pair *pair ) +vips_hash_table_predicate( const char *key, void *value, Pair *pair ) { return( (pair->result == pair->fn( value, pair->a, pair->b )) ); } @@ -227,7 +228,7 @@ im_hash_table_predicate( const char *key, void *value, Pair *pair ) /* Like slist map, but for a hash table. */ void * -im_hash_table_map( GHashTable *hash, VSListMap2Fn fn, void *a, void *b ) +vips_hash_table_map( GHashTable *hash, VipsSListMap2Fn fn, void *a, void *b ) { Pair pair; @@ -236,7 +237,7 @@ im_hash_table_map( GHashTable *hash, VSListMap2Fn fn, void *a, void *b ) pair.fn = fn; pair.result = NULL; - g_hash_table_find( hash, (GHRFunc) im_hash_table_predicate, &pair ); + g_hash_table_find( hash, (GHRFunc) vips_hash_table_predicate, &pair ); return( pair.result ); } @@ -244,7 +245,7 @@ im_hash_table_map( GHashTable *hash, VSListMap2Fn fn, void *a, void *b ) /* Like strncpy(), but always NULL-terminate, and don't pad with NULLs. */ char * -im_strncpy( char *dest, const char *src, int n ) +vips_strncpy( char *dest, const char *src, int n ) { int i; @@ -261,7 +262,7 @@ im_strncpy( char *dest, const char *src, int n ) /* Find the rightmost occurrence of needle in haystack. */ char * -im_strrstr( const char *haystack, const char *needle ) +vips_strrstr( const char *haystack, const char *needle ) { int haystack_len = strlen( haystack ); int needle_len = strlen( needle ); @@ -277,7 +278,7 @@ im_strrstr( const char *haystack, const char *needle ) /* Test for string b ends string a. */ gboolean -im_ispostfix( const char *a, const char *b ) +vips_ispostfix( const char *a, const char *b ) { int m = strlen( a ); int n = strlen( b ); @@ -291,7 +292,7 @@ im_ispostfix( const char *a, const char *b ) /* Test for string a starts string b. */ gboolean -im_isprefix( const char *a, const char *b ) +vips_isprefix( const char *a, const char *b ) { int n = strlen( a ); int m = strlen( b ); @@ -320,7 +321,7 @@ im_isprefix( const char *a, const char *b ) * int i; * int v[...]; * - * for( i = 0; (q = im_break_token( p, " " )); i++, p = q ) + * for( i = 0; (q = vips_break_token( p, " " )); i++, p = q ) * v[i] = atoi( p ); * * will set @@ -335,11 +336,11 @@ im_isprefix( const char *a, const char *b ) * int i; * int v[...]; * - * for( i = 0; p; p = im_break_token( p, " " ) ) + * for( i = 0; p; p = vips_break_token( p, " " ) ) * v[i] = atoi( p ); */ char * -im_break_token( char *str, const char *brk ) +vips_break_token( char *str, const char *brk ) { char *p; @@ -378,7 +379,7 @@ im_break_token( char *str, const char *brk ) /* Wrapper over (v)snprintf() ... missing on old systems. */ int -im_vsnprintf( char *str, size_t size, const char *format, va_list ap ) +vips_vsnprintf( char *str, size_t size, const char *format, va_list ap ) { #ifdef HAVE_VSNPRINTF return( vsnprintf( str, size, format, ap ) ); @@ -398,20 +399,20 @@ im_vsnprintf( char *str, size_t size, const char *format, va_list ap ) "(%d bytes written to buffer of %d bytes)", n, MAX_BUF ); - im_strncpy( str, buf, size ); + vips_strncpy( str, buf, size ); return( n ); #endif /*HAVE_VSNPRINTF*/ } int -im_snprintf( char *str, size_t size, const char *format, ... ) +vips_snprintf( char *str, size_t size, const char *format, ... ) { va_list ap; int n; va_start( ap, format ); - n = im_vsnprintf( str, size, format, ap ); + n = vips_vsnprintf( str, size, format, ap ); va_end( ap ); return( n ); @@ -428,11 +429,11 @@ im_snprintf( char *str, size_t size, const char *format, ... ) * */ void -im_filename_split( const char *path, char *name, char *mode ) +vips_filename_split( const char *path, char *name, char *mode ) { char *p; - im_strncpy( name, path, FILENAME_MAX ); + vips_strncpy( name, path, FILENAME_MAX ); /* Search back towards start stopping at each ':' char. */ @@ -448,7 +449,7 @@ im_filename_split( const char *path, char *name, char *mode ) } if( *p == ':' ) { - im_strncpy( mode, p + 1, FILENAME_MAX ); + vips_strncpy( mode, p + 1, FILENAME_MAX ); *p = '\0'; } else @@ -464,7 +465,7 @@ im_filename_split( const char *path, char *name, char *mode ) * either, just return the filename. */ const char * -im_skip_dir( const char *path ) +vips_skip_dir( const char *path ) { char name[FILENAME_MAX]; char mode[FILENAME_MAX]; @@ -477,7 +478,7 @@ im_skip_dir( const char *path ) /* Remove any trailing save modifiers: we don't want '/' or '\' in the * modifier confusing us. */ - im_filename_split( path, name, mode ); + vips_filename_split( path, name, mode ); /* The '\0' char at the end of the string. */ @@ -499,13 +500,13 @@ im_skip_dir( const char *path ) * FILENAME_MAX chars. Include the "." character, if any. */ void -im_filename_suffix( const char *path, char *suffix ) +vips_filename_suffix( const char *path, char *suffix ) { char name[FILENAME_MAX]; char mode[FILENAME_MAX]; char *p; - im_filename_split( path, name, mode ); + vips_filename_split( path, name, mode ); if( (p = strrchr( name, '.' )) ) strcpy( suffix, p ); else @@ -515,12 +516,12 @@ im_filename_suffix( const char *path, char *suffix ) /* Does a filename have one of a set of suffixes. Ignore case. */ int -im_filename_suffix_match( const char *path, const char *suffixes[] ) +vips_filename_suffix_match( const char *path, const char *suffixes[] ) { char suffix[FILENAME_MAX]; const char **p; - im_filename_suffix( path, suffix ); + vips_filename_suffix( path, suffix ); for( p = suffixes; *p; p++ ) if( g_ascii_strcasecmp( suffix, *p ) == 0 ) return( 1 ); @@ -533,7 +534,7 @@ im_filename_suffix_match( const char *path, const char *suffixes[] ) * missing). ',' characters inside options can be escaped with a '\'. */ char * -im_getnextoption( char **in ) +vips_getnextoption( char **in ) { char *p = *in; char *q = p; @@ -568,7 +569,7 @@ im_getnextoption( char **in ) /* Get a suboption string, or NULL. */ char * -im_getsuboption( const char *buf ) +vips_getsuboption( const char *buf ) { char *p, *q, *r; @@ -594,7 +595,7 @@ im_getsuboption( const char *buf ) /* Get file length ... 64-bitally. -1 for error. */ gint64 -im_file_length( int fd ) +vips_file_length( int fd ) { #ifdef OS_WIN32 struct _stati64 st; @@ -605,7 +606,7 @@ im_file_length( int fd ) if( fstat( fd, &st ) == -1 ) { #endif /*OS_WIN32*/ - vips_error_system( errno, "im_file_length", + vips_error_system( errno, "vips_file_length", "%s", _( "unable to get file stats" ) ); return( -1 ); } @@ -616,13 +617,13 @@ im_file_length( int fd ) /* Wrap write() up */ int -im__write( int fd, const void *buf, size_t count ) +vips__write( int fd, const void *buf, size_t count ) { do { size_t nwritten = write( fd, buf, count ); if( nwritten == (size_t) -1 ) { - vips_error_system( errno, "im__write", + vips_error_system( errno, "vips__write", "%s", _( "write failed" ) ); return( -1 ); } @@ -634,79 +635,6 @@ im__write( int fd, const void *buf, size_t count ) return( 0 ); } -/* Load up a file as a string. - */ -char * -im__file_read( FILE *fp, const char *filename, unsigned int *length_out ) -{ - long len; - size_t read; - char *str; - - /* Find length. - */ - fseek( fp, 0L, 2 ); - len = ftell( fp ); - if( len > 20 * 1024 * 1024 ) { - /* Seems crazy! - */ - vips_error( "im__file_read", _( "\"%s\" too long" ), filename ); - return( NULL ); - } - - if( len == -1 ) { - int size; - - /* Can't get length: read in chunks and realloc() to end of - * file. - */ - str = NULL; - len = 0; - size = 0; - do { - size += 1024; - if( !(str = realloc( str, size )) ) { - vips_error( "im__file_read", - "%s", _( "out of memory" ) ); - return( NULL ); - } - - /* -1 to allow space for an extra NULL we add later. - */ - read = fread( str + len, sizeof( char ), - (size - len - 1) / sizeof( char ), - fp ); - len += read; - } while( !feof( fp ) ); - -#ifdef DEBUG - printf( "read %ld bytes from unseekable stream\n", len ); -#endif /*DEBUG*/ - } - else { - /* Allocate memory and fill. - */ - if( !(str = vips_malloc( NULL, len + 1 )) ) - return( NULL ); - rewind( fp ); - read = fread( str, sizeof( char ), (size_t) len, fp ); - if( read != (size_t) len ) { - vips_free( str ); - vips_error( "im__file_read", - _( "error reading from file \"%s\"" ), - filename ); - return( NULL ); - } - } - - str[len] = '\0'; - - if( length_out ) - *length_out = len; - - return( str ); -} - /* Does a filename contain a directory separator? */ static gboolean @@ -730,7 +658,7 @@ filename_hasdir( const char *filename ) * directory separator, we try looking in the fallback dir. */ FILE * -im__file_open_read( const char *filename, const char *fallback_dir, +vips__file_open_read( const char *filename, const char *fallback_dir, gboolean text_mode ) { char *mode; @@ -759,14 +687,14 @@ im__file_open_read( const char *filename, const char *fallback_dir, return( fp ); } - vips_error( "im__file_open_read", + vips_error( "vips__file_open_read", _( "unable to open file \"%s\" for reading" ), filename ); return( NULL ); } FILE * -im__file_open_write( const char *filename, gboolean text_mode ) +vips__file_open_write( const char *filename, gboolean text_mode ) { char *mode; FILE *fp; @@ -781,7 +709,7 @@ im__file_open_write( const char *filename, gboolean text_mode ) #endif /*BINARY_OPEN*/ if( !(fp = fopen( filename, mode )) ) { - vips_error( "im__file_open_write", + vips_error( "vips__file_open_write", _( "unable to open file \"%s\" for writing" ), filename ); return( NULL ); @@ -790,19 +718,93 @@ im__file_open_write( const char *filename, gboolean text_mode ) return( fp ); } +/* Load up a file as a string. + */ +char * +vips__file_read( FILE *fp, const char *filename, unsigned int *length_out ) +{ + long len; + size_t read; + char *str; + + /* Find length. + */ + fseek( fp, 0L, 2 ); + len = ftell( fp ); + if( len > 20 * 1024 * 1024 ) { + /* Seems crazy! + */ + vips_error( "vips__file_read", + _( "\"%s\" too long" ), filename ); + return( NULL ); + } + + if( len == -1 ) { + int size; + + /* Can't get length: read in chunks and realloc() to end of + * file. + */ + str = NULL; + len = 0; + size = 0; + do { + size += 1024; + if( !(str = realloc( str, size )) ) { + vips_error( "vips__file_read", + "%s", _( "out of memory" ) ); + return( NULL ); + } + + /* -1 to allow space for an extra NULL we add later. + */ + read = fread( str + len, sizeof( char ), + (size - len - 1) / sizeof( char ), + fp ); + len += read; + } while( !feof( fp ) ); + +#ifdef DEBUG + printf( "read %ld bytes from unseekable stream\n", len ); +#endif /*DEBUG*/ + } + else { + /* Allocate memory and fill. + */ + if( !(str = vips_malloc( NULL, len + 1 )) ) + return( NULL ); + rewind( fp ); + read = fread( str, sizeof( char ), (size_t) len, fp ); + if( read != (size_t) len ) { + vips_free( str ); + vips_error( "vips__file_read", + _( "error reading from file \"%s\"" ), + filename ); + return( NULL ); + } + } + + str[len] = '\0'; + + if( length_out ) + *length_out = len; + + return( str ); +} + /* Load from a filename as a string. Used for things like reading in ICC * profiles, ie. binary objects. */ char * -im__file_read_name( const char *filename, const char *fallback_dir, +vips__file_read_name( const char *filename, const char *fallback_dir, unsigned int *length_out ) { FILE *fp; char *buffer; - if( !(fp = im__file_open_read( filename, fallback_dir, FALSE )) ) + if( !(fp = vips__file_open_read( filename, fallback_dir, FALSE )) ) return( NULL ); - if( !(buffer = im__file_read( fp, filename, length_out )) ) { + if( !(buffer = vips__file_read( fp, filename, length_out )) ) { fclose( fp ); return( NULL ); } @@ -811,10 +813,56 @@ im__file_read_name( const char *filename, const char *fallback_dir, return( buffer ); } +/* Like fwrite(), but returns non-zero on error and sets error message. + */ +int +vips__file_write( void *data, size_t size, size_t nmemb, FILE *stream ) +{ + size_t n; + + if( !data ) + return( 0 ); + + if( (n = fwrite( data, size, nmemb, stream )) != nmemb ) { + vips_error( "vips__file_write", + _( "writing error (%zd out of %zd blocks written) " + "... disc full?" ), n, nmemb ); + return( -1 ); + } + + return( 0 ); +} + +/* Read a few bytes from the start of a file. For sniffing file types. + */ +int +vips__get_bytes( const char *filename, unsigned char buf[], int len ) +{ + int fd; + + /* File may not even exist (for tmp images for example!) + * so no hasty messages. And the file might be truncated, so no error + * on read either. + */ +#ifdef BINARY_OPEN + if( (fd = open( filename, O_RDONLY | O_BINARY )) == -1 ) +#else /*BINARY_OPEN*/ + if( (fd = open( filename, O_RDONLY )) == -1 ) +#endif /*BINARY_OPEN*/ + return( 0 ); + if( read( fd, buf, len ) != len ) { + close( fd ); + return( 0 ); + } + close( fd ); + + return( 1 ); +} + /* Alloc/free a GValue. */ static GValue * -im__gvalue_new( GType type ) +vips__gvalue_new( GType type ) { GValue *value; @@ -825,29 +873,29 @@ im__gvalue_new( GType type ) } static GValue * -im__gvalue_copy( GValue *value ) +vips__gvalue_copy( GValue *value ) { GValue *value_copy; - value_copy = im__gvalue_new( G_VALUE_TYPE( value ) ); + value_copy = vips__gvalue_new( G_VALUE_TYPE( value ) ); g_value_copy( value, value_copy ); return( value_copy ); } static void -im__gvalue_free( GValue *value ) +vips__gvalue_free( GValue *value ) { g_value_unset( value ); g_free( value ); } GValue * -im__gvalue_ref_string_new( const char *text ) +vips__gvalue_ref_string_new( const char *text ) { GValue *value; - value = im__gvalue_new( VIPS_TYPE_REF_STRING ); + value = vips__gvalue_new( VIPS_TYPE_REF_STRING ); vips_ref_string_set( value, text ); return( value ); @@ -856,16 +904,16 @@ im__gvalue_ref_string_new( const char *text ) /* Free a GSList of GValue. */ void -im__gslist_gvalue_free( GSList *list ) +vips__gslist_gvalue_free( GSList *list ) { - g_slist_foreach( list, (GFunc) im__gvalue_free, NULL ); + g_slist_foreach( list, (GFunc) vips__gvalue_free, NULL ); g_slist_free( list ); } /* Copy a GSList of GValue. */ GSList * -im__gslist_gvalue_copy( const GSList *list ) +vips__gslist_gvalue_copy( const GSList *list ) { GSList *copy; const GSList *p; @@ -874,7 +922,7 @@ im__gslist_gvalue_copy( const GSList *list ) for( p = list; p; p = p->next ) copy = g_slist_prepend( copy, - im__gvalue_copy( (GValue *) p->data ) ); + vips__gvalue_copy( (GValue *) p->data ) ); copy = g_slist_reverse( copy ); @@ -886,7 +934,7 @@ im__gslist_gvalue_copy( const GSList *list ) * (string, blob, etc.). */ GSList * -im__gslist_gvalue_merge( GSList *a, const GSList *b ) +vips__gslist_gvalue_merge( GSList *a, const GSList *b ) { const GSList *i, *j; GSList *tail; @@ -914,7 +962,7 @@ im__gslist_gvalue_merge( GSList *a, const GSList *b ) if( !j ) tail = g_slist_prepend( tail, - im__gvalue_copy( value ) ); + vips__gvalue_copy( value ) ); } a = g_slist_concat( a, g_slist_reverse( tail ) ); @@ -926,7 +974,7 @@ im__gslist_gvalue_merge( GSList *a, const GSList *b ) * free the result. Empty list -> "", not NULL. Join strings with '\n'. */ char * -im__gslist_gvalue_get( const GSList *list ) +vips__gslist_gvalue_get( const GSList *list ) { const GSList *p; size_t length; @@ -976,7 +1024,7 @@ im__gslist_gvalue_get( const GSList *list ) /* Need our own seek(), since lseek() on win32 can't do long files. */ int -im__seek( int fd, gint64 pos ) +vips__seek( int fd, gint64 pos ) { #ifdef OS_WIN32 { @@ -985,14 +1033,14 @@ im__seek( int fd, gint64 pos ) p.QuadPart = pos; if( !SetFilePointerEx( hFile, p, NULL, FILE_BEGIN ) ) { - vips_error_system( GetLastError(), "im__seek", + vips_error_system( GetLastError(), "vips__seek", "%s", _( "unable to seek" ) ); return( -1 ); } } #else /*!OS_WIN32*/ if( lseek( fd, pos, SEEK_SET ) == (off_t) -1 ) { - vips_error( "im__seek", "%s", _( "unable to seek" ) ); + vips_error( "vips__seek", "%s", _( "unable to seek" ) ); return( -1 ); } #endif /*OS_WIN32*/ @@ -1008,7 +1056,7 @@ im__seek( int fd, gint64 pos ) */ int -im__ftruncate( int fd, gint64 pos ) +vips__ftruncate( int fd, gint64 pos ) { #ifdef OS_WIN32 { @@ -1016,17 +1064,17 @@ im__ftruncate( int fd, gint64 pos ) LARGE_INTEGER p; p.QuadPart = pos; - if( im__seek( fd, pos ) ) + if( vips__seek( fd, pos ) ) return( -1 ); if( !SetEndOfFile( hFile ) ) { - vips_error_system( GetLastError(), "im__ftruncate", + vips_error_system( GetLastError(), "vips__ftruncate", "%s", _( "unable to truncate" ) ); return( -1 ); } } #else /*!OS_WIN32*/ if( ftruncate( fd, pos ) ) { - vips_error_system( errno, "im__ftruncate", + vips_error_system( errno, "vips__ftruncate", "%s", _( "unable to truncate" ) ); return( -1 ); } @@ -1035,50 +1083,54 @@ im__ftruncate( int fd, gint64 pos ) return( 0 ); } -/* Like fwrite(), but returns non-zero on error and sets error message. +/* Test for file exists. */ int -im__file_write( void *data, size_t size, size_t nmemb, FILE *stream ) +vips_existsf( const char *name, ... ) { - size_t n; + va_list ap; + char buf1[PATH_MAX]; - if( !data ) - return( 0 ); + va_start( ap, name ); + (void) vips_vsnprintf( buf1, PATH_MAX - 1, name, ap ); + va_end( ap ); - if( (n = fwrite( data, size, nmemb, stream )) != nmemb ) { - vips_error( "im__file_write", - _( "writing error (%zd out of %zd blocks written) " - "... disc full?" ), n, nmemb ); - return( -1 ); - } + /* Try that. + */ + if( !access( buf1, R_OK ) ) + return( 1 ); - return( 0 ); + return( 0 ); } -/* Read a few bytes from the start of a file. For sniffing file types. +#ifdef OS_WIN32 +#define popen(b,m) _popen(b,m) +#define pclose(f) _pclose(f) +#endif /*OS_WIN32*/ + +/* Do popen(), with printf-style args. */ -int -im__get_bytes( const char *filename, unsigned char buf[], int len ) +FILE * +vips_popenf( const char *fmt, const char *mode, ... ) { - int fd; + va_list args; + char buf[4096]; + FILE *fp; - /* File may not even exist (for tmp images for example!) - * so no hasty messages. And the file might be truncated, so no error - * on read either. - */ -#ifdef BINARY_OPEN - if( (fd = open( filename, O_RDONLY | O_BINARY )) == -1 ) -#else /*BINARY_OPEN*/ - if( (fd = open( filename, O_RDONLY )) == -1 ) -#endif /*BINARY_OPEN*/ - return( 0 ); - if( read( fd, buf, len ) != len ) { - close( fd ); - return( 0 ); + va_start( args, mode ); + (void) vips_vsnprintf( buf, 4096, fmt, args ); + va_end( args ); + +#ifdef DEBUG + printf( "vips_popenf: running: %s\n", buf ); +#endif /*DEBUG*/ + + if( !(fp = popen( buf, mode )) ) { + vips_error( "popenf", "%s", strerror( errno ) ); + return( NULL ); } - close( fd ); - return( 1 ); + return( fp ); } /* Break a command-line argument into tokens separated by whitespace. Strings @@ -1198,7 +1250,8 @@ vips__token_must( const char *p, VipsToken *token, char *string, int size ) { if( !(p = vips__token_get( p, token, string, size )) ) { - vips_error( "get_token", "%s", _( "unexpected end of string" ) ); + vips_error( "get_token", + "%s", _( "unexpected end of string" ) ); return( NULL ); } @@ -1242,56 +1295,6 @@ vips__token_need( const char *p, VipsToken need_token, return( p ); } -/* Test for file exists. - */ -int -im_existsf( const char *name, ... ) -{ - va_list ap; - char buf1[PATH_MAX]; - - va_start( ap, name ); - (void) im_vsnprintf( buf1, PATH_MAX - 1, name, ap ); - va_end( ap ); - - /* Try that. - */ - if( !access( buf1, R_OK ) ) - return( 1 ); - - return( 0 ); -} - -#ifdef OS_WIN32 -#define popen(b,m) _popen(b,m) -#define pclose(f) _pclose(f) -#endif /*OS_WIN32*/ - -/* Do popen(), with printf-style args. - */ -FILE * -im_popenf( const char *fmt, const char *mode, ... ) -{ - va_list args; - char buf[4096]; - FILE *fp; - - va_start( args, mode ); - (void) im_vsnprintf( buf, 4096, fmt, args ); - va_end( args ); - -#ifdef DEBUG - printf( "im_popenf: running: %s\n", buf ); -#endif /*DEBUG*/ - - if( !(fp = popen( buf, mode )) ) { - vips_error( "popenf", "%s", strerror( errno ) ); - return( NULL ); - } - - return( fp ); -} - /* True if an int is a power of two ... 1, 2, 4, 8, 16, 32, etc. Do with just * integer arithmetic for portability. A previous Nicos version using doubles * and log/log failed on x86 with rounding problems. Return 0 for not @@ -1299,7 +1302,7 @@ im_popenf( const char *fmt, const char *mode, ... ) * bit 1 as the lsb). */ int -im_ispoweroftwo( int p ) +vips_ispoweroftwo( int p ) { int i, n; @@ -1322,7 +1325,7 @@ im_ispoweroftwo( int p ) /* Test this processor for endianness. True for SPARC order. */ int -im_amiMSBfirst( void ) +vips_amiMSBfirst( void ) { int test; unsigned char *p = (unsigned char *) &test; @@ -1340,7 +1343,7 @@ im_amiMSBfirst( void ) * TMP, TEMP and USERPROFILE. */ static const char * -im__temp_dir( void ) +vips__temp_dir( void ) { const char *tmpd; @@ -1369,7 +1372,7 @@ im__temp_dir( void ) * delete it for you. */ char * -im__temp_name( const char *format ) +vips__temp_name( const char *format ) { static int serial = 1; @@ -1379,9 +1382,9 @@ im__temp_name( const char *format ) char *name; int fd; - im_snprintf( file, FILENAME_MAX, "vips-%d-XXXXXX", serial++ ); - im_snprintf( file2, FILENAME_MAX, format, file ); - name = g_build_filename( im__temp_dir(), file2, NULL ); + vips_snprintf( file, FILENAME_MAX, "vips-%d-XXXXXX", serial++ ); + vips_snprintf( file2, FILENAME_MAX, format, file ); + name = g_build_filename( vips__temp_dir(), file2, NULL ); if( (fd = g_mkstemp( name )) == -1 ) { vips_error( "tempfile", @@ -1408,7 +1411,7 @@ vips__change_suffix( const char *name, char *out, int mx, /* Copy start string. */ - im_strncpy( out, name, mx ); + vips_strncpy( out, name, mx ); /* Drop all matching suffixes. */ @@ -1431,6 +1434,6 @@ vips__change_suffix( const char *name, char *out, int mx, /* Add new suffix. */ len = strlen( out ); - im_strncpy( out + len, new, mx - len ); + vips_strncpy( out + len, new, mx - len ); } diff --git a/libvips/iofuncs/vector.c b/libvips/iofuncs/vector.c index 563ced57..c61a9c2e 100644 --- a/libvips/iofuncs/vector.c +++ b/libvips/iofuncs/vector.c @@ -63,7 +63,7 @@ /* Cleared by the command-line --vips-novector switch and the IM_NOVECTOR env * var. */ -gboolean im__vector_enabled = TRUE; +gboolean vips__vector_enabled = TRUE; void vips_vector_init( void ) @@ -81,7 +81,7 @@ vips_vector_init( void ) * off as well. */ if( g_getenv( "IM_NOVECTOR" ) ) - im__vector_enabled = FALSE; + vips__vector_enabled = FALSE; #endif /*HAVE_ORC*/ } @@ -89,7 +89,7 @@ gboolean vips_vector_get_enabled( void ) { #ifdef HAVE_ORC - return( im__vector_enabled ); + return( vips__vector_enabled ); #else /*!HAVE_ORC*/ return( FALSE ); #endif /*HAVE_ORC*/ @@ -98,7 +98,7 @@ vips_vector_get_enabled( void ) void vips_vector_set_enabled( gboolean enabled ) { - im__vector_enabled = enabled; + vips__vector_enabled = enabled; } void @@ -201,9 +201,9 @@ vips_vector_constant( VipsVector *vector, char *name, int value, int size ) } if( value > 0 ) - im_snprintf( name, 256, "c%d%s", value, sname ); + vips_snprintf( name, 256, "c%d%s", value, sname ); else - im_snprintf( name, 256, "cm%d%s", -value, sname ); + vips_snprintf( name, 256, "cm%d%s", -value, sname ); if( orc_program_find_var_by_name( vector->program, name ) == -1 ) { orc_program_add_constant( vector->program, size, value, name ); @@ -235,7 +235,7 @@ vips_vector_source_scanline( VipsVector *vector, char *name, int line, int size ) { #ifdef HAVE_ORC - im_snprintf( name, 256, "sl%d", line ); + vips_snprintf( name, 256, "sl%d", line ); if( orc_program_find_var_by_name( vector->program, name ) == -1 ) { int var; diff --git a/libvips/iofuncs/vips.c b/libvips/iofuncs/vips.c index 6f31739c..f4345582 100644 --- a/libvips/iofuncs/vips.c +++ b/libvips/iofuncs/vips.c @@ -295,7 +295,7 @@ vips__write_header_bytes( VipsImage *im, unsigned char *to ) /* Always write the magic number MSB first. */ - magic = im_amiMSBfirst() ? VIPS_MAGIC_SPARC : VIPS_MAGIC_INTEL; + magic = vips_amiMSBfirst() ? VIPS_MAGIC_SPARC : VIPS_MAGIC_INTEL; to[0] = magic >> 24; to[1] = magic >> 16; to[2] = magic >> 8; @@ -322,7 +322,7 @@ read_chunk( int fd, gint64 offset, size_t length ) { char *buf; - if( im__seek( fd, offset ) ) + if( vips__seek( fd, offset ) ) return( NULL ); if( !(buf = vips_malloc( NULL, length + 1 )) ) return( NULL ); @@ -407,7 +407,7 @@ read_xml( VipsImage *im ) vips_free( buf ); if( !(node = xmlDocGetRootElement( doc )) || !node->nsDef || - !im_isprefix( NAMESPACE, (char *) node->nsDef->href ) ) { + !vips_isprefix( NAMESPACE, (char *) node->nsDef->href ) ) { vips_error( "VipsImage", "%s", _( "incorrect namespace in XML" ) ); xmlFreeDoc( doc ); @@ -445,7 +445,7 @@ get_sprop( xmlNode *xnode, const char *name, char *buf, int sz ) if( !value ) return( 0 ); - im_strncpy( buf, value, sz ); + vips_strncpy( buf, value, sz ); VIPS_FREEF( xmlFree, value ); return( 1 ); @@ -461,7 +461,7 @@ set_history( VipsImage *im, char *history ) /* There can be history there already if we're rewinding. */ - VIPS_FREEF( im__gslist_gvalue_free, im->history_list ); + VIPS_FREEF( vips__gslist_gvalue_free, im->history_list ); history_list = NULL; @@ -474,7 +474,7 @@ set_history( VipsImage *im, char *history ) q = p + strlen( p ); history_list = g_slist_prepend( history_list, - im__gvalue_ref_string_new( p ) ); + vips__gvalue_ref_string_new( p ) ); } im->history_list = g_slist_reverse( history_list ); @@ -599,7 +599,7 @@ rebuild_header( VipsImage *im ) return( 0 ); } -/* Called at the end of im_openin() ... get any XML after the pixel data +/* Called at the end of vips open ... get any XML after the pixel data * and read it in. */ static int @@ -616,7 +616,7 @@ readhist( VipsImage *im ) if( !(doc = read_xml( im )) ) return( -1 ); if( vips_image_set_area( im, VIPS_META_XML, - (im_callback_fn) xmlFreeDoc, doc ) ) { + (VipsCallbackFn) xmlFreeDoc, doc ) ) { xmlFreeDoc( doc ); return( -1 ); } @@ -637,7 +637,7 @@ set_prop( xmlNode *node, const char *name, const char *fmt, ... ) char value[MAX_STRSIZE]; va_start( ap, fmt ); - (void) im_vsnprintf( value, MAX_STRSIZE, fmt, ap ); + (void) vips_vsnprintf( value, MAX_STRSIZE, fmt, ap ); va_end( ap ); if( !xmlSetProp( node, (xmlChar *) name, (xmlChar *) value ) ) { @@ -720,8 +720,8 @@ save_fields( VipsImage *im, xmlNode *node ) if( !(this = xmlNewChild( node, NULL, (xmlChar *) "meta", NULL )) ) return( -1 ); if( im->meta_traverse && - im_slist_map2( im->meta_traverse, - (VSListMap2Fn) save_fields_meta, this, NULL ) ) + vips_slist_map2( im->meta_traverse, + (VipsSListMap2Fn) save_fields_meta, this, NULL ) ) return( -1 ); return( 0 ); @@ -734,17 +734,17 @@ vips__write_extension_block( VipsImage *im, void *buf, int size ) gint64 psize; psize = image_pixel_length( im ); - if( (length = im_file_length( im->fd )) == -1 ) + if( (length = vips_file_length( im->fd )) == -1 ) return( -1 ); if( length - psize < 0 ) { vips_error( "VipsImage", "%s", _( "file has been truncated" ) ); return( -1 ); } - if( im__ftruncate( im->fd, psize ) || - im__seek( im->fd, psize ) ) + if( vips__ftruncate( im->fd, psize ) || + vips__seek( im->fd, psize ) ) return( -1 ); - if( im__write( im->fd, buf, size ) ) + if( vips__write( im->fd, buf, size ) ) return( -1 ); #ifdef DEBUG @@ -844,7 +844,7 @@ vips__writehist( VipsImage *im ) if( !(doc = xmlNewDoc( (xmlChar *) "1.0" )) ) return( -1 ); - im_snprintf( namespace, 256, "%s/%d.%d.%d", + vips_snprintf( namespace, 256, "%s/%d.%d.%d", NAMESPACE, IM_MAJOR_VERSION, IM_MINOR_VERSION, IM_MICRO_VERSION ); if( !(doc->children = xmlNewDocNode( doc, @@ -889,7 +889,7 @@ vips__writehist( VipsImage *im ) return( -1 ); } - printf( "im__writehist: saved XML is: \"%s\"", dump2 ); + printf( "vips__writehist: saved XML is: \"%s\"", dump2 ); xmlFree( dump2 ); } #endif /*DEBUG*/ @@ -927,7 +927,7 @@ vips_image_open_input( VipsImage *image ) /* Predict and check the file size. */ psize = image_pixel_length( image ); - if( (rsize = im_file_length( image->fd )) == -1 ) + if( (rsize = vips_file_length( image->fd )) == -1 ) return( -1 ); image->file_length = rsize; if( psize > rsize ) @@ -970,7 +970,7 @@ vips_image_open_output( VipsImage *image ) } if( vips__write_header_bytes( image, header ) || - im__write( image->fd, header, IM_SIZEOF_HEADER ) ) + vips__write( image->fd, header, IM_SIZEOF_HEADER ) ) return( -1 ); } diff --git a/libvips/iofuncs/window.c b/libvips/iofuncs/window.c index e2db02a8..a43cc572 100644 --- a/libvips/iofuncs/window.c +++ b/libvips/iofuncs/window.c @@ -69,16 +69,16 @@ /* Sanity checking ... write to this during read tests to make sure we don't * get optimised out. */ -int im__read_test; +int vips__read_test; /* Add this many lines above and below the mmap() window. */ -int im__window_margin_pixels = IM__WINDOW_MARGIN_PIXELS; +int vips__window_margin_pixels = IM__WINDOW_MARGIN_PIXELS; /* Always map at least this many bytes. There's no point making tiny windows * on small files. */ -int im__window_margin_bytes = IM__WINDOW_MARGIN_BYTES; +int vips__window_margin_bytes = IM__WINDOW_MARGIN_BYTES; /* Track global mmap usage. */ @@ -189,7 +189,7 @@ trace_mmap_usage( void ) #endif /*DEBUG_TOTAL*/ static int -im_getpagesize() +vips_getpagesize() { static int pagesize = 0; @@ -205,7 +205,7 @@ im_getpagesize() #endif /*OS_WIN32*/ #ifdef DEBUG_TOTAL - printf( "im_getpagesize: 0x%x\n", pagesize ); + printf( "vips_getpagesize: 0x%x\n", pagesize ); #endif /*DEBUG_TOTAL*/ } @@ -217,7 +217,7 @@ im_getpagesize() static int vips_window_set( VipsWindow *window, int top, int height ) { - int pagesize = im_getpagesize(); + int pagesize = vips_getpagesize(); void *baseaddr; gint64 start, end, pagestart; @@ -255,7 +255,7 @@ vips_window_set( VipsWindow *window, int top, int height ) /* Sanity check ... make sure the data pointer is readable. */ - im__read_test &= window->data[0]; + vips__read_test &= window->data[0]; #ifdef DEBUG_TOTAL g_mutex_lock( vips__global_lock ); @@ -330,8 +330,8 @@ vips_window_find( IMAGE *im, int top, int height ) req.top = top; req.height = height; - window = im_slist_map2( im->windows, - (VSListMap2Fn) vips_window_fits, &req, NULL ); + window = vips_slist_map2( im->windows, + (VipsSListMap2Fn) vips_window_fits, &req, NULL ); if( window ) { window->ref_count += 1; @@ -360,8 +360,8 @@ vips_window_ref( IMAGE *im, int top, int height ) * window than we strictly need. There's no point making tiny * windows. */ - int margin = VIPS_MIN( im__window_margin_pixels, - im__window_margin_bytes / + int margin = VIPS_MIN( vips__window_margin_pixels, + vips__window_margin_bytes / VIPS_IMAGE_SIZEOF_LINE( im ) ); top -= margin;