Commit df37e6e2 authored by Diego Biurrun's avatar 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.
parent 1b4e3f9e
......@@ -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 );
}
}
......@@ -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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment