-
Notifications
You must be signed in to change notification settings - Fork 2
/
cbuffer.h
43 lines (36 loc) · 1.65 KB
/
cbuffer.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
35
36
37
38
39
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cbuffer.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dlancar <dlancar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/10/16 11:19:19 by dlancar #+# #+# */
/* Updated: 2016/12/08 15:19:46 by dlancar ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CBUFFER_H
# define CBUFFER_H
# include "libft.h"
# define CBUFFER_IS_EMPTY(buffer) (buffer->start==buffer->end && buffer->write)
typedef struct s_cbuffer
{
char *arr;
unsigned int start;
unsigned int end;
unsigned int capacity;
unsigned int it;
bool write;
} t_cbuffer;
t_cbuffer *cbuffer_new(unsigned int capacity);
t_cbuffer *cbuffer_add(t_cbuffer *buffer, const char *data,
unsigned int size);
t_cbuffer *cbuffer_clear(t_cbuffer *buffer);
void cbuffer_free(t_cbuffer **buffer);
bool cbuffer_has_next(const t_cbuffer *buffer);
bool cbuffer_it_is_last(const t_cbuffer *buffer);
char cbuffer_cnext(t_cbuffer *buffer);
char cbuffer_next(t_cbuffer *buffer);
char cbuffer_get_next(const t_cbuffer *buffer);
char cbuffer_get(const t_cbuffer *buffer);
#endif