FireBirdLib - Topfield TMS PVR TAP Programming Library
infData_LocateSig.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <string.h>
3
#include "
FBLib_rec.h
"
4
5
extern
FILE
*
infDatainfFile
;
6
7
bool
infData_LocateSig
(
const
char
*NameTag, dword *PayloadSize)
8
{
9
bool
ret;
10
tTFRPlusHdr
TFRPlusHdr;
11
char
NameTagHdr[256];
12
dword CurrentPos;
13
14
//Format
15
// char Magic[4] //TFr+
16
// dword PayloadSize
17
// word NameTagLength //includes the NULL character
18
// char NameTag[SigLength]
19
// byte Payload[PayloadSize]
20
21
TRACEENTER
();
22
23
ret = FALSE;
24
if
(PayloadSize) *PayloadSize = 0;
25
26
if
(NameTag && *NameTag &&
infDatainfFile
&& (
infData_Flen
() >
INFDATASTART
))
27
{
28
fseek(
infDatainfFile
,
INFDATASTART
,
SEEK_SET
);
29
30
while
((CurrentPos = ftell(
infDatainfFile
)) <
infData_Flen
())
31
{
32
fread(&TFRPlusHdr,
sizeof
(
tTFRPlusHdr
), 1,
infDatainfFile
);
33
34
//Stop parsing if the magic is invalid
35
if
(memcmp(TFRPlusHdr.
Magic
,
INFDATMAGIC
, 4) != 0)
break
;
36
37
fread(NameTagHdr, TFRPlusHdr.
NameTagLen
, 1,
infDatainfFile
);
38
39
if
(strcmp(NameTag, NameTagHdr) == 0)
40
{
41
ret = TRUE;
42
if
(PayloadSize) *PayloadSize = TFRPlusHdr.
PayloadSize
;
43
fseek(
infDatainfFile
, CurrentPos,
SEEK_SET
);
44
break
;
45
}
46
fseek(
infDatainfFile
, TFRPlusHdr.
PayloadSize
,
SEEK_CUR
);
47
}
48
}
49
50
TRACEEXIT
();
51
return
ret;
52
}
FILE
struct __STDIO_FILE_STRUCT FILE
Definition:
FBLib_hdd.h:137
FBLib_rec.h
INFDATMAGIC
#define INFDATMAGIC
Definition:
FBLib_rec.h:18
infData_Flen
dword infData_Flen(void)
Definition:
infData_Flen.c:6
INFDATASTART
#define INFDATASTART
Definition:
FBLib_rec.h:15
infData_LocateSig
bool infData_LocateSig(const char *NameTag, dword *PayloadSize)
Definition:
infData_LocateSig.c:7
infDatainfFile
FILE * infDatainfFile
Definition:
infData_OpenFile.c:4
SEEK_SET
#define SEEK_SET
Definition:
libFireBird.h:1875
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
SEEK_CUR
#define SEEK_CUR
Definition:
libFireBird.h:1879
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
tTFRPlusHdr
Definition:
FBLib_rec.h:21
tTFRPlusHdr::NameTagLen
dword NameTagLen
Definition:
FBLib_rec.h:23
tTFRPlusHdr::Magic
char Magic[4]
Definition:
FBLib_rec.h:22
tTFRPlusHdr::PayloadSize
dword PayloadSize
Definition:
FBLib_rec.h:24
rec
infData_LocateSig.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3