Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cijiugechu/utwt
Parsing utmp file
https://github.com/cijiugechu/utwt
linux login parser rust utmp wtmp
Last synced: 8 days ago
JSON representation
Parsing utmp file
- Host: GitHub
- URL: https://github.com/cijiugechu/utwt
- Owner: cijiugechu
- License: mit
- Created: 2023-09-07T03:41:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-02T14:22:27.000Z (3 months ago)
- Last Synced: 2024-09-17T01:37:13.459Z (about 2 months ago)
- Topics: linux, login, parser, rust, utmp, wtmp
- Language: Rust
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `utwt`
[![Crates.io](https://img.shields.io/crates/v/utwt.svg)](https://crates.io/crates/utwt)
[![Docs](https://docs.rs/utwt/badge.svg)](https://docs.rs/utwt)A Rust crate for parsing `utmp` files like `/var/run/utmp` and `/var/log/wtmp`.
> Note: This project has been forked from [utmp-rs](https://github.com/upsuper/utmp-rs) since September of 2023, but a lot has changed.
## Usage
Simplest way is to use `parse_from_*` functions,
which returns a `Vec` on success:
```rust
let entries = utwt::parse_utmp()?;
// or specify a path explicitly
let entries = utwt::parse_from_path("/var/run/utmp")?;
//
```If you don't need to collect them all,
`UtmpParser` can be used as an iterator:
```rust
use utwt::UtmpParser;
for entry in UtmpParser::from_path("/var/run/utmp")? {
let entry = entry?;
// ...
}
```All the `parse_from_*` functions as well as `UtmpParser` parse `utmp` file
based on the native format for the target platform.
If cross-platform parsing is needed,
`Utmp32Parser` or `Utmp64Parser` can be used instead of `UtmpParser`.