1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// lib.rs

//! A simplified interface to the `sysctl` system call.
//!
//! # Example: Get value
//! ```
//! # extern crate sysctl;
//! # use sysctl::Sysctl;
//! #[cfg(any(target_os = "macos", target_os = "freebsd"))]
//! const CTLNAME: &str = "kern.ostype";
//! #[cfg(any(target_os = "linux", target_os = "android"))]
//! const CTLNAME: &str = "kernel.ostype";
//!
//! let ctl = sysctl::Ctl::new(CTLNAME).unwrap();
//! let desc = ctl.description().unwrap();
//! println!("Description: {}", desc);
//! let val = ctl.value().unwrap();
//! println!("Value: {}", val);
//! // On Linux all sysctls are String type. Use the following for
//! // cross-platform compatibility:
//! let str_val = ctl.value_string().unwrap();
//! println!("String value: {}", val);
//! ```
//!
//! # Example: Get value as struct
//! ```
//! // Not available on Linux
//! # extern crate sysctl;
//! # extern crate libc;
//! # use sysctl::Sysctl;
//! #[derive(Debug, Default)]
//! #[repr(C)]
//! struct ClockInfo {
//!     hz: libc::c_int, /* clock frequency */
//!     tick: libc::c_int, /* micro-seconds per hz tick */
//!     spare: libc::c_int,
//!     stathz: libc::c_int, /* statistics clock frequency */
//!     profhz: libc::c_int, /* profiling clock frequency */
//! }
//! # #[cfg(any(target_os = "macos", target_os = "freebsd"))]
//! let val: Box<ClockInfo> = sysctl::Ctl::new("kern.clockrate").unwrap().value_as().unwrap();
//! # #[cfg(any(target_os = "macos", target_os = "freebsd"))]
//! println!("{:?}", val);
//! ```

#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate failure;
extern crate byteorder;
extern crate libc;

#[cfg(any(target_os = "android", target_os = "linux"))]
extern crate walkdir;

#[cfg(any(target_os = "android", target_os = "linux"))]
#[path = "linux/mod.rs"]
mod sys;

#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[path = "unix/mod.rs"]
mod sys;

mod consts;
mod ctl_error;
mod ctl_flags;
mod ctl_info;
mod ctl_type;
mod ctl_value;
#[cfg(target_os = "freebsd")]
mod temperature;
mod traits;

pub use consts::*;
pub use ctl_error::*;
pub use ctl_flags::*;
pub use ctl_info::*;
pub use ctl_type::*;
pub use ctl_value::*;
pub use sys::ctl::*;
pub use sys::ctl_iter::*;
#[cfg(target_os = "freebsd")]
pub use temperature::Temperature;
pub use traits::Sysctl;