168349Sobrien/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2020 Free Software
268349Sobrien   Foundation, Inc.
3290152Sdelphij   This file is derived from the one in the GNU C Library.
468349Sobrien
568349Sobrien   This program is free software: you can redistribute it and/or modify
668349Sobrien   it under the terms of the GNU General Public License as published by
768349Sobrien   the Free Software Foundation; either version 3 of the License, or
8103373Sobrien   (at your option) any later version.
968349Sobrien
1068349Sobrien   This program is distributed in the hope that it will be useful,
1168349Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1268349Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13103373Sobrien   GNU General Public License for more details.
1468349Sobrien
1568349Sobrien   You should have received a copy of the GNU General Public License
1668349Sobrien   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
17159764Sobrien
18159764Sobrien#if !_LIBC
19159764Sobrien# include <config.h>
20290152Sdelphij#endif
21226048Sobrien
22159764Sobrien#include <stdlib.h>
23226048Sobrien
24226048Sobrien#if !_LIBC
25226048Sobrien# include "tempname.h"
26226048Sobrien# define __gen_tempname gen_tempname
27226048Sobrien# ifndef __GTFILE
28226048Sobrien#  define __GT_FILE GT_FILE
29159764Sobrien# endif
30226048Sobrien#endif
31226048Sobrien
32226048Sobrien#include <stdio.h>
33226048Sobrien
34159764Sobrien#ifndef __GT_FILE
35226048Sobrien# define __GT_FILE 0
36226048Sobrien#endif
37267843Sdelphij
38267843Sdelphij/* Generate a unique temporary file name from XTEMPLATE.
39267843Sdelphij   The last six characters of XTEMPLATE must be "XXXXXX";
40267843Sdelphij   they are replaced with a string that makes the file name unique.
41267843Sdelphij   Then open the file and return a fd. */
42267843Sdelphijint
43267843Sdelphijmkostemp (char *xtemplate, int flags)
44267843Sdelphij{
45290152Sdelphij  return __gen_tempname (xtemplate, 0, flags, __GT_FILE);
46159764Sobrien}
47159764Sobrien