/** * im_error_clear: * * Clear and reset the error buffer. This is typically called after presentng * an error to the user. * * See also: im_error_buffer(). */ void im_error_clear( void ) { g_mutex_lock( im__global_lock ); vips_buf_rewind( &im_error_buf ); g_mutex_unlock( im__global_lock ); }
/** * vips_error_clear: * * Clear and reset the error buffer. This is typically called after presenting * an error to the user. * * See also: vips_error_buffer(). */ void vips_error_clear( void ) { g_mutex_lock( vips__global_lock ); vips_buf_rewind( &vips_error_buf ); g_mutex_unlock( vips__global_lock ); }
/** * vips_buf_init: * @buf: the buffer * * Initialize a buffer. */ void vips_buf_init( VipsBuf *buf ) { buf->base = NULL; buf->mx = 0; buf->dynamic = FALSE; vips_buf_rewind( buf ); }
/** * vips_buf_set_static: * @buf: the buffer * @base: the start of the memory area to use for storage * @mx: the size of the storage area * * Attach the buffer to a static memory area. The buffer needs to have been * initialised. The memory area needs to be at least 4 bytes long. */ void vips_buf_set_static( VipsBuf *buf, char *base, int mx ) { g_assert( mx >= 4 ); vips_buf_destroy( buf ); buf->base = base; buf->mx = mx; buf->dynamic = FALSE; vips_buf_rewind( buf ); }
/** * vips_buf_set_dynamic: * @buf: the buffer * @mx: the size of the storage area * * Attach the buffer to a heap memory area. The buffer needs to have been * initialised. The memory area needs to be at least 4 bytes long. */ void vips_buf_set_dynamic( VipsBuf *buf, int mx ) { g_assert( mx >= 4 ); if( buf->mx == mx && buf->dynamic ) /* No change? */ vips_buf_rewind( buf ); else { vips_buf_destroy( buf ); if( !(buf->base = VIPS_ARRAY( NULL, mx, char )) ) /* No error return, so just block writes. */ buf->full = TRUE; else { buf->mx = mx; buf->dynamic = TRUE; vips_buf_rewind( buf ); } }
/* Return the main caption. */ static const char * iimage_generate_caption( iObject *iobject ) { iImage *iimage = IIMAGE( iobject ); Imageinfo *ii = iimage->value.ii; VipsBuf *buf = &iimage->caption_buffer; vips_buf_rewind( buf ); image_value_caption( &iimage->value, buf ); if( ii ) { vips_buf_appends( buf, ", " ); iobject_info( IOBJECT( iimage->value.ii ), buf ); } return( vips_buf_all( buf ) ); }
static const char * iarrow_generate_caption( iObject *iobject ) { static const char *names[] = { CLASS_HGUIDE, CLASS_VGUIDE, CLASS_MARK, CLASS_ARROW, NULL }; iArrow *iarrow = IARROW( iobject ); VipsBuf *buf = &iarrow->caption_buffer; const int nimages = g_slist_length( CLASSMODEL( iarrow )->iimages ); Expr *expr; gboolean result; gboolean first; int i; if( !HEAPMODEL( iarrow )->row || !(expr = HEAPMODEL( iarrow )->row->expr) || !heap_is_class( &expr->root, &result ) || !result ) return( _( "No image" ) ); vips_buf_rewind( buf ); heapmodel_name( HEAPMODEL( iarrow ), buf ); vips_buf_appendf( buf, " " ); /* Used in (eg.) "Mark at (10, 10) on [A1, A2]" */ vips_buf_appendf( buf, _( "on" ) ); vips_buf_appendf( buf, " " ); if( nimages > 1 ) vips_buf_appendf( buf, "[" ); first = TRUE; slist_map2( CLASSMODEL( iarrow )->iimages, (SListMap2Fn) iarrow_generate_caption_sub, iarrow, &first ); if( nimages > 1 ) vips_buf_appendf( buf, "]" ); vips_buf_appendf( buf, " " ); for( i = 0; names[i]; i++ ) { if( !heap_is_instanceof( names[i], &expr->root, &result ) ) break; if( result ) { switch( i ) { case 0: vips_buf_appendf( buf, _( "at %d" ), iarrow->instance.area.top ); break; case 1: vips_buf_appendf( buf, _( "at %d" ), iarrow->instance.area.left ); break; case 2: vips_buf_appendf( buf, _( "at (%d, %d)" ), iarrow->instance.area.left, iarrow->instance.area.top ); break; case 3: vips_buf_appendf( buf, _( "at (%d, %d), offset (%d, %d)" ), iarrow->instance.area.left, iarrow->instance.area.top, iarrow->instance.area.width, iarrow->instance.area.height ); break; default: g_assert( 0 ); } break; } } return( vips_buf_all( buf ) ); }