unix.utmpx: Support utmpx on linux and fix on macosx. Add a unit test.

db4
Doug Coleman 2013-06-04 17:51:36 -07:00
parent d38fdb4433
commit 2c6accb084
8 changed files with 30 additions and 21 deletions

View File

@ -277,3 +277,25 @@ CONSTANT: SIGPWR 30
CONSTANT: SIGSYS 31 CONSTANT: SIGSYS 31
FUNCTION: ssize_t sendfile ( int out_fd, int in_fd, off_t* offset, size_t count ) ; FUNCTION: ssize_t sendfile ( int out_fd, int in_fd, off_t* offset, size_t count ) ;
CONSTANT: __UT_LINESIZE 32
CONSTANT: __UT_NAMESIZE 32
CONSTANT: __UT_HOSTSIZE 256
STRUCT: exit_status
{ e_termination short }
{ e_exit short } ;
STRUCT: utmpx
{ ut_type short }
{ ut_pid pid_t }
{ ut_line short }
{ ut_id short }
{ ut_user short }
{ ut_host short }
{ ut_exit exit_status }
{ ut_session long }
{ ut_tv timeval }
{ ut_addr_v6 int[4] }
{ __unused char[20] } ;

View File

@ -1 +0,0 @@
Doug Coleman

View File

@ -1,4 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: tools.test unix.utmpx.macosx ;
IN: unix.utmpx.macosx.tests

View File

@ -1,6 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax unix.ffi.macosx ;
IN: unix.utmpx.macosx
! empty

View File

@ -1 +0,0 @@
macosx

View File

@ -1 +1 @@
macosx unix

View File

@ -0,0 +1,6 @@
! Copyright (C) 2013 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel tools.test unix.utmpx ;
IN: unix.utmpx.tests
{ } [ all-utmpx drop ] unit-test

View File

@ -19,8 +19,6 @@ CONSTANT: ACCOUNTING 9
CONSTANT: SIGNATURE 10 CONSTANT: SIGNATURE 10
CONSTANT: SHUTDOWN_TIME 11 CONSTANT: SHUTDOWN_TIME 11
C-TYPE: utmpx
FUNCTION: void setutxent ( ) ; FUNCTION: void setutxent ( ) ;
FUNCTION: void endutxent ( ) ; FUNCTION: void endutxent ( ) ;
FUNCTION: utmpx* getutxent ( ) ; FUNCTION: utmpx* getutxent ( ) ;
@ -41,8 +39,7 @@ M: unix new-utmpx-record
utmpx-record new ; utmpx-record new ;
M: unix utmpx>utmpx-record ( utmpx -- utmpx-record ) M: unix utmpx>utmpx-record ( utmpx -- utmpx-record )
[ new-utmpx-record ] dip [ new-utmpx-record ] dip {
{
[ ut_user>> _UTX_USERSIZE memory>string >>user ] [ ut_user>> _UTX_USERSIZE memory>string >>user ]
[ ut_id>> _UTX_IDSIZE memory>string >>id ] [ ut_id>> _UTX_IDSIZE memory>string >>id ]
[ ut_line>> _UTX_LINESIZE memory>string >>line ] [ ut_line>> _UTX_LINESIZE memory>string >>line ]
@ -61,7 +58,3 @@ M: unix utmpx>utmpx-record ( utmpx -- utmpx-record )
[ utmpx>utmpx-record ] [ utmpx>utmpx-record ]
produce nip produce nip
] with-utmpx ; ] with-utmpx ;
os {
{ macosx [ "unix.utmpx.macosx" require ] }
} case