Skip to content

Commit acc47b2

Browse files
committed
Auto merge of #2429 - GrayJack:haiku-utmpx, r=JohnTitor
Haiku: Add the utmpx structure Add the utmpx structure like defined on the [haiku headers](https://github.com/haiku/haiku/blob/8f16317a5b6db5c672f331814273e5857555020f/headers/posix/utmpx.h#L13) > P.S. I'm participating in [Hacktoberfest 2021](https://hacktoberfest.digitalocean.com/). If this PR is up to standard and merged, I'd appreciate if the `hacktoberfest-accepted` label could be added. Thanks!
2 parents 032d105 + f6ac7ad commit acc47b2

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/unix/haiku/mod.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,63 @@ s_no_extra_traits! {
364364
__unused1: *mut ::c_void, // actually a function pointer
365365
pub sigev_notify_attributes: *mut ::pthread_attr_t,
366366
}
367+
368+
pub struct utmpx {
369+
pub ut_type: ::c_short,
370+
pub ut_tv: ::timeval,
371+
pub ut_id: [::c_char; 8],
372+
pub ut_pid: ::pid_t,
373+
pub ut_user: [::c_char; 32],
374+
pub ut_line: [::c_char; 16],
375+
pub ut_host: [::c_char; 128],
376+
__ut_reserved: [::c_char; 64],
377+
}
367378
}
368379

369380
cfg_if! {
370381
if #[cfg(feature = "extra_traits")] {
382+
impl PartialEq for utmpx {
383+
fn eq(&self, other: &utmpx) -> bool {
384+
self.ut_type == other.ut_type
385+
&& self.ut_tv == other.ut_tv
386+
&& self.ut_id == other.ut_id
387+
&& self.ut_pid == other.ut_pid
388+
&& self.ut_user == other.ut_user
389+
&& self.ut_line == other.ut_line
390+
&& self.ut_host.iter().zip(other.ut_host.iter()).all(|(a,b)| a == b)
391+
&& self.__ut_reserved == other.__ut_reserved
392+
}
393+
}
394+
395+
impl Eq for utmpx {}
396+
397+
impl ::fmt::Debug for utmpx {
398+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
399+
f.debug_struct("utmpx")
400+
.field("ut_type", &self.ut_type)
401+
.field("ut_tv", &self.ut_tv)
402+
.field("ut_id", &self.ut_id)
403+
.field("ut_pid", &self.ut_pid)
404+
.field("ut_user", &self.ut_user)
405+
.field("ut_line", &self.ut_line)
406+
.field("ut_host", &self.ut_host)
407+
.field("__ut_reserved", &self.__ut_reserved)
408+
.finish()
409+
}
410+
}
411+
412+
impl ::hash::Hash for utmpx {
413+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
414+
self.ut_type.hash(state);
415+
self.ut_tv.hash(state);
416+
self.ut_id.hash(state);
417+
self.ut_pid.hash(state);
418+
self.ut_user.hash(state);
419+
self.ut_line.hash(state);
420+
self.ut_host.hash(state);
421+
self.__ut_reserved.hash(state);
422+
}
423+
}
371424
impl PartialEq for sockaddr_un {
372425
fn eq(&self, other: &sockaddr_un) -> bool {
373426
self.sun_len == other.sun_len

0 commit comments

Comments
 (0)