2010-09-22 17:25:19 +02:00
|
|
|
#ifndef __RINGBUFFER_H
|
|
|
|
#define __RINGBUFFER_H
|
|
|
|
|
|
|
|
typedef struct ringbuffer {
|
2010-09-24 13:53:22 +02:00
|
|
|
char *buf;
|
2010-09-22 17:25:19 +02:00
|
|
|
unsigned int start;
|
|
|
|
unsigned int end;
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int avail;
|
2011-07-10 22:49:41 +02:00
|
|
|
} ringbuffer_t;
|
2010-09-22 17:25:19 +02:00
|
|
|
|
2011-07-10 22:49:41 +02:00
|
|
|
void ringbuffer_init(ringbuffer_t *rb, char* buffer, unsigned int bufsize);
|
|
|
|
void rb_add_element(ringbuffer_t *rb, char c);
|
|
|
|
void rb_add_elements(ringbuffer_t *rb, char *buf, int n);
|
|
|
|
int rb_get_element(ringbuffer_t *rb);
|
|
|
|
int rb_get_elements(ringbuffer_t *rb, char *buf, int n);
|
2010-09-22 17:25:19 +02:00
|
|
|
|
|
|
|
#endif /* __RINGBUFFER_H */
|