I would like to parse binary files with PCRE. My tactic until now was to use fgets to read a line of a file, then parse that line using pcre_exec.
This will not work for me now because the “lines” end with a null byte rather than a newline. I did not see a way to have fgets stop at a null byte rather than newline.
Edit
The functionality would be similar to running grep -az PATTERN FILE
In this case, no luck, you need to read your binary file byte by byte and check for
'\0'.You can then store this bytes on a buffer and:
or
Hope this help.
Regards.