view src/lib/iostream-private.h @ 16020:6cabb95d32ec

iostreams: Added close_parent flag to close() handler and clarified close/destroy APIs. This makes it unambiguous how things work: Unless you explicitly call [io]_stream_close(), the parent streams won't be closed. This is what most (hopefully all!) of the existing code expects. I was wondering a bit if [io]_stream_destroy() should simply have been removed and replaced with [io]_stream_unref() calls, since they would have worked basically everywhere, but there might be some places where it's better to have explicitly closed the stream (and where closing the parent stream doesn't matter).
author Timo Sirainen <tss@iki.fi>
date Wed, 13 Mar 2013 22:11:39 +0200
parents cf77e448295c
children 81d87e43e167
line wrap: on
line source

#ifndef IOSTREAM_PRIVATE_H
#define IOSTREAM_PRIVATE_H

/* This file is private to input stream and output stream implementations */

struct iostream_private {
	int refcount;
	char *name;

	void (*close)(struct iostream_private *streami, bool close_parent);
	void (*destroy)(struct iostream_private *stream);
	void (*set_max_buffer_size)(struct iostream_private *stream,
				    size_t max_size);

	void (*destroy_callback)(void *context);
	void *destroy_context;
};

void io_stream_init(struct iostream_private *stream);
void io_stream_ref(struct iostream_private *stream);
void io_stream_unref(struct iostream_private *stream);
void io_stream_close(struct iostream_private *stream, bool close_parent);
void io_stream_set_max_buffer_size(struct iostream_private *stream,
				   size_t max_size);

#endif