]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/strbuf.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / basic / strbuf.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
955bd501
KS
2#pragma once
3
4/***
5 This file is part of systemd.
6
1298001e 7 Copyright 2012 Kay Sievers <kay@vrfy.org>
955bd501
KS
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
11c3a366 23#include <stddef.h>
955bd501 24#include <stdint.h>
11c3a366 25#include <sys/types.h>
955bd501
KS
26
27struct strbuf {
28 char *buf;
29 size_t len;
30 struct strbuf_node *root;
31
32 size_t nodes_count;
33 size_t in_count;
34 size_t in_len;
35 size_t dedup_len;
36 size_t dedup_count;
37};
38
39struct strbuf_node {
40 size_t value_off;
41 size_t value_len;
42
43 struct strbuf_child_entry *children;
44 uint8_t children_count;
45};
46
47struct strbuf_child_entry {
48 uint8_t c;
49 struct strbuf_node *child;
50};
51
52struct strbuf *strbuf_new(void);
53ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
54void strbuf_complete(struct strbuf *str);
55void strbuf_cleanup(struct strbuf *str);