mutt stable branch with some hacks
at jcs 64 lines 2.3 kB view raw
1/* 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> 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 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. 19 */ 20 21#ifndef _BUFFER_H 22#define _BUFFER_H 23 24typedef struct 25{ 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? */ 30} BUFFER; 31 32/* Convert a buffer to a const char * "string" */ 33#define mutt_b2s(b) (b->data ? (const char *)b->data : "") 34 35BUFFER *mutt_buffer_new (void); 36BUFFER *mutt_buffer_init (BUFFER *); 37void mutt_buffer_free (BUFFER **); 38BUFFER *mutt_buffer_from (char *); 39void mutt_buffer_clear (BUFFER *); 40 41size_t mutt_buffer_len (BUFFER *); 42void mutt_buffer_increase_size (BUFFER *, size_t); 43void mutt_buffer_fix_dptr (BUFFER *); 44 45/* These two replace the buffer contents. */ 46int mutt_buffer_printf (BUFFER*, const char*, ...); 47void mutt_buffer_strcpy (BUFFER *, const char *); 48void mutt_buffer_strcpy_n (BUFFER *, const char *, size_t); 49void mutt_buffer_substrcpy (BUFFER *buf, const char *beg, const char *end); 50 51/* These append to the buffer. */ 52int mutt_buffer_add_printf (BUFFER*, const char*, ...); 53void mutt_buffer_addstr_n (BUFFER*, const char*, size_t); 54void mutt_buffer_addstr (BUFFER*, const char*); 55void mutt_buffer_addch (BUFFER*, char); 56 57 58void mutt_buffer_pool_init (void); 59void mutt_buffer_pool_free (void); 60 61BUFFER *mutt_buffer_pool_get (void); 62void mutt_buffer_pool_release (BUFFER **); 63 64#endif