error.c 2.2 KB
Newer Older
1 2 3 4 5
/*****************************************************************************
 * error.c: error management functions
 *****************************************************************************
 * Copyright (C) 1998-2002 VideoLAN
 *
6
 * Author: Sam Hocevar <sam@zoy.org>
7
 *
8
 * libdvdcss is free software; you can redistribute it and/or modify
9 10 11
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
12
 *
13
 * libdvdcss is distributed in the hope that it will be useful,
14 15 16 17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
Diego Biurrun's avatar
Diego Biurrun committed
18
 * You should have received a copy of the GNU General Public License along
19
 * with libdvdcss; if not, write to the Free Software Foundation, Inc.,
Diego Biurrun's avatar
Diego Biurrun committed
20
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 22
 *****************************************************************************/

23
#include <stdarg.h>
24
#include <stdio.h>
25

26 27
#include "libdvdcss.h"

28 29 30 31 32 33 34 35
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" );
}

36 37 38
/*****************************************************************************
 * Error messages
 *****************************************************************************/
39
void print_error( dvdcss_t dvdcss, const char *psz_string, ... )
40 41 42
{
    if( dvdcss->b_errors )
    {
43 44 45 46 47
        va_list args;

        va_start( args, psz_string );
        print_message("error", psz_string, args);
        va_end( args );
48 49 50 51
    }

    dvdcss->psz_error = psz_string;
}
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

/*****************************************************************************
 * 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 );
    }
}