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