134 | | ||uint32le ||4‐byte blob node ||integer node ||decodes a 4‐byte little‐endian unsigned integer || `x"01010000"` becomes `257` || |
135 | | ||zero_terminated ||blob node ||blob node ||takes bytes up until the first `00` || `x"7f0400"` becomes `x"7f04"` || |
136 | | ||ascii ||blob node ||string ||decodes some bytes as ASCII characters || `x"6869"` becomes `"hi"` || |
137 | | ||padded_with_spaces_at_end ||string ||string ||removes spaces from the end of a string || `"README "` becomes `"README"` |
| 134 | ||ascii ||blob node ||string ||decodes some bytes as ASCII characters || `hex:6869` becomes `"hi"` || |
| 135 | ||uint32be ||4‐byte blob node ||integer node ||decodes a 4‐byte big‐endian unsigned integer || `hex:00000201` becomes `513` || |
| 136 | ||uint32le ||4‐byte blob node ||integer node ||decodes a 4‐byte little‐endian unsigned integer || `hex:01010000` becomes `257` || |
| 137 | ||zero_terminated ||blob node ||blob node ||takes bytes up until the first `00` || `hex:7f0400` becomes `hex:7f04` || |
150 | | order. The transform `padded_with_spaces_at_end . ascii . zero_terminated` |
151 | | first removes the 0x00 from the end of the blob, then decodes it as ascii and |
152 | | removes spaces from the end. Note that the order of composition is consistent |
153 | | with function composition and nested application in mathematics, and also |
154 | | consistent with the general idea that data moves from right to left as it is |
155 | | decoded. |
| 150 | order. The transform `ascii <- zero_terminated` |
| 151 | first removes the 0x00 from the end of the blob, then decodes it as ascii. Note |
| 152 | that the order of composition is consistent with function composition and |
| 153 | nested application in mathematics, and also consistent with the general idea |
| 154 | that data moves from right to left as it is decoded. |
181 | | If `labeled_point` is applied to `x"06000000 4100 03000000 08000000"`, the |
182 | | result is `{"id": 6, "label": "A", "x": 3, "y": 8}`. |
| 180 | If `labeled_point` is applied to `hex:0600000041000300000008000000`, the result |
| 181 | is `{"id": 6, "label": "A", "x": 3, "y": 8}`. |
| 182 | |
| 183 | == Using Bithenge == |
| 184 | |
| 185 | The Bithenge source code is in `uspace/app/bithenge` and is built along with |
| 186 | HelenOS. It can be built for Linux instead with `make -f Makefile.linux`. |
| 187 | |
| 188 | The program can be run with `bithenge <script file> <source>`. The script file |
| 189 | must define a transform called `main`. The source can start with one of the |
| 190 | following prefixes: |
| 191 | |
| 192 | ||= Prefix =||= Example =||= Description =|| |
| 193 | || file: || file:/textdemo || Read the contents of a file. This is the default if no prefix is used. || |
| 194 | || block: || block:bd/initrd || Read the contents of a block device. (HelenOS only.) || |
| 195 | || hex: || hex:01000000 || Use a string of hexadecimal characters to create a blob node. || |
| 196 | |
| 197 | There are some example files in `uspace/dist/src/bithenge`. |