summaryrefslogtreecommitdiffstats
path: root/Gui/error.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-25 21:04:29 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-25 21:04:29 +0000
commit9f6529b3d3a1ec681a84735d57a9f2d8656809af (patch)
tree4943e4a95c68932a956ce7a693c58f5b2ed79b37 /Gui/error.c
parent05f7ab93841eef7bf50c31b64bf723c100e0c123 (diff)
downloadmpv-9f6529b3d3a1ec681a84735d57a9f2d8656809af.tar.bz2
mpv-9f6529b3d3a1ec681a84735d57a9f2d8656809af.tar.xz
GUI version n-1
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1694 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'Gui/error.c')
-rw-r--r--Gui/error.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/Gui/error.c b/Gui/error.c
new file mode 100644
index 0000000000..65cad72b7d
--- /dev/null
+++ b/Gui/error.c
@@ -0,0 +1,61 @@
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "error.h"
+
+int debug_level = 6;
+FILE * debug_file;
+int debug_stderr = 0;
+
+void defaultErrorHandler( int critical,const char * format, ... )
+{
+ char * p;
+ va_list ap;
+
+ if ( (p=(char *)malloc( 512 ) ) == NULL ) return;
+ va_start( ap,format );
+ vsnprintf( p,512,format,ap );
+ va_end( ap );
+ fprintf( stderr,"%s",p );
+ free( p );
+ if ( critical ) exit( 1 );
+}
+
+void defaultDebugHandler( int critical,const char * format, ... )
+{
+ char * p;
+ va_list ap;
+
+ if ( critical >= debug_level ) return;
+ if ( (p=(char *)malloc( 512 ) ) == NULL ) return;
+ va_start( ap,format );
+ vsnprintf( p,512,format,ap );
+ va_end( ap );
+ fprintf( debug_file,"%s",p );
+ free( p );
+}
+
+errorTHandler message = defaultErrorHandler;
+errorTHandler dbprintf = defaultDebugHandler;
+
+void initDebug( char * name )
+{
+ if ( name )
+ {
+ if ( ( debug_file=fopen( name,"wt+" ) ) != NULL )
+ {
+ debug_stderr=0;
+ return;
+ }
+ }
+ debug_file=stderr;
+ debug_stderr=1;
+}
+void doneDebug( void )
+{
+ if ( !debug_stderr ) fclose( debug_file );
+ debug_file=stderr;
+ debug_stderr=1;
+}