Restore licensing for embedded libical
[claws.git] / src / plugins / vcalendar / libical / scripts / mkrestrictiontable.pl
1 #!/usr/bin/perl
2
3 use Getopt::Std;
4 getopts('i:');
5
6 # the argument should be the path to the restriction datafile, usually
7 # design-data/restrictions.csv        
8 open(F,"$ARGV[0]") || die "Can't open restriction data file $ARGV[0]:$!";
9
10 # Write the file inline by copying everything before a demarcation
11 # line, and putting the generated data after the demarcation
12
13 if ($opt_i) {
14
15   open(IN,$opt_i) || die "Can't open input file $opt_i";
16
17   while(<IN>){
18
19     if (/Do not edit/){
20       last;
21     }
22
23     print;
24
25   }    
26
27   print "/* Everything below this line is machine generated. Do not edit. */\n";
28
29
30   close IN;
31 }
32
33 # First build the property restriction table 
34 print "icalrestriction_property_record icalrestriction_property_records[] = {\n";
35
36 while(<F>)
37 {
38
39   chop;
40
41   s/\#.*$//;
42
43   my($method,$targetcomp,$prop,$subcomp,$restr,$sub) = split(/,/,$_);
44
45   next if !$method;
46   
47   if(!$sub) {
48     $sub = "0";
49   } else {
50     $sub = "icalrestriction_".$sub;
51   }
52
53   if($prop ne "NONE"){
54     print("    \{ICAL_METHOD_${method},ICAL_${targetcomp}_COMPONENT,ICAL_${prop}_PROPERTY,ICAL_RESTRICTION_${restr},$sub},\n");
55   }
56
57 }
58
59
60 # Print the terminating line 
61 print "    {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_NONE}\n";
62
63 print "};\n";
64
65 print "icalrestriction_component_record icalrestriction_component_records[] = {\n";
66
67
68 # Go back through the entire file and build the component restriction table
69 close(F);  
70 open(F,"$ARGV[0]") || die "Can't open restriction data file $ARGV[0]:$!";
71
72 while(<F>)
73 {
74
75   chop;
76
77   s/\#.*$//;
78
79   my($method,$targetcomp,$prop,$subcomp,$restr,$sub) = split(/,/,$_);
80
81   next if !$method;
82   
83   if(!$sub) {
84     $sub = "0";
85   } else {
86     $sub = "icalrestriction_".$sub;
87   }
88
89
90     if($subcomp ne "NONE"){
91       print("    \{ICAL_METHOD_${method},ICAL_${targetcomp}_COMPONENT,ICAL_${subcomp}_COMPONENT,ICAL_RESTRICTION_${restr},$sub\},\n");
92     }
93
94 }
95
96 # print the terminating line 
97 print "    {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE}\n";
98 print "};\n";