// DIE's signature file
// Author: LinXP
// doc-ref: https://github.com/inikep/lizard/blob/lizard/doc/lizard_Frame_format.md
init("archive","");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if(Binary.getSize()>=9)
    {
        bDetected=true;
        switch(Binary.read_uint32(0x00,_BE))
        {
            case 0x02214C18: sName="LZ4 compressed data, legacy (.LZ4)" ; break;
            case 0x04224D18: sName="LZ4 compressed data (.LZ4)"     ; break;
            case 0x05224D18: sName="LZ5 compressed data (.LZ5)"     ; break;
            case 0x06224D18: sName="Lizard compressed data (.LIZ)"  ; break;
            default: bDetected=false; 
        }

        if(bDetected)
        {
            var bFlags=Binary.read_uint8(0x04);
            if (bFlags & 64)                  { sVersion="v1"; }
            if (bFlags & 128)                 { sVersion="v2"; }
            if (bFlags & 64 && bFlags & 128)  { sVersion="v3"; }
            if (Binary.isVerbose())
            {
                if (bFlags & 1 )  { sOption("PresetDictionary"); }
                if (bFlags & 4 )  { sOption("ContentChecksum"); }
                if (bFlags & 8 )  { sOption("ContentSize"); }
                if (bFlags & 16)  { sOption("BlockChecksum"); }
                if (bFlags & 32)  { sOption("BlockIndependence"); }
            }
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
