2007-11-24 15:58:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Vreixo Formoso
|
2008-08-19 00:01:42 +00:00
|
|
|
*
|
|
|
|
* This file is part of the libisofs project; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2 as
|
2007-11-24 15:58:36 +00:00
|
|
|
* published by the Free Software Foundation. See COPYING file for details.
|
|
|
|
*/
|
|
|
|
#ifndef LIBISO_STREAM_H_
|
|
|
|
#define LIBISO_STREAM_H_
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions of streams.
|
|
|
|
*/
|
2007-12-02 21:04:26 +00:00
|
|
|
#include "fsource.h"
|
2007-11-26 23:27:57 +00:00
|
|
|
|
2008-08-19 00:01:42 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
IsoFileSource *src;
|
|
|
|
|
|
|
|
/* key for file identification inside filesystem */
|
|
|
|
dev_t dev_id;
|
|
|
|
ino_t ino_id;
|
|
|
|
off_t size; /**< size of this file */
|
|
|
|
} FSrcStreamData;
|
|
|
|
|
2008-02-24 15:58:07 +00:00
|
|
|
/**
|
|
|
|
* Get an identifier for the file of the source, for debug purposes
|
2008-08-19 00:01:42 +00:00
|
|
|
* @param name
|
2008-02-24 15:58:07 +00:00
|
|
|
* Should provide at least PATH_MAX bytes
|
2007-11-24 15:58:36 +00:00
|
|
|
*/
|
2008-02-24 15:58:07 +00:00
|
|
|
void iso_stream_get_file_name(IsoStream *stream, char *name);
|
2007-11-24 15:58:36 +00:00
|
|
|
|
2007-12-02 21:04:26 +00:00
|
|
|
/**
|
|
|
|
* Create a stream to read from a IsoFileSource.
|
|
|
|
* The stream will take the ref. to the IsoFileSource, so after a successfully
|
|
|
|
* exectution of this function, you musn't unref() the source, unless you
|
|
|
|
* take an extra ref.
|
2008-08-19 00:01:42 +00:00
|
|
|
*
|
2007-12-02 21:04:26 +00:00
|
|
|
* @return
|
|
|
|
* 1 sucess, < 0 error
|
|
|
|
* Possible errors:
|
2008-08-19 00:01:42 +00:00
|
|
|
*
|
2007-12-02 21:04:26 +00:00
|
|
|
*/
|
|
|
|
int iso_file_source_stream_new(IsoFileSource *src, IsoStream **stream);
|
|
|
|
|
2008-03-08 20:45:19 +00:00
|
|
|
/**
|
|
|
|
* Create a new stream to read a chunk of an IsoFileSource..
|
|
|
|
* The stream will add a ref. to the IsoFileSource.
|
2008-08-19 00:01:42 +00:00
|
|
|
*
|
2008-03-08 20:45:19 +00:00
|
|
|
* @return
|
|
|
|
* 1 sucess, < 0 error
|
|
|
|
*/
|
2008-08-19 00:01:42 +00:00
|
|
|
int iso_cut_out_stream_new(IsoFileSource *src, off_t offset, off_t size,
|
2008-03-08 20:45:19 +00:00
|
|
|
IsoStream **stream);
|
|
|
|
|
2008-01-11 15:42:18 +00:00
|
|
|
/**
|
|
|
|
* Create a stream for reading from a arbitrary memory buffer.
|
|
|
|
* When the Stream refcount reach 0, the buffer is free(3).
|
2008-08-19 00:01:42 +00:00
|
|
|
*
|
2008-01-11 15:42:18 +00:00
|
|
|
* @return
|
|
|
|
* 1 sucess, < 0 error
|
|
|
|
*/
|
|
|
|
int iso_memory_stream_new(unsigned char *buf, size_t size, IsoStream **stream);
|
|
|
|
|
2007-11-24 15:58:36 +00:00
|
|
|
#endif /*STREAM_H_*/
|