"Fossies" - the Fresh Open Source Software Archive

Member "xorriso-1.5.4/libisofs/filter.c" (30 Jan 2021, 1624 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "filter.c" see the Fossies "Dox" file reference documentation.

    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 
   20 void iso_filter_ref(FilterContext *filter)
   21 {
   22     ++filter->refcount;
   23 }
   24 
   25 void iso_filter_unref(FilterContext *filter)
   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