mirror of
https://github.com/wader/fq.git
synced 2024-11-26 10:33:53 +03:00
8e0dde03d0
This will allow passing both cli options and format options to sub decoder. Ex: pass keylog option to a tls decoder when decoding a pcap. Ex: pass decode options to a format inside a http body inside a pcap. Add ArgAs method to lookup argument based on type. This also makes the format decode function have same signature as sub decoders in the decode API. This change decode.Format a bit: DecodeFn is now just func(d *D) any DecodeInArg renamed to DefaultInArg
37 lines
714 B
Go
37 lines
714 B
Go
package id3
|
|
|
|
import (
|
|
"github.com/wader/fq/format"
|
|
"github.com/wader/fq/pkg/decode"
|
|
"github.com/wader/fq/pkg/interp"
|
|
"github.com/wader/fq/pkg/scalar"
|
|
)
|
|
|
|
func init() {
|
|
interp.RegisterFormat(decode.Format{
|
|
Name: format.ID3V11,
|
|
Description: "ID3v1.1 metadata",
|
|
DecodeFn: id3v11Decode,
|
|
})
|
|
}
|
|
|
|
func id3v11Decode(d *decode.D) any {
|
|
d.AssertAtLeastBitsLeft(128 * 8)
|
|
d.FieldUTF8("magic", 4, d.StrAssert("TAG+"))
|
|
d.FieldUTF8("title", 60)
|
|
d.FieldUTF8("artist", 60)
|
|
d.FieldUTF8("album", 60)
|
|
d.FieldU8("speed", scalar.UintMapSymStr{
|
|
0: "unset",
|
|
1: "slow",
|
|
2: "medium",
|
|
3: "fast",
|
|
4: "hardcore",
|
|
})
|
|
d.FieldUTF8("genre", 30)
|
|
d.FieldUTF8("start", 6)
|
|
d.FieldUTF8("stop", 6)
|
|
|
|
return nil
|
|
}
|