| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #include "pngpriv.h" |
| |
| #ifdef PNG_READ_SUPPORTED |
| |
| |
| |
| |
| |
| |
| |
| void |
| png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length) |
| { |
| png_debug1(4, "reading %d bytes", (int)length); |
| |
| if (png_ptr->read_data_fn != NULL) |
| (*(png_ptr->read_data_fn))(png_ptr, data, length); |
| |
| else |
| png_error(png_ptr, "Call to NULL read function"); |
| } |
| |
| #ifdef PNG_STDIO_SUPPORTED |
| |
| |
| |
| |
| |
| void PNGCBAPI |
| png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) |
| { |
| png_size_t check; |
| |
| if (png_ptr == NULL) |
| return; |
| |
| |
| |
| |
| check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr)); |
| |
| if (check != length) |
| png_error(png_ptr, "Read Error"); |
| } |
| #endif |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void PNGAPI |
| png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, |
| png_rw_ptr read_data_fn) |
| { |
| if (png_ptr == NULL) |
| return; |
| |
| png_ptr->io_ptr = io_ptr; |
| |
| #ifdef PNG_STDIO_SUPPORTED |
| if (read_data_fn != NULL) |
| png_ptr->read_data_fn = read_data_fn; |
| |
| else |
| png_ptr->read_data_fn = png_default_read_data; |
| #else |
| png_ptr->read_data_fn = read_data_fn; |
| #endif |
| |
| #ifdef PNG_WRITE_SUPPORTED |
| |
| if (png_ptr->write_data_fn != NULL) |
| { |
| png_ptr->write_data_fn = NULL; |
| png_warning(png_ptr, |
| "Can't set both read_data_fn and write_data_fn in the" |
| " same structure"); |
| } |
| #endif |
| |
| #ifdef PNG_WRITE_FLUSH_SUPPORTED |
| png_ptr->output_flush_fn = NULL; |
| #endif |
| } |
| #endif |