2015-01-03 00:28:19 +08:00
|
|
|
/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
|
1998-08-09 04:02:34 +08: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 12:58:11 +08: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-09 04:02:34 +08: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 12:58:11 +08:00
|
|
|
Lesser General Public License for more details.
|
1998-08-09 04:02:34 +08:00
|
|
|
|
2001-07-06 12:58:11 +08:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-10 07:18:22 +08:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1998-08-09 04:02:34 +08:00
|
|
|
|
2000-03-22 07:09:29 +08:00
|
|
|
#include <shlib-compat.h>
|
2000-03-22 16:01:35 +08:00
|
|
|
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
2000-03-22 07:09:29 +08:00
|
|
|
|
1998-08-09 04:02:34 +08: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 17:29:17 +08:00
|
|
|
attribute_compat_text_section
|
1998-08-09 04:02:34 +08:00
|
|
|
__old_tmpfile (void)
|
|
|
|
{
|
|
|
|
char buf[FILENAME_MAX];
|
|
|
|
int fd;
|
|
|
|
FILE *f;
|
|
|
|
|
1998-12-14 23:23:56 +08:00
|
|
|
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
|
1998-08-09 04:02:34 +08:00
|
|
|
return NULL;
|
2009-10-30 15:11:07 +08:00
|
|
|
fd = __gen_tempname (buf, 0, 0, __GT_FILE);
|
1998-08-09 04:02:34 +08: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 15:14:15 +08:00
|
|
|
(void) __unlink (buf);
|
1998-08-09 04:02:34 +08:00
|
|
|
|
|
|
|
if ((f = _IO_old_fdopen (fd, "w+b")) == NULL)
|
1998-12-17 21:58:32 +08:00
|
|
|
__close (fd);
|
1998-08-09 04:02:34 +08:00
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
2000-03-27 13:18:47 +08:00
|
|
|
compat_symbol (libc, __old_tmpfile, tmpfile, GLIBC_2_0);
|
2000-03-22 07:09:29 +08:00
|
|
|
#endif
|