1use serde_json;
2
3use r2pipe::R2PipeSpawnOptions;
4use r2pipe::{R2Pipe, Result};
5
6fn test_trim() -> Result<()> {
7 let mut ns = R2Pipe::spawn("/bin/ls".to_owned(), None)?;
8 println!("(({}))", ns.cmd("\n\n?e hello world\n\n")?);
9 println!("(({}))", ns.cmd("\n\n?e hello world\n\n")?);
10 println!("(({}))", ns.cmd("\n\n?e hello world\n\n")?);
11 ns.close();
12 Ok(())
13}
14
15fn main() -> Result<()> {
16 test_trim()?;
17
18 let opts = R2PipeSpawnOptions {
19 exepath: "radare2".to_owned(),
20 ..Default::default()
21 };
22 let mut r2p = match R2Pipe::in_session() {
23 Some(_) => R2Pipe::open()?,
24 None => R2Pipe::spawn("/bin/ls".to_owned(), Some(opts))?,
25 };
26
27 println!("{}", r2p.cmd("?e Hello World")?);
28
29 let json = r2p.cmdj("ij")?;
30 println!("{}", serde_json::to_string_pretty(&json)?);
31 println!("ARCH {}", json["bin"]["arch"]);
32 println!("BITS {}", json["bin"]["bits"]);
33 println!("Disasm:\n{}", r2p.cmd("pd 20")?);
34 println!("Hexdump:\n{}", r2p.cmd("px 64")?);
35 r2p.close();
36
37 Ok(())
38}