
#include "jpeglib.h"
#include "jerror.h"

typedef int (*jpeg_func_t)(void *buf, int count, void *arg);

struct my_source_mgr {
  struct jpeg_source_mgr pub;
  jpeg_func_t fill;
  void *arg;
  char buf[32768];
};

struct my_error_mgr {
  struct jpeg_error_mgr pub;
  jmp_buf setjmp_buffer;
};

void jpeg_init(j_decompress_ptr cinfo, struct my_error_mgr *jerr, jpeg_func_t fill, void *arg);
int jpeg_read(j_decompress_ptr cinfo, void *buf, int count);
void jpeg_cleanup(j_decompress_ptr cinfo);
