nmsg  0.9.0
strbuf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 by Farsight Security, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef NMSG_STRBUF_H
18 #define NMSG_STRBUF_H
19 
20 #include <stdarg.h>
21 #include <stddef.h>
22 
23 #include <nmsg.h>
24 
32 struct nmsg_strbuf {
33  char *pos; /*%< end of string */
34  char *data; /*%< buffer for string data */
35  size_t bufsz; /*%< size of data allocation */
36 };
37 
43 struct nmsg_strbuf *nmsg_strbuf_init(void);
44 
50 void nmsg_strbuf_destroy(struct nmsg_strbuf **sb);
51 
65 nmsg_res nmsg_strbuf_append(struct nmsg_strbuf *sb, const char *fmt, ...);
66 
79 
87 size_t nmsg_strbuf_len(struct nmsg_strbuf *sb);
88 
89 #endif /* NMSG_STRBUF_H */
size_t nmsg_strbuf_len(struct nmsg_strbuf *sb)
Find the length of the used portion of the string buffer.
Definition: strbuf.c:111
nmsg_res
nmsg result code
Definition: res.h:25
Base nmsg support header.
char * pos
end of string
Definition: strbuf.h:33
size_t bufsz
size of data allocation
Definition: strbuf.h:35
struct nmsg_strbuf * nmsg_strbuf_init(void)
Initialize a string buffer.
Definition: strbuf.c:28
char * data
buffer for string data
Definition: strbuf.h:34
void nmsg_strbuf_destroy(struct nmsg_strbuf **sb)
Destroy all resources associated with a string buffer.
Definition: strbuf.c:37
nmsg_res nmsg_strbuf_append(struct nmsg_strbuf *sb, const char *fmt,...)
Append to a string buffer.
Definition: strbuf.c:44
String buffer.
Definition: strbuf.h:32
nmsg_res nmsg_strbuf_reset(struct nmsg_strbuf *sb)
Reset a string buffer.
Definition: strbuf.c:118