2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
8 #include <proto/exec.h>
13 /*****************************************************************************
24 Get an environment variable.
27 name - Name of the environment variable.
30 Pointer to the variable's value, or NULL on failure.
33 The returned contents of the environment variable is cached per
34 PosixCBase and per variable name. So the returned value is valid
35 and does not change until a next call to getenv with the same
36 PosixCBase and the same name.
45 Based on libnix getenv
47 ******************************************************************************/
49 __env_item
*var
= NULL
;
53 This will always return 0 if the var exists and EOF if it doesn't,
54 then we'll be able to retrieve the var length with IoErr()
56 if (!GetVar((char *)name
, &c
, 1, GVF_BINARY_VAR
))
60 var
= __env_getvar(name
, len
+1); /* size == len + null-byte. */
64 /* This should not fail, unless someone stole our variable */
65 /* FIXME: maybe this function should be atomic? */
66 GetVar((char *)name
, var
->value
, len
+1, GVF_BINARY_VAR
);
70 return (var
?var
->value
:NULL
);