#include <limits.h>
#include "citadel.h"
#include "server.h"
-#include "sysdep_decls.h"
#include "citserver.h"
#include "support.h"
#include "config.h"
-#include "serv_extensions.h"
#include "room_ops.h"
#include "policy.h"
#include "database.h"
#include "internet_addressing.h"
#include "tools.h"
+
+#include "ctdl_module.h"
+
+
#ifdef HAVE_LIBSIEVE
#include "serv_sieve.h"
/*
* Callback function to send libSieve trace messages to Citadel log facility
- * Set ctdl_libsieve_debug=1 to see extremely verbose libSieve trace
*/
int ctdl_debug(sieve2_context_t *s, void *my)
{
- static int ctdl_libsieve_debug = 1;
-
- if (ctdl_libsieve_debug) {
-/*
- lprintf(CTDL_DEBUG, "Sieve: level [%d] module [%s] file [%s] function [%s]\n",
- sieve2_getvalue_int(s, "level"),
- sieve2_getvalue_string(s, "module"),
- sieve2_getvalue_string(s, "file"),
- sieve2_getvalue_string(s, "function"));
- */
- lprintf(CTDL_DEBUG, "Sieve: %s\n",
- sieve2_getvalue_string(s, "message"));
- }
+ lprintf(CTDL_DEBUG, "Sieve: %s\n", sieve2_getvalue_string(s, "message"));
return SIEVE2_OK;
}
struct CtdlMessage *msg;
int i;
size_t headers_len = 0;
+ int len = 0;
lprintf(CTDL_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum);
strcpy(my.envelope_from, "");
}
+ len = strlen(my.envelope_from);
+ for (i=0; i<len; ++i) {
+ if (isspace(my.envelope_from[i])) my.envelope_from[i] = '_';
+ }
+ if (haschar(my.envelope_from, '@') == 0) {
+ strcat(my.envelope_from, "@");
+ strcat(my.envelope_from, config.c_fqdn);
+ }
+
/* Keep track of the envelope-to address (use body-to if not found) */
if (msg->cm_fields['V'] != NULL) {
safestrncpy(my.envelope_to, msg->cm_fields['V'], sizeof my.envelope_to);
strcpy(my.envelope_to, "");
}
+ len = strlen(my.envelope_to);
+ for (i=0; i<len; ++i) {
+ if (isspace(my.envelope_to[i])) my.envelope_to[i] = '_';
+ }
+ if (haschar(my.envelope_to, '@') == 0) {
+ strcat(my.envelope_to, "@");
+ strcat(my.envelope_to, config.c_fqdn);
+ }
+
CtdlFreeMessage(msg);
sieve2_setvalue_string(sieve2_context, "allheaders", my.rfc822headers);
return 0;
}
+#endif /* HAVE_LIBSIEVE */
-char *serv_sieve_init(void)
+CTDL_MODULE_INIT(sieve)
{
+
+#ifdef HAVE_LIBSIEVE
+
ctdl_sieve_init();
CtdlRegisterProtoHook(cmd_msiv, "MSIV", "Manage Sieve scripts");
+
CtdlRegisterRoomHook(serv_sieve_room);
- return "$Id$";
-}
+
+ CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE);
#else /* HAVE_LIBSIEVE */
-char *serv_sieve_init(void)
-{
lprintf(CTDL_INFO, "This server is missing libsieve. Mailbox filtering will be disabled.\n");
- /* return our Subversion id for the Log */
+#endif /* HAVE_LIBSIEVE */
+
+ /* return our Subversion id for the Log */
return "$Id$";
}
-#endif /* HAVE_LIBSIEVE */