]> git.sesse.net Git - vlc/blobdiff - src/interface/intf_msg.c
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / src / interface / intf_msg.c
index 720c7a287941d9ed6f469b5461202f0c7f58fa03..68c3b6301bd4f9d43bc8f58b6e7cb8ed2e404491 100644 (file)
@@ -5,7 +5,7 @@
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
  *
- * Authors:
+ * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
+
 #include "intf_msg.h"
 #include "interface.h"
 #include "intf_console.h"
@@ -175,6 +175,11 @@ void intf_MsgDestroy( void )
     }
 #endif
 
+#ifdef INTF_MSG_QUEUE
+    /* destroy lock */
+    vlc_mutex_destroy( &p_main->p_msg->lock );
+#endif
+    
     /* Free structure */
     free( p_main->p_msg );
 }
@@ -219,7 +224,7 @@ void intf_WarnMsg( int i_level, char *psz_format, ... )
 {
     va_list ap;
     
-    if( i_level >= p_main->p_intf->i_warning_level )
+    if( i_level >= p_main->i_warning_level )
     {
         va_start( ap, psz_format );
         QueueMsg( p_main->p_msg, INTF_MSG_WARN, psz_format, ap );
@@ -311,7 +316,7 @@ void intf_WarnMsgImm( int i_level, char *psz_format, ... )
 {
     va_list ap;
 
-    if( i_level >= p_main->p_intf->i_warning_level )
+    if( i_level >= p_main->i_warning_level )
     {
         va_start( ap, psz_format );
         QueueMsg( p_main->p_msg, INTF_MSG_WARN, psz_format, ap );
@@ -383,19 +388,23 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
     /*
      * Convert message to string
      */
-#ifdef SYS_BEOS
-    psz_str = (char*) malloc( strlen(psz_format) + INTF_MAX_MSG_SIZE );
-    vsprintf( psz_str, psz_format, ap );
-#else
+#ifdef HAVE_VASPRINTF
     vasprintf( &psz_str, psz_format, ap );
+#else
+    psz_str = (char*) malloc( strlen(psz_format) + INTF_MAX_MSG_SIZE );
 #endif
     if( psz_str == NULL )
     {
         fprintf(stderr, "warning: can't store following message (%s): ",
                 strerror(errno) );
         vfprintf(stderr, psz_format, ap );
+        fprintf(stderr, "\n" );
         exit( errno );
     }
+#ifdef HAVE_VASPRINTF
+#else
+    vsprintf( psz_str, psz_format, ap );
+#endif
 
 #ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/
     vlc_mutex_lock( &p_msg->lock );                              /* get lock */
@@ -415,7 +424,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
     p_msg_item->i_type =     i_type;
     p_msg_item->psz_msg =    psz_str;
 #ifdef DEBUG    
-    p_msg_item->date =         mdate();
+    p_msg_item->date =       mdate();
 #endif
 
 #ifdef INTF_MSG_QUEUE /*......................................... queue mode */
@@ -447,11 +456,11 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
     /*
      * Convert message to string
      */
-#ifdef SYS_BEOS
+#ifdef HAVE_VASPRINTF
+    vasprintf( &psz_str, psz_format, ap );
+#else
     psz_str = (char*) malloc( INTF_MAX_MSG_SIZE );
     vsprintf( psz_str, psz_format, ap );
-#else
-    vasprintf( &psz_str, psz_format, ap );
 #endif
     if( psz_str == NULL )
     {
@@ -459,6 +468,7 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
                 strerror(errno) );
         fprintf(stderr, INTF_MSG_DBG_FORMAT, psz_file, psz_function, i_line );
         vfprintf(stderr, psz_format, ap );
+        fprintf(stderr, "\n" );
         exit( errno );
     }
 
@@ -571,14 +581,14 @@ static void PrintMsg( intf_msg_item_t *p_msg )
     switch( p_msg->i_type )
     {
     case INTF_MSG_STD:                                  /* standard messages */
-        fprintf( stdout, psz_msg );
+        fprintf( stdout, "%s\n", psz_msg );
         break;
     case INTF_MSG_ERR:                                     /* error messages */
     case INTF_MSG_WARN:
 #ifndef DEBUG_LOG_ONLY
     case INTF_MSG_DBG:                                 /* debugging messages */
 #endif
-        fprintf( stderr, psz_msg );
+        fprintf( stderr, "%s\n", psz_msg );
         break;
     case INTF_MSG_INTF:                                /* interface messages */
         intf_ConsolePrint( p_main->p_intf->p_console, psz_msg );
@@ -590,6 +600,7 @@ static void PrintMsg( intf_msg_item_t *p_msg )
     if( p_main->p_msg->p_log_file != NULL )
     {
         fwrite( psz_msg, strlen( psz_msg ), 1, p_main->p_msg->p_log_file );
+        fwrite( "\n", 1, 1, p_main->p_msg->p_log_file );
     }
 #endif
 
@@ -608,11 +619,11 @@ static void PrintMsg( intf_msg_item_t *p_msg )
     {
     case INTF_MSG_STD:                                  /* standard messages */
     case INTF_MSG_DBG:                                     /* debug messages */
-        fprintf( stdout, p_msg->psz_msg );
+        fprintf( stdout, "%s\n", p_msg->psz_msg );
         break;
     case INTF_MSG_ERR:                                     /* error messages */
     case INTF_MSG_WARN:
-        fprintf( stderr, p_msg->psz_msg );                /* warning message */
+        fprintf( stderr, "%s\n", p_msg->psz_msg );        /* warning message */
         break;
     case INTF_MSG_INTF:                                /* interface messages */
         intf_ConsolePrint( p_main->p_intf->p_console, p_msg->psz_msg );
@@ -621,3 +632,4 @@ static void PrintMsg( intf_msg_item_t *p_msg )
 }
 
 #endif
+