From 3e187c094f12ef41ea6de2f55d128c3e037b5c12 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Wed, 25 Sep 2019 19:17:09 +0100 Subject: Untested version, recompiled with new buf library and with c+ --- libbuf/buf_misc.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 libbuf/buf_misc.h (limited to 'libbuf/buf_misc.h') diff --git a/libbuf/buf_misc.h b/libbuf/buf_misc.h new file mode 100644 index 0000000..ded41d7 --- /dev/null +++ b/libbuf/buf_misc.h @@ -0,0 +1,64 @@ +#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(); + int pop_pattern(int (*detect_pattern)(char *, int, int*), char **val, int *size); +}; + + +//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 -- cgit v1.2.3