Debian Codegraph @

ext/GOTCHA/src/example/autotee/test_autotee.c

raw symbols SCIP
1 /*
2 This file is part of GOTCHA. For copyright information see the COPYRIGHT
3 file in the top level directory, or at
4 https://github.com/LLNL/gotcha/blob/master/COPYRIGHT
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU Lesser General Public License (as published by the Free
7 Software Foundation) version 2.1 dated February 1999. This program is
8 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 PURPOSE. See the terms and conditions of the GNU Lesser General Public License
11 for more details. You should have received a copy of the GNU Lesser General
12 Public License along with this program; if not, write to the Free Software
13 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
14 */
15
16 #include <stdio.h>
17 #include <string.h>
18
19 extern int init_autotee(char *filename);
20 extern int close_autotee();
21
22 #define OUTPUT_FILE "tee.out"
23
24 int main() {
25 int result;
26
27 printf("Every stdout print after this line should also appear in %s:\n",
28 OUTPUT_FILE);
29
30 result = init_autotee(OUTPUT_FILE);
31 if (result != 0) return -1;
32
33 printf("First line\n");
34 printf("Second %s\n", "line");
35 fprintf(stdout, "Third line\n");
36 fprintf(stdout, "%s line\n", "Forth");
37 puts("Fifth line");
38 fputs("Sixth ", stdout);
39 fputs("line\n", stdout);
40 fwrite("Seventh line\n", 1, strlen("Seventh line\n"), stdout);
41 fprintf(stderr, "Eighth line is stderr and should not appear in in %s\n",
42 OUTPUT_FILE);
43 close_autotee();
44 printf("Ninth line is after close and should not appear in %s\n",
45 OUTPUT_FILE);
46
47 return 0;
48 }