1TMPNAM(3P)                 POSIX Programmer's Manual                TMPNAM(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       tmpnam - create a name for a temporary file
13

SYNOPSIS

15       #include <stdio.h>
16
17       char *tmpnam(char *s);
18
19

DESCRIPTION

21       The tmpnam() function shall generate a string that is a valid  filename
22       and  that is not the same as the name of an existing file. The function
23       is potentially capable of generating {TMP_MAX} different  strings,  but
24       any or all of them may already be in use by existing files and thus not
25       be suitable return values.
26
27       The tmpnam() function generates a different  string  each  time  it  is
28       called  from  the same process, up to {TMP_MAX} times.  If it is called
29       more than {TMP_MAX} times, the behavior is implementation-defined.
30
31       The implementation shall behave as if no function defined in this  vol‐
32       ume of IEEE Std 1003.1-2001 calls tmpnam().
33
34       If the application uses any of the functions guaranteed to be available
35       if either _POSIX_THREAD_SAFE_FUNCTIONS or  _POSIX_THREADS  is  defined,
36       the  application shall ensure that the tmpnam() function is called with
37       a non-NULL parameter.
38

RETURN VALUE

40       Upon successful completion,  tmpnam()  shall  return  a  pointer  to  a
41       string.  If  no suitable string can be generated, the tmpnam() function
42       shall return a null pointer.
43
44       If the argument s is a null pointer, tmpnam() shall leave its result in
45       an  internal  static object and return a pointer to that object. Subse‐
46       quent calls to tmpnam() may modify the same object. If the  argument  s
47       is  not a null pointer, it is presumed to point to an array of at least
48       L_tmpnam chars; tmpnam() shall write its result in that array and shall
49       return the argument as its value.
50

ERRORS

52       No errors are defined.
53
54       The following sections are informative.
55

EXAMPLES

57   Generating a Filename
58       The  following example generates a unique filename and stores it in the
59       array pointed to by ptr.
60
61
62              #include <stdio.h>
63              ...
64              char filename[L_tmpnam+1];
65              char *ptr;
66
67
68              ptr = tmpnam(filename);
69

APPLICATION USAGE

71       This function only creates filenames. It is the application's responsi‐
72       bility to create and remove the files.
73
74       Between  the  time  a pathname is created and the file is opened, it is
75       possible for some other process to create a file with  the  same  name.
76       Applications may find tmpfile() more useful.
77

RATIONALE

79       None.
80

FUTURE DIRECTIONS

82       None.
83

SEE ALSO

85       fopen(),  open(),  tempnam(), tmpfile(), unlink(), the Base Definitions
86       volume of IEEE Std 1003.1-2001, <stdio.h>
87
89       Portions of this text are reprinted and reproduced in  electronic  form
90       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
91       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
92       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
93       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
94       event of any discrepancy between this version and the original IEEE and
95       The Open Group Standard, the original IEEE and The Open Group  Standard
96       is  the  referee document. The original Standard can be obtained online
97       at http://www.opengroup.org/unix/online.html .
98
99
100
101IEEE/The Open Group                  2003                           TMPNAM(3P)
Impressum