FireBirdLib - Topfield TMS PVR TAP Programming Library
EPGInfo_CreateCache.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <fcntl.h>
4
#include <unistd.h>
5
#include <sys/mman.h>
6
#include <sys/stat.h>
7
#include "
FBLib_EPG.h
"
8
9
bool
EPGInfo_CreateCache
(
int
NrRecords)
10
{
11
TRACEENTER
();
12
13
extern
dword
__tap_ud__
;
14
15
TAP_SPrint(
EPGCacheFile
,
"/mnt/hd/tmp/EPGCache_%x.bin"
,
__tap_ud__
);
16
17
if
(
EPGInfoCacheFile
)
EPGInfo_DestroyCache
();
18
19
EPGInfoCacheSize
= NrRecords *
sizeof
(
TYPE_EPGInfo
);
20
21
//Delete the old cache
22
unlink(
EPGCacheFile
);
23
24
mkdir(
"/mnt/hd/tmp"
, 0777);
25
EPGInfoCacheFile
= open(
EPGCacheFile
, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
26
27
if
(
EPGInfoCacheFile
== -1)
28
{
29
LogEntryFBLibPrintf
(TRUE,
"EPGInfo: failed to create the memory mapped EPG cache"
);
30
31
TRACEEXIT
();
32
return
FALSE;
33
}
34
35
//Increase the size of the cache as needed
36
if
(lseek(
EPGInfoCacheFile
,
EPGInfoCacheSize
,
SEEK_SET
) == -1)
37
{
38
LogEntryFBLibPrintf
(TRUE,
"EPGInfo: failed to stretch the memory mapped EPG cache"
);
39
close(
EPGInfoCacheFile
);
40
unlink(
EPGCacheFile
);
41
42
TRACEEXIT
();
43
return
FALSE;
44
}
45
write(
EPGInfoCacheFile
,
""
, 1);
46
47
//Map the memory
48
EPGInfoCacheMap
= mmap(0,
EPGInfoCacheSize
, PROT_READ | PROT_WRITE, MAP_SHARED,
EPGInfoCacheFile
, 0);
49
if
(
EPGInfoCacheMap
== MAP_FAILED)
50
{
51
LogEntryFBLibPrintf
(TRUE,
"EPGInfo: failed to memory map the EPG cache file"
);
52
close(
EPGInfoCacheFile
);
53
unlink(
EPGCacheFile
);
54
55
TRACEEXIT
();
56
return
FALSE;
57
}
58
59
EPGInfoCache
= (
TYPE_EPGInfo
*)
EPGInfoCacheMap
;
60
61
TRACEEXIT
();
62
return
TRUE;
63
}
EPGInfo_CreateCache
bool EPGInfo_CreateCache(int NrRecords)
Definition:
EPGInfo_CreateCache.c:9
EPGInfo_DestroyCache
void EPGInfo_DestroyCache(void)
Definition:
EPGInfo_DestroyCache.c:5
EPGCacheFile
char EPGCacheFile[40]
Definition:
EPGInfo_FindFirst.c:13
EPGInfoCacheSize
dword EPGInfoCacheSize
Definition:
EPGInfo_FindFirst.c:7
EPGInfoCacheMap
byte * EPGInfoCacheMap
Definition:
EPGInfo_FindFirst.c:8
EPGInfoCacheFile
int EPGInfoCacheFile
Definition:
EPGInfo_FindFirst.c:6
EPGInfoCache
TYPE_EPGInfo * EPGInfoCache
Definition:
EPGInfo_FindFirst.c:9
FBLib_EPG.h
__tap_ud__
const dword __tap_ud__
LogEntryFBLibPrintf
void LogEntryFBLibPrintf(bool Console, char *format,...)
Definition:
LogEntryFBLibPrintf.c:13
SEEK_SET
#define SEEK_SET
Definition:
libFireBird.h:1875
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
TYPE_EPGInfo
Definition:
libFireBird.h:1297
EPG
EPGInfo_CreateCache.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3