xref: /netbsd-src/external/gpl2/groff/dist/src/libs/libgroff/mkstemp.cpp (revision 89a07cf815a29524268025a1139fac4c5190f765)
1*89a07cf8Schristos /*	$NetBSD: mkstemp.cpp,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $	*/
2*89a07cf8Schristos 
3*89a07cf8Schristos /* Copyright (C) 2001 Free Software Foundation, Inc.
4*89a07cf8Schristos      Written by Werner Lemberg (wl@gnu.org)
5*89a07cf8Schristos 
6*89a07cf8Schristos This file is part of groff.
7*89a07cf8Schristos 
8*89a07cf8Schristos groff is free software; you can redistribute it and/or modify it under
9*89a07cf8Schristos the terms of the GNU General Public License as published by the Free
10*89a07cf8Schristos Software Foundation; either version 2, or (at your option) any later
11*89a07cf8Schristos version.
12*89a07cf8Schristos 
13*89a07cf8Schristos groff is distributed in the hope that it will be useful, but WITHOUT ANY
14*89a07cf8Schristos WARRANTY; without even the implied warranty of MERCHANTABILITY or
15*89a07cf8Schristos FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16*89a07cf8Schristos for more details.
17*89a07cf8Schristos 
18*89a07cf8Schristos You should have received a copy of the GNU General Public License along
19*89a07cf8Schristos with groff; see the file COPYING.  If not, write to the Free Software
20*89a07cf8Schristos Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
21*89a07cf8Schristos 
22*89a07cf8Schristos 
23*89a07cf8Schristos /* This file is heavily based on the file mkstemp.c which is part of the
24*89a07cf8Schristos    fileutils package. */
25*89a07cf8Schristos 
26*89a07cf8Schristos 
27*89a07cf8Schristos extern int gen_tempname(char *, int);
28*89a07cf8Schristos 
29*89a07cf8Schristos /* Generate a unique temporary file name from TEMPLATE.
30*89a07cf8Schristos    The last six characters of TEMPLATE must be "XXXXXX";
31*89a07cf8Schristos    they are replaced with a string that makes the filename unique.
32*89a07cf8Schristos    Then open the file and return a fd. */
mkstemp(char * tmpl)33*89a07cf8Schristos int mkstemp(char *tmpl)
34*89a07cf8Schristos {
35*89a07cf8Schristos   return gen_tempname(tmpl, 0);
36*89a07cf8Schristos }
37