USING: alien alien.c-types alien.data alien.strings
alien.syntax kernel layouts sequences system unix
environment io.encodings.utf8 unix.utilities vocabs.loader
-combinators alien.accessors ;
+combinators alien.accessors unix.ffi ;
IN: environment.unix
HOOK: environ os ( -- void* )
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.syntax generic assocs kernel
kernel.private math io.ports sequences strings sbufs threads
-unix vectors io.buffers io.backend io.encodings math.parser
+unix unix.ffi vectors io.buffers io.backend io.encodings math.parser
continuations system libc namespaces make io.timeouts
io.encodings.utf8 destructors destructors.private accessors
summary combinators locals unix.time unix.types fry
continuations destructors fry io io.backend io.backend.unix
io.directories io.encodings.binary io.encodings.utf8 io.files
io.pathnames io.files.types kernel math.bitwise sequences system
-unix unix.stat vocabs.loader classes.struct ;
+unix unix.stat vocabs.loader classes.struct unix.ffi ;
IN: io.directories.unix
: touch-mode ( -- n )
HOOK: file-system-info os ( path -- file-system-info )
{
- { [ os unix? ] [ "io.files.info.unix." os name>> append ] }
+ { [ os unix? ] [ "io.files.info" ] }
{ [ os windows? ] [ "io.files.info.windows" ] }
} cond require
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel system math math.bitwise strings arrays
-sequences combinators combinators.short-circuit alien.c-types
-vocabs.loader calendar calendar.unix io.files.info
-io.files.types io.backend io.directories unix unix.stat
-unix.time unix.users unix.groups classes.struct
-specialized-arrays literals ;
-SPECIALIZED-ARRAY: timeval
+USING: accessors alien.c-types arrays calendar calendar.unix
+classes.struct combinators combinators.short-circuit io.backend
+io.directories io.files.info io.files.types kernel literals
+math math.bitwise sequences specialized-arrays strings system
+unix unix.ffi unix.groups unix.stat unix.time unix.users
+vocabs.loader ;
IN: io.files.info.unix
+SPECIALIZED-ARRAY: timeval
TUPLE: unix-file-system-info < file-system-info
block-size preferred-block-size
{ +regular-file+ [ file-type>executable ] }
[ drop file-type>executable ]
} case ;
+
+"io.files.info.unix." os name>> append require
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: io.backend io.files.links system unix io.pathnames kernel
-io.files sequences ;
+USING: io.backend io.files io.files.links io.pathnames kernel
+sequences system unix unix.ffi ;
IN: io.files.links.unix
M: unix make-link ( path1 path2 -- )
! See http://factorcode.org/license.txt for BSD license.
USING: unix byte-arrays kernel io.backend.unix math.bitwise
io.ports io.files io.files.private io.pathnames environment
-destructors system ;
+destructors system unix.ffi ;
IN: io.files.unix
M: unix cwd ( -- path )
io.files io.files.private io.files.unix io.launcher
io.launcher.unix.parser io.pathnames io.ports kernel math
namespaces sequences strings system threads unix
-unix.process ;
+unix.process unix.ffi ;
IN: io.launcher.unix
: get-arguments ( process -- seq )
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types system kernel unix math sequences
-io.backend.unix io.ports specialized-arrays accessors ;
+io.backend.unix io.ports specialized-arrays accessors unix.ffi ;
QUALIFIED: io.pipes
SPECIALIZED-ARRAY: int
IN: io.pipes.unix
openssl.libcrypto openssl.libssl io io.files io.ports
io.backend.unix io.sockets.unix io.encodings.ascii io.buffers
io.sockets io.sockets.private io.sockets.secure
-io.sockets.secure.openssl io.timeouts system summary fry ;
+io.sockets.secure.openssl io.timeouts system summary fry
+unix.ffi ;
FROM: io.ports => shutdown ;
IN: io.sockets.secure.unix
<< {
{ [ os windows? ] [ "windows.winsock" ] }
- { [ os unix? ] [ "unix" ] }
+ { [ os unix? ] [ "unix.ffi" ] }
} cond use-vocab >>
! Addressing
io.streams.duplex io.backend io.pathnames io.sockets.private
io.files.private io.encodings.utf8 math.parser continuations
libc combinators system accessors destructors unix locals init
-classes.struct alien.data ;
+classes.struct alien.data unix.ffi ;
EXCLUDE: namespaces => bind ;
EXCLUDE: io => read write ;
+++ /dev/null
-Slava Pestov
+++ /dev/null
-! Copyright (C) 2005, 2006 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax classes.struct combinators
-system unix.types vocabs.loader ;
-IN: unix
-
-CONSTANT: MAXPATHLEN 1024
-
-CONSTANT: O_RDONLY HEX: 0000
-CONSTANT: O_WRONLY HEX: 0001
-CONSTANT: O_RDWR HEX: 0002
-CONSTANT: O_NONBLOCK HEX: 0004
-CONSTANT: O_APPEND HEX: 0008
-CONSTANT: O_CREAT HEX: 0200
-CONSTANT: O_TRUNC HEX: 0400
-CONSTANT: O_EXCL HEX: 0800
-CONSTANT: O_NOCTTY HEX: 20000
-ALIAS: O_NDELAY O_NONBLOCK
-
-CONSTANT: SOL_SOCKET HEX: ffff
-CONSTANT: SO_REUSEADDR HEX: 4
-CONSTANT: SO_OOBINLINE HEX: 100
-CONSTANT: SO_SNDTIMEO HEX: 1005
-CONSTANT: SO_RCVTIMEO HEX: 1006
-
-CONSTANT: F_SETFD 2
-CONSTANT: F_SETFL 4
-CONSTANT: FD_CLOEXEC 1
-
-STRUCT: sockaddr-in
- { len uchar }
- { family uchar }
- { port ushort }
- { addr in_addr_t }
- { unused longlong } ;
-
-STRUCT: sockaddr-in6
- { len uchar }
- { family uchar }
- { port ushort }
- { flowinfo uint }
- { addr uchar[16] }
- { scopeid uint } ;
-
-STRUCT: sockaddr-un
- { len uchar }
- { family uchar }
- { path char[104] } ;
-
-STRUCT: passwd
- { pw_name char* }
- { pw_passwd char* }
- { pw_uid uid_t }
- { pw_gid gid_t }
- { pw_change time_t }
- { pw_class char* }
- { pw_gecos char* }
- { pw_dir char* }
- { pw_shell char* }
- { pw_expire time_t }
- { pw_fields int } ;
-
-CONSTANT: max-un-path 104
-
-CONSTANT: SOCK_STREAM 1
-CONSTANT: SOCK_DGRAM 2
-
-CONSTANT: AF_UNSPEC 0
-CONSTANT: AF_UNIX 1
-CONSTANT: AF_INET 2
-CONSTANT: AF_INET6 30
-
-ALIAS: PF_UNSPEC AF_UNSPEC
-ALIAS: PF_UNIX AF_UNIX
-ALIAS: PF_INET AF_INET
-ALIAS: PF_INET6 AF_INET6
-
-CONSTANT: IPPROTO_TCP 6
-CONSTANT: IPPROTO_UDP 17
-
-CONSTANT: AI_PASSIVE 1
-
-CONSTANT: SEEK_SET 0
-CONSTANT: SEEK_CUR 1
-CONSTANT: SEEK_END 2
-
-os {
- { macosx [ "unix.bsd.macosx" require ] }
- { freebsd [ "unix.bsd.freebsd" require ] }
- { openbsd [ "unix.bsd.openbsd" require ] }
- { netbsd [ "unix.bsd.netbsd" require ] }
-} case
+++ /dev/null
-USING: alien.c-types alien.syntax classes.struct unix.types ;
-IN: unix
-
-CONSTANT: FD_SETSIZE 1024
-
-STRUCT: addrinfo
- { flags int }
- { family int }
- { socktype int }
- { protocol int }
- { addrlen socklen_t }
- { canonname char* }
- { addr void* }
- { next addrinfo* } ;
-
-STRUCT: dirent
- { d_fileno u_int32_t }
- { d_reclen u_int16_t }
- { d_type u_int8_t }
- { d_namlen u_int8_t }
- { d_name char[256] } ;
-
-CONSTANT: EPERM 1
-CONSTANT: ENOENT 2
-CONSTANT: ESRCH 3
-CONSTANT: EINTR 4
-CONSTANT: EIO 5
-CONSTANT: ENXIO 6
-CONSTANT: E2BIG 7
-CONSTANT: ENOEXEC 8
-CONSTANT: EBADF 9
-CONSTANT: ECHILD 10
-CONSTANT: EDEADLK 11
-CONSTANT: ENOMEM 12
-CONSTANT: EACCES 13
-CONSTANT: EFAULT 14
-CONSTANT: ENOTBLK 15
-CONSTANT: EBUSY 16
-CONSTANT: EEXIST 17
-CONSTANT: EXDEV 18
-CONSTANT: ENODEV 19
-CONSTANT: ENOTDIR 20
-CONSTANT: EISDIR 21
-CONSTANT: EINVAL 22
-CONSTANT: ENFILE 23
-CONSTANT: EMFILE 24
-CONSTANT: ENOTTY 25
-CONSTANT: ETXTBSY 26
-CONSTANT: EFBIG 27
-CONSTANT: ENOSPC 28
-CONSTANT: ESPIPE 29
-CONSTANT: EROFS 30
-CONSTANT: EMLINK 31
-CONSTANT: EPIPE 32
-CONSTANT: EDOM 33
-CONSTANT: ERANGE 34
-CONSTANT: EAGAIN 35
-ALIAS: EWOULDBLOCK EAGAIN
-CONSTANT: EINPROGRESS 36
-CONSTANT: EALREADY 37
-CONSTANT: ENOTSOCK 38
-CONSTANT: EDESTADDRREQ 39
-CONSTANT: EMSGSIZE 40
-CONSTANT: EPROTOTYPE 41
-CONSTANT: ENOPROTOOPT 42
-CONSTANT: EPROTONOSUPPORT 43
-CONSTANT: ESOCKTNOSUPPORT 44
-CONSTANT: EOPNOTSUPP 45
-ALIAS: ENOTSUP EOPNOTSUPP
-CONSTANT: EPFNOSUPPORT 46
-CONSTANT: EAFNOSUPPORT 47
-CONSTANT: EADDRINUSE 48
-CONSTANT: EADDRNOTAVAIL 49
-CONSTANT: ENETDOWN 50
-CONSTANT: ENETUNREACH 51
-CONSTANT: ENETRESET 52
-CONSTANT: ECONNABORTED 53
-CONSTANT: ECONNRESET 54
-CONSTANT: ENOBUFS 55
-CONSTANT: EISCONN 56
-CONSTANT: ENOTCONN 57
-CONSTANT: ESHUTDOWN 58
-CONSTANT: ETOOMANYREFS 59
-CONSTANT: ETIMEDOUT 60
-CONSTANT: ECONNREFUSED 61
-CONSTANT: ELOOP 62
-CONSTANT: ENAMETOOLONG 63
-CONSTANT: EHOSTDOWN 64
-CONSTANT: EHOSTUNREACH 65
-CONSTANT: ENOTEMPTY 66
-CONSTANT: EPROCLIM 67
-CONSTANT: EUSERS 68
-CONSTANT: EDQUOT 69
-CONSTANT: ESTALE 70
-CONSTANT: EREMOTE 71
-CONSTANT: EBADRPC 72
-CONSTANT: ERPCMISMATCH 73
-CONSTANT: EPROGUNAVAIL 74
-CONSTANT: EPROGMISMATCH 75
-CONSTANT: EPROCUNAVAIL 76
-CONSTANT: ENOLCK 77
-CONSTANT: ENOSYS 78
-CONSTANT: EFTYPE 79
-CONSTANT: EAUTH 80
-CONSTANT: ENEEDAUTH 81
-CONSTANT: EIDRM 82
-CONSTANT: ENOMSG 83
-CONSTANT: EOVERFLOW 84
-CONSTANT: ECANCELED 85
-CONSTANT: EILSEQ 86
-CONSTANT: ENOATTR 87
-CONSTANT: EDOOFUS 88
-CONSTANT: EBADMSG 89
-CONSTANT: EMULTIHOP 90
-CONSTANT: ENOLINK 91
-CONSTANT: EPROTO 92
+++ /dev/null
-unportable
+++ /dev/null
-USING: alien.c-types alien.syntax unix.time unix.types
-unix.types.macosx classes.struct ;
-IN: unix
-
-CONSTANT: FD_SETSIZE 1024
-
-STRUCT: addrinfo
- { flags int }
- { family int }
- { socktype int }
- { protocol int }
- { addrlen socklen_t }
- { canonname char* }
- { addr void* }
- { next addrinfo* } ;
-
-CONSTANT: _UTX_USERSIZE 256
-CONSTANT: _UTX_LINESIZE 32
-CONSTANT: _UTX_IDSIZE 4
-CONSTANT: _UTX_HOSTSIZE 256
-
-STRUCT: utmpx
- { ut_user { char _UTX_USERSIZE } }
- { ut_id { char _UTX_IDSIZE } }
- { ut_line { char _UTX_LINESIZE } }
- { ut_pid pid_t }
- { ut_type short }
- { ut_tv timeval }
- { ut_host { char _UTX_HOSTSIZE } }
- { ut_pad { uint 16 } } ;
-
-CONSTANT: __DARWIN_MAXPATHLEN 1024
-CONSTANT: __DARWIN_MAXNAMELEN 255
-CONSTANT: __DARWIN_MAXNAMELEN+1 255
-
-STRUCT: dirent
- { d_ino ino_t }
- { d_reclen __uint16_t }
- { d_type __uint8_t }
- { d_namlen __uint8_t }
- { d_name { char __DARWIN_MAXNAMELEN+1 } } ;
-
-CONSTANT: EPERM 1
-CONSTANT: ENOENT 2
-CONSTANT: ESRCH 3
-CONSTANT: EINTR 4
-CONSTANT: EIO 5
-CONSTANT: ENXIO 6
-CONSTANT: E2BIG 7
-CONSTANT: ENOEXEC 8
-CONSTANT: EBADF 9
-CONSTANT: ECHILD 10
-CONSTANT: EDEADLK 11
-CONSTANT: ENOMEM 12
-CONSTANT: EACCES 13
-CONSTANT: EFAULT 14
-CONSTANT: ENOTBLK 15
-CONSTANT: EBUSY 16
-CONSTANT: EEXIST 17
-CONSTANT: EXDEV 18
-CONSTANT: ENODEV 19
-CONSTANT: ENOTDIR 20
-CONSTANT: EISDIR 21
-CONSTANT: EINVAL 22
-CONSTANT: ENFILE 23
-CONSTANT: EMFILE 24
-CONSTANT: ENOTTY 25
-CONSTANT: ETXTBSY 26
-CONSTANT: EFBIG 27
-CONSTANT: ENOSPC 28
-CONSTANT: ESPIPE 29
-CONSTANT: EROFS 30
-CONSTANT: EMLINK 31
-CONSTANT: EPIPE 32
-CONSTANT: EDOM 33
-CONSTANT: ERANGE 34
-CONSTANT: EAGAIN 35
-ALIAS: EWOULDBLOCK EAGAIN
-CONSTANT: EINPROGRESS 36
-CONSTANT: EALREADY 37
-CONSTANT: ENOTSOCK 38
-CONSTANT: EDESTADDRREQ 39
-CONSTANT: EMSGSIZE 40
-CONSTANT: EPROTOTYPE 41
-CONSTANT: ENOPROTOOPT 42
-CONSTANT: EPROTONOSUPPORT 43
-CONSTANT: ESOCKTNOSUPPORT 44
-CONSTANT: ENOTSUP 45
-CONSTANT: EPFNOSUPPORT 46
-CONSTANT: EAFNOSUPPORT 47
-CONSTANT: EADDRINUSE 48
-CONSTANT: EADDRNOTAVAIL 49
-CONSTANT: ENETDOWN 50
-CONSTANT: ENETUNREACH 51
-CONSTANT: ENETRESET 52
-CONSTANT: ECONNABORTED 53
-CONSTANT: ECONNRESET 54
-CONSTANT: ENOBUFS 55
-CONSTANT: EISCONN 56
-CONSTANT: ENOTCONN 57
-CONSTANT: ESHUTDOWN 58
-CONSTANT: ETOOMANYREFS 59
-CONSTANT: ETIMEDOUT 60
-CONSTANT: ECONNREFUSED 61
-CONSTANT: ELOOP 62
-CONSTANT: ENAMETOOLONG 63
-CONSTANT: EHOSTDOWN 64
-CONSTANT: EHOSTUNREACH 65
-CONSTANT: ENOTEMPTY 66
-CONSTANT: EPROCLIM 67
-CONSTANT: EUSERS 68
-CONSTANT: EDQUOT 69
-CONSTANT: ESTALE 70
-CONSTANT: EREMOTE 71
-CONSTANT: EBADRPC 72
-CONSTANT: ERPCMISMATCH 73
-CONSTANT: EPROGUNAVAIL 74
-CONSTANT: EPROGMISMATCH 75
-CONSTANT: EPROCUNAVAIL 76
-CONSTANT: ENOLCK 77
-CONSTANT: ENOSYS 78
-CONSTANT: EFTYPE 79
-CONSTANT: EAUTH 80
-CONSTANT: ENEEDAUTH 81
-CONSTANT: EPWROFF 82
-CONSTANT: EDEVERR 83
-CONSTANT: EOVERFLOW 84
-CONSTANT: EBADEXEC 85
-CONSTANT: EBADARCH 86
-CONSTANT: ESHLIBVERS 87
-CONSTANT: EBADMACHO 88
-CONSTANT: ECANCELED 89
-CONSTANT: EIDRM 90
-CONSTANT: ENOMSG 91
-CONSTANT: EILSEQ 92
-CONSTANT: ENOATTR 93
-CONSTANT: EBADMSG 94
-CONSTANT: EMULTIHOP 95
-CONSTANT: ENODATA 96
-CONSTANT: ENOLINK 97
-CONSTANT: ENOSR 98
-CONSTANT: ENOSTR 99
-CONSTANT: EPROTO 100
-CONSTANT: ETIME 101
-CONSTANT: EOPNOTSUPP 102
-CONSTANT: ENOPOLICY 103
+++ /dev/null
-unportable
+++ /dev/null
-USING: alien.syntax alien.c-types math vocabs.loader
-classes.struct unix.types ;
-IN: unix
-
-CONSTANT: FD_SETSIZE 256
-
-STRUCT: addrinfo
- { flags int }
- { family int }
- { socktype int }
- { protocol int }
- { addrlen socklen_t }
- { canonname char* }
- { addr void* }
- { next addrinfo* } ;
-
-STRUCT: dirent
- { d_fileno __uint32_t }
- { d_reclen __uint16_t }
- { d_type __uint8_t }
- { d_namlen __uint8_t }
- { d_name char[256] } ;
-
-CONSTANT: EPERM 1
-CONSTANT: ENOENT 2
-CONSTANT: ESRCH 3
-CONSTANT: EINTR 4
-CONSTANT: EIO 5
-CONSTANT: ENXIO 6
-CONSTANT: E2BIG 7
-CONSTANT: ENOEXEC 8
-CONSTANT: EBADF 9
-CONSTANT: ECHILD 10
-CONSTANT: EDEADLK 11
-CONSTANT: ENOMEM 12
-CONSTANT: EACCES 13
-CONSTANT: EFAULT 14
-CONSTANT: ENOTBLK 15
-CONSTANT: EBUSY 16
-CONSTANT: EEXIST 17
-CONSTANT: EXDEV 18
-CONSTANT: ENODEV 19
-CONSTANT: ENOTDIR 20
-CONSTANT: EISDIR 21
-CONSTANT: EINVAL 22
-CONSTANT: ENFILE 23
-CONSTANT: EMFILE 24
-CONSTANT: ENOTTY 25
-CONSTANT: ETXTBSY 26
-CONSTANT: EFBIG 27
-CONSTANT: ENOSPC 28
-CONSTANT: ESPIPE 29
-CONSTANT: EROFS 30
-CONSTANT: EMLINK 31
-CONSTANT: EPIPE 32
-CONSTANT: EDOM 33
-CONSTANT: ERANGE 34
-CONSTANT: EAGAIN 35
-ALIAS: EWOULDBLOCK EAGAIN
-CONSTANT: EINPROGRESS 36
-CONSTANT: EALREADY 37
-CONSTANT: ENOTSOCK 38
-CONSTANT: EDESTADDRREQ 39
-CONSTANT: EMSGSIZE 40
-CONSTANT: EPROTOTYPE 41
-CONSTANT: ENOPROTOOPT 42
-CONSTANT: EPROTONOSUPPORT 43
-CONSTANT: ESOCKTNOSUPPORT 44
-CONSTANT: EOPNOTSUPP 45
-CONSTANT: EPFNOSUPPORT 46
-CONSTANT: EAFNOSUPPORT 47
-CONSTANT: EADDRINUSE 48
-CONSTANT: EADDRNOTAVAIL 49
-CONSTANT: ENETDOWN 50
-CONSTANT: ENETUNREACH 51
-CONSTANT: ENETRESET 52
-CONSTANT: ECONNABORTED 53
-CONSTANT: ECONNRESET 54
-CONSTANT: ENOBUFS 55
-CONSTANT: EISCONN 56
-CONSTANT: ENOTCONN 57
-CONSTANT: ESHUTDOWN 58
-CONSTANT: ETOOMANYREFS 59
-CONSTANT: ETIMEDOUT 60
-CONSTANT: ECONNREFUSED 61
-CONSTANT: ELOOP 62
-CONSTANT: ENAMETOOLONG 63
-CONSTANT: EHOSTDOWN 64
-CONSTANT: EHOSTUNREACH 65
-CONSTANT: ENOTEMPTY 66
-CONSTANT: EPROCLIM 67
-CONSTANT: EUSERS 68
-CONSTANT: EDQUOT 69
-CONSTANT: ESTALE 70
-CONSTANT: EREMOTE 71
-CONSTANT: EBADRPC 72
-CONSTANT: ERPCMISMATCH 73
-CONSTANT: EPROGUNAVAIL 74
-CONSTANT: EPROGMISMATCH 75
-CONSTANT: EPROCUNAVAIL 76
-CONSTANT: ENOLCK 77
-CONSTANT: ENOSYS 78
-CONSTANT: EFTYPE 79
-CONSTANT: EAUTH 80
-CONSTANT: ENEEDAUTH 81
-CONSTANT: EIDRM 82
-CONSTANT: ENOMSG 83
-CONSTANT: EOVERFLOW 84
-CONSTANT: EILSEQ 85
-CONSTANT: ENOTSUP 86
-CONSTANT: ECANCELED 87
-CONSTANT: EBADMSG 88
-CONSTANT: ENODATA 89
-CONSTANT: ENOSR 90
-CONSTANT: ENOSTR 91
-CONSTANT: ETIME 92
-CONSTANT: ENOATTR 93
-CONSTANT: EMULTIHOP 94
-CONSTANT: ENOLINK 95
-CONSTANT: EPROTO 96
-CONSTANT: ELAST 96
-
-TYPEDEF: __uint8_t sa_family_t
-
-CONSTANT: _UTX_USERSIZE 32
-CONSTANT: _UTX_LINESIZE 32
-CONSTANT: _UTX_IDSIZE 4
-CONSTANT: _UTX_HOSTSIZE 256
-
-CONSTANT: _SS_MAXSIZE 128
-
-: _SS_ALIGNSIZE ( -- n )
- __int64_t heap-size ; inline
-
-: _SS_PAD1SIZE ( -- n )
- _SS_ALIGNSIZE 2 - ; inline
-
-: _SS_PAD2SIZE ( -- n )
- _SS_MAXSIZE 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE - ; inline
-
-"unix.bsd.netbsd.structs" require
+++ /dev/null
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax unix.time unix.types
-unix.types.netbsd classes.struct ;
-IN: unix
-
-STRUCT: sockaddr_storage
- { ss_len __uint8_t }
- { ss_family sa_family_t }
- { __ss_pad1 { char _SS_PAD1SIZE } }
- { __ss_align __int64_t }
- { __ss_pad2 { char _SS_PAD2SIZE } } ;
-
-STRUCT: exit_struct
- { e_termination uint16_t }
- { e_exit uint16_t } ;
-
-STRUCT: utmpx
- { ut_user { char _UTX_USERSIZE } }
- { ut_id { char _UTX_IDSIZE } }
- { ut_line { char _UTX_LINESIZE } }
- { ut_host { char _UTX_HOSTSIZE } }
- { ut_session uint16_t }
- { ut_type uint16_t }
- { ut_pid pid_t }
- { ut_exit exit_struct }
- { ut_ss sockaddr_storage }
- { ut_tv timeval }
- { ut_pad { uint32_t 10 } } ;
-
+++ /dev/null
-unportable
+++ /dev/null
-unportable
+++ /dev/null
-USING: alien.c-types alien.syntax classes.struct unix.types ;
-IN: unix
-
-CONSTANT: FD_SETSIZE 1024
-
-STRUCT: addrinfo
- { flags int }
- { family int }
- { socktype int }
- { protocol int }
- { addrlen socklen_t }
- { addr void* }
- { canonname char* }
- { next addrinfo* } ;
-
-STRUCT: dirent
- { d_fileno __uint32_t }
- { d_reclen __uint16_t }
- { d_type __uint8_t }
- { d_namlen __uint8_t }
- { d_name char[256] } ;
-
-CONSTANT: EPERM 1
-CONSTANT: ENOENT 2
-CONSTANT: ESRCH 3
-CONSTANT: EINTR 4
-CONSTANT: EIO 5
-CONSTANT: ENXIO 6
-CONSTANT: E2BIG 7
-CONSTANT: ENOEXEC 8
-CONSTANT: EBADF 9
-CONSTANT: ECHILD 10
-CONSTANT: EDEADLK 11
-CONSTANT: ENOMEM 12
-CONSTANT: EACCES 13
-CONSTANT: EFAULT 14
-CONSTANT: ENOTBLK 15
-CONSTANT: EBUSY 16
-CONSTANT: EEXIST 17
-CONSTANT: EXDEV 18
-CONSTANT: ENODEV 19
-CONSTANT: ENOTDIR 20
-CONSTANT: EISDIR 21
-CONSTANT: EINVAL 22
-CONSTANT: ENFILE 23
-CONSTANT: EMFILE 24
-CONSTANT: ENOTTY 25
-CONSTANT: ETXTBSY 26
-CONSTANT: EFBIG 27
-CONSTANT: ENOSPC 28
-CONSTANT: ESPIPE 29
-CONSTANT: EROFS 30
-CONSTANT: EMLINK 31
-CONSTANT: EPIPE 32
-CONSTANT: EDOM 33
-CONSTANT: ERANGE 34
-CONSTANT: EAGAIN 35
-ALIAS: EWOULDBLOCK EAGAIN
-CONSTANT: EINPROGRESS 36
-CONSTANT: EALREADY 37
-CONSTANT: ENOTSOCK 38
-CONSTANT: EDESTADDRREQ 39
-CONSTANT: EMSGSIZE 40
-CONSTANT: EPROTOTYPE 41
-CONSTANT: ENOPROTOOPT 42
-CONSTANT: EPROTONOSUPPORT 43
-CONSTANT: ESOCKTNOSUPPORT 44
-CONSTANT: EOPNOTSUPP 45
-CONSTANT: EPFNOSUPPORT 46
-CONSTANT: EAFNOSUPPORT 47
-CONSTANT: EADDRINUSE 48
-CONSTANT: EADDRNOTAVAIL 49
-CONSTANT: ENETDOWN 50
-CONSTANT: ENETUNREACH 51
-CONSTANT: ENETRESET 52
-CONSTANT: ECONNABORTED 53
-CONSTANT: ECONNRESET 54
-CONSTANT: ENOBUFS 55
-CONSTANT: EISCONN 56
-CONSTANT: ENOTCONN 57
-CONSTANT: ESHUTDOWN 58
-CONSTANT: ETOOMANYREFS 59
-CONSTANT: ETIMEDOUT 60
-CONSTANT: ECONNREFUSED 61
-CONSTANT: ELOOP 62
-CONSTANT: ENAMETOOLONG 63
-CONSTANT: EHOSTDOWN 64
-CONSTANT: EHOSTUNREACH 65
-CONSTANT: ENOTEMPTY 66
-CONSTANT: EPROCLIM 67
-CONSTANT: EUSERS 68
-CONSTANT: EDQUOT 69
-CONSTANT: ESTALE 70
-CONSTANT: EREMOTE 71
-CONSTANT: EBADRPC 72
-CONSTANT: ERPCMISMATCH 73
-CONSTANT: EPROGUNAVAIL 74
-CONSTANT: EPROGMISMATCH 75
-CONSTANT: EPROCUNAVAIL 76
-CONSTANT: ENOLCK 77
-CONSTANT: ENOSYS 78
-CONSTANT: EFTYPE 79
-CONSTANT: EAUTH 80
-CONSTANT: ENEEDAUTH 81
-CONSTANT: EIPSEC 82
-CONSTANT: ENOATTR 83
-CONSTANT: EILSEQ 84
-CONSTANT: ENOMEDIUM 85
-CONSTANT: EMEDIUMTYPE 86
-CONSTANT: EOVERFLOW 87
-CONSTANT: ECANCELED 88
+++ /dev/null
-unportable
+++ /dev/null
-*BSD/Mac OS X support
+++ /dev/null
-unportable
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: debugger prettyprint accessors unix kernel ;
-FROM: io => write print nl ;
+USING: accessors debugger io kernel prettyprint unix ;
IN: unix.debugger
M: unix-error error.
+++ /dev/null
-unportable
--- /dev/null
+Doug Coleman
\ No newline at end of file
--- /dev/null
+Slava Pestov
--- /dev/null
+! Copyright (C) 2005, 2006 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.syntax classes.struct combinators
+system unix.types vocabs.loader ;
+IN: unix.ffi
+
+CONSTANT: MAXPATHLEN 1024
+
+CONSTANT: O_RDONLY HEX: 0000
+CONSTANT: O_WRONLY HEX: 0001
+CONSTANT: O_RDWR HEX: 0002
+CONSTANT: O_NONBLOCK HEX: 0004
+CONSTANT: O_APPEND HEX: 0008
+CONSTANT: O_CREAT HEX: 0200
+CONSTANT: O_TRUNC HEX: 0400
+CONSTANT: O_EXCL HEX: 0800
+CONSTANT: O_NOCTTY HEX: 20000
+ALIAS: O_NDELAY O_NONBLOCK
+
+CONSTANT: SOL_SOCKET HEX: ffff
+CONSTANT: SO_REUSEADDR HEX: 4
+CONSTANT: SO_OOBINLINE HEX: 100
+CONSTANT: SO_SNDTIMEO HEX: 1005
+CONSTANT: SO_RCVTIMEO HEX: 1006
+
+CONSTANT: F_SETFD 2
+CONSTANT: F_SETFL 4
+CONSTANT: FD_CLOEXEC 1
+
+STRUCT: sockaddr-in
+ { len uchar }
+ { family uchar }
+ { port ushort }
+ { addr in_addr_t }
+ { unused longlong } ;
+
+STRUCT: sockaddr-in6
+ { len uchar }
+ { family uchar }
+ { port ushort }
+ { flowinfo uint }
+ { addr uchar[16] }
+ { scopeid uint } ;
+
+STRUCT: sockaddr-un
+ { len uchar }
+ { family uchar }
+ { path char[104] } ;
+
+STRUCT: passwd
+ { pw_name char* }
+ { pw_passwd char* }
+ { pw_uid uid_t }
+ { pw_gid gid_t }
+ { pw_change time_t }
+ { pw_class char* }
+ { pw_gecos char* }
+ { pw_dir char* }
+ { pw_shell char* }
+ { pw_expire time_t }
+ { pw_fields int } ;
+
+CONSTANT: max-un-path 104
+
+CONSTANT: SOCK_STREAM 1
+CONSTANT: SOCK_DGRAM 2
+
+CONSTANT: AF_UNSPEC 0
+CONSTANT: AF_UNIX 1
+CONSTANT: AF_INET 2
+CONSTANT: AF_INET6 30
+
+ALIAS: PF_UNSPEC AF_UNSPEC
+ALIAS: PF_UNIX AF_UNIX
+ALIAS: PF_INET AF_INET
+ALIAS: PF_INET6 AF_INET6
+
+CONSTANT: IPPROTO_TCP 6
+CONSTANT: IPPROTO_UDP 17
+
+CONSTANT: AI_PASSIVE 1
+
+CONSTANT: SEEK_SET 0
+CONSTANT: SEEK_CUR 1
+CONSTANT: SEEK_END 2
+
+os {
+ { macosx [ "unix.ffi.bsd.macosx" require ] }
+ { freebsd [ "unix.ffi.bsd.freebsd" require ] }
+ { openbsd [ "unix.ffi.bsd.openbsd" require ] }
+ { netbsd [ "unix.ffi.bsd.netbsd" require ] }
+} case
--- /dev/null
+USING: alien.c-types alien.syntax classes.struct unix.types ;
+IN: unix.ffi
+
+CONSTANT: FD_SETSIZE 1024
+
+STRUCT: addrinfo
+ { flags int }
+ { family int }
+ { socktype int }
+ { protocol int }
+ { addrlen socklen_t }
+ { canonname char* }
+ { addr void* }
+ { next addrinfo* } ;
+
+STRUCT: dirent
+ { d_fileno u_int32_t }
+ { d_reclen u_int16_t }
+ { d_type u_int8_t }
+ { d_namlen u_int8_t }
+ { d_name char[256] } ;
+
+CONSTANT: EPERM 1
+CONSTANT: ENOENT 2
+CONSTANT: ESRCH 3
+CONSTANT: EINTR 4
+CONSTANT: EIO 5
+CONSTANT: ENXIO 6
+CONSTANT: E2BIG 7
+CONSTANT: ENOEXEC 8
+CONSTANT: EBADF 9
+CONSTANT: ECHILD 10
+CONSTANT: EDEADLK 11
+CONSTANT: ENOMEM 12
+CONSTANT: EACCES 13
+CONSTANT: EFAULT 14
+CONSTANT: ENOTBLK 15
+CONSTANT: EBUSY 16
+CONSTANT: EEXIST 17
+CONSTANT: EXDEV 18
+CONSTANT: ENODEV 19
+CONSTANT: ENOTDIR 20
+CONSTANT: EISDIR 21
+CONSTANT: EINVAL 22
+CONSTANT: ENFILE 23
+CONSTANT: EMFILE 24
+CONSTANT: ENOTTY 25
+CONSTANT: ETXTBSY 26
+CONSTANT: EFBIG 27
+CONSTANT: ENOSPC 28
+CONSTANT: ESPIPE 29
+CONSTANT: EROFS 30
+CONSTANT: EMLINK 31
+CONSTANT: EPIPE 32
+CONSTANT: EDOM 33
+CONSTANT: ERANGE 34
+CONSTANT: EAGAIN 35
+ALIAS: EWOULDBLOCK EAGAIN
+CONSTANT: EINPROGRESS 36
+CONSTANT: EALREADY 37
+CONSTANT: ENOTSOCK 38
+CONSTANT: EDESTADDRREQ 39
+CONSTANT: EMSGSIZE 40
+CONSTANT: EPROTOTYPE 41
+CONSTANT: ENOPROTOOPT 42
+CONSTANT: EPROTONOSUPPORT 43
+CONSTANT: ESOCKTNOSUPPORT 44
+CONSTANT: EOPNOTSUPP 45
+ALIAS: ENOTSUP EOPNOTSUPP
+CONSTANT: EPFNOSUPPORT 46
+CONSTANT: EAFNOSUPPORT 47
+CONSTANT: EADDRINUSE 48
+CONSTANT: EADDRNOTAVAIL 49
+CONSTANT: ENETDOWN 50
+CONSTANT: ENETUNREACH 51
+CONSTANT: ENETRESET 52
+CONSTANT: ECONNABORTED 53
+CONSTANT: ECONNRESET 54
+CONSTANT: ENOBUFS 55
+CONSTANT: EISCONN 56
+CONSTANT: ENOTCONN 57
+CONSTANT: ESHUTDOWN 58
+CONSTANT: ETOOMANYREFS 59
+CONSTANT: ETIMEDOUT 60
+CONSTANT: ECONNREFUSED 61
+CONSTANT: ELOOP 62
+CONSTANT: ENAMETOOLONG 63
+CONSTANT: EHOSTDOWN 64
+CONSTANT: EHOSTUNREACH 65
+CONSTANT: ENOTEMPTY 66
+CONSTANT: EPROCLIM 67
+CONSTANT: EUSERS 68
+CONSTANT: EDQUOT 69
+CONSTANT: ESTALE 70
+CONSTANT: EREMOTE 71
+CONSTANT: EBADRPC 72
+CONSTANT: ERPCMISMATCH 73
+CONSTANT: EPROGUNAVAIL 74
+CONSTANT: EPROGMISMATCH 75
+CONSTANT: EPROCUNAVAIL 76
+CONSTANT: ENOLCK 77
+CONSTANT: ENOSYS 78
+CONSTANT: EFTYPE 79
+CONSTANT: EAUTH 80
+CONSTANT: ENEEDAUTH 81
+CONSTANT: EIDRM 82
+CONSTANT: ENOMSG 83
+CONSTANT: EOVERFLOW 84
+CONSTANT: ECANCELED 85
+CONSTANT: EILSEQ 86
+CONSTANT: ENOATTR 87
+CONSTANT: EDOOFUS 88
+CONSTANT: EBADMSG 89
+CONSTANT: EMULTIHOP 90
+CONSTANT: ENOLINK 91
+CONSTANT: EPROTO 92
--- /dev/null
+unportable
--- /dev/null
+USING: alien alien.c-types alien.libraries alien.syntax
+classes.struct combinators kernel system unix unix.time
+unix.types vocabs vocabs.loader ;
+IN: unix.ffi
+
+CONSTANT: FD_SETSIZE 1024
+
+STRUCT: addrinfo
+ { flags int }
+ { family int }
+ { socktype int }
+ { protocol int }
+ { addrlen socklen_t }
+ { canonname char* }
+ { addr void* }
+ { next addrinfo* } ;
+
+CONSTANT: _UTX_USERSIZE 256
+CONSTANT: _UTX_LINESIZE 32
+CONSTANT: _UTX_IDSIZE 4
+CONSTANT: _UTX_HOSTSIZE 256
+
+STRUCT: utmpx
+ { ut_user { char _UTX_USERSIZE } }
+ { ut_id { char _UTX_IDSIZE } }
+ { ut_line { char _UTX_LINESIZE } }
+ { ut_pid pid_t }
+ { ut_type short }
+ { ut_tv timeval }
+ { ut_host { char _UTX_HOSTSIZE } }
+ { ut_pad { uint 16 } } ;
+
+CONSTANT: __DARWIN_MAXPATHLEN 1024
+CONSTANT: __DARWIN_MAXNAMELEN 255
+CONSTANT: __DARWIN_MAXNAMELEN+1 255
+
+STRUCT: dirent
+ { d_ino ino_t }
+ { d_reclen __uint16_t }
+ { d_type __uint8_t }
+ { d_namlen __uint8_t }
+ { d_name { char __DARWIN_MAXNAMELEN+1 } } ;
+
+CONSTANT: EPERM 1
+CONSTANT: ENOENT 2
+CONSTANT: ESRCH 3
+CONSTANT: EINTR 4
+CONSTANT: EIO 5
+CONSTANT: ENXIO 6
+CONSTANT: E2BIG 7
+CONSTANT: ENOEXEC 8
+CONSTANT: EBADF 9
+CONSTANT: ECHILD 10
+CONSTANT: EDEADLK 11
+CONSTANT: ENOMEM 12
+CONSTANT: EACCES 13
+CONSTANT: EFAULT 14
+CONSTANT: ENOTBLK 15
+CONSTANT: EBUSY 16
+CONSTANT: EEXIST 17
+CONSTANT: EXDEV 18
+CONSTANT: ENODEV 19
+CONSTANT: ENOTDIR 20
+CONSTANT: EISDIR 21
+CONSTANT: EINVAL 22
+CONSTANT: ENFILE 23
+CONSTANT: EMFILE 24
+CONSTANT: ENOTTY 25
+CONSTANT: ETXTBSY 26
+CONSTANT: EFBIG 27
+CONSTANT: ENOSPC 28
+CONSTANT: ESPIPE 29
+CONSTANT: EROFS 30
+CONSTANT: EMLINK 31
+CONSTANT: EPIPE 32
+CONSTANT: EDOM 33
+CONSTANT: ERANGE 34
+CONSTANT: EAGAIN 35
+ALIAS: EWOULDBLOCK EAGAIN
+CONSTANT: EINPROGRESS 36
+CONSTANT: EALREADY 37
+CONSTANT: ENOTSOCK 38
+CONSTANT: EDESTADDRREQ 39
+CONSTANT: EMSGSIZE 40
+CONSTANT: EPROTOTYPE 41
+CONSTANT: ENOPROTOOPT 42
+CONSTANT: EPROTONOSUPPORT 43
+CONSTANT: ESOCKTNOSUPPORT 44
+CONSTANT: ENOTSUP 45
+CONSTANT: EPFNOSUPPORT 46
+CONSTANT: EAFNOSUPPORT 47
+CONSTANT: EADDRINUSE 48
+CONSTANT: EADDRNOTAVAIL 49
+CONSTANT: ENETDOWN 50
+CONSTANT: ENETUNREACH 51
+CONSTANT: ENETRESET 52
+CONSTANT: ECONNABORTED 53
+CONSTANT: ECONNRESET 54
+CONSTANT: ENOBUFS 55
+CONSTANT: EISCONN 56
+CONSTANT: ENOTCONN 57
+CONSTANT: ESHUTDOWN 58
+CONSTANT: ETOOMANYREFS 59
+CONSTANT: ETIMEDOUT 60
+CONSTANT: ECONNREFUSED 61
+CONSTANT: ELOOP 62
+CONSTANT: ENAMETOOLONG 63
+CONSTANT: EHOSTDOWN 64
+CONSTANT: EHOSTUNREACH 65
+CONSTANT: ENOTEMPTY 66
+CONSTANT: EPROCLIM 67
+CONSTANT: EUSERS 68
+CONSTANT: EDQUOT 69
+CONSTANT: ESTALE 70
+CONSTANT: EREMOTE 71
+CONSTANT: EBADRPC 72
+CONSTANT: ERPCMISMATCH 73
+CONSTANT: EPROGUNAVAIL 74
+CONSTANT: EPROGMISMATCH 75
+CONSTANT: EPROCUNAVAIL 76
+CONSTANT: ENOLCK 77
+CONSTANT: ENOSYS 78
+CONSTANT: EFTYPE 79
+CONSTANT: EAUTH 80
+CONSTANT: ENEEDAUTH 81
+CONSTANT: EPWROFF 82
+CONSTANT: EDEVERR 83
+CONSTANT: EOVERFLOW 84
+CONSTANT: EBADEXEC 85
+CONSTANT: EBADARCH 86
+CONSTANT: ESHLIBVERS 87
+CONSTANT: EBADMACHO 88
+CONSTANT: ECANCELED 89
+CONSTANT: EIDRM 90
+CONSTANT: ENOMSG 91
+CONSTANT: EILSEQ 92
+CONSTANT: ENOATTR 93
+CONSTANT: EBADMSG 94
+CONSTANT: EMULTIHOP 95
+CONSTANT: ENODATA 96
+CONSTANT: ENOLINK 97
+CONSTANT: ENOSR 98
+CONSTANT: ENOSTR 99
+CONSTANT: EPROTO 100
+CONSTANT: ETIME 101
+CONSTANT: EOPNOTSUPP 102
+CONSTANT: ENOPOLICY 103
--- /dev/null
+unportable
--- /dev/null
+USING: alien.syntax alien.c-types math vocabs.loader
+classes.struct unix.types ;
+IN: unix.ffi
+
+CONSTANT: FD_SETSIZE 256
+
+STRUCT: addrinfo
+ { flags int }
+ { family int }
+ { socktype int }
+ { protocol int }
+ { addrlen socklen_t }
+ { canonname char* }
+ { addr void* }
+ { next addrinfo* } ;
+
+STRUCT: dirent
+ { d_fileno __uint32_t }
+ { d_reclen __uint16_t }
+ { d_type __uint8_t }
+ { d_namlen __uint8_t }
+ { d_name char[256] } ;
+
+CONSTANT: EPERM 1
+CONSTANT: ENOENT 2
+CONSTANT: ESRCH 3
+CONSTANT: EINTR 4
+CONSTANT: EIO 5
+CONSTANT: ENXIO 6
+CONSTANT: E2BIG 7
+CONSTANT: ENOEXEC 8
+CONSTANT: EBADF 9
+CONSTANT: ECHILD 10
+CONSTANT: EDEADLK 11
+CONSTANT: ENOMEM 12
+CONSTANT: EACCES 13
+CONSTANT: EFAULT 14
+CONSTANT: ENOTBLK 15
+CONSTANT: EBUSY 16
+CONSTANT: EEXIST 17
+CONSTANT: EXDEV 18
+CONSTANT: ENODEV 19
+CONSTANT: ENOTDIR 20
+CONSTANT: EISDIR 21
+CONSTANT: EINVAL 22
+CONSTANT: ENFILE 23
+CONSTANT: EMFILE 24
+CONSTANT: ENOTTY 25
+CONSTANT: ETXTBSY 26
+CONSTANT: EFBIG 27
+CONSTANT: ENOSPC 28
+CONSTANT: ESPIPE 29
+CONSTANT: EROFS 30
+CONSTANT: EMLINK 31
+CONSTANT: EPIPE 32
+CONSTANT: EDOM 33
+CONSTANT: ERANGE 34
+CONSTANT: EAGAIN 35
+ALIAS: EWOULDBLOCK EAGAIN
+CONSTANT: EINPROGRESS 36
+CONSTANT: EALREADY 37
+CONSTANT: ENOTSOCK 38
+CONSTANT: EDESTADDRREQ 39
+CONSTANT: EMSGSIZE 40
+CONSTANT: EPROTOTYPE 41
+CONSTANT: ENOPROTOOPT 42
+CONSTANT: EPROTONOSUPPORT 43
+CONSTANT: ESOCKTNOSUPPORT 44
+CONSTANT: EOPNOTSUPP 45
+CONSTANT: EPFNOSUPPORT 46
+CONSTANT: EAFNOSUPPORT 47
+CONSTANT: EADDRINUSE 48
+CONSTANT: EADDRNOTAVAIL 49
+CONSTANT: ENETDOWN 50
+CONSTANT: ENETUNREACH 51
+CONSTANT: ENETRESET 52
+CONSTANT: ECONNABORTED 53
+CONSTANT: ECONNRESET 54
+CONSTANT: ENOBUFS 55
+CONSTANT: EISCONN 56
+CONSTANT: ENOTCONN 57
+CONSTANT: ESHUTDOWN 58
+CONSTANT: ETOOMANYREFS 59
+CONSTANT: ETIMEDOUT 60
+CONSTANT: ECONNREFUSED 61
+CONSTANT: ELOOP 62
+CONSTANT: ENAMETOOLONG 63
+CONSTANT: EHOSTDOWN 64
+CONSTANT: EHOSTUNREACH 65
+CONSTANT: ENOTEMPTY 66
+CONSTANT: EPROCLIM 67
+CONSTANT: EUSERS 68
+CONSTANT: EDQUOT 69
+CONSTANT: ESTALE 70
+CONSTANT: EREMOTE 71
+CONSTANT: EBADRPC 72
+CONSTANT: ERPCMISMATCH 73
+CONSTANT: EPROGUNAVAIL 74
+CONSTANT: EPROGMISMATCH 75
+CONSTANT: EPROCUNAVAIL 76
+CONSTANT: ENOLCK 77
+CONSTANT: ENOSYS 78
+CONSTANT: EFTYPE 79
+CONSTANT: EAUTH 80
+CONSTANT: ENEEDAUTH 81
+CONSTANT: EIDRM 82
+CONSTANT: ENOMSG 83
+CONSTANT: EOVERFLOW 84
+CONSTANT: EILSEQ 85
+CONSTANT: ENOTSUP 86
+CONSTANT: ECANCELED 87
+CONSTANT: EBADMSG 88
+CONSTANT: ENODATA 89
+CONSTANT: ENOSR 90
+CONSTANT: ENOSTR 91
+CONSTANT: ETIME 92
+CONSTANT: ENOATTR 93
+CONSTANT: EMULTIHOP 94
+CONSTANT: ENOLINK 95
+CONSTANT: EPROTO 96
+CONSTANT: ELAST 96
+
+TYPEDEF: __uint8_t sa_family_t
+
+CONSTANT: _UTX_USERSIZE 32
+CONSTANT: _UTX_LINESIZE 32
+CONSTANT: _UTX_IDSIZE 4
+CONSTANT: _UTX_HOSTSIZE 256
+
+CONSTANT: _SS_MAXSIZE 128
+
+: _SS_ALIGNSIZE ( -- n )
+ __int64_t heap-size ; inline
+
+: _SS_PAD1SIZE ( -- n )
+ _SS_ALIGNSIZE 2 - ; inline
+
+: _SS_PAD2SIZE ( -- n )
+ _SS_MAXSIZE 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE - ; inline
+
+"unix.ffi.bsd.netbsd.structs" require
--- /dev/null
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.syntax unix.time unix.types
+unix.types.netbsd classes.struct ;
+IN: unix
+
+STRUCT: sockaddr_storage
+ { ss_len __uint8_t }
+ { ss_family sa_family_t }
+ { __ss_pad1 { char _SS_PAD1SIZE } }
+ { __ss_align __int64_t }
+ { __ss_pad2 { char _SS_PAD2SIZE } } ;
+
+STRUCT: exit_struct
+ { e_termination uint16_t }
+ { e_exit uint16_t } ;
+
+STRUCT: utmpx
+ { ut_user { char _UTX_USERSIZE } }
+ { ut_id { char _UTX_IDSIZE } }
+ { ut_line { char _UTX_LINESIZE } }
+ { ut_host { char _UTX_HOSTSIZE } }
+ { ut_session uint16_t }
+ { ut_type uint16_t }
+ { ut_pid pid_t }
+ { ut_exit exit_struct }
+ { ut_ss sockaddr_storage }
+ { ut_tv timeval }
+ { ut_pad { uint32_t 10 } } ;
+
--- /dev/null
+unportable
--- /dev/null
+unportable
--- /dev/null
+USING: alien.c-types alien.syntax classes.struct unix.types ;
+IN: unix.ffi
+
+CONSTANT: FD_SETSIZE 1024
+
+STRUCT: addrinfo
+ { flags int }
+ { family int }
+ { socktype int }
+ { protocol int }
+ { addrlen socklen_t }
+ { addr void* }
+ { canonname char* }
+ { next addrinfo* } ;
+
+STRUCT: dirent
+ { d_fileno __uint32_t }
+ { d_reclen __uint16_t }
+ { d_type __uint8_t }
+ { d_namlen __uint8_t }
+ { d_name char[256] } ;
+
+CONSTANT: EPERM 1
+CONSTANT: ENOENT 2
+CONSTANT: ESRCH 3
+CONSTANT: EINTR 4
+CONSTANT: EIO 5
+CONSTANT: ENXIO 6
+CONSTANT: E2BIG 7
+CONSTANT: ENOEXEC 8
+CONSTANT: EBADF 9
+CONSTANT: ECHILD 10
+CONSTANT: EDEADLK 11
+CONSTANT: ENOMEM 12
+CONSTANT: EACCES 13
+CONSTANT: EFAULT 14
+CONSTANT: ENOTBLK 15
+CONSTANT: EBUSY 16
+CONSTANT: EEXIST 17
+CONSTANT: EXDEV 18
+CONSTANT: ENODEV 19
+CONSTANT: ENOTDIR 20
+CONSTANT: EISDIR 21
+CONSTANT: EINVAL 22
+CONSTANT: ENFILE 23
+CONSTANT: EMFILE 24
+CONSTANT: ENOTTY 25
+CONSTANT: ETXTBSY 26
+CONSTANT: EFBIG 27
+CONSTANT: ENOSPC 28
+CONSTANT: ESPIPE 29
+CONSTANT: EROFS 30
+CONSTANT: EMLINK 31
+CONSTANT: EPIPE 32
+CONSTANT: EDOM 33
+CONSTANT: ERANGE 34
+CONSTANT: EAGAIN 35
+ALIAS: EWOULDBLOCK EAGAIN
+CONSTANT: EINPROGRESS 36
+CONSTANT: EALREADY 37
+CONSTANT: ENOTSOCK 38
+CONSTANT: EDESTADDRREQ 39
+CONSTANT: EMSGSIZE 40
+CONSTANT: EPROTOTYPE 41
+CONSTANT: ENOPROTOOPT 42
+CONSTANT: EPROTONOSUPPORT 43
+CONSTANT: ESOCKTNOSUPPORT 44
+CONSTANT: EOPNOTSUPP 45
+CONSTANT: EPFNOSUPPORT 46
+CONSTANT: EAFNOSUPPORT 47
+CONSTANT: EADDRINUSE 48
+CONSTANT: EADDRNOTAVAIL 49
+CONSTANT: ENETDOWN 50
+CONSTANT: ENETUNREACH 51
+CONSTANT: ENETRESET 52
+CONSTANT: ECONNABORTED 53
+CONSTANT: ECONNRESET 54
+CONSTANT: ENOBUFS 55
+CONSTANT: EISCONN 56
+CONSTANT: ENOTCONN 57
+CONSTANT: ESHUTDOWN 58
+CONSTANT: ETOOMANYREFS 59
+CONSTANT: ETIMEDOUT 60
+CONSTANT: ECONNREFUSED 61
+CONSTANT: ELOOP 62
+CONSTANT: ENAMETOOLONG 63
+CONSTANT: EHOSTDOWN 64
+CONSTANT: EHOSTUNREACH 65
+CONSTANT: ENOTEMPTY 66
+CONSTANT: EPROCLIM 67
+CONSTANT: EUSERS 68
+CONSTANT: EDQUOT 69
+CONSTANT: ESTALE 70
+CONSTANT: EREMOTE 71
+CONSTANT: EBADRPC 72
+CONSTANT: ERPCMISMATCH 73
+CONSTANT: EPROGUNAVAIL 74
+CONSTANT: EPROGMISMATCH 75
+CONSTANT: EPROCUNAVAIL 76
+CONSTANT: ENOLCK 77
+CONSTANT: ENOSYS 78
+CONSTANT: EFTYPE 79
+CONSTANT: EAUTH 80
+CONSTANT: ENEEDAUTH 81
+CONSTANT: EIPSEC 82
+CONSTANT: ENOATTR 83
+CONSTANT: EILSEQ 84
+CONSTANT: ENOMEDIUM 85
+CONSTANT: EMEDIUMTYPE 86
+CONSTANT: EOVERFLOW 87
+CONSTANT: ECANCELED 88
--- /dev/null
+unportable
--- /dev/null
+*BSD/Mac OS X support
--- /dev/null
+unportable
--- /dev/null
+! Copyright (C) 2010 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien alien.c-types alien.libraries alien.syntax
+classes.struct combinators kernel system unix.time unix.types
+vocabs vocabs.loader ;
+IN: unix.ffi
+
+<<
+
+{
+ { [ os linux? ] [ "unix.ffi.linux" require ] }
+ { [ os bsd? ] [ "unix.ffi.bsd" require ] }
+ { [ os solaris? ] [ "unix.ffi.solaris" require ] }
+} cond
+
+>>
+
+CONSTANT: PROT_NONE 0
+CONSTANT: PROT_READ 1
+CONSTANT: PROT_WRITE 2
+CONSTANT: PROT_EXEC 4
+
+CONSTANT: MAP_FILE 0
+CONSTANT: MAP_SHARED 1
+CONSTANT: MAP_PRIVATE 2
+
+CONSTANT: SEEK_SET 0
+CONSTANT: SEEK_CUR 1
+CONSTANT: SEEK_END 2
+
+: MAP_FAILED ( -- alien ) -1 <alien> ; inline
+
+CONSTANT: NGROUPS_MAX 16
+
+CONSTANT: DT_UNKNOWN 0
+CONSTANT: DT_FIFO 1
+CONSTANT: DT_CHR 2
+CONSTANT: DT_DIR 4
+CONSTANT: DT_BLK 6
+CONSTANT: DT_REG 8
+CONSTANT: DT_LNK 10
+CONSTANT: DT_SOCK 12
+CONSTANT: DT_WHT 14
+
+LIBRARY: libc
+
+FUNCTION: char* strerror ( int errno ) ;
+
+STRUCT: group
+ { gr_name char* }
+ { gr_passwd char* }
+ { gr_gid int }
+ { gr_mem char** } ;
+
+FUNCTION: int accept ( int s, void* sockaddr, socklen_t* socklen ) ;
+FUNCTION: int bind ( int s, void* name, socklen_t namelen ) ;
+FUNCTION: int chdir ( char* path ) ;
+FUNCTION: int chmod ( char* path, mode_t mode ) ;
+FUNCTION: int fchmod ( int fd, mode_t mode ) ;
+FUNCTION: int chown ( char* path, uid_t owner, gid_t group ) ;
+FUNCTION: int chroot ( char* path ) ;
+FUNCTION: int close ( int fd ) ;
+FUNCTION: int closedir ( DIR* dirp ) ;
+FUNCTION: int connect ( int s, void* name, socklen_t namelen ) ;
+FUNCTION: int dup2 ( int oldd, int newd ) ;
+FUNCTION: void endpwent ( ) ;
+FUNCTION: int fchdir ( int fd ) ;
+FUNCTION: int fchown ( int fd, uid_t owner, gid_t group ) ;
+FUNCTION: int fcntl ( int fd, int cmd, int arg ) ;
+FUNCTION: int flock ( int fd, int operation ) ;
+FUNCTION: void freeaddrinfo ( addrinfo* ai ) ;
+FUNCTION: int futimes ( int id, timeval[2] times ) ;
+FUNCTION: char* gai_strerror ( int ecode ) ;
+FUNCTION: int getaddrinfo ( char* hostname, char* servname, addrinfo* hints, addrinfo** res ) ;
+FUNCTION: char* getcwd ( char* buf, size_t size ) ;
+FUNCTION: pid_t getpid ;
+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 ( ) ;
+FUNCTION: passwd* getpwuid ( uid_t uid ) ;
+FUNCTION: passwd* getpwnam ( char* login ) ;
+FUNCTION: int getpwnam_r ( char* login, passwd* pwd, char* buffer, size_t bufsize, passwd** result ) ;
+FUNCTION: int getgroups ( int gidsetlen, gid_t* gidset ) ;
+FUNCTION: int getgrouplist ( char* name, int basegid, int* groups, int* ngroups ) ;
+FUNCTION: int getrlimit ( int resource, rlimit* rlp ) ;
+FUNCTION: int setrlimit ( int resource, rlimit* rlp ) ;
+FUNCTION: int getpriority ( int which, id_t who ) ;
+FUNCTION: int setpriority ( int which, id_t who, int prio ) ;
+FUNCTION: int getrusage ( int who, rusage* r_usage ) ;
+FUNCTION: group* getgrent ;
+FUNCTION: int gethostname ( char* name, int len ) ;
+FUNCTION: int getsockname ( int socket, sockaddr* address, socklen_t* address_len ) ;
+FUNCTION: int getpeername ( int socket, sockaddr* address, socklen_t* address_len ) ;
+FUNCTION: uid_t getuid ;
+FUNCTION: uint htonl ( uint n ) ;
+FUNCTION: ushort htons ( ushort n ) ;
+! FUNCTION: int issetugid ;
+FUNCTION: int ioctl ( int fd, ulong request, char* argp ) ;
+FUNCTION: int lchown ( char* path, uid_t owner, gid_t group ) ;
+FUNCTION: int listen ( int s, int backlog ) ;
+FUNCTION: off_t lseek ( int fildes, off_t offset, int whence ) ;
+FUNCTION: int mkdir ( char* path, mode_t mode ) ;
+FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_t offset ) ;
+FUNCTION: int munmap ( void* addr, size_t len ) ;
+FUNCTION: uint ntohl ( uint n ) ;
+FUNCTION: ushort ntohs ( ushort n ) ;
+FUNCTION: int shutdown ( int fd, int how ) ;
+FUNCTION: int open ( char* path, int flags, int prot ) ;
+FUNCTION: DIR* opendir ( char* path ) ;
+
+STRUCT: utimbuf
+ { actime time_t }
+ { modtime time_t } ;
+
+FUNCTION: int utime ( char* path, utimbuf* buf ) ;
+
+FUNCTION: int pclose ( void* file ) ;
+FUNCTION: int pipe ( int* filedes ) ;
+FUNCTION: void* popen ( char* command, char* type ) ;
+FUNCTION: ssize_t read ( int fd, void* buf, size_t nbytes ) ;
+
+FUNCTION: dirent* readdir ( DIR* dirp ) ;
+FUNCTION: int readdir_r ( void* dirp, dirent* entry, dirent** result ) ;
+FUNCTION: ssize_t readlink ( char* path, char* buf, size_t bufsize ) ;
+
+CONSTANT: PATH_MAX 1024
+
+FUNCTION: ssize_t recv ( int s, void* buf, size_t nbytes, int flags ) ;
+FUNCTION: ssize_t recvfrom ( int s, void* buf, size_t nbytes, int flags, sockaddr-in* from, socklen_t* fromlen ) ;
+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 ) ;
+FUNCTION: int setgroups ( int ngroups, gid_t* gidset ) ;
+FUNCTION: int setregid ( gid_t rgid, gid_t egid ) ;
+FUNCTION: int setreuid ( uid_t ruid, uid_t euid ) ;
+FUNCTION: int setsockopt ( int s, int level, int optname, void* optval, socklen_t optlen ) ;
+FUNCTION: int setuid ( uid_t uid ) ;
+FUNCTION: int socket ( int domain, int type, int protocol ) ;
+FUNCTION: int symlink ( char* path1, char* path2 ) ;
+FUNCTION: int link ( char* path1, char* path2 ) ;
+FUNCTION: int system ( char* command ) ;
+FUNCTION: int unlink ( char* path ) ;
+FUNCTION: int utimes ( char* path, timeval[2] times ) ;
+FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ;
+
+"librt" "librt.so" "cdecl" add-library
--- /dev/null
+Doug Coleman
\ No newline at end of file
--- /dev/null
+! Copyright (C) 2010 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.syntax classes.struct unix.types ;
+IN: unix.ffi
+
+CONSTANT: MAXPATHLEN 1024
+
+CONSTANT: O_RDONLY HEX: 0000
+CONSTANT: O_WRONLY HEX: 0001
+CONSTANT: O_RDWR HEX: 0002
+CONSTANT: O_CREAT HEX: 0040
+CONSTANT: O_EXCL HEX: 0080
+CONSTANT: O_NOCTTY HEX: 0100
+CONSTANT: O_TRUNC HEX: 0200
+CONSTANT: O_APPEND HEX: 0400
+CONSTANT: O_NONBLOCK HEX: 0800
+
+ALIAS: O_NDELAY O_NONBLOCK
+
+CONSTANT: SOL_SOCKET 1
+
+CONSTANT: FD_SETSIZE 1024
+
+CONSTANT: SO_REUSEADDR 2
+CONSTANT: SO_OOBINLINE 10
+CONSTANT: SO_SNDTIMEO HEX: 15
+CONSTANT: SO_RCVTIMEO HEX: 14
+
+CONSTANT: F_SETFD 2
+CONSTANT: FD_CLOEXEC 1
+
+CONSTANT: F_SETFL 4
+
+STRUCT: addrinfo
+ { flags int }
+ { family int }
+ { socktype int }
+ { protocol int }
+ { addrlen socklen_t }
+ { addr void* }
+ { canonname char* }
+ { next addrinfo* } ;
+
+STRUCT: sockaddr-in
+ { family ushort }
+ { port ushort }
+ { addr in_addr_t }
+ { unused longlong } ;
+
+STRUCT: sockaddr-in6
+ { family ushort }
+ { port ushort }
+ { flowinfo uint }
+ { addr uchar[16] }
+ { scopeid uint } ;
+
+CONSTANT: max-un-path 108
+
+STRUCT: sockaddr-un
+ { family ushort }
+ { path { char max-un-path } } ;
+
+CONSTANT: SOCK_STREAM 1
+CONSTANT: SOCK_DGRAM 2
+
+CONSTANT: AF_UNSPEC 0
+CONSTANT: AF_UNIX 1
+CONSTANT: AF_INET 2
+CONSTANT: AF_INET6 10
+
+ALIAS: PF_UNSPEC AF_UNSPEC
+ALIAS: PF_UNIX AF_UNIX
+ALIAS: PF_INET AF_INET
+ALIAS: PF_INET6 AF_INET6
+
+CONSTANT: IPPROTO_TCP 6
+CONSTANT: IPPROTO_UDP 17
+
+CONSTANT: AI_PASSIVE 1
+
+CONSTANT: SEEK_SET 0
+CONSTANT: SEEK_CUR 1
+CONSTANT: SEEK_END 2
+
+STRUCT: passwd
+ { pw_name char* }
+ { pw_passwd char* }
+ { pw_uid uid_t }
+ { pw_gid gid_t }
+ { pw_gecos char* }
+ { pw_dir char* }
+ { pw_shell char* } ;
+
+! dirent64
+STRUCT: dirent
+ { d_ino ulonglong }
+ { d_off longlong }
+ { d_reclen ushort }
+ { d_type uchar }
+ { d_name char[256] } ;
+
+FUNCTION: int open64 ( char* path, int flags, int prot ) ;
+FUNCTION: dirent* readdir64 ( DIR* dirp ) ;
+FUNCTION: int readdir64_r ( void* dirp, dirent* entry, dirent** result ) ;
+
+CONSTANT: EPERM 1
+CONSTANT: ENOENT 2
+CONSTANT: ESRCH 3
+CONSTANT: EINTR 4
+CONSTANT: EIO 5
+CONSTANT: ENXIO 6
+CONSTANT: E2BIG 7
+CONSTANT: ENOEXEC 8
+CONSTANT: EBADF 9
+CONSTANT: ECHILD 10
+CONSTANT: EAGAIN 11
+CONSTANT: ENOMEM 12
+CONSTANT: EACCES 13
+CONSTANT: EFAULT 14
+CONSTANT: ENOTBLK 15
+CONSTANT: EBUSY 16
+CONSTANT: EEXIST 17
+CONSTANT: EXDEV 18
+CONSTANT: ENODEV 19
+CONSTANT: ENOTDIR 20
+CONSTANT: EISDIR 21
+CONSTANT: EINVAL 22
+CONSTANT: ENFILE 23
+CONSTANT: EMFILE 24
+CONSTANT: ENOTTY 25
+CONSTANT: ETXTBSY 26
+CONSTANT: EFBIG 27
+CONSTANT: ENOSPC 28
+CONSTANT: ESPIPE 29
+CONSTANT: EROFS 30
+CONSTANT: EMLINK 31
+CONSTANT: EPIPE 32
+CONSTANT: EDOM 33
+CONSTANT: ERANGE 34
+CONSTANT: EDEADLK 35
+CONSTANT: ENAMETOOLONG 36
+CONSTANT: ENOLCK 37
+CONSTANT: ENOSYS 38
+CONSTANT: ENOTEMPTY 39
+CONSTANT: ELOOP 40
+ALIAS: EWOULDBLOCK EAGAIN
+CONSTANT: ENOMSG 42
+CONSTANT: EIDRM 43
+CONSTANT: ECHRNG 44
+CONSTANT: EL2NSYNC 45
+CONSTANT: EL3HLT 46
+CONSTANT: EL3RST 47
+CONSTANT: ELNRNG 48
+CONSTANT: EUNATCH 49
+CONSTANT: ENOCSI 50
+CONSTANT: EL2HLT 51
+CONSTANT: EBADE 52
+CONSTANT: EBADR 53
+CONSTANT: EXFULL 54
+CONSTANT: ENOANO 55
+CONSTANT: EBADRQC 56
+CONSTANT: EBADSLT 57
+ALIAS: EDEADLOCK EDEADLK
+CONSTANT: EBFONT 59
+CONSTANT: ENOSTR 60
+CONSTANT: ENODATA 61
+CONSTANT: ETIME 62
+CONSTANT: ENOSR 63
+CONSTANT: ENONET 64
+CONSTANT: ENOPKG 65
+CONSTANT: EREMOTE 66
+CONSTANT: ENOLINK 67
+CONSTANT: EADV 68
+CONSTANT: ESRMNT 69
+CONSTANT: ECOMM 70
+CONSTANT: EPROTO 71
+CONSTANT: EMULTIHOP 72
+CONSTANT: EDOTDOT 73
+CONSTANT: EBADMSG 74
+CONSTANT: EOVERFLOW 75
+CONSTANT: ENOTUNIQ 76
+CONSTANT: EBADFD 77
+CONSTANT: EREMCHG 78
+CONSTANT: ELIBACC 79
+CONSTANT: ELIBBAD 80
+CONSTANT: ELIBSCN 81
+CONSTANT: ELIBMAX 82
+CONSTANT: ELIBEXEC 83
+CONSTANT: EILSEQ 84
+CONSTANT: ERESTART 85
+CONSTANT: ESTRPIPE 86
+CONSTANT: EUSERS 87
+CONSTANT: ENOTSOCK 88
+CONSTANT: EDESTADDRREQ 89
+CONSTANT: EMSGSIZE 90
+CONSTANT: EPROTOTYPE 91
+CONSTANT: ENOPROTOOPT 92
+CONSTANT: EPROTONOSUPPORT 93
+CONSTANT: ESOCKTNOSUPPORT 94
+CONSTANT: EOPNOTSUPP 95
+CONSTANT: EPFNOSUPPORT 96
+CONSTANT: EAFNOSUPPORT 97
+CONSTANT: EADDRINUSE 98
+CONSTANT: EADDRNOTAVAIL 99
+CONSTANT: ENETDOWN 100
+CONSTANT: ENETUNREACH 101
+CONSTANT: ENETRESET 102
+CONSTANT: ECONNABORTED 103
+CONSTANT: ECONNRESET 104
+CONSTANT: ENOBUFS 105
+CONSTANT: EISCONN 106
+CONSTANT: ENOTCONN 107
+CONSTANT: ESHUTDOWN 108
+CONSTANT: ETOOMANYREFS 109
+CONSTANT: ETIMEDOUT 110
+CONSTANT: ECONNREFUSED 111
+CONSTANT: EHOSTDOWN 112
+CONSTANT: EHOSTUNREACH 113
+CONSTANT: EALREADY 114
+CONSTANT: EINPROGRESS 115
+CONSTANT: ESTALE 116
+CONSTANT: EUCLEAN 117
+CONSTANT: ENOTNAM 118
+CONSTANT: ENAVAIL 119
+CONSTANT: EISNAM 120
+CONSTANT: EREMOTEIO 121
+CONSTANT: EDQUOT 122
+CONSTANT: ENOMEDIUM 123
+CONSTANT: EMEDIUMTYPE 124
+CONSTANT: ECANCELED 125
+CONSTANT: ENOKEY 126
+CONSTANT: EKEYEXPIRED 127
+CONSTANT: EKEYREVOKED 128
+CONSTANT: EKEYREJECTED 129
+CONSTANT: EOWNERDEAD 130
+CONSTANT: ENOTRECOVERABLE 131
--- /dev/null
+Slava Pestov
--- /dev/null
+! Copyright (C) 2006 Patrick Mauritz.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.syntax system kernel layouts ;
+IN: unix.ffi
+
+! Solaris.
+
+CONSTANT: O_RDONLY HEX: 0000
+CONSTANT: O_WRONLY HEX: 0001
+CONSTANT: O_RDWR HEX: 0002
+CONSTANT: O_APPEND HEX: 0008
+CONSTANT: O_CREAT HEX: 0100
+CONSTANT: O_TRUNC HEX: 0200
+
+CONSTANT: SEEK_END 2
+
+CONSTANT: SOL_SOCKET HEX: ffff
+
+: FD_SETSIZE ( -- n ) cell 4 = 1024 65536 ? ;
+
+CONSTANT: SO_REUSEADDR 4
+CONSTANT: SO_OOBINLINE HEX: 0100
+CONSTANT: SO_SNDTIMEO HEX: 1005
+CONSTANT: SO_RCVTIMEO HEX: 1006
+
+CONSTANT: F_SETFL 4 ! set file status flags
+CONSTANT: O_NONBLOCK HEX: 80 ! no delay
+
+STRUCT: addrinfo
+ { flags int }
+ { family int }
+ { socktype int }
+ { protocol int }
+! #ifdef __sparcv9
+! int _ai_pad;
+! #endif
+ { addrlen int }
+ { canonname char* }
+ { addr void* }
+ { next void* } ;
+
+STRUCT: sockaddr-in
+ { family ushort }
+ { port ushort }
+ { addr in_addr_t }
+ { unused longlong } ;
+
+STRUCT: sockaddr-in6
+ { family ushort }
+ { port ushort }
+ { flowinfo uint }
+ { addr uchar[16] }
+ { scopeid uint } ;
+
+CONSTANT: max-un-path 108
+
+STRUCT: sockaddr-un
+ { family ushort }
+ { path { "char" max-un-path } } ;
+
+CONSTANT: EINTR 4
+CONSTANT: EAGAIN 11
+CONSTANT: EINPROGRESS 150
+
+CONSTANT: SOCK_STREAM 2
+CONSTANT: SOCK_DGRAM 1
+
+CONSTANT: AF_UNSPEC 0
+CONSTANT: AF_UNIX 1
+CONSTANT: AF_INET 2
+CONSTANT: AF_INET6 26
+
+ALIAS: PF_UNSPEC AF_UNSPEC
+ALIAS: PF_UNIX AF_UNIX
+ALIAS: PF_INET AF_INET
+ALIAS: PF_INET6 AF_INET6
+
+CONSTANT: IPPROTO_TCP 6
+CONSTANT: IPPROTO_UDP 17
+
+CONSTANT: AI_PASSIVE 8
--- /dev/null
+unportable
io.backend.unix kernel math sequences splitting strings
combinators.short-circuit byte-arrays combinators
accessors math.parser fry assocs namespaces continuations
-unix.users unix.utilities classes.struct ;
+unix.users unix.utilities classes.struct unix ;
IN: unix.groups
-QUALIFIED: unix
+QUALIFIED: unix.ffi
QUALIFIED: grouping
gr_mem>> utf8 alien>strings ;
: (group-struct) ( id -- group-struct id group-struct byte-array length void* )
- [ \ unix:group <struct> ] dip over 4096
+ [ \ unix.ffi:group <struct> ] dip over 4096
[ <byte-array> ] keep f <void*> ;
: check-group-struct ( group-struct ptr -- group-struct/f )
*void* [ drop f ] unless ;
M: integer group-struct ( id -- group/f )
- (group-struct) [ unix:getgrgid_r unix:io-error ] keep check-group-struct ;
+ (group-struct)
+ [ [ unix.ffi:getgrgid_r ] unix-system-call io-error ] keep
+ check-group-struct ;
M: string group-struct ( string -- group/f )
- (group-struct) [ unix:getgrnam_r unix:io-error ] keep check-group-struct ;
+ (group-struct)
+ [ [ unix.ffi:getgrnam_r ] unix-system-call io-error ] keep
+ check-group-struct ;
: group-struct>group ( group-struct -- group )
[ \ group new ] dip
: (user-groups) ( string -- seq )
#! first group is -1337, legacy unix code
- -1337 unix:NGROUPS_MAX [ 4 * <byte-array> ] keep
- <int> [ unix:getgrouplist unix:io-error ] 2keep
+ -1337 unix.ffi:NGROUPS_MAX [ 4 * <byte-array> ] keep
+ <int> [ [ unix.ffi:getgrouplist ] unix-system-call io-error ] 2keep
[ 4 tail-slice ] [ *int 1 - ] bi* >groups ;
PRIVATE>
user-name (user-groups) ;
: all-groups ( -- seq )
- [ unix:getgrent dup ] [ \ unix:group memory>struct group-struct>group ] produce nip ;
+ [ [ unix.ffi:getgrent ] unix-system-call dup ] [ \ unix.ffi:group memory>struct group-struct>group ] produce nip ;
: <group-cache> ( -- assoc )
all-groups [ [ id>> ] keep ] H{ } map>assoc ;
: with-group-cache ( quot -- )
[ <group-cache> group-cache ] dip with-variable ; inline
-: real-group-id ( -- id ) unix:getgid ; inline
+: real-group-id ( -- id ) unix.ffi:getgid ; inline
: real-group-name ( -- string ) real-group-id group-name ; inline
-: effective-group-id ( -- string ) unix:getegid ; inline
+: effective-group-id ( -- string ) unix.ffi:getegid ; inline
: effective-group-name ( -- string )
effective-group-id group-name ; inline
<PRIVATE
: (set-real-group) ( id -- )
- unix:setgid unix:io-error ; inline
+ [ unix.ffi:setgid ] unix-system-call io-error ; inline
: (set-effective-group) ( id -- )
- unix:setegid unix:io-error ; inline
+ [ unix.ffi:setegid ] unix-system-call io-error ; inline
PRIVATE>
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax alien system classes.struct
-unix.types ;
-IN: unix
-
-! Linux.
-
-CONSTANT: MAXPATHLEN 1024
-
-CONSTANT: O_RDONLY HEX: 0000
-CONSTANT: O_WRONLY HEX: 0001
-CONSTANT: O_RDWR HEX: 0002
-CONSTANT: O_CREAT HEX: 0040
-CONSTANT: O_EXCL HEX: 0080
-CONSTANT: O_NOCTTY HEX: 0100
-CONSTANT: O_TRUNC HEX: 0200
-CONSTANT: O_APPEND HEX: 0400
-CONSTANT: O_NONBLOCK HEX: 0800
-
-ALIAS: O_NDELAY O_NONBLOCK
-
-CONSTANT: SOL_SOCKET 1
-
-CONSTANT: FD_SETSIZE 1024
-
-CONSTANT: SO_REUSEADDR 2
-CONSTANT: SO_OOBINLINE 10
-CONSTANT: SO_SNDTIMEO HEX: 15
-CONSTANT: SO_RCVTIMEO HEX: 14
-
-CONSTANT: F_SETFD 2
-CONSTANT: FD_CLOEXEC 1
-
-CONSTANT: F_SETFL 4
-
-STRUCT: addrinfo
- { flags int }
- { family int }
- { socktype int }
- { protocol int }
- { addrlen socklen_t }
- { addr void* }
- { canonname char* }
- { next addrinfo* } ;
-
-STRUCT: sockaddr-in
- { family ushort }
- { port ushort }
- { addr in_addr_t }
- { unused longlong } ;
-
-STRUCT: sockaddr-in6
- { family ushort }
- { port ushort }
- { flowinfo uint }
- { addr uchar[16] }
- { scopeid uint } ;
-
-CONSTANT: max-un-path 108
-
-STRUCT: sockaddr-un
- { family ushort }
- { path { char max-un-path } } ;
-
-CONSTANT: SOCK_STREAM 1
-CONSTANT: SOCK_DGRAM 2
-
-CONSTANT: AF_UNSPEC 0
-CONSTANT: AF_UNIX 1
-CONSTANT: AF_INET 2
-CONSTANT: AF_INET6 10
-
-ALIAS: PF_UNSPEC AF_UNSPEC
-ALIAS: PF_UNIX AF_UNIX
-ALIAS: PF_INET AF_INET
-ALIAS: PF_INET6 AF_INET6
-
-CONSTANT: IPPROTO_TCP 6
-CONSTANT: IPPROTO_UDP 17
-
-CONSTANT: AI_PASSIVE 1
-
-CONSTANT: SEEK_SET 0
-CONSTANT: SEEK_CUR 1
-CONSTANT: SEEK_END 2
-
-STRUCT: passwd
- { pw_name char* }
- { pw_passwd char* }
- { pw_uid uid_t }
- { pw_gid gid_t }
- { pw_gecos char* }
- { pw_dir char* }
- { pw_shell char* } ;
-
-! dirent64
-STRUCT: dirent
- { d_ino ulonglong }
- { d_off longlong }
- { d_reclen ushort }
- { d_type uchar }
- { d_name char[256] } ;
-
-FUNCTION: int open64 ( char* path, int flags, int prot ) ;
-FUNCTION: dirent* readdir64 ( DIR* dirp ) ;
-FUNCTION: int readdir64_r ( void* dirp, dirent* entry, dirent** result ) ;
+USING: system unix unix.ffi unix.ffi.linux ;
+IN: unix.linux
M: linux open-file [ open64 ] unix-system-call ;
-
-CONSTANT: EPERM 1
-CONSTANT: ENOENT 2
-CONSTANT: ESRCH 3
-CONSTANT: EINTR 4
-CONSTANT: EIO 5
-CONSTANT: ENXIO 6
-CONSTANT: E2BIG 7
-CONSTANT: ENOEXEC 8
-CONSTANT: EBADF 9
-CONSTANT: ECHILD 10
-CONSTANT: EAGAIN 11
-CONSTANT: ENOMEM 12
-CONSTANT: EACCES 13
-CONSTANT: EFAULT 14
-CONSTANT: ENOTBLK 15
-CONSTANT: EBUSY 16
-CONSTANT: EEXIST 17
-CONSTANT: EXDEV 18
-CONSTANT: ENODEV 19
-CONSTANT: ENOTDIR 20
-CONSTANT: EISDIR 21
-CONSTANT: EINVAL 22
-CONSTANT: ENFILE 23
-CONSTANT: EMFILE 24
-CONSTANT: ENOTTY 25
-CONSTANT: ETXTBSY 26
-CONSTANT: EFBIG 27
-CONSTANT: ENOSPC 28
-CONSTANT: ESPIPE 29
-CONSTANT: EROFS 30
-CONSTANT: EMLINK 31
-CONSTANT: EPIPE 32
-CONSTANT: EDOM 33
-CONSTANT: ERANGE 34
-CONSTANT: EDEADLK 35
-CONSTANT: ENAMETOOLONG 36
-CONSTANT: ENOLCK 37
-CONSTANT: ENOSYS 38
-CONSTANT: ENOTEMPTY 39
-CONSTANT: ELOOP 40
-ALIAS: EWOULDBLOCK EAGAIN
-CONSTANT: ENOMSG 42
-CONSTANT: EIDRM 43
-CONSTANT: ECHRNG 44
-CONSTANT: EL2NSYNC 45
-CONSTANT: EL3HLT 46
-CONSTANT: EL3RST 47
-CONSTANT: ELNRNG 48
-CONSTANT: EUNATCH 49
-CONSTANT: ENOCSI 50
-CONSTANT: EL2HLT 51
-CONSTANT: EBADE 52
-CONSTANT: EBADR 53
-CONSTANT: EXFULL 54
-CONSTANT: ENOANO 55
-CONSTANT: EBADRQC 56
-CONSTANT: EBADSLT 57
-ALIAS: EDEADLOCK EDEADLK
-CONSTANT: EBFONT 59
-CONSTANT: ENOSTR 60
-CONSTANT: ENODATA 61
-CONSTANT: ETIME 62
-CONSTANT: ENOSR 63
-CONSTANT: ENONET 64
-CONSTANT: ENOPKG 65
-CONSTANT: EREMOTE 66
-CONSTANT: ENOLINK 67
-CONSTANT: EADV 68
-CONSTANT: ESRMNT 69
-CONSTANT: ECOMM 70
-CONSTANT: EPROTO 71
-CONSTANT: EMULTIHOP 72
-CONSTANT: EDOTDOT 73
-CONSTANT: EBADMSG 74
-CONSTANT: EOVERFLOW 75
-CONSTANT: ENOTUNIQ 76
-CONSTANT: EBADFD 77
-CONSTANT: EREMCHG 78
-CONSTANT: ELIBACC 79
-CONSTANT: ELIBBAD 80
-CONSTANT: ELIBSCN 81
-CONSTANT: ELIBMAX 82
-CONSTANT: ELIBEXEC 83
-CONSTANT: EILSEQ 84
-CONSTANT: ERESTART 85
-CONSTANT: ESTRPIPE 86
-CONSTANT: EUSERS 87
-CONSTANT: ENOTSOCK 88
-CONSTANT: EDESTADDRREQ 89
-CONSTANT: EMSGSIZE 90
-CONSTANT: EPROTOTYPE 91
-CONSTANT: ENOPROTOOPT 92
-CONSTANT: EPROTONOSUPPORT 93
-CONSTANT: ESOCKTNOSUPPORT 94
-CONSTANT: EOPNOTSUPP 95
-CONSTANT: EPFNOSUPPORT 96
-CONSTANT: EAFNOSUPPORT 97
-CONSTANT: EADDRINUSE 98
-CONSTANT: EADDRNOTAVAIL 99
-CONSTANT: ENETDOWN 100
-CONSTANT: ENETUNREACH 101
-CONSTANT: ENETRESET 102
-CONSTANT: ECONNABORTED 103
-CONSTANT: ECONNRESET 104
-CONSTANT: ENOBUFS 105
-CONSTANT: EISCONN 106
-CONSTANT: ENOTCONN 107
-CONSTANT: ESHUTDOWN 108
-CONSTANT: ETOOMANYREFS 109
-CONSTANT: ETIMEDOUT 110
-CONSTANT: ECONNREFUSED 111
-CONSTANT: EHOSTDOWN 112
-CONSTANT: EHOSTUNREACH 113
-CONSTANT: EALREADY 114
-CONSTANT: EINPROGRESS 115
-CONSTANT: ESTALE 116
-CONSTANT: EUCLEAN 117
-CONSTANT: ENOTNAM 118
-CONSTANT: ENAVAIL 119
-CONSTANT: EISNAM 120
-CONSTANT: EREMOTEIO 121
-CONSTANT: EDQUOT 122
-CONSTANT: ENOMEDIUM 123
-CONSTANT: EMEDIUMTYPE 124
-CONSTANT: ECANCELED 125
-CONSTANT: ENOKEY 126
-CONSTANT: EKEYEXPIRED 127
-CONSTANT: EKEYREVOKED 128
-CONSTANT: EKEYREJECTED 129
-CONSTANT: EOWNERDEAD 130
-CONSTANT: ENOTRECOVERABLE 131
+++ /dev/null
-Slava Pestov
+++ /dev/null
-! Copyright (C) 2006 Patrick Mauritz.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax system kernel layouts ;
-IN: unix
-
-! Solaris.
-
-CONSTANT: O_RDONLY HEX: 0000
-CONSTANT: O_WRONLY HEX: 0001
-CONSTANT: O_RDWR HEX: 0002
-CONSTANT: O_APPEND HEX: 0008
-CONSTANT: O_CREAT HEX: 0100
-CONSTANT: O_TRUNC HEX: 0200
-
-CONSTANT: SEEK_END 2
-
-CONSTANT: SOL_SOCKET HEX: ffff
-
-: FD_SETSIZE ( -- n ) cell 4 = 1024 65536 ? ;
-
-CONSTANT: SO_REUSEADDR 4
-CONSTANT: SO_OOBINLINE HEX: 0100
-CONSTANT: SO_SNDTIMEO HEX: 1005
-CONSTANT: SO_RCVTIMEO HEX: 1006
-
-CONSTANT: F_SETFL 4 ! set file status flags
-CONSTANT: O_NONBLOCK HEX: 80 ! no delay
-
-STRUCT: addrinfo
- { flags int }
- { family int }
- { socktype int }
- { protocol int }
-! #ifdef __sparcv9
-! int _ai_pad;
-! #endif
- { addrlen int }
- { canonname char* }
- { addr void* }
- { next void* } ;
-
-STRUCT: sockaddr-in
- { family ushort }
- { port ushort }
- { addr in_addr_t }
- { unused longlong } ;
-
-STRUCT: sockaddr-in6
- { family ushort }
- { port ushort }
- { flowinfo uint }
- { addr uchar[16] }
- { scopeid uint } ;
-
-: max-un-path 108 ;
-
-STRUCT: sockaddr-un
- { family ushort }
- { path { "char" max-un-path } } ;
-
-CONSTANT: EINTR 4
-CONSTANT: EAGAIN 11
-CONSTANT: EINPROGRESS 150
-
-CONSTANT: SOCK_STREAM 2
-CONSTANT: SOCK_DGRAM 1
-
-CONSTANT: AF_UNSPEC 0
-CONSTANT: AF_UNIX 1
-CONSTANT: AF_INET 2
-CONSTANT: AF_INET6 26
-
-ALIAS: PF_UNSPEC AF_UNSPEC
-ALIAS: PF_UNIX AF_UNIX
-ALIAS: PF_INET AF_INET
-ALIAS: PF_INET6 AF_INET6
-
-CONSTANT: IPPROTO_TCP 6
-CONSTANT: IPPROTO_UDP 17
-
-CONSTANT: AI_PASSIVE 8
+++ /dev/null
-unportable
USING: alien.c-types arrays accessors combinators classes.struct
-alien.syntax unix.time unix.types ;
+alien.syntax unix.time unix.types unix.ffi ;
IN: unix.stat
! Mac OS X
USING: alien.c-types io.encodings.utf8 io.encodings.string
kernel sequences unix.stat accessors unix combinators math
grouping system alien.strings math.bitwise alien.syntax
-unix.types classes.struct ;
+unix.types classes.struct unix.ffi ;
IN: unix.statfs.macosx
CONSTANT: MNT_RDONLY HEX: 00000001
combinators.short-circuit combinators.smart continuations
generalizations io kernel libc locals macros math namespaces
sequences stack-checker strings system unix.time unix.types
-vocabs vocabs.loader ;
+vocabs vocabs.loader unix.ffi ;
IN: unix
-CONSTANT: PROT_NONE 0
-CONSTANT: PROT_READ 1
-CONSTANT: PROT_WRITE 2
-CONSTANT: PROT_EXEC 4
-
-CONSTANT: MAP_FILE 0
-CONSTANT: MAP_SHARED 1
-CONSTANT: MAP_PRIVATE 2
-
-CONSTANT: SEEK_SET 0
-CONSTANT: SEEK_CUR 1
-CONSTANT: SEEK_END 2
-
-: MAP_FAILED ( -- alien ) -1 <alien> ; inline
-
-CONSTANT: NGROUPS_MAX 16
-
-CONSTANT: DT_UNKNOWN 0
-CONSTANT: DT_FIFO 1
-CONSTANT: DT_CHR 2
-CONSTANT: DT_DIR 4
-CONSTANT: DT_BLK 6
-CONSTANT: DT_REG 8
-CONSTANT: DT_LNK 10
-CONSTANT: DT_SOCK 12
-CONSTANT: DT_WHT 14
-
-LIBRARY: libc
-
-FUNCTION: char* strerror ( int errno ) ;
-
ERROR: unix-error errno message ;
: (io-error) ( -- * ) errno dup strerror unix-error ;
HOOK: open-file os ( path flags mode -- fd )
-<<
-
-{
- { [ os linux? ] [ "unix.linux" require ] }
- { [ os bsd? ] [ "unix.bsd" require ] }
- { [ os solaris? ] [ "unix.solaris" require ] }
-} cond
-
-"debugger" vocab [
- "unix.debugger" require
-] when
-
->>
-
-STRUCT: group
- { gr_name char* }
- { gr_passwd char* }
- { gr_gid int }
- { gr_mem char** } ;
-
-FUNCTION: int accept ( int s, void* sockaddr, socklen_t* socklen ) ;
-FUNCTION: int bind ( int s, void* name, socklen_t namelen ) ;
-FUNCTION: int chdir ( char* path ) ;
-FUNCTION: int chmod ( char* path, mode_t mode ) ;
-FUNCTION: int fchmod ( int fd, mode_t mode ) ;
-FUNCTION: int chown ( char* path, uid_t owner, gid_t group ) ;
-FUNCTION: int chroot ( char* path ) ;
-
-FUNCTION: int close ( int fd ) ;
-FUNCTION: int closedir ( DIR* dirp ) ;
-
: close-file ( fd -- ) [ close ] unix-system-call drop ;
-FUNCTION: int connect ( int s, void* name, socklen_t namelen ) ;
-FUNCTION: int dup2 ( int oldd, int newd ) ;
-! FUNCTION: int dup ( int oldd ) ;
: _exit ( status -- * )
#! We throw to give this a terminating stack effect.
int f "_exit" { int } alien-invoke "Exit failed" throw ;
-FUNCTION: void endpwent ( ) ;
-FUNCTION: int fchdir ( int fd ) ;
-FUNCTION: int fchown ( int fd, uid_t owner, gid_t group ) ;
-FUNCTION: int fcntl ( int fd, int cmd, int arg ) ;
-FUNCTION: int flock ( int fd, int operation ) ;
-FUNCTION: void freeaddrinfo ( addrinfo* ai ) ;
-FUNCTION: int futimes ( int id, timeval[2] times ) ;
-FUNCTION: char* gai_strerror ( int ecode ) ;
-FUNCTION: int getaddrinfo ( char* hostname, char* servname, addrinfo* hints, addrinfo** res ) ;
-FUNCTION: char* getcwd ( char* buf, size_t size ) ;
-FUNCTION: pid_t getpid ;
-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 ( ) ;
-FUNCTION: passwd* getpwuid ( uid_t uid ) ;
-FUNCTION: passwd* getpwnam ( char* login ) ;
-FUNCTION: int getpwnam_r ( char* login, passwd* pwd, char* buffer, size_t bufsize, passwd** result ) ;
-FUNCTION: int getgroups ( int gidsetlen, gid_t* gidset ) ;
-FUNCTION: int getgrouplist ( char* name, int basegid, int* groups, int* ngroups ) ;
-FUNCTION: int getrlimit ( int resource, rlimit* rlp ) ;
-FUNCTION: int setrlimit ( int resource, rlimit* rlp ) ;
-
-FUNCTION: int getpriority ( int which, id_t who ) ;
-FUNCTION: int setpriority ( int which, id_t who, int prio ) ;
-
-FUNCTION: int getrusage ( int who, rusage* r_usage ) ;
-
-FUNCTION: group* getgrent ;
-FUNCTION: int gethostname ( char* name, int len ) ;
-FUNCTION: int getsockname ( int socket, sockaddr* address, socklen_t* address_len ) ;
-FUNCTION: int getpeername ( int socket, sockaddr* address, socklen_t* address_len ) ;
-FUNCTION: uid_t getuid ;
-FUNCTION: uint htonl ( uint n ) ;
-FUNCTION: ushort htons ( ushort n ) ;
-! FUNCTION: int issetugid ;
-FUNCTION: int ioctl ( int fd, ulong request, char* argp ) ;
-FUNCTION: int lchown ( char* path, uid_t owner, gid_t group ) ;
-FUNCTION: int listen ( int s, int backlog ) ;
-FUNCTION: off_t lseek ( int fildes, off_t offset, int whence ) ;
-FUNCTION: int mkdir ( char* path, mode_t mode ) ;
-FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_t offset ) ;
-FUNCTION: int munmap ( void* addr, size_t len ) ;
-FUNCTION: uint ntohl ( uint n ) ;
-FUNCTION: ushort ntohs ( ushort n ) ;
-FUNCTION: int shutdown ( int fd, int how ) ;
-
-FUNCTION: int open ( char* path, int flags, int prot ) ;
M: unix open-file [ open ] unix-system-call ;
-FUNCTION: DIR* opendir ( char* path ) ;
-
-STRUCT: utimbuf
- { actime time_t }
- { modtime time_t } ;
-
-FUNCTION: int utime ( char* path, utimbuf* buf ) ;
-
: touch ( filename -- ) f [ utime ] unix-system-call drop ;
: change-file-times ( filename access modification -- )
swap >>actime
[ utime ] unix-system-call drop ;
-FUNCTION: int pclose ( void* file ) ;
-FUNCTION: int pipe ( int* filedes ) ;
-FUNCTION: void* popen ( char* command, char* type ) ;
-FUNCTION: ssize_t read ( int fd, void* buf, size_t nbytes ) ;
-
-FUNCTION: dirent* readdir ( DIR* dirp ) ;
-FUNCTION: int readdir_r ( void* dirp, dirent* entry, dirent** result ) ;
-FUNCTION: ssize_t readlink ( char* path, char* buf, size_t bufsize ) ;
-
-CONSTANT: PATH_MAX 1024
-
: read-symbolic-link ( path -- path )
PATH_MAX <byte-array> dup [
PATH_MAX
[ readlink ] unix-system-call
] dip swap head-slice >string ;
-FUNCTION: ssize_t recv ( int s, void* buf, size_t nbytes, int flags ) ;
-FUNCTION: ssize_t recvfrom ( int s, void* buf, size_t nbytes, int flags, sockaddr-in* from, socklen_t* fromlen ) ;
-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 ) ;
-FUNCTION: int setgroups ( int ngroups, gid_t* gidset ) ;
-FUNCTION: int setregid ( gid_t rgid, gid_t egid ) ;
-FUNCTION: int setreuid ( uid_t ruid, uid_t euid ) ;
-FUNCTION: int setsockopt ( int s, int level, int optname, void* optval, socklen_t optlen ) ;
-FUNCTION: int setuid ( uid_t uid ) ;
-FUNCTION: int socket ( int domain, int type, int protocol ) ;
-FUNCTION: int symlink ( char* path1, char* path2 ) ;
-FUNCTION: int link ( char* path1, char* path2 ) ;
-FUNCTION: int system ( char* command ) ;
-
-FUNCTION: int unlink ( char* path ) ;
-
: unlink-file ( path -- ) [ unlink ] unix-system-call drop ;
-FUNCTION: int utimes ( char* path, timeval[2] times ) ;
+<<
-FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ;
+"debugger" vocab [
+ "unix.debugger" require
+] when
-"librt" "librt.so" "cdecl" add-library
+>>
io.backend.unix kernel math sequences splitting strings
combinators.short-circuit grouping byte-arrays combinators
accessors math.parser fry assocs namespaces continuations
-vocabs.loader system classes.struct ;
+vocabs.loader system classes.struct unix ;
IN: unix.users
-QUALIFIED: unix
+QUALIFIED: unix.ffi
TUPLE: passwd user-name password uid gid gecos dir shell ;
} cleave ;
: with-pwent ( quot -- )
- [ unix:endpwent ] [ ] cleanup ; inline
+ [ unix.ffi:endpwent ] [ ] cleanup ; inline
PRIVATE>
: all-users ( -- seq )
[
- [ unix:getpwent dup ] [ unix:passwd memory>struct passwd>new-passwd ] produce nip
+ [ unix.ffi:getpwent dup ] [ unix.ffi:passwd memory>struct passwd>new-passwd ] produce nip
] with-pwent ;
SYMBOL: user-cache
M: integer user-passwd ( id -- passwd/f )
user-cache get
- [ at ] [ unix:getpwuid [ unix:passwd memory>struct passwd>new-passwd ] [ f ] if* ] if* ;
+ [ at ] [ unix.ffi:getpwuid [ unix.ffi:passwd memory>struct passwd>new-passwd ] [ f ] if* ] if* ;
M: string user-passwd ( string -- passwd/f )
- unix:getpwnam dup [ unix:passwd memory>struct passwd>new-passwd ] when ;
+ unix.ffi:getpwnam dup [ unix.ffi:passwd memory>struct passwd>new-passwd ] when ;
: user-name ( id -- string )
dup user-passwd
user-passwd uid>> ;
: real-user-id ( -- id )
- unix:getuid ; inline
+ unix.ffi:getuid ; inline
: real-user-name ( -- string )
real-user-id user-name ; inline
: effective-user-id ( -- id )
- unix:geteuid ; inline
+ unix.ffi:geteuid ; inline
: effective-user-name ( -- string )
effective-user-id user-name ; inline
<PRIVATE
: (set-real-user) ( id -- )
- unix:setuid unix:io-error ; inline
+ [ unix.ffi:setuid ] unix-system-call io-error ; inline
: (set-effective-user) ( id -- )
- unix:seteuid unix:io-error ; inline
+ [ unix.ffi:seteuid ] unix-system-call io-error ; inline
PRIVATE>