[poppler] poppler/poppler: Error.cc, 1.1.1.1, 1.2 Error.h, 1.1.1.1, 1.2

Jeff Muizelaar jrmuizel at freedesktop.org
Wed Jun 1 17:35:46 PDT 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv10470/poppler

Modified Files:
	Error.cc Error.h 
Log Message:
2005-06-01  Jeff Muizelaar  <jeff at infidigm.net>

	* poppler/Error.cc:
	* poppler/Error.h: Make error handling function setable through
	setErrorFunction.

	Based on a patch by Albert Astals Cid.


Index: Error.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Error.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Error.cc	3 Mar 2005 19:46:02 -0000	1.1.1.1
+++ Error.cc	2 Jun 2005 00:35:44 -0000	1.2
@@ -18,21 +18,32 @@
 #include "GlobalParams.h"
 #include "Error.h"
 
-void CDECL error(int pos, char *msg, ...) {
-  va_list args;
-
-  // NB: this can be called before the globalParams object is created
-  if (globalParams && globalParams->getErrQuiet()) {
-    return;
-  }
+static void CDECL defaultErrorFunction(int pos, char *msg, va_list args)
+{
   if (pos >= 0) {
     fprintf(stderr, "Error (%d): ", pos);
   } else {
     fprintf(stderr, "Error: ");
   }
-  va_start(args, msg);
   vfprintf(stderr, msg, args);
-  va_end(args);
   fprintf(stderr, "\n");
   fflush(stderr);
 }
+
+static void CDECL (*errorFunction)(int , char *, va_list args) = defaultErrorFunction;
+
+void setErrorFunction(void CDECL (* f)(int , char *, va_list args))
+{
+    errorFunction = f;
+}
+
+void CDECL error(int pos, char *msg, ...) {
+  va_list args;
+  // NB: this can be called before the globalParams object is created
+  if (globalParams && globalParams->getErrQuiet()) {
+    return;
+  }
+  va_start(args, msg);
+  (*errorFunction)(pos, msg, args);
+  va_end(args);
+}

Index: Error.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Error.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Error.h	3 Mar 2005 19:46:00 -0000	1.1.1.1
+++ Error.h	2 Jun 2005 00:35:44 -0000	1.2
@@ -18,4 +18,6 @@
 
 extern void CDECL error(int pos, char *msg, ...);
 
+void setErrorFunction(void (* f)(int , char *, va_list args));
+
 #endif



More information about the poppler mailing list