divert(-1) # This file is part of mailfrom filter. # 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 changequote([<,>]) dnl __mf_argtype(arg) -- return Mailfromd value type code corresponding to dnl ARG: dnl __mf_argtype(STRING) => rettype_string dnl __mf_argtype(NUMBER) => rettype_number dnl __mf_argtype(anything) => rettype_unspecified dnl define([<__mf_argtype>],dnl []) dnl mf_argtype(TYPE NAME) -- return Mailfromd value type code corresponding to dnl TYPE. See __mf_argtype above. dnl define([],dnl [<__mf_argtype(patsubst([<$1>],[<[ \t].*>],))>]) dnl mf_typelist(arglist) -- convert ARGLIST into a list of corresponding dnl Mailfromd value type codes. e.g.: dnl mf_typelist(STRING a, NUMBER b) => rettype_string, rettype_number dnl define([],dnl [], []dnl [])>]) dnl __mf_c_type(TYPE) -- return a C type corresponding to the Mailfromd one dnl define([<__mf_c_type>],dnl []) dnl mf_c_argdcl(TYPE NAME) -- translate Mailfromd declaration "TYPE NAME" dnl into the corresponding C one, followed by an equals sign and a typecast, dnl e.g.: dnl mf_c_argdcl(STRING str) => char *str = (char*) define([],dnl [],[<\(\w+\)\W+\(\w+\)>],[<__mf_c_type(\1)>] \2 = ([<__mf_c_type(\1)>]))>]) dnl __mf_c_arglist(ARGC, NARG, LIST) -- translate Mailfromd declaration list dnl into a set of corresponding C variable declarations with initializations. dnl Arguments: dnl ARGC -- number of arguments in LIST dnl NARG -- ordinal number of the first variable in LIST dnl LIST -- comma-separated list of Mailfromd declarations dnl define([<__mf_c_arglist>],dnl [])>]) dnl mf_c_arglist(LIST) -- translate Mailfromd declaration list dnl into a set of corresponding C variable declarations with initializations. dnl Insert an instruction to adjust the stack parameters after obtaining the dnl variables. dnl E.g.: dnl mf_c_arglist(STRING a, NUMBER n) => char *a = (char*)get_arg(env, 1); dnl long n = (long)get_arg(env, 0); dnl adjust_stack(env, 2); dnl define([],dnl [<__mf_c_arglist($#, 1, $@) adjust_stack(env, $#);>]) dnl __mf_printf_type(TYPE) -- translate the Mailfromd data type TYPE into the dnl printf metacharacter useful to output it. dnl define([<__mf_printf_type>],dnl []) dnl mf_printf_macro(TYPE NAME) -- translate TYPE to the printf metacharacter dnl printf metacharacter useful to output it. dnl define([],dnl [<%[<>]regexp([<$1>],[<\(\w+\)\W+.*>],[<__mf_printf_type(\1)>])>]) dnl mf_printf_list(LIST) -- convert the list of Mailfromd variable declarations dnl to a space-separated list of printf macros to print them: dnl mf_printf_list(STRING a, NUMBER b) => %s %lu dnl define([],dnl []mf_printf_list(shift($@))>])>]) dnl __mf_argname(TYPE NAME) -- return NAME dnl define([<__mf_argname>],dnl [],\1)>]) dnl mf_argnames(LIST) -- extract names from the Mailfromd declaration list: dnl mf_argnames(STRING a, NUMBER b) => a, b dnl define([],dnl [], [<__mf_argname($1), mf_argnames(shift($@))>])>]) dnl __mf_check_end() -- signal error if the previous MF_DEFUN statement was dnl not properly closed with END dnl define([<__mf_check_end>],dnl [],dnl []__MF_FUNCTION__[<' was not closed ) popdef([<__MF_FUNCTION__>]) define([<__mf_error_code>],1)>])>]) dnl MF_STATE(state) - Declare next MF_DEFUN as valid only in the given state. dnl The state argument is any valid milter state, as declared in dnl enum smtp_state (see mailfrom.h around line 74--87), but withouth the dnl `smtp_state_' prefix. dnl dnl Multiple occurrences of MF_STATE accumulate. dnl define([], [],dnl [],__MF_STATE__[< | EXMASK(smtp_state_$1)>])>],dnl [],[])>])>]) dnl MF_CAPTURE - Declare next MF_DEFUN as requiring message capturing dnl define([], [],,[],1)>])>]) dnl env_get_stream - a wrapper around the library function of the same name. dnl Expand to the function invocation only if the current function is declared dnl with capture attribute or the invocation is issued outside of a defun. define([],dnl [],dnl [],[<[]($@)>],dnl []__MF_FUNCTION__[<' is not declared with MF_CAPTURE>] ) define([<__mf_error_code>],1)>])>],dnl [])>]) dnl MF_DEFUN(NAME, RETTYPE, ARGS...) -- Begin a built-in function declaration dnl define([],dnl [<__mf_check_end[<>]dnl void bi_$1(eval_environ_t env) pushdef([<__MF_FUNCTION__>], $1)dnl divert(1)dnl va_builtin_install_ex("$1", bi_$1,dnl ifdef([<__MF_STATE__>],__MF_STATE__,0),dnl ifdef([<__MF_CAPTURE__>],__MF_CAPTURE__,0),dnl __mf_argtype($2), eval($# - 2),dnl mf_typelist(shift(shift($@)))); divert(0)dnl { mf_c_arglist(shift(shift($@))) if (prog_trace_option) prog_trace(env, "$1[<>]mf_printf_list(shift(shift($@)))", mf_argnames(shift(shift($@)))); >]) dnl END -- Finish the built-in function declaration, created with MF_DEFUN dnl define([],dnl [])dnl undefine([<__MF_CAPTURE__>])dnl undefine([<__MF_STATE__>])dnl }>]) dnl MF_INIT(MODNAME) -- create the initialization function for module MODNAME. dnl The function will be named MODNAME_init_builtin. dnl define([],dnl [<__mf_check_end[<>]dnl define([<__MF_INIT__>],1) void $1_init_builtin() { undivert(1) $2 }>]) m4wrap([<__mf_check_end ifdef([<__MF_INIT__>],,[] not defined ) define([<__mf_error_code>],1)>]) ifdef([<__mf_error_code>],[])>]) divert(0)dnl /* -*- buffer-read-only: t -*- vi: set ro: THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */ #ifdef HAVE_CONFIG_H # include #endif #include #include "mailfrom.h" #include "prog.h" dnl End of snarf.m4