programs/common.[ch] : Add function program_name().

This commit is contained in:
Erik de Castro Lopo 2011-03-21 21:16:13 +11:00
parent e0c6b3038c
commit 7ef22ed2f1
3 changed files with 25 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2011-03-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* programs/common.[ch]
Add function program_name() which returns the program name minus the path
from argv [0].
2011-03-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/wav.c

View File

@ -360,3 +360,20 @@ sfe_dump_format_map (void)
} ;
} /* sfe_dump_format_map */
const char *
program_name (const char * argv0)
{ const char * tmp ;
tmp = strrchr (argv0, '/') ;
argv0 = tmp ? tmp + 1 : argv0 ;
tmp = strrchr (argv0, '/') ;
argv0 = tmp ? tmp + 1 : argv0 ;
/* Remove leading libtool name mangling. */
if (strstr (argv0, "lt-") == argv0)
return argv0 + 3 ;
return argv0 ;
} /* program_name */

View File

@ -69,3 +69,5 @@ void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
int sfe_file_type_of_ext (const char *filename, int format) ;
void sfe_dump_format_map (void) ;
const char * program_name (const char * argv0) ;