1 /*
2  * Function prototypes for handling string buffers.
3  * Copyright (C) 2000, 2001, 2002, 2003, 2004 Shawn Betts <sabetts@vcn.bc.ca>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation; either version 2 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA.
18  */
19 
20 #ifndef _SDORFEHS_SBUF_H
21 #define _SDORFEHS_SBUF_H 1
22 
23 #include <stdlib.h>
24 
25 struct sbuf {
26 	char *data;
27 	size_t len;
28 	size_t maxsz;
29 
30 	/* sbuf can exist in a list. */
31 	struct list_head node;
32 };
33 
34 struct sbuf *sbuf_new(size_t initsz);
35 void sbuf_free(struct sbuf *b);
36 char *sbuf_free_struct(struct sbuf *b);
37 char *sbuf_concat(struct sbuf *b, const char *str);
38 char *sbuf_nconcat(struct sbuf *b, const char *str, int len);
39 char *sbuf_utf8_nconcat(struct sbuf *b, const char *s, int width);
40 char *sbuf_copy(struct sbuf *b, const char *str);
41 char *sbuf_clear(struct sbuf *b);
42 char *sbuf_get(struct sbuf *b);
43 char *sbuf_printf(struct sbuf *b, char *fmt,...);
44 char *sbuf_printf_concat(struct sbuf *b, char *fmt,...);
45 void sbuf_chop(struct sbuf *b);
46 
47 #endif	/* ! _SDORFEHS_SBUF_H */
48