AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2009.02.12 20:12 "[Tiff] Accessing tif->tif_clientdata within my own error and warning functions", by Philip Watkinson
2009.02.13 08:13 "Re: [Tiff] Accessing tif->tif_clientdata within my own error andwarning functions", by
2009.02.17 16:17 "Re: [Tiff] Accessing tif->tif_clientdata within my own error andwarning functions", by Philip Watkinson
2009.02.17 17:04 "[Tiff] FW: Accessing tif->tif_clientdata within my own error andwarning functions", by Philip Watkinson
2009.02.17 18:24 "Re: [Tiff] FW: Accessing tif->tif_clientdata within my own error andwarning functions", by Bob Friesenhahn
2009.02.17 21:11 "Re: [Tiff] Accessing tif->tif_clientdata within my own errorandwarning functions", by
2009.02.17 21:36 "Re: [Tiff] Accessing tif->tif_clientdata within my own error andwarning functions", by

2009.02.13 08:13 "Re: [Tiff] Accessing tif->tif_clientdata within my own error andwarning functions", by

Philip,

For error and warning handling, the default action is write errors and warnings to standard error. You can create your own error and warning functions and set them with TIFFSetErrorHandler() (tif_error.c) and TIFFSetWarningHandler() (tif_warning.c). Error and warning messages are created with TIFFError() and TIFFWarning(). These functions can then call my own error and warning functions.

I would like to be able to access my structure pointed to by TIFF->tif_clientdata within my functions. I would like to buffer error and warning messages in my structure instead of using stderr. Unfortunately a pointer to TIFF is not passed to TIFFError() or TIFFWarning().

Is there another to control warning and error messages? I'm using version 3.7.1.

Is it possible in a future release to include access to tif->tif_clientdata for custom error and warning functions?

We've all had the same problem at one time or another, and I've cured it recently. In recent versions, the interface you describe here still exists for backwards compatibility, but there is an added interface that is much the same only it has an 'Ext' appended to the function names and it includes the tif->tif_clientdata so as to enable retrieving the context when handling warnings and errors.

I can't say from the top of my head in what version the extended interface got added. I don't think 3.7.1 has it. Do a library-wide search on 'TIFFSetErrorHandlerExt'. If that doesn't yield any search results, then you're out of luck and might need to upgrade to a newer version.

Some people manage to get a context from a global var. Of course, that only works as long as you've at most one TIFF object in your total application at any given time. Some get a context from a threadvar. Of course, that only works if you've at most one TIFF object per thread at any given time. If even the last condition does not apply to your setup, you will indeed need to use the 'Ext' error/warning handler interface in newer versions.

Best regards,

Joris