]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ncbuf2: define new ncbuf2 type
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 14 Oct 2025 09:29:40 +0000 (11:29 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 17 Oct 2025 07:29:01 +0000 (09:29 +0200)
Makefile
include/haproxy/ncbuf2-t.h [new file with mode: 0644]
include/haproxy/ncbuf2.h [new file with mode: 0644]
src/ncbuf2.c [new file with mode: 0644]

index 88c7548e8eb4d5f4017e49e6219d17a1bae6a90b..9255eea53cb0bd1fd832596b5f605c6ca766442c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -999,7 +999,7 @@ OBJS += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o src/log.o          \
         src/ebsttree.o src/freq_ctr.o src/systemd.o src/init.o         \
         src/http_acl.o src/dict.o src/dgram.o src/pipe.o               \
         src/hpack-huff.o src/hpack-enc.o src/ebtree.o src/hash.o       \
-        src/httpclient_cli.o src/version.o
+        src/httpclient_cli.o src/version.o src/ncbuf2.o
 
 ifneq ($(TRACE),)
   OBJS += src/calltrace.o
diff --git a/include/haproxy/ncbuf2-t.h b/include/haproxy/ncbuf2-t.h
new file mode 100644 (file)
index 0000000..31411dd
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _HAPROXY_NCBUF2_T_H
+#define _HAPROXY_NCBUF2_T_H
+
+#include <inttypes.h>
+
+typedef uint32_t        ncb2_sz_t;
+
+#define NCBUF2_NULL ((struct ncbuf2){ })
+
+struct ncbuf2 {
+       char *area;
+       char *bitmap;
+       ncb2_sz_t size;
+       ncb2_sz_t head;
+};
+
+#endif /* _HAPROXY_NCBUF2_T_H */
diff --git a/include/haproxy/ncbuf2.h b/include/haproxy/ncbuf2.h
new file mode 100644 (file)
index 0000000..e837187
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _HAPROXY_NCBUF2_H
+#define _HAPROXY_NCBUF2_H
+
+#include <haproxy/ncbuf2-t.h>
+#include <haproxy/ncbuf_common-t.h>
+
+struct ncbuf2 ncb2_make(char *area, ncb2_sz_t size, ncb2_sz_t head);
+
+#endif /* _HAPROXY_NCBUF2_H */
diff --git a/src/ncbuf2.c b/src/ncbuf2.c
new file mode 100644 (file)
index 0000000..ba83ce8
--- /dev/null
@@ -0,0 +1,63 @@
+#include <haproxy/ncbuf2.h>
+
+#include <string.h>
+
+struct ncbuf2 ncb2_make(char *area, ncb2_sz_t size, ncb2_sz_t head)
+{
+       struct ncbuf2 buf;
+       ncb2_sz_t bitmap_sz;
+
+       bitmap_sz = (size + 8) / 9;
+
+       buf.area = area;
+       buf.bitmap = area + size - bitmap_sz;
+       buf.size = size - bitmap_sz;
+       buf.head = head;
+
+       memset(area, 0, size);
+
+       return buf;
+}
+
+ncb2_sz_t ncb2_total_data(const struct ncbuf2 *buf)
+{
+       /* TODO */
+       return 0;
+}
+
+int ncb2_is_empty(const struct ncbuf2 *buf)
+{
+       /* TODO */
+       return 0;
+}
+
+int ncb2_is_full(const struct ncbuf2 *buf)
+{
+       /* TODO */
+       return 0;
+}
+
+int ncb2_is_fragmented(const struct ncbuf2 *buf)
+{
+       /* TODO */
+       return 0;
+}
+
+ncb2_sz_t ncb2_data(const struct ncbuf2 *buf, ncb2_sz_t off)
+{
+       /* TODO */
+       return 0;
+}
+
+enum ncb_ret ncb2_add(struct ncbuf2 *buf, ncb2_sz_t off,
+                       const char *data, ncb2_sz_t len, enum ncb_add_mode mode)
+{
+       /* TODO */
+       return NCB_RET_OK;
+}
+
+enum ncb_ret ncb2_advance(struct ncbuf2 *buf, ncb2_sz_t adv)
+{
+       /* TODO */
+       return NCB_RET_OK;
+}