| 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 |
FILE *redirect_stderr(CONST char *filename); |
| 37 |
/**< |
| 38 |
* 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 |
* redirection is set up. Returns NULL if stderr could not be |
| 42 |
* redirected. |
| 43 |
*/ |
| 44 |
|
| 45 |
FILE *reset_stderr(void); |
| 46 |
/**< |
| 47 |
* 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 |
* to the new stderr stream. Returns NULL if stderr could not |
| 51 |
* be reset. |
| 52 |
|
| 53 |
*/ |
| 54 |
|
| 55 |
FILE *redirect_stdin(CONST char *filename); |
| 56 |
/**< |
| 57 |
* 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 |
* redirection is set up. Returns NULL if stdin could not be |
| 61 |
* redirected. |
| 62 |
*/ |
| 63 |
|
| 64 |
FILE *reset_stdin(void); |
| 65 |
/**< |
| 66 |
* 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 |
* to the new stdin stream. Returns NULL if stdin could not |
| 70 |
* be reset. |
| 71 |
*/ |
| 72 |
|
| 73 |
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 |
|
| 91 |
#endif /* REDIRECTSTDSTREAMS_H_SEEN */ |