Search for bit patterns in standard input. Probably useless.
Search for first 11 bits of f8c
(1111 1000 110
) in the input:
$ echo 'h>0?' | ./bitmatch f8c 11 || echo not found
$ echo 'h<0?' | ./bitmatch f8c 11 || echo not found
not found
Input data h>0?
as bits:
$ echo 'h>0?' | xxd -b
00000000: 01101000 00111110 00110000 00111111 00001010 h>0?.
First 11 bits of pattern f8c
:
$ pattern="$(echo f8c | python3 -c 'print("".join(format(int(c, 16), "b") for c in input())[:11])')"
$ echo $pattern
11111000110
The bit pattern can be found in the input for example with grep
:
$ echo 'h>0?' | xxd -b | tr -d ' ' | grep "$pattern" || echo not found
00000000:0110100000111110001100000011111100001010h>0?.
$ echo 'h<0?' | xxd -b | tr -d ' ' | grep "$pattern" || echo not found
not found
That's basically the only thing bitmatch
does.
$ ./bitmatch
usage: bitmatch hex_pattern prefix_length
hex_pattern: string in hexadecimal of the pattern to search for. E.g. hex_pattern f8c will search for 111110001100
prefix_length: number of bits to use from the beginning of hex_pattern. E.g. prefix_length 9 would search for 111110001.
make all
./test.sh ./build/target bitmatch
make CC=gcc CXX=g++ all
make BUILD=release all
make dirs bitdump bitmatch_cpp
./test.sh ./build/target bitmatch_cpp
make dirs bitdump bitmatch_dyn
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./build
./test.sh ./build/target bitmatch_dyn