unix.utmpx: Fix bootstrap on linux, add platform-specific structs.

db4
Doug Coleman 2013-06-04 18:09:52 -07:00
parent 2c6accb084
commit 10bbc244d3
8 changed files with 48 additions and 16 deletions

View File

@ -1,6 +1,7 @@
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.syntax classes.struct unix.types ;
USING: alien.c-types alien.syntax classes.struct unix.time
unix.types ;
IN: unix.ffi
CONSTANT: MAXPATHLEN 1024
@ -290,10 +291,10 @@ STRUCT: exit_status
STRUCT: utmpx
{ ut_type short }
{ ut_pid pid_t }
{ ut_line short }
{ ut_id short }
{ ut_user short }
{ ut_host short }
{ ut_line char[__UT_LINESIZE] }
{ ut_id char[4] }
{ ut_user char[__UT_NAMESIZE] }
{ ut_host char[__UT_HOSTSIZE] }
{ ut_exit exit_status }
{ ut_session long }
{ ut_tv timeval }

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,17 @@
! Copyright (C) 2013 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors calendar.unix combinators kernel system
unix.ffi unix.utmpx ;
IN: unix.utmpx.linux
M: linux utmpx>utmpx-record ( utmpx -- utmpx-record )
[ new-utmpx-record ] dip {
[ ut_user>> __UT_NAMESIZE memory>string >>user ]
[ ut_id>> 4 memory>string >>id ]
[ ut_line>> __UT_LINESIZE memory>string >>line ]
[ ut_pid>> >>pid ]
[ ut_type>> >>type ]
[ ut_tv>> timeval>unix-time >>timestamp ]
[ ut_host>> __UT_HOSTSIZE memory>string >>host ]
} cleave ;

View File

@ -0,0 +1 @@
linux

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,16 @@
! Copyright (C) 2013 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors calendar.unix combinators kernel system
unix.ffi unix.utmpx ;
IN: unix.utmpx.macosx
M: macosx utmpx>utmpx-record ( utmpx -- utmpx-record )
[ new-utmpx-record ] dip {
[ ut_user>> _UTX_USERSIZE memory>string >>user ]
[ ut_id>> _UTX_IDSIZE memory>string >>id ]
[ ut_line>> _UTX_LINESIZE memory>string >>line ]
[ ut_pid>> >>pid ]
[ ut_type>> >>type ]
[ ut_tv>> timeval>unix-time >>timestamp ]
[ ut_host>> _UTX_HOSTSIZE memory>string >>host ]
} cleave ;

View File

@ -0,0 +1 @@
macosx

View File

@ -37,17 +37,6 @@ HOOK: utmpx>utmpx-record os ( utmpx -- utmpx-record )
M: unix new-utmpx-record
utmpx-record new ;
M: unix utmpx>utmpx-record ( utmpx -- utmpx-record )
[ new-utmpx-record ] dip {
[ ut_user>> _UTX_USERSIZE memory>string >>user ]
[ ut_id>> _UTX_IDSIZE memory>string >>id ]
[ ut_line>> _UTX_LINESIZE memory>string >>line ]
[ ut_pid>> >>pid ]
[ ut_type>> >>type ]
[ ut_tv>> timeval>unix-time >>timestamp ]
[ ut_host>> _UTX_HOSTSIZE memory>string >>host ]
} cleave ;
: with-utmpx ( quot -- )
setutxent [ endutxent ] [ ] cleanup ; inline
@ -58,3 +47,8 @@ M: unix utmpx>utmpx-record ( utmpx -- utmpx-record )
[ utmpx>utmpx-record ]
produce nip
] with-utmpx ;
os {
{ macosx [ "unix.utmpx.macosx" require ] }
{ linux [ "unix.utmpx.linux" require ] }
} case