From: Art Cancro Date: Fri, 9 Feb 2024 21:52:29 +0000 (-0500) Subject: Solved P=NP X-Git-Tag: v999~51 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=eab56df5d120be5d474378f8536837d0abd43214 Solved P=NP --- diff --git a/citadel/server/msgbase.c b/citadel/server/msgbase.c index 199a5efa3..f3188bcbd 100644 --- a/citadel/server/msgbase.c +++ b/citadel/server/msgbase.c @@ -1416,14 +1416,14 @@ int check_cached_msglist(long msgnum) { // Get a message off disk. (returns om_* values found in msgbase.h) int CtdlOutputMsg(long msg_num, // message number (local) to fetch int mode, // how would you like that message? - int headers_only, // eschew the message body? + int headers_only, // If nonzero, skip the message body. Also avoids loading it, if it's stored separately. int do_proto, // do Citadel protocol responses? - int crlf, // Use CRLF newlines instead of LF? + int crlf, // If nonzero, terminate lines with CRLF instead of just LF char *section, // NULL or a message/rfc822 section int flags, // various flags; see msgbase.h - char **Author, - char **Address, - char **MessageID + char **Author, // If non-NULL, allocate a string buffer and populate the display name (caller must free) + char **Address, // If non-NULL, allocate a string buffer and populate the email address (caller must free) + char **MessageID // If non-NULL, allocate a string buffer and populate the message ID (caller must free) ) { struct CtdlMessage *TheMessage = NULL; int retcode = CIT_OK; @@ -1456,15 +1456,10 @@ int CtdlOutputMsg(long msg_num, // message number (local) to fetch r = check_cached_msglist(msg_num); } if (r != om_ok) { - syslog(LOG_DEBUG, "msgbase: security check fail; message %ld is not in %s", - msg_num, CC->room.QRname - ); + syslog(LOG_DEBUG, "msgbase: security check fail; message %ld is not in %s", msg_num, CC->room.QRname); if (do_proto) { if (r == om_access_denied) { - cprintf("%d message %ld was not found in this room\n", - ERROR + HIGHER_ACCESS_REQUIRED, - msg_num - ); + cprintf("%d message %ld was not found in this room\n", ERROR + HIGHER_ACCESS_REQUIRED, msg_num); } } return(r); @@ -1479,8 +1474,7 @@ int CtdlOutputMsg(long msg_num, // message number (local) to fetch } if (TheMessage == NULL) { - if (do_proto) cprintf("%d Can't locate msg %ld on disk\n", - ERROR + MESSAGE_NOT_FOUND, msg_num); + if (do_proto) cprintf("%d Can't locate msg %ld on disk\n", ERROR + MESSAGE_NOT_FOUND, msg_num); return(om_no_such_msg); } @@ -1566,13 +1560,13 @@ void OutputCtdlMsgHeaders(struct CtdlMessage *TheMessage, int do_proto) { else { safestrncpy(display_name, buf, sizeof display_name); } - if ((is_room_aide()) - && ((TheMessage->cm_anon_type == MES_ANONONLY) - || (TheMessage->cm_anon_type == MES_ANONOPT))) { + if ( (is_room_aide()) + && ( (TheMessage->cm_anon_type == MES_ANONONLY) + || (TheMessage->cm_anon_type == MES_ANONOPT) + ) + ) { size_t tmp = strlen(display_name); - snprintf(&display_name[tmp], - sizeof display_name - tmp, - " [%s]", buf); + snprintf(&display_name[tmp], sizeof display_name - tmp, " [%s]", buf); } } @@ -1756,14 +1750,12 @@ void Dump_RFC822HeadersBody( // do nothing } else { - if ((!eoh) && - (*mptr == '\n')) - { + if ((!eoh) && (*mptr == '\n')) { eoh = (*(mptr+1) == '\r') && (*(mptr+2) == '\n'); - if (!eoh) + if (!eoh) { eoh = *(mptr+1) == '\n'; - if (eoh) - { + } + if (eoh) { StartOfText = mptr; StartOfText = strchr(StartOfText, '\n'); StartOfText = strchr(StartOfText, '\n'); @@ -1984,10 +1976,10 @@ int CtdlOutputPreLoadedMsg( } // nhdr=yes means that we're only displaying headers, no body - if ( (TheMessage->cm_anon_type == MES_ANONONLY) - && ((mode == MT_CITADEL) || (mode == MT_MIME)) - && (do_proto) - ) { + if ( (TheMessage->cm_anon_type == MES_ANONONLY) + && ((mode == MT_CITADEL) || (mode == MT_MIME)) + && (do_proto) + ) { cprintf("nhdr=yes\n"); } @@ -2060,11 +2052,7 @@ START_TEXT: (void *)&ma, 1); } else if (mode == MT_RFC822) { // unparsed RFC822 dump - Dump_RFC822HeadersBody( - TheMessage, - headers_only, - flags, - nl, nlen); + Dump_RFC822HeadersBody(TheMessage, headers_only, flags, nl, nlen); goto DONE; } } @@ -2078,11 +2066,9 @@ START_TEXT: if (do_proto) cprintf("text\n"); } - if (TheMessage->cm_format_type == FMT_FIXED) - DumpFormatFixed( - TheMessage, - mode, // how would you like that message? - nl, nlen); + if (TheMessage->cm_format_type == FMT_FIXED) { + DumpFormatFixed( TheMessage, mode, nl, nlen); + } // If the message on disk is format 0 (Citadel vari-format), we // output using the formatter at 80 columns. This is the final output @@ -2131,6 +2117,7 @@ DONE: // now we're done return(om_ok); } + // Save one or more message pointers into a specified room // (Returns 0 for success, nonzero for failure) // roomname may be NULL to use the current room @@ -2353,7 +2340,7 @@ long send_message(struct CtdlMessage *msg) { // Generate an ID if we don't have one already if (CM_IsEmpty(msg, emessageId)) { - msgidbuflen = snprintf(msgidbuf, sizeof msgidbuf, "%08lX-%08lX@%s", + msgidbuflen = snprintf(msgidbuf, sizeof msgidbuf, "%lX-%lX@%s", (long unsigned int) time(NULL), (long unsigned int) newmsgid, CtdlGetConfigStr("c_fqdn") diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index f042c7031..1c95c3806 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -224,7 +224,7 @@ void caldav_report(struct http_transaction *h, struct ctdlsession *c) { XML_Parse(xp, h->request_body, h->request_body_length, 1); XML_ParserFree(xp); - if (crp.Chardata != NULL) { // Discard any trailing chardata ... normally nothing here + if (crp.Chardata != NULL) { // Discard any trailing chardata ... normally nothing here FreeStrBuf(&crp.Chardata); crp.Chardata = NULL; } @@ -258,10 +258,15 @@ void caldav_report(struct http_transaction *h, struct ctdlsession *c) { StrBuf *one_item = fetch_ical(c, m); icalcomponent *cal = icalcomponent_new_from_string(ChrPtr(one_item)); - // this is a horrible temporary hack to output every item - int qualify = 1; + // qualify will be set to nonzero if this calendar item is a match for the QUERY. + int qualify = 0; + // this is a horrible temporary hack to output every item (for now) + qualify = 1; + + // Did this calendar item match the query? If so, output it. if (qualify) { + // FIXME need to populate the Href instead of NULL cal_multiget_out(m, NULL, one_item, ReportOut); }