1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types alien.data alien.strings
4 alien.syntax kernel layouts sequences system unix
5 environment io.encodings.utf8 unix.utilities vocabs.loader
6 combinators alien.accessors ;
9 HOOK: environ os ( -- void* )
11 M: unix environ ( -- void* ) &: environ ;
13 M: unix os-env ( key -- value ) getenv ;
15 M: unix set-os-env ( value key -- ) swap 1 setenv io-error ;
17 M: unix unset-os-env ( key -- ) unsetenv io-error ;
19 M: unix (os-envs) ( -- seq )
20 environ *void* utf8 alien>strings ;
22 : set-void* ( value alien -- ) 0 set-alien-cell ;
24 M: unix (set-os-envs) ( seq -- )
25 utf8 strings>alien malloc-byte-array environ set-void* ;
28 { macosx [ "environment.unix.macosx" require ] }