Mercurial > mplayer.hg
annotate mp_msg.c @ 5673:1186930949c0
cbr mp3 + wmp fixed (hopefully, untested)
author | arpi |
---|---|
date | Thu, 18 Apr 2002 14:23:07 +0000 |
parents | 30caf02c0eae |
children | 6d7131d79ce0 |
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 | |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
19 void mp_msg_init(){ |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
20 #ifdef USE_I18N |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
21 fprintf(stdout, "Using GNU internationalization\n"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
22 fprintf(stdout, "Original domain: %s\n", textdomain(NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
23 fprintf(stdout, "Original dirname: %s\n", bindtextdomain(textdomain(NULL),NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
24 setlocale(LC_ALL, ""); /* set from the environment variables */ |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
25 bindtextdomain("mplayer", PREFIX"/share/locale"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
26 textdomain("mplayer"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
27 fprintf(stdout, "Current domain: %s\n", textdomain(NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
28 fprintf(stdout, "Current dirname: %s\n", bindtextdomain(textdomain(NULL),NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
29 #endif |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
30 mp_msg_set_level(MSGL_STATUS); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
31 } |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
32 |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
33 void mp_msg_set_level(int verbose){ |
1562 | 34 int i; |
35 for(i=0;i<MSGT_MAX;i++){ | |
36 mp_msg_levels[i]=verbose; | |
37 } | |
38 } | |
39 | |
40 void mp_msg_c( int x, const char *format, ... ){ | |
5102 | 41 #if 1 |
42 va_list va; | |
43 char tmp[2048]; | |
44 | |
45 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
5286
30caf02c0eae
10l - va_start needs teh pointer to stack - not the translated message
arpi
parents:
5220
diff
changeset
|
46 va_start(va, format); |
5102 | 47 vsnprintf(tmp, 2048, mp_gettext(format), va); |
48 tmp[2047] = 0; | |
49 | |
50 #if defined(HAVE_NEW_GUI) && !defined(HAVE_MENCODER) | |
51 if(use_gui) | |
52 { | |
53 switch(x & 255) | |
54 { | |
55 case MSGL_FATAL: | |
56 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, tmp); | |
57 break; | |
58 case MSGL_ERR: | |
59 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, tmp); | |
60 break; | |
61 case MSGL_WARN: | |
62 gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, tmp); | |
63 break; | |
64 } | |
65 } | |
66 #endif | |
67 | |
68 fprintf(stderr, "%s", tmp); | |
69 if ((x & 255) <= MSGL_ERR) | |
70 fflush(stderr); | |
71 else | |
72 fflush(stdout); | |
73 | |
74 va_end(va); | |
75 #else | |
1562 | 76 va_list va; |
77 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
78 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
|
79 #if defined( HAVE_NEW_GUI ) && !defined( HAVE_MENCODER ) |
1971 | 80 if(use_gui){ |
3293 | 81 char tmp[16*80]; |
1971 | 82 vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0; |
83 switch( x&255 ) { | |
1925 | 84 case MSGL_FATAL: |
85 fprintf( stderr,"%s",tmp ); | |
3780 | 86 fflush(stderr); |
1971 | 87 gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp ); |
1925 | 88 break; |
89 case MSGL_ERR: | |
90 fprintf( stderr,"%s",tmp ); | |
3780 | 91 fflush(stderr); |
1971 | 92 gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp ); |
1925 | 93 break; |
94 case MSGL_WARN: | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
95 fprintf( stderr, "%s",tmp ); |
3780 | 96 fflush(stdout); |
1971 | 97 gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp ); |
1925 | 98 break; |
99 default: | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
100 fprintf(stderr, "%s",tmp ); |
3780 | 101 fflush(stdout); |
1971 | 102 } |
103 } else | |
104 #endif | |
105 if((x&255)<=MSGL_ERR){ | |
106 // fprintf(stderr,"%%%%%% "); | |
107 vfprintf(stderr,format, va); | |
3780 | 108 fflush(stderr); |
1971 | 109 } else { |
110 // printf("%%%%%% "); | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
111 vfprintf(stderr,format, va); |
3780 | 112 fflush(stdout); |
1971 | 113 } |
114 va_end(va); | |
5102 | 115 #endif |
1562 | 116 } |
117 | |
118 #else | |
119 | |
120 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err) | |
121 static FILE* mp_msg_last_file=NULL; | |
122 | |
123 // how to handle errors->stderr messages->stdout ? | |
124 void mp_msg( int x, const char *format, ... ){ | |
125 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display | |
126 va_list va; | |
127 va_start(va, format); | |
128 vfprintf(mp_msg_file[x>>8],format, va); | |
129 if(mp_msg_last_file!=mp_msg_file[x>>8]){ | |
130 fflush(mp_msg_file[x>>8]); | |
131 mp_msg_last_file=mp_msg_file[x>>8]; | |
132 } | |
133 va_end(va); | |
134 } | |
135 | |
136 #endif |