]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/strbuf.h
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / basic / strbuf.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2012 Kay Sievers <kay@vrfy.org>
8 ***/
9
10 #include <stddef.h>
11 #include <stdint.h>
12 #include <sys/types.h>
13
14 struct strbuf {
15 char *buf;
16 size_t len;
17 struct strbuf_node *root;
18
19 size_t nodes_count;
20 size_t in_count;
21 size_t in_len;
22 size_t dedup_len;
23 size_t dedup_count;
24 };
25
26 struct strbuf_node {
27 size_t value_off;
28 size_t value_len;
29
30 struct strbuf_child_entry *children;
31 uint8_t children_count;
32 };
33
34 struct strbuf_child_entry {
35 uint8_t c;
36 struct strbuf_node *child;
37 };
38
39 struct strbuf *strbuf_new(void);
40 ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
41 void strbuf_complete(struct strbuf *str);
42 void strbuf_cleanup(struct strbuf *str);