+ icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
+ icalproperty *p;
+ icalproperty_kind Kind;
+ const char *str;
+
+ Kind = (icalproperty_kind) GetTemplateTokenNumber(Target, TP, 0, ICAL_ANY_PROPERTY);
+ p = icalcomponent_get_first_property(cal, Kind);
+ if (p != NULL) {
+ str = icalproperty_get_comment (p);
+ StrBufAppendTemplateStr(Target, TP, str, 1);
+ }
+}
+
+void tmplput_CtxICalProperty(StrBuf *Target, WCTemplputParams *TP)
+{
+ icalproperty *p = (icalproperty *) CTX(CTX_ICALPROPERTY);
+ const char *str;
+
+ str = icalproperty_get_comment (p);
+ StrBufAppendTemplateStr(Target, TP, str, 0);
+}
+
+int ReleaseIcalSubCtx(StrBuf *Target, WCTemplputParams *TP)
+{
+ WCTemplputParams *TPP = TP;
+ UnStackContext(TP);
+ free(TPP);
+ return 0;
+}
+int cond_ICalIsA(StrBuf *Target, WCTemplputParams *TP)
+{
+ icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
+ icalcomponent_kind c = GetTemplateTokenNumber(Target, TP, 2, ICAL_NO_COMPONENT);
+ return icalcomponent_isa(cal) == c;
+}
+
+int cond_ICalHaveItem(StrBuf *Target, WCTemplputParams *TP)
+{
+ icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
+ icalproperty *p;
+ icalproperty_kind Kind;
+
+ Kind = (icalproperty_kind) GetTemplateTokenNumber(Target, TP, 2, ICAL_ANY_PROPERTY);
+ p = icalcomponent_get_first_property(cal, Kind);
+ if (p != NULL) {
+ WCTemplputParams *DynamicTP;
+
+ DynamicTP = (WCTemplputParams*) malloc(sizeof(WCTemplputParams));
+ StackDynamicContext (TP,
+ DynamicTP,
+ p,
+ CTX_ICALPROPERTY,
+ 0,
+ TP->Tokens,
+ ReleaseIcalSubCtx,
+ TP->Tokens->Params[1]->lvalue);
+
+ return 1;
+ }
+ return 0;
+}
+
+int ReleaseIcalTimeCtx(StrBuf *Target, WCTemplputParams *TP)
+{
+ WCTemplputParams *TPP = TP;
+
+ UnStackContext(TP);
+ free(TPP);
+ return 0;
+}
+
+int cond_ICalHaveTimeItem(StrBuf *Target, WCTemplputParams *TP)
+{
+ icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
+ icalproperty *p;
+ icalproperty_kind Kind;
+
+ Kind = (icalproperty_kind) GetTemplateTokenNumber(Target, TP, 2, ICAL_ANY_PROPERTY);
+ p = icalcomponent_get_first_property(cal, Kind);
+ if (p != NULL) {
+ struct icaltimetype *t;
+ struct icaltimetype tt;
+ WCTemplputParams *DynamicTP;
+
+ DynamicTP = (WCTemplputParams*) malloc(sizeof(WCTemplputParams) +
+ sizeof(struct icaltimetype));
+ t = (struct icaltimetype *) &DynamicTP[1];
+ memset(&tt, 0, sizeof(struct icaltimetype));
+ switch (Kind)
+ {
+ case ICAL_DTSTART_PROPERTY:
+ tt = icalproperty_get_dtstart(p);
+ break;
+ case ICAL_DTEND_PROPERTY:
+ tt = icalproperty_get_dtend(p);
+ break;
+ default:
+ break;
+ }
+ memcpy(t, &tt, sizeof(struct icaltimetype));
+
+ StackDynamicContext (TP,
+ DynamicTP,
+ t,
+ CTX_ICALTIME,
+ 0,
+ TP->Tokens,
+ ReleaseIcalTimeCtx,
+ TP->Tokens->Params[1]->lvalue);
+
+ return 1;
+ }
+ return 0;
+}
+
+
+int cond_ICalTimeIsDate(StrBuf *Target, WCTemplputParams *TP)
+{
+ struct icaltimetype *t = (struct icaltimetype *) CTX(CTX_ICALTIME);
+ return t->is_date;
+}