2 * $Id: serv_test.c 3850 2005-09-13 14:00:24Z ajc $
15 #include <sys/types.h>
17 #if TIME_WITH_SYS_TIME
18 # include <sys/time.h>
22 # include <sys/time.h>
33 #include "sysdep_decls.h"
34 #include "citserver.h"
37 #include "serv_extensions.h"
47 #include <sieve2_error.h>
48 #include "serv_sieve.h"
50 struct RoomProcList *sieve_list = NULL;
53 * Add a room to the list of those rooms which potentially require sieve processing
55 void sieve_queue_room(struct ctdlroom *which_room) {
56 struct RoomProcList *ptr;
58 ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList));
59 if (ptr == NULL) return;
61 safestrncpy(ptr->name, which_room->QRname, sizeof ptr->name);
62 begin_critical_section(S_SIEVELIST);
63 ptr->next = sieve_list;
65 end_critical_section(S_SIEVELIST);
70 * Perform sieve processing for a single room
72 void sieve_do_room(char *roomname) {
73 lprintf(CTDL_DEBUG, "Performing Sieve processing for <%s>\n", roomname);
74 /* FIXME ... actually do this instead of just talking about it */
79 * Perform sieve processing for all rooms which require it
81 void perform_sieve_processing(void) {
82 struct RoomProcList *ptr = NULL;
84 if (sieve_list != NULL) {
85 lprintf(CTDL_DEBUG, "Begin Sieve processing\n");
86 while (sieve_list != NULL) {
87 char spoolroomname[ROOMNAMELEN];
88 safestrncpy(spoolroomname, sieve_list->name, sizeof spoolroomname);
89 begin_critical_section(S_SIEVELIST);
91 /* pop this record off the list */
93 sieve_list = sieve_list->next;
96 /* invalidate any duplicate entries to prevent double processing */
97 for (ptr=sieve_list; ptr!=NULL; ptr=ptr->next) {
98 if (!strcasecmp(ptr->name, spoolroomname)) {
103 end_critical_section(S_SIEVELIST);
104 if (spoolroomname[0] != 0) {
105 sieve_do_room(spoolroomname);
114 * We don't really care about dumping the entire credits to the log
115 * every time the server is initialized. The documentation will suffice
116 * for that purpose. We are making a call to sieve2_credits() in order
117 * to demonstrate that we have successfully linked in to libsieve.
119 void log_the_sieve2_credits(void) {
122 cred = strdup(sieve2_credits());
123 if (cred == NULL) return;
125 if (strlen(cred) > 60) {
126 strcpy(&cred[55], "...");
129 lprintf(CTDL_INFO, "%s\n",cred);
134 char *serv_sieve_init(void)
136 log_the_sieve2_credits();
137 return "$Id: serv_sieve.c 3850 2005-09-13 14:00:24Z ajc $";
140 #else /* HAVE_LIBSIEVE */
142 char *serv_sieve_init(void)
144 lprintf(CTDL_INFO, "This server is missing libsieve. Mailbox filtering will be disabled.\n");
145 return "$Id: serv_sieve.c 3850 2005-09-13 14:00:24Z ajc $";
148 #endif /* HAVE_LIBSIEVE */