/* 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 */ static int valid_user_p(eval_environ_t env, const char *name) { int rc; struct mu_auth_data *auth_data = NULL; #if HAVE_MU_GET_AUTH rc = mu_get_auth(&auth_data, mu_auth_key_name, name); mu_auth_data_free(auth_data); switch (rc) { case 0: rc = 1; break; case MU_ERR_AUTH_FAILURE: rc = 0; break; case EAGAIN: MF_CATCH(mf_temp_failure, "Temporary failure querying for username %s", name); break; default: MF_CATCH(mf_failure, "Failure querying for username %s", name); break; } #else auth_data = mu_get_auth_by_name(name); rc = auth_data != NULL; mu_auth_data_free(auth_data); #endif debug2(10, "Checking user %s: %s", name, rc ? "true" : "false"); return rc; } MF_DEFUN(validuser, NUMBER, STRING name) { MF_RETURN(valid_user_p(env, name)); } END MF_DEFUN(interval, NUMBER, STRING str) { time_t t; char *endp; MF_ASSERT(parse_time_interval(str, &t, &endp) == 0, mf_invtime, "unrecognized time format (near `%s')", endp); MF_RETURN(t); } END MF_DEFUN(rate, NUMBER, STRING key, NUMBER interval) { double rate; long lrate; MF_ASSERT(get_rate(key, &rate) == mf_success, mf_dbfailure, "cannot get rate for %s", key); lrate = rate * interval; MF_RETURN(lrate); } END MF_DEFUN(debug, VOID, STRING spec) { enable_debug_list(spec); } END MF_DEFUN(cancel_debug, VOID, STRING spec) { disable_debug_list(spec); } END MF_DEFUN(program_trace, VOID, STRING name) { enable_prog_trace(name); } END MF_DEFUN(cancel_program_trace, VOID, STRING name) { disable_prog_trace(name); } END MF_INIT