1
0
Files
irix-657m-src/eoe/man/man3c/putenv.3c
2022-09-29 17:59:04 +03:00

78 lines
1.9 KiB
Plaintext

'\"macro stdmacro
.if n .pH g3c.putenv @(#)putenv 40.11 of 5/22/91
.\" Copyright 1991 UNIX System Laboratories, Inc.
.\" Copyright 1989, 1990 AT&T
.nr X
.if \nX=0 .ds x} putenv 3C "C Development Set" "\&"
.if \nX=1 .ds x} putenv 3C "C Development Set"
.if \nX=2 .ds x} putenv 3C "" "\&"
.if \nX=3 .ds x} putenv "" "" "\&"
.TH \*(x}
.SH NAME
\f4putenv\f1 \- change or add value to environment
.SH SYNOPSIS
\f4#include <stdlib.h>\f1
.PP
\f4int putenv (char \(**string);\f1
.SH DESCRIPTION
.I string\^
points to a string of the form
\f2``name\f4=\f2value.''\f1
\f4putenv\fP
makes the value of the environment variable
.I name\^
equal to
.I value\^
by altering an existing variable or creating a new one.
In either case, the string pointed to by
.I string\^
becomes part of the
environment, so altering the string will change the environment.
The space used by
.I string\^
is no longer used once a new string-defining
.I name\^
is passed to
\f4putenv\fP.
Because of this limitation,
.I string
should be declared static if it is declared
within a function.
.SH SEE ALSO
\f4exec\fP(2), \f4getenv\fP(3C), \f4malloc\fP(3C), \f4environ\fP(5).
.SH DIAGNOSTICS
\f4putenv\fP
returns non-zero
if it was unable to obtain enough space
via
\f4malloc\fP
for an expanded environment,
otherwise zero.
.SH WARNINGS
\f4putenv\fP
manipulates the environment pointed to by
\f2environ\f4,\f1
and can be used in conjunction with
\f4getenv\f1.
However,
.I envp
(the third argument to
.IR main )
is not changed.
.sp .2
This routine uses
\f4malloc\fP(3C)
to enlarge the environment.
.sp .2
After
\f4putenv\fP
is called, environmental variables are not in
alphabetical order.
.pp
A potential error is to call the function \f4putenv\f1
with a pointer to an automatic variable as the argument and to
then exit the calling function while \f2string\fP is still part of the
environment.
.\" @(#)putenv.3c 6.4 of 4/2/84
.Ee