Blame lib/orfcontainer.cpp

rpm-build d2b433
/*
rpm-build d2b433
 * libopenraw - orfcontainer.cpp
rpm-build d2b433
 *
rpm-build d2b433
 * Copyright (C) 2006-2017 Hubert Figuière
rpm-build d2b433
 *
rpm-build d2b433
 * This library is free software: you can redistribute it and/or
rpm-build d2b433
 * modify it under the terms of the GNU Lesser General Public License
rpm-build d2b433
 * as published by the Free Software Foundation, either version 3 of
rpm-build d2b433
 * the License, or (at your option) any later version.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is distributed in the hope that it will be useful,
rpm-build d2b433
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build d2b433
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build d2b433
 * Lesser General Public License for more details.
rpm-build d2b433
 *
rpm-build d2b433
 * You should have received a copy of the GNU Lesser General Public
rpm-build d2b433
 * License along with this library.  If not, see
rpm-build d2b433
 * <http://www.gnu.org/licenses/>.
rpm-build d2b433
 */
rpm-build d2b433
rpm-build d2b433
#include <libopenraw/debug.h>
rpm-build d2b433
rpm-build d2b433
#include "trace.hpp"
rpm-build d2b433
#include "orfcontainer.hpp"
rpm-build d2b433
rpm-build d2b433
using namespace Debug;
rpm-build d2b433
rpm-build d2b433
namespace OpenRaw {
rpm-build d2b433
rpm-build d2b433
namespace Internals {
rpm-build d2b433
rpm-build d2b433
OrfContainer::OrfContainer(const IO::Stream::Ptr &_file, off_t _offset)
rpm-build d2b433
    : IfdFileContainer(_file, _offset), subtype_(0)
rpm-build d2b433
{
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
OrfContainer::~OrfContainer()
rpm-build d2b433
{
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
IfdFileContainer::EndianType OrfContainer::isMagicHeader(const char *p, int len)
rpm-build d2b433
{
rpm-build d2b433
    if (len < 4) {
rpm-build d2b433
        // we need at least 4 bytes to check
rpm-build d2b433
        return ENDIAN_NULL;
rpm-build d2b433
    }
rpm-build d2b433
    if ((p[0] == 'I') && (p[1] == 'I')) {
rpm-build d2b433
        if ((p[2] == 'R') && ((p[3] == 'O') || (p[3] == 'S'))) {
rpm-build d2b433
rpm-build d2b433
            LOGDBG1("Identified EL ORF file. Subtype = %c\n", p[3]);
rpm-build d2b433
            subtype_ = p[3];
rpm-build d2b433
            return ENDIAN_LITTLE;
rpm-build d2b433
        }
rpm-build d2b433
    } else if ((p[0] == 'M') && (p[1] == 'M')) {
rpm-build d2b433
        if ((p[3] == 'R') && ((p[2] == 'O') || (p[2] == 'S'))) {
rpm-build d2b433
rpm-build d2b433
            LOGDBG1("Identified BE ORF file. Subtype = %c\n", p[2]);
rpm-build d2b433
            subtype_ = p[2];
rpm-build d2b433
            return ENDIAN_BIG;
rpm-build d2b433
        }
rpm-build d2b433
    }
rpm-build d2b433
rpm-build d2b433
    LOGERR("Unidentified ORF file\n");
rpm-build d2b433
rpm-build d2b433
    return ENDIAN_NULL;
rpm-build d2b433
}
rpm-build d2b433
}
rpm-build d2b433
}