| 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 |
|
|
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 |
jds |
59 |
#ifndef REDIRECTSTDSTREAMS_H_SEEN |
| 34 |
|
|
#define REDIRECTSTDSTREAMS_H_SEEN |
| 35 |
johnpye |
956 |
|
| 36 |
|
|
#if 0 /* disabling this stuff (it was making it hard to debug tests) */ |
| 37 |
jds |
59 |
|
| 38 |
jds |
61 |
FILE *redirect_stderr(CONST char *filename); |
| 39 |
|
|
/**< |
| 40 |
jds |
59 |
* 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 |
jds |
61 |
* redirection is set up. Returns NULL if stderr could not be |
| 44 |
|
|
* redirected. |
| 45 |
jds |
59 |
*/ |
| 46 |
|
|
|
| 47 |
jds |
61 |
FILE *reset_stderr(void); |
| 48 |
|
|
/**< |
| 49 |
jds |
59 |
* 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 |
jds |
61 |
* to the new stderr stream. Returns NULL if stderr could not |
| 53 |
|
|
* be reset. |
| 54 |
jds |
59 |
|
| 55 |
|
|
*/ |
| 56 |
|
|
|
| 57 |
jds |
61 |
FILE *redirect_stdin(CONST char *filename); |
| 58 |
|
|
/**< |
| 59 |
jds |
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 |
jds |
61 |
* redirection is set up. Returns NULL if stdin could not be |
| 63 |
|
|
* redirected. |
| 64 |
jds |
59 |
*/ |
| 65 |
|
|
|
| 66 |
jds |
61 |
FILE *reset_stdin(void); |
| 67 |
|
|
/**< |
| 68 |
jds |
59 |
* 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 |
johnpye |
607 |
* to the new stdin stream. Returns NULL if stdin could not |
| 72 |
jds |
61 |
* be reset. |
| 73 |
jds |
59 |
*/ |
| 74 |
|
|
|
| 75 |
jds |
61 |
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 |
johnpye |
956 |
|
| 93 |
|
|
#endif |
| 94 |
jds |
61 |
|
| 95 |
jds |
59 |
#endif /* REDIRECTSTDSTREAMS_H_SEEN */ |