Blame gnulib/lib/mkstemp.c

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