1
1
mirror of https://github.com/wader/fq.git synced 2024-09-20 00:08:01 +03:00
Commit Graph

292 Commits

Author SHA1 Message Date
Mattias Wadman
0d74e879fb bitio,doc: Even more cleanup 2022-02-09 01:35:47 +01:00
Mattias Wadman
82aeb35591 bitio: More doc cleanup 2022-02-09 01:03:50 +01:00
Mattias Wadman
06245d1295 binary,decode,doc: Rename buffer to binary and add some documentation
Rename buffer to binary. Still some work left what to call buffer/binary in decode code.
Document decode value and binary type
Fix proper unit padding for tobytes and add still undocumenated extra padding argument.
Add some additional binary tests
2022-02-08 22:20:28 +01:00
Mattias Wadman
2dc2a24f92
Merge pull request #132 from wader/asn1-frompem-doc
asn1_ber: Add more doc and multiple outputs for frompem
2022-02-07 18:04:12 +01:00
Mattias Wadman
0312c92c31 asn1_ber: Add more doc and multiple outputs for frompem 2022-02-07 17:41:05 +01:00
Mattias Wadman
0a1a5610a9 interp: Add missing default opts for tovalue 2022-02-07 17:11:51 +01:00
Mattias Wadman
0829c167cc asn1_ber: Add decoder
Basic support, can also do CER and DER but without any extra validation.
No schema support.

Redo format doc.md usage a bit, now format/<dir>/<format>.md instead.

Related to #20
2022-02-06 22:13:03 +01:00
Mattias Wadman
be71eb01ac decode: Rename LenFn() to LimitedFn, add FramedFn and document
I think framed makes more sense, but not sure
2022-02-06 13:49:00 +01:00
Mattias Wadman
032cb7d3d7
Merge pull request #126 from wader/interp-allow-force-as-cli-option
interp: Support force decode as -o force=true
2022-02-05 17:30:37 +01:00
Mattias Wadman
366f6b185c interp: Support force decode as -o force=true 2022-02-05 17:24:42 +01:00
Mattias Wadman
d854ed5737 bitio: Cleanup documentation a bit 2022-02-05 16:54:54 +01:00
Mattias Wadman
7c5215347d bitio,decode: Refactor bitio usage and make buffer slicing more correct
Remove bitio.Buffer layer. bitio.Buffer was a kitchen sink layer with helpers
now it's just a buffer and most functions have been moved to decode instead.

bitio package now only have primitive types and functions simialar to standard
library io and bytes packages.

Make nearly eveything internally use bitio.Bit* interfaces so that slicing work
correctly this will also make it possible to start experimenting with more
complicated silcing helpers, ex things like:
breplace(.header.bitrate; 123) to get a new buffer with bitrate changed.
2022-02-04 21:41:53 +01:00
Mattias Wadman
4ab6381dc4 decode: Add scalars args to FieldRootBitBuf
Also move *Value.TryScalarFn to value.go
2022-02-01 22:24:24 +01:00
Mattias Wadman
b66e3287f2
Merge pull request #112 from wader/interp-cleanup-d-alises
interp: Cleanup display aliases, now: d, da, dd, dv, ddv
2022-01-29 12:28:46 +01:00
Mattias Wadman
2efc3cba9b
Merge pull request #115 from wader/doc-example-usages
doc,interp: Add some example usages to cli help
2022-01-29 12:26:08 +01:00
Mattias Wadman
7bc2521938 doc,interp: Add some example usages to cli help 2022-01-29 12:21:51 +01:00
Mattias Wadman
ca68e6a1e4 interp: Add Platform() method to OS interface
Felt bad that main should have to know about it
2022-01-29 11:31:36 +01:00
Mattias Wadman
fc0aacb654 interp: Cleanup display aliases, now: d, da, dd, dv, ddv
Think it makes sense to have them all start with d.
Also f is often used as function argument name.
2022-01-28 18:25:38 +01:00
Mattias Wadman
6cd1c38fbf decode,scalar: Add scalar.Str{Uint/Int/F}ToSym to parse numbers 2022-01-28 17:18:50 +01:00
Mattias Wadman
b2e5a83860
Merge pull request #110 from wader/doc-improve-use-other-func-notation
doc: Use f($a; $b) instead of jq f/2 notation
2022-01-27 10:10:12 +01:00
Mattias Wadman
c52a1a2364 doc: Use f($a; $b) instead of jq f/2 notation
Also some general polish
2022-01-27 09:55:45 +01:00
Mattias Wadman
233d86a384 fq: Add arch and os to --version 2022-01-26 18:09:59 +01:00
Mattias Wadman
898dfec1d1 lint: Fix typeassert and case exhaustive warnings 2022-01-25 17:23:41 +01:00
Mattias Wadman
e792598c69 interp: Add grep_by/1 to recursively match using a filter
Refactor other grep functions to use it
2022-01-24 18:26:25 +01:00
Mattias Wadman
bc107f82e4
Merge pull request #101 from wader/dump-sym-correct-color
interp: Use correct sym color
2022-01-24 17:53:46 +01:00
Mattias Wadman
c31ec2a388 interp: Use correct sym color 2022-01-24 16:57:35 +01:00
Mattias Wadman
b8efd8e549 fuzz: Fuzz all formats
Fix string readers to not panic on make slice with bogus sizes
2022-01-24 16:56:24 +01:00
Mattias Wadman
21ce6574fa
Merge pull request #96 from wader/pcapng-fatal-on-negzero-blocklen
pcapng,fuzz: Fix infinite loop by fatal error on block length <= 0
2022-01-23 13:39:04 +01:00
Mattias Wadman
d1943dad49 pcapng,fuzz: Fix infinite loop by fatal error on block length <= 0
Also add dev/fuzzbytes.go tool to convert fuzz input to raw bytes
2022-01-23 13:34:56 +01:00
Mattias Wadman
bf7a483f87 interp: Fix handling of group decode error from stdin
null input to open means stdin but it as also erroneously also used as object key
to store the error.
2022-01-23 12:41:31 +01:00
Mattias Wadman
34a09c40a7
Merge pull request #90 from wader/decode-stable-sort
decode: Use stable sort for values to not change order or values with…
2022-01-20 16:34:47 +01:00
Mattias Wadman
9198e18c10 decode: Add FieldArrayRootBitBufFn for completeness
Should rethink these, not very nice api
2022-01-20 16:27:52 +01:00
Mattias Wadman
cf8a50c150 decode: Use stable sort for values to not change order or values with same range start
Some decoders might relay on values added with same start to be kept in same order.
2022-01-20 16:21:50 +01:00
Mattias Wadman
ff5c0b8195 decode: Error on negative number of bits when reading numbers
Maybe should even give error on zero bits? maybe only allow for zero bit for unsigned ints?
2022-01-18 12:01:04 +01:00
Mattias Wadman
548a065388 decode,interp: Finish up nil value support
Update msgpack, bson and cbor to use it.
2022-01-17 10:49:46 +01:00
Mattias Wadman
edad481878 num,mathextra: Rename num package to mathextra
Think it makes more sense
2022-01-15 19:00:42 +01:00
Mattias Wadman
1383b411ae decode,interp: Add arbitrary large integer support (BigInt)
Was already handled in fq in various places as gojq uses them

