summaryrefslogtreecommitdiff
path: root/lib/freopen.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-10-07 04:46:57 +0200
committerBruno Haible <bruno@clisp.org>2007-10-07 04:46:57 +0200
commit86f87b4967587bcac4fae90ee86c6fce24e3a4f3 (patch)
tree8f5b7b203e64b52cf531e5b7bf08ddbf1ae19ce3 /lib/freopen.c
parent77676a2d625501ec06a3c1dfb6f6db0c858b8b8c (diff)
downloadgnulib-86f87b4967587bcac4fae90ee86c6fce24e3a4f3.tar.gz
New modules 'fopen' and 'freopen'.
Diffstat (limited to 'lib/freopen.c')
-rw-r--r--lib/freopen.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/freopen.c b/lib/freopen.c
new file mode 100644
index 0000000000..4ae24096ec
--- /dev/null
+++ b/lib/freopen.c
@@ -0,0 +1,37 @@
+/* Open a stream to a file.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+#include <string.h>
+
+FILE *
+freopen (const char *filename, const char *mode, FILE *stream)
+#undef freopen
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ if (strcmp (filename, "/dev/null") == 0)
+ filename = "NUL";
+#endif
+
+ return freopen (filename, mode, stream);
+}