diff options
author | Ken Murchison <murch@fastmail.com> | 2022-01-06 15:39:57 -0500 |
---|---|---|
committer | Ken Murchison <murch@fastmail.com> | 2022-01-06 15:39:57 -0500 |
commit | ab139b5dbe7c0104b96ec0fe0c6277a7ec296ac6 (patch) | |
tree | b1ecc7b52733955fb5f9654c4acfe4881af38b04 /scripts | |
parent | a9fb0936a3d75ef1e463f6d2ed02bf02daa41a7a (diff) | |
download | libical-git-ab139b5dbe7c0104b96ec0fe0c6277a7ec296ac6.tar.gz |
mkrestrictiontable.pl: add component restrictions to table
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/mkrestrictiontable.pl | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/scripts/mkrestrictiontable.pl b/scripts/mkrestrictiontable.pl index 21bc499a..ca8c8355 100755 --- a/scripts/mkrestrictiontable.pl +++ b/scripts/mkrestrictiontable.pl @@ -47,8 +47,9 @@ if ($opt_i) { sub insert_code { - # First build the property restriction table - print "static const icalrestriction_property_record icalrestriction_property_records[] = {\n"; + # First parse the restrictions file and make a hash of the restrictions + my @prop_restr = (); + my @comp_restr = (); while (<F>) { @@ -67,17 +68,36 @@ sub insert_code } $restr =~ s/\s+$//; - if ($prop ne "NONE") { - print( -" \{ICAL_METHOD_${method}, ICAL_${targetcomp}_COMPONENT, ICAL_${prop}_PROPERTY, ICAL_RESTRICTION_${restr}, $sub},\n" - ); + if ($prop eq "NONE") { + $prop = "NO"; + } + if ($subcomp eq "NONE") { + $subcomp = "NO"; } + my @value = ($restr, $sub); + $prop_restr{$method}{$targetcomp}{$prop}{$subcomp} = \@value; } + # Build the restriction table + print "static const icalrestriction_record icalrestriction_records[] = {\n"; + + for $method ( sort keys %prop_restr ) { + for $targetcomp ( sort keys %{ $prop_restr{$method} } ) { + for $prop ( sort keys %{ $prop_restr{$method}{$targetcomp} } ) { + for $subcomp ( sort keys %{ $prop_restr{$method}{$targetcomp}{$prop} } ) { + my ($restr, $sub) = @{$prop_restr{$method}{$targetcomp}{$prop}{$subcomp}}; + print( +" \{ICAL_METHOD_${method}, ICAL_${targetcomp}_COMPONENT, ICAL_${prop}_PROPERTY, ICAL_${subcomp}_COMPONENT, ICAL_RESTRICTION_${restr}, $sub},\n" + ); + } + } + } +} + # Print the terminating line print - " {ICAL_METHOD_NONE, ICAL_NO_COMPONENT, ICAL_NO_PROPERTY, ICAL_RESTRICTION_NONE, NULL}\n"; + " {ICAL_METHOD_NONE, ICAL_NO_COMPONENT, ICAL_NO_PROPERTY, ICAL_NO_COMPONENT, ICAL_RESTRICTION_NONE, NULL}\n"; print "};\n"; |