/*****************************************************************************
* Preamble
*****************************************************************************/
+
+#include <vlc/vlc.h>
+
#include <stdio.h> /* required */
#include <stdarg.h> /* va_list for BSD */
#include <stdlib.h> /* malloc() */
#include <string.h> /* strerror() */
-#include <vlc/vlc.h>
#ifdef HAVE_FCNTL_H
# include <fcntl.h> /* O_CREAT, O_TRUNC, O_WRONLY, O_SYNC */
#endif
#include "vlc_interface.h"
+#include "charset.h"
/*****************************************************************************
* Local macros
*/
void __msg_Create( vlc_object_t *p_this )
{
- vlc_mutex_init( p_this, &(p_this->p_libvlc->msg_bank.lock) );
+ vlc_mutex_init( p_this, &(p_this->p_libvlc_global->msg_bank.lock) );
CreateMsgQueue( p_this, MSG_QUEUE_NORMAL );
CreateMsgQueue( p_this, MSG_QUEUE_HTTPD_ACCESS );
#ifdef UNDER_CE
- p_this->p_libvlc->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile =
+ p_this->p_libvlc_global->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile =
CreateFile( L"vlc-log.txt", GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, 0, NULL );
- SetFilePointer( p_this->p_libvlc->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->
+ SetFilePointer( p_this->p_libvlc_global->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->
logfile, 0, NULL, FILE_END );
#endif
p_queue->i_sub = 0;
p_queue->pp_sub = NULL;
- INSERT_ELEM( p_this->p_libvlc->msg_bank.pp_queues,
- p_this->p_libvlc->msg_bank.i_queues,
+ INSERT_ELEM( p_this->p_libvlc_global->msg_bank.pp_queues,
+ p_this->p_libvlc_global->msg_bank.i_queues,
i_queue,
p_queue );
}
{
int i;
- for( i = 0 ; i < p_this->p_libvlc->msg_bank.i_queues; i++ )
+ for( i = 0 ; i < p_this->p_libvlc_global->msg_bank.i_queues; i++ )
{
- vlc_mutex_lock( &p_this->p_libvlc->msg_bank.pp_queues[i]->lock );
- FlushMsg( p_this->p_libvlc->msg_bank.pp_queues[i] );
- vlc_mutex_unlock( &p_this->p_libvlc->msg_bank.pp_queues[i]->lock );
+ vlc_mutex_lock( &p_this->p_libvlc_global->msg_bank.pp_queues[i]->lock );
+ FlushMsg( p_this->p_libvlc_global->msg_bank.pp_queues[i] );
+ vlc_mutex_unlock( &p_this->p_libvlc_global->msg_bank.pp_queues[i]->lock );
}
}
void __msg_Destroy( vlc_object_t *p_this )
{
int i;
- for( i = 0 ; i < p_this->p_libvlc->msg_bank.i_queues; i++ )
+ for( i = p_this->p_libvlc_global->msg_bank.i_queues -1 ; i >= 0; i-- )
{
- msg_queue_t *p_queue = p_this->p_libvlc->msg_bank.pp_queues[i];
+ msg_queue_t *p_queue = p_this->p_libvlc_global->msg_bank.pp_queues[i];
if( p_queue->i_sub )
{
msg_Err( p_this, "stale interface subscribers" );
#ifdef UNDER_CE
if( i == MSG_QUEUE_NORMAL )
- CloseHandle( p_this->p_libvlc->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile );
+ CloseHandle( p_this->p_libvlc_global->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile );
#endif
/* Destroy lock */
vlc_mutex_destroy( &p_queue->lock );
+ REMOVE_ELEM( p_this->p_libvlc_global->msg_bank.pp_queues,
+ p_this->p_libvlc_global->msg_bank.i_queues, i );
+ free( p_queue );
}
- vlc_mutex_destroy( &(p_this->p_libvlc->msg_bank.lock) );
+ vlc_mutex_destroy( &(p_this->p_libvlc_global->msg_bank.lock) );
}
/**
*/
msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this, int i_queue )
{
- msg_bank_t *p_bank = &p_this->p_libvlc->msg_bank;
+ msg_bank_t *p_bank = &p_this->p_libvlc_global->msg_bank;
msg_subscription_t *p_sub = malloc( sizeof( msg_subscription_t ) );
msg_queue_t *p_queue = NULL;
int i;
*/
void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
{
- msg_bank_t *p_bank = &p_this->p_libvlc->msg_bank;
+ msg_bank_t *p_bank = &p_this->p_libvlc_global->msg_bank;
int i,j;
vlc_mutex_lock( &p_bank->lock );
const char *psz_module,
const char *psz_format, va_list _args )
{
- int i_header_size; /* Size of the additionnal header */
+ int i_header_size; /* Size of the additionnal header */
vlc_object_t *p_obj;
- msg_bank_t * p_bank = &p_this->p_libvlc->msg_bank; /* message bank */
+ msg_bank_t *p_bank; /* message bank */
msg_queue_t *p_queue = NULL;
char * psz_str = NULL; /* formatted message string */
char * psz_header = NULL;
msg_item_t * p_item = NULL; /* pointer to message */
msg_item_t item; /* message in case of a full queue */
-#if !defined(HAVE_VASPRINTF) || defined(SYS_DARWIN) || defined(SYS_BEOS)
+#if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
int i_size = strlen(psz_format) + INTF_MAX_MSG_SIZE;
#endif
int i;
- if( p_this->i_flags & OBJECT_FLAGS_QUIET ||
- (p_this->i_flags & OBJECT_FLAGS_NODBG &&
- i_type == VLC_MSG_DBG ) )
+ if( p_this == NULL || p_this->i_flags & OBJECT_FLAGS_QUIET ||
+ (p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) )
{
return;
}
+ p_bank = &p_this->p_libvlc_global->msg_bank;
+
/*
* Convert message to string
*/
-#if defined(HAVE_VASPRINTF) && !defined(SYS_DARWIN) && !defined( SYS_BEOS )
+#if defined(HAVE_VASPRINTF) && !defined(__APPLE__) && !defined( SYS_BEOS )
vlc_va_copy( args, _args );
vasprintf( &psz_str, psz_format, args );
va_end( args );
fprintf( stderr, "main warning: can't store message (%s): ",
strerror(errno) );
vlc_va_copy( args, _args );
+ /* We should use utf8_vfprintf - but it calls malloc()... */
vfprintf( stderr, psz_format, args );
va_end( args );
- fprintf( stderr, "\n" );
+ fputs( "\n", stderr );
return;
}
p_obj = p_obj->p_parent;
}
-#if !defined(HAVE_VASPRINTF) || defined(SYS_DARWIN) || defined(SYS_BEOS)
+#if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
vlc_va_copy( args, _args );
vsnprintf( psz_str, i_size, psz_format, args );
va_end( args );
switch( i_type )
{
case VLC_MSG_ERR:
- if( p_this->p_libvlc->i_verbose < 0 ) return;
+ if( p_this->p_libvlc_global->i_verbose < 0 ) return;
break;
case VLC_MSG_INFO:
- if( p_this->p_libvlc->i_verbose < 0 ) return;
+ if( p_this->p_libvlc_global->i_verbose < 0 ) return;
break;
case VLC_MSG_WARN:
- if( p_this->p_libvlc->i_verbose < 1 ) return;
+ if( p_this->p_libvlc_global->i_verbose < 1 ) return;
break;
case VLC_MSG_DBG:
- if( p_this->p_libvlc->i_verbose < 2 ) return;
+ if( p_this->p_libvlc_global->i_verbose < 2 ) return;
break;
}
switch( p_item->i_object_type )
{
case VLC_OBJECT_ROOT: psz_object = "root"; break;
- case VLC_OBJECT_VLC: psz_object = "vlc"; break;
+ case VLC_OBJECT_LIBVLC: psz_object = "libvlc"; break;
case VLC_OBJECT_MODULE: psz_object = "module"; break;
case VLC_OBJECT_INTF: psz_object = "interface"; break;
case VLC_OBJECT_PLAYLIST: psz_object = "playlist"; break;
case VLC_OBJECT_VOUT: psz_object = "video output"; break;
case VLC_OBJECT_AOUT: psz_object = "audio output"; break;
case VLC_OBJECT_SOUT: psz_object = "stream output"; break;
- case VLC_OBJECT_HTTPD: psz_object = "http daemon"; break;
+ case VLC_OBJECT_HTTPD: psz_object = "http server"; break;
+ case VLC_OBJECT_HTTPD_HOST: psz_object = "http server"; break;
case VLC_OBJECT_DIALOGS: psz_object = "dialogs provider"; break;
case VLC_OBJECT_VLM: psz_object = "vlm"; break;
case VLC_OBJECT_ANNOUNCE: psz_object = "announce handler"; break;
}
#ifdef UNDER_CE
-# define CE_WRITE(str) WriteFile( p_this->p_libvlc->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile, \
+# define CE_WRITE(str) WriteFile( p_this->p_libvlc_global->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile, \
str, strlen(str), &i_dummy, NULL );
CE_WRITE( p_item->psz_module );
CE_WRITE( " " );
CE_WRITE( ": " );
CE_WRITE( p_item->psz_msg );
CE_WRITE( "\r\n" );
- FlushFileBuffers( p_this->p_libvlc->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile );
+ FlushFileBuffers( p_this->p_libvlc_global->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile );
#else
/* Send the message to stderr */
- if( p_this->p_libvlc->b_color )
+ if( p_this->p_libvlc_global->b_color )
{
if( p_item->psz_header )
{
- fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s %s%s: %s%s" GRAY
+ utf8_fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s %s%s: %s%s" GRAY
"\n",
p_item->i_object_id, p_item->psz_header,
p_item->psz_module, psz_object,
}
else
{
- fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s%s: %s%s" GRAY "\n",
+ utf8_fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s%s: %s%s" GRAY "\n",
p_item->i_object_id, p_item->psz_module, psz_object,
ppsz_type[i_type], ppsz_color[i_type],
p_item->psz_msg );
{
if( p_item->psz_header )
{
- fprintf( stderr, "[%.8i] %s %s %s%s: %s\n", p_item->i_object_id,
+ utf8_fprintf( stderr, "[%.8i] %s %s %s%s: %s\n", p_item->i_object_id,
p_item->psz_header, p_item->psz_module,
psz_object, ppsz_type[i_type], p_item->psz_msg );
}
else
{
- fprintf( stderr, "[%.8i] %s %s%s: %s\n", p_item->i_object_id,
+ utf8_fprintf( stderr, "[%.8i] %s %s%s: %s\n", p_item->i_object_id,
p_item->psz_module, psz_object, ppsz_type[i_type],
p_item->psz_msg );
}