FireBirdLib - Topfield TMS PVR TAP Programming Library
HDD_SetExtRecording.c
Go to the documentation of this file.
1#include <stdlib.h>
2#include <string.h>
3#include "libFireBird.h"
4
5//This function returns 0x0000 on success
6// 0xe00* for warnings
7// and 0xf00* for errors
8word HDD_SetExtRecording(bool ExtDisk)
9{
10 TRACEENTER();
11
12 dword *__nExtPartition;
13 textPartitionInfo *__extPartitionInfo;
14 dword *__extTsFolder;
15 byte *__isAllPartitionInvalid;
16 int *__selectedPartition;
18 char *ExtDiskPart;
19
20 void (*Appl_SetIsExternal)(bool) = NULL;
21
22 //Resolve all firmware functions and variables
23 __nExtPartition = (dword*)FIS_vnExtPartition();
24 if(!__nExtPartition)
25 {
26 TRACEEXIT();
27 return 0xf000;
28 }
29
32 {
33 TRACEEXIT();
34 return 0xf001;
35 }
36
37 __extPartitionInfo = (textPartitionInfo*)FIS_vExtPartitionInfo();
38 if(!__extPartitionInfo)
39 {
40 TRACEEXIT();
41 return 0xf002;
42 }
43
44 __extTsFolder = (dword*)FIS_vExtTsFolder();
45 if(!__extTsFolder)
46 {
47 TRACEEXIT();
48 return 0xf003;
49 }
50
51 __isAllPartitionInvalid = (byte*)FIS_vIsAllPartitionInvalid();
52 if(!__isAllPartitionInvalid)
53 {
54 TRACEEXIT();
55 return 0xf004;
56 }
57
58 __selectedPartition = (int*)FIS_vSelectedPartition();
59 if(!__selectedPartition)
60 {
61 TRACEEXIT();
62 return 0xf005;
63 }
64
65 if(ExtDisk)
66 {
67 //Check if an external disk has been mounted
68 if(*__nExtPartition == 0)
69 {
70 TRACEEXIT();
71 return 0xe000;
72 }
73
74 //Check if there is at least one partition which can be used for recording
75 if(*__isAllPartitionInvalid != 0)
76 {
77 TRACEEXIT();
78 return 0xe001;
79 }
80
81 //Another check to make sure that there is a selectable partition
82 if(__selectedPartition[1] < 0)
83 {
84 TRACEEXIT();
85 return 0xe002;
86 }
87
88 //Get the first partition of that drive
89 ExtDiskPart = __extPartitionInfo[__selectedPartition[1]].MountPath;
90
91 //Build the DirEntry struct
92 DirEntry = TAP_MemAlloc(sizeof(tDirEntry));
93 if(!DirEntry)
94 {
95 TRACEEXIT();
96 return 0xf006;
97 }
98
99 DirEntry->Magic = 0xbacaed31;
100 DirEntry->Path = TAP_MemAlloc(strlen(ExtDiskPart) + 1);
101 if(!DirEntry->Path)
102 {
103 TRACEEXIT();
104 return 0xf007;
105 }
106
107 memset(DirEntry->Path, 0, strlen(ExtDiskPart) + 1);
108 strcpy(DirEntry->Path, ExtDiskPart);
109 DirEntry->unknown1 = 9;
110 DirEntry->unknown2 = 16;
111
112 //Let the extTsFolder point to our DirEnt structure
113 *__extTsFolder = (dword)DirEntry;
114
115 //Set the external disk usage flag
116 Appl_SetIsExternal(TRUE);
117 }
118 else
119 {
120 Appl_SetIsExternal(FALSE);
121 }
122
123 TRACEEXIT();
124 return 0x0000;
125}
void Appl_SetIsExternal(bool External)
#define bool
Definition: ELF.h:26
dword FIS_fwAppl_SetIsExternal(void)
dword FIS_vExtPartitionInfo(void)
dword FIS_vExtTsFolder(void)
dword FIS_vIsAllPartitionInvalid(void)
dword FIS_vnExtPartition(void)
dword FIS_vSelectedPartition(void)
word HDD_SetExtRecording(bool ExtDisk)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243