annotate mp_msg.c @ 4778:85d041ad0c87

3 mails describing hwac3 tech details
author arpi
date Thu, 21 Feb 2002 02:01:46 +0000
parents 116abdd0aed1
children cb2adf32c356
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
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
13
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
14 #include "mp_msg.h"
2caba2f48026 new message printing system
arpi
parents:
diff changeset
15
2caba2f48026 new message printing system
arpi
parents:
diff changeset
16 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
2caba2f48026 new message printing system
arpi
parents:
diff changeset
17
2caba2f48026 new message printing system
arpi
parents:
diff changeset
18 #if 1
2caba2f48026 new message printing system
arpi
parents:
diff changeset
19
2caba2f48026 new message printing system
arpi
parents:
diff changeset
20 void mp_msg_init(int verbose){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
21 int i;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
22 for(i=0;i<MSGT_MAX;i++){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
23 mp_msg_levels[i]=verbose;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
24 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
25 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
26
2caba2f48026 new message printing system
arpi
parents:
diff changeset
27 void mp_msg_c( int x, const char *format, ... ){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
28 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
29 if((x&255)>mp_msg_levels[x>>8]) return; // do not display
2caba2f48026 new message printing system
arpi
parents:
diff changeset
30 va_start(va, format);
4176
116abdd0aed1 small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents: 3780
diff changeset
31 #if defined( HAVE_NEW_GUI ) && !defined( HAVE_MENCODER )
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
32 if(use_gui){
3293
fc74fe43eb89 msg limit increased
arpi
parents: 1971
diff changeset
33 char tmp[16*80];
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
34 vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0;
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
35 switch( x&255 ) {
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
36 case MSGL_FATAL:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
37 fprintf( stderr,"%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
38 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
39 gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
40 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
41 case MSGL_ERR:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
42 fprintf( stderr,"%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
43 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
44 gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
45 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
46 case MSGL_WARN:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
47 printf( "%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
48 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
49 gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
50 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
51 default:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
52 printf( "%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
53 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
54 }
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
55 } else
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
56 #endif
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
57 if((x&255)<=MSGL_ERR){
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
58 // fprintf(stderr,"%%%%%% ");
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
59 vfprintf(stderr,format, va);
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
60 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
61 } else {
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
62 // printf("%%%%%% ");
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
63 vprintf(format, va);
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
64 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
65 }
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
66 va_end(va);
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
67 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
68
2caba2f48026 new message printing system
arpi
parents:
diff changeset
69 #else
2caba2f48026 new message printing system
arpi
parents:
diff changeset
70
2caba2f48026 new message printing system
arpi
parents:
diff changeset
71 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err)
2caba2f48026 new message printing system
arpi
parents:
diff changeset
72 static FILE* mp_msg_last_file=NULL;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
73
2caba2f48026 new message printing system
arpi
parents:
diff changeset
74 // how to handle errors->stderr messages->stdout ?
2caba2f48026 new message printing system
arpi
parents:
diff changeset
75 void mp_msg( int x, const char *format, ... ){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
76 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
77 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
78 va_start(va, format);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
79 vfprintf(mp_msg_file[x>>8],format, va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
80 if(mp_msg_last_file!=mp_msg_file[x>>8]){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
81 fflush(mp_msg_file[x>>8]);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
82 mp_msg_last_file=mp_msg_file[x>>8];
2caba2f48026 new message printing system
arpi
parents:
diff changeset
83 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
84 va_end(va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
85 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
86
2caba2f48026 new message printing system
arpi
parents:
diff changeset
87 #endif