libopenraw
orfcontainer.cpp
1 /*
2  * libopenraw - orfcontainer.cpp
3  *
4  * Copyright (C) 2006, 2010 Hubert Figuiere
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #include "trace.h"
23 #include "orfcontainer.h"
24 
25 
26 using namespace Debug;
27 
28 namespace OpenRaw {
29 
30 namespace Internals {
31 
32 
33 OrfContainer::OrfContainer(IO::Stream *_file, off_t offset)
34  : IFDFileContainer(_file, offset)
35  , subtype_(0)
36 {
37 }
38 
39 
41 {
42 }
43 
44 
46 OrfContainer::isMagicHeader(const char *p, int len)
47 {
48  if (len < 4){
49  // we need at least 4 bytes to check
50  return ENDIAN_NULL;
51  }
52  if ((p[0] == 'I') && (p[1] == 'I')) {
53  if((p[2] == 'R') && ((p[3] == 'O') || (p[3] == 'S'))) {
54 
55  Trace(DEBUG1) << "Identified EL ORF file. Subtype = " << p[3] << "\n";
56  subtype_ = p[3];
57  return ENDIAN_LITTLE;
58  }
59  }
60  else if((p[0] == 'M') && (p[1] == 'M')) {
61  if((p[3] == 'R') && ((p[2] == 'O') || (p[2] == 'S'))) {
62 
63  Trace(DEBUG1) << "Identified BE ORF file. Subtype = " << p[2] << "\n";
64  subtype_ = p[2];
65  return ENDIAN_BIG;
66  }
67  }
68 
69  Trace(ERROR) << "Unidentified ORF file\n";
70 
71  return ENDIAN_NULL;
72 }
73 
74 }
75 }
76 
virtual IFDFileContainer::EndianType isMagicHeader(const char *p, int len)