MPD 0.17~git
src/fifo_buffer.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2011 The Music Player Daemon Project
00003  * http://www.musicpd.org
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  * notice, this list of conditions and the following disclaimer.
00011  *
00012  * - Redistributions in binary form must reproduce the above copyright
00013  * notice, this list of conditions and the following disclaimer in the
00014  * documentation and/or other materials provided with the
00015  * distribution.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00018  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00019  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00020  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
00021  * FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00022  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00025  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00026  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00028  * OF THE POSSIBILITY OF SUCH DAMAGE.
00029  */
00030 
00041 #ifndef MPD_FIFO_BUFFER_H
00042 #define MPD_FIFO_BUFFER_H
00043 
00044 #include <stdbool.h>
00045 #include <stddef.h>
00046 
00047 struct fifo_buffer;
00048 
00056 struct fifo_buffer *
00057 fifo_buffer_new(size_t size);
00058 
00068 struct fifo_buffer *
00069 fifo_buffer_realloc(struct fifo_buffer *buffer, size_t new_size);
00070 
00074 void
00075 fifo_buffer_free(struct fifo_buffer *buffer);
00076 
00081 size_t
00082 fifo_buffer_capacity(const struct fifo_buffer *buffer);
00083 
00087 size_t
00088 fifo_buffer_available(const struct fifo_buffer *buffer);
00089 
00095 void
00096 fifo_buffer_clear(struct fifo_buffer *buffer);
00097 
00107 const void *
00108 fifo_buffer_read(const struct fifo_buffer *buffer, size_t *length_r);
00109 
00116 void
00117 fifo_buffer_consume(struct fifo_buffer *buffer, size_t length);
00118 
00129 void *
00130 fifo_buffer_write(struct fifo_buffer *buffer, size_t *max_length_r);
00131 
00138 void
00139 fifo_buffer_append(struct fifo_buffer *buffer, size_t length);
00140 
00144 bool
00145 fifo_buffer_is_empty(struct fifo_buffer *buffer);
00146 
00150 bool
00151 fifo_buffer_is_full(struct fifo_buffer *buffer);
00152 
00153 #endif