Upgraded GRUB2 to 2.00 release.
[AROS.git] / compiler / clib / __arosc_set_environptr.c
blob1ad578b05c2365fbc3274dcac0c2d2ad902eae5e
1 /*
2 Copyright © 2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: AROS specific function for environ emulation handling
6 */
8 #include <proto/exec.h>
9 #include <proto/dos.h>
10 #include <dos/dos.h>
12 #include "__arosc_privdata.h"
13 #include "__env.h"
15 #include <stdio.h>
17 #define DEBUG 0
18 #include <aros/debug.h>
20 /*****************************************************************************
22 NAME */
23 #include <stdlib.h>
25 void __arosc_set_environptr (
27 /* SYNOPSIS */
28 char ***environptr)
30 /* FUNCTION
31 This function is called to enable environ emulation mode.
33 INPUTS
34 environptr - ptr to the child environ variable (== &environ).
36 RESULT
39 NOTES
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.
44 EXAMPLE
46 BUGS
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
49 reflected in environ.
50 This is still TODO.
52 SEE ALSO
53 getenv(), setenv()
55 INTERNALS
57 ******************************************************************************/
59 struct aroscbase *aroscbase = __aros_getbase();
60 int len;
62 D(bug("Initializing POSIX environ emulation\n"));
64 aroscbase->acb_environptr = environptr;
66 len = __env_get_environ(NULL, 0);
67 *environptr = malloc(len);
68 if (__env_get_environ(*environptr, len) < 0)
70 fputs("Internal error with environ initialization\n", stderr);
71 abort();