< prev index next >

src/java.base/share/native/libzip/zlib/gzwrite.c

Print this page
*** 27,22 ***
   * For conditions of distribution and use, see copyright notice in zlib.h
   */
  
  #include "gzguts.h"
  
- /* Local functions */
- local int gz_init OF((gz_statep));
- local int gz_comp OF((gz_statep, int));
- local int gz_zero OF((gz_statep, z_off64_t));
- local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
- 
  /* Initialize state for writing a gzip file.  Mark initialization by setting
     state->size to non-zero.  Return -1 on a memory allocation failure, or 0 on
     success. */
! local int gz_init(state)
-     gz_statep state;
- {
      int ret;
      z_streamp strm = &(state->strm);
  
      /* allocate input buffer (double size for gzprintf) */
      state->in = (unsigned char *)malloc(state->want << 1);
--- 27,14 ---
   * For conditions of distribution and use, see copyright notice in zlib.h
   */
  
  #include "gzguts.h"
  
  /* Initialize state for writing a gzip file.  Mark initialization by setting
     state->size to non-zero.  Return -1 on a memory allocation failure, or 0 on
     success. */
! local int gz_init(gz_statep state) {
      int ret;
      z_streamp strm = &(state->strm);
  
      /* allocate input buffer (double size for gzprintf) */
      state->in = (unsigned char *)malloc(state->want << 1);

*** 92,14 ***
     Return -1 if there is an error writing to the output file or if gz_init()
     fails to allocate memory, otherwise 0.  flush is assumed to be a valid
     deflate() flush value.  If flush is Z_FINISH, then the deflate() state is
     reset to start a new gzip stream.  If gz->direct is true, then simply write
     to the output file without compressing, and ignore flush. */
! local int gz_comp(state, flush)
-     gz_statep state;
-     int flush;
- {
      int ret, writ;
      unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
      z_streamp strm = &(state->strm);
  
      /* allocate memory if this is the first time through */
--- 84,11 ---
     Return -1 if there is an error writing to the output file or if gz_init()
     fails to allocate memory, otherwise 0.  flush is assumed to be a valid
     deflate() flush value.  If flush is Z_FINISH, then the deflate() state is
     reset to start a new gzip stream.  If gz->direct is true, then simply write
     to the output file without compressing, and ignore flush. */
! local int gz_comp(gz_statep state, int flush) {
      int ret, writ;
      unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
      z_streamp strm = &(state->strm);
  
      /* allocate memory if this is the first time through */

*** 173,14 ***
      return 0;
  }
  
  /* Compress len zeros to output.  Return -1 on a write error or memory
     allocation failure by gz_comp(), or 0 on success. */
! local int gz_zero(state, len)
-     gz_statep state;
-     z_off64_t len;
- {
      int first;
      unsigned n;
      z_streamp strm = &(state->strm);
  
      /* consume whatever's left in the input buffer */
--- 162,11 ---
      return 0;
  }
  
  /* Compress len zeros to output.  Return -1 on a write error or memory
     allocation failure by gz_comp(), or 0 on success. */
! local int gz_zero(gz_statep state, z_off64_t len) {
      int first;
      unsigned n;
      z_streamp strm = &(state->strm);
  
      /* consume whatever's left in the input buffer */

*** 206,15 ***
      return 0;
  }
  
  /* Write len bytes from buf to file.  Return the number of bytes written.  If
     the returned value is less than len, then there was an error. */
! local z_size_t gz_write(state, buf, len)
-     gz_statep state;
-     voidpc buf;
-     z_size_t len;
- {
      z_size_t put = len;
  
      /* if len is zero, avoid unnecessary operations */
      if (len == 0)
          return 0;
--- 192,11 ---
      return 0;
  }
  
  /* Write len bytes from buf to file.  Return the number of bytes written.  If
     the returned value is less than len, then there was an error. */
! local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
      z_size_t put = len;
  
      /* if len is zero, avoid unnecessary operations */
      if (len == 0)
          return 0;

*** 274,15 ***
      /* input was all buffered or compressed */
      return put;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzwrite(file, buf, len)
-     gzFile file;
-     voidpc buf;
-     unsigned len;
- {
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
          return 0;
--- 256,11 ---
      /* input was all buffered or compressed */
      return put;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
          return 0;

*** 302,16 ***
      /* write len bytes from buf (the return value will fit in an int) */
      return (int)gz_write(state, buf, len);
  }
  
  /* -- see zlib.h -- */
! z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
!     voidpc buf;
-     z_size_t size;
-     z_size_t nitems;
-     gzFile file;
- {
      z_size_t len;
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
--- 280,12 ---
      /* write len bytes from buf (the return value will fit in an int) */
      return (int)gz_write(state, buf, len);
  }
  
  /* -- see zlib.h -- */
! z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
!                           gzFile file) {
      z_size_t len;
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)

*** 332,14 ***
      /* write len bytes to buf, return the number of full items written */
      return len ? gz_write(state, buf, len) / size : 0;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzputc(file, c)
-     gzFile file;
-     int c;
- {
      unsigned have;
      unsigned char buf[1];
      gz_statep state;
      z_streamp strm;
  
--- 306,11 ---
      /* write len bytes to buf, return the number of full items written */
      return len ? gz_write(state, buf, len) / size : 0;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzputc(gzFile file, int c) {
      unsigned have;
      unsigned char buf[1];
      gz_statep state;
      z_streamp strm;
  

*** 380,14 ***
          return -1;
      return c & 0xff;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzputs(file, s)
-     gzFile file;
-     const char *s;
- {
      z_size_t len, put;
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
--- 351,11 ---
          return -1;
      return c & 0xff;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzputs(gzFile file, const char *s) {
      z_size_t len, put;
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)

*** 410,12 ***
  
  #if defined(STDC) || defined(Z_HAVE_STDARG_H)
  #include <stdarg.h>
  
  /* -- see zlib.h -- */
! int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
- {
      int len;
      unsigned left;
      char *next;
      gz_statep state;
      z_streamp strm;
--- 378,11 ---
  
  #if defined(STDC) || defined(Z_HAVE_STDARG_H)
  #include <stdarg.h>
  
  /* -- see zlib.h -- */
! int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
      int len;
      unsigned left;
      char *next;
      gz_statep state;
      z_streamp strm;

*** 482,12 ***
          strm->avail_in = left;
      }
      return len;
  }
  
! int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
- {
      va_list va;
      int ret;
  
      va_start(va, format);
      ret = gzvprintf(file, format, va);
--- 449,11 ---
          strm->avail_in = left;
      }
      return len;
  }
  
! int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
      va_list va;
      int ret;
  
      va_start(va, format);
      ret = gzvprintf(file, format, va);

*** 496,17 ***
  }
  
  #else /* !STDC && !Z_HAVE_STDARG_H */
  
  /* -- see zlib.h -- */
! int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
!                        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
!     gzFile file;
!     const char *format;
-     int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
-         a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
- {
      unsigned len, left;
      char *next;
      gz_statep state;
      z_streamp strm;
  
--- 462,14 ---
  }
  
  #else /* !STDC && !Z_HAVE_STDARG_H */
  
  /* -- see zlib.h -- */
! int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
!                        int a4, int a5, int a6, int a7, int a8, int a9, int a10,
!                        int a11, int a12, int a13, int a14, int a15, int a16,
!                        int a17, int a18, int a19, int a20) {
      unsigned len, left;
      char *next;
      gz_statep state;
      z_streamp strm;
  

*** 584,14 ***
  }
  
  #endif
  
  /* -- see zlib.h -- */
! int ZEXPORT gzflush(file, flush)
-     gzFile file;
-     int flush;
- {
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
          return Z_STREAM_ERROR;
--- 547,11 ---
  }
  
  #endif
  
  /* -- see zlib.h -- */
! int ZEXPORT gzflush(gzFile file, int flush) {
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
          return Z_STREAM_ERROR;

*** 616,26 ***
      (void)gz_comp(state, flush);
      return state->err;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzsetparams(file, level, strategy)
-     gzFile file;
-     int level;
-     int strategy;
- {
      gz_statep state;
      z_streamp strm;
  
      /* get internal structure */
      if (file == NULL)
          return Z_STREAM_ERROR;
      state = (gz_statep)file;
      strm = &(state->strm);
  
      /* check that we're writing and that there's no error */
!     if (state->mode != GZ_WRITE || state->err != Z_OK)
          return Z_STREAM_ERROR;
  
      /* if no change is requested, then do nothing */
      if (level == state->level && strategy == state->strategy)
          return Z_OK;
--- 576,22 ---
      (void)gz_comp(state, flush);
      return state->err;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
      gz_statep state;
      z_streamp strm;
  
      /* get internal structure */
      if (file == NULL)
          return Z_STREAM_ERROR;
      state = (gz_statep)file;
      strm = &(state->strm);
  
      /* check that we're writing and that there's no error */
!     if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct)
          return Z_STREAM_ERROR;
  
      /* if no change is requested, then do nothing */
      if (level == state->level && strategy == state->strategy)
          return Z_OK;

*** 658,13 ***
      state->strategy = strategy;
      return Z_OK;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzclose_w(file)
-     gzFile file;
- {
      int ret = Z_OK;
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
--- 614,11 ---
      state->strategy = strategy;
      return Z_OK;
  }
  
  /* -- see zlib.h -- */
! int ZEXPORT gzclose_w(gzFile file) {
      int ret = Z_OK;
      gz_statep state;
  
      /* get internal structure */
      if (file == NULL)
< prev index next >