]> git.sesse.net Git - vlc/blobdiff - src/misc/messages.c
More cleanup
[vlc] / src / misc / messages.c
index 2f2fcd0b88a094cdb27be0974d2d5d59a397f485..a7a0885a5dd6338c7f0cf58de47519cbdee506eb 100644 (file)
@@ -45,6 +45,7 @@
 #endif
 
 #include "vlc_interface.h"
+#include "charset.h"
 
 /*****************************************************************************
  * Local macros
@@ -133,7 +134,7 @@ void __msg_Flush( vlc_object_t *p_this )
 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->msg_bank.i_queues -1 ; i >= 0;  i-- )
     {
         msg_queue_t *p_queue = p_this->p_libvlc->msg_bank.pp_queues[i];
         if( p_queue->i_sub )
@@ -148,6 +149,9 @@ void __msg_Destroy( vlc_object_t *p_this )
 #endif
         /* Destroy lock */
         vlc_mutex_destroy( &p_queue->lock );
+        REMOVE_ELEM( p_this->p_libvlc->msg_bank.pp_queues,
+                     p_this->p_libvlc->msg_bank.i_queues, i );
+        free( p_queue );
     }
     vlc_mutex_destroy( &(p_this->p_libvlc->msg_bank.lock) );
 }
@@ -292,9 +296,9 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue_id, int i_type,
                       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;
@@ -302,22 +306,23 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue_id, int i_type,
     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->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 );
@@ -330,9 +335,10 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue_id, int i_type,
         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;
     }
 
@@ -363,7 +369,7 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue_id, int i_type,
         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 );
@@ -567,7 +573,8 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
         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;
@@ -593,7 +600,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
     {
         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,
@@ -602,7 +609,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
         }
         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 );
@@ -612,13 +619,13 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
     {
         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 );
         }