Mercurial > mplayer.hg
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 |
rev | line source |
---|---|
7200 | 1 |
2 //#define MSG_USE_COLORS | |
1562 | 3 |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <stdarg.h> | |
7 | |
1925 | 8 #include "config.h" |
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 | 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 | 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 | 16 extern int use_gui; |
17 #endif | |
1562 | 18 #include "mp_msg.h" |
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 | 23 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module |
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 | 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 | 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 | 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 | 36 fprintf(stdout, "Current dirname: %s\n\n", bindtextdomain(textdomain(NULL),NULL)); |
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 | 43 int i; |
44 for(i=0;i<MSGT_MAX;i++){ | |
45 mp_msg_levels[i]=verbose; | |
46 } | |
47 } | |
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 | 54 void mp_msg(int mod, int lev, const char *format, ... ){ |
5102 | 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 | 57 |
16618 | 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 | 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 | 64 |
16618 | 65 #ifdef HAVE_NEW_GUI |
5102 | 66 if(use_gui) |
16618 | 67 guiMessageBox(lev, tmp); |
5102 | 68 #endif |
69 | |
7200 | 70 #ifdef MSG_USE_COLORS |
10415 | 71 /* that's only a silly color test */ |
16379 | 72 #ifdef MP_ANNOY_ME |
7200 | 73 { int c; |
74 static int flag=1; | |
75 if(flag) | |
16379 | 76 for(c=0;c<24;c++) |
7200 | 77 printf("\033[%d;3%dm*** COLOR TEST %d ***\n",(c>7),c&7,c); |
78 flag=0; | |
79 } | |
80 #endif | |
16379 | 81 { unsigned char v_colors[10]={9,1,3,15,7,2,2,8,8,8}; |
82 static const char *lev_text[]= { | |
83 "FATAL", | |
84 "ERROR", | |
85 "WARN", | |
86 "HINT", | |
87 "INFO", | |
88 "STATUS", | |
89 "V", | |
90 "DGB2", | |
91 "DGB3", | |
92 "DGB4"}; | |
93 static const char *mod_text[]= { | |
94 "GLOBAL", | |
95 "CPLAYER", | |
96 "GPLAYER", | |
97 "VIDEOOUT", | |
98 "AUDIOOUT", | |
99 "DEMUXER", | |
100 "DS", | |
101 "DEMUX", | |
102 "HEADER", | |
103 "AVSYNC", | |
104 "AUTOQ", | |
105 "CFGPARSER", | |
106 "DECAUDIO", | |
107 "DECVIDEO", | |
108 "SEEK", | |
109 "WIN32", | |
110 "OPEN", | |
111 "DVD", | |
112 "PARSEES", | |
113 "LIRC", | |
114 "STREAM", | |
115 "CACHE", | |
116 "MENCODER", | |
117 "XACODEC", | |
118 "TV", | |
119 "OSDEP", | |
120 "SPUDEC", | |
121 "PLAYTREE", | |
122 "INPUT", | |
123 "VFILTER", | |
124 "OSD", | |
125 "NETWORK", | |
126 "CPUDETECT", | |
127 "CODECCFG", | |
128 "SWS", | |
129 "VOBSUB", | |
130 "SUBREADER", | |
131 "AFILTER", | |
132 "NETST", | |
133 "MUXER"}; | |
134 | |
16618 | 135 int c=v_colors[lev]; |
136 int c2=(mod+1)%15+1; | |
16379 | 137 static int header=1; |
16618 | 138 FILE *stream= (lev) <= MSGL_WARN ? stderr : stdout; |
16379 | 139 if(header){ |
16618 | 140 fprintf(stream, "\033[%d;3%dm%9s\033[0;37m: ",c2>>3,c2&7, mod_text[mod]); |
16379 | 141 } |
142 fprintf(stream, "\033[%d;3%dm",c>>3,c&7); | |
143 header= tmp[strlen(tmp)-1] == '\n' | |
144 /*||tmp[strlen(tmp)-1] == '\r'*/; | |
7200 | 145 } |
146 #endif | |
16618 | 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 | 152 } |