Commit d7f237b8 authored by Lev Walkin's avatar Lev Walkin

support for RFC 3852

parent cc3e13d4
...@@ -33,22 +33,29 @@ while(<>) { ...@@ -33,22 +33,29 @@ while(<>) {
# The least correct way to find the start of ASN # The least correct way to find the start of ASN
# definition. # definition.
# #
if(/^[ \t]*END[ \t]*$/) { if(/^[ \t]*END[ \t]*(--.*)?$/) {
print STDERR print STDERR
"Missed an ASN.1 grammar before line ". $. ."?\n"; "Missed an ASN.1 grammar before line ". $. ."?\n";
unlink($currentFile) or die "Can't remove $!";
print STDERR "Removed $currentFile";
exit(1); exit(1);
} }
my $modName = ''; # ASN.1 module name
my $rfcid = ''; my $rfcid = '';
$rfcid = $1 . '-' if($ARGV =~ /([a-z0-9]+)/i); $rfcid = $1 . '-' if($ARGV =~ /([a-z0-9]+)/i);
if(/^[ \t]+([A-Za-z0-9-]+).*DEFINITIONS.*::=/) { if(/^[ \t]+([A-Z][A-Za-z0-9-]*).*DEFINITIONS.*::=/) {
$currentFname = $rfcid . $1 . ".asn1"; $modName = $1;
$currentFname = $rfcid . $modName . ".asn1";
$inasn = 1; $inasn = 1;
} elsif(/^[ \t]*([A-Za-z0-9-]+).*{.*iso/) { } elsif(/^[ \t]*([A-Z][A-Za-z0-9-]*).*{[ \t]*iso/
$currentFname = $rfcid . $1 . ".asn1"; || /^[ \t]*{[ \t]*iso/) {
$modName = $1;
unless(length($modName)) {
next unless $prevLine =~
/^[ \t]*([A-Z][A-Za-z0-9-]*)[ \t]*$/;
$modName = $1;
}
$currentFname = $rfcid . $modName . ".asn1";
my @a = ($_); my @a = ($_);
my $i; my $i;
for($i = 0; $i < 8; $i++) { for($i = 0; $i < 8; $i++) {
...@@ -62,10 +69,11 @@ while(<>) { ...@@ -62,10 +69,11 @@ while(<>) {
} }
next unless $inasn; next unless $inasn;
} else { } else {
$prevLine = $_;
next; next;
} }
print STDERR "Found $1 at line $. => $currentFname\n"; print STDERR "Found $modName at line $.\n=> Saving as $currentFname\n";
open(O, "> $currentFname") or die "Can't open $currentFname"; open(O, "> $currentFname") or die "Can't open $currentFname";
select(O); select(O);
...@@ -77,7 +85,7 @@ while(<>) { ...@@ -77,7 +85,7 @@ while(<>) {
print "\n"; print "\n";
} }
if(/^[ \t]*END[ \t]*$/) { if(/^[ \t]*END[ \t]*(--.*)?$/) {
print; print;
select(STDOUT); select(STDOUT);
close(O); close(O);
...@@ -92,7 +100,7 @@ while(<>) { ...@@ -92,7 +100,7 @@ while(<>) {
# ASN.1 extraction and do not want to alter the ASN.1 specs. # ASN.1 extraction and do not want to alter the ASN.1 specs.
# #
if( if(
/^(.*)((UniversalString|BMPString|UTF8String)\s+::=\s+\[[A-Z]+\s\d+\]\sIMPLICIT\sOCTET\sSTRING)(.*)$/ms /^([ \t]*)((UniversalString|BMPString|UTF8String)\s+::=\s+\[[A-Z]+\s\d+\]\sIMPLICIT\sOCTET\sSTRING)(.*)$/ms
) { ) {
print "\n-- Legacy redefinition of $3 removed by $0:\n"; print "\n-- Legacy redefinition of $3 removed by $0:\n";
print "$1-- $2 -- $4"; print "$1-- $2 -- $4";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment