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