cd5f6a1c7198022e33e67a9ff59cb25e357bc252
[citadel.git] / citadel / modules / network / netspool.h
1 /*
2  * This module handles shared rooms, inter-Citadel mail, and outbound
3  * mailing list processing.
4  *
5  * Copyright (c) 2000-2012 by the citadel.org team
6  *
7  *  This program is open source software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  * ** NOTE **   A word on the S_NETCONFIGS semaphore:
22  * This is a fairly high-level type of critical section.  It ensures that no
23  * two threads work on the netconfigs files at the same time.  Since we do
24  * so many things inside these, here are the rules:
25  *  1. begin_critical_section(S_NETCONFIGS) *before* begin_ any others.
26  *  2. Do *not* perform any I/O with the client during these sections.
27  *
28  */
29
30 typedef struct SpoolControl SpoolControl;
31
32 struct SpoolControl {
33         OneRoomNetCfg *RNCfg;
34         struct ctdlroom room;
35         StrBuf *Users[maxRoomNetCfg];
36         StrBuf *RoomInfo;
37         StrBuf *ListID;
38         FILE *digestfp;
39         int haveDigest;
40         int num_msgs_spooled;
41         long lastsent;
42
43         HashList *working_ignetcfg;
44         HashList *the_netmap;
45
46         SpoolControl *next;
47 };
48
49
50 void network_spoolout_room(SpoolControl *sc);
51
52 void InspectQueuedRoom(SpoolControl **pSC,
53                        RoomProcList *room_to_spool,     
54                        HashList *working_ignetcfg,
55                        HashList *the_netmap);
56
57 int HaveSpoolConfig(OneRoomNetCfg* RNCfg);
58
59 void Netmap_AddMe(struct CtdlMessage *msg, const char *defl, long defllen);
60 void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed);
61 void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netmap);
62 void free_spoolcontrol_struct(SpoolControl **scc);
63 void free_spoolcontrol_struct_members(SpoolControl *scc);
64 int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename);
65 int read_spoolcontrol_file(SpoolControl **scc, char *filename);
66
67 void aggregate_recipients(StrBuf **recps, RoomNetCfg Which, OneRoomNetCfg *OneRNCfg, long nSegments);
68
69 void CalcListID(SpoolControl *sc);