divert(-1) # This file is part of mailfromd. # Copyright (C) 2006, 2007 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([<,>]) changecom(/*,*/) dnl MF_MODULE_NAME() - Returns the name of the current module. dnl define([],[]) dnl MF_SOURCE_DEBUG_NAME(MODULE) - Initialize the "debug" name for the MODULE. dnl define([],[]translit(patsubst($1,\(.*/\)?\(.*\)\.m4,\2),[],[])>]) dnl MF_MODULE_MASK() - Returns BUILTIN_MASK_ constant for the current module. dnl define([],[]MF_MODULE_NAME()>]) dnl __mf_argtype(arg) -- return Mailfromd value type code corresponding to dnl ARG: dnl __mf_argtype(STRING) => dtype_string dnl __mf_argtype(NUMBER) => dtype_number dnl __mf_argtype(anything) => dtype_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) => dtype_string, dtype_number dnl define([],dnl [], dnl, $1, [], [], []dnl [])>]) dnl __mf_optarg_defined_p(TYPE,NAME) -- Return a C conditional expression dnl that yields true if the built-in function parameter NAME of type TYPE dnl is defined. dnl define([<__mf_optarg_defined_p>], []) dnl __mf_optarg_defined(NAME, ARGLIST...) -- Scan ARGLIST for the definition dnl of the built-in function parameter NAME, and return a C conditional dnl expression that yields true if it is defined. dnl ARGLIST is the list of parameter declarations in the form: dnl TYPE1,NAME1,TYPE2,NAME2... dnl define([<__mf_optarg_defined>], [])>],dnl $2, [], [<__mf_optarg_defined($1, shift(shift($@)))>],dnl $1,$3,[<__mf_optarg_defined_p($2,$3)>],dnl [<__mf_optarg_defined($1, shift(shift(shift($@))))>])>]) dnl __mf_defined(NAME, ARGS...) -- Scan ARGS... for the definition dnl of the built-in function parameter NAME, and return a C conditional dnl expression that yields true if it is defined. dnl ARGS are parameter declarations in the form: dnl TYPE NAME dnl define([<__mf_defined>], [<__mf_optarg_defined(patsubst([<$*>], [<[ ][ ]*>], [<,>]))>]) dnl MF_DEFINED(NAME) -- Return a C conditional expression dnl that yields true if the parameter NAME is defined. dnl define([], [],([<__mf_defined($1, __MF_ARGLIST__)>]),dnl [])>])>]) dnl MF_OPTVAL(NAME[, DEFVAL]) -- If the parameter NAME is defined, return dnl its value, otherwise return DEFVAL or 0 dnl define([], [],[],,$1,(MF_DEFINED($1) ? $1 : $2))>],dnl [])>])>]) dnl __mf_c_type(TYPE) -- return a C type corresponding to the Mailfromd one dnl define([<__mf_c_type>],dnl []) dnl __mf_c_getarg(TYPE) -- return a get_(.*)_arg function for the given MFL dnl TYPE define([<__mf_c_getarg>],dnl []) dnl mf_c_argdcl(TYPE NAME) -- translate Mailfromd declaration "TYPE NAME" dnl into the corresponding C one, followed by an equals sign, a typecast, dnl and the name of corresponding get_.*_arg function dnl e.g.: dnl mf_c_argdcl(STRING str) => char *str = (char*) get_string_arg define([],dnl [],[<\(\w+\)\W+\(\w+\)>],[<__mf_c_type(\1)>] \2 = ([<__mf_c_type(\1)>]) [<__mf_c_getarg(\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) => dnl char *a = (char*)get_string_arg(env, 1); dnl long n = (long)get_numeric_arg(env, 0); dnl adjust_stack(env, 2); dnl define([],dnl [< pushdef([<__ARGC__>], mf_argcount($@))dnl __mf_c_arglist(__ARGC__, 1, $@) adjust_stack(env, __ARGC__); popdef([<__ARGC__>])dnl >]) 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 for use in *printf functions. 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 [],dnl [],dnl [< mf_printf_macro($1)[<>]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 [],dnl $1,[],[],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 mailfromd.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_optcount(ARGS...) -- Return the number of optional arguments in ARGS dnl define([],[],eval($# - 1),[])>]) dnl __mf_argcount(COUNT, ARGS...) -- Auxiliary function for mf_argcount dnl COUNT is number of arguments counted so far dnl ARGS are the rest of the arguments dnl define([<__mf_argcount>],[],[<__mf_argcount($1, shift(shift($@)))>],dnl [<__mf_argcount(incr($1), shift(shift($@)))>])>]) dnl mf_argcount(ARGS...) -- Return the number of arguments in ARGS, not dnl counting eventual OPTIONAL modifier. dnl define([],[]) dnl mf_prog_trace(fname[, args...]) dnl define([],[]mf_printf_list(shift($@))"dnl ifelse($2,,,[<,mf_argnames(shift($@))>]));>]) 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 pushdef([<__MF_ARGLIST__>], []) 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), dnl mf_argcount(shift(shift($@))), mf_optcount(shift(shift($@))), dnl mf_typelist(shift(shift($@)))); divert(0)dnl { mf_c_arglist(shift(shift($@))) if (prog_trace_option & MF_MODULE_MASK) mf_prog_trace($1,shift(shift($@))); >]) dnl MF_RETURN(value) - Return a numeric value dnl define([],[]) dnl MF_RETURN_STRING(value) - Return a string value dnl define([],[]) dnl MF_ALLOC_HEAP(off, len) - Allocate LEN bytes from the heap dnl define([],[] = heap_reserve(env, $2)))>]) dnl MF_ALLOC_HEAP_TEMP(len) - Temporarly allocate LEN bytes from the heap. dnl define([],[]) dnl MF_COPY_STRING(off, string) - Copy STRING to the heap. Return the dnl pointer to the copy. dnl define([],[]) dnl MF_BEGIN_TEMP_SPACE(ptr,size) - Begin temporary space manipulations dnl On return PTR will point to the temporary heap space capable of holding dnl at least SIZE bytes of data. dnl NOTE: No other heap manipulation function can be used between dnl MF_BEGIN_TEMP_SPACE and MF_END_TEMP_SPACE/MF_RETURN_TEMP_SPACE dnl define([],[],$1)>]) dnl MF_END_TEMP_SPACE - Cancel temporary heap allocation initiated by dnl MF_BEGIN_TEMP_SPACE dnl define([],[])>]) dnl MF_RETURN_TEMP_SPACE([SIZE]) - Relocate and return temporary space dnl define([],[< MF_RETURN(heap_fix_tempspace(env, dnl []))dnl MF_END_TEMP_SPACE()>]) dnl MF_VAR(name,type) - Declare a global variable NAME of type TYPE. dnl define([],[off; divert(0)dnl >]) dnl MF_VAR_REF(name[, value]) - Reference global variable NAME dnl In one-argument form, return its value. In two-arguments form, assign dnl the VALUE to it. dnl define([],[]) dnl MF_VAR_SET_STRING(name, value) - Set variable NAME to the string VALUE define([],[< { size_t off; if ($2) MF_COPY_STRING(off, $2); else off = 0; MF_VAR_REF($1, off); } >]) dnl MF_VAR_INC(name) - Increment the value of the global variable NAME dnl define([],[]) dnl MF_DECLARE_DATA(name, init [, destr]) - Declare private data for dnl the current module. dnl NAME - data identifier. dnl INIT - initialization function (void init(void)) dnl DESTR - destructor function (void destr(void*)) dnl define([],[< define([<__MF_PRIV_ID__>],$1_id) static int __MF_PRIV_ID__; divert(1)dnl __MF_PRIV_ID__ = builtin_priv_register($2, dnl ifelse($3,,NULL,$3)); divert(0)dnl >]) dnl MF_GET_DATA - Return pointer to the private data, declared with dnl MF_DECLARE_DATA dnl define([],[],[],dnl [] first) ) define([<__mf_error_code>],1) >])>]) dnl MF_THROW(exception, ...) dnl define([],[],dnl "__MF_FUNCTION__: ") shift($@)); >]) dnl MF_ASSERT(cond, exception, ...) dnl define([],[]) dnl END -- Finish the built-in function declaration, created with MF_DEFUN dnl define([],dnl [])dnl popdef([<__MF_ARGLIST__>])dnl undefine([<__MF_CAPTURE__>])dnl undefine([<__MF_STATE__>])dnl }>]) dnl MF_INIT(CODE) -- create the initialization function for the curent module. dnl The function will be named MODNAME_init_builtin. dnl define([],dnl [<__mf_check_end[<>]dnl undefine([<__MF_PRIV_ID__>])dnl define([<__MF_INIT__>],1) void MF_MODULE_NAME()_init_builtin() { undivert(1) $1 }>]) 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. */ MF_SOURCE_DEBUG_NAME(SOURCE) #ifdef HAVE_CONFIG_H # include #endif #include #include "mailfromd.h" #include "prog.h" #include "builtin.h" dnl End of snarf.m4