From bf88439c0ab363323343f027002a51ca7c8c3d37 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 14 Dec 2011 14:13:34 +0000 Subject: [PATCH] "vips list" can show any class --- TODO | 9 --------- tools/vips.c | 38 ++++++++------------------------------ 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/TODO b/TODO index 8a6b6a83..e17981f9 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,5 @@ - suppression for the strspn() thing? - leak check output should write a single line for each leaked image, not the - whole header - - "header" should maybe not have it's own summary printer? can we put this in - vips somewhere - - "vips list VipsInterpolate" should list all classes below VipsInterpolate - - - "header fred.png" does not work, since header uses im_open() which uses diff --git a/tools/vips.c b/tools/vips.c index 50919a09..523cfa73 100644 --- a/tools/vips.c +++ b/tools/vips.c @@ -186,6 +186,11 @@ print_list( int argc, char **argv ) else if( strcmp( argv[0], "classes" ) == 0 ) vips_type_map_all( g_type_from_name( "VipsObject" ), (VipsTypeMapFn) list_class, NULL ); + else if( g_type_from_name( argv[0] ) && + g_type_is_a( g_type_from_name( argv[0] ), VIPS_TYPE_OBJECT ) ) { + vips_type_map_all( g_type_from_name( argv[0] ), + (VipsTypeMapFn) list_class, NULL ); + } else { if( map_name( argv[0], list_function ) ) error_exit( "unknown package \"%s\"", argv[0] ); @@ -194,33 +199,6 @@ print_list( int argc, char **argv ) return( 0 ); } -/* Is s1 a prefix of s2? - */ -static int -isprefix( const char *s1, const char *s2 ) -{ - while( *s1 && *s1 == *s2 ) { - s1++; - s2++; - } - - return( *s1 == '\0' ); -} - -/* Is s1 a postfix of s2? - */ -static int -ispostfix( const char *s1, const char *s2 ) -{ - int l1 = strlen( s1 ); - int l2 = strlen( s2 ); - - if( l2 < l1 ) - return( 0 ); - - return( strcasecmp( s1, s2 + l2 - l1 ) == 0 ); -} - /* Print "ln -s" lines for this package. */ static void * @@ -455,7 +433,7 @@ find_ioargs( im_function *fn, int *ia, int *oa ) static gboolean drop_postfix( char *str, const char *postfix ) { - if( ispostfix( postfix, str ) ) { + if( vips_ispostfix( str, postfix ) ) { str[strlen( str ) - strlen( postfix )] = '\0'; return( TRUE ); @@ -485,7 +463,7 @@ c2cpp_name( const char *in, char *out ) /* Copy, chopping off "im_" prefix. */ - if( isprefix( "im_", in ) ) + if( vips_isprefix( "im_", in ) ) strcpy( out, in + 3 ); else strcpy( out, in ); @@ -498,7 +476,7 @@ c2cpp_name( const char *in, char *out ) found = FALSE; for( i = 0; i < IM_NUMBER( dont_drop ); i++ ) - if( ispostfix( dont_drop[i], out ) ) { + if( vips_ispostfix( out, dont_drop[i] ) ) { found = TRUE; break; }