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
48 #include "dbginfo_t.h"
53 static void str_init(void *object, size_t n)
60 * append a char to a string buffer.
62 static void str_append_char(void *object, size_t n, char ch)
69 strncat(object, buf, n);
73 * append a string to a string buffer.
75 static void str_append_str(void *object, size_t n, const char *str)
77 strncat(object, str, n);
82 * Init the file. i.e. do nothing.
84 static void file_init(void *object, size_t n)
91 * append a char to a file.
93 static void file_append_char(void *object, size_t n, char ch)
100 * append a string to a file.
102 static void file_append_str(void *object, size_t n, const char *str)
109 * Init the obstack. i.e. do nothing.
111 static void obst_init(void *object, size_t n)
118 * append a char to a obstack.
120 static void obst_append_char(void *object, size_t n, char ch)
122 struct obstack *obst = object;
124 obstack_1grow(obst, ch);
128 * append a string to a obstack.
130 static void obst_append_str(void *object, size_t n, const char *str)
132 struct obstack *obst = object;
134 obstack_grow(obst, str, strlen(str));
141 static const appender_t file_appender = {
148 * the string buffer appender
150 static const appender_t str_appender = {
157 * the obstack appender.
159 static const appender_t obst_appender = {
165 #include "irargs_t.h"
167 void ir_printf(const char *fmt, ...)
172 lc_evprintf(firm_get_arg_env(), fmt, args);
176 void ir_fprintf(FILE *f, const char *fmt, ...)
181 lc_evfprintf(firm_get_arg_env(), f, fmt, args);
185 void ir_snprintf(char *buf, size_t n, const char *fmt, ...)
190 lc_evsnprintf(firm_get_arg_env(), buf, n, fmt, args);
194 void ir_vprintf(const char *fmt, va_list args)
196 lc_evprintf(firm_get_arg_env(), fmt, args);
199 void ir_vfprintf(FILE *f, const char *fmt, va_list args)
201 lc_evfprintf(firm_get_arg_env(), f, fmt, args);
204 void ir_vsnprintf(char *buf, size_t len, const char *fmt, va_list args)
206 lc_evsnprintf(firm_get_arg_env(), buf, len, fmt, args);
209 void ir_obst_vprintf(struct obstack *obst, const char *fmt, va_list args)
211 lc_evoprintf(firm_get_arg_env(), obst, fmt, args);