+
+ /*
+ * Process client-side list participations for this room
+ */
+ instr_len = SIZ;
+ if (sc->participates != NULL) {
+ msg = CtdlFetchMessage(msgnum, 1);
+ if (msg != NULL) {
+
+ /* Only send messages which originated on our own Citadel
+ * network, otherwise we'll end up sending the remote
+ * mailing list's messages back to it, which is rude...
+ */
+ ok_to_participate = 0;
+ if (msg->cm_fields['N'] != NULL) {
+ if (!strcasecmp(msg->cm_fields['N'], config.c_nodename)) {
+ ok_to_participate = 1;
+ }
+ if (is_valid_node(NULL, NULL, msg->cm_fields['N']) == 0) {
+ ok_to_participate = 1;
+ }
+ }
+ if (ok_to_participate) {
+ if (msg->cm_fields['F'] != NULL) {
+ free(msg->cm_fields['F']);
+ }
+ msg->cm_fields['F'] = malloc(SIZ);
+ /* Replace the Internet email address of the actual
+ * author with the email address of the room itself,
+ * so the remote listserv doesn't reject us.
+ * FIXME ... I want to be able to pick any address
+ */
+ snprintf(msg->cm_fields['F'], SIZ,
+ "room_%s@%s", CC->room.QRname,
+ config.c_fqdn);
+ for (i=0; i<strlen(msg->cm_fields['F']); ++i) {
+ if (isspace(msg->cm_fields['F'][i])) {
+ msg->cm_fields['F'][i] = '_';
+ }
+ }
+
+ /* Now save it and generate delivery instructions */
+ list_msgnum = CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM);
+
+ /*
+ * Figure out how big a buffer we need to allocate
+ */
+ for (nptr = sc->participates; nptr != NULL; nptr = nptr->next) {
+ instr_len = instr_len + strlen(nptr->name);
+ }
+
+ /*
+ * allocate...
+ */
+ instr = malloc(instr_len);
+ if (instr == NULL) {
+ lprintf(CTDL_EMERG,
+ "Cannot allocate %ld bytes for instr...\n",
+ (long)instr_len);
+ abort();
+ }
+ snprintf(instr, instr_len,
+ "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
+ "bounceto|postmaster@%s\n" ,
+ SPOOLMIME, list_msgnum, (long)time(NULL), config.c_fqdn );
+
+ /* Generate delivery instructions for each recipient */
+ for (nptr = sc->participates; nptr != NULL; nptr = nptr->next) {
+ size_t tmp = strlen(instr);
+ snprintf(&instr[tmp], instr_len - tmp,
+ "remote|%s|0||\n", nptr->name);
+ }
+
+ /*
+ * Generate a message from the instructions
+ */
+ imsg = malloc(sizeof(struct CtdlMessage));
+ memset(imsg, 0, sizeof(struct CtdlMessage));
+ imsg->cm_magic = CTDLMESSAGE_MAGIC;
+ imsg->cm_anon_type = MES_NORMAL;
+ imsg->cm_format_type = FMT_RFC822;
+ imsg->cm_fields['A'] = strdup("Citadel");
+ imsg->cm_fields['M'] = instr;
+
+ /* Save delivery instructions in spoolout room */
+ CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM);
+ CtdlFreeMessage(imsg);
+ }
+ CtdlFreeMessage(msg);
+ }
+ }