
2001-10-22 Damon Chaplin <damon@ximian.com> * zoneinfo/*: updated all files again, placing current RDATEs first, so Outlook uses those. Also fixed a few bugs in vzic which resulted in a few changes. * zoneinfo/Makefile.am (DIRS): added America/North_Dakota. 2001-10-22 Damon Chaplin <damon@ximian.com> * src/libical/icaltimezone.c (icaltimezone_get_utc_offset): (icaltimezone_get_utc_offset_of_utc_time): if we go off the start of the changes array, return the TZOFFSETFROM of the first change. Also changed the maximum year to 2037. * src/libical/icaltime.c (icaltime_day_of_week): (icaltime_start_doy_of_week): (icaltime_week_number): init tm_hour to 12. Sometimes mktime() adjusts the time, if that local time doesn't actually exist, leading to the wrong day being returned. It is unlikely to adjust by 12 hours. (icaltime_as_timet_with_zone): (icaltime_from_timet_with_zone): change it back so it does convert DATE values to/from the timezone. time_t values don't really go well with DATE values, so be very careful when using them. We now assume that the time_t points to the start of the day in the given timezone. (We used to assume it pointed to the start of the day in UTC, but that meant it was actually incorrect wrt the displayed calendar.) * src/libical/icalrecur.c (expand_year_days): for FREQ=YEARLY with no modifiers, we add one day, using the month and day from DTSTART. (next_year): make sure we never go past 2037. * scripts/mkderivedproperties.pl: Updated to allow DTSTART, DTEND, DUE and RECURRENCE-ID to be set with DATE values. I think it now handles all properties which can take DATE values, except RDATE which uses DATE-TIME-PERIOD. svn path=/trunk/; revision=13912
241 lines
5.2 KiB
Perl
Executable File
241 lines
5.2 KiB
Perl
Executable File
#!/usr/local/bin/perl
|
|
|
|
require "readvaluesfile.pl";
|
|
|
|
use Getopt::Std;
|
|
getopts('chspmi:');
|
|
|
|
# ARG 0 is properties.csv
|
|
%propmap = read_properties_file($ARGV[0]);
|
|
|
|
# ARG 1 is value-types.txt
|
|
%valuemap = read_values_file($ARGV[1]);
|
|
|
|
|
|
# Write the file inline by copying everything before a demarcation
|
|
# line, and putting the generated data after the demarcation
|
|
|
|
if ($opt_i) {
|
|
|
|
open(IN,$opt_i) || die "Can't open input file $opt_i";
|
|
|
|
while(<IN>){
|
|
|
|
if (/Do not edit/){
|
|
last;
|
|
}
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
print "/* Everything below this line is machine generated. Do not edit. */\n";
|
|
|
|
|
|
}
|
|
|
|
sub fudge_data {
|
|
my $prop = shift;
|
|
|
|
my $value = $propmap{$prop}->{'lic_value'};
|
|
|
|
if (!$value){
|
|
die "Can't find value for property \"$prop\"\n";
|
|
}
|
|
my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$prop));
|
|
my $lc = lc($ucf);
|
|
my $uc = uc($lc);
|
|
|
|
my $ucfvalue = join("",map {ucfirst(lc($_));} split(/-/,$value));
|
|
my $lcvalue = lc($ucfvalue);
|
|
my $ucvalue = uc($lcvalue);
|
|
|
|
my $type = $valuemap{$value}->{C}->[1];
|
|
|
|
return ($uc,$lc,$lcvalue,$ucvalue,$type);
|
|
|
|
}
|
|
|
|
# Create the property map data
|
|
if($opt_c){
|
|
|
|
print "static struct icalproperty_map property_map[] = {\n";
|
|
|
|
foreach $prop (sort keys %propmap) {
|
|
|
|
next if !$prop;
|
|
|
|
next if $prop eq 'NO';
|
|
|
|
my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
|
|
|
|
print "{ICAL_${uc}_PROPERTY,\"$prop\",ICAL_${ucvalue}_VALUE},\n";
|
|
|
|
}
|
|
|
|
$prop = "NO";
|
|
|
|
my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
|
|
|
|
print "{ICAL_${uc}_PROPERTY,\"\",ICAL_NO_VALUE}};\n\n";
|
|
|
|
|
|
print "static struct icalproperty_enum_map enum_map[] = {\n";
|
|
|
|
$idx = 10000;
|
|
|
|
foreach $value (sort keys %valuemap) {
|
|
|
|
next if !$value;
|
|
next if $value eq 'NO' or $prop eq 'ANY';
|
|
|
|
my $ucv = join("",map {uc(lc($_));} split(/-/,$value));
|
|
my @enums = @{$valuemap{$value}->{'enums'}};
|
|
|
|
if(@enums){
|
|
|
|
my ($c_autogen,$c_type) = @{$valuemap{$value}->{'C'}};
|
|
|
|
unshift(@enums,"X");
|
|
push(@enums,"NONE");
|
|
|
|
foreach $e (@enums) {
|
|
|
|
my $uce = join("",map {uc(lc($_));} split(/-/,$e));
|
|
|
|
if($e ne "X" and $e ne "NONE"){
|
|
$str = $e;
|
|
} else {
|
|
$str = "";
|
|
}
|
|
|
|
print " {ICAL_${ucv}_PROPERTY,ICAL_${ucv}_${uce},\"$str\" }, /*$idx*/\n";
|
|
|
|
$idx++;
|
|
}
|
|
|
|
}
|
|
}
|
|
print " {ICAL_NO_PROPERTY,0,\"\"}\n};\n\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
if($opt_h){
|
|
|
|
# Create the property enumerations list
|
|
print "typedef enum icalproperty_kind {\n ICAL_ANY_PROPERTY = 0,\n";
|
|
foreach $prop (sort keys %propmap) {
|
|
|
|
next if !$prop;
|
|
|
|
next if $prop eq 'NO' or $prop eq 'ANY';
|
|
|
|
my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
|
|
|
|
print " ICAL_${uc}_PROPERTY, \n";
|
|
|
|
}
|
|
print " ICAL_NO_PROPERTY\n} icalproperty_kind;\n\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
foreach $prop (sort keys %propmap) {
|
|
|
|
next if !$prop;
|
|
|
|
next if $prop eq 'NO' or $prop eq 'ANY';
|
|
|
|
my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop);
|
|
|
|
|
|
my $pointer_check;
|
|
if ($type =~ /\*/){
|
|
$pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");\n" if $type =~ /\*/;
|
|
} elsif ( $type eq "void" ){
|
|
$pointer_check = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/;
|
|
|
|
}
|
|
|
|
my $set_pointer_check = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/;
|
|
|
|
if($opt_c) { # Generate C source
|
|
print<<EOM;
|
|
/* $prop */
|
|
icalproperty* icalproperty_new_${lc}($type v) {
|
|
struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY); $pointer_check
|
|
icalproperty_set_${lc}((icalproperty*)impl,v);
|
|
return (icalproperty*)impl;
|
|
}
|
|
icalproperty* icalproperty_vanew_${lc}($type v, ...){
|
|
va_list args;
|
|
struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY); $pointer_check
|
|
icalproperty_set_${lc}((icalproperty*)impl,v);
|
|
va_start(args,v);
|
|
icalproperty_add_parameters(impl, args);
|
|
va_end(args);
|
|
return (icalproperty*)impl;
|
|
}
|
|
EOM
|
|
|
|
# Allow DTSTART, DTEND, DUE, EXDATE and RECURRENCE-ID to take DATE values.
|
|
if ($lc eq "dtstart" || $lc eq "dtend" || $lc eq "due" || $lc eq "exdate"
|
|
|| $lc eq "recurrenceid") {
|
|
print<<EOM;
|
|
void icalproperty_set_${lc}(icalproperty* prop, $type v){
|
|
icalvalue *value;
|
|
$set_pointer_check
|
|
icalerror_check_arg_rv( (prop!=0),"prop");
|
|
if (v.is_date)
|
|
value = icalvalue_new_date(v);
|
|
else
|
|
value = icalvalue_new_datetime(v);
|
|
icalproperty_set_value(prop,value);
|
|
}
|
|
EOM
|
|
} else {
|
|
print<<EOM;
|
|
void icalproperty_set_${lc}(icalproperty* prop, $type v){
|
|
icalvalue *value;
|
|
$set_pointer_check
|
|
icalerror_check_arg_rv( (prop!=0),"prop");
|
|
value = icalvalue_new_${lcvalue}(v);
|
|
icalproperty_set_value(prop,value);
|
|
}
|
|
EOM
|
|
}
|
|
|
|
print<<EOM;
|
|
$type icalproperty_get_${lc}(icalproperty* prop){
|
|
icalvalue *value;
|
|
icalerror_check_arg( (prop!=0),"prop");
|
|
value = icalproperty_get_value(prop);
|
|
return icalvalue_get_${lcvalue}(value);
|
|
}
|
|
EOM
|
|
|
|
|
|
} elsif ($opt_h) { # Generate C Header file
|
|
print "\
|
|
/* $prop */\
|
|
icalproperty* icalproperty_new_${lc}($type v);\
|
|
icalproperty* icalproperty_vanew_${lc}($type v, ...);\
|
|
void icalproperty_set_${lc}(icalproperty* prop, $type v);\
|
|
$type icalproperty_get_${lc}(icalproperty* prop);";
|
|
|
|
}
|
|
|
|
|
|
} # This brace terminates the main loop
|
|
|
|
|
|
|
|
if ($opt_h){
|
|
|
|
print "\n\n#endif /*ICALPROPERTY_H*/\n"
|
|
}
|
|
|