require db4-devel
[platform/upstream/libical.git] / scripts / mkrestrictionrecords.pl
1 #!/usr/bin/env perl
2
3 # Version: 1.0
4 # Script last updated: 30May1999 GMD
5 # Change log:
6 # <none>
7
8 # usually open restrictions.csv
9 open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!";
10
11 print <<EOM;
12 /*
13   ======================================================================
14   File: restrictionrecords.c
15     
16  (C) COPYRIGHT 1999 Graham Davison
17  mailto:g.m.davison\@computer.org
18
19  The contents of this file are subject to the Mozilla Public License
20  Version 1.0 (the "License"); you may not use this file except in
21  compliance with the License. You may obtain a copy of the License at
22  http://www.mozilla.org/MPL/
23  
24  Software distributed under the License is distributed on an "AS IS"
25  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
26  the License for the specific language governing rights and
27  limitations under the License.
28  
29
30  ======================================================================*/
31
32
33 /*
34  * THIS FILE IS MACHINE GENERATED DO NOT EDIT
35  */
36
37
38 typedef struct icalrestriction_record {
39         icalproperty_method method;
40         icalcomponent_kind component;
41         icalproperty_kind property;
42         icalcomponent_kind subcomponent;
43         icalrestriction_kind restriction;
44 } icalrestriction_record;
45
46
47 icalrestriction_record icalrestriction_records[] = 
48 {
49 EOM
50
51 my $last_method = "";
52 my $last_component = "";
53 my $last_property = "";
54 my $need_header = 0;
55
56 while(<F>)
57 {
58         chop;
59         
60         # split line at commas
61         my ($method,$component,$property,$subcomponent,$restriction)=split(/\,/,$_);
62         
63         #
64         #put in code to generate comments here!
65         #
66         if ($method ne $last_method)
67         {
68                 $need_header = 1;
69                 $last_method = $method;
70         }
71         if ($component ne $last_component)
72         {
73                 $need_header = 1;
74                 $last_component = $component;
75         }
76         
77         if ($need_header)
78         {
79                 print "\n\t/* METHOD: ${method}, COMPONENT: ${component} */\n";
80                 $need_header = 0;
81         }
82         
83         foreach $item ($component,$property,$subcomponent,$restriction)
84         {
85                 # handle special cases.
86                 if ($item eq "NONE")
87                         { $item = "NO"; }
88                 else { if (substr($item,0,1) eq "X")
89                         { $item = "X"; }}
90                 
91                 # strip out dashes
92                 $item = join("",split(/-/,$item));
93         }
94         # strip leading V from component names
95         $component =~ s/^(V?)(\w+?)((SAVINGS)?)((TIME)?)$/$2/;
96         $subcomponent =~ s/^V(\w+)/$1/;
97
98         print "\t\{ICAL_METHOD_${method},ICAL_${component}_COMPONENT,";
99         print "ICAL_${property}_PROPERTY,ICAL_${subcomponent}_COMPONENT,";
100         print "ICAL_RESTRICTION_${restriction}\},\n";
101         
102 }
103
104 print <<EOM;
105         
106         /* END */
107         {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE}
108 };
109 EOM