diff options
author | Jeff Muizelaar <jeff@infidigm.net> | 2005-06-02 00:35:44 +0000 |
---|---|---|
committer | Jeff Muizelaar <jeff@infidigm.net> | 2005-06-02 00:35:44 +0000 |
commit | 9f0da96dd005defd5d82dd05b627ff1925430215 (patch) | |
tree | bacb8cbfd888bc33454377c04d7358abd881465f /poppler/Error.cc | |
parent | f688aa11d066f1c6f4115cbdb604ac61fb8b5146 (diff) |
2005-06-01 Jeff Muizelaar <jeff@infidigm.net>
* poppler/Error.cc:
* poppler/Error.h: Make error handling function setable through
setErrorFunction.
Based on a patch by Albert Astals Cid.
Diffstat (limited to 'poppler/Error.cc')
-rw-r--r-- | poppler/Error.cc | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/poppler/Error.cc b/poppler/Error.cc index 03d29e09..f3b98b95 100644 --- a/poppler/Error.cc +++ b/poppler/Error.cc @@ -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); +} |