Blame lib/mkstemp.c

Packit Service 2723c6
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2018 Free Software
Packit Service 2723c6
   Foundation, Inc.
Packit Service 2723c6
   This file is derived from the one in the GNU C Library.
Packit Service 2723c6
Packit Service 2723c6
   This program is free software: you can redistribute it and/or modify
Packit Service 2723c6
   it under the terms of the GNU General Public License as published by
Packit Service 2723c6
   the Free Software Foundation; either version 3 of the License, or
Packit Service 2723c6
   (at your option) any later version.
Packit Service 2723c6
Packit Service 2723c6
   This program is distributed in the hope that it will be useful,
Packit Service 2723c6
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2723c6
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 2723c6
   GNU General Public License for more details.
Packit Service 2723c6
Packit Service 2723c6
   You should have received a copy of the GNU General Public License
Packit Service 2723c6
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 2723c6
Packit Service 2723c6
#if !_LIBC
Packit Service 2723c6
# include <config.h>
Packit Service 2723c6
#endif
Packit Service 2723c6
Packit Service 2723c6
#include <stdlib.h>
Packit Service 2723c6
Packit Service 2723c6
#if !_LIBC
Packit Service 2723c6
# include "tempname.h"
Packit Service 2723c6
# define __gen_tempname gen_tempname
Packit Service 2723c6
# ifndef __GT_FILE
Packit Service 2723c6
#  define __GT_FILE GT_FILE
Packit Service 2723c6
# endif
Packit Service 2723c6
#endif
Packit Service 2723c6
Packit Service 2723c6
#include <stdio.h>
Packit Service 2723c6
Packit Service 2723c6
#ifndef __GT_FILE
Packit Service 2723c6
# define __GT_FILE 0
Packit Service 2723c6
#endif
Packit Service 2723c6
Packit Service 2723c6
/* Generate a unique temporary file name from XTEMPLATE.
Packit Service 2723c6
   The last six characters of XTEMPLATE must be "XXXXXX";
Packit Service 2723c6
   they are replaced with a string that makes the file name unique.
Packit Service 2723c6
   Then open the file and return a fd.
Packit Service 2723c6
Packit Service 2723c6
   If you are creating temporary files which will later be removed,
Packit Service 2723c6
   consider using the clean-temp module, which avoids several pitfalls
Packit Service 2723c6
   of using mkstemp directly. */
Packit Service 2723c6
int
Packit Service 2723c6
mkstemp (char *xtemplate)
Packit Service 2723c6
{
Packit Service 2723c6
  return __gen_tempname (xtemplate, 0, 0, __GT_FILE);
Packit Service 2723c6
}