OSDN Git Service

1e0703a514f5e311b8e2009001ad35bfca5543ef
[linuxjm/LDP_man-pages.git] / release / man3 / mktemp.3
1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sat Jul 24 18:48:06 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Fri Jun 23 01:26:34 1995 by Andries Brouwer (aeb@cwi.nl)
29 .\" (prompted by Scott Burkett <scottb@IntNet.net>)
30 .\" Modified Sun Mar 28 23:44:38 1999 by Andries Brouwer (aeb@cwi.nl)
31 .\"
32 .\" Japanese Version Copyright (c) 1997 Kazuyuki Tanisako
33 .\"         all rights reserved.
34 .\" Translated Sat Apr 10 02:12:40 JST 1999
35 .\"         by Kazuyuki Tanisako <tanisako@osa.dec.com>
36 .\"
37 .\"WORD:        temporary file          テンポラリファイル
38 .\"WORD:        filename                ファイル名
39 .\"WORD:        pointer                 ポインター
40 .\"WORD:        function                関数
41 .\"
42 .TH MKTEMP 3  2010-09-20 "GNU" "Linux Programmer's Manual"
43 .SH 名前
44 mktemp \- 他と重ならないテンポラリファイル名を作成する
45 .SH 書式
46 .nf
47 .B #include <stdlib.h>
48 .sp
49 .BI "char *mktemp(char *" template );
50 .fi
51 .sp
52 .in -4n
53 glibc 向けの機能検査マクロの要件
54 .RB ( feature_test_macros (7)
55 参照):
56 .in
57 .sp
58 .BR mktemp ():
59 .ad l
60 .PD 0
61 .RS 4
62 .TP 4
63 glibc 2.12 以降:
64 _BSD_SOURCE || _SVID_SOURCE ||
65     (_XOPEN_SOURCE\ >=\ 500 ||
66          _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
67     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
68 .TP
69 glibc 2.12 より前:
70 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
71 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
72 .RE
73 .PD
74 .ad b
75 \"O .SH DESCRIPTION
76 .SH 説明
77 関数
78 .BR mktemp ()
79 は引数 \fItemplate\fP から他と重ならない
80 テンポラリファイル名を作成する。引数 \fItemplate\fP で指示する文字配列
81 の後6文字は XXXXXX である必要がある。この部分がファイル名を他と
82 重ならないにするような文字で置き換えられる。
83 .I template
84 は書き換えられるため、文字列定数ではなく文字配列として宣言するように
85 しなければならない。
86 .SH 返り値
87 関数
88 .BR mktemp ()
89 は常に \fItemplate\fP を戻す。
90 一意な名前が作成された場合、
91 \fItemplate\fP の最後の 6 バイトに
92 他と重ならない名前 (それまでに出ていない名前) になるような値が格納される。
93 一意な名前が作成できなかった場合には、
94 \fItemplate\fP には空文字列がセットされる。
95 .SH エラー
96 .TP
97 .B EINVAL
98 引数 \fItemplate\fP で指示された文字列の後6文字が XXXXXX でない。
99 .SH 準拠
100 4.3BSD, POSIX.1-2001.
101 POSIX.1-2008 では
102 .BR mktemp ()
103 の仕様が削除されている。
104 .SH 注意
105 libc4, libc5, glibc1 でのプロトタイプ宣言は
106 .I <unistd.h>
107 に含まれる; glibc2 では Single UNIX Specification に従って
108 .I <stdlib.h>
109 に含まれている。
110 .SH バグ
111 .BR mktemp ()
112 を決して使わないこと。4.3BSD 系の実装や XXXXXX を
113 プロセス ID と1文字により置き換える方式ではせいぜい26の名前を返す
114 ことができるにすぎない。
115 この名前は簡単に推測できることや、その名前がすでに存在しているかどうか
116 テストして、そのファイルをオープンする間に競合がある事から、
117 .BR mktemp ()
118 を使うのは毎回セキュリティリスクをおかすことになる。
119 この競合は
120 .BR mkstemp (3)
121 を使うことで避けられる。
122 .SH 関連項目
123 .BR mkstemp (3),
124 .BR tempnam (3),
125 .BR tmpfile (3),
126 .BR tmpnam (3)