FireBirdLib - Topfield TMS PVR TAP Programming Library
FlashTransponderTablesDel.c
Go to the documentation of this file.
1#include <string.h>
2#include "FBLib_flash.h"
3
4bool FlashTransponderTablesDel(int SatNum, int TransponderNum)
5{
7
8 bool ret;
9
10 //SatNum out of range
11 if((SatNum < 0) || (SatNum >= FlashSatTablesGetTotal()))
12 {
13 TRACEEXIT();
14 return FALSE;
15 }
16
17 //TransponderNum out of range
18 if((TransponderNum < 0) || (TransponderNum >= FlashTransponderTablesGetTotal(SatNum)))
19 {
20 TRACEEXIT();
21 return FALSE;
22 }
23
24 ret = FALSE;
25 switch(GetSystemType())
26 {
27 //Unknown and old 5k/6k systems are not supported
28 case ST_UNKNOWN:
29 case ST_S:
30 case ST_ST:
31 case ST_T:
32 case ST_C:
33 case ST_CT:
34 case ST_T5700:
35 case ST_T5800:
36 case ST_TF7k7HDPVR: break;
37
38 case ST_TMSS:
39 {
40 TYPE_TpInfo_TMSS *pTransp, *pTranspEnd;
42 int i, TPIdx, NrSats;
43 dword *NrTransponders;
44
46 if(!pSat)
47 {
48 TRACEEXIT();
49 return FALSE;
50 }
51
52 NrSats = FlashSatTablesGetTotal();
53
54 pTransp = (TYPE_TpInfo_TMSS*)(FIS_vFlashBlockTransponderInfo());
55 if(!pTransp)
56 {
57 TRACEEXIT();
58 return FALSE;
59 }
60
61 //Find the end of the transponder list
62 pTranspEnd = pTransp;
63 for(i = 0; i <= NrSats; i++)
64 {
65 pTranspEnd += (pSat->NrOfTransponders);
66 pSat++;
67 }
68
69 //Find the location where to delete the transponder
70 TPIdx = 0;
72 for(i = 0; i < SatNum; i++)
73 {
74 TPIdx += pSat->NrOfTransponders;
75 pSat++;
76 }
77 pTransp += (TPIdx + TransponderNum);
78
79 //Move all transponders
80 while(pTranspEnd > pTransp)
81 {
82 memcpy(pTransp, pTransp + 1, sizeof(TYPE_TpInfo_TMSS));
83 pTransp++;
84 }
85
86 //Decrement the number of transponders
87 NrTransponders = (dword*)(FIS_vFlashBlockTransponderInfo() - 4);
88 *NrTransponders = *NrTransponders - 1;
89 pSat->NrOfTransponders--;
90
91 ret = TRUE;
92 break;
93 }
94
95 case ST_TMST:
96 {
97 TYPE_TpInfo_TMST *pTransp, *pTranspEnd;
99 dword *NrTransponders;
100
102 if(!pSat)
103 {
104 TRACEEXIT();
105 return FALSE;
106 }
107
108 pTransp = (TYPE_TpInfo_TMST*)(FIS_vFlashBlockTransponderInfo());
109 if(!pTransp)
110 {
111 TRACEEXIT();
112 return FALSE;
113 }
114
115 //Find the location where to delete the transponder
116 pTransp += TransponderNum;
117
118 //Find the end of the transponder list
119 pTranspEnd = pTransp;
120 while(pTranspEnd->Frequency) pTranspEnd++;
121
122 //Move all transponders
123 while(pTranspEnd > pTransp)
124 {
125 memcpy(pTransp, pTransp + 1, sizeof(TYPE_TpInfo_TMST));
126 pTransp++;
127 }
128
129 //Decrement the number of transponders
130 NrTransponders = (dword*)(FIS_vFlashBlockTransponderInfo() - 4);
131 *NrTransponders = *NrTransponders - 1;
132 pSat->NrOfTransponders--;
133
134 ret = TRUE;
135 break;
136 }
137
138 case ST_TMSC:
139 {
140 TYPE_TpInfo_TMSC *pTransp, *pTranspEnd;
141 TYPE_SatInfo_TMSC *pSat;
142 dword *NrTransponders;
143
145 if(!pSat)
146 {
147 TRACEEXIT();
148 return FALSE;
149 }
150
151 pTransp = (TYPE_TpInfo_TMSC*)(FIS_vFlashBlockTransponderInfo());
152 if(!pTransp)
153 {
154 TRACEEXIT();
155 return FALSE;
156 }
157
158 //Find the location where to delete the transponder
159 pTransp += TransponderNum;
160
161 //Find the end of the transponder list
162 pTranspEnd = pTransp;
163 while(pTranspEnd->Frequency) pTranspEnd++;
164
165 //Move all transponders
166 while(pTranspEnd > pTransp)
167 {
168 memcpy(pTransp, pTransp + 1, sizeof(TYPE_TpInfo_TMSC));
169 pTransp++;
170 }
171
172 //Decrement the number of transponders
173 NrTransponders = (dword*)(FIS_vFlashBlockTransponderInfo() - 4);
174 *NrTransponders = *NrTransponders - 1;
175 pSat->NrOfTransponders--;
176
177 ret = TRUE;
178 break;
179 }
180
181 case ST_NRTYPES: break;
182 }
183
184 if(ret)
185 {
186 int NrServices, i;
187 tFlashService Service;
188
189 //Delete all services from that specific transponder and renumber all transponder indices of services with a higher index
190 //TV
191 NrServices = FlashServiceGetTotal(SVC_TYPE_Tv);
192 i = NrServices - 1;
193 while(i >= 0)
194 {
195 if(FlashServiceGetInfo(SVC_TYPE_Tv, i, &Service) && (Service.SatIndex == SatNum))
196 {
197 if(Service.TransponderIndex == TransponderNum)
198 FlashServiceDel(SVC_TYPE_Tv, i);
199 else if(Service.TransponderIndex > TransponderNum)
200 {
201 Service.TransponderIndex--;
202 FlashServiceSetInfo(SVC_TYPE_Tv, i, &Service);
203 }
204 }
205 i--;
206 }
207
208 //Radio
209 NrServices = FlashServiceGetTotal(SVC_TYPE_Radio);
210 i = NrServices - 1;
211 while(i >= 0)
212 {
213 if(FlashServiceGetInfo(SVC_TYPE_Radio, i, &Service) && (Service.SatIndex == SatNum))
214 {
215 if(Service.TransponderIndex == TransponderNum)
216 FlashServiceDel(SVC_TYPE_Radio, i);
217 else if(Service.TransponderIndex > TransponderNum)
218 {
219 Service.TransponderIndex--;
220 FlashServiceSetInfo(SVC_TYPE_Radio, i, &Service);
221 }
222 }
223 i--;
224 }
225 }
226
227 TRACEEXIT();
228 return ret;
229}
dword FIS_vFlashBlockSatInfo(void)
dword FIS_vFlashBlockTransponderInfo(void)
int FlashSatTablesGetTotal(void)
bool FlashServiceDel(int SvcType, int SvcIndex)
bool FlashServiceGetInfo(int SvcType, int SvcNum, tFlashService *Service)
int FlashServiceGetTotal(int SvcType)
bool FlashServiceSetInfo(int SvcType, int SvcNum, tFlashService *Service)
bool FlashTransponderTablesDel(int SatNum, int TransponderNum)
int FlashTransponderTablesGetTotal(int SatNum)
SYSTEM_TYPE GetSystemType(void)
Definition: GetSystemType.c:3
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
@ ST_CT
Definition: libFireBird.h:77
@ ST_T
Definition: libFireBird.h:69
@ ST_TMSC
Definition: libFireBird.h:74
@ ST_UNKNOWN
Definition: libFireBird.h:67
@ ST_T5700
Definition: libFireBird.h:71
@ ST_TMST
Definition: libFireBird.h:73
@ ST_T5800
Definition: libFireBird.h:75
@ ST_TMSS
Definition: libFireBird.h:72
@ ST_ST
Definition: libFireBird.h:76
@ ST_NRTYPES
Definition: libFireBird.h:79
@ ST_TF7k7HDPVR
Definition: libFireBird.h:78
@ ST_S
Definition: libFireBird.h:68
@ ST_C
Definition: libFireBird.h:70
word TransponderIndex
Definition: libFireBird.h:1523