FireBirdLib - Topfield TMS PVR TAP Programming Library
TFDSize.c
Go to the documentation of this file.
1#include "libFireBird.h"
2#include "FBLib_compression.h"
3
4dword TFDSize(byte *pTFD)
5{
7
8 word NrBlocks = 0;
9 dword i;
10 byte *p = pTFD;
11
12 if(!pTFD)
13 {
14 TRACEEXIT();
15 return 0;
16 }
17
18 if(LOAD_WORD(p) != 8)
19 {
20 //Invalid header
21 TRACEEXIT();
22 return 0;
23 }
24
25 if(CRC16 (0, p + 4, 6) != LOAD_WORD(p + 2))
26 {
27 //Invalid header CRC
28 TRACEEXIT();
29 return 0;
30 }
31
32 if(LOAD_WORD(p + 6) != 1)
33 {
34 //Invalid file version
35 TRACEEXIT();
36 return 0;
37 }
38
39 NrBlocks = LOAD_WORD(p + 8);
40 p += 10;
41 for(i = 0; i < NrBlocks; i++)
42 p += LOAD_WORD(p) + 2;
43
44 TRACEEXIT();
45 return p - pTFD;
46}
word CRC16(word StartValue, void *StartAddress, dword Length)
Definition: CRC16.c:23
#define LOAD_WORD(x)
dword TFDSize(byte *pTFD)
Definition: TFDSize.c:4
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243