summaryrefslogtreecommitdiff
path: root/buf_misc.h
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2018-02-27 22:32:49 +0000
committerFreeArtMan <dos21h@gmail.com>2018-02-27 22:32:49 +0000
commit03bfeedc5f4c04c20764c8a9a58bd02604f27b2c (patch)
tree7ab09ac16649d80ca9e6397fc1b19aa8e184e2db /buf_misc.h
parenta8b9b15b4f02ce3c6c7eac0d9393c44cb3fc668d (diff)
downloadlibbuf-03bfeedc5f4c04c20764c8a9a58bd02604f27b2c.tar.gz
libbuf-03bfeedc5f4c04c20764c8a9a58bd02604f27b2c.zip
Created circular buffer
Diffstat (limited to 'buf_misc.h')
-rw-r--r--buf_misc.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/buf_misc.h b/buf_misc.h
new file mode 100644
index 0000000..c0d8aab
--- /dev/null
+++ b/buf_misc.h
@@ -0,0 +1,38 @@
+#ifndef __LIBBUF_MISC_H
+#define __LIBBUF_MISC_H
+
+#include "buf.h"
+
+//line buffer, put data get line out
+typedef struct bbuf_line
+{
+ bbuf *buf;
+ char sep; //seperator character
+} bbuf_line;
+
+int bbuf_line_new(bbuf_line *buf, char sep, 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);
+
+//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