+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// TIFF library error/warning handlers
+// ----------------------------------------------------------------------------
+
+static wxString
+FormatTiffMessage(const char *module, const char *fmt, va_list ap)
+{
+ char buf[512];
+ if ( wxCRT_VsnprintfA(buf, WXSIZEOF(buf), fmt, ap) <= 0 )
+ {
+ // this isn't supposed to happen, but if it does, it's better
+ // than nothing
+ strcpy(buf, "Incorrectly formatted TIFF message");
+ }
+ buf[WXSIZEOF(buf)-1] = 0; // make sure it is always NULL-terminated
+
+ wxString msg(buf);
+ if ( module )
+ msg += wxString::Format(_(" (in module \"%s\")"), module);
+
+ return msg;
+}
+
+extern "C"
+{
+
+static void
+TIFFwxWarningHandler(const char* module, const char *fmt, va_list ap)
+{
+ wxLogWarning("%s", FormatTiffMessage(module, fmt, ap));
+}
+
+static void
+TIFFwxErrorHandler(const char* module, const char *fmt, va_list ap)
+{
+ wxLogError("%s", FormatTiffMessage(module, fmt, ap));
+}
+
+} // extern "C"
+