// DIE's signature file
// Author: LinXP
// doc-ref: http://site.xara.com/support/docs/webformat/spec/XARFormatDocument.pdf
init("image", "Xar Vector graphic file (.XAR)");

function detect(bShowType, bShowVersion, bShowOptions) {
    if (Binary.getSize() >= 0x40) {
        if (Binary.compare("'XARA'A3A30D0A")) {
            bDetected = true;
            var sProducer = Binary.getString(0x1F);
            var sProducerVersion = Binary.getString(0x1F + sProducer.length + 1);
            var sProducerBuild = Binary.getString(0x1F + sProducer.length + 1 + sProducerVersion.length + 1);
            sName = sProducer + " Document (.XAR)";
            sVersion = sProducerVersion;
            if (Binary.isVerbose()) {
                sOption("build:" + sProducerBuild);
                switch (Binary.getString(0x10, 3)) {
                    case 'CXW':
                        sOption("Web file");
                        break;
                    case 'CXN':
                        sOption("Paper-publishable file");
                        break;
                        //default: bDetected=false;
                }
            }
        }
    }

    return result(bShowType, bShowVersion, bShowOptions);
}