1562
|
1
|
|
2 #include <stdio.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <stdarg.h>
|
|
5
|
1925
|
6 #include "config.h"
|
|
7
|
|
8 #ifdef HAVE_NEW_GUI
|
|
9 #include "Gui/mplayer/widgets.h"
|
|
10 extern void gtkMessageBox( int type,char * str );
|
|
11 extern int use_gui;
|
|
12 #endif
|
|
13
|
1562
|
14 #include "mp_msg.h"
|
|
15
|
|
16 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
|
|
17
|
|
18 #if 1
|
|
19
|
|
20 void mp_msg_init(int verbose){
|
|
21 int i;
|
|
22 for(i=0;i<MSGT_MAX;i++){
|
|
23 mp_msg_levels[i]=verbose;
|
|
24 }
|
|
25 }
|
|
26
|
|
27 void mp_msg_c( int x, const char *format, ... ){
|
|
28 va_list va;
|
1934
|
29 char tmp[8*80];
|
1562
|
30 if((x&255)>mp_msg_levels[x>>8]) return; // do not display
|
|
31 va_start(va, format);
|
1925
|
32 vsnprintf( tmp,128,format,va );
|
|
33 /*
|
1563
|
34 if((x&255)<=MSGL_ERR){
|
1566
|
35 // fprintf(stderr,"%%%%%% ");
|
1562
|
36 vfprintf(stderr,format, va);
|
|
37 } else {
|
1566
|
38 // printf("%%%%%% ");
|
1562
|
39 vprintf(format, va);
|
|
40 }
|
1925
|
41 */
|
1562
|
42 va_end(va);
|
1925
|
43 switch( x&255 )
|
|
44 {
|
|
45 case MSGL_FATAL:
|
|
46 fprintf( stderr,"%s",tmp );
|
|
47 #ifdef HAVE_NEW_GUI
|
|
48 if ( use_gui ) gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp );
|
|
49 #endif
|
|
50 break;
|
|
51 case MSGL_ERR:
|
|
52 fprintf( stderr,"%s",tmp );
|
|
53 #ifdef HAVE_NEW_GUI
|
|
54 if ( use_gui ) gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp );
|
|
55 #endif
|
|
56 break;
|
|
57 case MSGL_WARN:
|
|
58 printf( "%s",tmp );
|
|
59 #ifdef HAVE_NEW_GUI
|
|
60 if ( use_gui ) gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp );
|
|
61 #endif
|
|
62 break;
|
|
63 default:
|
|
64 printf( "%s",tmp );
|
|
65 break;
|
|
66 }
|
1562
|
67 }
|
|
68
|
|
69 #else
|
|
70
|
|
71 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err)
|
|
72 static FILE* mp_msg_last_file=NULL;
|
|
73
|
|
74 // how to handle errors->stderr messages->stdout ?
|
|
75 void mp_msg( int x, const char *format, ... ){
|
|
76 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display
|
|
77 va_list va;
|
|
78 va_start(va, format);
|
|
79 vfprintf(mp_msg_file[x>>8],format, va);
|
|
80 if(mp_msg_last_file!=mp_msg_file[x>>8]){
|
|
81 fflush(mp_msg_file[x>>8]);
|
|
82 mp_msg_last_file=mp_msg_file[x>>8];
|
|
83 }
|
|
84 va_end(va);
|
|
85 }
|
|
86
|
|
87 #endif
|