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

NAME

6       tmpnam - create a name for a temporary file
7

SYNOPSIS

9       #include <stdio.h>
10
11       char *tmpnam(char *s);
12
13

DESCRIPTION

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

RETURN VALUE

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

ERRORS

46       No errors are defined.
47
48       The following sections are informative.
49

EXAMPLES

51   Generating a Filename
52       The following example generates a unique filename and stores it in  the
53       array pointed to by ptr.
54
55
56              #include <stdio.h>
57              ...
58              char filename[L_tmpnam+1];
59              char *ptr;
60
61
62              ptr = tmpnam(filename);
63

APPLICATION USAGE

65       This function only creates filenames. It is the application's responsi‐
66       bility to create and remove the files.
67
68       Between the time a pathname is created and the file is  opened,  it  is
69       possible  for  some  other process to create a file with the same name.
70       Applications may find tmpfile() more useful.
71

RATIONALE

73       None.
74

FUTURE DIRECTIONS

76       None.
77

SEE ALSO

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