1 '\" te
   2 .\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
   3 .\" Copyright 1989 AT&T
   4 .\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
   5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   6 .\" http://www.opengroup.org/bookstore/.
   7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   8 .\"  This notice shall appear on any product containing this material.
   9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
  10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  12 .TH MKTEMP 3C "Sep 15, 2004"
  13 .SH NAME
  14 mktemp \- make a unique file name  from a template
  15 .SH SYNOPSIS
  16 .LP
  17 .nf
  18 #include <stdlib.h>
  19 
  20 \fBchar *\fR\fBmktemp\fR(\fBchar *\fR\fItemplate\fR);
  21 .fi
  22 
  23 .SH DESCRIPTION
  24 .sp
  25 .LP
  26 The \fBmktemp()\fR function replaces the contents of the string pointed to by
  27 \fItemplate\fR with a unique file name, and returns \fItemplate\fR. The string
  28 in \fItemplate\fR should look like a file name with six trailing 'X's;
  29 \fBmktemp()\fR will replace the 'X's with a character string that can be used
  30 to create a unique file name. Only 26 unique file names per thread can be
  31 created for each unique \fItemplate\fR.
  32 .SH RETURN VALUES
  33 .sp
  34 .LP
  35 The \fBmktemp()\fR function returns a pointer to the \fItemplate\fR on success
  36 and \fBNULL\fR if unique name cannot be created.
  37 .SH ERRORS
  38 .sp
  39 .LP
  40 No errors are defined.
  41 .SH EXAMPLES
  42 .LP
  43 \fBExample 1 \fRGenerate a filename.
  44 .sp
  45 .LP
  46 The following example replaces the contents of the "template" string with a
  47 10-character filename beginning with the characters "file" and returns a
  48 pointer to the "template" string that contains the new filename.
  49 
  50 .sp
  51 .in +2
  52 .nf
  53 #include <stdlib.h>
  54 \&...
  55 char template[] = "/tmp/fileXXXXXX";
  56 char *ptr;
  57 ptr = mktemp(template);
  58 .fi
  59 .in -2
  60 
  61 .SH USAGE
  62 .sp
  63 .LP
  64 Between the time a pathname is created and the file opened, it is possible for
  65 some other process to create a file with the same name. The \fBmkstemp\fR(3C)
  66 function avoids this problem and is preferred over this function.
  67 .SH ATTRIBUTES
  68 .sp
  69 .LP
  70 See \fBattributes\fR(5) for descriptions of the following attributes:
  71 .sp
  72 
  73 .sp
  74 .TS
  75 box;
  76 c | c
  77 l | l .
  78 ATTRIBUTE TYPE  ATTRIBUTE VALUE
  79 _
  80 Interface Stability     Standard
  81 _
  82 MT-Level        Safe
  83 .TE
  84 
  85 .SH SEE ALSO
  86 .sp
  87 .LP
  88 \fBmkstemp\fR(3C), \fBtmpfile\fR(3C), \fBtmpnam\fR(3C), \fBattributes\fR(5),
  89 \fBstandards\fR(5)