@@ -348,6 +348,11 @@ s! {
348348 pub d_descriptor: :: c_int,
349349 pub d_id: :: door_id_t
350350 }
351+
352+ pub struct exit_status {
353+ e_termination: :: c_short,
354+ e_exit: :: c_short,
355+ }
351356}
352357
353358s_no_extra_traits ! {
@@ -357,6 +362,20 @@ s_no_extra_traits! {
357362 pub u64 : u64 ,
358363 }
359364
365+ pub struct utmpx {
366+ pub ut_user: [ :: c_char; _UTX_USERSIZE] ,
367+ pub ut_id: [ :: c_char; _UTX_IDSIZE] ,
368+ pub ut_line: [ :: c_char; _UTX_LINESIZE] ,
369+ pub ut_pid: :: pid_t,
370+ pub ut_type: :: c_short,
371+ pub ut_exit: exit_status,
372+ pub ut_tv: :: timeval,
373+ pub ut_session: :: c_int,
374+ pub ut_pad: [ :: c_int; _UTX_PADSIZE] ,
375+ pub ut_syslen: :: c_short,
376+ pub ut_host: [ :: c_char; _UTX_HOSTSIZE] ,
377+ }
378+
360379 pub struct sockaddr_un {
361380 pub sun_family: sa_family_t,
362381 pub sun_path: [ c_char; 108 ]
@@ -434,6 +453,62 @@ s_no_extra_traits! {
434453
435454cfg_if ! {
436455 if #[ cfg( feature = "extra_traits" ) ] {
456+ impl PartialEq for utmpx {
457+ fn eq( & self , other: & utmpx) -> bool {
458+ self . ut_type == other. ut_type
459+ && self . ut_pid == other. ut_pid
460+ && self . ut_user == other. ut_user
461+ && self . ut_line == other. ut_line
462+ && self . ut_id == other. ut_id
463+ && self . ut_exit == other. ut_exit
464+ && self . ut_session == other. ut_session
465+ && self . ut_tv == other. ut_tv
466+ && self . ut_syslen == other. ut_syslen
467+ && self . ut_pad == other. ut_pad
468+ && self
469+ . ut_host
470+ . iter( )
471+ . zip( other. ut_host. iter( ) )
472+ . all( |( a, b) | a == b)
473+ }
474+ }
475+
476+ impl Eq for utmpx { }
477+
478+ impl :: fmt:: Debug for utmpx {
479+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
480+ f. debug_struct( "utmpx" )
481+ . field( "ut_user" , & self . ut_user)
482+ . field( "ut_id" , & self . ut_id)
483+ . field( "ut_line" , & self . ut_line)
484+ . field( "ut_pid" , & self . ut_pid)
485+ . field( "ut_type" , & self . ut_type)
486+ . field( "ut_exit" , & self . ut_exit)
487+ . field( "ut_tv" , & self . ut_tv)
488+ . field( "ut_session" , & self . ut_session)
489+ . field( "ut_pad" , & self . ut_pad)
490+ . field( "ut_syslen" , & self . ut_syslen)
491+ . field( "ut_host" , & self . ut_host)
492+ . finish( )
493+ }
494+ }
495+
496+ impl :: hash:: Hash for utmpx {
497+ fn hash<H : :: hash:: Hasher >( & self , state: & mut H ) {
498+ self . ut_user. hash( state) ;
499+ self . ut_type. hash( state) ;
500+ self . ut_pid. hash( state) ;
501+ self . ut_line. hash( state) ;
502+ self . ut_id. hash( state) ;
503+ self . ut_host. hash( state) ;
504+ self . ut_exit. hash( state) ;
505+ self . ut_session. hash( state) ;
506+ self . ut_tv. hash( state) ;
507+ self . ut_syslen. hash( state) ;
508+ self . ut_pad. hash( state) ;
509+ }
510+ }
511+
437512 impl PartialEq for epoll_event {
438513 fn eq( & self , other: & epoll_event) -> bool {
439514 self . events == other. events
@@ -1615,6 +1690,23 @@ pub const PORT_SOURCE_FILE: ::c_int = 7;
16151690pub const PORT_SOURCE_POSTWAIT : :: c_int = 8 ;
16161691pub const PORT_SOURCE_SIGNAL : :: c_int = 9 ;
16171692
1693+ pub const _UTX_USERSIZE: usize = 32 ;
1694+ pub const _UTX_LINESIZE: usize = 32 ;
1695+ pub const _UTX_PADSIZE: usize = 5 ;
1696+ pub const _UTX_IDSIZE: usize = 4 ;
1697+ pub const _UTX_HOSTSIZE: usize = 257 ;
1698+ pub const EMPTY : :: c_short = 0 ;
1699+ pub const RUN_LVL : :: c_short = 1 ;
1700+ pub const BOOT_TIME : :: c_short = 2 ;
1701+ pub const OLD_TIME : :: c_short = 3 ;
1702+ pub const NEW_TIME : :: c_short = 4 ;
1703+ pub const INIT_PROCESS : :: c_short = 5 ;
1704+ pub const LOGIN_PROCESS : :: c_short = 6 ;
1705+ pub const USER_PROCESS : :: c_short = 7 ;
1706+ pub const DEAD_PROCESS : :: c_short = 8 ;
1707+ pub const ACCOUNTING : :: c_short = 9 ;
1708+ pub const DOWN_TIME : :: c_short = 10 ;
1709+
16181710const _TIOC: :: c_int = ( 'T' as i32 ) << 8 ;
16191711const tIOC: :: c_int = ( 't' as i32 ) << 8 ;
16201712pub const TCGETA : :: c_int = ( _TIOC | 1 ) ;
@@ -2301,6 +2393,21 @@ extern "C" {
23012393 attributes : door_attr_t ,
23022394 ) -> :: c_int ;
23032395 pub fn fattach ( fildes : :: c_int , path : * const :: c_char ) -> :: c_int ;
2396+
2397+ pub fn makeutx ( ux : * const utmpx ) -> * mut utmpx ;
2398+ pub fn modutx ( ux : * const utmpx ) -> * mut utmpx ;
2399+ pub fn updwtmpx ( file : * const :: c_char , ut : * const utmpx ) -> :: c_int ;
2400+ pub fn utmpxname ( file : * const :: c_char ) -> :: c_int ;
2401+ pub fn getutxent ( ) -> * mut utmpx ;
2402+ pub fn getutxid ( ut : * const utmpx ) -> * mut utmpx ;
2403+ pub fn getutxline ( ut : * const utmpx ) -> * mut utmpx ;
2404+ pub fn pututxline ( ut : * const utmpx ) -> * mut utmpx ;
2405+ pub fn setutxent ( ) ;
2406+ pub fn endutxent ( ) ;
2407+ // TODO: uncomment after utmp implementation
2408+ // pub fn getutmp(ux: *const utmpx, u: *mut utmp);
2409+ // pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
2410+ // pub fn updwtmp(file: *const ::c_char, u: *mut utmp);
23042411}
23052412
23062413mod compat;
0 commit comments