From 2d5504af09fb903b0a9bbd105481ba67c309d34d Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 10 Feb 2024 14:17:33 -0500 Subject: [PATCH] Improved logging of XML parse --- webcit-ng/server/caldav_reports.c | 39 +++++++++++++++++++++---------- webcit-ng/server/webcit.h | 5 ++-- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index 1c95c3806..e6a13cef0 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -1,10 +1,6 @@ -// This file contains functions which handle all of the CalDAV "REPORT" queries -// specified in RFC4791 section 7. -// +// This file contains functions which handle all of the CalDAV "REPORT" queries specified in RFC4791 section 7. // Copyright (c) 2023-2024 by the citadel.org team -// -// This program is open source software. Use, duplication, or -// disclosure is subject to the GNU General Public License v3. +// This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License v3. #include "webcit.h" @@ -31,13 +27,21 @@ struct cr_parms { // XML parser callback void caldav_xml_start(void *data, const char *el, const char **attr) { struct cr_parms *crp = (struct cr_parms *) data; - int i; - - // syslog(LOG_DEBUG, "CALDAV ELEMENT START: <%s> %d", el, crp->tag_nesting_level); +#ifdef DEBUG_XML_PARSE + // logging + int i; + char indent[256]; + indent[0] = 0; + for (i=0; itag_nesting_level; ++i) { + strcat(indent, " "); + } + syslog(LOG_DEBUG, "%s<%s>", indent, el); for (i = 0; attr[i] != NULL; i += 2) { - syslog(LOG_DEBUG, " Attribute '%s' = '%s'", attr[i], attr[i + 1]); + syslog(LOG_DEBUG, "%sAttribute '%s' = '%s'", indent, attr[i], attr[i + 1]); } + // end logging +#endif // RFC4791 7.8 "calendar-query" REPORT - Client will send a lot of search criteria. if (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:calendar-query")) { @@ -61,12 +65,23 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { // XML parser callback void caldav_xml_end(void *data, const char *el) { struct cr_parms *crp = (struct cr_parms *) data; + --crp->tag_nesting_level; +#ifdef DEBUG_XML_PARSE + // logging + int i; + char indent[256]; + indent[0] = 0; + for (i=0; itag_nesting_level; ++i) { + strcat(indent, " "); + } if (crp->Chardata != NULL) { - // syslog(LOG_DEBUG, "CALDAV CHARDATA : %s", ChrPtr(crp->Chardata)); + syslog(LOG_DEBUG, "%sCHARDATA: '%s'", indent, ChrPtr(crp->Chardata)); } - // syslog(LOG_DEBUG, "CALDAV ELEMENT END : <%s> %d", el, crp->tag_nesting_level); + syslog(LOG_DEBUG, "%s", indent, el); + // end logging +#endif if ((!strcasecmp(el, "DAV::href")) || (!strcasecmp(el, "DAV:href"))) { if (crp->Hrefs == NULL) { // append crp->Chardata to crp->Hrefs diff --git a/webcit-ng/server/webcit.h b/webcit-ng/server/webcit.h index b5b8bb2e3..a773a32c5 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -6,9 +6,10 @@ // disclosure is subject to the GNU General Public License v3. // uncomment one or more of these to see raw http transactions -#define DEBUG_HTTP -#define REQUEST_BODY_TO_STDERR +//#define DEBUG_HTTP +//#define REQUEST_BODY_TO_STDERR //#define RESPONSE_BODY_TO_STDERR +#define DEBUG_XML_PARSE #define SHOW_ME_VAPPEND_PRINTF -- 2.30.2