use sylpheed_formats::{pak, ui_layout}; fn main(){ let mut a=std::env::args().skip(1); let pk=a.next().unwrap(); let ar=pak::PakArchive::open(pk).unwrap(); for t in a { let i:usize=t.parse().unwrap(); let by=ar.read(&ar.entries()[i]).unwrap(); let Some(b)=ui_layout::parse_build(&by) else { continue }; let top=u32::from_be_bytes(by[8..12].try_into().unwrap()); println!("entry {i:2} TOP +08 = {top}"); let mut ks:Vec<&String>=b.records.keys().collect(); ks.sort(); for rn in ks { let &(o,s)=b.records.get(rn).unwrap(); if o+16>by.len() { continue } let magic=&by[o..o+4]; let h4=u32::from_be_bytes(by[o+4..o+8].try_into().unwrap()); let h8=u32::from_be_bytes(by[o+8..o+12].try_into().unwrap()); let maxt=ui_layout::parse_build(&by[o..o+s]) .map(|lb|lb.elements.iter().flat_map(|e|e.keyframes.iter() .filter_map(|k|k.time)).max().unwrap_or(0)).unwrap_or(0); println!(" {rn:<24} magic={:?} +04={:08x}({:.1}) +08={h8:<6} max keyframe t={maxt} ratio={:.4}", String::from_utf8_lossy(magic), h4, h4 as f64/65536.0, if maxt>0 {h8 as f64/maxt as f64} else {0.0}); } } }