Annotation of 43BSDReno/lib/libc/stdlib/getenv.3, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1988 The Regents of the University of California.
                      2: .\" All rights reserved.
                      3: .\"
                      4: .\" Redistribution and use in source and binary forms are permitted
                      5: .\" provided that: (1) source distributions retain this entire copyright
                      6: .\" notice and comment, and (2) distributions including binaries display
                      7: .\" the following acknowledgement:  ``This product includes software
                      8: .\" developed by the University of California, Berkeley and its contributors''
                      9: .\" in the documentation or other materials provided with the distribution
                     10: .\" and in all advertising materials mentioning features or use of this
                     11: .\" software. Neither the name of the University nor the names of its
                     12: .\" contributors may be used to endorse or promote products derived
                     13: .\" from this software without specific prior written permission.
                     14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     15: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     16: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     17: .\"
                     18: .\"    @(#)getenv.3    6.9 (Berkeley) 5/17/90
                     19: .\"
                     20: .TH GETENV 3 "May 17, 1990"
                     21: .AT 3
                     22: .SH NAME
                     23: getenv, putenv, setenv, unsetenv \- manipulate environmental variables
                     24: .SH SYNOPSIS
                     25: .nf
                     26: .ft B
                     27: #include <stdlib.h>
                     28: 
                     29: char *
                     30: getenv(const char *name);
                     31: 
                     32: setenv(const char *name, const char *value, int overwrite);
                     33: 
                     34: putenv(const char *string);
                     35: 
                     36: void
                     37: unsetenv(const char *name);
                     38: .ft R
                     39: .fi
                     40: .SH DESCRIPTION
                     41: .I Getenv
                     42: searches the environment list (see
                     43: .IR environ (7))
                     44: for a string of the form \fIname\fP\fB=\fP\fIvalue\fP and returns
                     45: a pointer to the string
                     46: .I value
                     47: if such a string is present, and a NULL pointer if it is not.
                     48: .PP
                     49: .I Setenv
                     50: searches the environment list as
                     51: .I getenv
                     52: does; if the string
                     53: .I name
                     54: is not found, a string of the form \fIname\fP\fB=\fP\fIvalue\fP is
                     55: added to the environment.
                     56: If it is found, and
                     57: .I overwrite
                     58: is non-zero, its value is changed to
                     59: .IR value .
                     60: .I Setenv
                     61: returns 0 on success and -1 on failure, setting the external variable
                     62: .IR errno .
                     63: .PP
                     64: .I Putenv
                     65: takes an argument of the form ``\fIname\fR=\fIvalue\fR'' and is the
                     66: equivalent of:
                     67: .sp
                     68: .RS
                     69: setenv(name, value, 1);
                     70: .RE
                     71: .PP
                     72: .I Unsetenv
                     73: removes all occurrences of the string
                     74: .I name
                     75: from the environment.
                     76: There is no library provision for completely removing the current
                     77: environment.
                     78: It is suggested that the following code be used to do so.
                     79: .sp
                     80: .RS
                     81: .nf
                     82: static char    *envinit[1];
                     83: extern char    **environ;
                     84: environ = envinit;
                     85: .fi
                     86: .RE
                     87: .PP
                     88: All of these routines permit, but do not require, a trailing equals
                     89: (``='') sign on
                     90: .I name
                     91: or a leading equals sign on
                     92: .IR value .
                     93: .SH ERRORS
                     94: .TP
                     95: [ENOMEM]
                     96: .I Setenv
                     97: or
                     98: .I putenv
                     99: failed because they were unable to allocate memory for the environment.
                    100: .SH SEE ALSO
                    101: csh(1), sh(1), execve(2), environ(7)
                    102: .SH STANDARDS
                    103: .B Getenv
                    104: conforms to ANSI X3.159-1989 (``ANSI C'').

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.