/* A sceleton notify action. This is to demonstrate the bug in the sieve engine's parsing. Author: Kostas Zorbadelos Last modification: 3/10/2006 Syntax: notify [:method ] */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include /* Produce diagnostic output. */ static int diag (mu_sieve_machine_t mach) { if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE) { mu_sieve_locus_t locus; mu_sieve_get_locus (mach, &locus); mu_sieve_debug (mach, "%s:%lu: NOTIFY\n", locus.source_file, (unsigned long) locus.source_line); } mu_sieve_log_action (mach, "NOTIFY", NULL); return mu_sieve_is_dry_run (mach); } /* ------------------------------------------------------------------------- */ /* The notify action function */ /* ------------------------------------------------------------------------- */ int sieve_action_notify (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) { mu_sieve_value_t *val; int status; mu_sieve_locus_t locus; char *url; if (diag (mach)) return 0; status = mu_sieve_get_locus (mach, &locus); if (status) /* Cannot get locus ?! */ { mu_sieve_error (mach, "NOTIFY: Cannot get locus for sieve engine"); return -1; } if (mu_sieve_tag_lookup (tags, "method", &val)) { url = val->v.string; } else { mu_sieve_error (mach,"%s:%lu: NOTIFY: cannot get :method tag", locus.source_file, (unsigned long) locus.source_line); return -1; } return 0; } /* Tagged arguments: */ static mu_sieve_tag_def_t notify_tags[] = { {"method", SVT_STRING}, {NULL} }; static mu_sieve_tag_group_t notify_tag_groups[] = { {notify_tags, NULL}, {NULL} }; /* Required arguments: */ /* There are no required arguments */ static mu_sieve_data_type notify_args[] = { SVT_VOID }; int SIEVE_EXPORT (notify, init) (mu_sieve_machine_t mach) { return mu_sieve_register_action (mach, "notify", sieve_action_notify, notify_args, notify_tag_groups, 1); }