aboutsummaryrefslogtreecommitdiffstats
path: root/dvb-t/be-Brussels
diff options
context:
space:
mode:
authorChristoph Pfister <pfister@linuxtv.org>2009-11-07 18:42:11 +0100
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-11-07 18:42:11 +0100
commit77867391a372881dea264e021e4cddf37379459a (patch)
tree02ef06c6d7ba7b553389502135668fc458087477 /dvb-t/be-Brussels
parent3211f5237d1f22bd7f805643a79bf00ac4e6cac9 (diff)
downloaddtv-scan-tables-77867391a372881dea264e021e4cddf37379459a.tar.gz
update scan file for au-SunshineCoast
submitted by bugs.kde.org 213197
Diffstat (limited to 'dvb-t/be-Brussels')
0 files changed, 0 insertions, 0 deletions
id='n84' href='#n84'>84 85 86 87 88 89 90 91 92
#!/usr/bin/perl -w

use strict;

die "no section perl file given" unless @ARGV;

my $h = require($ARGV[0]);

our $basename;
our $debug = $ARGV[1];

($basename) = $ARGV[0] =~ /([a-zA-Z0-9_\-_]+).pl/;

local *H;
local *C;

h_header();
c_header();

foreach (sort keys %{$h}) {
	foreach my $item (@{$h->{$_}}) {
		if ($_ eq "descriptors") {
			printf H ("#define %s_ID 0x%02X\n",uc($item->{name}),$item->{id});
		}

		do_it  ($item->{name},$item->{elements});
	}
}

h_footer();
c_footer();

sub type
{
	if ($_[0] > 16) {
		return "u32";
	} elsif ($_[0] > 8) {
		return "u16";
	} else {
		return "u8 ";
	}
}

sub do_it
{
	my ($name,$val) = @_;
	print H "struct $name {\n";

	print C <<EOL;
struct $name read_$name(const u8 *b)
{
	struct $name v;
EOL
	my $offs = 0;
	for (my $i = 0; $i < scalar @{$val}; $i+=2) {
		printf H ("\t\t%s %-25s :%2d;\n",type($val->[$i+1]),$val->[$i],$val->[$i+1]);

		printf C ("\tv.%-25s = getBits(b,%3d,%2d);\n",$val->[$i],$offs,$val->[$i+1]);
		printf C ("\tfprintf(stderr,\"  %s = %%x %%d\\n\",v.%s,v.%s);\n",$val->[$i],$val->[$i],$val->[$i]) if $debug;
		$offs += $val->[$i+1];
	}
	print H "} PACKED;\n";
	print H "struct $name read_$name(const u8 *);\n\n";

	print C "\treturn v;\n}\n\n"
}

sub h_header
{
	open(H,">$basename.h");
	print H "#ifndef __".uc($basename)."_H_\n";
	print H "#define __".uc($basename)."_H_\n\n";
	print H "#include \"section.h\"\n\n";
}

sub c_header
{
	open(C,">$basename.c");
	print C "#include \"$basename.h\"\n\n";
}


sub c_footer
{
	close(C);
}

sub h_footer
{
	print H "#endif\n";
	close(H);
}