From: Art Cancro Date: Wed, 14 Feb 2024 18:16:33 +0000 (-0500) Subject: Completed framework for caldav_apply_one_filter() X-Git-Tag: v999~44 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=b71f6ba27ff81252619feaea6c5046e4502403df Completed framework for caldav_apply_one_filter() Now we have an array of tokens containing the filter name and all attributes. --- diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index f4eb6c06a..21dbdb74e 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -80,12 +80,11 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { ) { char newfilter[SIZ]; int a = 0; - int len = snprintf(newfilter, SIZ, &el[23]); // strip off "urn:ietf:params:xml:ns:caldav:" for our purposes + int len = snprintf(newfilter, SIZ, &el[30]); // strip off "urn:ietf:params:xml:ns:caldav:" for our purposes while (attr[a]) { len += snprintf(&newfilter[len], SIZ-len, "|%s", attr[a++]); // now save the attributes } array_append(crp->filters, newfilter); - syslog(LOG_DEBUG, "%s", newfilter); } } @@ -270,6 +269,17 @@ void caldav_report_one_item(struct http_transaction *h, struct ctdlsession *c, S // Returns 1 if the calendar item DOES match the filter. int caldav_apply_one_filter(void *cal, char *filter) { syslog(LOG_DEBUG, "applying filter: %s", filter); + + char this_filter[SIZ]; // we have to copy the filter string because we will destructively tokenize it + safestrncpy(this_filter, filter, sizeof(this_filter)); + + char *t[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } ; + char *f = this_filter; + int num_tokens = 0; + while ( (t[num_tokens]=strtok_r(f, "|", &f)) && (num_tokens<10) ) { + ++num_tokens; + } + return(1); } diff --git a/webcit-ng/server/webcit.h b/webcit-ng/server/webcit.h index ec66ece33..657ac18b2 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -155,7 +155,10 @@ void caldav_xml_start(void *, const char *, const char **); void caldav_xml_end(void *, const char *); void caldav_xml_chardata(void *, const XML_Char *, int); StrBuf *fetch_ical(struct ctdlsession *, long); +void cal_multiget_out(long, StrBuf *, StrBuf *, StrBuf *); void caldav_report_one_item(struct http_transaction *, struct ctdlsession *, StrBuf *, StrBuf *); +int caldav_apply_one_filter(void *, char *); +int caldav_apply_filters(void *, Array *, int); void caldav_report(struct http_transaction *, struct ctdlsession *); // ctdlclient.c