diff libinterp/corefcn/__tiff__.cc @ 31161:b731c8f6db95

Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors * Tiff.m: added PKG_ADD directive to disable errors at package load time. * __tiff__.cc: added __tiff_set_errors_enabled__ function to enable or disable LibTIFF error output.
author magedrifaat <magedrifaat@gmail.com>
date Wed, 10 Aug 2022 16:01:51 +0200
parents 5f0c3da75926
children 28817158ca86
line wrap: on
line diff
--- a/libinterp/corefcn/__tiff__.cc	Wed Aug 10 00:58:12 2022 +0200
+++ b/libinterp/corefcn/__tiff__.cc	Wed Aug 10 16:01:51 2022 +0200
@@ -20,6 +20,7 @@
 
 #if defined (HAVE_TIFF)
 #  include <tiffio.h>
+TIFFErrorHandler tiff_default_handler = NULL;
 #endif
 
 namespace octave
@@ -2366,4 +2367,21 @@
 #endif
   }
 
+  DEFUN (__tiff_set_errors_enabled__, args, ,
+         "Enables or Disables error output from LibTIFF")
+  {
+#if defined (HAVE_TIFF)
+    if (args (0).bool_value ())
+      TIFFSetErrorHandler (tiff_default_handler);
+    else if (tiff_default_handler == NULL)
+      tiff_default_handler = TIFFSetErrorHandler (NULL);
+    else
+      TIFFSetErrorHandler (NULL);
+
+    return octave_value_list ();
+#else
+    err_disabled_feature ("setErrorEnabled", "Tiff");
+#endif
+  }
+
 }