aboutsummaryrefslogblamecommitdiffstats
path: root/buf.h
blob: 3af86ca39cb8da607ee33da0aec6a2c85c90a9b2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                     
                                                                          
























                                               
#ifndef __BUF_H
#define __BUF_H

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

typedef struct bbuf {
	int size;
	int buf_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);
//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);

void bbuf_free(bbuf *buf);

#endif