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 "body.bi"
29 /* This file is part of Mailfromd.             -*- c -*-
30    Copyright (C) 2008-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 #include "msg.h"
48 
49 
50 void
51 #line 22
bi_body_string(eval_environ_t env)52 bi_body_string(eval_environ_t env)
53 #line 22
54 
55 #line 22
56 
57 #line 22 "body.bi"
58 {
59 #line 22
60 
61 #line 22
62 
63 #line 22
64 
65 #line 22
66 void * MFL_DATASEG text;
67 #line 22
68         long  length;
69 #line 22
70 
71 #line 22
72 get_pointer_arg(env, 0, &text);
73 #line 22
74         get_numeric_arg(env, 1, &length);
75 #line 22
76 
77 #line 22
78 
79 #line 22
80         adjust_stack(env, 2);
81 #line 22
82 
83 #line 22
84 
85 #line 22
86 	if (builtin_module_trace(BUILTIN_IDX_body))
87 #line 22
88 		prog_trace(env, "body_string %p %lu",text, length);;
89 #line 22
90 
91 {
92 	size_t off;
93 	char *s = (char*) env_data_ref(env, (off = heap_reserve(env, length + 1)));
94 	memcpy(s, text, length);
95 	s[length] = 0;
96 
97 #line 28
98 do {
99 #line 28
100   push(env, (STKVAL) (mft_size) (off));
101 #line 28
102   goto endlab;
103 #line 28
104 } while (0);
105 }
106 endlab:
107 #line 30
108         env_function_cleanup_flush(env, NULL);
109 #line 30
110 	return;
111 #line 30
112 }
113 
114 
115 void
116 #line 33
bi_body_has_nulls(eval_environ_t env)117 bi_body_has_nulls(eval_environ_t env)
118 #line 33
119 
120 #line 33
121 
122 #line 33 "body.bi"
123 {
124 #line 33
125 
126 #line 33
127 
128 #line 33
129 
130 #line 33
131 void *  text;
132 #line 33
133         long  length;
134 #line 33
135 
136 #line 33
137 get_pointer_arg(env, 0, &text);
138 #line 33
139         get_numeric_arg(env, 1, &length);
140 #line 33
141 
142 #line 33
143 
144 #line 33
145         adjust_stack(env, 2);
146 #line 33
147 
148 #line 33
149 
150 #line 33
151 	if (builtin_module_trace(BUILTIN_IDX_body))
152 #line 33
153 		prog_trace(env, "body_has_nulls %p %lu",text, length);;
154 #line 33
155 
156 {
157 
158 #line 35
159 do {
160 #line 35
161   push(env, (STKVAL)(mft_number)(memchr(text, 0, length) != NULL));
162 #line 35
163   goto endlab;
164 #line 35
165 } while (0);
166 }
167 endlab:
168 #line 37
169         env_function_cleanup_flush(env, NULL);
170 #line 37
171 	return;
172 #line 37
173 }
174 
175 /* number current_message() */
176 
177 
178 void
179 #line 42
bi_current_message(eval_environ_t env)180 bi_current_message(eval_environ_t env)
181 #line 42
182 
183 #line 42
184 
185 #line 42 "body.bi"
186 {
187 #line 42
188 
189 #line 42
190 
191 #line 42
192 
193 #line 42
194 
195 #line 42
196 
197 #line 42
198 
199 #line 42
200         adjust_stack(env, 0);
201 #line 42
202 
203 #line 42
204 
205 #line 42
206 	if (builtin_module_trace(BUILTIN_IDX_body))
207 #line 42
208 		prog_trace(env, "current_message");;
209 #line 42
210 
211 {
212 
213 #line 44
214 do {
215 #line 44
216   push(env, (STKVAL)(mft_number)(bi_get_current_message(env, NULL)));
217 #line 44
218   goto endlab;
219 #line 44
220 } while (0);
221 }
222 endlab:
223 #line 46
224         env_function_cleanup_flush(env, NULL);
225 #line 46
226 	return;
227 #line 46
228 }
229 
230 void
231 #line 48
bi_replbody(eval_environ_t env)232 bi_replbody(eval_environ_t env)
233 #line 48
234 
235 #line 48
236 
237 #line 48 "body.bi"
238 {
239 #line 48
240 
241 #line 48
242 
243 #line 48
244 
245 #line 48
246 char *  text;
247 #line 48
248 
249 #line 48
250 get_string_arg(env, 0, &text);
251 #line 48
252 
253 #line 48
254 
255 #line 48
256         adjust_stack(env, 1);
257 #line 48
258 
259 #line 48
260 
261 #line 48
262 	if (builtin_module_trace(BUILTIN_IDX_body))
263 #line 48
264 		prog_trace(env, "replbody %s",text);;
265 #line 48
266 
267 {
268 	env_msgmod_append(env, body_repl, "BODY", text, 0);
269 }
270 
271 #line 52
272         env_function_cleanup_flush(env, NULL);
273 #line 52
274 	return;
275 #line 52
276 }
277 
278 void
279 #line 54
bi_replbody_fd(eval_environ_t env)280 bi_replbody_fd(eval_environ_t env)
281 #line 54
282 
283 #line 54
284 
285 #line 54 "body.bi"
286 {
287 #line 54
288 
289 #line 54
290 
291 #line 54
292 
293 #line 54
294 long  fd;
295 #line 54
296 
297 #line 54
298 get_numeric_arg(env, 0, &fd);
299 #line 54
300 
301 #line 54
302 
303 #line 54
304         adjust_stack(env, 1);
305 #line 54
306 
307 #line 54
308 
309 #line 54
310 	if (builtin_module_trace(BUILTIN_IDX_body))
311 #line 54
312 		prog_trace(env, "replbody_fd %lu",fd);;
313 #line 54
314 
315 {
316 	env_msgmod_append(env, body_repl_fd, "BODYFD", NULL, _bi_io_fd(env, fd, 0));
317 }
318 
319 #line 58
320         env_function_cleanup_flush(env, NULL);
321 #line 58
322 	return;
323 #line 58
324 }
325 
326 #line 982 "../../src/builtin/snarf.m4"
327 
328 #line 982
329 
330 #line 982
331 
332 #line 982
333 void
334 #line 982
body_init_builtin(void)335 body_init_builtin(void)
336 #line 982
337 {
338 #line 982
339 
340 #line 982
341 	#line 22 "body.bi"
342 va_builtin_install_ex("body_string", bi_body_string, STATMASK(smtp_state_body), dtype_string, 2, 0, 0|0, dtype_pointer, dtype_number);
343 #line 33 "body.bi"
344 va_builtin_install_ex("body_has_nulls", bi_body_has_nulls, STATMASK(smtp_state_body), dtype_number, 2, 0, 0|0, dtype_pointer, dtype_number);
345 #line 42 "body.bi"
346 va_builtin_install_ex("current_message", bi_current_message, STATMASK(smtp_state_eom), dtype_number, 0, 0, MFD_BUILTIN_CAPTURE|0, dtype_unspecified);
347 #line 48 "body.bi"
348 va_builtin_install_ex("replbody", bi_replbody, 0, dtype_unspecified, 1, 0, 0|0, dtype_string);
349 #line 54 "body.bi"
350 va_builtin_install_ex("replbody_fd", bi_replbody_fd, 0, dtype_unspecified, 1, 0, 0|0, dtype_number);
351 
352 #line 982 "../../src/builtin/snarf.m4"
353 
354 #line 982
355 }
356 #line 982 "../../src/builtin/snarf.m4"
357 
358