|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this change, libtiff relied on global error handlers,
which is problematic when libtiff used by multiple independent
libraries from within the same process, as they may unwittingly
clobber the error handling, introduce race conditions when setting
handlers, or otherwise have unintended side effects.
This change adds error handlers to the TIFF struct, which are
used preferentially when available. The error handlers are invoked
when the re-entrant error functions are called:
void TIFFErrorExtR(TIFF*, const char* module, const char* fmt, ...)
void TIFFWarningExtR(TIFF*, const char* module, const char* fmt, ...)
The handlers have a similar signature to the existing extended
handlers, additionally returning an int:
int TIFFErrorHandlerExtR(thandle_t, const char*, const char*, va_list)
thandle_t is the userdata passed to TIFFOpen
When the handler returns 1, the global handlers are not called.
Custom error/warning handlers may be installed on a per-file
basis by calling the Set functions:
TIFF* tif = TIFFOpen(...);
TIFFSetErrorHandlerExtR(tif, MyErrorHandler);
TIFFSetWarningHandlerExtR(tif, MyWarningHandler);
Additionally, the callsites to TIFFErrorExt and TIFFWarningExt
have been updated to call the reentrant versions.
|