COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
pngrio.c File Reference
#include "pngpriv.h"
Include dependency graph for pngrio.c:

Functions

void png_read_data (png_structrp png_ptr, png_bytep data, png_size_t length)
 
void png_default_read_data (png_structp png_ptr, png_bytep data, png_size_t length)
 
void png_set_read_fn (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
 

Function Documentation

void png_read_data ( png_structrp  png_ptr,
png_bytep  data,
png_size_t  length 
)
33 {
34  png_debug1(4, "reading %d bytes", (int)length);
35 
36  if (png_ptr->read_data_fn != NULL)
37  (*(png_ptr->read_data_fn))(png_ptr, data, length);
38 
39  else
40  png_error(png_ptr, "Call to NULL read function");
41 }
png_rw_ptr read_data_fn
Definition: pngstruct.h:158
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 length
Definition: png.c:2173
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
void png_default_read_data ( png_structp  png_ptr,
png_bytep  data,
png_size_t  length 
)
51 {
52  png_size_t check;
53 
54  if (png_ptr == NULL)
55  return;
56 
57  /* fread() returns 0 on error, so it is OK to store this in a png_size_t
58  * instead of an int, which is what fread() actually returns.
59  */
60  check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
61 
62  if (check != length)
63  png_error(png_ptr, "Read Error");
64 }
#define png_voidcast(type, value)
Definition: pngpriv.h:408
png_voidp io_ptr
Definition: pngstruct.h:159
png_uint_32 length
Definition: png.c:2173
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
size_t png_size_t
Definition: pngconf.h:543
void png_set_read_fn ( png_structrp  png_ptr,
png_voidp  io_ptr,
png_rw_ptr  read_data_fn 
)
89 {
90  if (png_ptr == NULL)
91  return;
92 
93  png_ptr->io_ptr = io_ptr;
94 
95 #ifdef PNG_STDIO_SUPPORTED
96  if (read_data_fn != NULL)
97  png_ptr->read_data_fn = read_data_fn;
98 
99  else
101 #else
102  png_ptr->read_data_fn = read_data_fn;
103 #endif
104 
105 #ifdef PNG_WRITE_SUPPORTED
106  /* It is an error to write to a read device */
107  if (png_ptr->write_data_fn != NULL)
108  {
109  png_ptr->write_data_fn = NULL;
110  png_warning(png_ptr,
111  "Can't set both read_data_fn and write_data_fn in the"
112  " same structure");
113  }
114 #endif
115 
116 #ifdef PNG_WRITE_FLUSH_SUPPORTED
117  png_ptr->output_flush_fn = NULL;
118 #endif
119 }
png_rw_ptr read_data_fn
Definition: pngstruct.h:158
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
void png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngrio.c:50
png_rw_ptr write_data_fn
Definition: pngstruct.h:157
png_voidp io_ptr
Definition: pngstruct.h:159