1use clap::{crate_version, Command};
9use libc::c_long;
10use uucore::{error::UResult, format_usage, help_about, help_usage};
11
12const USAGE: &str = help_usage!("hostid.md");
13const ABOUT: &str = help_about!("hostid.md");
14
15extern "C" {
17 pub fn gethostid() -> c_long;
18}
19
20#[uucore::main]
21pub fn uumain(args: impl uucore::Args) -> UResult<()> {
22 uu_app().try_get_matches_from(args)?;
23 hostid();
24 Ok(())
25}
26
27pub fn uu_app() -> Command {
28 Command::new(uucore::util_name())
29 .version(crate_version!())
30 .about(ABOUT)
31 .override_usage(format_usage(USAGE))
32 .infer_long_args(true)
33}
34
35fn hostid() {
36 let mut result: c_long;
43 unsafe {
44 result = gethostid();
45 }
46
47 #[allow(overflowing_literals)]
48 let mask = 0xffff_ffff;
49
50 result &= mask;
51 println!("{result:0>8x}");
52}