Update msgpack to support negative integers that can't represented as int64
Rename read try* number functions to make them more explicit
2022-01-15 19:00:42 +01:00
Mattias Wadman
0b0f28e966 cbor: Add decoder
Does not decode sematic tag types
Also fixes broken float16 support

Fixes #71
2022-01-12 17:56:03 +01:00
Mattias Wadman
149cb3f45a interp: Add torepr/0 that converts decode value into what it reptresents
Ex: fq -d msgpack torepr file.msgpack
Willoutput the JSON representation of the msgpack

Make per format *_torepr functions internal
2022-01-12 17:33:58 +01:00
Mattias Wadman
05df5a9092
Merge pull request #69 from wader/msgpack
msgpack: Add decoder
2022-01-10 21:38:59 +01:00
Mattias Wadman
9770b0046b repl: Make prompt for array and iter more jqish
Really need to refactor script.go some day into a proper parser
2022-01-10 20:02:43 +01:00
Mattias Wadman
a6bf62ce19 msgpack: Add decoder
Fixes #25
2022-01-10 19:33:09 +01:00
Mattias Wadman
af8e7efc61 bencode: Add decoder
Closes #63
2022-01-10 10:52:14 +01:00
Mattias Wadman
b3a09805a4 interp: Document bit opts funcs and add some error tests 2022-01-09 10:43:07 +01:00
Mattias Wadman
be0ef80c8d interp,fq: Make bit operators normal functions
Uses same rule as jq math functions, 1 arg uses input, more than one all passed as args.
So "bnot 1" -> "1 | bnot", "1 bsl 1" -> "bsl(1; 1)"

Don't think it's worth changing the jq syntax for this and also it could make fq
scripts no compatiblr with other jq tools. Non-10 base number literals are still allowed
but should probably not be used in scripts, only in repl and with cli.
2022-01-09 01:06:36 +01:00
Mattias Wadman
a3cfcd0ad2 interp: Add stderr again for jq compat
Also add tests for print* and stderr
2022-01-07 11:30:09 +01:00
Mattias Wadman
628f0f403d bson: Add decoder
Only supports basic types for now
2022-01-06 00:51:37 +01:00
Mattias Wadman
681dbc26b7 elf,ar: Add ar decoder, improved elf decoder
Add x86, 386, arm64, arm v6, arm v7 linux elf test files
2022-01-05 22:05:09 +01:00
Mattias Wadman
f6abcff1fc
Merge pull request #54 from wader/interp-stdio-cleanup
interp: Cleanup stdio usage and functions
2022-01-05 21:44:48 +01:00
Mattias Wadman
e365f22084 interp: Cleanup stdio usage and functions 2022-01-05 21:41:11 +01:00