public EXTHheader(Header header)
{
// Header length, including eye catcher : Bytes 20-4 big-endian integer
m_MOBIlen = header.ReadInt(20);
// EXTH follows immediately after MOBI
m_EXTHoffset = m_MOBIlen + 16;
// EXTH eye catcher - Bytes EXTH+0-4 ASCII
m_EXTH = header.ReadString(m_EXTHoffset, 4);
if (!m_EXTH.Equals("EXTH"))
throw new Exception("Invalid PRC file (reason 02)");
// Get the total length of the EXTH record
int totLen = header.ReadInt(m_EXTHoffset + 4);
// Get the count of EXTH records
int recCnt = header.ReadInt(m_EXTHoffset + 8);
// Loop through the rest of the EXTH records saving them
int endOffset = m_EXTHoffset + totLen;
int pos = m_EXTHoffset + 12;
while (pos < endOffset - 1)
{
String value;
int recType = header.ReadInt(pos);
int recLen = header.ReadInt(pos + 4);
switch (recType)
{
case 115:
case 116:
case 201:
case 202:
case 204:
case 205:
case 206:
case 207:
value = header.ReadInt(pos + 8).ToString();
break;
default:
value = header.ReadString(pos + 8, recLen - 8);
break;
}
m_EXTHrecs.Add(recType, value);
pos += recLen;
}
}