libopenraw
|
00001 /* 00002 * libopenraw - orfcontainer.cpp 00003 * 00004 * Copyright (C) 2006, 2010 Hubert Figuiere 00005 * 00006 * This library is free software: you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation, either version 3 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library. If not, see 00018 * <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 00022 #include "trace.h" 00023 #include "orfcontainer.h" 00024 00025 00026 using namespace Debug; 00027 00028 namespace OpenRaw { 00029 00030 namespace Internals { 00031 00032 00033 OrfContainer::OrfContainer(IO::Stream *_file, off_t offset) 00034 : IFDFileContainer(_file, offset) 00035 , subtype_(0) 00036 { 00037 } 00038 00039 00040 OrfContainer::~OrfContainer() 00041 { 00042 } 00043 00044 00045 IFDFileContainer::EndianType 00046 OrfContainer::isMagicHeader(const char *p, int len) 00047 { 00048 if (len < 4){ 00049 // we need at least 4 bytes to check 00050 return ENDIAN_NULL; 00051 } 00052 if ((p[0] == 'I') && (p[1] == 'I')) { 00053 if((p[2] == 'R') && ((p[3] == 'O') || (p[3] == 'S'))) { 00054 00055 Trace(DEBUG1) << "Identified EL ORF file. Subtype = " << p[3] << "\n"; 00056 subtype_ = p[3]; 00057 return ENDIAN_LITTLE; 00058 } 00059 } 00060 else if((p[0] == 'M') && (p[1] == 'M')) { 00061 if((p[3] == 'R') && ((p[2] == 'O') || (p[2] == 'S'))) { 00062 00063 Trace(DEBUG1) << "Identified BE ORF file. Subtype = " << p[2] << "\n"; 00064 subtype_ = p[2]; 00065 return ENDIAN_BIG; 00066 } 00067 } 00068 00069 Trace(ERROR) << "Unidentified ORF file\n"; 00070 00071 return ENDIAN_NULL; 00072 } 00073 00074 } 00075 } 00076