FireBirdLib - Topfield TMS PVR TAP Programming Library
infData_Set.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_Set
(
const
char
*infFileName,
char
*NameTag, dword PayloadSize,
byte
*Payload)
8
{
9
bool
ret;
10
tTFRPlusHdr
TFRPlusHdr;
11
12
TRACEENTER
();
13
14
ret = FALSE;
15
16
infData_Delete
(infFileName, NameTag);
17
if
(NameTag && *NameTag &&
infData_OpenFile
(infFileName))
18
{
19
ret = TRUE;
20
21
//Ensure the minimum size of INFDATASTART bytes
22
if
(
infData_Flen
() <
INFDATASTART
)
23
{
24
infData_CloseFile
();
25
infData_Truncate
(infFileName,
INFDATASTART
);
26
infData_OpenFile
(infFileName);
27
}
28
29
//Add the data block
30
fseek(
infDatainfFile
, 0,
SEEK_END
);
31
32
memcpy(TFRPlusHdr.
Magic
,
INFDATMAGIC
, 4);
33
TFRPlusHdr.
NameTagLen
= strlen(NameTag) + 1;
34
TFRPlusHdr.
PayloadSize
= PayloadSize;
35
36
if
(PayloadSize && (Payload == NULL))
37
{
38
LogEntryFBLibPrintf
(TRUE,
"infData: PayloadSize of %s:%s is not 0, but data pointer is NULL!"
, infFileName, NameTag);
39
TFRPlusHdr.
PayloadSize
= 0;
40
ret = FALSE;
41
}
42
43
fwrite(&TFRPlusHdr,
sizeof
(
tTFRPlusHdr
), 1,
infDatainfFile
);
44
fwrite(NameTag, TFRPlusHdr.
NameTagLen
, 1,
infDatainfFile
);
45
46
if
(Payload)
47
fwrite(Payload, TFRPlusHdr.
PayloadSize
, 1,
infDatainfFile
);
48
}
49
infData_CloseFile
();
50
51
TRACEEXIT
();
52
return
ret;
53
}
FILE
struct __STDIO_FILE_STRUCT FILE
Definition:
FBLib_hdd.h:137
FBLib_rec.h
INFDATMAGIC
#define INFDATMAGIC
Definition:
FBLib_rec.h:18
infData_Truncate
void infData_Truncate(const char *infFileName, dword Position)
Definition:
infData_Truncate.c:4
infData_OpenFile
bool infData_OpenFile(const char *infFileName)
Definition:
infData_OpenFile.c:6
infData_CloseFile
void infData_CloseFile(void)
Definition:
infData_CloseFile.c:6
infData_Flen
dword infData_Flen(void)
Definition:
infData_Flen.c:6
INFDATASTART
#define INFDATASTART
Definition:
FBLib_rec.h:15
LogEntryFBLibPrintf
void LogEntryFBLibPrintf(bool Console, char *format,...)
Definition:
LogEntryFBLibPrintf.c:13
infDatainfFile
FILE * infDatainfFile
Definition:
infData_OpenFile.c:4
infData_Set
bool infData_Set(const char *infFileName, char *NameTag, dword PayloadSize, byte *Payload)
Definition:
infData_Set.c:7
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
infData_Delete
bool infData_Delete(const char *infFileName, const char *NameTag)
Definition:
infData_Delete.c:6
SEEK_END
#define SEEK_END
Definition:
libFireBird.h:1883
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_Set.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3