2 Copyright © 2012-2013, The AROS Development Team. All rights reserved.
5 Desc: AROS specific function for environ emulation handling
8 #include <proto/exec.h>
12 #include "__posixc_intbase.h"
18 #include <aros/debug.h>
20 /*****************************************************************************
25 int __posixc_set_environptr (
31 This function is called to enable environ emulation mode.
34 environptr - ptr to the child environ variable (== &environ).
37 0 on fail, other value on succes
40 This function will enable environ emulation. This means that
41 all current DOS local variables are converted to the 'var=value'
42 format and be accessible through char **environ.
47 At the moment only a static list is supported. getenv() and setenv()
48 don't use this yet so changes done with these functions are not
53 __posixc_get_environptr(), getenv(), setenv()
57 ******************************************************************************/
59 struct PosixCIntBase
*PosixCBase
=
60 (struct PosixCIntBase
*)__aros_getbase_PosixCBase();
63 D(bug("Initializing POSIX environ emulation\n"));
65 PosixCBase
->environptr
= environptr
;
67 len
= __env_get_environ(NULL
, 0);
68 *environptr
= malloc(len
);
69 return (__env_get_environ(*environptr
, len
) >= 0);
72 /*****************************************************************************
77 char ***__posixc_get_environptr (
83 This function the get pointer to the child environ global variable
84 currently used by posixc.library.
90 environptr - ptr to the child environ variable (== &environ).
91 NULL is return if envirion emulation is disabled.
100 __posixc_set_environptr()
104 ******************************************************************************/
106 struct PosixCIntBase
*PosixCBase
=
107 (struct PosixCIntBase
*)__aros_getbase_PosixCBase();
109 return PosixCBase
->environptr
;