GETENV(3) BSD Programmer's Manual GETENV(3) NNAAMMEE ggeetteennvv, ppuutteennvv, sseetteennvv, uunnsseetteennvv - environment variable functions SSYYNNOOPPSSIISS ##iinncclluuddee <<ssttddlliibb..hh>> _c_h_a_r _* ggeetteennvv(_c_o_n_s_t _c_h_a_r _*_n_a_m_e); _i_n_t sseetteennvv(_c_o_n_s_t _c_h_a_r _*_n_a_m_e, _c_o_n_s_t _c_h_a_r _*_v_a_l_u_e, _i_n_t _o_v_e_r_w_r_i_t_e); _i_n_t ppuutteennvv(_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g); _v_o_i_d uunnsseetteennvv(_c_o_n_s_t _c_h_a_r _*_n_a_m_e); DDEESSCCRRIIPPTTIIOONN These functions set, unset and fetch environment variables from the host _e_n_v_i_r_o_n_m_e_n_t _l_i_s_t. For compatibility with differing environment conven- tions, the given arguments _n_a_m_e and _v_a_l_u_e may be appended and prepended, respectively, with an equal sign ``=''. The ggeetteennvv() function obtains the current value of the environment vari- able, _n_a_m_e. If the variable _n_a_m_e is not in the current environment , a null pointer is returned. The sseetteennvv() function inserts or resets the environment variable _n_a_m_e in the current environment list. If the variable _n_a_m_e does not exist in the list, it is inserted with the given _v_a_l_u_e_. If the variable does exist, the argument _o_v_e_r_w_r_i_t_e is tested; if _o_v_e_r_w_r_i_t_e _i_s zero, the variable is not reset, otherwise it is reset to the given _v_a_l_u_e. The ppuutteennvv() function takes an argument of the form ``name=value'' and is equivalent to: setenv(name, value, 1); The uunnsseetteennvv() function deletes all instances of the variable name point- ed to by _n_a_m_e from the list. RREETTUURRNN VVAALLUUEESS The functions sseetteennvv() and ppuutteennvv() return zero if successful; otherwise the global variable _e_r_r_n_o is set to indicate the error and a -1 is re- turned. EERRRROORRSS [ENOMEM] The function sseetteennvv() or ppuutteennvv() failed because they were un- able to allocate memory for the environment. SSEEEE AALLSSOO csh(1), sh(1), execve(2), environ(7) SSTTAANNDDAARRDDSS The ggeetteennvv() function conforms to ANSI C X3.159-1989 (``ANSI C ''). HHIISSTTOORRYY The functions sseetteennvv() and uunnsseetteennvv() appeared in Version 7 AT&T UNIX. The ppuutteennvv() function appeared in 4.3BSD-Reno. 4.4BSD June 4, 1993 1