about summary refs log tree commit diff
path: root/gifprobe
diff options
context:
space:
mode:
authorGenevieve Alfirevic <gen@nyble.dev>2022-02-11 14:13:36 -0600
committerGenevieve Alfirevic <gen@nyble.dev>2022-02-11 14:13:36 -0600
commit7a7da6b0fe15fa20ec10544fb0f0d8177dbb9ca9 (patch)
tree1cf43a4d3bb4a8d304d0de1b22623c38eb3ae708 /gifprobe
parent64dc74a04eedd550f1c72af1caa88d2b81ab70e8 (diff)
downloadgifed-7a7da6b0fe15fa20ec10544fb0f0d8177dbb9ca9.tar.gz
gifed-7a7da6b0fe15fa20ec10544fb0f0d8177dbb9ca9.zip
Start moving packed fields to their own structs
Diffstat (limited to 'gifprobe')
-rw-r--r--gifprobe/src/main.rs24
1 files changed, 22 insertions, 2 deletions
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());
+					}
+				}
 			}
 		}
 	}