summaryrefslogtreecommitdiff
path: root/pngrio.c
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2010-01-02 23:05:45 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2010-01-02 23:15:33 -0600
commit7e3a82cd9cdd6b9619a7ababce4f1dadf5e6fbaf (patch)
tree40112f08a4330cf86b98d31ed87d4922f64100bf /pngrio.c
parent115817d118aa6c8ece819d6b9e2b76f37268ce44 (diff)
downloadlibpng-7e3a82cd9cdd6b9619a7ababce4f1dadf5e6fbaf.tar.gz
[master] Imported from libpng-1.4.0.tarv1.4.0
Diffstat (limited to 'pngrio.c')
-rw-r--r--pngrio.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/pngrio.c b/pngrio.c
index 9ce073794..53f2a4527 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,8 +1,8 @@
/* pngrio.c - functions for data input
*
- * Last changed in libpng 1.2.41 [December 3, 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,10 +18,10 @@
* libpng use it at run time with png_set_read_fn(...).
*/
-#define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h"
#ifdef PNG_READ_SUPPORTED
+#include "pngpriv.h"
/* Read the data from whatever input you are using. The default routine
* reads from a file pointer. Note that this routine sometimes gets called
@@ -57,13 +57,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
* instead of an int, which is what fread() actually returns.
*/
-#ifdef _WIN32_WCE
- if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
- check = 0;
-#else
- check = (png_size_t)fread(data, (png_size_t)1, length,
- (png_FILE_p)png_ptr->io_ptr);
-#endif
+ check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
if (check != length)
png_error(png_ptr, "Read Error");
@@ -80,7 +74,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
static void PNGAPI
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
- int check;
+ png_size_t check;
png_byte *n_data;
png_FILE_p io_ptr;
@@ -91,12 +85,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
if ((png_bytep)n_data == data)
{
-#ifdef _WIN32_WCE
- if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
- check = 0;
-#else
check = fread(n_data, 1, length, io_ptr);
-#endif
}
else
{
@@ -107,12 +96,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
do
{
read = MIN(NEAR_BUF_SIZE, remaining);
-#ifdef _WIN32_WCE
- if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
- err = 0;
-#else
- err = fread(buf, (png_size_t)1, read, io_ptr);
-#endif
+ err = fread(buf, 1, read, io_ptr);
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
if (err != read)
break;
@@ -169,7 +153,7 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
png_warning(png_ptr,
"It's an error to set both read_data_fn and write_data_fn in the ");
png_warning(png_ptr,
- "same structure. Resetting write_data_fn to NULL.");
+ "same structure. Resetting write_data_fn to NULL");
}
#ifdef PNG_WRITE_FLUSH_SUPPORTED