+ free(sc);
+ *scc=NULL;
+ }
+ return 1;
+}
+int is_recipient(SpoolControl *sc, const char *Name)
+{
+ namelist *nptr;
+ size_t len;
+
+ len = strlen(Name);
+ nptr = sc->listrecps;
+ while (nptr != NULL) {
+ if (strncmp(Name, nptr->name, len)==0)
+ return 1;
+ nptr = nptr->next;
+ }
+ /* Do the same for digestrecps */
+ nptr = sc->digestrecps;
+ while (nptr != NULL) {
+ if (strncmp(Name, nptr->name, len)==0)
+ return 1;
+ nptr = nptr->next;
+ }
+ /* Do the same for participates */
+ nptr = sc->participates;
+ while (nptr != NULL) {
+ if (strncmp(Name, nptr->name, len)==0)
+ return 1;
+ nptr = nptr->next;
+ }
+ return 0;
+}
+
+
+/*
+ * Batch up and send all outbound traffic from the current room
+ */
+void network_spoolout_room(char *room_to_spool) {
+ char buf[SIZ];
+ char filename[PATH_MAX];
+ SpoolControl *sc;
+ int i;
+
+ /*
+ * If the room doesn't exist, don't try to perform its networking tasks.
+ * Normally this should never happen, but once in a while maybe a room gets
+ * queued for networking and then deleted before it can happen.
+ */
+ if (getroom(&CC->room, room_to_spool) != 0) {
+ CtdlLogPrintf(CTDL_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
+ return;
+ }
+
+ assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
+ begin_critical_section(S_NETCONFIGS);
+
+ /* Only do net processing for rooms that have netconfigs */
+ if (!read_spoolcontrol_file(&sc, filename))
+ {
+ end_critical_section(S_NETCONFIGS);
+ return;
+ }
+ CtdlLogPrintf(CTDL_INFO, "Networking started for <%s>\n", CC->room.QRname);
+
+ /* If there are digest recipients, we have to build a digest */
+ if (sc->digestrecps != NULL) {
+ sc->digestfp = tmpfile();
+ fprintf(sc->digestfp, "Content-type: text/plain\n\n");
+ }
+
+ /* Do something useful */
+ CtdlForEachMessage(MSGS_GT, sc->lastsent, NULL, NULL, NULL,
+ network_spool_msg, sc);
+
+ /* If we wrote a digest, deliver it and then close it */
+ snprintf(buf, sizeof buf, "room_%s@%s",
+ CC->room.QRname, config.c_fqdn);
+ for (i=0; buf[i]; ++i) {
+ buf[i] = tolower(buf[i]);
+ if (isspace(buf[i])) buf[i] = '_';
+ }
+ if (sc->digestfp != NULL) {
+ fprintf(sc->digestfp, " -----------------------------------"
+ "------------------------------------"
+ "-------\n"
+ "You are subscribed to the '%s' "
+ "list.\n"
+ "To post to the list: %s\n",
+ CC->room.QRname, buf
+ );
+ network_deliver_digest(sc); /* deliver and close */