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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#ifndef __LIBBUF_MISC_H
#define __LIBBUF_MISC_H
#include "buf.h"
#define BUF_PATTER_SIZE 2
/*
//line buffer, put data get line out
typedef struct bbuf_line
{
bbuf *buf;
char pattern[BUF_PATTER_SIZE];
char sep; //seperator character
} bbuf_line;
int bbuf_line_new(bbuf_line *buf, int size);
int bbuf_line_pattern(bbuf_line *buf, char *patt, int size);
int bbuf_line_add(bbuf_line *buf_line, bbuf *new_data);
int bbuf_line_get_line(bbuf_line *buf_line, bbuf *line);
int bbuf_line_free(bbuf_line *buf);
*/
class BufLine
{
private:
Buf *buf;
char pattern[BUF_PATTER_SIZE];
char sep; //seperator character
public:
BufLine(int size);
~BufLine();
int setpattern(char *pattern);
int setseperator(char s);
int add(char *string, int size);
int add(Buf *newdata);
int pop_line(char **val, int *size);
int print();
};
//formating buf ops
//circular buffer
/*
typedef struct bbuf_circ
{
bbuf *buf;
int head;
int tail;
} bbuf_circ;
int bbuf_circ_new(bbuf_circ **circ, int size);
int bbuf_circ_add(bbuf_circ *circ, bbuf *new_data);
int bbuf_circ_get_line(bbuf_circ *circ, bbuf *line);
int bbuf_circ_reset(bbuf_circ *circ);
int bbuf_circ_get(bbuf_circ *circ, char *data);
int bbuf_circ_put(bbuf_circ *circ, char data);
int bbuf_circ_empty(bbuf_circ *circ);
int bbuf_circ_full(bbuf_circ *circ);
int bbuf_circ_free(bbuf_circ *circ);
*/
#endif
|