blob: 4db4f6243bed816b7bb620661065fda2ce098ab3 (
plain) (
blame)
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
44
45
46
|
#ifndef __BUF_H
#define __BUF_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
typedef struct bbuf {
int size; //total size
int buf_size; //used size
char *buf;
} bbuf;
//operations on plain buffers also operations on bufer to buffer should be
//supoorted
//create new buffer without content
bbuf* bbuf_new(int size);
//set buffer value
int bbuf_set(bbuf *a, char *val, int size);
//get copy of buffer
bbuf *bbuf_copy(bbuf *buf);
//get buffer from buffer
int bbuf_get(bbuf *buf, char **val, int *size);
//resize buffer
int bbuf_realloc(bbuf *buf, int size);
//set to minimal size
int bbuf_reduce(bbuf *buf);
//increase buffer for size
int bbuf_inc(bbuf *a, char *b, int size);
//decrease buffer for size
int bbuf_dec(bbuf *a, char *b, int size);
//free buffer
void bbuf_free(bbuf *buf);
int bbuf_concat(bbuf *a, bbuf *b);
int bbuf_size(bbuf *a);
int bbuf_print(bbuf *a);
void bbuf_free(bbuf *buf);
#endif
|