2003-09-17 Uwe Reimann <Uwe_Reimann@gmx.net> Hans-Peter Nilsson <hp@axis.com>
[glibc.git] / libio / oldiofopen.c
blob29c0a18a21860f2734e4cfa7bfa879e23c426627
1 /* Copyright (C) 1993,1997,1999,2000,2002,2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA.
19 As a special exception, if you link the code in this file with
20 files compiled with a GNU compiler to produce an executable,
21 that does not cause the resulting executable to be covered by
22 the GNU Lesser General Public License. This exception does not
23 however invalidate any other reasons why the executable file
24 might be covered by the GNU Lesser General Public License.
25 This exception applies to code released by its copyright holders
26 in files containing the exception. */
28 #include <shlib-compat.h>
29 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
31 #define _IO_USE_OLD_IO_FILE
32 #include "libioP.h"
33 #ifdef __STDC__
34 #include <stdlib.h>
35 #endif
38 _IO_FILE *
39 _IO_old_fopen (filename, mode)
40 const char *filename;
41 const char *mode;
43 struct locked_FILE
45 struct _IO_FILE_plus fp;
46 #ifdef _IO_MTSAFE_IO
47 _IO_lock_t lock;
48 #endif
49 } *new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
51 if (new_f == NULL)
52 return NULL;
53 #ifdef _IO_MTSAFE_IO
54 new_f->fp.file._lock = &new_f->lock;
55 #endif
56 _IO_old_init (&new_f->fp.file, 0);
57 _IO_JUMPS (&new_f->fp) = &_IO_old_file_jumps;
58 _IO_old_file_init (&new_f->fp);
59 #if !_IO_UNIFIED_JUMPTABLES
60 new_f->fp.vtable = NULL;
61 #endif
62 if (_IO_old_file_fopen ((_IO_FILE *) &new_f->fp, filename, mode) != NULL)
63 return (_IO_FILE *) &new_f->fp;
64 INTUSE(_IO_un_link) (&new_f->fp);
65 free (new_f);
66 return NULL;
69 strong_alias (_IO_old_fopen, __old_fopen)
70 compat_symbol (libc, _IO_old_fopen, _IO_fopen, GLIBC_2_0);
71 compat_symbol (libc, __old_fopen, fopen, GLIBC_2_0);
72 #endif