// Detect It Easy: detection rule file
// Author: horsicq <horsicq@gmail.com>

meta("format", "Small Web Format (.SWF)");

includeScript("zlib");

function detect() {
    if (Binary.getSize() >= 32 && Binary.compare("%% %% %% ?? ?? ?? ?? 00")) {
        switch (Binary.getString(0, 3)) {
            case "FWS":
                sOptions = "uncompressed";
                bDetected = true;
                break;
            case "CWS":
                if (detect_zlib(Binary, 0x08))
                    bDetected = true;
                break;
            case "ZWS":
                sOptions = "LZMA";
                bDetected = true;
        }

        if (bDetected) {
            sVersion = Binary.read_uint8(0x03);
        }
    }

    return result();
}