istream-seekable.h revision 6967fa47dde9f2726bd86019a50627dacf2d7509
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch#ifndef ISTREAM_SEEKABLE_H
12ff27eadb44c6877298d3e214c7039342669669Timo Sirainen#define ISTREAM_SEEKABLE_H
12ff27eadb44c6877298d3e214c7039342669669Timo Sirainen
c8d88cb784cc7f7edcdc97f8b24b243eb1bba7aaTimo Sirainen/* Create a seekable stream from given NULL-terminated list of input streams.
86441ffc028f11857152c15fe7b0d24ff0874504Timo Sirainen Try to keep it in memory, but use a temporary file if it's too large.
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen When max_buffer_size is reached, fd_callback is called. It should return
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen the fd and path of the created file. Typically the callback would also
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen unlink the file before returning. */
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainenstruct istream *
8322e7400bbeee586529e797f6e332149178aa4fTimo Siraineni_streams_merge(struct istream *input[], size_t max_buffer_size,
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen int (*fd_callback)(const char **path_r, void *context),
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen void *context) ATTR_NULL(4);
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen/* Same as i_streams_merge(), but if all of the inputs are seekable already,
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen create a concat stream instead. */
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainenstruct istream *
8322e7400bbeee586529e797f6e332149178aa4fTimo Siraineni_stream_create_seekable(struct istream *input[],
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen size_t max_buffer_size,
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen int (*fd_callback)(const char **path_r, void *context),
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen void *context) ATTR_NULL(4);
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainenstruct istream *
8322e7400bbeee586529e797f6e332149178aa4fTimo Siraineni_stream_create_seekable_path(struct istream *input[],
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen size_t max_buffer_size,
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen const char *temp_path_prefix);
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen#endif
8322e7400bbeee586529e797f6e332149178aa4fTimo Sirainen