mirror of
https://github.com/wader/fq.git
synced 2024-12-23 13:22:58 +03:00
parent
ece2fd78ec
commit
a6bf62ce19
@ -104,7 +104,7 @@ go run fq.go
|
|||||||
|
|
||||||
[./formats_list.jq]: sh-start
|
[./formats_list.jq]: sh-start
|
||||||
|
|
||||||
aac_frame, adts, adts_frame, apev2, ar, av1_ccr, av1_frame, av1_obu, avc_annexb, avc_au, avc_dcr, avc_nalu, avc_pps, avc_sei, avc_sps, bencode, bsd_loopback_frame, bson, bzip2, dns, dns_tcp, elf, ether8023_frame, exif, flac, flac_frame, flac_metadatablock, flac_metadatablocks, flac_picture, flac_streaminfo, gif, gzip, hevc_annexb, hevc_au, hevc_dcr, hevc_nalu, icc_profile, icmp, id3v1, id3v11, id3v2, ipv4_packet, jpeg, json, matroska, mp3, mp3_frame, mp4, mpeg_asc, mpeg_es, mpeg_pes, mpeg_pes_packet, mpeg_spu, mpeg_ts, ogg, ogg_page, opus_packet, pcap, pcapng, png, protobuf, protobuf_widevine, pssh_playready, raw, sll2_packet, sll_packet, tar, tcp_segment, tiff, udp_datagram, vorbis_comment, vorbis_packet, vp8_frame, vp9_cfm, vp9_frame, vpx_ccr, wav, webp, xing, zip
|
aac_frame, adts, adts_frame, apev2, ar, av1_ccr, av1_frame, av1_obu, avc_annexb, avc_au, avc_dcr, avc_nalu, avc_pps, avc_sei, avc_sps, bencode, bsd_loopback_frame, bson, bzip2, dns, dns_tcp, elf, ether8023_frame, exif, flac, flac_frame, flac_metadatablock, flac_metadatablocks, flac_picture, flac_streaminfo, gif, gzip, hevc_annexb, hevc_au, hevc_dcr, hevc_nalu, icc_profile, icmp, id3v1, id3v11, id3v2, ipv4_packet, jpeg, json, matroska, mp3, mp3_frame, mp4, mpeg_asc, mpeg_es, mpeg_pes, mpeg_pes_packet, mpeg_spu, mpeg_ts, msgpack, ogg, ogg_page, opus_packet, pcap, pcapng, png, protobuf, protobuf_widevine, pssh_playready, raw, sll2_packet, sll_packet, tar, tcp_segment, tiff, udp_datagram, vorbis_comment, vorbis_packet, vp8_frame, vp9_cfm, vp9_frame, vpx_ccr, wav, webp, xing, zip
|
||||||
|
|
||||||
[#]: sh-end
|
[#]: sh-end
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
|`mpeg_pes_packet` |MPEG Packetized elementary stream packet |<sub></sub>|
|
|`mpeg_pes_packet` |MPEG Packetized elementary stream packet |<sub></sub>|
|
||||||
|`mpeg_spu` |Sub Picture Unit (DVD subtitle) |<sub></sub>|
|
|`mpeg_spu` |Sub Picture Unit (DVD subtitle) |<sub></sub>|
|
||||||
|`mpeg_ts` |MPEG Transport Stream |<sub></sub>|
|
|`mpeg_ts` |MPEG Transport Stream |<sub></sub>|
|
||||||
|
|`msgpack` |MessagePack |<sub></sub>|
|
||||||
|`ogg` |OGG file |<sub>`ogg_page` `vorbis_packet` `opus_packet` `flac_metadatablock` `flac_frame`</sub>|
|
|`ogg` |OGG file |<sub>`ogg_page` `vorbis_packet` `opus_packet` `flac_metadatablock` `flac_frame`</sub>|
|
||||||
|`ogg_page` |OGG page |<sub></sub>|
|
|`ogg_page` |OGG page |<sub></sub>|
|
||||||
|`opus_packet` |Opus packet |<sub>`vorbis_comment`</sub>|
|
|`opus_packet` |Opus packet |<sub>`vorbis_comment`</sub>|
|
||||||
|
@ -1586,11 +1586,17 @@
|
|||||||
<polygon fill="paleturquoise" stroke="transparent" points="2464.5,-1539 2464.5,-1558 2511.5,-1558 2511.5,-1539 2464.5,-1539"/>
|
<polygon fill="paleturquoise" stroke="transparent" points="2464.5,-1539 2464.5,-1558 2511.5,-1558 2511.5,-1539 2464.5,-1539"/>
|
||||||
<text text-anchor="start" x="2467" y="-1544.3" font-family="Times,serif" font-size="14.00">dns_tcp</text>
|
<text text-anchor="start" x="2467" y="-1544.3" font-family="Times,serif" font-size="14.00">dns_tcp</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- raw -->
|
<!-- msgpack -->
|
||||||
<g id="node85" class="node">
|
<g id="node85" class="node">
|
||||||
|
<title>msgpack</title>
|
||||||
|
<polygon fill="paleturquoise" stroke="transparent" points="2545.5,-1539 2545.5,-1558 2598.5,-1558 2598.5,-1539 2545.5,-1539"/>
|
||||||
|
<text text-anchor="start" x="2548" y="-1544.3" font-family="Times,serif" font-size="14.00">msgpack</text>
|
||||||
|
</g>
|
||||||
|
<!-- raw -->
|
||||||
|
<g id="node86" class="node">
|
||||||
<title>raw</title>
|
<title>raw</title>
|
||||||
<polygon fill="paleturquoise" stroke="transparent" points="2552.5,-1539 2552.5,-1558 2577.5,-1558 2577.5,-1539 2552.5,-1539"/>
|
<polygon fill="paleturquoise" stroke="transparent" points="2639.5,-1539 2639.5,-1558 2664.5,-1558 2664.5,-1539 2639.5,-1539"/>
|
||||||
<text text-anchor="start" x="2555" y="-1544.3" font-family="Times,serif" font-size="14.00">raw</text>
|
<text text-anchor="start" x="2642" y="-1544.3" font-family="Times,serif" font-size="14.00">raw</text>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 102 KiB |
@ -23,6 +23,7 @@ import (
|
|||||||
_ "github.com/wader/fq/format/mp3"
|
_ "github.com/wader/fq/format/mp3"
|
||||||
_ "github.com/wader/fq/format/mp4"
|
_ "github.com/wader/fq/format/mp4"
|
||||||
_ "github.com/wader/fq/format/mpeg"
|
_ "github.com/wader/fq/format/mpeg"
|
||||||
|
_ "github.com/wader/fq/format/msgpack"
|
||||||
_ "github.com/wader/fq/format/ogg"
|
_ "github.com/wader/fq/format/ogg"
|
||||||
_ "github.com/wader/fq/format/opus"
|
_ "github.com/wader/fq/format/opus"
|
||||||
_ "github.com/wader/fq/format/pcap"
|
_ "github.com/wader/fq/format/pcap"
|
||||||
|
@ -74,6 +74,7 @@ const (
|
|||||||
MPEG_PES_PACKET = "mpeg_pes_packet"
|
MPEG_PES_PACKET = "mpeg_pes_packet"
|
||||||
MPEG_SPU = "mpeg_spu"
|
MPEG_SPU = "mpeg_spu"
|
||||||
MPEG_TS = "mpeg_ts"
|
MPEG_TS = "mpeg_ts"
|
||||||
|
MSGPACK = "msgpack"
|
||||||
OGG = "ogg"
|
OGG = "ogg"
|
||||||
OGG_PAGE = "ogg_page"
|
OGG_PAGE = "ogg_page"
|
||||||
OPUS_PACKET = "opus_packet"
|
OPUS_PACKET = "opus_packet"
|
||||||
|
158
format/msgpack/msgpack.go
Normal file
158
format/msgpack/msgpack.go
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
package msgpack
|
||||||
|
|
||||||
|
// https://github.com/msgpack/msgpack/blob/master/spec.md
|
||||||
|
|
||||||
|
// TODO: ext types done correctly?
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
|
||||||
|
"github.com/wader/fq/format"
|
||||||
|
"github.com/wader/fq/format/registry"
|
||||||
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/scalar"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed *.jq
|
||||||
|
var msgPackFS embed.FS
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registry.MustRegister(decode.Format{
|
||||||
|
Name: format.MSGPACK,
|
||||||
|
Description: "MessagePack",
|
||||||
|
DecodeFn: decodeMsgPack,
|
||||||
|
Files: msgPackFS,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type formatEntry struct {
|
||||||
|
r [2]byte
|
||||||
|
s scalar.S
|
||||||
|
d func(d *decode.D)
|
||||||
|
}
|
||||||
|
|
||||||
|
type formatEntries []formatEntry
|
||||||
|
|
||||||
|
func (fes formatEntries) lookup(u byte) (formatEntry, bool) {
|
||||||
|
for _, fe := range fes {
|
||||||
|
if u >= fe.r[0] && u <= fe.r[1] {
|
||||||
|
return fe, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return formatEntry{}, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fes formatEntries) MapScalar(s scalar.S) (scalar.S, error) {
|
||||||
|
u := s.ActualU()
|
||||||
|
if fe, ok := fes.lookup(byte(u)); ok {
|
||||||
|
s = fe.s
|
||||||
|
s.Actual = u
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeMsgPackValue(d *decode.D) {
|
||||||
|
arrayFn := func(seekBits int64, lengthBits int) func(d *decode.D) {
|
||||||
|
return func(d *decode.D) {
|
||||||
|
d.SeekRel(seekBits)
|
||||||
|
length := d.FieldU("length", lengthBits)
|
||||||
|
d.FieldArray("elements", func(d *decode.D) {
|
||||||
|
for i := uint64(0); i < length; i++ {
|
||||||
|
d.FieldStruct("element", decodeMsgPackValue)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapFn := func(seekBits int64, lengthBits int) func(d *decode.D) {
|
||||||
|
return func(d *decode.D) {
|
||||||
|
d.SeekRel(seekBits)
|
||||||
|
length := d.FieldU("length", lengthBits)
|
||||||
|
d.FieldArray("pairs", func(d *decode.D) {
|
||||||
|
for i := uint64(0); i < length; i++ {
|
||||||
|
d.FieldStruct("pair", func(d *decode.D) {
|
||||||
|
d.FieldStruct("key", decodeMsgPackValue)
|
||||||
|
d.FieldStruct("value", decodeMsgPackValue)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
extFn := func(lengthBits int) func(d *decode.D) {
|
||||||
|
return func(d *decode.D) {
|
||||||
|
length := d.FieldU8("length")
|
||||||
|
d.FieldS8("fixtype")
|
||||||
|
d.FieldRawLen("value", int64(length)*8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// is defined here as a global map would cause a init dependency cycle
|
||||||
|
formatMap := formatEntries{
|
||||||
|
{r: [2]byte{0x00, 0x7f}, s: scalar.S{Sym: "positive_fixint"}, d: func(d *decode.D) {
|
||||||
|
d.SeekRel(-8)
|
||||||
|
d.FieldU8("value")
|
||||||
|
}},
|
||||||
|
{r: [2]byte{0x80, 0x8f}, s: scalar.S{Sym: "fixmap"}, d: mapFn(-4, 4)},
|
||||||
|
{r: [2]byte{0x90, 0x9f}, s: scalar.S{Sym: "fixarray"}, d: arrayFn(-4, 4)},
|
||||||
|
{r: [2]byte{0xa0, 0xbf}, s: scalar.S{Sym: "fixstr"}, d: func(d *decode.D) {
|
||||||
|
d.SeekRel(-4)
|
||||||
|
length := d.FieldU4("length")
|
||||||
|
d.FieldUTF8("value", int(length))
|
||||||
|
}},
|
||||||
|
{r: [2]byte{0xc0, 0xc0}, s: scalar.S{Sym: "nil"}, d: func(d *decode.D) {
|
||||||
|
// TODO: fq has no good null type atm
|
||||||
|
}},
|
||||||
|
{r: [2]byte{0xc1, 0xc1}, s: scalar.S{Sym: "never_used"}, d: func(d *decode.D) {
|
||||||
|
d.Fatalf("0xc1 never used")
|
||||||
|
}},
|
||||||
|
{r: [2]byte{0xc2, 0xc2}, s: scalar.S{Sym: "false"}, d: func(d *decode.D) {
|
||||||
|
d.FieldValueBool("value", false)
|
||||||
|
}},
|
||||||
|
{r: [2]byte{0xc3, 0xc3}, s: scalar.S{Sym: "true"}, d: func(d *decode.D) {
|
||||||
|
d.FieldValueBool("value", true)
|
||||||
|
}},
|
||||||
|
{r: [2]byte{0xc4, 0xc4}, s: scalar.S{Sym: "bin8"}, d: func(d *decode.D) { d.FieldRawLen("value", int64(d.FieldU8("length"))*8) }},
|
||||||
|
{r: [2]byte{0xc5, 0xc5}, s: scalar.S{Sym: "bin16"}, d: func(d *decode.D) { d.FieldRawLen("value", int64(d.FieldU16("length"))*8) }},
|
||||||
|
{r: [2]byte{0xc6, 0xc6}, s: scalar.S{Sym: "bin32"}, d: func(d *decode.D) { d.FieldRawLen("value", int64(d.FieldU32("length"))*8) }},
|
||||||
|
{r: [2]byte{0xc7, 0xc7}, s: scalar.S{Sym: "ext8"}, d: extFn(8)},
|
||||||
|
{r: [2]byte{0xc8, 0xc8}, s: scalar.S{Sym: "ext16"}, d: extFn(16)},
|
||||||
|
{r: [2]byte{0xc9, 0xc9}, s: scalar.S{Sym: "ext32"}, d: extFn(32)},
|
||||||
|
{r: [2]byte{0xca, 0xca}, s: scalar.S{Sym: "float32"}, d: func(d *decode.D) { d.FieldF32("value") }},
|
||||||
|
{r: [2]byte{0xcb, 0xcb}, s: scalar.S{Sym: "float64"}, d: func(d *decode.D) { d.FieldF64("value") }},
|
||||||
|
{r: [2]byte{0xcc, 0xcc}, s: scalar.S{Sym: "uint8"}, d: func(d *decode.D) { d.FieldU8("value") }},
|
||||||
|
{r: [2]byte{0xcd, 0xcd}, s: scalar.S{Sym: "uint16"}, d: func(d *decode.D) { d.FieldU16("value") }},
|
||||||
|
{r: [2]byte{0xce, 0xce}, s: scalar.S{Sym: "uint32"}, d: func(d *decode.D) { d.FieldU32("value") }},
|
||||||
|
{r: [2]byte{0xcf, 0xcf}, s: scalar.S{Sym: "uint64"}, d: func(d *decode.D) { d.FieldU64("value") }},
|
||||||
|
{r: [2]byte{0xd0, 0xd0}, s: scalar.S{Sym: "int8"}, d: func(d *decode.D) { d.FieldS8("value") }},
|
||||||
|
{r: [2]byte{0xd1, 0xd1}, s: scalar.S{Sym: "int16"}, d: func(d *decode.D) { d.FieldS16("value") }},
|
||||||
|
{r: [2]byte{0xd2, 0xd2}, s: scalar.S{Sym: "int32"}, d: func(d *decode.D) { d.FieldS32("value") }},
|
||||||
|
{r: [2]byte{0xd3, 0xd3}, s: scalar.S{Sym: "int64"}, d: func(d *decode.D) { d.FieldS64("value") }},
|
||||||
|
{r: [2]byte{0xd4, 0xd4}, s: scalar.S{Sym: "fixext1"}, d: func(d *decode.D) { d.FieldS8("fixtype"); d.FieldRawLen("value", 1*8) }},
|
||||||
|
{r: [2]byte{0xd5, 0xd5}, s: scalar.S{Sym: "fixext2"}, d: func(d *decode.D) { d.FieldS8("fixtype"); d.FieldRawLen("value", 2*8) }},
|
||||||
|
{r: [2]byte{0xd6, 0xd6}, s: scalar.S{Sym: "fixext4"}, d: func(d *decode.D) { d.FieldS8("fixtype"); d.FieldRawLen("value", 4*8) }},
|
||||||
|
{r: [2]byte{0xd7, 0xd7}, s: scalar.S{Sym: "fixext8"}, d: func(d *decode.D) { d.FieldS8("fixtype"); d.FieldRawLen("value", 8*8) }},
|
||||||
|
{r: [2]byte{0xd8, 0xd8}, s: scalar.S{Sym: "fixext16"}, d: func(d *decode.D) { d.FieldS8("fixtype"); d.FieldRawLen("value", 16*8) }},
|
||||||
|
{r: [2]byte{0xd9, 0xd9}, s: scalar.S{Sym: "str8"}, d: func(d *decode.D) { d.FieldUTF8("value", int(d.FieldU8("length"))) }},
|
||||||
|
{r: [2]byte{0xda, 0xda}, s: scalar.S{Sym: "str16"}, d: func(d *decode.D) { d.FieldUTF8("value", int(d.FieldU16("length"))) }},
|
||||||
|
{r: [2]byte{0xdb, 0xdb}, s: scalar.S{Sym: "str32"}, d: func(d *decode.D) { d.FieldUTF8("value", int(d.FieldU32("length"))) }},
|
||||||
|
{r: [2]byte{0xdc, 0xdc}, s: scalar.S{Sym: "array16"}, d: arrayFn(0, 16)},
|
||||||
|
{r: [2]byte{0xdd, 0xdd}, s: scalar.S{Sym: "array32"}, d: arrayFn(0, 32)},
|
||||||
|
{r: [2]byte{0xde, 0xde}, s: scalar.S{Sym: "map16"}, d: mapFn(0, 16)},
|
||||||
|
{r: [2]byte{0xdf, 0xdf}, s: scalar.S{Sym: "map32"}, d: mapFn(0, 32)},
|
||||||
|
{r: [2]byte{0xe0, 0xff}, s: scalar.S{Sym: "negative_fixint"}, d: func(d *decode.D) {
|
||||||
|
d.SeekRel(-8)
|
||||||
|
d.FieldS8("value")
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
typ := d.FieldU8("type", formatMap, scalar.Hex)
|
||||||
|
if fe, ok := formatMap.lookup(byte(typ)); ok {
|
||||||
|
fe.d(d)
|
||||||
|
} else {
|
||||||
|
panic("unreachable")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeMsgPack(d *decode.D, in interface{}) interface{} {
|
||||||
|
decodeMsgPackValue(d)
|
||||||
|
return nil
|
||||||
|
}
|
13
format/msgpack/msgpack.jq
Normal file
13
format/msgpack/msgpack.jq
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
def msgpack_torepr:
|
||||||
|
def _f:
|
||||||
|
( if .type | . == "fixmap" or . == "map16" or . == "map32" then
|
||||||
|
( .pairs
|
||||||
|
| map({key: (.key | _f), value: (.value | _f)})
|
||||||
|
| from_entries
|
||||||
|
)
|
||||||
|
elif .type | . == "fixarray" or . == "array16" or . == "array32" then .elements | map(_f)
|
||||||
|
elif .type | . == "bin8" or . == "bin16" or . == "bin32" then .value | tostring
|
||||||
|
else .value
|
||||||
|
end
|
||||||
|
);
|
||||||
|
_f;
|
114
format/msgpack/testdata/ints.fqtest
vendored
Normal file
114
format/msgpack/testdata/ints.fqtest
vendored
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
# fq -n '[0,1,2,3,4,5,6,7,8,9,127,128,-1,-2,-3,-4,-5,-6,-7,-8,-31,-32,0xffff_ffff,-0xffff_ffff,0x7fff_ffff,-0x7fff_ffff]' | json2msgpack > ints.msgpack
|
||||||
|
$ fq -d msgpack v ints.msgpack
|
||||||
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: ints.msgpack (msgpack) 0x0-0x31.7 (50)
|
||||||
|
0x00|dc |. | type: "array16" (0xdc) 0x0-0x0.7 (1)
|
||||||
|
0x00| 00 1a | .. | length: 26 0x1-0x2.7 (2)
|
||||||
|
| | | elements[0:26]: 0x3-0x31.7 (47)
|
||||||
|
| | | [0]{}: element 0x3-0x3.7 (1)
|
||||||
|
0x00| 00 | . | type: "positive_fixint" (0x0) 0x3-0x3.7 (1)
|
||||||
|
0x00| 00 | . | value: 0 0x3-0x3.7 (1)
|
||||||
|
| | | [1]{}: element 0x4-0x4.7 (1)
|
||||||
|
0x00| 01 | . | type: "positive_fixint" (0x1) 0x4-0x4.7 (1)
|
||||||
|
0x00| 01 | . | value: 1 0x4-0x4.7 (1)
|
||||||
|
| | | [2]{}: element 0x5-0x5.7 (1)
|
||||||
|
0x00| 02 | . | type: "positive_fixint" (0x2) 0x5-0x5.7 (1)
|
||||||
|
0x00| 02 | . | value: 2 0x5-0x5.7 (1)
|
||||||
|
| | | [3]{}: element 0x6-0x6.7 (1)
|
||||||
|
0x00| 03 | . | type: "positive_fixint" (0x3) 0x6-0x6.7 (1)
|
||||||
|
0x00| 03 | . | value: 3 0x6-0x6.7 (1)
|
||||||
|
| | | [4]{}: element 0x7-0x7.7 (1)
|
||||||
|
0x00| 04 | . | type: "positive_fixint" (0x4) 0x7-0x7.7 (1)
|
||||||
|
0x00| 04 | . | value: 4 0x7-0x7.7 (1)
|
||||||
|
| | | [5]{}: element 0x8-0x8.7 (1)
|
||||||
|
0x00| 05 | . | type: "positive_fixint" (0x5) 0x8-0x8.7 (1)
|
||||||
|
0x00| 05 | . | value: 5 0x8-0x8.7 (1)
|
||||||
|
| | | [6]{}: element 0x9-0x9.7 (1)
|
||||||
|
0x00| 06 | . | type: "positive_fixint" (0x6) 0x9-0x9.7 (1)
|
||||||
|
0x00| 06 | . | value: 6 0x9-0x9.7 (1)
|
||||||
|
| | | [7]{}: element 0xa-0xa.7 (1)
|
||||||
|
0x00| 07 | . | type: "positive_fixint" (0x7) 0xa-0xa.7 (1)
|
||||||
|
0x00| 07 | . | value: 7 0xa-0xa.7 (1)
|
||||||
|
| | | [8]{}: element 0xb-0xb.7 (1)
|
||||||
|
0x00| 08 | . | type: "positive_fixint" (0x8) 0xb-0xb.7 (1)
|
||||||
|
0x00| 08 | . | value: 8 0xb-0xb.7 (1)
|
||||||
|
| | | [9]{}: element 0xc-0xc.7 (1)
|
||||||
|
0x00| 09 | . | type: "positive_fixint" (0x9) 0xc-0xc.7 (1)
|
||||||
|
0x00| 09 | . | value: 9 0xc-0xc.7 (1)
|
||||||
|
| | | [10]{}: element 0xd-0xd.7 (1)
|
||||||
|
0x00| 7f | . | type: "positive_fixint" (0x7f) 0xd-0xd.7 (1)
|
||||||
|
0x00| 7f | . | value: 127 0xd-0xd.7 (1)
|
||||||
|
| | | [11]{}: element 0xe-0xf.7 (2)
|
||||||
|
0x00| cc | . | type: "uint8" (0xcc) 0xe-0xe.7 (1)
|
||||||
|
0x00| 80| .| value: 128 0xf-0xf.7 (1)
|
||||||
|
| | | [12]{}: element 0x10-0x10.7 (1)
|
||||||
|
0x10|ff |. | type: "negative_fixint" (0xff) 0x10-0x10.7 (1)
|
||||||
|
0x10|ff |. | value: -1 0x10-0x10.7 (1)
|
||||||
|
| | | [13]{}: element 0x11-0x11.7 (1)
|
||||||
|
0x10| fe | . | type: "negative_fixint" (0xfe) 0x11-0x11.7 (1)
|
||||||
|
0x10| fe | . | value: -2 0x11-0x11.7 (1)
|
||||||
|
| | | [14]{}: element 0x12-0x12.7 (1)
|
||||||
|
0x10| fd | . | type: "negative_fixint" (0xfd) 0x12-0x12.7 (1)
|
||||||
|
0x10| fd | . | value: -3 0x12-0x12.7 (1)
|
||||||
|
| | | [15]{}: element 0x13-0x13.7 (1)
|
||||||
|
0x10| fc | . | type: "negative_fixint" (0xfc) 0x13-0x13.7 (1)
|
||||||
|
0x10| fc | . | value: -4 0x13-0x13.7 (1)
|
||||||
|
| | | [16]{}: element 0x14-0x14.7 (1)
|
||||||
|
0x10| fb | . | type: "negative_fixint" (0xfb) 0x14-0x14.7 (1)
|
||||||
|
0x10| fb | . | value: -5 0x14-0x14.7 (1)
|
||||||
|
| | | [17]{}: element 0x15-0x15.7 (1)
|
||||||
|
0x10| fa | . | type: "negative_fixint" (0xfa) 0x15-0x15.7 (1)
|
||||||
|
0x10| fa | . | value: -6 0x15-0x15.7 (1)
|
||||||
|
| | | [18]{}: element 0x16-0x16.7 (1)
|
||||||
|
0x10| f9 | . | type: "negative_fixint" (0xf9) 0x16-0x16.7 (1)
|
||||||
|
0x10| f9 | . | value: -7 0x16-0x16.7 (1)
|
||||||
|
| | | [19]{}: element 0x17-0x17.7 (1)
|
||||||
|
0x10| f8 | . | type: "negative_fixint" (0xf8) 0x17-0x17.7 (1)
|
||||||
|
0x10| f8 | . | value: -8 0x17-0x17.7 (1)
|
||||||
|
| | | [20]{}: element 0x18-0x18.7 (1)
|
||||||
|
0x10| e1 | . | type: "negative_fixint" (0xe1) 0x18-0x18.7 (1)
|
||||||
|
0x10| e1 | . | value: -31 0x18-0x18.7 (1)
|
||||||
|
| | | [21]{}: element 0x19-0x19.7 (1)
|
||||||
|
0x10| e0 | . | type: "negative_fixint" (0xe0) 0x19-0x19.7 (1)
|
||||||
|
0x10| e0 | . | value: -32 0x19-0x19.7 (1)
|
||||||
|
| | | [22]{}: element 0x1a-0x1e.7 (5)
|
||||||
|
0x10| ce | . | type: "uint32" (0xce) 0x1a-0x1a.7 (1)
|
||||||
|
0x10| ff ff ff ff | .... | value: 4294967295 0x1b-0x1e.7 (4)
|
||||||
|
| | | [23]{}: element 0x1f-0x27.7 (9)
|
||||||
|
0x10| d3| .| type: "int64" (0xd3) 0x1f-0x1f.7 (1)
|
||||||
|
0x20|ff ff ff ff 00 00 00 01 |........ | value: -4294967295 0x20-0x27.7 (8)
|
||||||
|
| | | [24]{}: element 0x28-0x2c.7 (5)
|
||||||
|
0x20| ce | . | type: "uint32" (0xce) 0x28-0x28.7 (1)
|
||||||
|
0x20| 7f ff ff ff | .... | value: 2147483647 0x29-0x2c.7 (4)
|
||||||
|
| | | [25]{}: element 0x2d-0x31.7 (5)
|
||||||
|
0x20| d2 | . | type: "int32" (0xd2) 0x2d-0x2d.7 (1)
|
||||||
|
0x20| 80 00| ..| value: -2147483647 0x2e-0x31.7 (4)
|
||||||
|
0x30|00 01| |..| |
|
||||||
|
$ fq -d msgpack msgpack_torepr ints.msgpack
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
127,
|
||||||
|
128,
|
||||||
|
-1,
|
||||||
|
-2,
|
||||||
|
-3,
|
||||||
|
-4,
|
||||||
|
-5,
|
||||||
|
-6,
|
||||||
|
-7,
|
||||||
|
-8,
|
||||||
|
-31,
|
||||||
|
-32,
|
||||||
|
4294967295,
|
||||||
|
-4294967295,
|
||||||
|
2147483647,
|
||||||
|
-2147483647
|
||||||
|
]
|
BIN
format/msgpack/testdata/ints.msgpack
vendored
Normal file
BIN
format/msgpack/testdata/ints.msgpack
vendored
Normal file
Binary file not shown.
102
format/msgpack/testdata/test.fqtest
vendored
Normal file
102
format/msgpack/testdata/test.fqtest
vendored
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# msgpack-tools
|
||||||
|
# echo '{"array": [1,2,3], "object": {"key": "value"}, "number": 123, "string": "abc", "true": true, "false": false, "null": null}' | json2msgpack > test.msgpack
|
||||||
|
$ fq -d msgpack v test.msgpack
|
||||||
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: test.msgpack (msgpack) 0x0-0x42.7 (67)
|
||||||
|
0x00|87 |. | type: "fixmap" (0x87) 0x0-0x0.7 (1)
|
||||||
|
0x00|87 |. | length: 7 0x0.4-0x0.7 (0.4)
|
||||||
|
| | | pairs[0:7]: 0x1-0x42.7 (66)
|
||||||
|
| | | [0]{}: pair 0x1-0xa.7 (10)
|
||||||
|
| | | key{}: 0x1-0x6.7 (6)
|
||||||
|
0x00| a5 | . | type: "fixstr" (0xa5) 0x1-0x1.7 (1)
|
||||||
|
0x00| a5 | . | length: 5 0x1.4-0x1.7 (0.4)
|
||||||
|
0x00| 61 72 72 61 79 | array | value: "array" 0x2-0x6.7 (5)
|
||||||
|
| | | value{}: 0x7-0xa.7 (4)
|
||||||
|
0x00| 93 | . | type: "fixarray" (0x93) 0x7-0x7.7 (1)
|
||||||
|
0x00| 93 | . | length: 3 0x7.4-0x7.7 (0.4)
|
||||||
|
| | | elements[0:3]: 0x8-0xa.7 (3)
|
||||||
|
| | | [0]{}: element 0x8-0x8.7 (1)
|
||||||
|
0x00| 01 | . | type: "positive_fixint" (0x1) 0x8-0x8.7 (1)
|
||||||
|
0x00| 01 | . | value: 1 0x8-0x8.7 (1)
|
||||||
|
| | | [1]{}: element 0x9-0x9.7 (1)
|
||||||
|
0x00| 02 | . | type: "positive_fixint" (0x2) 0x9-0x9.7 (1)
|
||||||
|
0x00| 02 | . | value: 2 0x9-0x9.7 (1)
|
||||||
|
| | | [2]{}: element 0xa-0xa.7 (1)
|
||||||
|
0x00| 03 | . | type: "positive_fixint" (0x3) 0xa-0xa.7 (1)
|
||||||
|
0x00| 03 | . | value: 3 0xa-0xa.7 (1)
|
||||||
|
| | | [1]{}: pair 0xb-0x1c.7 (18)
|
||||||
|
| | | key{}: 0xb-0x11.7 (7)
|
||||||
|
0x00| a6 | . | type: "fixstr" (0xa6) 0xb-0xb.7 (1)
|
||||||
|
0x00| a6 | . | length: 6 0xb.4-0xb.7 (0.4)
|
||||||
|
0x00| 6f 62 6a 65| obje| value: "object" 0xc-0x11.7 (6)
|
||||||
|
0x10|63 74 |ct |
|
||||||
|
| | | value{}: 0x12-0x1c.7 (11)
|
||||||
|
0x10| 81 | . | type: "fixmap" (0x81) 0x12-0x12.7 (1)
|
||||||
|
0x10| 81 | . | length: 1 0x12.4-0x12.7 (0.4)
|
||||||
|
| | | pairs[0:1]: 0x13-0x1c.7 (10)
|
||||||
|
| | | [0]{}: pair 0x13-0x1c.7 (10)
|
||||||
|
| | | key{}: 0x13-0x16.7 (4)
|
||||||
|
0x10| a3 | . | type: "fixstr" (0xa3) 0x13-0x13.7 (1)
|
||||||
|
0x10| a3 | . | length: 3 0x13.4-0x13.7 (0.4)
|
||||||
|
0x10| 6b 65 79 | key | value: "key" 0x14-0x16.7 (3)
|
||||||
|
| | | value{}: 0x17-0x1c.7 (6)
|
||||||
|
0x10| a5 | . | type: "fixstr" (0xa5) 0x17-0x17.7 (1)
|
||||||
|
0x10| a5 | . | length: 5 0x17.4-0x17.7 (0.4)
|
||||||
|
0x10| 76 61 6c 75 65 | value | value: "value" 0x18-0x1c.7 (5)
|
||||||
|
| | | [2]{}: pair 0x1d-0x24.7 (8)
|
||||||
|
| | | key{}: 0x1d-0x23.7 (7)
|
||||||
|
0x10| a6 | . | type: "fixstr" (0xa6) 0x1d-0x1d.7 (1)
|
||||||
|
0x10| a6 | . | length: 6 0x1d.4-0x1d.7 (0.4)
|
||||||
|
0x10| 6e 75| nu| value: "number" 0x1e-0x23.7 (6)
|
||||||
|
0x20|6d 62 65 72 |mber |
|
||||||
|
| | | value{}: 0x24-0x24.7 (1)
|
||||||
|
0x20| 7b | { | type: "positive_fixint" (0x7b) 0x24-0x24.7 (1)
|
||||||
|
0x20| 7b | { | value: 123 0x24-0x24.7 (1)
|
||||||
|
| | | [3]{}: pair 0x25-0x2f.7 (11)
|
||||||
|
| | | key{}: 0x25-0x2b.7 (7)
|
||||||
|
0x20| a6 | . | type: "fixstr" (0xa6) 0x25-0x25.7 (1)
|
||||||
|
0x20| a6 | . | length: 6 0x25.4-0x25.7 (0.4)
|
||||||
|
0x20| 73 74 72 69 6e 67 | string | value: "string" 0x26-0x2b.7 (6)
|
||||||
|
| | | value{}: 0x2c-0x2f.7 (4)
|
||||||
|
0x20| a3 | . | type: "fixstr" (0xa3) 0x2c-0x2c.7 (1)
|
||||||
|
0x20| a3 | . | length: 3 0x2c.4-0x2c.7 (0.4)
|
||||||
|
0x20| 61 62 63| abc| value: "abc" 0x2d-0x2f.7 (3)
|
||||||
|
| | | [4]{}: pair 0x30-0x35.7 (6)
|
||||||
|
| | | key{}: 0x30-0x34.7 (5)
|
||||||
|
0x30|a4 |. | type: "fixstr" (0xa4) 0x30-0x30.7 (1)
|
||||||
|
0x30|a4 |. | length: 4 0x30.4-0x30.7 (0.4)
|
||||||
|
0x30| 74 72 75 65 | true | value: "true" 0x31-0x34.7 (4)
|
||||||
|
| | | value{}: 0x35-0x35.7 (1)
|
||||||
|
0x30| c3 | . | type: "true" (0xc3) 0x35-0x35.7 (1)
|
||||||
|
| | | value: true 0x36-NA (0)
|
||||||
|
| | | [5]{}: pair 0x36-0x3c.7 (7)
|
||||||
|
| | | key{}: 0x36-0x3b.7 (6)
|
||||||
|
0x30| a5 | . | type: "fixstr" (0xa5) 0x36-0x36.7 (1)
|
||||||
|
0x30| a5 | . | length: 5 0x36.4-0x36.7 (0.4)
|
||||||
|
0x30| 66 61 6c 73 65 | false | value: "false" 0x37-0x3b.7 (5)
|
||||||
|
| | | value{}: 0x3c-0x3c.7 (1)
|
||||||
|
0x30| c2 | . | type: "false" (0xc2) 0x3c-0x3c.7 (1)
|
||||||
|
| | | value: false 0x3d-NA (0)
|
||||||
|
| | | [6]{}: pair 0x3d-0x42.7 (6)
|
||||||
|
| | | key{}: 0x3d-0x41.7 (5)
|
||||||
|
0x30| a4 | . | type: "fixstr" (0xa4) 0x3d-0x3d.7 (1)
|
||||||
|
0x30| a4 | . | length: 4 0x3d.4-0x3d.7 (0.4)
|
||||||
|
0x30| 6e 75| nu| value: "null" 0x3e-0x41.7 (4)
|
||||||
|
0x40|6c 6c |ll |
|
||||||
|
| | | value{}: 0x42-0x42.7 (1)
|
||||||
|
0x40| c0| | .| | type: "nil" (0xc0) 0x42-0x42.7 (1)
|
||||||
|
$ fq -d msgpack msgpack_torepr test.msgpack
|
||||||
|
{
|
||||||
|
"array": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"false": false,
|
||||||
|
"null": null,
|
||||||
|
"number": 123,
|
||||||
|
"object": {
|
||||||
|
"key": "value"
|
||||||
|
},
|
||||||
|
"string": "abc",
|
||||||
|
"true": true
|
||||||
|
}
|
1
format/msgpack/testdata/test.msgpack
vendored
Normal file
1
format/msgpack/testdata/test.msgpack
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
‡¥array“¦object<63>£key¥value¦number{¦string£abc¤trueÃ¥false¤nullÀ
|
1
pkg/interp/testdata/args.fqtest
vendored
1
pkg/interp/testdata/args.fqtest
vendored
@ -105,6 +105,7 @@ mpeg_pes MPEG Packetized elementary stream
|
|||||||
mpeg_pes_packet MPEG Packetized elementary stream packet
|
mpeg_pes_packet MPEG Packetized elementary stream packet
|
||||||
mpeg_spu Sub Picture Unit (DVD subtitle)
|
mpeg_spu Sub Picture Unit (DVD subtitle)
|
||||||
mpeg_ts MPEG Transport Stream
|
mpeg_ts MPEG Transport Stream
|
||||||
|
msgpack MessagePack
|
||||||
ogg OGG file
|
ogg OGG file
|
||||||
ogg_page OGG page
|
ogg_page OGG page
|
||||||
opus_packet Opus packet
|
opus_packet Opus packet
|
||||||
|
Loading…
Reference in New Issue
Block a user