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

Functions

void png_write_data (png_structrp png_ptr, png_const_bytep data, png_size_t length)
 
void png_default_write_data (png_structp png_ptr, png_bytep data, png_size_t length)
 
void png_flush (png_structrp png_ptr)
 
void png_default_flush (png_structp png_ptr)
 
void png_set_write_fn (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
 

Function Documentation

void png_write_data ( png_structrp  png_ptr,
png_const_bytep  data,
png_size_t  length 
)
34 {
35  /* NOTE: write_data_fn must not change the buffer! */
36  if (png_ptr->write_data_fn != NULL )
37  (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
38  length);
39 
40  else
41  png_error(png_ptr, "Call to NULL write function");
42 }
png_byte * png_bytep
Definition: pngconf.h:600
png_rw_ptr write_data_fn
Definition: pngstruct.h:157
#define png_constcast(type, value)
Definition: pngpriv.h:409
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_write_data ( png_structp  png_ptr,
png_bytep  data,
png_size_t  length 
)
52 {
53  png_size_t check;
54 
55  if (png_ptr == NULL)
56  return;
57 
58  check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
59 
60  if (check != length)
61  png_error(png_ptr, "Write Error");
62 }
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_flush ( png_structrp  png_ptr)
72 {
73  if (png_ptr->output_flush_fn != NULL)
74  (*(png_ptr->output_flush_fn))(png_ptr);
75 }
void png_default_flush ( png_structp  png_ptr)
80 {
81  png_FILE_p io_ptr;
82 
83  if (png_ptr == NULL)
84  return;
85 
86  io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
87  fflush(io_ptr);
88 }
#define png_voidcast(type, value)
Definition: pngpriv.h:408
png_voidp io_ptr
Definition: pngstruct.h:159
void png_set_write_fn ( png_structrp  png_ptr,
png_voidp  io_ptr,
png_rw_ptr  write_data_fn,
png_flush_ptr  output_flush_fn 
)
124 {
125  if (png_ptr == NULL)
126  return;
127 
128  png_ptr->io_ptr = io_ptr;
129 
130 #ifdef PNG_STDIO_SUPPORTED
131  if (write_data_fn != NULL)
132  png_ptr->write_data_fn = write_data_fn;
133 
134  else
136 #else
137  png_ptr->write_data_fn = write_data_fn;
138 #endif
139 
140 #ifdef PNG_WRITE_FLUSH_SUPPORTED
141 # ifdef PNG_STDIO_SUPPORTED
142 
143  if (output_flush_fn != NULL)
144  png_ptr->output_flush_fn = output_flush_fn;
145 
146  else
147  png_ptr->output_flush_fn = png_default_flush;
148 
149 # else
150  png_ptr->output_flush_fn = output_flush_fn;
151 # endif
152 #else
153  PNG_UNUSED(output_flush_fn)
154 #endif /* WRITE_FLUSH */
155 
156 #ifdef PNG_READ_SUPPORTED
157  /* It is an error to read while writing a png file */
158  if (png_ptr->read_data_fn != NULL)
159  {
160  png_ptr->read_data_fn = NULL;
161 
162  png_warning(png_ptr,
163  "Can't set both read_data_fn and write_data_fn in the"
164  " same structure");
165  }
166 #endif
167 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
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
png_rw_ptr write_data_fn
Definition: pngstruct.h:157
void png_default_flush(png_structp png_ptr)
Definition: pngwio.c:79
png_voidp io_ptr
Definition: pngstruct.h:159
void png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngwio.c:51