sereal 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #------------------------------------------------------------------------------
  2. # $File: sereal,v 1.3 2015/02/05 19:14:45 christos Exp $
  3. # sereal: file(1) magic the Sereal binary serialization format
  4. #
  5. # From: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  6. #
  7. # See the specification of the format at
  8. # https://github.com/Sereal/Sereal/blob/master/sereal_spec.pod#document-header-format
  9. #
  10. # I'd have liked to do the byte&0xF0 matching against 0, 1, 2 ... by
  11. # doing (byte&0xF0)>>4 here, but unfortunately that's not
  12. # supported. So when we print out a message about an unknown format
  13. # we'll print out e.g. 0x30 instead of the more human-readable
  14. # 0x30>>4.
  15. #
  16. # See https://github.com/Sereal/Sereal/commit/35372ae01d in the
  17. # Sereal.git repository for test Sereal data.
  18. 0 name sereal
  19. >4 byte&0x0F x (version %d,
  20. >4 byte&0xF0 0x00 uncompressed)
  21. >4 byte&0xF0 0x10 compressed with non-incremental Snappy)
  22. >4 byte&0xF0 0x20 compressed with incremental Snappy)
  23. >4 byte&0xF0 >0x20 unknown subformat, flag: %d>>4)
  24. 0 string/b \=srl Sereal data packet
  25. !:mime application/sereal
  26. >&0 use sereal
  27. 0 string/b \=\xF3rl Sereal data packet
  28. !:mime application/sereal
  29. >&0 use sereal
  30. 0 string/b \=\xC3\xB3rl Sereal data packet, UTF-8 encoded
  31. !:mime application/sereal
  32. >&0 use sereal