~jonn/bed

Binary editor. It's like sed, but for binary data.
Problem: io_srv doesn't know where to send jobs
Problem: default formatter sucks
Problem: no easy to use binary stream editor

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~jonn/bed
read/write
git@git.sr.ht:~jonn/bed

You can also use your local clone with git send-email.

#Bed: Binary Editor

#Problem

There is no way to reasonably quickly manipulate binaries

#Objectives

  • Simple binary maipulation with ergonomic syntax
  • Work with arbitrary chunks and paddings
  • Streaming support
  • Saving recipes for later use and composition

#Requirements

1.PMAP: bed shall allow for writing pmap (parallel map) instructions over binary data 2.PIPE: bed shall be compatible with UNIX-pipe streaming 3.SPLT: bed shall have capabilities to produce binary and text outputs 4.CMPS: bed shall have utility to compose instructions 5.SCRT: bed shall provide a facility to save instructions or their compositions into script files

#Commentary

1.PMAP: For mapping part of the pipeline, we want to parallelise it so that as many cores as possible are used. Interplay with 5.SCRP is as follows: whenever a user submits more than one map instruction, map instructions are composed into one instruction first and then executed in parallel. 2.PIPE: We pick UNIX pipes because that's the way sed and awk works, but we will aim to write code in such way that bed is extendible with other sorts of streaming (raw tcp, ...). 3.SPLT: Plain text output will not be sufficient for code generation, as we'll need to have 4.CMPS: This is covered in 1.PMAP, but we should explicitly mention that we'll execute instructions in the order submitted by the user 5.SCRT: Make --save flag or something...

#User stories and format

#Basic usage

  • abcdefgh>abcdefg transforms to non-byte-aligned bitstring
  • abcdefgh>abcdefg|:0 transforms to byte-aligned binary (|:0 means "byte-pad the end with zeroes")
  • abcdefgh>abcdefg|0: transforms to byte-aligned binary (|0: means "byte-pad the beginning with zeroes")
  • abcdefgh>abcdefg|0:9 transforms to 9-bit-aligned bitstring (I don't know why anyone would need it)
  • abcdefgh>abcdefg|"the world wonders": uses ASCII padding in front, produces byte-aligned text

#Several rules

  • 1bcd>d;a1cd>cd;abcd>dcba|:1 - keeps last bit of quartet if the first bit is 1 - keeps last two bits of quartet if the second bit is 1 - reverses the quartet otherwise - pads with ones in the end

#Roadmap

The same way we can't support folds, we can pmap non-aligned inputs, this is why a rule like this is currently not possible 0ab>;a1cd>d1ca;ab0d>0000;abcd>dcba;|:1.

When we add sequential backend for folds, we'll also add support for non-aligned rules.