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