xfprintf.c 1.28 KB
Newer Older
Götz Lindenmaier's avatar
Götz Lindenmaier committed
1
2
3
4
5
6
7
8
9
10
11
/*
 * Project:     libFIRM
 * File name:   ir/common/xfprintf.c
 * Purpose:     Xfprintf --- extended formatted output to files.
 * Author:      Christian von Roques
 * Modified by:
 * Created:     1999 by getting from fiasco
 * CVS-ID:      $Id$
 * Copyright:   (c) 1995, 1996 Christian von Roques
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */
Christian Schäfer's avatar
Christian Schäfer committed
12

Boris Boesler's avatar
Boris Boesler committed
13

Christian Schäfer's avatar
Christian Schäfer committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#ifndef USE_PRINTF

#include <assert.h>
#include "xprintf.h"


static int
xfprinter (void *f, const char *data, size_t len)
{
  size_t togo = len;

  while (togo > 0) {
    size_t n = fwrite (data, 1, togo, (FILE*)f);

    if (!n) return -1;
    togo -= n;
    data += n;
  }

  return len;
}

int
xfprintf (FILE *F, const char *fmt, ...)
{
  va_list args;
  int res;

  va_start (args, fmt);
  res = xvgprintf (xfprinter, F, fmt, args);
  va_end (args);
  return res;
}


int
xvfprintf (FILE *F, const char *fmt, va_list args)
{
  return xvgprintf (xfprinter, F, fmt, args);
}


int
xprintf (const char *fmt, ...)
{
  va_list args;
  int res;

  va_start (args, fmt);
  res = xvgprintf (xfprinter, stdout, fmt, args);
  va_end (args);
  return res;
}

int
xvprintf (const char *fmt, va_list args)
{
  return xvgprintf (xfprinter, stdout, fmt, args);
}

#endif /* USE_PRINTF */