]> gitweb.factorcode.org Git - factor.git/blob - basis/environment/unix/unix.factor
84dfbbd43e68906717bb819169c3556ce7f56ec3
[factor.git] / basis / environment / unix / unix.factor
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 ;
6 IN: environment.unix
7
8 HOOK: environ os ( -- void* )
9
10 M: unix environ ( -- void* ) &: environ ;
11
12 M: unix os-env ( key -- value ) getenv ;
13
14 M: unix set-os-env ( value key -- ) swap 1 setenv io-error ;
15
16 M: unix unset-os-env ( key -- ) unsetenv io-error ;
17
18 M: unix (os-envs) ( -- seq )
19     environ *void* utf8 alien>strings ;
20
21 : set-void* ( value alien -- ) 0 set-alien-cell ;
22
23 M: unix (set-os-envs) ( seq -- )
24     utf8 strings>alien malloc-byte-array environ set-void* ;
25
26 os {
27     { macosx [ "environment.unix.macosx" require ] }
28     [ drop ]
29 } case