Back to index

glibc  2.9
oldiofopen.c
Go to the documentation of this file.
00001 /* Copyright (C) 1993,1997,1999,2000,2002,2003,2004
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.
00019 
00020    As a special exception, if you link the code in this file with
00021    files compiled with a GNU compiler to produce an executable,
00022    that does not cause the resulting executable to be covered by
00023    the GNU Lesser General Public License.  This exception does not
00024    however invalidate any other reasons why the executable file
00025    might be covered by the GNU Lesser General Public License.
00026    This exception applies to code released by its copyright holders
00027    in files containing the exception.  */
00028 
00029 #include <shlib-compat.h>
00030 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
00031 
00032 #define _IO_USE_OLD_IO_FILE
00033 #include "libioP.h"
00034 #ifdef __STDC__
00035 #include <stdlib.h>
00036 #endif
00037 
00038 
00039 _IO_FILE *
00040 attribute_compat_text_section
00041 _IO_old_fopen (filename, mode)
00042      const char *filename;
00043      const char *mode;
00044 {
00045   struct locked_FILE
00046   {
00047     struct _IO_FILE_complete_plus fp;
00048 #ifdef _IO_MTSAFE_IO
00049     _IO_lock_t lock;
00050 #endif
00051   } *new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
00052 
00053   if (new_f == NULL)
00054     return NULL;
00055 #ifdef _IO_MTSAFE_IO
00056   new_f->fp.file._file._lock = &new_f->lock;
00057 #endif
00058   _IO_old_init (&new_f->fp.file._file, 0);
00059   _IO_JUMPS ((struct _IO_FILE_plus *) &new_f->fp) = &_IO_old_file_jumps;
00060   _IO_old_file_init ((struct _IO_FILE_plus *) &new_f->fp);
00061 #if  !_IO_UNIFIED_JUMPTABLES
00062   new_f->fp.vtable = NULL;
00063 #endif
00064   if (_IO_old_file_fopen ((_IO_FILE *) &new_f->fp, filename, mode) != NULL)
00065     return (_IO_FILE *) &new_f->fp;
00066   INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) &new_f->fp);
00067   free (new_f);
00068   return NULL;
00069 }
00070 
00071 strong_alias (_IO_old_fopen, __old_fopen)
00072 compat_symbol (libc, _IO_old_fopen, _IO_fopen, GLIBC_2_0);
00073 compat_symbol (libc, __old_fopen, fopen, GLIBC_2_0);
00074 #endif