+void network_process_digest(SpoolControl *sc, struct CtdlMessage *omsg, long *delete_after_send)
+{
+
+ struct CtdlMessage *msg = NULL;
+
+ /*
+ * Process digest recipients
+ */
+ if ((sc->RNCfg->NetConfigs[digestrecp] == NULL) ||
+ (sc->digestfp == NULL))
+ return;
+
+ msg = CtdlDuplicateMessage(omsg);
+ if (msg != NULL) {
+ fprintf(sc->digestfp,
+ " -----------------------------------"
+ "------------------------------------"
+ "-------\n");
+ fprintf(sc->digestfp, "From: ");
+ if (msg->cm_fields['A'] != NULL) {
+ fprintf(sc->digestfp,
+ "%s ",
+ msg->cm_fields['A']);
+ }
+ if (msg->cm_fields['F'] != NULL) {
+ fprintf(sc->digestfp,
+ "<%s> ",
+ msg->cm_fields['F']);
+ }
+ else if (msg->cm_fields['N'] != NULL) {
+ fprintf(sc->digestfp,
+ "@%s ",
+ msg->cm_fields['N']);
+ }
+ fprintf(sc->digestfp, "\n");
+ if (msg->cm_fields['U'] != NULL) {
+ fprintf(sc->digestfp,
+ "Subject: %s\n",
+ msg->cm_fields['U']);
+ }
+
+ CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
+
+ safestrncpy(CC->preferred_formats,
+ "text/plain",
+ sizeof CC->preferred_formats);
+
+ CtdlOutputPreLoadedMsg(msg,
+ MT_CITADEL,
+ HEADERS_NONE,
+ 0, 0, 0);
+
+ StrBufTrim(CC->redirect_buffer);
+ fwrite(HKEY("\n"), 1, sc->digestfp);
+ fwrite(SKEY(CC->redirect_buffer), 1, sc->digestfp);
+ fwrite(HKEY("\n"), 1, sc->digestfp);
+
+ FreeStrBuf(&CC->redirect_buffer);
+
+ sc->num_msgs_spooled += 1;
+ CtdlFreeMessage(msg);
+ }
+}
+
+
+void network_process_list(SpoolControl *sc, struct CtdlMessage *omsg, long *delete_after_send)
+{
+ int rlen;
+ char *pCh;
+ StrBuf *Subject, *FlatSubject;
+ struct CtdlMessage *msg = NULL;
+ int i;
+
+ /*
+ * Process mailing list recipients
+ */
+ if (sc->RNCfg->NetConfigs[listrecp] == NULL)
+ return;
+
+ /* create our own copy of the message.
+ * We're going to need to modify it
+ * in order to insert the [list name] in it, etc.
+ */
+
+ msg = CtdlDuplicateMessage(omsg);
+
+ if (msg->cm_fields['K'] != NULL)
+ free(msg->cm_fields['K']);
+ if (msg->cm_fields['V'] == NULL){
+ /* local message, no enVelope */
+ StrBuf *Buf;
+ Buf = NewStrBuf();
+ StrBufAppendBufPlain(Buf,
+ msg->cm_fields['O']
+ , -1, 0);
+ StrBufAppendBufPlain(Buf, HKEY("@"), 0);
+ StrBufAppendBufPlain(Buf, config.c_fqdn, -1, 0);
+
+ msg->cm_fields['K'] = SmashStrBuf(&Buf);
+ }
+ else {
+ msg->cm_fields['K'] =
+ strdup (msg->cm_fields['V']);
+ }
+ /* Set the 'List-ID' header */
+ if (msg->cm_fields['L'] != NULL) {
+ free(msg->cm_fields['L']);
+ }
+ msg->cm_fields['L'] = malloc(1024);
+ snprintf(msg->cm_fields['L'], 1024,
+ "%s <%ld.list-id.%s>",
+ CC->room.QRname,
+ CC->room.QRnumber,
+ config.c_fqdn
+ );
+
+ /* Prepend "[List name]" to the subject */
+ if (msg->cm_fields['U'] == NULL) {
+ Subject = NewStrBufPlain(HKEY("(no subject)"));
+ }
+ else {
+ Subject = NewStrBufPlain(
+ msg->cm_fields['U'], -1);
+ }
+ FlatSubject = NewStrBufPlain(NULL, StrLength(Subject));
+ StrBuf_RFC822_to_Utf8(FlatSubject, Subject, NULL, NULL);
+
+ rlen = strlen(CC->room.QRname);
+ pCh = strstr(ChrPtr(FlatSubject), CC->room.QRname);
+ if ((pCh == NULL) ||
+ (*(pCh + rlen) != ']') ||
+ (pCh == ChrPtr(FlatSubject)) ||
+ (*(pCh - 1) != '[')
+ )
+ {
+ StrBuf *tmp;
+ StrBufPlain(Subject, HKEY("["));
+ StrBufAppendBufPlain(Subject,
+ CC->room.QRname,
+ rlen, 0);
+ StrBufAppendBufPlain(Subject, HKEY("] "), 0);
+ StrBufAppendBuf(Subject, FlatSubject, 0);
+ /* so we can free the right one swap them */
+ tmp = Subject;
+ Subject = FlatSubject;
+ FlatSubject = tmp;
+ StrBufRFC2047encode(&Subject, FlatSubject);
+ }
+
+ if (msg->cm_fields['U'] != NULL)
+ free (msg->cm_fields['U']);
+ msg->cm_fields['U'] = SmashStrBuf(&Subject);
+
+ FreeStrBuf(&FlatSubject);
+
+ /* else we won't modify the buffer, since the
+ * roomname is already here.
+ */
+
+ /* if there is no other recipient, Set the recipient
+ * of the list message to the email address of the
+ * room itself.
+ */
+ if ((msg->cm_fields['R'] == NULL) ||
+ IsEmptyStr(msg->cm_fields['R']))
+ {
+ if (msg->cm_fields['R'] != NULL)
+ free(msg->cm_fields['R']);
+
+ msg->cm_fields['R'] = malloc(256);
+ snprintf(msg->cm_fields['R'], 256,
+ "room_%s@%s", CC->room.QRname,
+ config.c_fqdn);
+ for (i=0; msg->cm_fields['R'][i]; ++i) {
+ if (isspace(msg->cm_fields['R'][i])) {
+ msg->cm_fields['R'][i] = '_';
+ }
+ }
+ }
+
+ /* Handle delivery */
+// network_deliver_list(msg, sc, CC->room.QRname);
+ CtdlFreeMessage(msg);
+}
+