From 7a7da6b0fe15fa20ec10544fb0f0d8177dbb9ca9 Mon Sep 17 00:00:00 2001 From: Genevieve Alfirevic Date: Fri, 11 Feb 2022 14:13:36 -0600 Subject: Start moving packed fields to their own structs --- gifprobe/src/main.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'gifprobe') diff --git a/gifprobe/src/main.rs b/gifprobe/src/main.rs index a8e3cfd..128aae1 100644 --- a/gifprobe/src/main.rs +++ b/gifprobe/src/main.rs @@ -51,10 +51,17 @@ fn main() { Block::GraphicControlExtension(gce) => { hundreths += gce.delay() as usize; + let dispose_string = if let Some(dispose) = gce.disposal_method() { + dispose.to_string() + } else { + String::from("Reserved Value!"); + format!("Reserved: {:b}", gce.packed().disposal_method()) + }; + println!( "Graphic Control Extension\n\tDelay Time {}\n\tDispose {}", format!("{}s", gce.delay() as f32 / 100.0).yellow(), - gce.disposal_method().unwrap().yellow() + dispose_string.yellow() ) } Block::LoopingExtension(_) => todo!(), @@ -63,13 +70,26 @@ fn main() { } Block::ApplicationExtension(app) => { let auth = app.authentication_code(); + let app_ident = String::from_utf8_lossy(app.identifier()); + println!( "Application Extension\n\tIdentifier {}\n\tAuthentication {:02X} {:02X} {:02X}", - String::from_utf8_lossy(app.identifier()).yellow(), + app_ident.yellow(), auth[0].yellow(), auth[1].yellow(), auth[2].yellow() ); + + if app_ident == "NETSCAPE" { + let data = app.data(); + let looping = u16::from_le_bytes([data[0], data[1]]); + + if looping == 0 { + println!("\tLoop {}", "forever".yellow()) + } else { + println!("\tLoop {}", looping.yellow()); + } + } } } } -- cgit 1.4.1-3-g733a5