]> git.sesse.net Git - vlc/blobdiff - src/misc/messages.c
GetLastError throws a DWORD, IIRC, not a char*
[vlc] / src / misc / messages.c
index 1bcc6a5ec665f8dd9f7bac7102359300e8e6e873..5020a198aa539c3d44bba8423174db67dde9263b 100644 (file)
  * Preamble
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 
 #include <stdarg.h>                                       /* va_list for BSD */
@@ -76,11 +80,12 @@ static void PrintMsg ( vlc_object_t *, msg_item_t * );
 void __msg_Create( vlc_object_t *p_this )
 {
     int i;
-    vlc_mutex_init( p_this, &(p_this->p_libvlc->msg_bank.lock) );
+    vlc_mutex_init( (vlc_object_t *)NULL,
+                    &(p_this->p_libvlc->msg_bank.lock) );
 
     for( i = 0; i < 2; i++ )
     {
-         vlc_mutex_init( p_this, &QUEUE(i).lock );
+         vlc_mutex_init( (vlc_object_t *)NULL, &QUEUE(i).lock );
          QUEUE(i).b_overflow = VLC_FALSE;
          QUEUE(i).i_id = i;
          QUEUE(i).i_start = 0;
@@ -246,7 +251,7 @@ void __msg_GenericVa( vlc_object_t *p_this, int i_queue,
     { \
         va_list args; \
         va_start( args, psz_format ); \
-        QueueMsg( (vlc_object_t *)p_this,MSG_QUEUE_NORMAL, FN_TYPE, "unknown", \
+        QueueMsg( p_this,MSG_QUEUE_NORMAL, FN_TYPE, "unknown", \
                   psz_format, args ); \
         va_end( args ); \
     } \
@@ -295,17 +300,27 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
     int          i_size = strlen(psz_format) + INTF_MAX_MSG_SIZE;
 #endif
 
-    if( p_this == NULL || p_this->i_flags & OBJECT_FLAGS_QUIET ||
-        (p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) )
+    if( p_this == NULL )
     {
+#ifndef NDEBUG
+        if( i_type == VLC_MSG_DBG )
+            return;
+#endif
+        utf8_vfprintf( stderr, psz_format, _args );
+        fputc ('\n', stderr);
         return;
     }
 
+    if( p_this->i_flags & OBJECT_FLAGS_QUIET ||
+        (p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) )
+        return;
+
 #ifndef __GLIBC__
     /* Expand %m to strerror(errno) - only once */
     char buf[strlen( psz_format ) + 2001], *ptr;
     strcpy( buf, psz_format );
-    ptr = psz_format = buf;
+    ptr = (char*)buf;
+    psz_format = (const char*) buf;
 
     for( ;; )
     {
@@ -327,7 +342,8 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
                 strncpy( errbuf, net_strerror( sockerr ), 1001 );
                 WSASetLastError( sockerr );
             }
-            else
+            if ((sockerr == 0)
+             || (strcmp ("Unknown network stack error", errbuf) == 0))
                 strncpy( errbuf, strerror( errno ), 1001 );
 #endif
             errbuf[1000] = 0;
@@ -370,20 +386,13 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
 #ifdef __GLIBC__
         fprintf( stderr, "main warning: can't store message (%m): " );
 #else
-        char *psz_err[1001];
+        char psz_err[1001];
 #ifndef WIN32
         /* we're not using GLIBC, so we are sure that the error description
          * will be stored in the buffer we provide to strerror_r() */
         strerror_r( errno, psz_err, 1001 );
 #else
-        int sockerr = WSAGetLastError( );
-        if( sockerr )
-        {
-            strncpy( psz_err, net_strerror( sockerr ), 1001 );
-            WSASetLastError( sockerr );
-        }
-        else
-            strncpy( psz_err, strerror( errno ), 1001 );
+        strncpy( psz_err, strerror( errno ), 1001 );
 #endif
         psz_err[1000] = '\0';
         fprintf( stderr, "main warning: can't store message (%s): ", psz_err );
@@ -569,7 +578,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
 #   define RED     COL(31)
 #   define GREEN   COL(32)
 #   define YELLOW  COL(33)
-#   define WHITE   COL(37)
+#   define WHITE   COL(0)
 #   define GRAY    "\033[0m"
 
 #ifdef UNDER_CE