2 dbuf_string.h - Append formatted string to the dynamic buffer
3 version 1.0.0, January 6th, 2007
5 Copyright (c) 2002-2007 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
30 /* Attribute `nonnull' was valid as of gcc 3.3. */
31 #ifndef ATTRIBUTE_NONNULL
32 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
33 # define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
35 # define ATTRIBUTE_NONNULL(m)
36 # endif /* GNUC >= 3.3 */
37 #endif /* ATTRIBUTE_NONNULL */
39 /* The __-protected variants of `format' and `printf' attributes
40 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
41 #ifndef ATTRIBUTE_PRINTF
42 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
43 # define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
45 # define ATTRIBUTE_PRINTF(m, n)
46 # endif /* GNUC >= 2.7 */
47 #endif /* ATTRIBUTE_PRINTF */
53 int dbuf_append_str(struct dbuf_s *dbuf, const char *str);
54 int dbuf_append_char(struct dbuf_s *dbuf, char chr);
55 int dbuf_vprintf(struct dbuf_s *dbuf, const char *format, va_list args);
56 int dbuf_printf (struct dbuf_s *dbuf, const char *format, ...) ATTRIBUTE_PRINTF(2, 3);
57 void dbuf_write (struct dbuf_s *dbuf, FILE *dest);
58 void dbuf_write_and_destroy (struct dbuf_s *dbuf, FILE *dest);
64 #endif /* __DBUF_STRING_H */