Back to index

citadel  8.12
Classes | Defines | Functions | Variables
serv_sieve.h File Reference
#include <sieve2.h>
#include <sieve2_error.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sdm_script
struct  sdm_vacation
struct  sdm_userdata
struct  ctdl_sieve

Defines

#define CTDLSIEVECONFIGSEPARATOR   "\n-=<CtdlSieveConfigSeparator>=-\n"
#define MAX_VACATION   30

Functions

void sieve_queue_room (struct ctdlroom *)
void perform_sieve_processing (void)
void msiv_load (struct sdm_userdata *u)
void msiv_store (struct sdm_userdata *u, int changes_made)
int msiv_setactive (struct sdm_userdata *u, char *script_name)
char * msiv_getscript (struct sdm_userdata *u, char *script_name)
int msiv_deletescript (struct sdm_userdata *u, char *script_name)
void msiv_putscript (struct sdm_userdata *u, char *script_name, char *script_content)

Variables

struct RoomProcListsieve_list
char * msiv_extensions

Class Documentation

struct sdm_script

Definition at line 6 of file serv_sieve.h.

Collaboration diagram for sdm_script:
Class Members
struct sdm_script * next
int script_active
char * script_content
char script_name
struct sdm_vacation

Definition at line 13 of file serv_sieve.h.

Collaboration diagram for sdm_vacation:
Class Members
char fromaddr
struct sdm_vacation * next
time_t timestamp
struct sdm_userdata

Definition at line 19 of file serv_sieve.h.

Collaboration diagram for sdm_userdata:
Class Members
long config_msgnum confirms that a sieve config was located
char config_roomname
struct sdm_script * first_script
struct sdm_vacation * first_vacation
long lastproc last message processed
sieve2_context_t * sieve2_context for libsieve's use
struct ctdl_sieve

Definition at line 28 of file serv_sieve.h.

Collaboration diagram for ctdl_sieve:
Class Members
int cancel_implicit_keep
char envelope_from
char envelope_to
int keep
long msgnum
char recp_name
char recp_node
char recp_user
char * rfc822headers
char sender
char subject
struct sdm_userdata * u
long usernum

Define Documentation

#define CTDLSIEVECONFIGSEPARATOR   "\n-=<CtdlSieveConfigSeparator>=-\n"

Definition at line 46 of file serv_sieve.h.

#define MAX_VACATION   30

Definition at line 52 of file serv_sieve.h.


Function Documentation

int msiv_deletescript ( struct sdm_userdata u,
char *  script_name 
)

Definition at line 1102 of file serv_sieve.c.

                                                                 {
       struct sdm_script *s = NULL;
       struct sdm_script *script_to_delete = NULL;

       for (s=u->first_script; s!=NULL; s=s->next) {
              if (!strcasecmp(s->script_name, script_name)) {
                     script_to_delete = s;
                     if (s->script_active) {
                            return(2);
                     }
              }
       }

       if (script_to_delete == NULL) return(1);

       if (u->first_script == script_to_delete) {
              u->first_script = u->first_script->next;
       }
       else for (s=u->first_script; s!=NULL; s=s->next) {
              if (s->next == script_to_delete) {
                     s->next = s->next->next;
              }
       }

       free(script_to_delete->script_content);
       free(script_to_delete);
       return(0);
}

Here is the caller graph for this function:

char* msiv_getscript ( struct sdm_userdata u,
char *  script_name 
)

Definition at line 1080 of file serv_sieve.c.

                                                                {
       struct sdm_script *s;

       for (s=u->first_script; s!=NULL; s=s->next) {
              if (!strcasecmp(s->script_name, script_name)) {
                     if (s->script_content != NULL) {
                            return (s->script_content);
                     }
              }
       }

       return(NULL);
}

Here is the caller graph for this function:

void msiv_load ( struct sdm_userdata u)

Definition at line 1000 of file serv_sieve.c.

                                       {
       char hold_rm[ROOMNAMELEN];

       strcpy(hold_rm, CC->room.QRname);       /* save current room */

       /* Take a spin through the user's personal address book */
       if (CtdlGetRoom(&CC->room, USERCONFIGROOM) == 0) {
       
              u->config_msgnum = (-1);
              strcpy(u->config_roomname, CC->room.QRname);
              CtdlForEachMessage(MSGS_LAST, 1, NULL, SIEVECONFIG, NULL,
                     get_sieve_config_backend, (void *)u );

       }

       if (strcmp(CC->room.QRname, hold_rm)) {
              CtdlGetRoom(&CC->room, hold_rm);    /* return to saved room */
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void msiv_putscript ( struct sdm_userdata u,
char *  script_name,
char *  script_content 
)

Definition at line 1137 of file serv_sieve.c.

                                                                                     {
       int replaced = 0;
       struct sdm_script *s, *sptr;

       for (s=u->first_script; s!=NULL; s=s->next) {
              if (!strcasecmp(s->script_name, script_name)) {
                     if (s->script_content != NULL) {
                            free(s->script_content);
                     }
                     s->script_content = script_content;
                     replaced = 1;
              }
       }

       if (replaced == 0) {
              sptr = malloc(sizeof(struct sdm_script));
              safestrncpy(sptr->script_name, script_name, sizeof sptr->script_name);
              sptr->script_content = script_content;
              sptr->script_active = 0;
              sptr->next = u->first_script;
              u->first_script = sptr;
       }
}

Here is the caller graph for this function:

int msiv_setactive ( struct sdm_userdata u,
char *  script_name 
)

Definition at line 1040 of file serv_sieve.c.

                                                              {
       int ok = 0;
       struct sdm_script *s;

       /* First see if the supplied value is ok */

       if (IsEmptyStr(script_name)) {
              ok = 1;
       }
       else {
              for (s=u->first_script; s!=NULL; s=s->next) {
                     if (!strcasecmp(s->script_name, script_name)) {
                            ok = 1;
                     }
              }
       }

       if (!ok) return(-1);

       /* Now set the active script */
       for (s=u->first_script; s!=NULL; s=s->next) {
              if (!strcasecmp(s->script_name, script_name)) {
                     s->script_active = 1;
              }
              else {
                     s->script_active = 0;
              }
       }
       
       return(0);
}

Here is the caller graph for this function:

void msiv_store ( struct sdm_userdata u,
int  changes_made 
)

Definition at line 1020 of file serv_sieve.c.

                                                               {
/*
 * Initialise the sieve configs last processed message number.
 * We don't need to get the highest message number for the users inbox since the systems
 * highest message number will be higher than that and loer than this scripts message number
 * This prevents this new script from processing any old messages in the inbox.
 * Most importantly it will prevent vacation messages being sent to lots of old messages
 * in the inbox.
 */
       u->lastproc = CtdlGetCurrentMessageNumber();
       rewrite_ctdl_sieve_config(u, yes_write_to_disk);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void perform_sieve_processing ( void  )

Definition at line 969 of file serv_sieve.c.

                                    {
       struct RoomProcList *ptr = NULL;

       if (sieve_list != NULL) {
              SVM_syslog(LOG_DEBUG, "Begin Sieve processing");
              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);
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sieve_queue_room ( struct ctdlroom )

Definition at line 514 of file serv_sieve.c.

                                                   {
       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);
       SV_syslog(LOG_DEBUG, "<%s> queued for Sieve processing", which_room->QRname);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 53 of file serv_sieve.c.

Definition at line 52 of file serv_sieve.c.