os envs code and use unix.utilities

db4
Doug Coleman 2008-10-18 21:15:43 -05:00
parent 51f7204356
commit 8b26610808
3 changed files with 14 additions and 16 deletions

View File

@ -4,7 +4,7 @@ USING: alien alien.c-types alien.strings io.encodings.utf8
io.unix.backend kernel math sequences splitting unix strings
combinators.short-circuit byte-arrays combinators qualified
accessors math.parser fry assocs namespaces continuations
unix.users ;
unix.users unix.utilities ;
IN: unix.groups
QUALIFIED: grouping
@ -18,12 +18,7 @@ GENERIC: group-struct ( obj -- group )
<PRIVATE
: group-members ( group-struct -- seq )
group-gr_mem
[ dup { [ ] [ *void* ] } 1&& ]
[
dup *void* utf8 alien>string
[ alien-address "char**" heap-size + <alien> ] dip
] [ ] produce nip ;
group-gr_mem utf8 alien>strings ;
: (group-struct) ( id -- group-struct id group-struct byte-array length void* )
"group" <c-object> tuck 4096

View File

@ -1,6 +1,6 @@
USING: kernel alien.c-types alien.strings sequences math alien.syntax unix
vectors kernel namespaces continuations threads assocs vectors
io.unix.backend io.encodings.utf8 ;
vectors kernel namespaces continuations threads assocs vectors
io.unix.backend io.encodings.utf8 unix.utilities ;
IN: unix.process
! Low-level Unix process launching utilities. These are used
@ -15,17 +15,16 @@ FUNCTION: int execv ( char* path, char** argv ) ;
FUNCTION: int execvp ( char* path, char** argv ) ;
FUNCTION: int execve ( char* path, char** argv, char** envp ) ;
: >argv ( seq -- alien )
[ utf8 malloc-string ] map f suffix >c-void*-array ;
: exec ( pathname argv -- int )
[ utf8 malloc-string ] [ >argv ] bi* execv ;
[ utf8 malloc-string ] [ utf8 strings>alien ] bi* execv ;
: exec-with-path ( filename argv -- int )
[ utf8 malloc-string ] [ >argv ] bi* execvp ;
[ utf8 malloc-string ] [ utf8 strings>alien ] bi* execvp ;
: exec-with-env ( filename argv envp -- int )
[ utf8 malloc-string ] [ >argv ] [ >argv ] tri* execve ;
[ utf8 malloc-string ]
[ utf8 strings>alien ]
[ utf8 strings>alien ] tri* execve ;
: exec-args ( seq -- int )
[ first ] [ ] bi exec ;
@ -99,4 +98,4 @@ FUNCTION: pid_t wait ( int* status ) ;
FUNCTION: pid_t waitpid ( pid_t wpid, int* status, int options ) ;
: wait-for-pid ( pid -- status )
0 <int> [ 0 waitpid drop ] keep *int WEXITSTATUS ;
0 <int> [ 0 waitpid drop ] keep *int WEXITSTATUS ;

View File

@ -105,6 +105,8 @@ FUNCTION: int getdtablesize ;
FUNCTION: gid_t getegid ;
FUNCTION: uid_t geteuid ;
FUNCTION: gid_t getgid ;
FUNCTION: char* getenv ( char* name ) ;
FUNCTION: int getgrgid_r ( gid_t gid, group* grp, char* buffer, size_t bufsize, group** result ) ;
FUNCTION: int getgrnam_r ( char* name, group* grp, char* buffer, size_t bufsize, group** result ) ;
FUNCTION: passwd* getpwent ( ) ;
@ -171,6 +173,8 @@ FUNCTION: int rename ( char* from, char* to ) ;
FUNCTION: int rmdir ( char* path ) ;
FUNCTION: int select ( int nfds, void* readfds, void* writefds, void* exceptfds, timeval* timeout ) ;
FUNCTION: ssize_t sendto ( int s, void* buf, size_t len, int flags, sockaddr-in* to, socklen_t tolen ) ;
FUNCTION: int setenv ( char* name, char* value, int overwrite ) ;
FUNCTION: int unsetenv ( char* name ) ;
FUNCTION: int setegid ( gid_t egid ) ;
FUNCTION: int seteuid ( uid_t euid ) ;
FUNCTION: int setgid ( gid_t gid ) ;