*** empty log message ***
[libfirm] / ir / common / xfprintf.c
1 /* Xfprintf --- extended formatted output to files.
2    Copyright (C) 1995, 1996 Christian von Roques */
3
4 #ifdef HAVE_CONFIG_H
5 # include <config.h>
6 #endif
7
8 #ifndef USE_PRINTF
9
10 #include <assert.h>
11 #include "xprintf.h"
12
13
14 static int
15 xfprinter (void *f, const char *data, size_t len)
16 {
17   size_t togo = len;
18
19   while (togo > 0) {
20     size_t n = fwrite (data, 1, togo, (FILE*)f);
21
22     if (!n) return -1;
23     togo -= n;
24     data += n;
25   }
26
27   return len;
28 }
29
30 int
31 xfprintf (FILE *F, const char *fmt, ...)
32 {
33   va_list args;
34   int res;
35
36   va_start (args, fmt);
37   res = xvgprintf (xfprinter, F, fmt, args);
38   va_end (args);
39   return res;
40 }
41
42
43 int
44 xvfprintf (FILE *F, const char *fmt, va_list args)
45 {
46   return xvgprintf (xfprinter, F, fmt, args);
47 }
48
49
50 int
51 xprintf (const char *fmt, ...)
52 {
53   va_list args;
54   int res;
55
56   va_start (args, fmt);
57   res = xvgprintf (xfprinter, stdout, fmt, args);
58   va_end (args);
59   return res;
60 }
61
62 int
63 xvprintf (const char *fmt, va_list args)
64 {
65   return xvgprintf (xfprinter, stdout, fmt, args);
66 }
67
68 #endif /* USE_PRINTF */