Redirect libTIFF errors and Warnings
This commit is contained in:
parent
addf8d9798
commit
40dd718dd1
@ -41,15 +41,6 @@ extern void GFX2_Log(GFX2_Log_priority_T priority, const char * fmt, ...)
|
|||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
GFX2_LogV(priority, fmt, ap);
|
GFX2_LogV(priority, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
{
|
|
||||||
char message[1024];
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(message, sizeof(message), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
OutputDebugStringA(message);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void GFX2_LogV(GFX2_Log_priority_T priority, const char * fmt, va_list ap)
|
extern void GFX2_LogV(GFX2_Log_priority_T priority, const char * fmt, va_list ap)
|
||||||
@ -83,6 +74,13 @@ extern void GFX2_LogV(GFX2_Log_priority_T priority, const char * fmt, va_list ap
|
|||||||
#else
|
#else
|
||||||
vfprintf((unsigned)priority >= GFX2_INFO ? stdout : stderr, fmt, ap);
|
vfprintf((unsigned)priority >= GFX2_INFO ? stdout : stderr, fmt, ap);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||||
|
{
|
||||||
|
char message[1024];
|
||||||
|
vsnprintf(message, sizeof(message), fmt, ap);
|
||||||
|
OutputDebugStringA(message);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void GFX2_LogHexDump(GFX2_Log_priority_T priority, const char * header, const byte * data, long offset, long count)
|
extern void GFX2_LogHexDump(GFX2_Log_priority_T priority, const char * header, const byte * data, long offset, long count)
|
||||||
|
|||||||
@ -22,8 +22,6 @@
|
|||||||
///@file tifformat.c
|
///@file tifformat.c
|
||||||
/// Support of TIFF
|
/// Support of TIFF
|
||||||
///
|
///
|
||||||
/// @todo use TIFFSetErrorHandler() and TIFFSetWarningHandler() to
|
|
||||||
/// redirect warning/error output to our own functions
|
|
||||||
|
|
||||||
#ifndef __no_tifflib__
|
#ifndef __no_tifflib__
|
||||||
|
|
||||||
@ -43,6 +41,37 @@
|
|||||||
extern char Program_version[]; // generated in pversion.c
|
extern char Program_version[]; // generated in pversion.c
|
||||||
extern const char SVN_revision[]; // generated in version.c
|
extern const char SVN_revision[]; // generated in version.c
|
||||||
|
|
||||||
|
|
||||||
|
static void TIFF_LogError(const char* module, const char* fmt, va_list ap)
|
||||||
|
{
|
||||||
|
char format[256];
|
||||||
|
snprintf(format, sizeof(format), "%s: %s\n", module, fmt);
|
||||||
|
GFX2_LogV(GFX2_ERROR, format, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TIFF_LogWarning(const char* module, const char* fmt, va_list ap)
|
||||||
|
{
|
||||||
|
char format[256];
|
||||||
|
snprintf(format, sizeof(format), "%s: %s\n", module, fmt);
|
||||||
|
GFX2_LogV(GFX2_WARNING, format, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initialisation for using the TIFF library
|
||||||
|
static void TIFF_Init(void)
|
||||||
|
{
|
||||||
|
static int init_done = 0;
|
||||||
|
|
||||||
|
if (init_done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/// use TIFFSetErrorHandler() and TIFFSetWarningHandler() to
|
||||||
|
/// redirect warning/error output to our own functions
|
||||||
|
TIFFSetErrorHandler(TIFF_LogError);
|
||||||
|
TIFFSetWarningHandler(TIFF_LogWarning);
|
||||||
|
|
||||||
|
init_done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/// test for a valid TIFF
|
/// test for a valid TIFF
|
||||||
void Test_TIFF(T_IO_Context * context, FILE * file)
|
void Test_TIFF(T_IO_Context * context, FILE * file)
|
||||||
{
|
{
|
||||||
@ -366,6 +395,7 @@ void Load_TIFF(T_IO_Context * context)
|
|||||||
file = Open_file_read(context);
|
file = Open_file_read(context);
|
||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
|
TIFF_Init();
|
||||||
tif = TIFFFdOpen(fileno(file), context->File_name, "r");
|
tif = TIFFFdOpen(fileno(file), context->File_name, "r");
|
||||||
if (tif != NULL)
|
if (tif != NULL)
|
||||||
{
|
{
|
||||||
@ -379,6 +409,7 @@ void Load_TIFF(T_IO_Context * context)
|
|||||||
|
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
Get_full_filename(filename, context->File_name, context->File_directory);
|
||||||
|
TIFF_Init();
|
||||||
tif = TIFFOpen(filename, "r");
|
tif = TIFFOpen(filename, "r");
|
||||||
if (tif != NULL)
|
if (tif != NULL)
|
||||||
{
|
{
|
||||||
@ -468,6 +499,7 @@ void Save_TIFF(T_IO_Context * context)
|
|||||||
|
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
|
|
||||||
|
TIFF_Init();
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
if (context->File_name_unicode != NULL && context->File_name_unicode[0] != 0)
|
if (context->File_name_unicode != NULL && context->File_name_unicode[0] != 0)
|
||||||
tif = TIFFOpenW(context->File_name_unicode, "w");
|
tif = TIFFOpenW(context->File_name_unicode, "w");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user