]>
Commit | Line | Data |
---|---|---|
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 | ||
11c3a366 | 10 | #include <stddef.h> |
955bd501 | 11 | #include <stdint.h> |
11c3a366 | 12 | #include <sys/types.h> |
955bd501 | 13 | |
f201daec ZJS |
14 | #include "macro.h" |
15 | ||
955bd501 KS |
16 | struct strbuf { |
17 | char *buf; | |
18 | size_t len; | |
19 | struct strbuf_node *root; | |
20 | ||
21 | size_t nodes_count; | |
22 | size_t in_count; | |
23 | size_t in_len; | |
24 | size_t dedup_len; | |
25 | size_t dedup_count; | |
26 | }; | |
27 | ||
28 | struct strbuf_node { | |
29 | size_t value_off; | |
30 | size_t value_len; | |
31 | ||
32 | struct strbuf_child_entry *children; | |
33 | uint8_t children_count; | |
34 | }; | |
35 | ||
36 | struct strbuf_child_entry { | |
37 | uint8_t c; | |
38 | struct strbuf_node *child; | |
39 | }; | |
40 | ||
41 | struct strbuf *strbuf_new(void); | |
42 | ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len); | |
43 | void strbuf_complete(struct strbuf *str); | |
44 | void strbuf_cleanup(struct strbuf *str); | |
f201daec | 45 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_cleanup); |