OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / tmpnam.3
1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
2 .\" Japanese Version Copyright 1997 Tenkou N. Hattori <tnh@alpsmap.co.jp>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" 2003-11-15, aeb, added tmpnam_r
25 .\"
26 .\" Japanese Version Copyright (c) 1997 Tenkou N. Hattori
27 .\"       all rights reserved.
28 .\" Translated 1997-01-18, Tenkou N. Hattori <tnh@alpsmap.co.jp>
29 .\" Updated 2000-03-15, Kentaro Shirakata <argrath@yo.rim.or.jp>
30 .\" Updated 2005-03-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .\" Updated 2006-07-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
32 .\"
33 .TH TMPNAM 3  2008-08-06 "" "Linux Programmer's Manual"
34 .\"O .SH NAME
35 .SH Ì¾Á°
36 .\"O tmpnam, tmpnam_r \- create a name for a temporary file
37 tmpnam, tmpnam_r \- °ì»þ¥Õ¥¡¥¤¥ë¤Î̾Á°¤òºîÀ®¤¹¤ë
38 .\"O .SH SYNOPSIS
39 .SH ½ñ¼°
40 .nf
41 .B #include <stdio.h>
42 .sp
43 .BI "char *tmpnam(char *" s );
44 .fi
45 .\"O .SH DESCRIPTION
46 .SH ÀâÌÀ
47 .\"O The
48 .\"O .BR tmpnam ()
49 .\"O function returns a pointer to a string that is a valid filename,
50 .\"O and such that a file with this name did not exist at some point
51 .\"O in time, so that naive programmers may think it
52 .\"O a suitable name for a temporary file.
53 .\"O If the argument
54 .\"O .I s
55 .\"O is NULL this name is generated in an internal static buffer
56 .\"O and may be overwritten by the next call to
57 .\"O .BR tmpnam ().
58 .BR tmpnam ()
59 ´Ø¿ô¤Ï¡¢¥Õ¥¡¥¤¥ë̾¤Ë»È¤¨¤ëʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
60 ¤¢¤ë»þÅÀ¤Ç¤ÏƱ¤¸Ì¾Á°¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¥Õ¥¡¥¤¥ë̾¤¬ÊÖ¤µ¤ì¤ë¤Î¤Ç¡¢
61 ÍÄÃÕ¤Ê¥×¥í¥°¥é¥Þ¤Ï¤³¤Îʸ»úÎ󤬰ì»þ¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ë̾¤È¤·¤Æ
62 Ŭ¤·¤Æ¤¤¤ë¤È¹Í¤¨¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
63 °ú¤­¿ô
64 .I s
65 ¤¬ NULL ¤Ê¤é¡¢¤³¤Î̾Á°¤ÏÆâÉô¤ÎÀÅŪ¥Ð¥Ã¥Õ¥¡¤ËºîÀ®¤µ¤ì¡¢
66 ¼¡¤Ë
67 .BR tmpnam ()
68 ´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿»þ¤Ë¾å½ñ¤­¤µ¤ì¤ë¡£
69 .\"O If
70 .\"O .I s
71 .\"O is not NULL, the name is copied to the character array (of length
72 .\"O at least
73 .\"O .IR L_tmpnam )
74 .\"O pointed to by
75 .\"O .I s
76 .\"O and the value
77 .\"O .I s
78 .\"O is returned in case of success.
79 .I s
80 ¤¬ NULL ¤Ç¤Ê¤±¤ì¤Ð¡¢¥Õ¥¡¥¤¥ë̾¤Ï
81 .I s
82 ¤¬»Ø¤¹ (¾¯¤Ê¤¯¤È¤â
83 .I L_tmpnam
84 ¤ÎŤµ¤ò»ý¤Ä) Ê¸»úÇÛÎó¤Ë¥³¥Ô¡¼¤µ¤ì¡¢
85 À®¸ù¤·¤¿¾ì¹ç¤Ï
86 .I s
87 ¤¬ÊÖ¤µ¤ì¤ë¡£
88 .LP
89 .\"O The pathname that is created, has a directory prefix
90 .\"O .IR P_tmpdir .
91 ºîÀ®¤µ¤ì¤ë¥Ñ¥¹Ì¾¤Ï¡¢¥Ç¥£¥ì¥¯¥È¥ê¤ÎÉôʬ¤Ë
92 .I P_tmpdir
93 ¤¬»È¤ï¤ì¤ë¡£
94 .\"O (Both
95 .\"O .I L_tmpnam
96 .\"O and
97 .\"O .I P_tmpdir
98 .\"O are defined in
99 .\"O .IR <stdio.h> ,
100 .\"O just like the
101 .\"O .B TMP_MAX
102 .\"O mentioned below.)
103 .RI ( L_tmpnam
104 ¤È
105 .I P_tmpdir
106 ¤Ï¡¢°Ê²¼¤ÇÀâÌÀ¤¹¤ë
107 .B TMP_MAX
108 ƱÍÍ
109 .I <stdio.h>
110 ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£)
111 .\"O .SH "RETURN VALUE"
112 .SH ÊÖ¤êÃÍ
113 .\"O The
114 .\"O .BR tmpnam ()
115 .\"O function returns a pointer to a unique temporary
116 .\"O filename, or NULL if a unique name cannot be generated.
117 .BR tmpnam ()
118 ´Ø¿ô¤Ï°ì°Õ¤Ê°ì»þ¥Õ¥¡¥¤¥ë̾¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
119 °ì°Õ¤Ê¥Õ¥¡¥¤¥ë̾¤¬ºîÀ®¤Ç¤­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
120 .SH ¥¨¥é¡¼
121 .\"O No errors are defined.
122 ¥¨¥é¡¼¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
123 .\"O .SH "CONFORMING TO"
124 .SH ½àµò
125 SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
126 .\"O POSIX.1-2008 marks
127 .\"O .BR tmpnam ()
128 .\"O as obsolete.
129 POSIX.1-2008 ¤Ï
130 .BR tmpnam ()
131 ¤òÇÑ»ßͽÄê¤È¤·¤Æ¤¤¤ë¡£
132 .\"O .SH NOTES
133 .SH Ãí°Õ
134 .\"O The
135 .\"O .BR tmpnam ()
136 .\"O function generates a different string each time it is called,
137 .\"O up to
138 .\"O .B TMP_MAX
139 .\"O times.
140 .\"O If it is called more than
141 .\"O .B TMP_MAX
142 .\"O times,
143 .\"O the behavior is implementation defined.
144 .BR tmpnam ()
145 ´Ø¿ô¤ÏºÇÂç
146 .B TMP_MAX
147 ²ó¤Þ¤Ç¡¢¸Æ¤Ó½Ð¤µ¤ì¤ëÅ٤˰ۤʤëʸ»úÎó¤òºîÀ®¤¹¤ë¡£
148 .B TMP_MAX
149 ²ó°Ê¾å¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢¤½¤ÎÆ°ºî¤Ï¼ÂÁõ°Í¸¤Ç¤¢¤ë¡£
150 .LP
151 .\"O Although
152 .\"O .BR tmpnam ()
153 .\"O generates names that are difficult to guess,
154 .\"O it is nevertheless possible that between the time that
155 .\"O .BR tmpnam ()
156 .\"O returns a pathname, and the time that the program opens it,
157 .\"O another program might create that pathname using
158 .\"O .BR open (2),
159 .\"O or create it as a symbolic link.
160 .\"O This can lead to security holes.
161 .\"O To avoid such possibilities, use the
162 .\"O .BR open (2)
163 .\"O .B O_EXCL
164 .\"O flag to open the pathname.
165 .\"O Or better yet, use
166 .\"O .BR mkstemp (3)
167 .\"O or
168 .\"O .BR tmpfile (3).
169 .BR tmpnam ()
170 ¤Ï¿ä¬¤¬Æñ¤·¤¤Ì¾Á°¤òÀ¸À®¤¹¤ë¤¬¡¢¤½¤ì¤Ë¤â¤«¤«¤ï¤é¤º¡¢
171 .BR tmpnam ()
172 ¤¬¥Ñ¥¹Ì¾¤òÊÖ¤·¤Æ¤«¤é¡¢¥×¥í¥°¥é¥à¤¬¤½¤Î¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ë
173 ¤Þ¤Ç¤Î´Ö¤Ë¡¢ÊÌ¤Î¥×¥í¥°¥é¥à¤¬Æ±¤¸¥Ñ¥¹Ì¾¤Ç¡¢¥Õ¥¡¥¤¥ë¤ò
174 .BR open (2)
175 ¤ÇºîÀ®¤·¤¿¤ê¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤òºîÀ®¤·¤¿¤ê¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
176 ¤³¤ì¤Ï¥»¥­¥å¥ê¥Æ¥£¥Û¡¼¥ë¤Ë¤Ä¤Ê¤¬¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
177 ¤½¤Î¤è¤¦¤Ê²ÄǽÀ­¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¤Ï¡¢
178 .BR open (2)
179 ¤Î
180 .B O_EXCL
181 ¥Õ¥é¥°¤ò»È¤Ã¤Æ¥Ñ¥¹Ì¾¤ò¥ª¡¼¥×¥ó¤¹¤ì¤Ð¤è¤¤¡£
182 ¤â¤Ã¤È¤¤¤¤¤Î¤Ï¡¢
183 .BR mkstemp (3)
184 ¤ä
185 .BR tmpfile (3)
186 ¤ò»È¤¦¤³¤È¤Ç¤¢¤ë¡£
187 .LP
188 .\"O Portable applications that use threads cannot call
189 .\"O .BR tmpnam ()
190 .\"O with a NULL parameter if either
191 .\"O .B _POSIX_THREADS
192 .\"O or
193 .\"O .B _POSIX_THREAD_SAFE_FUNCTIONS
194 .\"O is defined.
195 °Ü¿¢À­¤¬É¬Íפʡ¢¥¹¥ì¥Ã¥É¤ò»È¤Ã¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢
196 .B _POSIX_THREADS
197 ¤«
198 .B _POSIX_THREAD_SAFE_FUNCTIONS
199 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¡¢
200 .BR tmpnam ()
201 ´Ø¿ô¤ò NULL °ú¤­¿ô¤Ç¸Æ¤Ó½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
202 .LP
203 .\"O A POSIX draft proposed to use a function
204 .\"O .BR tmpnam_r ()
205 .\"O defined by
206 .\"O .sp
207 .\"O .nf
208 .\"O .in +4n
209 .\"O char *tmpnam_r(char *s) {
210 .\"O     return s ? tmpnam(s) : NULL;
211 .\"O }
212 .\"O .in
213 .\"O .fi
214 .\"O .sp
215 .\"O apparently as a warning not to use NULL.
216 POSIX Áð°Æ¤Ç¤Ï¡¢´Ø¿ô
217 .BR tmpnam_r ()
218 ¤ò»È¤¦¤³¤È¤òÄó°Æ¤·¤Æ¤¤¤ë¡£
219 ¤³¤Î´Ø¿ô¤Ï¡¢°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤ª¤ê¡¢
220 NULL ¤ò»È¤ï¤Ê¤¤¤è¤¦¤Ë¤È¤¤¤¦·Ù¹ð¤Î°ÕÌ£¤Ç NULL ¤òÊÌ°·¤¤¤·¤Æ¤¤¤ë¡£
221 .sp
222 .nf
223 .in +4n
224 char *
225 tmpnam_r(char *s)
226 {
227     return s ? tmpnam(s) : NULL;
228 }
229 .in
230 .fi
231 .sp
232 .\"O A few systems implement it.
233 .\"O To get a glibc prototype for this function,
234 .\"O define
235 .\"O .B _SVID_SOURCE
236 .\"O or
237 .\"O .B _BSD_SOURCE
238 .\"O before including
239 .\"O .IR <stdio.h> .
240 ¿ô¤Ï¾¯¤Ê¤¤¤¬¡¢¤³¤Î´Ø¿ô¤ò¼ÂÁõ¤·¤Æ¤¤¤ë¥·¥¹¥Æ¥à¤â¤¢¤ë¡£
241 ¤³¤Î´Ø¿ô¤Î glibc ¤Î¥×¥í¥È¥¿¥¤¥×¤ò»È¤¦¤Ë¤Ï¡¢
242 .I <stdio.h>
243 ¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ëÁ°¤Ë
244 .B _SVID_SOURCE
245 ¤«
246 .B _BSD_SOURCE
247 ¤òÄêµÁ¤·¤Æ¤ª¤¯É¬Íפ¬¤¢¤ë¡£
248 .\"O .SH BUGS
249 .SH ¥Ð¥°
250 .\"O Never use this function.
251 .\"O Use
252 .\"O .BR mkstemp (3)
253 .\"O or
254 .\"O .BR tmpfile (3)
255 .\"O instead.
256 ·è¤·¤Æ¤³¤Î´Ø¿ô¤ò»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£Âå¤ï¤ê¤Ë
257 .BR mkstemp (3)
258 ¤«
259 .BR tmpfile (3)
260 ¤ò»È¤¦¤³¤È¡£
261 .\"O .SH "SEE ALSO"
262 .SH ´ØÏ¢¹àÌÜ
263 .BR mkstemp (3),
264 .BR mktemp (3),
265 .BR tempnam (3),
266 .BR tmpfile (3)