struct mszip_stream *mszip_init(int fd,
				  int ofd,
				  int input_buffer_size,
				  int repair_mode,
				  struct cab_file *file,
			          int (*read_cb)(struct cab_file *, unsigned char *, int))
{
  struct mszip_stream *zip;

  input_buffer_size = (input_buffer_size + 1) & -2;
  if (!input_buffer_size) return NULL;

  /* allocate decompression state */
  if (!(zip = cli_calloc(1, sizeof(struct mszip_stream)))) {
    return NULL;
  }

  /* allocate input buffer */
  zip->inbuf  = cli_malloc((size_t) input_buffer_size);
  if (!zip->inbuf) {
    free(zip);
    return NULL;
  }

  /* initialise decompression state */
  zip->fd	       = fd;
  zip->ofd	       = ofd;
  zip->wflag	       = 1;
  zip->inbuf_size      = input_buffer_size;
  zip->error           = CL_SUCCESS;
  zip->repair_mode     = repair_mode;
  zip->flush_window    = &mszip_flush_window;
  zip->input_end       = 0;

  zip->i_ptr = zip->i_end = &zip->inbuf[0];
  zip->o_ptr = zip->o_end = NULL;
  zip->bit_buffer = 0; zip->bits_left = 0;

  zip->file = file;
  zip->read_cb = read_cb;

  return zip;
}
struct mszip_stream *mszip_init(int fd,
				  int ofd,
				  int input_buffer_size,
				  int repair_mode,
				  struct cab_file *file,
			          int (*read_cb)(struct cab_file *, unsigned char *, int))
{
  struct mszip_stream *zip;

  input_buffer_size = (input_buffer_size + 1) & -2;
  if (!input_buffer_size) return NULL;

   
  if (!(zip = cli_calloc(1, sizeof(struct mszip_stream)))) {
    return NULL;
  }

   
  zip->inbuf  = cli_malloc((size_t) input_buffer_size);
  if (!zip->inbuf) {
    free(zip);
    return NULL;
  }

   
  zip->fd	       = fd;
  zip->ofd	       = ofd;
  zip->wflag	       = 1;
  zip->inbuf_size      = input_buffer_size;
  zip->error           = CL_SUCCESS;
  zip->repair_mode     = repair_mode;
  zip->flush_window    = &mszip_flush_window;
  zip->input_end       = 0;

  zip->i_ptr = zip->i_end = &zip->inbuf[0];
  zip->o_ptr = zip->o_end = NULL;
  zip->bit_buffer = 0; zip->bits_left = 0;

  zip->file = file;
  zip->read_cb = read_cb;

  return zip;
}