Skip to content
Snippets Groups Projects
Commit 256eb369 authored by François Cartegnie's avatar François Cartegnie :fingers_crossed:
Browse files

implement logger callback

parent f8500ca5
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_CHECK_FUNCS([memset mkdir sqrt strchr strdup strstr strtoul])
AC_CHECK_FUNCS([memset mkdir sqrt strchr strdup strstr strtoul vasprintf])
AC_CONFIG_FILES([Makefile
src/Makefile src/aribb24.pc])
......
......@@ -23,9 +23,18 @@
#ifndef ARIBB24_MAIN_C
#define ARIBB24_MAIN_C 1
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_VASPRINTF
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "aribb24/aribb24.h"
#include "aribb24_private.h"
......@@ -34,6 +43,31 @@
#include "aribb24/decoder.h"
#include "decoder_private.h"
void arib_log( arib_instance_t *p_instance, const char *psz_format, ... )
{
#ifdef HAVE_VASPRINTF
va_list args;
free( p_instance->p->psz_last_error );
va_start( args, psz_format );
if ( vasprintf( &p_instance->p->psz_last_error, psz_format, args ) < 0 )
{
p_instance->p->psz_last_error = NULL;
return;
}
if ( p_instance->p->pf_messages )
{
p_instance->p->pf_messages( p_instance->p->p_opaque,
p_instance->p->psz_last_error );
}
else
{
// vprintf ?
}
va_end( args );
#endif
}
arib_instance_t * arib_instance_new( void *p_opaque )
{
arib_instance_t *p_instance = calloc( 1, sizeof(*p_instance) );
......@@ -56,6 +90,7 @@ void arib_instance_destroy( arib_instance_t *p_instance )
arib_decoder_free( p_instance->p->p_decoder );
if ( p_instance->p->p_parser )
arib_parser_free( p_instance->p->p_parser );
free( p_instance->p->psz_last_error );
free( p_instance );
}
......
......@@ -30,6 +30,9 @@ struct arib_instance_private_t
arib_decoder_t *p_decoder;
arib_parser_t *p_parser;
char *psz_base_path;
char *psz_last_error;
};
void arib_log( arib_instance_t *, const char *, ... );
#endif
......@@ -30,6 +30,7 @@
#include <stdint.h>
#include "aribb24/decoder.h"
#include "aribb24_private.h"
#include "decoder_private.h"
#include "aribb24/convtable.h"
#include "aribb24/decoder_macro.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment