1 #line 982 "../../src/builtin/snarf.m4"
2 /* -*- buffer-read-only: t -*- vi: set ro:
3 THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT.
4 */
5 #line 982
6 #ifdef HAVE_CONFIG_H
7 #line 982
8 # include <config.h>
9 #line 982
10 #endif
11 #line 982
12 #include <sys/types.h>
13 #line 982
14
15 #line 982
16 #include "mailfromd.h"
17 #line 982
18 #include "prog.h"
19 #line 982
20 #include "builtin.h"
21 #line 982
22
23 #line 982
24
25 #line 1022 "../../src/builtin/snarf.m4"
26
27 /* End of snarf.m4 */
28 #line 1 "rate.bi"
29 /* This file is part of Mailfromd. -*- c -*-
30 Copyright (C) 2006-2021 Sergey Poznyakoff
31
32 This program is free software; you can redistribute it and/or modify
33 it under the terms of the GNU General Public License as published by
34 the Free Software Foundation; either version 3, or (at your option)
35 any later version.
36
37 This program is distributed in the hope that it will be useful,
38 but WITHOUT ANY WARRANTY; without even the implied warranty of
39 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 GNU General Public License for more details.
41
42 You should have received a copy of the GNU General Public License
43 along with this program. If not, see <http://www.gnu.org/licenses/>. */
44
45
46
47 void
48 #line 19
bi_rate(eval_environ_t env)49 bi_rate(eval_environ_t env)
50 #line 19
51
52 #line 19
53
54 #line 19 "rate.bi"
55 {
56 #line 19
57
58 #line 19
59
60 #line 19
61 long __bi_argcnt;
62 #line 19
63 char * key;
64 #line 19
65 long interval;
66 #line 19
67 long mincnt;
68 #line 19
69 long threshold;
70 #line 19
71
72 #line 19
73 get_string_arg(env, 1, &key);
74 #line 19
75 get_numeric_arg(env, 2, &interval);
76 #line 19
77 get_numeric_arg(env, 3, &mincnt);
78 #line 19
79 get_numeric_arg(env, 4, &threshold);
80 #line 19
81
82 #line 19
83 get_numeric_arg(env, 0, &__bi_argcnt);
84 #line 19
85 adjust_stack(env, __bi_argcnt + 1);
86 #line 19
87
88 #line 19
89
90 #line 19
91 if (builtin_module_trace(BUILTIN_IDX_rate))
92 #line 19
93 prog_trace(env, "rate %s %lu %lu %lu",key, interval, ((__bi_argcnt > 2) ? mincnt : 0), ((__bi_argcnt > 3) ? threshold : 0));;
94
95 {
96 long ret;
97
98 if (!(get_rate(key, &ret, interval,
99 #line 24
100 ((__bi_argcnt > 2) ? mincnt : 0),
101 #line 24
102 ((__bi_argcnt > 3) ? threshold : 0)) == mf_success))
103 #line 24
104 (
105 #line 24
106 env_throw_bi(env, mfe_dbfailure, "rate", _("cannot get rate for %s"),key)
107 #line 24
108 )
109 #line 28
110 ;
111
112
113 #line 30
114 do {
115 #line 30
116 push(env, (STKVAL)(mft_number)(ret));
117 #line 30
118 goto endlab;
119 #line 30
120 } while (0);
121 }
122 endlab:
123 #line 32
124 env_function_cleanup_flush(env, NULL);
125 #line 32
126 return;
127 #line 32
128 }
129
130 void
131 #line 34
bi_tbf_rate(eval_environ_t env)132 bi_tbf_rate(eval_environ_t env)
133 #line 34
134
135 #line 34
136
137 #line 34 "rate.bi"
138 {
139 #line 34
140
141 #line 34
142
143 #line 34
144
145 #line 34
146 char * key;
147 #line 34
148 long cost;
149 #line 34
150 long interval;
151 #line 34
152 long burst_size;
153 #line 34
154
155 #line 34
156 get_string_arg(env, 0, &key);
157 #line 34
158 get_numeric_arg(env, 1, &cost);
159 #line 34
160 get_numeric_arg(env, 2, &interval);
161 #line 34
162 get_numeric_arg(env, 3, &burst_size);
163 #line 34
164
165 #line 34
166
167 #line 34
168 adjust_stack(env, 4);
169 #line 34
170
171 #line 34
172
173 #line 34
174 if (builtin_module_trace(BUILTIN_IDX_rate))
175 #line 34
176 prog_trace(env, "tbf_rate %s %lu %lu %lu",key, cost, interval, burst_size);;
177
178 {
179 int result;
180
181 if (!(check_tbf_rate(key, &result, cost, interval,
182 #line 39
183 burst_size) == mf_success))
184 #line 39
185 (
186 #line 39
187 env_throw_bi(env, mfe_dbfailure, "tbf_rate", _("cannot check TBF rate for %s"),key)
188 #line 39
189 )
190 #line 42
191 ;
192
193
194 #line 44
195 do {
196 #line 44
197 push(env, (STKVAL)(mft_number)(result));
198 #line 44
199 goto endlab;
200 #line 44
201 } while (0);
202 }
203 endlab:
204 #line 46
205 env_function_cleanup_flush(env, NULL);
206 #line 46
207 return;
208 #line 46
209 }
210
211 #line 982 "../../src/builtin/snarf.m4"
212
213 #line 982
214
215 #line 982
216
217 #line 982
218 void
219 #line 982
rate_init_builtin(void)220 rate_init_builtin(void)
221 #line 982
222 {
223 #line 982
224
225 #line 982
226 #line 19 "rate.bi"
227 va_builtin_install_ex("rate", bi_rate, 0, dtype_number, 4, 2, 0|0, dtype_string, dtype_number, dtype_number, dtype_number);
228 #line 34 "rate.bi"
229 va_builtin_install_ex("tbf_rate", bi_tbf_rate, 0, dtype_number, 4, 0, 0|0, dtype_string, dtype_number, dtype_number, dtype_number);
230
231 #line 982 "../../src/builtin/snarf.m4"
232
233 #line 982
234 }
235 #line 982 "../../src/builtin/snarf.m4"
236
237