2 dbuf_string.h - Append formatted string to the dynamic buffer
3 version 1.2.2, March 20th, 2012
5 Copyright (c) 2002-2012 Borut Razem
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 Boston, MA 02110-1301, USA.
24 #ifndef __DBUF_STRING_H
25 #define __DBUF_STRING_H
31 /* Attribute `nonnull' was valid as of gcc 3.3. */
32 #ifndef ATTRIBUTE_NONNULL
33 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
34 # define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
36 # define ATTRIBUTE_NONNULL(m)
37 # endif /* GNUC >= 3.3 */
38 #endif /* ATTRIBUTE_NONNULL */
40 /* The __-protected variants of `format' and `printf' attributes
41 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
42 #ifndef ATTRIBUTE_PRINTF
43 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
44 # define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
46 # define ATTRIBUTE_PRINTF(m, n)
47 # endif /* GNUC >= 2.7 */
48 #endif /* ATTRIBUTE_PRINTF */
54 int dbuf_append_str(struct dbuf_s
*dbuf
, const char *str
);
55 int dbuf_prepend_str(struct dbuf_s
*dbuf
, const char *str
);
56 int dbuf_append_char(struct dbuf_s
*dbuf
, char chr
);
57 int dbuf_prepend_char(struct dbuf_s
*dbuf
, char chr
);
58 int dbuf_vprintf(struct dbuf_s
*dbuf
, const char *format
, va_list args
);
59 int dbuf_printf (struct dbuf_s
*dbuf
, const char *format
, ...) ATTRIBUTE_PRINTF(2, 3);
60 size_t dbuf_getline(struct dbuf_s
*dbuf
, FILE *infp
);
61 size_t dbuf_chomp (struct dbuf_s
*dbuf
);
62 void dbuf_write (struct dbuf_s
*dbuf
, FILE *dest
);
63 void dbuf_write_and_destroy (struct dbuf_s
*dbuf
, FILE *dest
);
69 #endif /* __DBUF_STRING_H */