I'm trying to create a magic database file for the UNIX tool "file" for a specific file format. I have read the whole manual (man magic
and man file
) but did not find a way to output a 24-bit big endian integer. I've only found 8 bit (byte), 16 bit (beshort), 32 bit (belong) and 64 bit (bequad).
Is there a way to print a 24-bit (3-byte) big-endian integer from a file with a specific "magic file command"?
OK, I have just found out a way to read a three-byte value with file
:
Instead of ">0x04 belong x %d" (which prints a 4-byte int from offset 0x04) I use the command ">0x03&0x00ffffff belong x %d" which masks out the first byte and so reads my three-byte value from 0x04.