[libdvdcss-devel] Convert debug print macro to a function.
[email protected] (Diego Biurrun) Tue, 18 Nov 2014 18:13:23 +0100 (CET)
| Newsgroups | gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel |
|---|---|
| Message-ID | <[email protected]> |
libdvdcss | branch: master | Diego Biurrun <[email protected]> | Mon Nov 17 13:43:35 2014 +0100| [df37e6e222bcd2504b0fe7434bfd69429750d428] | committer: Diego Biurrun Convert debug print macro to a function. This reduces library size by ~10%. Also allow passing extra arguments to the error printing function. > http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=df37e6e222bcd2504b0fe7434bfd69429750d428 --- src/error.c | 32 ++++++++++++++++++++++++++++++-- src/libdvdcss.h | 11 ++--------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/error.c b/src/error.c index 4b2754a..4c30d2f 100644 --- a/src/error.c +++ b/src/error.c @@ -20,19 +20,47 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *****************************************************************************/ +#include <stdarg.h> #include <stdio.h> #include "libdvdcss.h" +static void print_message( const char *prefix, const char *psz_string, + va_list args ) +{ + fprintf( stderr, "libdvdcss %s: ", prefix ); + vfprintf( stderr, psz_string, args ); + fprintf( stderr, "\n" ); +} + /***************************************************************************** * Error messages *****************************************************************************/ -void print_error( dvdcss_t dvdcss, const char *psz_string ) +void print_error( dvdcss_t dvdcss, const char *psz_string, ... ) { if( dvdcss->b_errors ) { - fprintf( stderr, "libdvdcss error: %s\n", psz_string ); + va_list args; + + va_start( args, psz_string ); + print_message("error", psz_string, args); + va_end( args ); } dvdcss->psz_error = psz_string; } + +/***************************************************************************** + * Debug messages + *****************************************************************************/ +void print_debug( const dvdcss_t dvdcss, const char *psz_string, ... ) +{ + if( dvdcss->b_debug ) + { + va_list args; + + va_start( args, psz_string ); + print_message("debug", psz_string, args ); + va_end( args ); + } +} diff --git a/src/libdvdcss.h b/src/libdvdcss.h index 5f6cb3e..9447124 100644 --- a/src/libdvdcss.h +++ b/src/libdvdcss.h @@ -84,14 +84,7 @@ struct dvdcss_s /***************************************************************************** * Functions used across the library *****************************************************************************/ -#define print_debug( dvdcss, ... ) \ - if( dvdcss->b_debug ) \ - { \ - fprintf( stderr, "libdvdcss debug: " ); \ - fprintf( stderr, __VA_ARGS__ ); \ - fprintf( stderr, "\n" ); \ - } - -void print_error ( dvdcss_t, const char * ); +void print_error ( dvdcss_t, const char *, ... ); +void print_debug ( const dvdcss_t, const char *, ... ); #endif /* DVDCSS_LIBDVDCSS_H */ _______________________________________________ libdvdcss-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libdvdcss-devel