static int moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, int *pdiscard) { int rc; mu_sieve_machine_t newmach; mu_attribute_t attr; mu_sieve_value_t *arg; if (mu_sieve_tag_lookup (tags, "source", &arg)) { rc = mu_sieve_machine_inherit (mach, &newmach); if (rc) { mu_sieve_error (mach, _("cannot initialize sieve machine: %s"), mu_strerror (rc)); return 1; } /* FIXME: This should be configurable: moderator :inherit moderator :debug 2 ... */ rc = mu_sieve_compile (newmach, arg->v.string); if (rc) mu_sieve_error (mach, _("cannot compile source `%s'"), arg->v.string); } else rc = mu_sieve_machine_dup (mach, &newmach); if (rc) return rc; mu_message_get_attribute (msg, &attr); mu_attribute_unset_deleted (attr); rc = mu_sieve_message (newmach, msg); if (rc) mu_sieve_error (newmach, _("failed to run inferior sieve machine")); else *pdiscard = mu_attribute_is_deleted (attr); mu_sieve_machine_destroy (&newmach); return rc; }
static PyObject * api_sieve_machine_destroy (PyObject *self, PyObject *args) { PySieveMachine *py_mach; if (!PyArg_ParseTuple (args, "O!", &PySieveMachineType, &py_mach)) return NULL; if (py_mach->mach) { struct _mu_py_sieve_logger *s = mu_sieve_get_data (py_mach->mach); if (s) free (s); mu_sieve_machine_destroy (&py_mach->mach); } return _ro (Py_None); }