Merge pull request #340 from knight42/utmp

Add utmpx
This commit is contained in:
Alex Crichton 2016-07-28 08:51:46 -07:00 committed by GitHub
commit 3b4f15d576
6 changed files with 109 additions and 0 deletions

View File

@ -105,6 +105,7 @@ fn main() {
cfg.header("arpa/inet.h"); cfg.header("arpa/inet.h");
cfg.header("time64.h"); cfg.header("time64.h");
cfg.header("xlocale.h"); cfg.header("xlocale.h");
cfg.header("utmp.h");
} else if !windows { } else if !windows {
cfg.header("glob.h"); cfg.header("glob.h");
cfg.header("ifaddrs.h"); cfg.header("ifaddrs.h");
@ -122,6 +123,12 @@ fn main() {
cfg.header("execinfo.h"); cfg.header("execinfo.h");
cfg.header("xlocale.h"); cfg.header("xlocale.h");
} }
if openbsd {
cfg.header("utmp.h");
} else {
cfg.header("utmpx.h");
}
} }
} }

View File

@ -137,8 +137,25 @@ s! {
pub int_p_sign_posn: ::c_char, pub int_p_sign_posn: ::c_char,
pub int_n_sign_posn: ::c_char, pub int_n_sign_posn: ::c_char,
} }
pub struct lastlog {
ll_time: ::time_t,
ll_line: [::c_char; UT_LINESIZE],
ll_host: [::c_char; UT_HOSTSIZE],
}
pub struct utmp {
pub ut_line: [::c_char; UT_LINESIZE],
pub ut_name: [::c_char; UT_NAMESIZE],
pub ut_host: [::c_char; UT_HOSTSIZE],
pub ut_time: ::time_t,
}
} }
pub const UT_NAMESIZE: usize = 32;
pub const UT_LINESIZE: usize = 8;
pub const UT_HOSTSIZE: usize = 256;
pub const O_CLOEXEC: ::c_int = 0x10000; pub const O_CLOEXEC: ::c_int = 0x10000;
pub const MS_SYNC : ::c_int = 0x0002; pub const MS_SYNC : ::c_int = 0x0002;

View File

@ -142,6 +142,10 @@ pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2;
pub const CPU_SETSIZE: ::size_t = 32; pub const CPU_SETSIZE: ::size_t = 32;
pub const __CPU_BITS: ::size_t = 32; pub const __CPU_BITS: ::size_t = 32;
pub const UT_LINESIZE: usize = 8;
pub const UT_NAMESIZE: usize = 8;
pub const UT_HOSTSIZE: usize = 16;
extern { extern {
pub fn timegm64(tm: *const ::tm) -> ::time64_t; pub fn timegm64(tm: *const ::tm) -> ::time64_t;
} }

View File

@ -152,6 +152,10 @@ pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4;
pub const CPU_SETSIZE: ::size_t = 1024; pub const CPU_SETSIZE: ::size_t = 1024;
pub const __CPU_BITS: ::size_t = 64; pub const __CPU_BITS: ::size_t = 64;
pub const UT_LINESIZE: usize = 32;
pub const UT_NAMESIZE: usize = 32;
pub const UT_HOSTSIZE: usize = 256;
extern { extern {
pub fn timegm(tm: *const ::tm) -> ::time64_t; pub fn timegm(tm: *const ::tm) -> ::time64_t;
} }

View File

@ -100,8 +100,37 @@ s! {
pub struct sem_t { pub struct sem_t {
count: ::c_uint, count: ::c_uint,
} }
pub struct lastlog {
ll_time: ::time_t,
ll_line: [::c_char; UT_LINESIZE],
ll_host: [::c_char; UT_HOSTSIZE],
}
pub struct exit_status {
pub e_termination: ::c_short,
pub e_exit: ::c_short,
}
pub struct utmp {
pub ut_type: ::c_short,
pub ut_pid: ::pid_t,
pub ut_line: [::c_char; UT_LINESIZE],
pub ut_id: [::c_char; 4],
pub ut_user: [::c_char; UT_NAMESIZE],
pub ut_host: [::c_char; UT_HOSTSIZE],
pub ut_exit: exit_status,
pub ut_session: ::c_long,
pub ut_tv: ::timeval,
pub ut_addr_v6: [::int32_t; 4],
unused: [::c_char; 20],
}
} }
pub const USER_PROCESS: ::c_short = 7;
pub const BUFSIZ: ::c_uint = 1024; pub const BUFSIZ: ::c_uint = 1024;
pub const FILENAME_MAX: ::c_uint = 1024; pub const FILENAME_MAX: ::c_uint = 1024;
pub const FOPEN_MAX: ::c_uint = 20; pub const FOPEN_MAX: ::c_uint = 20;
@ -591,6 +620,10 @@ extern {
pub fn __sched_cpufree(set: *mut ::cpu_set_t); pub fn __sched_cpufree(set: *mut ::cpu_set_t);
pub fn __sched_cpucount(setsize: ::size_t, set: *mut cpu_set_t) -> ::c_int; pub fn __sched_cpucount(setsize: ::size_t, set: *mut cpu_set_t) -> ::c_int;
pub fn sched_getcpu() -> ::c_int; pub fn sched_getcpu() -> ::c_int;
pub fn utmpname(name: *const ::c_char) -> ::c_int;
pub fn setutent();
pub fn getutent() -> *mut utmp;
} }
cfg_if! { cfg_if! {

View File

@ -83,6 +83,27 @@ s! {
pub mem_unit: ::c_uint, pub mem_unit: ::c_uint,
pub _f: [::c_char; 8], pub _f: [::c_char; 8],
} }
pub struct __exit_status {
pub e_termination: ::c_short,
pub e_exit: ::c_short,
}
pub struct utmpx {
pub ut_type: ::c_short,
pub ut_pid: ::pid_t,
pub ut_line: [::c_char; __UT_LINESIZE],
pub ut_id: [::c_char; 4],
pub ut_user: [::c_char; __UT_NAMESIZE],
pub ut_host: [::c_char; __UT_HOSTSIZE],
pub ut_exit: __exit_status,
pub ut_session: ::c_long,
pub ut_tv: ::timeval,
pub ut_addr_v6: [::int32_t; 4],
__glibc_reserved: [::c_char; 20],
}
} }
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
@ -97,6 +118,29 @@ pub const PTRACE_SETFPXREGS: ::c_uint = 19;
pub const PTRACE_GETREGS: ::c_uint = 12; pub const PTRACE_GETREGS: ::c_uint = 12;
pub const PTRACE_SETREGS: ::c_uint = 13; pub const PTRACE_SETREGS: ::c_uint = 13;
pub const __UT_LINESIZE: usize = 32;
pub const __UT_NAMESIZE: usize = 32;
pub const __UT_HOSTSIZE: usize = 256;
pub const EMPTY: ::c_short = 0;
pub const RUN_LVL: ::c_short = 1;
pub const BOOT_TIME: ::c_short = 2;
pub const NEW_TIME: ::c_short = 3;
pub const OLD_TIME: ::c_short = 4;
pub const INIT_PROCESS: ::c_short = 5;
pub const LOGIN_PROCESS: ::c_short = 6;
pub const USER_PROCESS: ::c_short = 7;
pub const DEAD_PROCESS: ::c_short = 8;
pub const ACCOUNTING: ::c_short = 9;
extern {
pub fn getutxent() -> *mut utmpx;
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
pub fn setutxent();
pub fn endutxent();
}
cfg_if! { cfg_if! {
if #[cfg(target_arch = "x86")] { if #[cfg(target_arch = "x86")] {
mod x86; mod x86;