// Detect It Easy: detection rule file format
// Author: LinXP
// Status: WIP

init("archive", "Long Range ZIP (.LRZ)");

function detect(bShowType, bShowVersion, bShowOptions) {
    if (Binary.getSize() >= 9) {
        if (Binary.compare("'LRZI'")) {
            bDetected = true;
            var nMajor = Binary.read_uint8(0x04);
            var nMinor = Binary.read_uint8(0x05);
            sVersion = nMajor + "." + nMinor;
            switch (Binary.read_uint8(0x31)) {
                case 3:
                    break;
                case 4:
                    sOption("BZIP2");
                    break;
                case 5:
                    sOption("LZO");
                    break;
                case 6:
                    sOption("LZMA");
                    break;
                case 7:
                    sOption("GZIP");
                    break;
                case 8:
                    sOption("ZPAQ");
                    break;
                default:
                    bDetected = false;
            }
            switch (Binary.read_uint8(0x16)) {
                case 0:
                    break;
                case 1:
                    sOption("encrypted");
                    break;
                default:
                    bDetected = false;
            }
            switch (Binary.read_uint8(0x15)) {
                case 0:
                    break;
                case 1:
                    sOption("md5");
                    break;
                default:
                    bDetected = false;
            }
        }
    }

    return result(bShowType, bShowVersion, bShowOptions);
}