annotate mp_msg.c @ 16731:be1316b8d1f6

solaris bug workarounds, take 2..
author rfelker
date Tue, 11 Oct 2005 22:50:23 +0000
parents bad73cd81b23
children 05af35012e4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7200
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
1
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
2 //#define MSG_USE_COLORS
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
3
2caba2f48026 new message printing system
arpi
parents:
diff changeset
4 #include <stdio.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
5 #include <stdlib.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
6 #include <stdarg.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
7
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
8 #include "config.h"
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
9
8573
b2e4f9dab7ad codec-cfg cannot be built when the gui is enabled - it fails to link with a
jkeil
parents: 7205
diff changeset
10 #if defined(FOR_MENCODER) || defined(CODECS2HTML)
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
11 #undef HAVE_NEW_GUI
8573
b2e4f9dab7ad codec-cfg cannot be built when the gui is enabled - it fails to link with a
jkeil
parents: 7205
diff changeset
12 #endif
b2e4f9dab7ad codec-cfg cannot be built when the gui is enabled - it fails to link with a
jkeil
parents: 7205
diff changeset
13
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
14 #ifdef HAVE_NEW_GUI
16374
e2e231134056 Remove many annoying GTK includes in every compile line and remove GTK
ods15
parents: 14542
diff changeset
15 #include "Gui/interface.h"
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
16 extern int use_gui;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
17 #endif
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
18 #include "mp_msg.h"
2caba2f48026 new message printing system
arpi
parents:
diff changeset
19
6306
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
20 /* 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
21 #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
22
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
23 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
2caba2f48026 new message printing system
arpi
parents:
diff changeset
24
5220
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
25 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
26 #ifdef USE_I18N
10415
c1247b33c424 moved some annonying messages to debug mode only
alex
parents: 8573
diff changeset
27 #ifdef MP_DEBUG
5220
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
28 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
29 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
30 fprintf(stdout, "Original dirname: %s\n", bindtextdomain(textdomain(NULL),NULL));
10415
c1247b33c424 moved some annonying messages to debug mode only
alex
parents: 8573
diff changeset
31 #endif
5220
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
32 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
33 textdomain("mplayer");
10415
c1247b33c424 moved some annonying messages to debug mode only
alex
parents: 8573
diff changeset
34 #ifdef MP_DEBUG
5220
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
35 fprintf(stdout, "Current domain: %s\n", textdomain(NULL));
10415
c1247b33c424 moved some annonying messages to debug mode only
alex
parents: 8573
diff changeset
36 fprintf(stdout, "Current dirname: %s\n\n", bindtextdomain(textdomain(NULL),NULL));
c1247b33c424 moved some annonying messages to debug mode only
alex
parents: 8573
diff changeset
37 #endif
5220
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
38 #endif
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
39 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
40 }
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
41
4afbe13150e6 splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents: 5102
diff changeset
42 void mp_msg_set_level(int verbose){
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
43 int i;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
44 for(i=0;i<MSGT_MAX;i++){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
45 mp_msg_levels[i]=verbose;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
46 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
47 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
48
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6306
diff changeset
49 int mp_msg_test(int mod, int lev)
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6306
diff changeset
50 {
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6306
diff changeset
51 return lev <= mp_msg_levels[mod];
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6306
diff changeset
52 }
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6306
diff changeset
53
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
54 void mp_msg(int mod, int lev, const char *format, ... ){
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
55 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
56 char tmp[MSGSIZE_MAX];
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
57
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
58 if (lev > mp_msg_levels[mod]) return; // do not display
5286
30caf02c0eae 10l - va_start needs teh pointer to stack - not the translated message
arpi
parents: 5220
diff changeset
59 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
60 vsnprintf(tmp, MSGSIZE_MAX, mp_gettext(format), va);
7195
a5b2566f3c2b print only fatal/error/warning to stderr, others go to stdout
arpi
parents: 7058
diff changeset
61 va_end(va);
10853
1e04ac498440 force a new line if a message is very long
pl
parents: 10415
diff changeset
62 tmp[MSGSIZE_MAX-2] = '\n';
6306
786ab42c10be Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents: 6048
diff changeset
63 tmp[MSGSIZE_MAX-1] = 0;
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
64
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
65 #ifdef HAVE_NEW_GUI
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
66 if(use_gui)
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
67 guiMessageBox(lev, tmp);
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
68 #endif
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
69
7200
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
70 #ifdef MSG_USE_COLORS
10415
c1247b33c424 moved some annonying messages to debug mode only
alex
parents: 8573
diff changeset
71 /* that's only a silly color test */
16379
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
72 #ifdef MP_ANNOY_ME
7200
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
73 { int c;
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
74 static int flag=1;
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
75 if(flag)
16379
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
76 for(c=0;c<24;c++)
7200
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
77 printf("\033[%d;3%dm*** COLOR TEST %d ***\n",(c>7),c&7,c);
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
78 flag=0;
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
79 }
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
80 #endif
16379
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
81 { unsigned char v_colors[10]={9,1,3,15,7,2,2,8,8,8};
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
82 static const char *lev_text[]= {
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
83 "FATAL",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
84 "ERROR",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
85 "WARN",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
86 "HINT",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
87 "INFO",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
88 "STATUS",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
89 "V",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
90 "DGB2",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
91 "DGB3",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
92 "DGB4"};
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
93 static const char *mod_text[]= {
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
94 "GLOBAL",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
95 "CPLAYER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
96 "GPLAYER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
97 "VIDEOOUT",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
98 "AUDIOOUT",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
99 "DEMUXER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
100 "DS",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
101 "DEMUX",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
102 "HEADER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
103 "AVSYNC",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
104 "AUTOQ",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
105 "CFGPARSER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
106 "DECAUDIO",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
107 "DECVIDEO",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
108 "SEEK",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
109 "WIN32",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
110 "OPEN",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
111 "DVD",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
112 "PARSEES",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
113 "LIRC",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
114 "STREAM",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
115 "CACHE",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
116 "MENCODER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
117 "XACODEC",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
118 "TV",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
119 "OSDEP",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
120 "SPUDEC",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
121 "PLAYTREE",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
122 "INPUT",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
123 "VFILTER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
124 "OSD",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
125 "NETWORK",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
126 "CPUDETECT",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
127 "CODECCFG",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
128 "SWS",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
129 "VOBSUB",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
130 "SUBREADER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
131 "AFILTER",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
132 "NETST",
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
133 "MUXER"};
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
134
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
135 int c=v_colors[lev];
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
136 int c2=(mod+1)%15+1;
16379
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
137 static int header=1;
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
138 FILE *stream= (lev) <= MSGL_WARN ? stderr : stdout;
16379
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
139 if(header){
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
140 fprintf(stream, "\033[%d;3%dm%9s\033[0;37m: ",c2>>3,c2&7, mod_text[mod]);
16379
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
141 }
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
142 fprintf(stream, "\033[%d;3%dm",c>>3,c&7);
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
143 header= tmp[strlen(tmp)-1] == '\n'
cdd8c0dfc19b improve colorization
michael
parents: 16374
diff changeset
144 /*||tmp[strlen(tmp)-1] == '\r'*/;
7200
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
145 }
9a123ba671fd - warnings enabled for GUI mode
arpi
parents: 7195
diff changeset
146 #endif
16618
bad73cd81b23 mp_msg cleanup.
ods15
parents: 16379
diff changeset
147 if (lev <= MSGL_WARN){
7195
a5b2566f3c2b print only fatal/error/warning to stderr, others go to stdout
arpi
parents: 7058
diff changeset
148 fprintf(stderr, "%s", tmp);fflush(stderr);
a5b2566f3c2b print only fatal/error/warning to stderr, others go to stdout
arpi
parents: 7058
diff changeset
149 } else {
a5b2566f3c2b print only fatal/error/warning to stderr, others go to stdout
arpi
parents: 7058
diff changeset
150 printf("%s", tmp);fflush(stdout);
a5b2566f3c2b print only fatal/error/warning to stderr, others go to stdout
arpi
parents: 7058
diff changeset
151 }
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
152 }