1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 2005 Jerry St.Clair |
3 |
Copyright (C) 2006 Carnegie Mellon University |
4 |
|
5 |
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 |
|
10 |
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 |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
Boston, MA 02111-1307, USA. |
19 |
*//** |
20 |
@file |
21 |
Centralized redirection of standard streams to file. |
22 |
|
23 |
Many ASCEND routines print messages. In a testing context, it |
24 |
is usually preferable to have output redirected to a file. This |
25 |
module provides a centralized location for this code (which may |
26 |
end up somewhat platform-dependent). |
27 |
|
28 |
Requires: |
29 |
#include <stdio.h> |
30 |
#include "utilities/ascConfig.h" |
31 |
*/ |
32 |
|
33 |
#ifndef REDIRECTSTDSTREAMS_H_SEEN |
34 |
#define REDIRECTSTDSTREAMS_H_SEEN |
35 |
|
36 |
#if 0 /* disabling this stuff (it was making it hard to debug tests) */ |
37 |
|
38 |
FILE *redirect_stderr(CONST char *filename); |
39 |
/**< |
40 |
* Redirects stderr to the specified file. |
41 |
* Returns a pointer to the new stream. If stderr was already being |
42 |
* redirected to a file, the previous file is closed before the new |
43 |
* redirection is set up. Returns NULL if stderr could not be |
44 |
* redirected. |
45 |
*/ |
46 |
|
47 |
FILE *reset_stderr(void); |
48 |
/**< |
49 |
* Restores stderr to the console. |
50 |
* This function closes the redirection file (if any) and |
51 |
* restores stderr to console output. It returns a pointer |
52 |
* to the new stderr stream. Returns NULL if stderr could not |
53 |
* be reset. |
54 |
|
55 |
*/ |
56 |
|
57 |
FILE *redirect_stdin(CONST char *filename); |
58 |
/**< |
59 |
* Redirects stdin to the specified file. |
60 |
* Returns a pointer to the new stream. If stdin was already being |
61 |
* redirected to a file, the previous file is closed before the new |
62 |
* redirection is set up. Returns NULL if stdin could not be |
63 |
* redirected. |
64 |
*/ |
65 |
|
66 |
FILE *reset_stdin(void); |
67 |
/**< |
68 |
* Restores stdin to the console. |
69 |
* This function closes the redirection file (if any) and |
70 |
* restores stdin to console output. It returns a pointer |
71 |
* to the new stdin stream. Returns NULL if stdin could not |
72 |
* be reset. |
73 |
*/ |
74 |
|
75 |
FILE *redirect_stdout(CONST char *filename); |
76 |
/**< |
77 |
* Redirects stdout to the specified file. |
78 |
* Returns a pointer to the new stream. If stdout was already being |
79 |
* redirected to a file, the previous file is closed before the new |
80 |
* redirection is set up. Returns NULL if stdout could not be |
81 |
* redirected. |
82 |
*/ |
83 |
|
84 |
FILE *reset_stdout(void); |
85 |
/**< |
86 |
* Restores stdout to the console. |
87 |
* This function closes the redirection file (if any) and |
88 |
* restores stdout to console output. It returns a pointer |
89 |
* to the new stdout stream. Returns NULL if stdout could not |
90 |
* be reset. |
91 |
*/ |
92 |
|
93 |
#endif |
94 |
|
95 |
#endif /* REDIRECTSTDSTREAMS_H_SEEN */ |