Mercurial > mplayer.hg
comparison mp_msg.c @ 1562:2caba2f48026
new message printing system
author | arpi |
---|---|
date | Thu, 16 Aug 2001 22:13:20 +0000 |
parents | |
children | 0199567db534 |
comparison
equal
deleted
inserted
replaced
1561:e71337d1e58b | 1562:2caba2f48026 |
---|---|
1 | |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <stdarg.h> | |
5 | |
6 #include "mp_msg.h" | |
7 | |
8 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module | |
9 | |
10 #if 1 | |
11 | |
12 void mp_msg_init(int verbose){ | |
13 int i; | |
14 for(i=0;i<MSGT_MAX;i++){ | |
15 mp_msg_levels[i]=verbose; | |
16 } | |
17 } | |
18 | |
19 void mp_msg_c( int x, const char *format, ... ){ | |
20 va_list va; | |
21 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
22 va_start(va, format); | |
23 if((x&255)<=MSGL_ERROR){ | |
24 vfprintf(stderr,format, va); | |
25 } else { | |
26 vprintf(format, va); | |
27 } | |
28 va_end(va); | |
29 } | |
30 | |
31 #else | |
32 | |
33 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err) | |
34 static FILE* mp_msg_last_file=NULL; | |
35 | |
36 // how to handle errors->stderr messages->stdout ? | |
37 void mp_msg( int x, const char *format, ... ){ | |
38 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display | |
39 va_list va; | |
40 va_start(va, format); | |
41 vfprintf(mp_msg_file[x>>8],format, va); | |
42 if(mp_msg_last_file!=mp_msg_file[x>>8]){ | |
43 fflush(mp_msg_file[x>>8]); | |
44 mp_msg_last_file=mp_msg_file[x>>8]; | |
45 } | |
46 va_end(va); | |
47 } | |
48 | |
49 #endif |