2 * Copyright (C) 1996-2002,2010,2013 Michael R. Elkins <me@mutt.org>
3 * Copyright (C) 2004 g10 Code GmbH
4 * Copyright (C) 2018 Kevin J. McCarthy <kevin@8t8.us>
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 char *data; /* pointer to data */
27 char *dptr; /* current read/write position */
28 size_t dsize; /* length of data */
29 int destroy; /* destroy `data' when done? */
32 /* Convert a buffer to a const char * "string" */
33 #define mutt_b2s(b) (b->data ? (const char *)b->data : "")
35 BUFFER *mutt_buffer_new (void);
36 BUFFER *mutt_buffer_init (BUFFER *);
37 void mutt_buffer_free (BUFFER **);
38 BUFFER *mutt_buffer_from (char *);
39 void mutt_buffer_clear (BUFFER *);
41 size_t mutt_buffer_len (BUFFER *);
42 void mutt_buffer_increase_size (BUFFER *, size_t);
43 void mutt_buffer_fix_dptr (BUFFER *);
45 /* These two replace the buffer contents. */
46 int mutt_buffer_printf (BUFFER*, const char*, ...);
47 void mutt_buffer_strcpy (BUFFER *, const char *);
48 void mutt_buffer_strcpy_n (BUFFER *, const char *, size_t);
49 void mutt_buffer_substrcpy (BUFFER *buf, const char *beg, const char *end);
51 /* These append to the buffer. */
52 int mutt_buffer_add_printf (BUFFER*, const char*, ...);
53 void mutt_buffer_addstr_n (BUFFER*, const char*, size_t);
54 void mutt_buffer_addstr (BUFFER*, const char*);
55 void mutt_buffer_addch (BUFFER*, char);
58 void mutt_buffer_pool_init (void);
59 void mutt_buffer_pool_free (void);
61 BUFFER *mutt_buffer_pool_get (void);
62 void mutt_buffer_pool_release (BUFFER **);