annotate mp_msg.c @ 6668:4e3493443b36

100l - seq++ for grouping
author arpi
date Sun, 07 Jul 2002 20:06:55 +0000
parents 786ab42c10be
children 2e5c07262861
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
1
2caba2f48026 new message printing system
arpi
parents:
diff changeset
2 #include <stdio.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
3 #include <stdlib.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
4 #include <stdarg.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
5
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
6 #include "config.h"
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
7
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
8 #ifdef HAVE_NEW_GUI
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
9 #include "Gui/mplayer/widgets.h"
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
10 extern void gtkMessageBox( int type,char * str );
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
11 extern int use_gui;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
12 #endif
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
13 #include "mp_msg.h"
2caba2f48026 new message printing system
arpi
parents:
diff changeset
14
6306
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
15 /* maximum message length of mp_msg */
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
16 #define MSGSIZE_MAX 3072
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
17
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
18 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
2caba2f48026 new message printing system
arpi
parents:
diff changeset
19
2caba2f48026 new message printing system
arpi
parents:
diff changeset
20 #if 1
2caba2f48026 new message printing system
arpi
parents:
diff changeset
21
5220
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
22 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
23 #ifdef USE_I18N
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
24 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
25 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
26 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
27 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
28 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
29 textdomain("mplayer");
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
30 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
31 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
32 #endif
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
33 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
34 }
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
35
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
36 void mp_msg_set_level(int verbose){
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
37 int i;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
38 for(i=0;i<MSGT_MAX;i++){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
39 mp_msg_levels[i]=verbose;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
40 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
41 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
42
2caba2f48026 new message printing system
arpi
parents:
diff changeset
43 void mp_msg_c( int x, const char *format, ... ){
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
44 #if 1
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
45 va_list va;
6306
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
46 char tmp[MSGSIZE_MAX];
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
47
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
48 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
49 va_start(va, format);
6306
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
50 vsnprintf(tmp, MSGSIZE_MAX, mp_gettext(format), va);
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
51 tmp[MSGSIZE_MAX-1] = 0;
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
52
6048
4301077b29d0 HAVE_MENCODER->FOR_MENCODER (forgot to commit some weeks ago...)
arpi
parents: 5919
diff changeset
53 #if defined(HAVE_NEW_GUI) && !defined(FOR_MENCODER)
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
54 if(use_gui)
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
55 {
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
56 switch(x & 255)
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
57 {
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
58 case MSGL_FATAL:
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
59 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, tmp);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
60 break;
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
61 case MSGL_ERR:
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
62 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, tmp);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
63 break;
5919
60cf2bca993f some bug fix
pontscho
parents: 5901
diff changeset
64 // case MSGL_WARN:
60cf2bca993f some bug fix
pontscho
parents: 5901
diff changeset
65 // gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, tmp);
60cf2bca993f some bug fix
pontscho
parents: 5901
diff changeset
66 // break;
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
67 }
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
68 }
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
69 #endif
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
70
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
71 fprintf(stderr, "%s", tmp);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
72 if ((x & 255) <= MSGL_ERR)
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
73 fflush(stderr);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
74 else
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
75 fflush(stdout);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
76
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
77 va_end(va);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
78 #else
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
79 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
80 if((x&255)>mp_msg_levels[x>>8]) return; // do not display
2caba2f48026 new message printing system
arpi
parents:
diff changeset
81 va_start(va, format);
6048
4301077b29d0 HAVE_MENCODER->FOR_MENCODER (forgot to commit some weeks ago...)
arpi
parents: 5919
diff changeset
82 #if defined( HAVE_NEW_GUI ) && !defined( FOR_MENCODER )
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
83 if(use_gui){
3293
fc74fe43eb89 msg limit increased
arpi
parents: 1971
diff changeset
84 char tmp[16*80];
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
85 vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0;
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
86 switch( x&255 ) {
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
87 case MSGL_FATAL:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
88 fprintf( stderr,"%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
89 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
90 gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
91 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
92 case MSGL_ERR:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
93 fprintf( stderr,"%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
94 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
95 gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
96 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
97 case MSGL_WARN:
4888
cb2adf32c356 Use stdout as default mencoder's output if no filename specified
nick
parents: 4176
diff changeset
98 fprintf( stderr, "%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
99 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
100 gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
101 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
102 default:
4888
cb2adf32c356 Use stdout as default mencoder's output if no filename specified
nick
parents: 4176
diff changeset
103 fprintf(stderr, "%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
104 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
105 }
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
106 } else
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
107 #endif
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
108 if((x&255)<=MSGL_ERR){
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
109 // fprintf(stderr,"%%%%%% ");
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
110 vfprintf(stderr,format, va);
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
111 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
112 } else {
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
113 // printf("%%%%%% ");
4888
cb2adf32c356 Use stdout as default mencoder's output if no filename specified
nick
parents: 4176
diff changeset
114 vfprintf(stderr,format, va);
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
115 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
116 }
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
117 va_end(va);
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
118 #endif
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
119 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
120
2caba2f48026 new message printing system
arpi
parents:
diff changeset
121 #else
2caba2f48026 new message printing system
arpi
parents:
diff changeset
122
2caba2f48026 new message printing system
arpi
parents:
diff changeset
123 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err)
2caba2f48026 new message printing system
arpi
parents:
diff changeset
124 static FILE* mp_msg_last_file=NULL;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
125
2caba2f48026 new message printing system
arpi
parents:
diff changeset
126 // how to handle errors->stderr messages->stdout ?
2caba2f48026 new message printing system
arpi
parents:
diff changeset
127 void mp_msg( int x, const char *format, ... ){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
128 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display
2caba2f48026 new message printing system
arpi
parents:
diff changeset
129 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
130 va_start(va, format);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
131 vfprintf(mp_msg_file[x>>8],format, va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
132 if(mp_msg_last_file!=mp_msg_file[x>>8]){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
133 fflush(mp_msg_file[x>>8]);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
134 mp_msg_last_file=mp_msg_file[x>>8];
2caba2f48026 new message printing system
arpi
parents:
diff changeset
135 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
136 va_end(va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
137 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
138
2caba2f48026 new message printing system
arpi
parents:
diff changeset
139 #endif