satyr  0.28
strbuf.h
Go to the documentation of this file.
1 /*
2  strbuf.h - a string buffer
3 
4  Copyright (C) 2010 Red Hat, Inc.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20 #ifndef SATYR_STRBUF_H
21 #define SATYR_STRBUF_H
22 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <stdarg.h>
33 #include "utils.h"
34 
38 struct sr_strbuf
39 {
43  size_t alloc;
47  size_t len;
48  char *buf;
49 };
50 
57 struct sr_strbuf *
58 sr_strbuf_new(void);
59 
65 void
66 sr_strbuf_init(struct sr_strbuf *strbuf);
67 
73 void
74 sr_strbuf_free(struct sr_strbuf *strbuf);
75 
81 char *
82 sr_strbuf_free_nobuf(struct sr_strbuf *strbuf);
83 
88 void
89 sr_strbuf_clear(struct sr_strbuf *strbuf);
90 
95 void
96 sr_strbuf_grow(struct sr_strbuf *strbuf, size_t num);
97 
102 struct sr_strbuf *
103 sr_strbuf_append_char(struct sr_strbuf *strbuf,
104  char c);
105 
110 struct sr_strbuf *
111 sr_strbuf_append_str(struct sr_strbuf *strbuf,
112  const char *str);
113 
118 struct sr_strbuf *
119 sr_strbuf_prepend_str(struct sr_strbuf *strbuf,
120  const char *str);
121 
126 struct sr_strbuf *
127 sr_strbuf_append_strf(struct sr_strbuf *strbuf,
128  const char *format, ...) __sr_printf(2, 3);
129 
134 struct sr_strbuf *
135 sr_strbuf_append_strfv(struct sr_strbuf *strbuf,
136  const char *format, va_list p);
137 
143 struct sr_strbuf *
144 sr_strbuf_prepend_strf(struct sr_strbuf *strbuf,
145  const char *format, ...) __sr_printf(2, 3);
146 
151 struct sr_strbuf *
152 sr_strbuf_prepend_strfv(struct sr_strbuf *strbuf,
153  const char *format, va_list p);
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif
struct sr_strbuf * sr_strbuf_prepend_strf(struct sr_strbuf *strbuf, const char *format,...) __sr_printf(2
struct sr_strbuf * sr_strbuf_append_str(struct sr_strbuf *strbuf, const char *str)
struct sr_strbuf struct sr_strbuf * sr_strbuf_prepend_strfv(struct sr_strbuf *strbuf, const char *format, va_list p)
void sr_strbuf_clear(struct sr_strbuf *strbuf)
A resizable string buffer.
Definition: strbuf.h:38
Various utility functions, macros and variables that do not fit elsewhere.
struct sr_strbuf * sr_strbuf_new(void)
struct sr_strbuf * sr_strbuf_append_char(struct sr_strbuf *strbuf, char c)
struct sr_strbuf * sr_strbuf_append_strf(struct sr_strbuf *strbuf, const char *format,...) __sr_printf(2
size_t len
Definition: strbuf.h:47
void sr_strbuf_init(struct sr_strbuf *strbuf)
struct sr_strbuf struct sr_strbuf * sr_strbuf_append_strfv(struct sr_strbuf *strbuf, const char *format, va_list p)
void sr_strbuf_grow(struct sr_strbuf *strbuf, size_t num)
char * sr_strbuf_free_nobuf(struct sr_strbuf *strbuf)
void sr_strbuf_free(struct sr_strbuf *strbuf)
struct sr_strbuf * sr_strbuf_prepend_str(struct sr_strbuf *strbuf, const char *str)
size_t alloc
Definition: strbuf.h:43