src/3rdparty/libpng/pngwio.c
changeset 30 5dc02b23752f
parent 0 1918ee327afb
--- a/src/3rdparty/libpng/pngwio.c	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/3rdparty/libpng/pngwio.c	Tue Jul 06 15:10:48 2010 +0300
@@ -1,8 +1,8 @@
 
 /* pngwio.c - functions for data output
  *
- * Last changed in libpng 1.2.37 [June 4, 2009]
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
+ * Last changed in libpng 1.4.0 [January 3, 2010]
+ * Copyright (c) 1998-2010 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -18,9 +18,10 @@
  * them at run time with png_set_write_fn(...).
  */
 
-#define PNG_INTERNAL
+#define PNG_NO_PEDANTIC_WARNINGS
 #include "png.h"
 #ifdef PNG_WRITE_SUPPORTED
+#include "pngpriv.h"
 
 /* Write the data to whatever output you are using.  The default routine
  * writes to a file pointer.  Note that this routine sometimes gets called
@@ -38,7 +39,7 @@
       png_error(png_ptr, "Call to NULL write function");
 }
 
-#if !defined(PNG_NO_STDIO)
+#ifdef PNG_STDIO_SUPPORTED
 /* This is the function that does the actual writing of data.  If you are
  * not writing to a standard C stream, you should create a replacement
  * write_data function and use it at run time with png_set_write_fn(), rather
@@ -52,12 +53,7 @@
 
    if (png_ptr == NULL)
       return;
-#if defined(_WIN32_WCE)
-   if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
-      check = 0;
-#else
    check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
-#endif
    if (check != length)
       png_error(png_ptr, "Write Error");
 }
@@ -84,12 +80,7 @@
    io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
    if ((png_bytep)near_data == data)
    {
-#if defined(_WIN32_WCE)
-      if ( !WriteFile(io_ptr, near_data, length, &check, NULL) )
-         check = 0;
-#else
       check = fwrite(near_data, 1, length, io_ptr);
-#endif
    }
    else
    {
@@ -101,12 +92,7 @@
       {
          written = MIN(NEAR_BUF_SIZE, remaining);
          png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
-#if defined(_WIN32_WCE)
-         if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
-            err = 0;
-#else
          err = fwrite(buf, 1, written, io_ptr);
-#endif
          if (err != written)
             break;
 
@@ -129,7 +115,7 @@
  * to disk).  After png_flush is called, there should be no data pending
  * writing in any buffers.
  */
-#if defined(PNG_WRITE_FLUSH_SUPPORTED)
+#ifdef PNG_WRITE_FLUSH_SUPPORTED
 void /* PRIVATE */
 png_flush(png_structp png_ptr)
 {
@@ -137,19 +123,15 @@
       (*(png_ptr->output_flush_fn))(png_ptr);
 }
 
-#if !defined(PNG_NO_STDIO)
+#ifdef PNG_STDIO_SUPPORTED
 void PNGAPI
 png_default_flush(png_structp png_ptr)
 {
-#if !defined(_WIN32_WCE)
    png_FILE_p io_ptr;
-#endif
    if (png_ptr == NULL)
       return;
-#if !defined(_WIN32_WCE)
    io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
    fflush(io_ptr);
-#endif
 }
 #endif
 #endif
@@ -192,7 +174,7 @@
 
    png_ptr->io_ptr = io_ptr;
 
-#if !defined(PNG_NO_STDIO)
+#ifdef PNG_STDIO_SUPPORTED
    if (write_data_fn != NULL)
       png_ptr->write_data_fn = write_data_fn;
 
@@ -202,8 +184,8 @@
    png_ptr->write_data_fn = write_data_fn;
 #endif
 
-#if defined(PNG_WRITE_FLUSH_SUPPORTED)
-#if !defined(PNG_NO_STDIO)
+#ifdef PNG_WRITE_FLUSH_SUPPORTED
+#ifdef PNG_STDIO_SUPPORTED
    if (output_flush_fn != NULL)
       png_ptr->output_flush_fn = output_flush_fn;
 
@@ -221,12 +203,12 @@
       png_warning(png_ptr,
          "Attempted to set both read_data_fn and write_data_fn in");
       png_warning(png_ptr,
-         "the same structure.  Resetting read_data_fn to NULL.");
+         "the same structure.  Resetting read_data_fn to NULL");
    }
 }
 
-#if defined(USE_FAR_KEYWORD)
-#if defined(_MSC_VER)
+#ifdef USE_FAR_KEYWORD
+#ifdef _MSC_VER
 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
 {
    void *near_ptr;