2013-01-02 19:01:50 +00:00
|
|
|
/* Copyright (C) 1991-2013 Free Software Foundation, Inc.
|
1998-08-08 20:02:34 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1998-08-08 20:02:34 +00:00
|
|
|
|
|
|
|
The GNU C Library 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
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1998-08-08 20:02:34 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1998-08-08 20:02:34 +00:00
|
|
|
|
2000-03-21 23:09:29 +00:00
|
|
|
#include <shlib-compat.h>
|
2000-03-22 08:01:35 +00:00
|
|
|
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
2000-03-21 23:09:29 +00:00
|
|
|
|
1998-08-08 20:02:34 +00:00
|
|
|
#define _IO_USE_OLD_IO_FILE
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <iolibio.h>
|
|
|
|
|
|
|
|
/* This returns a new stream opened on a temporary file (generated
|
|
|
|
by tmpnam). The file is opened with mode "w+b" (binary read/write).
|
|
|
|
If we couldn't generate a unique filename or the file couldn't
|
|
|
|
be opened, NULL is returned. */
|
|
|
|
FILE *
|
2004-03-10 09:29:17 +00:00
|
|
|
attribute_compat_text_section
|
1998-08-08 20:02:34 +00:00
|
|
|
__old_tmpfile (void)
|
|
|
|
{
|
|
|
|
char buf[FILENAME_MAX];
|
|
|
|
int fd;
|
|
|
|
FILE *f;
|
|
|
|
|
1998-12-14 15:23:56 +00:00
|
|
|
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
|
1998-08-08 20:02:34 +00:00
|
|
|
return NULL;
|
2009-10-30 07:11:07 +00:00
|
|
|
fd = __gen_tempname (buf, 0, 0, __GT_FILE);
|
1998-08-08 20:02:34 +00:00
|
|
|
if (fd < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Note that this relies on the Unix semantics that
|
|
|
|
a file is not really removed until it is closed. */
|
2003-09-02 07:14:15 +00:00
|
|
|
(void) __unlink (buf);
|
1998-08-08 20:02:34 +00:00
|
|
|
|
|
|
|
if ((f = _IO_old_fdopen (fd, "w+b")) == NULL)
|
1998-12-17 13:58:32 +00:00
|
|
|
__close (fd);
|
1998-08-08 20:02:34 +00:00
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
2000-03-27 05:18:47 +00:00
|
|
|
compat_symbol (libc, __old_tmpfile, tmpfile, GLIBC_2_0);
|
2000-03-21 23:09:29 +00:00
|
|
|
#endif
|