diff --git a/configure.ac b/configure.ac index 09d59c0..0f492c1 100644 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,7 @@ AC_INIT([cyrus-timezones],[1.0]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_HEADERS(config.h) dnl Checks for programs. AC_PROG_CC @@ -29,7 +30,12 @@ dnl AC_FUNC_VPRINTF dnl AC_CHECK_FUNCS([gettimeofday memset strchr strdup strpbrk]) dnl Checks for required libraries -PKG_CHECK_MODULES([ICAL], [libical]) +PKG_CHECK_MODULES([ICAL], [libical], [ + dnl icalrecurrencetype_new will be new in libical 4.0 + AC_CHECK_LIB(ical, icalrecurrencetype_new, + AC_DEFINE(HAVE_RECUR_BY_REF,[], + [Do we have support for icalrecurrencetype by reference?])) +]) AC_SUBST([ICAL_LIBS]) AC_SUBST([ICAL_CFLAGS]) PKG_CHECK_VAR([ICAL_LIBDIR], [libical], [libdir]) diff --git a/guesstz/guesstz.c b/guesstz/guesstz.c index 36ae27d..598b6c2 100644 --- a/guesstz/guesstz.c +++ b/guesstz/guesstz.c @@ -57,6 +57,7 @@ #include #include +#include "config.h" #include "guesstz.h" /* @@ -391,17 +392,24 @@ static void expand_icalobservances(icalcomponent *vtz, } if (rrule_prop) { +#ifdef HAVE_RECUR_BY_REF + struct icalrecurrencetype *rrule = + icalproperty_get_rrule(rrule_prop); + icaltimetype *rrule_until = &rrule->until; +#else struct icalrecurrencetype rrule = icalproperty_get_rrule(rrule_prop); + icaltimetype *rrule_until = &rrule.until; +#endif icalrecur_iterator *ritr = NULL; - unsigned eternal = icaltime_is_null_time(rrule.until); + unsigned eternal = icaltime_is_null_time(*rrule_until); unsigned trunc_until = 0; /* Check RRULE duration */ - if (!eternal && icaltime_compare(rrule.until, start) < 0) { + if (!eternal && icaltime_compare(*rrule_until, start) < 0) { /* RRULE ends prior to our window open - check UNTIL vs tombstone */ - obs.onset = rrule.until; + obs.onset = *rrule_until; if (need_tomb) check_tombstone(&tombstone, &obs); /* Remove RRULE */ @@ -411,15 +419,15 @@ static void expand_icalobservances(icalcomponent *vtz, else { /* RRULE ends on/after our window open */ if (!icaltime_is_null_time(end) && - (eternal || icaltime_compare(rrule.until, end) >= 0)) { + (eternal || icaltime_compare(*rrule_until, end) >= 0)) { /* RRULE ends after our window close - need to adjust it */ trunc_until = 1; } if (!eternal) { /* Adjust UNTIL to local time (for iterator) */ - icaltime_adjust(&rrule.until, 0, 0, 0, obs.offset_from); - icaltime_set_utc(&rrule.until, 0); + icaltime_adjust(rrule_until, 0, 0, 0, obs.offset_from); + icaltime_set_utc(rrule_until, 0); } if (trunc_dtstart) { @@ -470,7 +478,7 @@ static void expand_icalobservances(icalcomponent *vtz, } else if (!eternal) { /* Set UNTIL to previous onset */ - rrule.until = prev_onset; + *rrule_until = prev_onset; icalproperty_set_rrule(rrule_prop, rrule); } @@ -496,7 +504,7 @@ static void expand_icalobservances(icalcomponent *vtz, trunc_dtstart = 0; /* Check if new DSTART is within 1yr of UNTIL */ - ydiff = rrule.until.year - recur.year; + ydiff = rrule_until->year - recur.year; if (!trunc_until && ydiff <= 1) { /* Remove RRULE */ icalcomponent_remove_property(comp, rrule_prop); @@ -505,7 +513,7 @@ static void expand_icalobservances(icalcomponent *vtz, if (ydiff) { /* Add UNTIL as RDATE */ struct icaldatetimeperiodtype rdate = { - rrule.until, + *rrule_until, icalperiodtype_null_period() }; prop = icalproperty_new_rdate(rdate);