aboutsummaryrefslogblamecommitdiff
path: root/ja_JP.eucJP/man/man3/getenv.3
blob: ff9e5edd9ee62365943f5d41ae229df6267fa56a (plain) (tree)




































                                                                              
             








































































































                                                                      
.\" Copyright (c) 1988, 1991, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the American National Standards Committee X3, on Information
.\" Processing Systems.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     @(#)getenv.3	8.2 (Berkeley) 12/11/93
.\"
.\" $FreeBSD$
.Dd December 11, 1993
.Dt GETENV 3
.Os
.Sh 名称
.Nm getenv ,
.Nm putenv ,
.Nm setenv ,
.Nm unsetenv
.Nd 環境変数関数
.Sh 書式
.Fd #include <stdlib.h>
.Ft char *
.Fn getenv "const char *name"
.Ft int
.Fn setenv "const char *name" "const char *value" "int overwrite"
.Ft int
.Fn putenv "const char *string"
.Ft void
.Fn unsetenv "const char *name"
.Sh 解説
これらの関数は環境変数を設定し、設定を解除し、ホストの
.Em environment list
からそれらを取り出します。異なる環境規定との互換性を得るため、与えられ
た引数
.Ar name
および
.Ar value
はそれぞれ、等価記号
.Dq Li \&= .
によって後に付加することも、前に付加することもできます。 
.Pp
.Fn getenv
関数は、環境変数
.Ar name
の現在の値を取得します。変数
.Ar name
が現在の
環境にない場合は、null ポインタが返ります。
.Pp
.Fn setenv
関数は環境変数
.Ar name
を現在の環境リストに挿入またはリセットします。変数
.Ar name
がリストにない場合は、与えられた
.Ar value
によって挿入されます。変数が存在する場合は引数
.Ar overwrite
がテストされ、
.Ar overwrite
がゼロならば変数
.Ar name
は上書きされず、その他の場合は与えられた値に再設定されます。
.Pp
.Fn putenv
関数は ``name=value'' の形で引数をとります。これは次と等価です。
.Bd -literal -offset indent 
setenv(name, value, 1);
.Ed
.Pp
.Fn unsetenv
関数は
.Fa name
で示される変数名のインスタンスを、リストからすべて削除します。
.Sh 戻り値
関数
.Fn setenv
および
.Fn putenv
は、成功するとゼロを返します。その他の場合は、エラーを示すためにグロー
バル変数 
.Va errno
が設定され、
\-1 が返ります。
.Sh エラー
.Bl -tag -width [ENOMEM]
.It Bq Er ENOMEM
環境にメモリを割り振ることができなかったので、関数
.Fn setenv
または
.Fn putenv
は失敗しました。
.El
.Sh 関連項目
.Xr csh 1 ,
.Xr sh 1 ,
.Xr execve 2 ,
.Xr environ 7
.Sh 規格
.Fn getenv
関数は、
.St -ansiC
に準拠しています。
.Sh 歴史
関数
.Fn setenv
および
.Fn unsetenv
は、
.At v7
で最初に登場しました。
.Fn putenv
関数は、
.Bx 4.3 Reno
で最初に登場しました。