2001-08-16 22:13:20 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2001-09-20 10:27:24 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_NEW_GUI
|
|
|
|
#include "Gui/mplayer/widgets.h"
|
|
|
|
extern void gtkMessageBox( int type,char * str );
|
|
|
|
extern int use_gui;
|
|
|
|
#endif
|
|
|
|
|
2001-08-16 22:13:20 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
|
|
|
|
static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
void mp_msg_init(int verbose){
|
|
|
|
int i;
|
|
|
|
for(i=0;i<MSGT_MAX;i++){
|
|
|
|
mp_msg_levels[i]=verbose;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mp_msg_c( int x, const char *format, ... ){
|
|
|
|
va_list va;
|
|
|
|
if((x&255)>mp_msg_levels[x>>8]) return; // do not display
|
|
|
|
va_start(va, format);
|
2002-01-15 17:03:19 +00:00
|
|
|
#if defined( HAVE_NEW_GUI ) && !defined( HAVE_MENCODER )
|
2001-09-26 18:40:57 +00:00
|
|
|
if(use_gui){
|
2001-12-03 21:10:18 +00:00
|
|
|
char tmp[16*80];
|
2001-09-26 18:40:57 +00:00
|
|
|
vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0;
|
|
|
|
switch( x&255 ) {
|
2001-09-20 10:27:24 +00:00
|
|
|
case MSGL_FATAL:
|
|
|
|
fprintf( stderr,"%s",tmp );
|
2001-12-27 00:34:00 +00:00
|
|
|
fflush(stderr);
|
2001-09-26 18:40:57 +00:00
|
|
|
gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp );
|
2001-09-20 10:27:24 +00:00
|
|
|
break;
|
|
|
|
case MSGL_ERR:
|
|
|
|
fprintf( stderr,"%s",tmp );
|
2001-12-27 00:34:00 +00:00
|
|
|
fflush(stderr);
|
2001-09-26 18:40:57 +00:00
|
|
|
gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp );
|
2001-09-20 10:27:24 +00:00
|
|
|
break;
|
|
|
|
case MSGL_WARN:
|
2002-02-28 08:26:20 +00:00
|
|
|
fprintf( stderr, "%s",tmp );
|
2001-12-27 00:34:00 +00:00
|
|
|
fflush(stdout);
|
2001-09-26 18:40:57 +00:00
|
|
|
gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp );
|
2001-09-20 10:27:24 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-02-28 08:26:20 +00:00
|
|
|
fprintf(stderr, "%s",tmp );
|
2001-12-27 00:34:00 +00:00
|
|
|
fflush(stdout);
|
2001-09-26 18:40:57 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if((x&255)<=MSGL_ERR){
|
|
|
|
// fprintf(stderr,"%%%%%% ");
|
|
|
|
vfprintf(stderr,format, va);
|
2001-12-27 00:34:00 +00:00
|
|
|
fflush(stderr);
|
2001-09-26 18:40:57 +00:00
|
|
|
} else {
|
|
|
|
// printf("%%%%%% ");
|
2002-02-28 08:26:20 +00:00
|
|
|
vfprintf(stderr,format, va);
|
2001-12-27 00:34:00 +00:00
|
|
|
fflush(stdout);
|
2001-09-26 18:40:57 +00:00
|
|
|
}
|
|
|
|
va_end(va);
|
2001-08-16 22:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err)
|
|
|
|
static FILE* mp_msg_last_file=NULL;
|
|
|
|
|
|
|
|
// how to handle errors->stderr messages->stdout ?
|
|
|
|
void mp_msg( int x, const char *format, ... ){
|
|
|
|
if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display
|
|
|
|
va_list va;
|
|
|
|
va_start(va, format);
|
|
|
|
vfprintf(mp_msg_file[x>>8],format, va);
|
|
|
|
if(mp_msg_last_file!=mp_msg_file[x>>8]){
|
|
|
|
fflush(mp_msg_file[x>>8]);
|
|
|
|
mp_msg_last_file=mp_msg_file[x>>8];
|
|
|
|
}
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|