1*29619d2aSchristos /* $NetBSD: mkstemp.c,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $ */
2*29619d2aSchristos
3*29619d2aSchristos /* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
4*29619d2aSchristos This file is derived from the one in the GNU C Library.
5*29619d2aSchristos
6*29619d2aSchristos This program is free software; you can redistribute it and/or modify
7*29619d2aSchristos it under the terms of the GNU General Public License as published by
8*29619d2aSchristos the Free Software Foundation; either version 2, or (at your option)
9*29619d2aSchristos any later version.
10*29619d2aSchristos
11*29619d2aSchristos This program is distributed in the hope that it will be useful,
12*29619d2aSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of
13*29619d2aSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*29619d2aSchristos GNU General Public License for more details.
15*29619d2aSchristos
16*29619d2aSchristos You should have received a copy of the GNU General Public License along
17*29619d2aSchristos with this program; if not, write to the Free Software Foundation,
18*29619d2aSchristos Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19*29619d2aSchristos
20*29619d2aSchristos #include <config.h>
21*29619d2aSchristos
22*29619d2aSchristos /* Disable the definition of mkstemp to rpl_mkstemp (from config.h) in this
23*29619d2aSchristos file. Otherwise, we'd get conflicting prototypes for rpl_mkstemp on
24*29619d2aSchristos most systems. */
25*29619d2aSchristos #undef mkstemp
26*29619d2aSchristos
27*29619d2aSchristos #include <stdio.h>
28*29619d2aSchristos #include <stdlib.h>
29*29619d2aSchristos
30*29619d2aSchristos #ifndef __GT_FILE
31*29619d2aSchristos # define __GT_FILE 0
32*29619d2aSchristos #endif
33*29619d2aSchristos
34*29619d2aSchristos int __gen_tempname ();
35*29619d2aSchristos
36*29619d2aSchristos /* Generate a unique temporary file name from TEMPLATE.
37*29619d2aSchristos The last six characters of TEMPLATE must be "XXXXXX";
38*29619d2aSchristos they are replaced with a string that makes the filename unique.
39*29619d2aSchristos Then open the file and return a fd. */
40*29619d2aSchristos int
rpl_mkstemp(char * template)41*29619d2aSchristos rpl_mkstemp (char *template)
42*29619d2aSchristos {
43*29619d2aSchristos return __gen_tempname (template, __GT_FILE);
44*29619d2aSchristos }
45