xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

filter.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Vreixo Formoso
3  * Copyright (c) 2009 Thomas Schmitt
4  *
5  * This file is part of the libisofs project; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License version 2
7  * or later as published by the Free Software Foundation.
8  * See COPYING file for details.
9  */
10 
11 #ifdef HAVE_CONFIG_H
12 #include "../config.h"
13 #endif
14 
15 #include "libisofs.h"
16 #include "filter.h"
17 #include "node.h"
18 
19 
21 {
22  ++filter->refcount;
23 }
24 
26 {
27  if (--filter->refcount == 0) {
28  filter->free(filter);
29  free(filter);
30  }
31 }
32 
33 int iso_file_add_filter(IsoFile *file, FilterContext *filter, int flag)
34 {
35  int ret;
36  IsoStream *original, *filtered;
37  if (file == NULL || filter == NULL) {
38  return ISO_NULL_POINTER;
39  }
40 
41  original = file->stream;
42 
43  if (!iso_stream_is_repeatable(original)) {
44  /* TODO use custom error */
45  return ISO_WRONG_ARG_VALUE;
46  }
47 
48  ret = filter->get_filter(filter, original, &filtered);
49  if (ret < 0) {
50  return ret;
51  }
52  iso_stream_unref(original);
53  file->stream = filtered;
54  return ISO_SUCCESS;
55 }
56 
57 
58 int iso_file_remove_filter(IsoFile *file, int flag)
59 {
60  IsoStream *file_stream, *input_stream;
61 
62  file_stream = file->stream;
63  input_stream = iso_stream_get_input_stream(file_stream, 0);
64  if (input_stream == NULL)
65  return 0;
66  file->stream = input_stream;
67  iso_stream_ref(input_stream); /* Protect against _unref(file_stream) */
68  iso_stream_unref(file_stream);
69  return 1;
70 }
71 
void iso_filter_unref(FilterContext *filter)
Definition: filter.c:25
int iso_file_remove_filter(IsoFile *file, int flag)
Definition: filter.c:58
void iso_filter_ref(FilterContext *filter)
Definition: filter.c:20
int iso_file_add_filter(IsoFile *file, FilterContext *filter, int flag)
Definition: filter.c:33
#define ISO_SUCCESS
Definition: libisofs.h:8719
IsoStream * iso_stream_get_input_stream(IsoStream *stream, int flag)
Definition: stream.c:867
#define ISO_WRONG_ARG_VALUE
Definition: libisofs.h:8751
#define ISO_NULL_POINTER
Definition: libisofs.h:8742
void iso_stream_unref(IsoStream *stream)
Definition: stream.c:789
void iso_stream_ref(IsoStream *stream)
Definition: stream.c:784
int iso_stream_is_repeatable(IsoStream *stream)
Definition: stream.c:822
Definition: node.h:149
IsoStream * stream
Definition: node.h:166
void(* free)(FilterContext *filter)
Definition: filter.h:60
int refcount
Definition: filter.h:36
int(* get_filter)(FilterContext *filter, IsoStream *original, IsoStream **filtered)
Definition: filter.h:53