/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Based on ringbuffer.h by Patrick Prasse (patrick.prasse@gmx.net). Code has been modified by Telenor and Gemalto. */ #ifndef __RINGBUF_H_ #define __RINGBUF_H_ #include #include typedef struct ring_buffer_s { uint8_t *buffer; int wr_pointer; int rd_pointer; int size; } ring_buffer_t; /* Initial the ring buffer */ void rb_init (ring_buffer_t *ring, uint8_t *buf, int size) ; /* Clear the ring buffer data */ void rb_clear (ring_buffer_t *rb) ; /* Get ring buffer left free size */ int rb_free_size (ring_buffer_t *rb); /* Get data size in the ring buffer */ int rb_data_size (ring_buffer_t *rb); /* Read $max bytes data from ring buffer $rb to $buf */ int rb_read (ring_buffer_t *rb, uint8_t *buf, int max); /* Description: Write $len bytes data in $buf into ring buffer $rb * Return Value: The actual written into ring buffer data size, if ring buffer * left space size small than $len, then only part of the data be written into. */ int rb_write (ring_buffer_t *rb, uint8_t *buf, int len) ; /* Read a specify $index byte data in ring buffer $rb */ uint8_t rb_peek(ring_buffer_t *rb, int index); #endif /* __RINGBUF_H_ */