1GETENV(3) 386BSD Programmer's Manual GETENV(3) 2 3NNAAMMEE 4 ggeetteennvv, ppuutteennvv, sseetteennvv, uunnsseetteennvv - environment variable functions 5 6SSYYNNOOPPSSIISS 7 ##iinncclluuddee <<ssttddlliibb..hh>> 8 9 _c_h_a_r * 10 ggeetteennvv(_c_o_n_s_t _c_h_a_r *_n_a_m_e) 11 12 _i_n_t 13 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) 14 15 _i_n_t 16 ppuutteennvv(_c_o_n_s_t _c_h_a_r *_s_t_r_i_n_g) 17 18 _v_o_i_d 19 uunnsseetteennvv(_c_o_n_s_t _c_h_a_r *_n_a_m_e) 20 21DDEESSCCRRIIPPTTIIOONN 22 These functions set, unset and fetch environment variables from the host 23 _e_n_v_i_r_o_n_m_e_n_t _l_i_s_t. For compatibility with differing environment 24 conventions, the given arguments _n_a_m_e and _v_a_l_u_e may be appended and 25 prepended, respectively, with an equal sign ``=''. 26 27 The ggeetteennvv() function obtains the current value of the environment 28 variable, _n_a_m_e. If the variable _n_a_m_e is not in the current environment , 29 a null pointer is returned. 30 31 The sseetteennvv() function inserts or resets the environment variable _n_a_m_e in 32 the current environment list. If the variable _n_a_m_e does not exist in the 33 list, it is inserted with the given _v_a_l_u_e. If the variable does exist, 34 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 35 not reset, otherwise it is reset to the given _v_a_l_u_e. 36 37 The ppuutteennvv() function performs the equivalent of: 38 39 setenv(name, value, 1); 40 41 The uunnsseetteennvv() function deletes all instances of the variable name 42 pointed to by _n_a_m_e from the list. 43 44RREETTUURRNN VVAALLUUEESS 45 The functions sseetteennvv() and ppuutteennvv() return zero if successful; otherwise 46 the global variable _e_r_r_n_o is set to indicate the error and a -1 is 47 returned. 48 49EERRRROORRSS 50 [ENOMEM] The function sseetteennvv() or ppuutteennvv() failed because they were 51 unable to allocate memory for the environment. 52 53SSEEEE AALLSSOO 54 csh(1), sh(1), execve(2), environ(7) 55 56SSTTAANNDDAARRDDSS 57 The ggeetteennvv() function conforms to ANSI C3.159-1989 (``ANSI C''). 58 59HHIISSTTOORRYY 60 The functions sseetteennvv() and uunnsseetteennvv() appeared in Version 7 AT&T UNIX. 61 The ppuutteennvv() function appeared in 4.3BSD-Reno. 62 63BSD Experimental June 29, 1991 1 64 65 66 67