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