/*****************************************************************************
* intf_msg.c: messages interface
- * (c)1998 VideoLAN
- *****************************************************************************
* This library provides basic functions for threads to interact with user
* interface, such as message output. See config.h for output configuration.
+ *****************************************************************************
+ * Copyright (C) 1998, 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include "defs.h"
+
+#include <errno.h> /* errno */
+#include <fcntl.h> /* O_CREAT, O_TRUNC, O_WRONLY, O_SYNC */
+#include <stdio.h> /* required */
+#include <stdarg.h> /* va_list for BSD */
+#include <stdlib.h> /* malloc() */
+#include <string.h> /* strerror() */
+#include <unistd.h> /* close(), write() */
#include "config.h"
#include "common.h"
+#include "threads.h"
#include "mtime.h"
-#include "vlc_thread.h"
+#include "plugins.h"
#include "intf_msg.h"
#include "interface.h"
#include "intf_console.h"
+
#include "main.h"
/*****************************************************************************
*****************************************************************************/
static void QueueMsg ( intf_msg_t *p_msg, int i_type,
- char *psz_format, va_list ap );
+ char *psz_format, va_list ap );
static void PrintMsg ( intf_msg_item_t *p_msg );
#ifdef DEBUG
static void QueueDbgMsg ( intf_msg_t *p_msg, char *psz_file,
/*****************************************************************************
- * intf_MsgCreate: initialize messages interface (ok ?)
+ * intf_MsgCreate: initialize messages interface (ok ?)
*****************************************************************************
* This functions has to be called before any call to other intf_*Msg functions.
* It set up the locks and the message queue if it is used.
p_msg = malloc( sizeof( intf_msg_t ) );
if( p_msg == NULL )
{
- errno = ENOMEM;
+ errno = ENOMEM;
}
else
{
#endif
#ifdef DEBUG_LOG
- /* Log file initialization - on failure, file pointer will be null,
- * and no log will be issued, but this is not considered as an
- * error */
- p_msg->i_log_file = open( DEBUG_LOG,
- O_CREAT | O_TRUNC | O_SYNC | O_WRONLY,
- 0666 );
+ /* Log file initialization - on failure, file pointer will be null,
+ * and no log will be issued, but this is not considered as an
+ * error */
+ p_msg->i_log_file = open( DEBUG_LOG, O_CREAT | O_TRUNC |
+#ifndef SYS_BSD
+ O_SYNC |
+#else
+ O_ASYNC |
+#endif /* SYS_BSD */
+ O_WRONLY, 0666 );
+
#endif
}
return( p_msg );
/* Close log file if any */
if( p_main->p_msg->i_log_file >= 0 )
{
- close( p_main->p_msg->i_log_file );
+ close( p_main->p_msg->i_log_file );
}
#endif
/*
* 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
vasprintf( &psz_str, psz_format, ap );
+#endif
if( psz_str == NULL )
{
fprintf(stderr, "warning: can't store following message (%s): ",
*****************************************************************************/
#ifdef DEBUG
static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
- int i_line, char *psz_format, va_list ap)
+ int i_line, char *psz_format, va_list ap)
{
char * psz_str; /* formatted message string */
intf_msg_item_t * p_msg_item; /* pointer to message */
/*
* Convert message to string
*/
+#ifdef SYS_BEOS
+ 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 )
{
fprintf(stderr, "warning: can't store following message (%s): ",
strerror(errno) );
fprintf(stderr, INTF_MSG_DBG_FORMAT, psz_file, psz_function, i_line );
- vfprintf(stderr, psz_format, ap );
+ vfprintf(stderr, psz_format, ap );
exit( errno );
}
/* Append all messages to log file */
if( p_main->p_msg->i_log_file >= 0 )
{
- write( p_main->p_msg->i_log_file, psz_msg, strlen( psz_msg ) );
+ write( p_main->p_msg->i_log_file, psz_msg, strlen( psz_msg ) );
}
#endif