1 /* Copyright 1996,1997,1999,2001,2002,2008,2009 Alain Knaff.
2 * This file is part of mtools.
4 * Mtools is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Mtools is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
18 #include "sysincludes.h"
24 int flush_stream(Stream_t *Stream)
28 if(Stream->Class->flush)
29 ret |= Stream->Class->flush(Stream);
31 ret |= flush_stream(Stream->Next);
36 Stream_t *copy_stream(Stream_t *Stream)
43 int free_stream(Stream_t **Stream)
49 if(! --(*Stream)->refs){
50 if((*Stream)->Class->flush)
51 ret |= (*Stream)->Class->flush(*Stream);
52 if((*Stream)->Class->freeFunc)
53 ret |= (*Stream)->Class->freeFunc(*Stream);
55 ret |= free_stream(&(*Stream)->Next);
57 } else if ( (*Stream)->Next )
58 ret |= flush_stream((*Stream)->Next);
64 #define GET_DATA(stream, date, size, type, address) \
65 (stream)->Class->get_data( (stream), (date), (size), (type), (address) )
68 int get_data_pass_through(Stream_t *Stream, time_t *date, mt_size_t *size,
69 int *type, int *address)
71 return GET_DATA(Stream->Next, date, size, type, address);
74 int read_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
76 return READS(Stream->Next, buf, start, len);
79 int write_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
81 return WRITES(Stream->Next, buf, start, len);
84 doscp_t *get_dosConvert_pass_through(Stream_t *Stream)
86 return GET_DOSCONVERT(Stream->Next);