More EasyTree compatibility.
[gedcom-parse.git] / t / src / output.c
1 /* Test program for the Gedcom library.
2    Copyright (C) 2001, 2002 The Genes Development Team
3    This file is part of the Gedcom parser library.
4    Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
5
6    The Gedcom parser library is free software; you can redistribute it
7    and/or modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The Gedcom parser library is distributed in the hope that it will be
12    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the Gedcom parser library; if not, write to the
18    Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 /* $Id$ */
22 /* $Name$ */
23
24 #include "output.h"
25 #include <stdio.h>
26 #include <stdarg.h>
27
28 #define OUTFILE "check.out"
29 FILE* outfile = NULL;
30 int quiet = 0;
31
32 void output(int to_stdout_too, const char* format, ...)
33 {
34   va_list ap;
35   va_start(ap, format);
36   if (outfile) {
37     vfprintf(outfile, format, ap);
38   }
39   if (to_stdout_too && !quiet) {
40     vprintf(format, ap);
41   }
42   va_end(ap);
43 }
44
45 void output_set_quiet(int q)
46 {
47   quiet = q;
48 }
49
50 void output_open(const char *outfilename)
51 {
52   if (!outfilename)
53     outfilename = OUTFILE;
54   outfile = fopen(outfilename, "a");
55   if (!outfile) {
56     printf("Could not open %s for appending\n", outfilename);
57   }
58 }
59
60 void output_close()
61 {
62   fclose(outfile);
63 }
64