2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief A little printf helper unterstanding firm types
23 * @author Sebastian Hack
30 #ifdef HAVE_INTTYPES_H
51 #include "dbginfo_t.h"
53 #define STRNIL "(nil)"
58 static void str_init(void *object, size_t n)
65 * append a char to a string buffer.
67 static void str_append_char(void *object, size_t n, char ch)
74 strncat(object, buf, n);
78 * append a string to a string buffer.
80 static void str_append_str(void *object, size_t n, const char *str)
82 strncat(object, str, n);
87 * Init the file. i.e. do nothing.
89 static void file_init(void *object, size_t n)
96 * append a char to a file.
98 static void file_append_char(void *object, size_t n, char ch)
105 * append a string to a file.
107 static void file_append_str(void *object, size_t n, const char *str)
114 * Init the obstack. i.e. do nothing.
116 static void obst_init(void *object, size_t n)
123 * append a char to a obstack.
125 static void obst_append_char(void *object, size_t n, char ch)
127 struct obstack *obst = object;
129 obstack_1grow(obst, ch);
133 * append a string to a obstack.
135 static void obst_append_str(void *object, size_t n, const char *str)
137 struct obstack *obst = object;
139 obstack_grow(obst, str, strlen(str));
146 static const appender_t file_appender = {
153 * the string buffer appender
155 static const appender_t str_appender = {
162 * the obstack appender.
164 static const appender_t obst_appender = {
170 #include "irargs_t.h"
172 void ir_printf(const char *fmt, ...)
177 lc_evprintf(firm_get_arg_env(), fmt, args);
181 void ir_fprintf(FILE *f, const char *fmt, ...)
186 lc_evfprintf(firm_get_arg_env(), f, fmt, args);
190 void ir_snprintf(char *buf, size_t n, const char *fmt, ...)
195 lc_evsnprintf(firm_get_arg_env(), buf, n, fmt, args);
199 void ir_vprintf(const char *fmt, va_list args)
201 lc_evprintf(firm_get_arg_env(), fmt, args);
204 void ir_vfprintf(FILE *f, const char *fmt, va_list args)
206 lc_evfprintf(firm_get_arg_env(), f, fmt, args);
209 void ir_vsnprintf(char *buf, size_t len, const char *fmt, va_list args)
211 lc_evsnprintf(firm_get_arg_env(), buf, len, fmt, args);
214 void ir_obst_vprintf(struct obstack *obst, const char *fmt, va_list args)
216 lc_evoprintf(firm_get_arg_env(), obst, fmt, args);