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
34 #ifdef HAVE_INTTYPES_H
44 #include "firm_config.h"
56 #include "dbginfo_t.h"
58 #define STRNIL "(nil)"
63 static void str_init(void *object, size_t n)
70 * append a char to a string buffer.
72 static void str_append_char(void *object, size_t n, char ch)
79 strncat(object, buf, n);
83 * append a string to a string buffer.
85 static void str_append_str(void *object, size_t n, const char *str)
87 strncat(object, str, n);
92 * Init the file. i.e. do nothing.
94 static void file_init(void *object, size_t n)
101 * append a char to a file.
103 static void file_append_char(void *object, size_t n, char ch)
110 * append a string to a file.
112 static void file_append_str(void *object, size_t n, const char *str)
119 * Init the obstack. i.e. do nothing.
121 static void obst_init(void *object, size_t n)
128 * append a char to a obstack.
130 static void obst_append_char(void *object, size_t n, char ch)
132 struct obstack *obst = object;
134 obstack_1grow(obst, ch);
138 * append a string to a obstack.
140 static void obst_append_str(void *object, size_t n, const char *str)
142 struct obstack *obst = object;
144 obstack_grow(obst, str, strlen(str));
151 static const appender_t file_appender = {
158 * the string buffer appender
160 static const appender_t str_appender = {
167 * the obstack appender.
169 static const appender_t obst_appender = {
175 #include "irargs_t.h"
177 void ir_printf(const char *fmt, ...)
182 lc_evprintf(firm_get_arg_env(), fmt, args);
186 void ir_fprintf(FILE *f, const char *fmt, ...)
191 lc_evfprintf(firm_get_arg_env(), f, fmt, args);
195 void ir_snprintf(char *buf, size_t n, const char *fmt, ...)
200 lc_evsnprintf(firm_get_arg_env(), buf, n, fmt, args);
204 void ir_vprintf(const char *fmt, va_list args)
206 lc_evprintf(firm_get_arg_env(), fmt, args);
209 void ir_vfprintf(FILE *f, const char *fmt, va_list args)
211 lc_evfprintf(firm_get_arg_env(), f, fmt, args);
214 void ir_vsnprintf(char *buf, size_t len, const char *fmt, va_list args)
216 lc_evsnprintf(firm_get_arg_env(), buf, len, fmt, args);
219 void ir_obst_vprintf(struct obstack *obst, const char *fmt, va_list args)
221 lc_evoprintf(firm_get_arg_env(), obst, fmt, args);