X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=buffer.h;fp=buffer.h;h=bd3499dbc924209d6df9062e2083496822e6d0b2;hp=877b1ec1efa504f957d3e73bcb9e21524d74a46b;hb=9aae63e2d1cce39bb0928362416a8d17b953ca5e;hpb=9274cbe8e6410ddb95ddc667faa678a29da85420 diff --git a/buffer.h b/buffer.h index 877b1ec..bd3499d 100644 --- a/buffer.h +++ b/buffer.h @@ -1,3 +1,22 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Copyright © 2006 Pierre Habouzit + */ + /* * Copyright notice from original mutt: * Copyright (C) 1996-2000 Michael R. Elkins @@ -6,17 +25,32 @@ * It's licensed under the GNU General Public License, * please see the file GPL in the top level source directory. */ + #ifndef _MUTT_BUFFER_H #define _MUTT_BUFFER_H -#include "mutt.h" +#include + +typedef struct { + char *data; /* pointer to data */ + char *dptr; /* current read/write position */ + size_t dsize; /* length of data */ + int destroy; /* destroy `data' when done? */ +} BUFFER; + +BUFFER *mutt_buffer_init(BUFFER *); +void mutt_buffer_free(BUFFER **); + +BUFFER *mutt_buffer_from(BUFFER *, const char *); +int mutt_extract_token(BUFFER *, BUFFER *, int); + +void mutt_buffer_add(BUFFER *, const char *, size_t); +static inline void mutt_buffer_addstr(BUFFER *b, const char *s) { + mutt_buffer_add(b, s, m_strlen(s)); +} -int mutt_extract_token (BUFFER *, BUFFER *, int); -BUFFER *mutt_buffer_init (BUFFER *); -BUFFER *mutt_buffer_from (BUFFER *, const char *); -void mutt_buffer_free (BUFFER **); -void mutt_buffer_add (BUFFER *, const char *, size_t); -void mutt_buffer_addstr (BUFFER *, const char *); -void mutt_buffer_addch (BUFFER *, char); +static inline void mutt_buffer_addch(BUFFER *b, char c) { + mutt_buffer_add(b, &c, 1); +} #endif /* !_MUTT_BUFFER_H */