1 |
johnpye |
607 |
/* ASCEND modelling environment |
2 |
|
|
Copyright (C) 2005 Jerry St.Clair |
3 |
|
|
Copyright (C) 2006 Carnegie Mellon University |
4 |
jds |
59 |
|
5 |
johnpye |
607 |
This program is free software; you can redistribute it and/or modify |
6 |
|
|
it under the terms of the GNU General Public License as published by |
7 |
|
|
the Free Software Foundation; either version 2, or (at your option) |
8 |
|
|
any later version. |
9 |
jds |
59 |
|
10 |
johnpye |
607 |
This program is distributed in the hope that it will be useful, |
11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
GNU General Public License for more details. |
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU General Public License |
16 |
jpye |
2649 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 |
johnpye |
607 |
*//** |
18 |
|
|
@file |
19 |
|
|
Centralized redirection of standard streams to file. |
20 |
|
|
|
21 |
|
|
Many ASCEND routines print messages. In a testing context, it |
22 |
|
|
is usually preferable to have output redirected to a file. This |
23 |
|
|
module provides a centralized location for this code (which may |
24 |
|
|
end up somewhat platform-dependent). |
25 |
|
|
|
26 |
|
|
Requires: |
27 |
|
|
#include <stdio.h> |
28 |
|
|
#include "utilities/ascConfig.h" |
29 |
|
|
*/ |
30 |
|
|
|
31 |
jds |
59 |
#ifndef REDIRECTSTDSTREAMS_H_SEEN |
32 |
|
|
#define REDIRECTSTDSTREAMS_H_SEEN |
33 |
johnpye |
956 |
|
34 |
|
|
#if 0 /* disabling this stuff (it was making it hard to debug tests) */ |
35 |
jds |
59 |
|
36 |
jds |
61 |
FILE *redirect_stderr(CONST char *filename); |
37 |
|
|
/**< |
38 |
jds |
59 |
* Redirects stderr to the specified file. |
39 |
|
|
* Returns a pointer to the new stream. If stderr was already being |
40 |
|
|
* redirected to a file, the previous file is closed before the new |
41 |
jds |
61 |
* redirection is set up. Returns NULL if stderr could not be |
42 |
|
|
* redirected. |
43 |
jds |
59 |
*/ |
44 |
|
|
|
45 |
jds |
61 |
FILE *reset_stderr(void); |
46 |
|
|
/**< |
47 |
jds |
59 |
* Restores stderr to the console. |
48 |
|
|
* This function closes the redirection file (if any) and |
49 |
|
|
* restores stderr to console output. It returns a pointer |
50 |
jds |
61 |
* to the new stderr stream. Returns NULL if stderr could not |
51 |
|
|
* be reset. |
52 |
jds |
59 |
|
53 |
|
|
*/ |
54 |
|
|
|
55 |
jds |
61 |
FILE *redirect_stdin(CONST char *filename); |
56 |
|
|
/**< |
57 |
jds |
59 |
* Redirects stdin to the specified file. |
58 |
|
|
* Returns a pointer to the new stream. If stdin was already being |
59 |
|
|
* redirected to a file, the previous file is closed before the new |
60 |
jds |
61 |
* redirection is set up. Returns NULL if stdin could not be |
61 |
|
|
* redirected. |
62 |
jds |
59 |
*/ |
63 |
|
|
|
64 |
jds |
61 |
FILE *reset_stdin(void); |
65 |
|
|
/**< |
66 |
jds |
59 |
* Restores stdin to the console. |
67 |
|
|
* This function closes the redirection file (if any) and |
68 |
|
|
* restores stdin to console output. It returns a pointer |
69 |
johnpye |
607 |
* to the new stdin stream. Returns NULL if stdin could not |
70 |
jds |
61 |
* be reset. |
71 |
jds |
59 |
*/ |
72 |
|
|
|
73 |
jds |
61 |
FILE *redirect_stdout(CONST char *filename); |
74 |
|
|
/**< |
75 |
|
|
* Redirects stdout to the specified file. |
76 |
|
|
* Returns a pointer to the new stream. If stdout was already being |
77 |
|
|
* redirected to a file, the previous file is closed before the new |
78 |
|
|
* redirection is set up. Returns NULL if stdout could not be |
79 |
|
|
* redirected. |
80 |
|
|
*/ |
81 |
|
|
|
82 |
|
|
FILE *reset_stdout(void); |
83 |
|
|
/**< |
84 |
|
|
* Restores stdout to the console. |
85 |
|
|
* This function closes the redirection file (if any) and |
86 |
|
|
* restores stdout to console output. It returns a pointer |
87 |
|
|
* to the new stdout stream. Returns NULL if stdout could not |
88 |
|
|
* be reset. |
89 |
|
|
*/ |
90 |
johnpye |
956 |
|
91 |
|
|
#endif |
92 |
jds |
61 |
|
93 |
jds |
59 |
#endif /* REDIRECTSTDSTREAMS_H_SEEN */ |