annotate mp_msg.c @ 1881:d75b24bda7ce

Applied fix for mixercontrol w/alsa ossemu by Christian Ohm.
author atmos4
date Tue, 11 Sep 2001 16:26:41 +0000
parents 913c1ee56b4f
children 633a7f0d72a4
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
2caba2f48026 new message printing system
arpi
parents:
diff changeset
6 #include "mp_msg.h"
2caba2f48026 new message printing system
arpi
parents:
diff changeset
7
2caba2f48026 new message printing system
arpi
parents:
diff changeset
8 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
2caba2f48026 new message printing system
arpi
parents:
diff changeset
9
2caba2f48026 new message printing system
arpi
parents:
diff changeset
10 #if 1
2caba2f48026 new message printing system
arpi
parents:
diff changeset
11
2caba2f48026 new message printing system
arpi
parents:
diff changeset
12 void mp_msg_init(int verbose){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
13 int i;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
14 for(i=0;i<MSGT_MAX;i++){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
15 mp_msg_levels[i]=verbose;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
16 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
17 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
18
2caba2f48026 new message printing system
arpi
parents:
diff changeset
19 void mp_msg_c( int x, const char *format, ... ){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
20 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
21 if((x&255)>mp_msg_levels[x>>8]) return; // do not display
2caba2f48026 new message printing system
arpi
parents:
diff changeset
22 va_start(va, format);
1563
0199567db534 constans shortend
arpi
parents: 1562
diff changeset
23 if((x&255)<=MSGL_ERR){
1566
913c1ee56b4f updated
arpi
parents: 1563
diff changeset
24 // fprintf(stderr,"%%%%%% ");
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
25 vfprintf(stderr,format, va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
26 } else {
1566
913c1ee56b4f updated
arpi
parents: 1563
diff changeset
27 // printf("%%%%%% ");
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
28 vprintf(format, va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
29 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
30 va_end(va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
31 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
32
2caba2f48026 new message printing system
arpi
parents:
diff changeset
33 #else
2caba2f48026 new message printing system
arpi
parents:
diff changeset
34
2caba2f48026 new message printing system
arpi
parents:
diff changeset
35 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err)
2caba2f48026 new message printing system
arpi
parents:
diff changeset
36 static FILE* mp_msg_last_file=NULL;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
37
2caba2f48026 new message printing system
arpi
parents:
diff changeset
38 // how to handle errors->stderr messages->stdout ?
2caba2f48026 new message printing system
arpi
parents:
diff changeset
39 void mp_msg( int x, const char *format, ... ){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
40 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
41 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
42 va_start(va, format);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
43 vfprintf(mp_msg_file[x>>8],format, va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
44 if(mp_msg_last_file!=mp_msg_file[x>>8]){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
45 fflush(mp_msg_file[x>>8]);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
46 mp_msg_last_file=mp_msg_file[x>>8];
2caba2f48026 new message printing system
arpi
parents:
diff changeset
47 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
48 va_end(va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
49 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
50
2caba2f48026 new message printing system
arpi
parents:
diff changeset
51 #endif