Mercurial > hg > octave-kai > gnulib-hg
annotate lib/fopen.c @ 9349:0c6048a8aaed
Use rpl_ prefix for functions, so as to avoid endless recursions in weird cases.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 15 Oct 2007 22:40:19 +0200 |
parents | bbbbbf4cd1c5 |
children | 8532ecccedda |
rev | line source |
---|---|
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Open a stream to a file. |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 Copyright (C) 2007 Free Software Foundation, Inc. |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
7 (at your option) any later version. |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 /* Specification. */ |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #include <stdio.h> |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include <string.h> |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 FILE * |
9349
0c6048a8aaed
Use rpl_ prefix for functions, so as to avoid endless recursions in weird cases.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
27 rpl_fopen (const char *filename, const char *mode) |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 #undef fopen |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 { |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 if (strcmp (filename, "/dev/null") == 0) |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 filename = "NUL"; |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 #endif |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 return fopen (filename, mode); |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 } |