OSDN Git Service

(split) LDP: Update draft and release (from the previous commit)
[linuxjm/LDP_man-pages.git] / release / man3 / setenv.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2004, 2007 Michael kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" References consulted:
27 .\"     Linux libc source code
28 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\"     386BSD man pages
30 .\" Modified Sat Jul 24 18:20:58 1993 by Rik Faith (faith@cs.unc.edu)
31 .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl)
32 .\" Modified 9 Jun 2004, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\"     Changed unsetenv() prototype; added EINVAL error
34 .\"     Noted nonstandard behavior of setenv() if name contains '='
35 .\" 2005-08-12, mtk, glibc 2.3.4 fixed the "name contains '='" bug
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" This file was generated with po4a. Translate the source file.
40 .\"
41 .\"*******************************************************************
42 .\"
43 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
44 .\"     all rights reserved.
45 .\" Translated 1997-12-19, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
46 .\" Updated & Modified 2005-02-17, Yuichi SATO <ysato444@yahoo.co.jp>
47 .\" Updated & Modified 2005-10-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
48 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
49 .\" Updated 2010-04-10, Akihiro MOTOKI, LDP v3.24
50 .\"
51 .TH SETENV 3 2013\-10\-11 GNU "Linux Programmer's Manual"
52 .SH 名前
53 setenv \- 環境変数を変更または追加する
54 .SH 書式
55 .nf
56 \fB#include <stdlib.h>\fP
57 .sp
58 \fBint setenv(const char *\fP\fIname\fP\fB, const char *\fP\fIvalue\fP\fB, int \fP\fIoverwrite\fP\fB);\fP
59 .sp
60 \fBint unsetenv(const char *\fP\fIname\fP\fB);\fP
61 .fi
62 .sp
63 .in -4n
64 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
65 .in
66 .sp
67 .ad l
68 \fBsetenv\fP(), \fBunsetenv\fP():
69 .RS 4
70 _BSD_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
71 .RE
72 .ad b
73 .SH 説明
74 The \fBsetenv\fP()  function adds the variable \fIname\fP to the environment with
75 the value \fIvalue\fP, if \fIname\fP does not already exist.  If \fIname\fP does
76 exist in the environment, then its value is changed to \fIvalue\fP if
77 \fIoverwrite\fP is nonzero; if \fIoverwrite\fP is zero, then the value of \fIname\fP
78 is not changed (and \fBsetenv\fP()  returns a success status).  This function
79 makes copies of the strings pointed to by \fIname\fP and \fIvalue\fP (by contrast
80 with \fBputenv\fP(3)).
81 .PP
82 \fBunsetenv\fP()  関数は、変数 \fIname\fP を環境から削除する。 \fIname\fP
83 が環境にない場合、この関数は成功し、環境は変更されない。
84 .SH 返り値
85 \fBsetenv\fP()  関数は、成功すると 0 を返す。 エラーの場合、\-1 を返し、 \fIerrno\fP にエラーの原因を示す値がセットされる。
86
87 \fBunsetenv\fP()  関数は、成功すると 0 を返す。 エラーの場合は \-1 を返し、 \fIerrno\fP を設定してエラーの原因を示す。
88 .SH エラー
89 .TP 
90 \fBEINVAL\fP
91 \fIname\fP が NULL であるか、長さが 0 の文字列を指しているか、 \(aq=\(aq 文字が含まれている。
92 .TP 
93 \fBENOMEM\fP
94 環境に新しい変数を追加するのに十分なメモリがない。
95 .SH 準拠
96 4.3BSD, POSIX.1\-2001.
97 .SH 注意
98 POSIX.1\-2001 は、 \fBsetenv\fP()  や \fBunsetenv\fP()  がリエントラント (再入可能) であることを要求していない。
99
100 glibc 2.2.2 以前では、 \fBunsetenv\fP()  は 返り値が \fIvoid\fP のプロトタイプであった。 もっと最近の glibc
101 版は、「書式」セクションで示しているように POSIX.1\-2001 互換のプロトタイプである。
102 .SH バグ
103 POSIX.1\-2001 では 「\fIname\fP に \(aq=\(aq 文字が含まれる場合、 \fBsetenv\fP()  はエラー \fBEINVAL\fP
104 で失敗すべきである」と述べられている。 しかし 2.3.4 より前のバージョンの glibc では、 \fIname\fP に \(aq=\(aq
105 文字が含まれるのを許している。
106 .SH 関連項目
107 \fBclearenv\fP(3), \fBgetenv\fP(3), \fBputenv\fP(3), \fBenviron\fP(7)
108 .SH この文書について
109 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.63 の一部
110 である。プロジェクトの説明とバグ報告に関する情報は
111 http://www.kernel.org/doc/man\-pages/ に書かれている。