1/* This file is part of Mailfromd.             -*- c -*-
2   Copyright (C) 2006-2021 Sergey Poznyakoff
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation; either version 3, or (at your option)
7   any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   GNU General Public License for more details.
13
14   You should have received a copy of the GNU General Public License
15   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17MF_BUILTIN_MODULE
18
19MF_DEFUN(rate, NUMBER, STRING key, NUMBER interval, OPTIONAL, NUMBER mincnt,
20	 NUMBER threshold)
21{
22	long ret;
23
24	MF_ASSERT(get_rate(key, &ret, interval,
25			   MF_OPTVAL(mincnt),
26			   MF_OPTVAL(threshold)) == mf_success,
27		  mfe_dbfailure,
28		  _("cannot get rate for %s"), key);
29
30	MF_RETURN(ret);
31}
32END
33
34MF_DEFUN(tbf_rate, NUMBER, STRING key, NUMBER cost,
35	 NUMBER interval, NUMBER burst_size)
36{
37        int result;
38
39	MF_ASSERT(check_tbf_rate(key, &result, cost, interval,
40				 burst_size) == mf_success,
41		  mfe_dbfailure,
42		  _("cannot check TBF rate for %s"), key);
43
44	MF_RETURN(result);
45}
46END
47
48