-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfifo_buf.h
34 lines (28 loc) · 843 Bytes
/
fifo_buf.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
#ifndef FIFO_BUF_H
#define FIFO_BUF_H
#include <unistd.h>
#ifdef __cplusplus
extern "C" {
#endif
struct fifo_buf
{
char *buf; /* The buffer content. */
int size; /* Size of the buffer. */
int pos; /* Current position. */
int fill; /* Current fill. */
};
void fifo_buf_init (struct fifo_buf *b, const size_t size);
void fifo_buf_destroy (struct fifo_buf *b);
size_t fifo_buf_put (struct fifo_buf *b, const char *data, size_t size);
size_t fifo_buf_get (struct fifo_buf *b, char *user_buf,
size_t user_buf_size);
size_t fifo_buf_peek (struct fifo_buf *b, char *user_buf,
size_t user_buf_size);
size_t fifo_buf_get_space (const struct fifo_buf *b);
void fifo_buf_clear (struct fifo_buf *b);
size_t fifo_buf_get_fill (const struct fifo_buf *b);
size_t fifo_buf_get_size (const struct fifo_buf *b);
#ifdef __cplusplus
}
#endif
#endif