Previous: Sieve Scripts, Up: Tutorial


7.7 Parsing CONTENT_FILTER

To scan the actions in the list's CONTENT_FILTER template you don't need to call listserv_getmail_template and parse the results. You can just rely on listserv_getcontent_filter . Let's check the first action, stored in the CONTENT_FILTER of the list ABC-L:

     struct listserv_content_filter** content_filter =
         listserv_getcontent_filter (l, "ABC-L");
     if (content_filter[0] == NULL)
         printf ("No actions in CONTENT_FILTER for ABC-L.\n");
     else {
         printf ("Scan in 'Text', 'Header' or specific header: %s\n",
                 content_filter[0]->header);
         printf ("Scan for: \"%s\".\n", content_filter[0]->value);
         switch (content_filter[0]->action) {
           case 'A': printf ("The action is ACCEPT.\n"); break;
           case 'R': printf ("The action is REJECT.\n"); break;
           case 'M': printf ("The action is MODERATE.\n"); break;
           case 'D': printf ("The action is DISCARD.\n");
         }
         if (content_filter[0]->text)
             printf ("The provided action parameter is \"%s\".\n",
                     content_filter[0]->text);
         if (content_filter[1])
             printf ("There is a second action in CONTENT_FILTER for ABC-L.\n");
     }