nmsg 1.1.1
strbuf.h
1/*
2 * Copyright (c) 2023 DomainTools LLC
3 * Copyright (c) 2009-2015 by Farsight Security, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NMSG_STRBUF_H
19#define NMSG_STRBUF_H
20
28struct nmsg_strbuf {
29 char *pos; /*%< end of string */
30 char *data; /*%< buffer for string data */
31 size_t bufsz; /*%< size of data allocation */
32};
33
39struct nmsg_strbuf *nmsg_strbuf_init(void);
40
46void nmsg_strbuf_destroy(struct nmsg_strbuf **sb);
47
60nmsg_res nmsg_strbuf_append_str_json(struct nmsg_strbuf *sb, const char *str, size_t len);
61
74nmsg_res nmsg_strbuf_append_str(struct nmsg_strbuf *sb, const char *str, size_t len);
75
89nmsg_res nmsg_strbuf_append(struct nmsg_strbuf *sb, const char *fmt, ...);
90
101nmsg_res nmsg_strbuf_reset(struct nmsg_strbuf *sb);
102
110size_t nmsg_strbuf_len(struct nmsg_strbuf *sb);
111
112#endif /* NMSG_STRBUF_H */