pngerror.c
Upload User: caisha3
Upload Date: 2013-09-21
Package Size: 208739k
Code Size: 4k
Category:

Windows Develop

Development Platform:

Visual C++

  1. /* pngerror.c - stub functions for i/o and memory allocation
  2.    libpng 1.0 beta 2 - version 0.88
  3.    For conditions of distribution and use, see copyright notice in png.h
  4.    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  5.    January 25, 1996
  6.    This file provides a location for all error handling.  Users which
  7.    need special error handling are expected to write replacement functions
  8.    and use png_set_message_fn() to use those functions.  See the instructions
  9.    at each function. */
  10. #ifdef NEVER
  11. #define PNG_INTERNAL
  12. #include "png.h"
  13. #endif
  14. #include "headers.h"
  15. /* This function is called whenever there is a fatal error.  This function
  16.    should not be changed.  If there is a need to handle errors differently,
  17.    you should supply a replacement error function and use png_set_message_fn()
  18.    to replace the error function at run-time. */
  19. void
  20. png_error(png_structp png_ptr, png_const_charp message)
  21. {
  22.    if (png_ptr->error_fn)
  23.       (*(png_ptr->error_fn))(png_ptr, message);
  24.    /* if the following returns or doesn't exist, use the default function,
  25.       which will not return */
  26.    png_default_error(png_ptr, message);
  27. }
  28. /* This function is called whenever there is a non-fatal error.  This function
  29.    should not be changed.  If there is a need to handle warnings differently,
  30.    you should supply a replacement warning function and use
  31.    png_set_message_fn() to replace the warning function at run-time. */
  32. void
  33. png_warning(png_structp png_ptr, png_const_charp message)
  34. {
  35.    if (png_ptr->warning_fn)
  36.       (*(png_ptr->warning_fn))(png_ptr, message);
  37.    else
  38.       png_default_warning(png_ptr, message);
  39. }
  40. /* This is the default error handling function.  Note that replacements for
  41.    this function MUST NOT RETURN, or the program will likely crash.  This
  42.    function is used by default, or if the program supplies NULL for the
  43.    error function pointer in png_set_message_fn(). */
  44. void
  45. png_default_error(png_structp png_ptr, png_const_charp message)
  46. {
  47. #ifndef PNG_NO_STDIO
  48.     OutputDebugStringA( "libpng error: " );
  49.     OutputDebugStringA( message );
  50.     OutputDebugStringA( "n" );
  51. #endif
  52. #ifdef USE_FAR_KEYWORD
  53.    {
  54.       jmp_buf jmpbuf;
  55.       png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf));
  56.       longjmp(jmpbuf, 1);
  57.    }
  58. #else
  59.    longjmp(png_ptr->jmpbuf, 1);
  60. #endif
  61. }
  62. /* This function is called when there is a warning, but the library thinks
  63.    it can continue anyway.  Replacement functions don't have to do anything
  64.    here if you don't want to.  In the default configuration, png_ptr is
  65.    not used, but it is passed in case it may be useful. */
  66. void
  67. png_default_warning(png_structp png_ptr, png_const_charp message)
  68. {
  69.    if (!png_ptr)
  70.       return;
  71. #ifndef PNG_NO_STDIO
  72.     OutputDebugStringA( "libpng warning: " );
  73.     OutputDebugStringA( message );
  74.     OutputDebugStringA( "n" );
  75. #endif
  76. }
  77. /* This function is called when the application wants to use another method
  78.    of handling errors and warnings.  Note that the error function MUST NOT
  79.    return to the calling routine or serious problems will occur. The error
  80.    return method used in the default routine calls
  81.    longjmp(png_ptr->jmpbuf, 1) */
  82. void
  83. png_set_message_fn(png_structp png_ptr, png_voidp msg_ptr, png_msg_ptr error_fn,
  84.    png_msg_ptr warning_fn)
  85. {
  86.    png_ptr->msg_ptr = msg_ptr;
  87.    png_ptr->error_fn = error_fn;
  88.    png_ptr->warning_fn = warning_fn;
  89. }
  90. /* This function returns a pointer to the msg_ptr associated with the user
  91.    functions.  The application should free any memory associated with this
  92.    pointer before png_write_destroy and png_read_destroy are called. */
  93. png_voidp
  94. png_get_msg_ptr(png_structp png_ptr)
  95. {
  96.    return png_ptr->msg_ptr;
  97. }