version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
MKTEMP |
|
|
2 |
!!!MKTEMP |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
CONFORMING TO |
|
|
9 |
NOTE |
|
|
10 |
BUGS |
|
|
11 |
SEE ALSO |
|
|
12 |
---- |
|
|
13 |
!!NAME |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
mktemp - make a unique temporary file name |
|
|
17 |
!!SYNOPSIS |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
__#include |
|
|
21 |
__''template''__); |
|
|
22 |
__ |
|
|
23 |
!!DESCRIPTION |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
The __mktemp()__ function generates a unique temporary |
|
|
27 |
file name from ''template''. The last six characters of |
|
|
28 |
''template'' must be XXXXXX and these are replaced with a |
|
|
29 |
string that makes the filename unique. Since it will be |
|
|
30 |
modified, ''template'' must not be a string constant, but |
|
|
31 |
should be declared as a character array. |
|
|
32 |
!!RETURN VALUE |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
The __mktemp()__ function returns NULL on error |
|
|
36 |
(''template'' did not end in XXXXXX) and ''template'' |
|
|
37 |
otherwise. If the call was successful, the last six bytes of |
|
|
38 |
''template'' will have been modified in such a way that |
|
|
39 |
the resulting name is unique (does not exist already). If |
|
|
40 |
the call was unsuccessful, ''template'' is made an empty |
|
|
41 |
string. |
|
|
42 |
!!ERRORS |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
__EINVAL__ |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
The last six characters of ''template'' were not |
|
|
49 |
XXXXXX. |
|
|
50 |
!!CONFORMING TO |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
BSD 4.3. POSIX dictates tmpnam(3). |
|
|
54 |
!!NOTE |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
The prototype is in '''' for libc4, |
|
|
58 |
libc5, glibc1; glibc2 follows the Single Unix Specification |
|
|
59 |
and has the prototype in |
|
|
60 |
''''. |
|
|
61 |
!!BUGS |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
Never use __mktemp()__. Some implementations follow BSD |
|
|
65 |
4.3 and replace XXXXXX by the current process id and a |
|
|
66 |
single letter, so that at most 26 different names can be |
|
|
67 |
returned. Since on the one hand the names are easy to guess, |
|
|
68 |
and on the other hand there is a race between testing |
|
|
69 |
whether the name exists and opening the file, every use of |
|
|
70 |
__mktemp()__ is a security risk. The race is avoided by |
|
|
71 |
mkstemp(3). |
|
|
72 |
!!SEE ALSO |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
mkstemp(3), tempnam(3), tmpfile(3), |
|
|
76 |
tmpnam(3) |
|
|
77 |
---- |