Imported Upstream version 2.9.0
[debian/cc1111] / support / Util / dbuf_string.h
1 /*
2   dbuf_string.h - Append formatted string to the dynamic buffer
3   version 1.2.0, February 10th, 2008
4
5   Copyright (c) 2002-2008 Borut Razem
6
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)
10   any later version.
11
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.
16
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.
21 */
22
23
24 #ifndef __DBUF_STRING_H
25 #define __DBUF_STRING_H
26
27 #include <stdarg.h>
28 #include "dbuf.h"
29
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)))
34 # else
35 #  define ATTRIBUTE_NONNULL(m)
36 # endif /* GNUC >= 3.3 */
37 #endif /* ATTRIBUTE_NONNULL */
38
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)
44 #else
45 #  define ATTRIBUTE_PRINTF(m, n)
46 # endif /* GNUC >= 2.7 */
47 #endif /* ATTRIBUTE_PRINTF */
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
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 size_t dbuf_getline(struct dbuf_s *dbuf, FILE *infp);
58 int dbuf_chomp (struct dbuf_s *dbuf);
59 void dbuf_write (struct dbuf_s *dbuf, FILE *dest);
60 void dbuf_write_and_destroy (struct dbuf_s *dbuf, FILE *dest);
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif  /* __DBUF_STRING_H */