/* This file is part of mailfrom filter. -*- c -*- Copyright (C) 2006 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ size_t last_poll_host_loc; size_t last_poll_send_loc; size_t last_poll_recv_loc; size_t cache_used_loc; void set_last_poll_result(eval_environ_t env, const char *host_addr, const char *send, const char *recv) { char *s; s = host_addr ? strcpy(heap_reserve(env, strlen(host_addr) + 1), host_addr) : NULL; *env_var_ref(env, last_poll_host_loc) = s; s = send ? strcpy(heap_reserve(env, strlen(send) + 1), send) : NULL; *env_var_ref(env, last_poll_send_loc) = s; s = recv ? strcpy(heap_reserve(env, strlen(recv) + 1), recv) : NULL; *env_var_ref(env, last_poll_recv_loc) = s; } void set_cache_used(eval_environ_t env, int value) { *env_var_ref(env, cache_used_loc) = (STKVAL) value; } MF_DEFUN(stdpoll, NUMBER, STRING email, STRING ehlo, STRING mailfrom) { mf_status rc; const struct locus *locus = env_get_locus(env); trace("%s%s:%lu: STANDARD POLL FOR %s FROM %s AS %s", mailfromd_msgid(env_get_context(env)), locus->file, locus->line, email, ehlo, mailfrom); rc = method_standard(env, email, ehlo, mailfrom); if (!mf_resolved (rc)) { if (env_catch(env, rc) == 0) return; else runtime_error(env, "unhandled exception %s", mf_status_str(rc)); } push(env, (STKVAL) rc); } END MF_DEFUN(strictpoll, NUMBER, STRING host, STRING email, STRING ehlo, STRING mailfrom) { mf_status rc; const struct locus *locus = env_get_locus(env); trace("%s%s:%lu: STRICT POLL FOR %s HOST %s FROM %s AS %s", mailfromd_msgid(env_get_context(env)), locus->file, locus->line, email, host, ehlo, mailfrom); rc = method_strict(env, email, host, ehlo, mailfrom); if (!mf_resolved (rc)) { if (env_catch(env, rc) == 0) return; else runtime_error(env, "unhandled exception %s", mf_status_str(rc)); } push(env, (STKVAL) rc); } END MF_DEFUN(_pollhost, NUMBER, STRING host, STRING email, STRING ehlo, STRING mailfrom) { mf_status rc; const struct locus *locus = env_get_locus(env); trace("%s%s:%lu: POLLHOST %s FOR %s FROM %s AS %s", mailfromd_msgid(env_get_context(env)), locus->file, locus->line, email, host, ehlo, mailfrom); rc = check_on_host(env, email, host, ehlo, mailfrom); if (!mf_resolved (rc)) { if (env_catch(env, rc) == 0) return; else runtime_error(env, "unhandled exception %s", mf_status_str(rc)); } push(env, (STKVAL) rc); } END MF_DEFUN(_pollmx, NUMBER, STRING domain, STRING email, STRING ehlo, STRING mailfrom) { mf_status rc; const struct locus *locus = env_get_locus(env); trace("%s%s:%lu: POLLMX %s FOR %s FROM %s AS %s", mailfromd_msgid(env_get_context(env)), locus->file, locus->line, domain, email, ehlo, mailfrom); rc = check_mx_records(env, email, domain, ehlo, mailfrom, NULL); if (!mf_resolved (rc)) { if (env_catch(env, rc) == 0) return; else runtime_error(env, "unhandled exception %s", mf_status_str(rc)); } push(env, (STKVAL) rc); } END MF_INIT(poll, last_poll_host_loc = builtin_variable_install("last_poll_host", rettype_string)->off; last_poll_send_loc = builtin_variable_install("last_poll_send", rettype_string)->off; last_poll_recv_loc = builtin_variable_install("last_poll_recv", rettype_string)->off; cache_used_loc = builtin_variable_install("cache_used", rettype_string)->off; )