summaryrefslogtreecommitdiffstats
path: root/data/gen-error-list.pl
blob: 40204da8481797e21c3a06423f4322628dfe5156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env perl
use strict;
my $doc_start;
my $error_data;
my $line;
my @errors;

while ($line = <>) {
	chomp $line;

	$line =~ /^\/\*\*/ and do {
		$doc_start = 1;
		next;
	};

	$line =~ /^\s*\*\// and undef $error_data;

	$doc_start and $line =~ /^\s*\*\s*QmiProtocolError:/ and do {
		$error_data = 1;
		undef $doc_start;
		next;
	};
	undef $doc_start;

	$line =~ /^.*@([A-Z0-9_]+): ([A-z0-9 ]+)[.].*$/ and push @errors, [ $1, $2 ];
}

@errors > 0 or die "No data found\n";

print <<EOF;
static const struct {
	QmiProtocolError code;
	const char *text;
} qmi_errors[] = {
EOF
foreach my $error (@errors) {
	print "\t{ ".$error->[0].", \"".$error->[1]."\" },\n";
}
print <<EOF;
};
EOF