FireBirdLib - Topfield TMS PVR TAP Programming Library
infData_Get.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include "
FBLib_rec.h
"
3
4
extern
FILE
*
infDatainfFile
;
5
6
bool
infData_Get
(
const
char
*infFileName,
const
char
*NameTag, dword *PayloadSize,
byte
**Payload)
7
{
8
byte
*DataBlock;
9
bool
ret;
10
tTFRPlusHdr
TFRPlusHdr;
11
char
NameTagHdr[256], s[256];
12
13
TRACEENTER
();
14
15
ret = FALSE;
16
if
(PayloadSize) *PayloadSize = 0;
17
if
(Payload) *Payload = NULL;
18
19
if
(NameTag && *NameTag && Payload &&
infData_OpenFile
(infFileName) &&
infData_LocateSig
(NameTag, NULL))
20
{
21
ret = TRUE;
22
DataBlock = NULL;
23
24
fread(&TFRPlusHdr,
sizeof
(
tTFRPlusHdr
), 1,
infDatainfFile
);
25
fread(NameTagHdr, TFRPlusHdr.
NameTagLen
, 1,
infDatainfFile
);
26
if
(PayloadSize) *PayloadSize = TFRPlusHdr.
PayloadSize
;
27
28
if
(TFRPlusHdr.
PayloadSize
> 0)
29
{
30
DataBlock = TAP_MemAlloc(TFRPlusHdr.
PayloadSize
);
31
if
(DataBlock)
32
fread(DataBlock, TFRPlusHdr.
PayloadSize
, 1,
infDatainfFile
);
33
else
34
{
35
TAP_SPrint(s,
"failed to reserve %lu bytes for %s:%s"
, TFRPlusHdr.
PayloadSize
, infFileName, NameTag);
36
LogEntryFBLibPrintf
(TRUE,
"infData: %s"
, s);
37
}
38
}
39
*Payload = DataBlock;
40
}
41
42
infData_CloseFile
();
43
44
TRACEEXIT
();
45
return
ret;
46
}
FILE
struct __STDIO_FILE_STRUCT FILE
Definition:
FBLib_hdd.h:137
FBLib_rec.h
infData_LocateSig
bool infData_LocateSig(const char *NameTag, dword *PayloadSize)
Definition:
infData_LocateSig.c:7
infData_OpenFile
bool infData_OpenFile(const char *infFileName)
Definition:
infData_OpenFile.c:6
infData_CloseFile
void infData_CloseFile(void)
Definition:
infData_CloseFile.c:6
LogEntryFBLibPrintf
void LogEntryFBLibPrintf(bool Console, char *format,...)
Definition:
LogEntryFBLibPrintf.c:13
infDatainfFile
FILE * infDatainfFile
Definition:
infData_OpenFile.c:4
infData_Get
bool infData_Get(const char *infFileName, const char *NameTag, dword *PayloadSize, byte **Payload)
Definition:
infData_Get.c:6
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
tTFRPlusHdr
Definition:
FBLib_rec.h:21
tTFRPlusHdr::NameTagLen
dword NameTagLen
Definition:
FBLib_rec.h:23
tTFRPlusHdr::PayloadSize
dword PayloadSize
Definition:
FBLib_rec.h:24
rec
infData_Get.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3