Mercurial > mplayer.hg
annotate mp_msg.c @ 5210:ba800cb05b94
comments on compiling
author | arpi |
---|---|
date | Wed, 20 Mar 2002 01:39:09 +0000 |
parents | 17f97ed8259e |
children | 4afbe13150e6 |
rev | line source |
---|---|
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 | |
1562 | 13 #include "mp_msg.h" |
14 | |
15 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module | |
16 | |
17 #if 1 | |
18 | |
19 void mp_msg_init(int verbose){ | |
20 int i; | |
21 for(i=0;i<MSGT_MAX;i++){ | |
22 mp_msg_levels[i]=verbose; | |
23 } | |
24 } | |
25 | |
26 void mp_msg_c( int x, const char *format, ... ){ | |
5102 | 27 #if 1 |
28 va_list va; | |
29 char tmp[2048]; | |
30 | |
31 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
32 va_start(va, mp_gettext(format)); | |
33 vsnprintf(tmp, 2048, mp_gettext(format), va); | |
34 tmp[2047] = 0; | |
35 | |
36 #if defined(HAVE_NEW_GUI) && !defined(HAVE_MENCODER) | |
37 if(use_gui) | |
38 { | |
39 switch(x & 255) | |
40 { | |
41 case MSGL_FATAL: | |
42 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, tmp); | |
43 break; | |
44 case MSGL_ERR: | |
45 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, tmp); | |
46 break; | |
47 case MSGL_WARN: | |
48 gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, tmp); | |
49 break; | |
50 } | |
51 } | |
52 #endif | |
53 | |
54 fprintf(stderr, "%s", tmp); | |
55 if ((x & 255) <= MSGL_ERR) | |
56 fflush(stderr); | |
57 else | |
58 fflush(stdout); | |
59 | |
60 va_end(va); | |
61 #else | |
1562 | 62 va_list va; |
63 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
64 va_start(va, format); | |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3780
diff
changeset
|
65 #if defined( HAVE_NEW_GUI ) && !defined( HAVE_MENCODER ) |
1971 | 66 if(use_gui){ |
3293 | 67 char tmp[16*80]; |
1971 | 68 vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0; |
69 switch( x&255 ) { | |
1925 | 70 case MSGL_FATAL: |
71 fprintf( stderr,"%s",tmp ); | |
3780 | 72 fflush(stderr); |
1971 | 73 gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp ); |
1925 | 74 break; |
75 case MSGL_ERR: | |
76 fprintf( stderr,"%s",tmp ); | |
3780 | 77 fflush(stderr); |
1971 | 78 gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp ); |
1925 | 79 break; |
80 case MSGL_WARN: | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
81 fprintf( stderr, "%s",tmp ); |
3780 | 82 fflush(stdout); |
1971 | 83 gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp ); |
1925 | 84 break; |
85 default: | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
86 fprintf(stderr, "%s",tmp ); |
3780 | 87 fflush(stdout); |
1971 | 88 } |
89 } else | |
90 #endif | |
91 if((x&255)<=MSGL_ERR){ | |
92 // fprintf(stderr,"%%%%%% "); | |
93 vfprintf(stderr,format, va); | |
3780 | 94 fflush(stderr); |
1971 | 95 } else { |
96 // printf("%%%%%% "); | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
97 vfprintf(stderr,format, va); |
3780 | 98 fflush(stdout); |
1971 | 99 } |
100 va_end(va); | |
5102 | 101 #endif |
1562 | 102 } |
103 | |
104 #else | |
105 | |
106 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err) | |
107 static FILE* mp_msg_last_file=NULL; | |
108 | |
109 // how to handle errors->stderr messages->stdout ? | |
110 void mp_msg( int x, const char *format, ... ){ | |
111 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display | |
112 va_list va; | |
113 va_start(va, format); | |
114 vfprintf(mp_msg_file[x>>8],format, va); | |
115 if(mp_msg_last_file!=mp_msg_file[x>>8]){ | |
116 fflush(mp_msg_file[x>>8]); | |
117 mp_msg_last_file=mp_msg_file[x>>8]; | |
118 } | |
119 va_end(va); | |
120 } | |
121 | |
122 #endif |