From: Art Cancro Date: Mon, 12 Feb 2024 19:41:12 +0000 (-0500) Subject: Final changes to XML parser trace logging. X-Git-Tag: v999~47 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=a58a2ebc498fe473e72adc8d544162bb3be16d64 Final changes to XML parser trace logging. This is extremely inefficient code, but it will be ifdef'ed out during normal use. Like the rest of the protocol trace options, they are only getting ifdef'ed into use while I am developing. --- diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index 15a05dccf..5883c7347 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -37,6 +37,11 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { strcat(indent, "··"); } syslog(LOG_DEBUG, "%s<%s>", indent, el); + ++crp->tag_nesting_level; + indent[0] = 0; + for (i=0; itag_nesting_level; ++i) { + strcat(indent, "··"); + } for (i = 0; attr[i] != NULL; i += 2) { syslog(LOG_DEBUG, "%sAttribute '%s' = '%s'", indent, attr[i], attr[i + 1]); } @@ -58,7 +63,6 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { crp->report_type = cr_freebusy_query; } - ++crp->tag_nesting_level; } @@ -108,25 +112,28 @@ void caldav_xml_chardata(void *data, const XML_Char *s, int len) { memcpy(app, s, len); app[len] = 0; + if (crp->Chardata == NULL) { + crp->Chardata = NewStrBuf(); + } + + StrBufAppendBufPlain(crp->Chardata, app, len, 0); + #ifdef DEBUG_XML_PARSE // logging - int i; - char indent[256]; - indent[0] = 0; - for (i=0; itag_nesting_level; ++i) { - strcat(indent, "··"); + string_trim(app); // remove leading/trailing whitespace. ok to mangle it because we've already appended. + if (!IsEmptyStr(app)) { + int i; + char indent[256]; + indent[0] = 0; + for (i=0; itag_nesting_level; ++i) { + strcat(indent, "··"); + } + syslog(LOG_DEBUG, "%s%s", indent, app, len); } - syslog(LOG_DEBUG, "%s%s", indent, app, len); // end logging #endif - if (crp->Chardata == NULL) { - crp->Chardata = NewStrBuf(); - } - - StrBufAppendBufPlain(crp->Chardata, app, len, 0); free(app); - return; }