Completed framework for caldav_apply_one_filter()
authorArt Cancro <ajc@citadel.org>
Wed, 14 Feb 2024 18:16:33 +0000 (13:16 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 14 Feb 2024 18:16:33 +0000 (13:16 -0500)
Now we have an array of tokens containing the filter name and all attributes.

webcit-ng/server/caldav_reports.c
webcit-ng/server/webcit.h

index f4eb6c06ad14b9bb61580727c4b188a40d21b509..21dbdb74e55a41b27e5c31864cbec49db15f946d 100644 (file)
@@ -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);
 }
 
index ec66ece335b4ff6faf6301407526057d8a7c393d..657ac18b222bfc0fcb2dca0799d99c3323e1a157 100644 (file)
@@ -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