X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fserv_sieve.c;h=604a9f8916fa7478ce40b064348e437e4f1edfac;hb=5864d4453d4533cb1988d80ea4e5fa59171e7076;hp=e9fca4f50be01397f3f2a68a9c4e00d56b8eb245;hpb=ba0ac79036289d7c0ba57386ffef91fadea58ae4;p=citadel.git diff --git a/citadel/serv_sieve.c b/citadel/serv_sieve.c index e9fca4f50..604a9f891 100644 --- a/citadel/serv_sieve.c +++ b/citadel/serv_sieve.c @@ -39,11 +39,76 @@ #include "policy.h" #include "database.h" #include "msgbase.h" +#include "tools.h" #ifdef HAVE_LIBSIEVE -#include "sieve2.h" -#include "sieve2_error.h" +#include +#include +#include "serv_sieve.h" + +struct RoomProcList *sieve_list = NULL; + +/* + * Add a room to the list of those rooms which potentially require sieve processing + */ +void sieve_queue_room(struct ctdlroom *which_room) { + struct RoomProcList *ptr; + + ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList)); + if (ptr == NULL) return; + + safestrncpy(ptr->name, which_room->QRname, sizeof ptr->name); + begin_critical_section(S_SIEVELIST); + ptr->next = sieve_list; + sieve_list = ptr; + end_critical_section(S_SIEVELIST); +} + + +/* + * Perform sieve processing for a single room + */ +void sieve_do_room(char *roomname) { + lprintf(CTDL_DEBUG, "Performing Sieve processing for <%s>\n", roomname); + /* FIXME ... actually do this instead of just talking about it */ +} + + +/* + * Perform sieve processing for all rooms which require it + */ +void perform_sieve_processing(void) { + struct RoomProcList *ptr = NULL; + + if (sieve_list != NULL) { + lprintf(CTDL_DEBUG, "Begin Sieve processing\n"); + while (sieve_list != NULL) { + char spoolroomname[ROOMNAMELEN]; + safestrncpy(spoolroomname, sieve_list->name, sizeof spoolroomname); + begin_critical_section(S_SIEVELIST); + + /* pop this record off the list */ + ptr = sieve_list; + sieve_list = sieve_list->next; + free(ptr); + + /* invalidate any duplicate entries to prevent double processing */ + for (ptr=sieve_list; ptr!=NULL; ptr=ptr->next) { + if (!strcasecmp(ptr->name, spoolroomname)) { + ptr->name[0] = 0; + } + } + + end_critical_section(S_SIEVELIST); + if (spoolroomname[0] != 0) { + sieve_do_room(spoolroomname); + } + } + } +} + + /** * We don't really care about dumping the entire credits to the log