FireBirdLib - Topfield TMS PVR TAP Programming Library
HDD_TAP_GetInfo.c
Go to the documentation of this file.
1#include <stdlib.h>
2#include <string.h>
3#include "libFireBird.h"
4
5bool HDD_TAP_GetInfo(const char *FileName, tTAPInfo *pTAPInfo)
6{
8
9 dword Index;
10 char s[128];
11
12 if(!pTAPInfo)
13 {
14 TRACEEXIT();
15 return FALSE;
16 }
17
18 if(!ELFOpenFile(FileName))
19 {
20 ELFCleanup();
21
22 TRACEEXIT();
23 return FALSE;
24 }
25
26 if(!ELFReadELFHeader())
27 {
28 ELFCleanup();
29
30 TRACEEXIT();
31 return FALSE;
32 }
33
35 {
36 ELFCleanup();
37
38 TRACEEXIT();
39 return FALSE;
40 }
41
43 {
44 ELFCleanup();
45
46 TRACEEXIT();
47 return FALSE;
48 }
49
50 Index = ELFGetSectionIndex("._tap_id");
51 if((Index == 0) || !ELFReadDWORD(Index, &pTAPInfo->TAPID))
52 {
53 ELFCleanup();
54
55 TRACEEXIT();
56 return FALSE;
57 }
58
59 pTAPInfo->Date = 0;
60 Index = ELFGetSectionIndex("._tap_etcinfo");
61 if((Index != 0) && ELFReadData(Index, s))
62 {
63 word y, m, d;
64 int i;
65 char Mon[13][4] = {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
66
67 //"Dec 9 2009"
68 y = atoi(&s[7]);
69 s[6] = '\0';
70
71 d = atoi(&s[4]);
72
73 s[3] = '\0';
74 m = 0;
75 for(i = 1; i <= 12; i++)
76 if(!strcmp(s, Mon[i]))
77 {
78 m = i;
79 break;
80 }
81
82 pTAPInfo->Date = TAP_MakeMjd(y, m, d);
83 }
84
85 pTAPInfo->TAPName[0] = '\0';
86 Index = ELFGetSectionIndex("._tap_program_name");
87 if(Index) ELFReadData(Index, pTAPInfo->TAPName);
88
89 pTAPInfo->Author[0] = '\0';
90 Index = ELFGetSectionIndex("._tap_author_name");
91 if(Index) ELFReadData(Index, pTAPInfo->Author);
92
93 pTAPInfo->Description[0] = '\0';
94 Index = ELFGetSectionIndex("._tap_description");
95 if(Index) ELFReadData(Index, pTAPInfo->Description);
96
97 #ifdef MAX_PROGRAM_VERSION
98 pTAPInfo->TAPVersion[0] = '\0';
99 Index = ELFGetSectionIndex("._tap_program_version");
100 if(Index) ELFReadData(Index, pTAPInfo->TAPVersion);
101 #endif
102
103 ELFCleanup();
104
105 TRACEEXIT();
106 return TRUE;
107}
void ELFCleanup(void)
Definition: ELFCleanup.c:5
dword ELFGetSectionIndex(const char *SectionName)
bool ELFOpenFile(const char *FileName)
Definition: ELFOpenFile.c:12
bool ELFReadDWORD(dword SectionIndex, dword *Data)
Definition: ELFReadDWORD.c:4
bool ELFReadData(dword SectionIndex, byte *Data)
Definition: ELFReadData.c:4
bool ELFReadELFHeader(void)
bool ELFReadSectionHeaders(void)
bool ELFReadShstrtabSection(void)
bool HDD_TAP_GetInfo(const char *FileName, tTAPInfo *pTAPInfo)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
dword TAPID
Definition: libFireBird.h:2592
char Author[MAX_AUTHOR_NAME]
Definition: libFireBird.h:2595
char TAPName[MAX_PROGRAM_NAME]
Definition: libFireBird.h:2594
dword Date
Definition: libFireBird.h:2593
char Description[MAX_DESCRIPTION]
Definition: libFireBird.h:2596