interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / new / netbsd / utmpx_.rs

92 lines · 2915 bytes Raw Blame History
1//! Header: `utmpx.h`
2//!
3//! <https://github.com/NetBSD/src/blob/master/include/utmp.h>
4
5use crate::prelude::*;
6
7// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx";
8// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx";
9// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx";
10// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update";
11
12pub const _UTX_USERSIZE: usize = 32;
13pub const _UTX_LINESIZE: usize = 32;
14pub const _UTX_IDSIZE: usize = 4;
15pub const _UTX_HOSTSIZE: usize = 256;
16
17pub const EMPTY: u16 = 0;
18pub const RUN_LVL: u16 = 1;
19pub const BOOT_TIME: u16 = 2;
20pub const OLD_TIME: u16 = 3;
21pub const NEW_TIME: u16 = 4;
22pub const INIT_PROCESS: u16 = 5;
23pub const LOGIN_PROCESS: u16 = 6;
24pub const USER_PROCESS: u16 = 7;
25pub const DEAD_PROCESS: u16 = 8;
26pub const ACCOUNTING: u16 = 9;
27pub const SIGNATURE: u16 = 10;
28pub const DOWN_TIME: u16 = 11;
29
30// Expression based on the comment in NetBSD source.
31pub const _UTX_PADSIZE: usize = if cfg!(target_pointer_width = "64") {
32 36
33} else {
34 40
35};
36
37s! {
38 pub struct utmpx {
39 pub ut_name: [c_char; _UTX_USERSIZE],
40 pub ut_id: [c_char; _UTX_IDSIZE],
41 pub ut_line: [c_char; _UTX_LINESIZE],
42 pub ut_host: [c_char; _UTX_HOSTSIZE],
43 pub ut_session: u16,
44 pub ut_type: u16,
45 pub ut_pid: crate::pid_t,
46 pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported
47 pub ut_ss: crate::sockaddr_storage,
48 pub ut_tv: crate::timeval,
49 ut_pad: Padding<[u8; _UTX_PADSIZE]>,
50 }
51
52 pub struct __exit_status {
53 pub e_termination: u16,
54 pub e_exit: u16,
55 }
56
57 pub struct lastlogx {
58 pub ll_tv: crate::timeval,
59 pub ll_line: [c_char; _UTX_LINESIZE],
60 pub ll_host: [c_char; _UTX_HOSTSIZE],
61 pub ll_ss: crate::sockaddr_storage,
62 }
63}
64
65#[link(name = "util")]
66extern "C" {
67 pub fn setutxent();
68 pub fn endutxent();
69
70 #[link_name = "__getutxent50"]
71 pub fn getutxent() -> *mut utmpx;
72 #[link_name = "__getutxid50"]
73 pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
74 #[link_name = "__getutxline50"]
75 pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
76 #[link_name = "__pututxline50"]
77 pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
78
79 #[link_name = "__updwtmpx50"]
80 pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int;
81 #[link_name = "__getlastlogx50"]
82 pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx)
83 -> *mut lastlogx;
84
85 #[link_name = "__updlastlogx50"]
86 pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int;
87 #[link_name = "__getutmp50"]
88 pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp);
89 #[link_name = "__getutmpx50"]
90 pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx);
91 pub fn utmpxname(file: *const c_char) -> c_int;
92}