First part of commit removing xprintf to make later merging easier
[libfirm] / ir / common / xoprintf.c
1 /* Xfprintf --- extended formatted output to obstacks.
2    Copyright (C) 1995, 1996 Christian von Roques */
3
4 /* $Id$ */
5
6 #ifdef HAVE_CONFIG_H
7 # include <config.h>
8 #endif
9
10 #ifndef USE_PRINTF
11
12 #include <obstack.h>
13 #include <string.h>
14 #include <assert.h>
15 #include "xprintf.h"
16
17 /* bcopy is not ISO C */
18 #define bcopy(X, Y, Z) memcpy((Y), (X), (Z))
19
20 static int
21 xoprinter (void *obst, const char *data, size_t len)
22 {
23   obstack_grow ((struct obstack *)obst, data, len);
24   return len;
25 }
26
27
28 int
29 xoprintf (struct obstack *obst, const char *fmt, ...)
30 {
31   va_list args;
32   int res;
33
34   va_start (args, fmt);
35   res = xvgprintf (xoprinter, obst, fmt, args);
36   va_end (args);
37   return res;
38 }
39
40 int
41 xvoprintf (struct obstack *obst, const char *fmt, va_list args)
42 {
43   return xvgprintf (xoprinter, obst, fmt, args);
44 }
45
46 #endif /* USE_PRINTF */