libisofs  1.5.4
About: libisofs is a library to create an ISO 9660 filesystem, supports extensions like RockRidge or Joliet, makes bootable ISO 9660, and records file attributes which are of interest for data backups.
  Fossies Dox: libisofs-1.5.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

gzip.c File Reference
#include "../libisofs.h"
#include "../filter.h"
#include "../fsource.h"
#include "../util.h"
#include "../stream.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
Include dependency graph for gzip.c:

Go to the source code of this file.

Data Structures

struct  GzipFilterRuntime
 
struct  GzipFilterStreamData
 

Functions

static int gzip_stream_uncompress (IsoStream *stream, void *buf, size_t desired)
 
static int gzip_stream_close_flag (IsoStream *stream, int flag)
 
static int gzip_stream_close (IsoStream *stream)
 
static int gzip_stream_open_flag (IsoStream *stream, int flag)
 
static int gzip_stream_open (IsoStream *stream)
 
static int gzip_stream_convert (IsoStream *stream, void *buf, size_t desired, int flag)
 
static int gzip_stream_compress (IsoStream *stream, void *buf, size_t desired)
 
static off_t gzip_stream_get_size (IsoStream *stream)
 
static int gzip_stream_is_repeatable (IsoStream *stream)
 
static void gzip_stream_get_id (IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
 
static void gzip_stream_free (IsoStream *stream)
 
static int gzip_update_size (IsoStream *stream)
 
static IsoStreamgzip_get_input_stream (IsoStream *stream, int flag)
 
static int gzip_clone_stream (IsoStream *old_stream, IsoStream **new_stream, int flag)
 
static int gzip_cmp_ino (IsoStream *s1, IsoStream *s2)
 
static int gzip_uncompress_cmp_ino (IsoStream *s1, IsoStream *s2)
 
int gzip_add_filter (IsoFile *file, int flag)
 
int iso_file_add_gzip_filter (IsoFile *file, int flag)
 Install a gzip or gunzip filter on top of the content stream of a data file. More...
 
int iso_gzip_get_refcounts (off_t *gzip_count, off_t *gunzip_count, int flag)
 Inquire the number of gzip compression and uncompression filters which are in use. More...
 

Variables

static off_t gzip_ref_count = 0
 
static off_t gunzip_ref_count = 0
 
IsoStreamIface gzip_stream_compress_class
 
IsoStreamIface gzip_stream_uncompress_class
 

Function Documentation

◆ gzip_add_filter()

int gzip_add_filter ( IsoFile file,
int  flag 
)

Definition at line 764 of file gzip.c.

765 {
766 
767 #ifdef Libisofs_with_zliB
768 
769  int ret;
770  FilterContext *f = NULL;
771  IsoStream *stream;
772  off_t original_size = 0, filtered_size = 0;
773 
774  if (flag & 4)
775  return 2;
776 
777  original_size = iso_file_get_size(file);
778 
779  ret = gzip_create_context(&f, flag & 2);
780  if (ret < 0) {
781  return ret;
782  }
783  ret = iso_file_add_filter(file, f, 0);
784  free(f);
785  if (ret < 0) {
786  return ret;
787  }
788  if (flag & 8) /* size will be filled in by caller */
789  return ISO_SUCCESS;
790 
791  /* Run a full filter process getsize so that the size is cached */
792  stream = iso_file_get_stream(file);
793  filtered_size = iso_stream_get_size(stream);
794  if (filtered_size < 0) {
795  iso_file_remove_filter(file, 0);
796  return filtered_size;
797  }
798  if ((filtered_size >= original_size ||
799  ((flag & 1) && filtered_size / 2048 >= original_size / 2048))
800  && !(flag & 2)){
801  ret = iso_file_remove_filter(file, 0);
802  if (ret < 0) {
803  return ret;
804  }
805  return 2;
806  }
807  return ISO_SUCCESS;
808 
809 #else
810 
811  return ISO_ZLIB_NOT_ENABLED;
812 
813 #endif /* ! Libisofs_with_zliB */
814 
815 }
int iso_file_remove_filter(IsoFile *file, int flag)
Delete the top filter stream from a data file.
Definition: filter.c:58
int iso_file_add_filter(IsoFile *file, FilterContext *filter, int flag)
Definition: filter.c:33
IsoStream * iso_file_get_stream(IsoFile *file)
Get the IsoStream that represents the contents of the given IsoFile.
Definition: node.c:1161
#define ISO_ZLIB_NOT_ENABLED
Use of zlib was not enabled at compile time (FAILURE, HIGH, -345)
Definition: libisofs.h:8956
#define ISO_SUCCESS
successfully execution
Definition: libisofs.h:8719
off_t iso_file_get_size(IsoFile *file)
Get the size of the file, in bytes.
Definition: node.c:1144
off_t iso_stream_get_size(IsoStream *stream)
Get the size of a given stream.
Definition: stream.c:810
Representation of file contents as a stream of bytes.
Definition: libisofs.h:1184

References iso_file_add_filter(), iso_file_get_size(), iso_file_get_stream(), iso_file_remove_filter(), iso_stream_get_size(), ISO_SUCCESS, and ISO_ZLIB_NOT_ENABLED.

Referenced by iso_file_add_gzip_filter().

◆ gzip_clone_stream()

static int gzip_clone_stream ( IsoStream old_stream,
IsoStream **  new_stream,
int  flag 
)
static

Definition at line 535 of file gzip.c.

536 {
537 
538 #ifdef Libisofs_with_zliB
539 
540  int ret;
541  IsoStream *new_input_stream, *stream;
542  GzipFilterStreamData *stream_data, *old_stream_data;
543 
544  if (flag)
545  return ISO_STREAM_NO_CLONE; /* unknown option required */
546 
547  stream_data = calloc(1, sizeof(GzipFilterStreamData));
548  if (stream_data == NULL)
549  return ISO_OUT_OF_MEM;
550  ret = iso_stream_clone_filter_common(old_stream, &stream,
551  &new_input_stream, 0);
552  if (ret < 0) {
553  free((char *) stream_data);
554  return ret;
555  }
556  old_stream_data = (GzipFilterStreamData *) old_stream->data;
557  stream_data->orig = new_input_stream;
558  stream_data->size = old_stream_data->size;
559  stream_data->running = NULL;
560  stream_data->id = ++gzip_ino_id;
561  stream->data = stream_data;
562  *new_stream = stream;
563  return ISO_SUCCESS;
564 
565 #else /* Libisofs_with_zliB */
566 
567  return ISO_STREAM_NO_CLONE;
568 
569 #endif /* ! Libisofs_with_zliB */
570 
571 }
#define ISO_STREAM_NO_CLONE
Data file input stream object offers no cloning method (FAILURE, HIGH, -374)
Definition: libisofs.h:9089
#define ISO_OUT_OF_MEM
Memory allocation error (FATAL,HIGH, -6)
Definition: libisofs.h:8745
int iso_stream_clone_filter_common(IsoStream *old_stream, IsoStream **new_stream, IsoStream **new_input, int flag)
Create a clone of the input stream of old_stream and a roughly initialized clone of old_stream which ...
Definition: stream.c:1292
GzipFilterRuntime * running
Definition: gzip.c:164
IsoStream * orig
Definition: gzip.c:160
void * data
Definition: libisofs.h:1187

References iso_stream::data, GzipFilterStreamData::id, ISO_OUT_OF_MEM, iso_stream_clone_filter_common(), ISO_STREAM_NO_CLONE, ISO_SUCCESS, GzipFilterStreamData::orig, GzipFilterStreamData::running, and GzipFilterStreamData::size.

◆ gzip_cmp_ino()

static int gzip_cmp_ino ( IsoStream s1,
IsoStream s2 
)
static

Definition at line 615 of file gzip.c.

616 {
617  /* This function may rely on being called by iso_stream_cmp_ino()
618  only with s1, s2 which both point to it as their .cmp_ino() function.
619  It would be a programming error to let any other than
620  gzip_stream_compress_class point to gzip_cmp_ino().
621  This fallback endangers transitivity of iso_stream_cmp_ino().
622  */
623  if (s1->class != s2->class || (s1->class != &gzip_stream_compress_class &&
625  return iso_stream_cmp_ino(s1, s2, 1);
626 
627  /* Both streams apply the same treatment to their input streams */
629  iso_stream_get_input_stream(s2, 0), 0);
630 }
IsoStreamIface gzip_stream_compress_class
Definition: gzip.c:580
IsoStream * iso_stream_get_input_stream(IsoStream *stream, int flag)
Obtain the eventual input stream of a filter stream.
Definition: stream.c:867
int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag)
Compare two streams whether they are based on the same input and will produce the same output.
Definition: stream.c:1042
IsoStreamIface * class
Definition: libisofs.h:1185

References iso_stream::class, gzip_stream_compress_class, iso_stream_cmp_ino(), and iso_stream_get_input_stream().

◆ gzip_get_input_stream()

static IsoStream* gzip_get_input_stream ( IsoStream stream,
int  flag 
)
static

Definition at line 522 of file gzip.c.

523 {
524  GzipFilterStreamData *data;
525 
526  if (stream == NULL) {
527  return NULL;
528  }
529  data = stream->data;
530  return data->orig;
531 }

References iso_stream::data, and GzipFilterStreamData::orig.

◆ gzip_stream_close()

static int gzip_stream_close ( IsoStream stream)
static

Definition at line 231 of file gzip.c.

232 {
233  return gzip_stream_close_flag(stream, 0);
234 }
static int gzip_stream_close_flag(IsoStream *stream, int flag)
Definition: gzip.c:195

References gzip_stream_close_flag().

Referenced by gzip_stream_free(), and gzip_stream_get_size().

◆ gzip_stream_close_flag()

static int gzip_stream_close_flag ( IsoStream stream,
int  flag 
)
static

Definition at line 195 of file gzip.c.

196 {
197 
198 #ifdef Libisofs_with_zliB
199 
200  GzipFilterStreamData *data;
201 
202  if (stream == NULL) {
203  return ISO_NULL_POINTER;
204  }
205  data = stream->data;
206 
207  if (data->running == NULL) {
208  return 1;
209  }
210  if (stream->class->read == &gzip_stream_uncompress) {
211  inflateEnd(&(data->running->strm));
212  } else {
213  deflateEnd(&(data->running->strm));
214  }
215  gzip_running_destroy(&(data->running), 0);
216 
217  if (flag & 1)
218  return 1;
219  return iso_stream_close(data->orig);
220 
221 #else
222 
223  return ISO_ZLIB_NOT_ENABLED;
224 
225 #endif
226 
227 }
static int gzip_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
Definition: gzip.c:422
#define ISO_NULL_POINTER
NULL pointer as value for an arg.
Definition: libisofs.h:8742
int iso_stream_close(IsoStream *stream)
Close a previously opened IsoStream.
Definition: stream.c:804
int(* read)(IsoStream *stream, void *buf, size_t count)
Attempt to read up to count bytes from the given stream into the buffer starting at buf.
Definition: libisofs.h:1055

References iso_stream::class, iso_stream::data, gzip_stream_uncompress(), ISO_NULL_POINTER, iso_stream_close(), ISO_ZLIB_NOT_ENABLED, GzipFilterStreamData::orig, IsoStream_Iface::read, and GzipFilterStreamData::running.

Referenced by gzip_stream_close().

◆ gzip_stream_compress()

static int gzip_stream_compress ( IsoStream stream,
void *  buf,
size_t  desired 
)
static

Definition at line 416 of file gzip.c.

417 {
418  return gzip_stream_convert(stream, buf, desired, 0);
419 }
static int gzip_stream_convert(IsoStream *stream, void *buf, size_t desired, int flag)
Definition: gzip.c:316

References gzip_stream_convert().

◆ gzip_stream_convert()

static int gzip_stream_convert ( IsoStream stream,
void *  buf,
size_t  desired,
int  flag 
)
static

Definition at line 316 of file gzip.c.

317 {
318 
319 #ifdef Libisofs_with_zliB
320 
321  int ret, todo, cnv_ret, c_bytes;
322  GzipFilterStreamData *data;
323  GzipFilterRuntime *rng;
324  size_t fill = 0;
325  z_stream *strm;
326 
327  if (stream == NULL) {
328  return ISO_NULL_POINTER;
329  }
330  data = stream->data;
331  rng= data->running;
332  if (rng == NULL) {
333  return ISO_FILE_NOT_OPENED;
334  }
335  strm = &(rng->strm);
336  if (rng->error_ret < 0) {
337  return rng->error_ret;
338  } else if (rng->error_ret == 0) {
339  if (rng->out_buffer_size - strm->avail_out
340  - (rng->rpt - rng->out_buffer) <= 0)
341  return 0;
342  }
343 
344  while (1) {
345 
346  /* Transfer eventual converted bytes from strm to buf */
347  c_bytes = rng->out_buffer_size - strm->avail_out
348  - (rng->rpt - rng->out_buffer);
349  if (c_bytes > 0) {
350  todo = desired - fill;
351  if (todo > c_bytes)
352  todo = c_bytes;
353  memcpy(((char *) buf) + fill, rng->rpt, todo);
354  rng->rpt += todo;
355  fill += todo;
356  rng->out_counter += todo;
357  }
358 
359  if (fill >= desired || rng->error_ret == 0)
360  return fill;
361 
362  /* All buffered out data are consumed now */
363  rng->rpt = rng->out_buffer;
364  strm->next_out = (Bytef *) rng->out_buffer;
365  strm->avail_out = rng->out_buffer_size;
366 
367  if (strm->avail_in == 0) {
368  /* All pending input is consumed. Get new input. */
369  ret = iso_stream_read(data->orig, rng->in_buffer,
370  rng->in_buffer_size);
371  if (ret < 0)
372  return (rng->error_ret = ret);
373  if (ret == 0) {
374  if (flag & 2) {
375  /* Early input EOF */
376  return (rng->error_ret = ISO_ZLIB_EARLY_EOF);
377  } else {
378  /* Tell zlib by the next call that it is over */
379  rng->do_flush = Z_FINISH;
380  }
381  }
382  strm->next_in = (Bytef *) rng->in_buffer;
383  strm->avail_in = ret;
384  rng->in_counter += ret;
385  }
386 
387  /* Submit input and fetch output until input is consumed */
388  while (1) {
389  if (flag & 2) {
390  cnv_ret = inflate(strm, rng->do_flush);
391  } else {
392  cnv_ret = deflate(strm, rng->do_flush);
393  }
394  if (cnv_ret == Z_STREAM_ERROR || cnv_ret == Z_BUF_ERROR) {
395  return (rng->error_ret = ISO_ZLIB_COMPR_ERR);
396  }
397  if ((int) strm->avail_out < rng->out_buffer_size)
398  break; /* output is available */
399  if (strm->avail_in == 0) /* all pending input consumed */
400  break;
401  }
402  if (cnv_ret == Z_STREAM_END)
403  rng->error_ret = 0;
404  }
405  return fill;
406 
407 #else
408 
409  return ISO_ZLIB_NOT_ENABLED;
410 
411 #endif
412 
413 }
#define ISO_ZLIB_EARLY_EOF
Premature EOF of zlib input stream (FAILURE, HIGH, -351)
Definition: libisofs.h:8975
#define ISO_FILE_NOT_OPENED
Trying to read or close a file not opened (FAILURE,HIGH, -133)
Definition: libisofs.h:8811
int iso_stream_read(IsoStream *stream, void *buf, size_t count)
Attempts to read up to count bytes from the given stream into the buffer starting at buf.
Definition: stream.c:816
#define ISO_ZLIB_COMPR_ERR
zlib compression/decompression error (FAILURE, HIGH, -348)
Definition: libisofs.h:8965
int out_buffer_size
Definition: gzip.c:67
off_t in_counter
Definition: gzip.c:70
char * out_buffer
Definition: gzip.c:65
off_t out_counter
Definition: gzip.c:71
int do_flush
Definition: gzip.c:73
int in_buffer_size
Definition: gzip.c:66
int error_ret
Definition: gzip.c:75
char * rpt
Definition: gzip.c:68
char * in_buffer
Definition: gzip.c:64

References iso_stream::data, GzipFilterRuntime::do_flush, GzipFilterRuntime::error_ret, GzipFilterRuntime::in_buffer, GzipFilterRuntime::in_buffer_size, GzipFilterRuntime::in_counter, ISO_FILE_NOT_OPENED, ISO_NULL_POINTER, iso_stream_read(), ISO_ZLIB_COMPR_ERR, ISO_ZLIB_EARLY_EOF, ISO_ZLIB_NOT_ENABLED, GzipFilterStreamData::orig, GzipFilterRuntime::out_buffer, GzipFilterRuntime::out_buffer_size, GzipFilterRuntime::out_counter, GzipFilterRuntime::rpt, and GzipFilterStreamData::running.

Referenced by gzip_stream_compress(), and gzip_stream_uncompress().

◆ gzip_stream_free()

static void gzip_stream_free ( IsoStream stream)
static

Definition at line 490 of file gzip.c.

491 {
492  GzipFilterStreamData *data;
493 
494  if (stream == NULL) {
495  return;
496  }
497  data = stream->data;
498  if (data->running != NULL) {
499  gzip_stream_close(stream);
500  }
501  if (stream->class->read == &gzip_stream_uncompress) {
502  if (--gunzip_ref_count < 0)
503  gunzip_ref_count = 0;
504  } else {
505  if (--gzip_ref_count < 0)
506  gzip_ref_count = 0;
507  }
508  iso_stream_unref(data->orig);
509  free(data);
510 }
static int gzip_stream_close(IsoStream *stream)
Definition: gzip.c:231
static off_t gzip_ref_count
Definition: gzip.c:136
static off_t gunzip_ref_count
Definition: gzip.c:139
void iso_stream_unref(IsoStream *stream)
Decrement reference count of an IsoStream, and eventually free it if refcount reach 0.
Definition: stream.c:789

References iso_stream::class, iso_stream::data, gunzip_ref_count, gzip_ref_count, gzip_stream_close(), gzip_stream_uncompress(), iso_stream_unref(), GzipFilterStreamData::orig, IsoStream_Iface::read, and GzipFilterStreamData::running.

◆ gzip_stream_get_id()

static void gzip_stream_get_id ( IsoStream stream,
unsigned int *  fs_id,
dev_t *  dev_id,
ino_t *  ino_id 
)
static

Definition at line 477 of file gzip.c.

479 {
480  GzipFilterStreamData *data;
481 
482  data = stream->data;
483  *fs_id = ISO_FILTER_FS_ID;
484  *dev_id = ISO_FILTER_GZIP_DEV_ID;
485  *ino_id = data->id;
486 }
#define ISO_FILTER_GZIP_DEV_ID
Definition: filter.h:29
#define ISO_FILTER_FS_ID
Definition: fsource.h:25

References iso_stream::data, GzipFilterStreamData::id, ISO_FILTER_FS_ID, and ISO_FILTER_GZIP_DEV_ID.

◆ gzip_stream_get_size()

static off_t gzip_stream_get_size ( IsoStream stream)
static

Definition at line 429 of file gzip.c.

430 {
431  int ret, ret_close;
432  off_t count = 0;
433  GzipFilterStreamData *data;
434  char buf[64 * 1024];
435  size_t bufsize = 64 * 1024;
436 
437  if (stream == NULL) {
438  return ISO_NULL_POINTER;
439  }
440  data = stream->data;
441 
442  if (data->size >= 0) {
443  return data->size;
444  }
445 
446  /* Run filter command and count output bytes */
447  ret = gzip_stream_open_flag(stream, 1);
448  if (ret < 0) {
449  return ret;
450  }
451  while (1) {
452  ret = stream->class->read(stream, buf, bufsize);
453  if (ret <= 0)
454  break;
455  count += ret;
456  }
457  ret_close = gzip_stream_close(stream);
458  if (ret < 0)
459  return ret;
460  if (ret_close < 0)
461  return ret_close;
462 
463  data->size = count;
464  return count;
465 }
static int gzip_stream_open_flag(IsoStream *stream, int flag)
Definition: gzip.c:241

References iso_stream::class, iso_stream::data, gzip_stream_close(), gzip_stream_open_flag(), ISO_NULL_POINTER, IsoStream_Iface::read, and GzipFilterStreamData::size.

◆ gzip_stream_is_repeatable()

static int gzip_stream_is_repeatable ( IsoStream stream)
static

Definition at line 469 of file gzip.c.

470 {
471  /* Only repeatable streams are accepted as orig */
472  return 1;
473 }

◆ gzip_stream_open()

static int gzip_stream_open ( IsoStream stream)
static

Definition at line 306 of file gzip.c.

307 {
308  return gzip_stream_open_flag(stream, 0);
309 }

References gzip_stream_open_flag().

◆ gzip_stream_open_flag()

static int gzip_stream_open_flag ( IsoStream stream,
int  flag 
)
static

Definition at line 241 of file gzip.c.

242 {
243 
244 #ifdef Libisofs_with_zliB
245 
246  GzipFilterStreamData *data;
247  GzipFilterRuntime *running = NULL;
248  int ret;
249  z_stream *strm;
250 
251  if (stream == NULL) {
252  return ISO_NULL_POINTER;
253  }
254  data = (GzipFilterStreamData*) stream->data;
255  if (data->running != NULL) {
257  }
258  if (data->size < 0 && !(flag & 1)) {
259  /* Do the size determination run now, so that the size gets cached
260  and .get_size() will not fail on an opened stream.
261  */
262  stream->class->get_size(stream);
263  }
264 
265  ret = gzip_running_new(&running,
266  stream->class->read == &gzip_stream_uncompress);
267  if (ret < 0) {
268  return ret;
269  }
270  data->running = running;
271 
272  /* Start up zlib compression context */
273  strm = &(running->strm);
274  strm->zalloc = Z_NULL;
275  strm->zfree = Z_NULL;
276  strm->opaque = Z_NULL;
277  if (stream->class->read == &gzip_stream_uncompress) {
278  ret = inflateInit2(strm, 15 | 16);
279  } else {
280  ret = deflateInit2(strm, gzip_compression_level, Z_DEFLATED,
281  15 | 16, 8, Z_DEFAULT_STRATEGY);
282  }
283  if (ret != Z_OK)
284  return ISO_ZLIB_COMPR_ERR;
285  strm->next_out = (Bytef *) running->out_buffer;
286  strm->avail_out = running->out_buffer_size;
287 
288  /* Open input stream */
289  ret = iso_stream_open(data->orig);
290  if (ret < 0) {
291  return ret;
292  }
293 
294  return 1;
295 
296 #else
297 
298  return ISO_ZLIB_NOT_ENABLED;
299 
300 #endif
301 
302 }
int iso_stream_open(IsoStream *stream)
Opens the given stream.
Definition: stream.c:798
#define ISO_FILE_ALREADY_OPENED
Trying to open an already opened file (FAILURE,HIGH, -129)
Definition: libisofs.h:8796
off_t(* get_size)(IsoStream *stream)
Get the size (in bytes) of the stream.
Definition: libisofs.h:1039

References iso_stream::class, iso_stream::data, IsoStream_Iface::get_size, gzip_stream_uncompress(), ISO_FILE_ALREADY_OPENED, ISO_NULL_POINTER, iso_stream_open(), ISO_ZLIB_COMPR_ERR, ISO_ZLIB_NOT_ENABLED, GzipFilterStreamData::orig, GzipFilterRuntime::out_buffer, GzipFilterRuntime::out_buffer_size, IsoStream_Iface::read, GzipFilterStreamData::running, and GzipFilterStreamData::size.

Referenced by gzip_stream_get_size(), and gzip_stream_open().

◆ gzip_stream_uncompress()

static int gzip_stream_uncompress ( IsoStream stream,
void *  buf,
size_t  desired 
)
static

Definition at line 422 of file gzip.c.

423 {
424  return gzip_stream_convert(stream, buf, desired, 2);
425 }

References gzip_stream_convert().

Referenced by gzip_stream_close_flag(), gzip_stream_free(), and gzip_stream_open_flag().

◆ gzip_uncompress_cmp_ino()

static int gzip_uncompress_cmp_ino ( IsoStream s1,
IsoStream s2 
)
static

Definition at line 634 of file gzip.c.

635 {
636  /* This function may rely on being called by iso_stream_cmp_ino()
637  only with s1, s2 which both point to it as their .cmp_ino() function.
638  It would be a programming error to let any other than
639  gzip_stream_uncompress_class point to gzip_uncompress_cmp_ino().
640  */
641  if (s1->class != s2->class ||
644  return iso_stream_cmp_ino(s1, s2, 1);
645 
646  /* Both streams apply the same treatment to their input streams */
648  iso_stream_get_input_stream(s2, 0), 0);
649 }
IsoStreamIface gzip_stream_uncompress_class
Definition: gzip.c:597

References iso_stream::class, gzip_stream_uncompress_class, iso_stream_cmp_ino(), and iso_stream_get_input_stream().

◆ gzip_update_size()

static int gzip_update_size ( IsoStream stream)
static

Definition at line 514 of file gzip.c.

515 {
516  /* By principle size is determined only once */
517  return 1;
518 }

◆ iso_file_add_gzip_filter()

int iso_file_add_gzip_filter ( IsoFile file,
int  flag 
)

Install a gzip or gunzip filter on top of the content stream of a data file.

gzip is a compression format which is used by programs gzip and gunzip. The filter will not be installed if its output size is not smaller than the size of the input stream. This is only enabled if the use of libz was enabled at compile time.

Parameters
fileThe data file node which shall show filtered content.
flagBitfield for control purposes bit0= Do not install filter if the number of output blocks is not smaller than the number of input blocks. Block size is 2048. bit1= Install a decompression filter rather than one for compression. bit2= Only inquire availability of gzip filtering. file may be NULL. If available return 2, else return error. bit3= is reserved for internal use and will be forced to 0
Returns
1 on success, 2 if filter available but installation revoked <0 on error, e.g. ISO_ZLIB_NOT_ENABLED
Since
0.6.18

Definition at line 819 of file gzip.c.

820 {
821  return gzip_add_filter(file, flag & ~8);
822 }
int gzip_add_filter(IsoFile *file, int flag)
Definition: gzip.c:764

References gzip_add_filter().

◆ iso_gzip_get_refcounts()

int iso_gzip_get_refcounts ( off_t *  gzip_count,
off_t *  gunzip_count,
int  flag 
)

Inquire the number of gzip compression and uncompression filters which are in use.

Parameters
gzip_countWill return the number of currently installed compression filters.
gunzip_countWill return the number of currently installed uncompression filters.
flagBitfield for control purposes, unused yet, submit 0
Returns
1 on success, <0 on error
Since
0.6.18

Definition at line 826 of file gzip.c.

827 {
828  *gzip_count = gzip_ref_count;
829  *gunzip_count = gunzip_ref_count;
830  return ISO_SUCCESS;
831 }

References gunzip_ref_count, gzip_ref_count, and ISO_SUCCESS.

Variable Documentation

◆ gunzip_ref_count

off_t gunzip_ref_count = 0
static

Definition at line 139 of file gzip.c.

Referenced by gzip_stream_free(), and iso_gzip_get_refcounts().

◆ gzip_ref_count

off_t gzip_ref_count = 0
static

Definition at line 136 of file gzip.c.

Referenced by gzip_stream_free(), and iso_gzip_get_refcounts().

◆ gzip_stream_compress_class

IsoStreamIface gzip_stream_compress_class
Initial value:
= {
4,
"gzip",
}
static int gzip_clone_stream(IsoStream *old_stream, IsoStream **new_stream, int flag)
Definition: gzip.c:535
static void gzip_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
Definition: gzip.c:477
static int gzip_stream_compress(IsoStream *stream, void *buf, size_t desired)
Definition: gzip.c:416
static int gzip_stream_is_repeatable(IsoStream *stream)
Definition: gzip.c:469
static IsoStream * gzip_get_input_stream(IsoStream *stream, int flag)
Definition: gzip.c:522
static int gzip_update_size(IsoStream *stream)
Definition: gzip.c:514
static int gzip_stream_open(IsoStream *stream)
Definition: gzip.c:306
static void gzip_stream_free(IsoStream *stream)
Definition: gzip.c:490
static int gzip_cmp_ino(IsoStream *s1, IsoStream *s2)
Definition: gzip.c:615
static off_t gzip_stream_get_size(IsoStream *stream)
Definition: gzip.c:429

Definition at line 580 of file gzip.c.

Referenced by gzip_cmp_ino().

◆ gzip_stream_uncompress_class

IsoStreamIface gzip_stream_uncompress_class