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 "vars.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 #include "filenames.h" /* For DEFAULT_FROM_ADDRESS */
48 static size_t rcpt_count_loc
49 #line 20 "vars.bi"
50 ;
51 static size_t milter_client_family_loc
52 #line 21 "vars.bi"
53 ;
54 static size_t milter_client_address_loc
55 #line 22 "vars.bi"
56 ;
57 static size_t milter_server_family_loc
58 #line 23 "vars.bi"
59 ;
60 static size_t milter_server_address_loc
61 #line 24 "vars.bi"
62 ;
63 static size_t milter_server_id_loc
64 #line 25 "vars.bi"
65 ;
66 
67 /* Functions to access %rcpt_count */
68 unsigned long
get_rcpt_count(eval_environ_t env)69 get_rcpt_count(eval_environ_t env)
70 {
71  	return mf_c_val(*env_data_ref(env, rcpt_count_loc),long) ;
72 }
73 
74 void
clear_rcpt_count(eval_environ_t env)75 clear_rcpt_count(eval_environ_t env)
76 {
77 	mf_c_val(*env_data_ref(env, rcpt_count_loc),long) = (0);
78 }
79 
80 void
incr_rcpt_count(eval_environ_t env)81 incr_rcpt_count(eval_environ_t env)
82 {
83 	env_var_inc(env, rcpt_count_loc);
84 }
85 
86 /* define_milter_address name */
87 #line 91
88 
89 
90 
91 #line 93
92 
93 #line 93
94 void
95 #line 93
set_milter_server_address(eval_environ_t env,milter_sockaddr_t * addr,socklen_t len)96 set_milter_server_address(eval_environ_t env, milter_sockaddr_t *addr,
97 #line 93
98 		      socklen_t len)
99 #line 93
100 {
101 #line 93
102 	char *path;
103 #line 93
104 
105 #line 93
106 	switch (addr->sa.sa_family) {
107 #line 93
108 	case PF_INET:
109 #line 93
110 		mf_c_val(*env_data_ref(env, milter_server_family_loc),long) = (MFAM_INET);
111 #line 93
112 
113 #line 93
114 { size_t __off;
115 #line 93
116   const char *__s = inet_ntoa(addr->sin.sin_addr);
117 #line 93
118   if (__s)
119 #line 93
120      strcpy((char*)env_data_ref(env, __off = heap_reserve(env, strlen(__s) + 1)), __s);
121 #line 93
122   else
123 #line 93
124      __off = 0;
125 #line 93
126   mf_c_val(*env_data_ref(env, milter_server_address_loc),size) = (__off); }
127 #line 93
128 ;
129 #line 93
130 		break;
131 #line 93
132 
133 #line 93
134 #ifdef GACOPYZ_IPV6
135 #line 93
136 	case PF_INET6: {
137 #line 93
138 		char hostbuf[NI_MAXHOST];
139 #line 93
140 
141 #line 93
142 		mf_c_val(*env_data_ref(env, milter_server_family_loc),long) = (MFAM_INET6);
143 #line 93
144 		if (getnameinfo(&addr->sa, sizeof(addr->sin6),
145 #line 93
146 				hostbuf, sizeof hostbuf,
147 #line 93
148 				NULL, 0,
149 #line 93
150 				NI_NUMERICHOST|NI_NUMERICSERV))
151 #line 93
152 			hostbuf[0] = 0;
153 #line 93
154 
155 #line 93
156 { size_t __off;
157 #line 93
158   const char *__s = hostbuf;
159 #line 93
160   if (__s)
161 #line 93
162      strcpy((char*)env_data_ref(env, __off = heap_reserve(env, strlen(__s) + 1)), __s);
163 #line 93
164   else
165 #line 93
166      __off = 0;
167 #line 93
168   mf_c_val(*env_data_ref(env, milter_server_address_loc),size) = (__off); }
169 #line 93
170 ;
171 #line 93
172 		break;
173 #line 93
174 	}
175 #line 93
176 #endif
177 #line 93
178 
179 #line 93
180 	case PF_UNIX:
181 #line 93
182 		mf_c_val(*env_data_ref(env, milter_server_family_loc),long) = (MFAM_UNIX);
183 #line 93
184 		if (len == sizeof (addr->sa.sa_family))
185 #line 93
186 			path = "";
187 #line 93
188 		else
189 #line 93
190 			path = addr->sunix.sun_path;
191 #line 93
192 
193 #line 93
194 { size_t __off;
195 #line 93
196   const char *__s = path;
197 #line 93
198   if (__s)
199 #line 93
200      strcpy((char*)env_data_ref(env, __off = heap_reserve(env, strlen(__s) + 1)), __s);
201 #line 93
202   else
203 #line 93
204      __off = 0;
205 #line 93
206   mf_c_val(*env_data_ref(env, milter_server_address_loc),size) = (__off); }
207 #line 93
208 ;
209 #line 93
210 		break;
211 #line 93
212 
213 #line 93
214 	default:
215 #line 93
216 		/* FIXME */
217 #line 93
218 		mf_c_val(*env_data_ref(env, milter_server_family_loc),long) = ((long)addr->sa.sa_family);
219 #line 93
220 	}
221 #line 93
222 }
223 #line 93
224 
225 #line 93
226 
227 #line 93
228 
229 #line 93
230 
231 
232 #line 94
233 
234 #line 94
235 void
236 #line 94
set_milter_client_address(eval_environ_t env,milter_sockaddr_t * addr,socklen_t len)237 set_milter_client_address(eval_environ_t env, milter_sockaddr_t *addr,
238 #line 94
239 		      socklen_t len)
240 #line 94
241 {
242 #line 94
243 	char *path;
244 #line 94
245 
246 #line 94
247 	switch (addr->sa.sa_family) {
248 #line 94
249 	case PF_INET:
250 #line 94
251 		mf_c_val(*env_data_ref(env, milter_client_family_loc),long) = (MFAM_INET);
252 #line 94
253 
254 #line 94
255 { size_t __off;
256 #line 94
257   const char *__s = inet_ntoa(addr->sin.sin_addr);
258 #line 94
259   if (__s)
260 #line 94
261      strcpy((char*)env_data_ref(env, __off = heap_reserve(env, strlen(__s) + 1)), __s);
262 #line 94
263   else
264 #line 94
265      __off = 0;
266 #line 94
267   mf_c_val(*env_data_ref(env, milter_client_address_loc),size) = (__off); }
268 #line 94
269 ;
270 #line 94
271 		break;
272 #line 94
273 
274 #line 94
275 #ifdef GACOPYZ_IPV6
276 #line 94
277 	case PF_INET6: {
278 #line 94
279 		char hostbuf[NI_MAXHOST];
280 #line 94
281 
282 #line 94
283 		mf_c_val(*env_data_ref(env, milter_client_family_loc),long) = (MFAM_INET6);
284 #line 94
285 		if (getnameinfo(&addr->sa, sizeof(addr->sin6),
286 #line 94
287 				hostbuf, sizeof hostbuf,
288 #line 94
289 				NULL, 0,
290 #line 94
291 				NI_NUMERICHOST|NI_NUMERICSERV))
292 #line 94
293 			hostbuf[0] = 0;
294 #line 94
295 
296 #line 94
297 { size_t __off;
298 #line 94
299   const char *__s = hostbuf;
300 #line 94
301   if (__s)
302 #line 94
303      strcpy((char*)env_data_ref(env, __off = heap_reserve(env, strlen(__s) + 1)), __s);
304 #line 94
305   else
306 #line 94
307      __off = 0;
308 #line 94
309   mf_c_val(*env_data_ref(env, milter_client_address_loc),size) = (__off); }
310 #line 94
311 ;
312 #line 94
313 		break;
314 #line 94
315 	}
316 #line 94
317 #endif
318 #line 94
319 
320 #line 94
321 	case PF_UNIX:
322 #line 94
323 		mf_c_val(*env_data_ref(env, milter_client_family_loc),long) = (MFAM_UNIX);
324 #line 94
325 		if (len == sizeof (addr->sa.sa_family))
326 #line 94
327 			path = "";
328 #line 94
329 		else
330 #line 94
331 			path = addr->sunix.sun_path;
332 #line 94
333 
334 #line 94
335 { size_t __off;
336 #line 94
337   const char *__s = path;
338 #line 94
339   if (__s)
340 #line 94
341      strcpy((char*)env_data_ref(env, __off = heap_reserve(env, strlen(__s) + 1)), __s);
342 #line 94
343   else
344 #line 94
345      __off = 0;
346 #line 94
347   mf_c_val(*env_data_ref(env, milter_client_address_loc),size) = (__off); }
348 #line 94
349 ;
350 #line 94
351 		break;
352 #line 94
353 
354 #line 94
355 	default:
356 #line 94
357 		/* FIXME */
358 #line 94
359 		mf_c_val(*env_data_ref(env, milter_client_family_loc),long) = ((long)addr->sa.sa_family);
360 #line 94
361 	}
362 #line 94
363 }
364 #line 94
365 
366 #line 94
367 
368 #line 94
369 
370 #line 94
371 
372 
373 
374 #line 96
375 
376 #line 96
377 void
378 #line 96
set_milter_server_id(eval_environ_t env,const char * id)379 set_milter_server_id(eval_environ_t env, const char *id)
380 #line 96
381 {
382 #line 96
383 
384 #line 96
385 { size_t __off;
386 #line 96
387   const char *__s = id ? id : "";
388 #line 96
389   if (__s)
390 #line 96
391      strcpy((char*)env_data_ref(env, __off = heap_reserve(env, strlen(__s) + 1)), __s);
392 #line 96
393   else
394 #line 96
395      __off = 0;
396 #line 96
397   mf_c_val(*env_data_ref(env, milter_server_id_loc),size) = (__off); }
398 #line 96
399 ;
400 #line 96
401 }
402 #line 96
403 
404 #line 96
405 
406 #line 96
407 
408 #line 102
409 
410 
411 #line 982 "../../src/builtin/snarf.m4"
412 
413 #line 982
414 
415 #line 982
416 
417 #line 982
418 void
419 #line 982
vars_init_builtin(void)420 vars_init_builtin(void)
421 #line 982
422 {
423 #line 982
424 
425 #line 982
426 	#line 20 "vars.bi"
427 	builtin_variable_install("rcpt_count", dtype_number, SYM_VOLATILE, &rcpt_count_loc);
428 #line 21 "vars.bi"
429 	builtin_variable_install("milter_client_family", dtype_number, SYM_VOLATILE|SYM_PRECIOUS, &milter_client_family_loc);
430 #line 22 "vars.bi"
431 	builtin_variable_install("milter_client_address", dtype_string, SYM_VOLATILE|SYM_PRECIOUS, &milter_client_address_loc);
432 #line 23 "vars.bi"
433 	builtin_variable_install("milter_server_family", dtype_number, SYM_VOLATILE|SYM_PRECIOUS, &milter_server_family_loc);
434 #line 24 "vars.bi"
435 	builtin_variable_install("milter_server_address", dtype_string, SYM_VOLATILE|SYM_PRECIOUS, &milter_server_address_loc);
436 #line 25 "vars.bi"
437 	builtin_variable_install("milter_server_id", dtype_string, SYM_VOLATILE|SYM_PRECIOUS, &milter_server_id_loc);
438 
439 #line 982 "../../src/builtin/snarf.m4"
440 
441 #line 982
442 }
443 #line 982 "../../src/builtin/snarf.m4"
444 
445