forked from gozfree/gear-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibringbuffer.h
34 lines (29 loc) · 877 Bytes
/
libringbuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/******************************************************************************
* Copyright (C) 2014-2015
* file: libringbuffer.h
* author: gozfree <[email protected]>
* created: 2016-06-29 11:42:50
* updated: 2016-06-29 11:42:50
*****************************************************************************/
#ifndef LIBRINGBUFFER_H
#define LIBRINGBUFFER_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ringbuffer {
void *buffer;
int length;
size_t start;
size_t end;
} ringbuffer;
struct ringbuffer *rb_create(int len);
void rb_destroy(struct ringbuffer *rb);
ssize_t rb_write(struct ringbuffer *rb, const void *buf, size_t len);
ssize_t rb_read(struct ringbuffer *rb, void *buf, size_t len);
void *rb_dump(struct ringbuffer *rb, size_t *len);
void rb_cleanup(struct ringbuffer *rb);
#ifdef __cplusplus
}
#endif
#endif