diff options
author | Alex Crichton <alex@alexcrichton.com> | 2016-07-28 08:51:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-28 08:51:46 -0700 |
commit | 3b4f15d5769530cb540d992f0583bca63af847ee (patch) | |
tree | cd3643eb5744215214ef88ad0c61ffed3d81ab31 | |
parent | 5066b7dcab7e700844b0e2ba71b8af9dc627a59b (diff) | |
parent | b47e554216fadb9613f4ff8ec271ecd9a5bcbc7f (diff) | |
download | rust-libc-3b4f15d5769530cb540d992f0583bca63af847ee.tar.gz |
Merge pull request #340 from knight42/utmp
Add utmpx
-rw-r--r-- | libc-test/build.rs | 7 | ||||
-rw-r--r-- | src/unix/bsd/openbsdlike/openbsd.rs | 17 | ||||
-rw-r--r-- | src/unix/notbsd/android/b32.rs | 4 | ||||
-rw-r--r-- | src/unix/notbsd/android/b64.rs | 4 | ||||
-rw-r--r-- | src/unix/notbsd/android/mod.rs | 33 | ||||
-rw-r--r-- | src/unix/notbsd/linux/other/b32/mod.rs | 44 |
6 files changed, 109 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index a0b16f234a..a9ac4fb33c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -105,6 +105,7 @@ fn main() { cfg.header("arpa/inet.h"); cfg.header("time64.h"); cfg.header("xlocale.h"); + cfg.header("utmp.h"); } else if !windows { cfg.header("glob.h"); cfg.header("ifaddrs.h"); @@ -122,6 +123,12 @@ fn main() { cfg.header("execinfo.h"); cfg.header("xlocale.h"); } + + if openbsd { + cfg.header("utmp.h"); + } else { + cfg.header("utmpx.h"); + } } } diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index b608fa5070..491ff840e8 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -137,8 +137,25 @@ s! { pub int_p_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 MS_SYNC : ::c_int = 0x0002; diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs index 91a56a3fca..bd69ccf37d 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32.rs @@ -142,6 +142,10 @@ pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2; pub const CPU_SETSIZE: ::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 { pub fn timegm64(tm: *const ::tm) -> ::time64_t; } diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64.rs index 025dabd458..b35dde4216 100644 --- a/src/unix/notbsd/android/b64.rs +++ b/src/unix/notbsd/android/b64.rs @@ -152,6 +152,10 @@ pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4; pub const CPU_SETSIZE: ::size_t = 1024; 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 { pub fn timegm(tm: *const ::tm) -> ::time64_t; } diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 5dbd39e9cf..6c6d7b087a 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -100,8 +100,37 @@ s! { pub struct sem_t { 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 FILENAME_MAX: ::c_uint = 1024; pub const FOPEN_MAX: ::c_uint = 20; @@ -591,6 +620,10 @@ extern { 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_getcpu() -> ::c_int; + + pub fn utmpname(name: *const ::c_char) -> ::c_int; + pub fn setutent(); + pub fn getutent() -> *mut utmp; } cfg_if! { diff --git a/src/unix/notbsd/linux/other/b32/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs index ba48d638b1..02542986ee 100644 --- a/src/unix/notbsd/linux/other/b32/mod.rs +++ b/src/unix/notbsd/linux/other/b32/mod.rs @@ -83,6 +83,27 @@ s! { pub mem_unit: ::c_uint, 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; @@ -97,6 +118,29 @@ pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_GETREGS: ::c_uint = 12; 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! { if #[cfg(target_arch = "x86")] { mod x86; |