tipc: Allow retransmission of cloned buffers
[linux/fpc-iii.git] / Documentation / dvb / get_dvb_firmware
blob239cbdbf4d120edc39869cd1af74764c01c4acbe
1 #!/usr/bin/perl
2 # DVB firmware extractor
4 # (c) 2004 Andrew de Quincey
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 use File::Temp qw/ tempdir /;
22 use IO::Handle;
24 @components = ( "sp8870", "sp887x", "tda10045", "tda10046",
25 "tda10046lifeview", "av7110", "dec2000t", "dec2540t",
26 "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
27 "or51211", "or51132_qam", "or51132_vsb", "bluebird",
28 "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718",
29 "af9015", "ngene");
31 # Check args
32 syntax() if (scalar(@ARGV) != 1);
33 $cid = $ARGV[0];
35 # Do it!
36 for ($i=0; $i < scalar(@components); $i++) {
37 if ($cid eq $components[$i]) {
38 $outfile = eval($cid);
39 die $@ if $@;
40 print STDERR <<EOF;
41 Firmware(s) $outfile extracted successfully.
42 Now copy it(them) to either /usr/lib/hotplug/firmware or /lib/firmware
43 (depending on configuration of firmware hotplug).
44 EOF
45 exit(0);
49 # If we get here, it wasn't found
50 print STDERR "Unknown component \"$cid\"\n";
51 syntax();
56 # ---------------------------------------------------------------
57 # Firmware-specific extraction subroutines
59 sub sp8870 {
60 my $sourcefile = "tt_Premium_217g.zip";
61 my $url = "http://www.softwarepatch.pl/9999ccd06a4813cb827dbb0005071c71/$sourcefile";
62 my $hash = "53970ec17a538945a6d8cb608a7b3899";
63 my $outfile = "dvb-fe-sp8870.fw";
64 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
66 checkstandard();
68 wgetfile($sourcefile, $url);
69 unzip($sourcefile, $tmpdir);
70 verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash);
71 copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile);
73 $outfile;
76 sub sp887x {
77 my $sourcefile = "Dvbt1.3.57.6.zip";
78 my $url = "http://www.avermedia.com/software/$sourcefile";
79 my $cabfile = "DVBT Net Ver1.3.57.6/disk1/data1.cab";
80 my $hash = "237938d53a7f834c05c42b894ca68ac3";
81 my $outfile = "dvb-fe-sp887x.fw";
82 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
84 checkstandard();
85 checkunshield();
87 wgetfile($sourcefile, $url);
88 unzip($sourcefile, $tmpdir);
89 unshield("$tmpdir/$cabfile", $tmpdir);
90 verify("$tmpdir/ZEnglish/sc_main.mc", $hash);
91 copy("$tmpdir/ZEnglish/sc_main.mc", $outfile);
93 $outfile;
96 sub tda10045 {
97 my $sourcefile = "tt_budget_217g.zip";
98 my $url = "http://www.technotrend.de/new/217g/$sourcefile";
99 my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a";
100 my $outfile = "dvb-fe-tda10045.fw";
101 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
103 checkstandard();
105 wgetfile($sourcefile, $url);
106 unzip($sourcefile, $tmpdir);
107 extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp");
108 verify("$tmpdir/fwtmp", $hash);
109 copy("$tmpdir/fwtmp", $outfile);
111 $outfile;
114 sub tda10046 {
115 my $sourcefile = "TT_PCI_2.19h_28_11_2006.zip";
116 my $url = "http://www.tt-download.com/download/updates/219/$sourcefile";
117 my $hash = "6a7e1e2f2644b162ff0502367553c72d";
118 my $outfile = "dvb-fe-tda10046.fw";
119 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
121 checkstandard();
123 wgetfile($sourcefile, $url);
124 unzip($sourcefile, $tmpdir);
125 extract("$tmpdir/TT_PCI_2.19h_28_11_2006/software/OEM/PCI/App/ttlcdacc.dll", 0x65389, 24478, "$tmpdir/fwtmp");
126 verify("$tmpdir/fwtmp", $hash);
127 copy("$tmpdir/fwtmp", $outfile);
129 $outfile;
132 sub tda10046lifeview {
133 my $sourcefile = "7%5Cdrv_2.11.02.zip";
134 my $url = "http://www.lifeview.hk/dbimages/document/$sourcefile";
135 my $hash = "1ea24dee4eea8fe971686981f34fd2e0";
136 my $outfile = "dvb-fe-tda10046.fw";
137 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
139 checkstandard();
141 wgetfile($sourcefile, $url);
142 unzip($sourcefile, $tmpdir);
143 extract("$tmpdir/LVHybrid.sys", 0x8b088, 24602, "$tmpdir/fwtmp");
144 verify("$tmpdir/fwtmp", $hash);
145 copy("$tmpdir/fwtmp", $outfile);
147 $outfile;
150 sub av7110 {
151 my $sourcefile = "dvb-ttpci-01.fw-261d";
152 my $url = "http://www.linuxtv.org/downloads/firmware/$sourcefile";
153 my $hash = "603431b6259715a8e88f376a53b64e2f";
154 my $outfile = "dvb-ttpci-01.fw";
156 checkstandard();
158 wgetfile($sourcefile, $url);
159 verify($sourcefile, $hash);
160 copy($sourcefile, $outfile);
162 $outfile;
165 sub dec2000t {
166 my $sourcefile = "dec217g.exe";
167 my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
168 my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9";
169 my $outfile = "dvb-ttusb-dec-2000t.fw";
170 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
172 checkstandard();
174 wgetfile($sourcefile, $url);
175 unzip($sourcefile, $tmpdir);
176 verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash);
177 copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile);
179 $outfile;
182 sub dec2540t {
183 my $sourcefile = "dec217g.exe";
184 my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
185 my $hash = "53e58f4f5b5c2930beee74a7681fed92";
186 my $outfile = "dvb-ttusb-dec-2540t.fw";
187 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
189 checkstandard();
191 wgetfile($sourcefile, $url);
192 unzip($sourcefile, $tmpdir);
193 verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash);
194 copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile);
196 $outfile;
199 sub dec3000s {
200 my $sourcefile = "dec217g.exe";
201 my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
202 my $hash = "b013ececea83f4d6d8d2a29ac7c1b448";
203 my $outfile = "dvb-ttusb-dec-3000s.fw";
204 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
206 checkstandard();
208 wgetfile($sourcefile, $url);
209 unzip($sourcefile, $tmpdir);
210 verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash);
211 copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile);
213 $outfile;
215 sub opera1{
216 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
218 checkstandard();
219 my $fwfile1="dvb-usb-opera1-fpga-01.fw";
220 my $fwfile2="dvb-usb-opera-01.fw";
221 extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw");
222 extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1");
223 extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2");
224 delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1");
225 delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1");
226 verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70");
227 verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1");
228 verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d");
230 my $RES1="\x01\x92\x7f\x00\x01\x00";
231 my $RES0="\x01\x92\x7f\x00\x00\x00";
232 my $DAT1="\x01\x00\xe6\x00\x01\x00";
233 my $DAT0="\x01\x00\xe6\x00\x00\x00";
234 open FW,">$tmpdir/opera.fw";
235 print FW "$RES1";
236 print FW "$DAT1";
237 print FW "$RES1";
238 print FW "$DAT1";
239 appendfile(FW,"$tmpdir/fw1part1-1");
240 print FW "$RES0";
241 print FW "$DAT0";
242 print FW "$RES1";
243 print FW "$DAT1";
244 appendfile(FW,"$tmpdir/fw1part2-1");
245 print FW "$RES1";
246 print FW "$DAT1";
247 print FW "$RES0";
248 print FW "$DAT0";
249 copy ("$tmpdir/opera1-fpga.fw",$fwfile1);
250 copy ("$tmpdir/opera.fw",$fwfile2);
252 $fwfile1.",".$fwfile2;
255 sub vp7041 {
256 my $sourcefile = "2.422.zip";
257 my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile";
258 my $hash = "e88c9372d1f66609a3e7b072c53fbcfe";
259 my $outfile = "dvb-vp7041-2.422.fw";
260 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
262 checkstandard();
264 wgetfile($sourcefile, $url);
265 unzip($sourcefile, $tmpdir);
266 extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1");
267 extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2");
269 my $CMD = "\000\001\000\222\177\000";
270 my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000";
271 my ($FW);
272 open $FW, ">$tmpdir/fwtmp3";
273 print $FW "$CMD\001$PAD";
274 print $FW "$CMD\001$PAD";
275 appendfile($FW, "$tmpdir/fwtmp1");
276 print $FW "$CMD\000$PAD";
277 print $FW "$CMD\001$PAD";
278 appendfile($FW, "$tmpdir/fwtmp2");
279 print $FW "$CMD\001$PAD";
280 print $FW "$CMD\000$PAD";
281 close($FW);
283 verify("$tmpdir/fwtmp3", $hash);
284 copy("$tmpdir/fwtmp3", $outfile);
286 $outfile;
289 sub dibusb {
290 my $url = "http://www.linuxtv.org/downloads/firmware/dvb-usb-dibusb-5.0.0.11.fw";
291 my $outfile = "dvb-dibusb-5.0.0.11.fw";
292 my $hash = "fa490295a527360ca16dcdf3224ca243";
294 checkstandard();
296 wgetfile($outfile, $url);
297 verify($outfile,$hash);
299 $outfile;
302 sub nxt2002 {
303 my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip";
304 my $url = "http://www.bbti.us/download/windows/$sourcefile";
305 my $hash = "476befae8c7c1bb9648954060b1eec1f";
306 my $outfile = "dvb-fe-nxt2002.fw";
307 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
309 checkstandard();
311 wgetfile($sourcefile, $url);
312 unzip($sourcefile, $tmpdir);
313 verify("$tmpdir/SkyNET.sys", $hash);
314 extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile);
316 $outfile;
319 sub nxt2004 {
320 my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip";
321 my $url = "http://www.avermedia-usa.com/support/Drivers/$sourcefile";
322 my $hash = "111cb885b1e009188346d72acfed024c";
323 my $outfile = "dvb-fe-nxt2004.fw";
324 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
326 checkstandard();
328 wgetfile($sourcefile, $url);
329 unzip($sourcefile, $tmpdir);
330 verify("$tmpdir/3xHybrid.sys", $hash);
331 extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile);
333 $outfile;
336 sub or51211 {
337 my $fwfile = "dvb-fe-or51211.fw";
338 my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
339 my $hash = "d830949c771a289505bf9eafc225d491";
341 checkstandard();
343 wgetfile($fwfile, $url);
344 verify($fwfile, $hash);
346 $fwfile;
349 sub cx231xx {
350 my $fwfile = "v4l-cx231xx-avcore-01.fw";
351 my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
352 my $hash = "7d3bb956dc9df0eafded2b56ba57cc42";
354 checkstandard();
356 wgetfile($fwfile, $url);
357 verify($fwfile, $hash);
359 $fwfile;
362 sub cx18 {
363 my $url = "http://linuxtv.org/downloads/firmware/";
365 my %files = (
366 'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a',
367 'v4l-cx23418-cpu.fw' => 'b6c7ed64bc44b1a6e0840adaeac39d79',
368 'v4l-cx23418-dig.fw' => '95bc688d3e7599fd5800161e9971cc55',
371 checkstandard();
373 my $allfiles;
374 foreach my $fwfile (keys %files) {
375 wgetfile($fwfile, "$url/$fwfile");
376 verify($fwfile, $files{$fwfile});
377 $allfiles .= " $fwfile";
380 $allfiles =~ s/^\s//;
382 $allfiles;
385 sub mpc718 {
386 my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip';
387 my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive";
388 my $fwfile = "dvb-cx18-mpc718-mt352.fw";
389 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
391 checkstandard();
392 wgetfile($archive, $url);
393 unzip($archive, $tmpdir);
395 my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys";
396 my $found = 0;
398 open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n";
399 binmode IN;
400 open OUT, '>', $fwfile;
401 binmode OUT;
403 # Block scope because we change the line terminator variable $/
404 my $prevlen = 0;
405 my $currlen;
407 # Buried in the data segment are 3 runs of almost identical
408 # register-value pairs that end in 0x5d 0x01 which is a "TUNER GO"
409 # command for the MT352.
410 # Pull out the middle run (because it's easy) of register-value
411 # pairs to make the "firmware" file.
413 local $/ = "\x5d\x01"; # MT352 "TUNER GO"
415 while (<IN>) {
416 $currlen = length($_);
417 if ($prevlen == $currlen && $currlen <= 64) {
418 chop; chop; # Get rid of "TUNER GO"
419 s/^\0\0//; # get rid of leading 00 00 if it's there
420 printf OUT "$_";
421 $found = 1;
422 last;
424 $prevlen = $currlen;
427 close OUT;
428 close IN;
429 if (!$found) {
430 unlink $fwfile;
431 die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n";
433 $fwfile;
436 sub cx23885 {
437 my $url = "http://linuxtv.org/downloads/firmware/";
439 my %files = (
440 'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb',
441 'v4l-cx23885-enc.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb',
444 checkstandard();
446 my $allfiles;
447 foreach my $fwfile (keys %files) {
448 wgetfile($fwfile, "$url/$fwfile");
449 verify($fwfile, $files{$fwfile});
450 $allfiles .= " $fwfile";
453 $allfiles =~ s/^\s//;
455 $allfiles;
458 sub pvrusb2 {
459 my $url = "http://linuxtv.org/downloads/firmware/";
461 my %files = (
462 'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320',
465 checkstandard();
467 my $allfiles;
468 foreach my $fwfile (keys %files) {
469 wgetfile($fwfile, "$url/$fwfile");
470 verify($fwfile, $files{$fwfile});
471 $allfiles .= " $fwfile";
474 $allfiles =~ s/^\s//;
476 $allfiles;
479 sub or51132_qam {
480 my $fwfile = "dvb-fe-or51132-qam.fw";
481 my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
482 my $hash = "7702e8938612de46ccadfe9b413cb3b5";
484 checkstandard();
486 wgetfile($fwfile, $url);
487 verify($fwfile, $hash);
489 $fwfile;
492 sub or51132_vsb {
493 my $fwfile = "dvb-fe-or51132-vsb.fw";
494 my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
495 my $hash = "c16208e02f36fc439a557ad4c613364a";
497 checkstandard();
499 wgetfile($fwfile, $url);
500 verify($fwfile, $hash);
502 $fwfile;
505 sub bluebird {
506 my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw";
507 my $outfile = "dvb-usb-bluebird-01.fw";
508 my $hash = "658397cb9eba9101af9031302671f49d";
510 checkstandard();
512 wgetfile($outfile, $url);
513 verify($outfile,$hash);
515 $outfile;
518 sub af9015 {
519 my $sourcefile = "download.ashx?file=57";
520 my $url = "http://www.ite.com.tw/EN/Services/$sourcefile";
521 my $hash = "ff5b096ed47c080870eacdab2de33ad6";
522 my $outfile = "dvb-usb-af9015.fw";
523 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
524 my $fwoffset = 0x22708;
525 my $fwlength = 18225;
526 my ($chunklength, $buf, $rcount);
528 checkstandard();
530 wgetfile($sourcefile, $url);
531 unzip($sourcefile, $tmpdir);
532 verify("$tmpdir/Driver/Files/AF15BDA.sys", $hash);
534 open INFILE, '<', "$tmpdir/Driver/Files/AF15BDA.sys";
535 open OUTFILE, '>', $outfile;
537 sysseek(INFILE, $fwoffset, SEEK_SET);
538 while($fwlength > 0) {
539 $chunklength = 55;
540 $chunklength = $fwlength if ($chunklength > $fwlength);
541 $rcount = sysread(INFILE, $buf, $chunklength);
542 die "Ran out of data\n" if ($rcount != $chunklength);
543 syswrite(OUTFILE, $buf);
544 sysread(INFILE, $buf, 8);
545 $fwlength -= $rcount + 8;
548 close OUTFILE;
549 close INFILE;
552 sub ngene {
553 my $url = "http://www.digitaldevices.de/download/";
554 my $file1 = "ngene_15.fw";
555 my $hash1 = "d798d5a757121174f0dbc5f2833c0c85";
556 my $file2 = "ngene_17.fw";
557 my $hash2 = "26b687136e127b8ac24b81e0eeafc20b";
559 checkstandard();
561 wgetfile($file1, $url . $file1);
562 verify($file1, $hash1);
564 wgetfile($file2, $url . $file2);
565 verify($file2, $hash2);
567 "$file1, $file2";
570 # ---------------------------------------------------------------
571 # Utilities
573 sub checkstandard {
574 if (system("which unzip > /dev/null 2>&1")) {
575 die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n";
577 if (system("which md5sum > /dev/null 2>&1")) {
578 die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n";
580 if (system("which wget > /dev/null 2>&1")) {
581 die "This firmware requires the wget command - see http://wget.sunsite.dk/\n";
585 sub checkunshield {
586 if (system("which unshield > /dev/null 2>&1")) {
587 die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n";
591 sub wgetfile {
592 my ($sourcefile, $url) = @_;
594 if (! -f $sourcefile) {
595 system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware";
599 sub unzip {
600 my ($sourcefile, $todir) = @_;
602 $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" );
603 if ((($status >> 8) > 2) || (($status & 0xff) != 0)) {
604 die ("unzip failed - unable to extract firmware");
608 sub unshield {
609 my ($sourcefile, $todir) = @_;
611 system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware");
614 sub verify {
615 my ($filename, $hash) = @_;
616 my ($testhash);
618 open(CMD, "md5sum \"$filename\"|");
619 $testhash = <CMD>;
620 $testhash =~ /([a-zA-Z0-9]*)/;
621 $testhash = $1;
622 close CMD;
623 die "Hash of extracted file does not match!\n" if ($testhash ne $hash);
626 sub copy {
627 my ($from, $to) = @_;
629 system("cp -f \"$from\" \"$to\"") and die ("cp failed");
632 sub extract {
633 my ($infile, $offset, $length, $outfile) = @_;
634 my ($chunklength, $buf, $rcount);
636 open INFILE, "<$infile";
637 open OUTFILE, ">$outfile";
638 sysseek(INFILE, $offset, SEEK_SET);
639 while($length > 0) {
640 # Calc chunk size
641 $chunklength = 2048;
642 $chunklength = $length if ($chunklength > $length);
644 $rcount = sysread(INFILE, $buf, $chunklength);
645 die "Ran out of data\n" if ($rcount != $chunklength);
646 syswrite(OUTFILE, $buf);
647 $length -= $rcount;
649 close INFILE;
650 close OUTFILE;
653 sub appendfile {
654 my ($FH, $infile) = @_;
655 my ($buf);
657 open INFILE, "<$infile";
658 while(1) {
659 $rcount = sysread(INFILE, $buf, 2048);
660 last if ($rcount == 0);
661 print $FH $buf;
663 close(INFILE);
666 sub delzero{
667 my ($infile,$outfile) =@_;
669 open INFILE,"<$infile";
670 open OUTFILE,">$outfile";
671 while (1){
672 $rcount=sysread(INFILE,$buf,22);
673 $len=ord(substr($buf,0,1));
674 print OUTFILE substr($buf,0,1);
675 print OUTFILE substr($buf,2,$len+3);
676 last if ($rcount<1);
677 printf OUTFILE "%c",0;
678 #print $len." ".length($buf)."\n";
681 close(INFILE);
682 close(OUTFILE);
685 sub syntax() {
686 print STDERR "syntax: get_dvb_firmware <component>\n";
687 print STDERR "Supported components:\n";
688 @components = sort @components;
689 for($i=0; $i < scalar(@components); $i++) {
690 print STDERR "\t" . $components[$i] . "\n";
692 exit(1);