1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types alien.data alien.syntax
4 continuations io.encodings.string io.encodings.utf8 kernel
5 sequences system unix.ffi vocabs ;
13 CONSTANT: INIT_PROCESS 5
14 CONSTANT: LOGIN_PROCESS 6
15 CONSTANT: USER_PROCESS 7
16 CONSTANT: DEAD_PROCESS 8
17 CONSTANT: ACCOUNTING 9
18 CONSTANT: SIGNATURE 10
19 CONSTANT: SHUTDOWN_TIME 11
21 FUNCTION: void setutxent ( )
22 FUNCTION: void endutxent ( )
23 FUNCTION: utmpx* getutxent ( )
24 FUNCTION: utmpx* getutxid ( utmpx* id )
25 FUNCTION: utmpx* getutxline ( utmpx* line )
26 FUNCTION: utmpx* pututxline ( utmpx* utx )
28 TUPLE: utmpx-record user id line pid type timestamp host ;
30 HOOK: new-utmpx-record os ( -- utmpx-record )
32 HOOK: utmpx>utmpx-record os ( utmpx -- utmpx-record )
34 : memory>string ( alien n -- string )
35 memory>byte-array utf8 decode [ 0 = ] trim-tail ;
37 M: unix new-utmpx-record
40 : with-utmpx ( quot -- )
41 setutxent [ endutxent ] [ ] cleanup ; inline
43 : all-utmpx ( -- seq )
46 [ utmpx>utmpx-record ]
50 "unix.utmpx." os name>> append require