From d8b9854a76d69e99bbbddd285a0e0d7727a62e4f Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 2 Nov 2018 12:47:51 +0200 Subject: Revise preprocessor macros for builtin functions. * doc/mailfromd.texi: Minor change. * src/builtin/Makefile.am (builtin.h): Depend pn init.m4 (.bi.c): Don't eliminate first #line * src/builtin/snarf.m4 (MF_BUILTIN_MODULE): New macro. (MF_INIT): Rewrite. Revise comments. * src/builtin/init.m4 (MF_BUILTIN_MODULE): New macro. (MF_INIT): Remove. * src/builtin/body.bi: Use MF_BUILTIN_MODULE statement. * src/builtin/burst.bi: Likewise. * src/builtin/callout.bi: Likewise. * src/builtin/ctype.bi: Likewise. * src/builtin/curhdr.bi: Likewise. * src/builtin/db.bi: Likewise. * src/builtin/debug.bi: Likewise. * src/builtin/dns.bi: Likewise. * src/builtin/dspam.bi: Likewise. * src/builtin/email.bi: Likewise. * src/builtin/from.bi: Likewise. * src/builtin/geoip.bi: Likewise. * src/builtin/gethostname.bi: Likewise. * src/builtin/getopt.bi: Likewise. * src/builtin/getpw.bi: Likewise. * src/builtin/gettext.bi: Likewise. * src/builtin/header.bi: Likewise. * src/builtin/io.bi: Likewise. * src/builtin/ipaddr.bi: Likewise. * src/builtin/macro.bi: Likewise. * src/builtin/mail.bi: Likewise. * src/builtin/mbox.bi: Likewise. * src/builtin/mmq.bi: Likewise. * src/builtin/msg.bi: Likewise. * src/builtin/other.bi: Likewise. * src/builtin/prereq.bi: Likewise. * src/builtin/progress.bi: Likewise. * src/builtin/qrnt.bi: Likewise. * src/builtin/rate.bi: Likewise. * src/builtin/rcpt.bi: Likewise. * src/builtin/sa.bi: Likewise. * src/builtin/sieve.bi: Likewise. * src/builtin/spf.bi: Likewise. * src/builtin/sprintf.bi: Likewise. * src/builtin/string.bi: Likewise. * src/builtin/syslog.bi: Likewise. * src/builtin/system.bi: Likewise. * src/builtin/vars.bi: Likewise. --- src/builtin/Makefile.am | 6 +- src/builtin/body.bi | 3 +- src/builtin/builtin.def | 2 +- src/builtin/burst.bi | 2 + src/builtin/callout.bi | 1 + src/builtin/ctype.bi | 2 +- src/builtin/curhdr.bi | 2 +- src/builtin/db.bi | 3 +- src/builtin/debug.bi | 3 +- src/builtin/dns.bi | 3 +- src/builtin/dspam.bi | 2 +- src/builtin/email.bi | 2 +- src/builtin/from.bi | 3 +- src/builtin/geoip.bi | 3 +- src/builtin/gethostname.bi | 5 +- src/builtin/getopt.bi | 2 + src/builtin/getpw.bi | 4 +- src/builtin/gettext.bi | 5 +- src/builtin/header.bi | 3 +- src/builtin/init.m4 | 19 +- src/builtin/io.bi | 2 + src/builtin/ipaddr.bi | 5 +- src/builtin/macro.bi | 3 +- src/builtin/mail.bi | 3 +- src/builtin/mbox.bi | 2 + src/builtin/mmq.bi | 3 +- src/builtin/msg.bi | 2 + src/builtin/other.bi | 3 +- src/builtin/prereq.bi | 3 +- src/builtin/progress.bi | 3 +- src/builtin/qrnt.bi | 3 +- src/builtin/rate.bi | 3 +- src/builtin/rcpt.bi | 3 +- src/builtin/sa.bi | 4 +- src/builtin/sieve.bi | 3 +- src/builtin/snarf.m4 | 550 +++++++++++++++++++++++++++++++-------------- src/builtin/spf.bi | 3 +- src/builtin/sprintf.bi | 3 +- src/builtin/string.bi | 3 +- src/builtin/syslog.bi | 3 +- src/builtin/system.bi | 3 +- src/builtin/vars.bi | 3 +- 42 files changed, 465 insertions(+), 223 deletions(-) (limited to 'src') diff --git a/src/builtin/Makefile.am b/src/builtin/Makefile.am index 2e397f11..7d5db661 100644 --- a/src/builtin/Makefile.am +++ b/src/builtin/Makefile.am @@ -79,7 +79,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)\ $(DSPAM_CFLAGS) -builtin.h: Makefile.am builtin.def +builtin.h: Makefile.am builtin.def init.m4 $(BI_FILES:.bi=.c): snarf.m4 init.m4 @@ -88,9 +88,7 @@ SUFFIXES = .bi .c .def .h .mfi .mf M4=m4 .bi.c: - $(AM_V_GEN)$(M4) --prefix -s -DSOURCE="$<" $(top_srcdir)/src/builtin/snarf.m4 $< > $@-t && \ - sed '1{/#line/d;}' $@-t > $@ && \ - rm $@-t + $(AM_V_GEN)$(M4) --prefix -s -DSOURCE="$<" $(top_srcdir)/src/builtin/snarf.m4 $< > $@ .def.h: $(AM_V_GEN) $(M4) --prefix $(top_srcdir)/src/builtin/init.m4 $(BI_FILES) $< > $@ diff --git a/src/builtin/body.bi b/src/builtin/body.bi index ab6611ff..8626f122 100644 --- a/src/builtin/body.bi +++ b/src/builtin/body.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "msg.h" MF_STATE(body) @@ -66,4 +68,3 @@ MF_DEFUN(replbody_fd, VOID, NUMBER fd) } END -MF_INIT diff --git a/src/builtin/builtin.def b/src/builtin/builtin.def index ea1b39a4..3595df79 100644 --- a/src/builtin/builtin.def +++ b/src/builtin/builtin.def @@ -1,4 +1,4 @@ -/* This file is part of Mailfromd. +/* This file is part of Mailfromd. -*- C -*- Copyright (C) 2010-2018 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify diff --git a/src/builtin/burst.bi b/src/builtin/burst.bi index 34971f3b..ae0bb83c 100644 --- a/src/builtin/burst.bi +++ b/src/builtin/burst.bi @@ -16,6 +16,8 @@ /* Functions for converting RFC-934 digests into MIME messages. Largely inspired by MU's mh/burst.c */ + +MF_BUILTIN_MODULE #include #include "msg.h" #include "global.h" diff --git a/src/builtin/callout.bi b/src/builtin/callout.bi index 3c3f1586..24f9400f 100644 --- a/src/builtin/callout.bi +++ b/src/builtin/callout.bi @@ -15,6 +15,7 @@ along with this program. If not, see . */ /* Run-time support for callout functions */ +MF_BUILTIN_MODULE #include "filenames.h" #include "callout.h" diff --git a/src/builtin/ctype.bi b/src/builtin/ctype.bi index e452e25d..faa3e703 100644 --- a/src/builtin/ctype.bi +++ b/src/builtin/ctype.bi @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE MF_VAR(ctype_mismatch, NUMBER); m4_define([],[< @@ -44,4 +45,3 @@ MF_DEFUN_CTYPE(isspace) MF_DEFUN_CTYPE(isupper) MF_DEFUN_CTYPE(isxdigit) -MF_INIT diff --git a/src/builtin/curhdr.bi b/src/builtin/curhdr.bi index e7dc4606..14430d6c 100644 --- a/src/builtin/curhdr.bi +++ b/src/builtin/curhdr.bi @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE #include "msg.h" /* number current_header_count([string name]) */ @@ -148,4 +149,3 @@ MF_DEFUN(current_header, STRING, STRING name, OPTIONAL, NUMBER index) } END -MF_INIT diff --git a/src/builtin/db.bi b/src/builtin/db.bi index 7186e3c7..8dea160e 100644 --- a/src/builtin/db.bi +++ b/src/builtin/db.bi @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE #define DEFAULT_DB_MODE 0640 #include @@ -967,5 +968,3 @@ MF_DEFUN(db_expire_interval, NUMBER, STRING fmtid) } END -MF_INIT - diff --git a/src/builtin/debug.bi b/src/builtin/debug.bi index e2307946..f9a49c69 100644 --- a/src/builtin/debug.bi +++ b/src/builtin/debug.bi @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE #include "mflib/_register.h" #include "srvcfg.h" @@ -132,4 +133,4 @@ MF_INIT([< bi_debug, 0, dtype_unspecified, 1, 0, 0, dtype_string); >]) - + diff --git a/src/builtin/dns.bi b/src/builtin/dns.bi index 6a98dfd5..b417a8c1 100644 --- a/src/builtin/dns.bi +++ b/src/builtin/dns.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include #include #include @@ -277,4 +279,3 @@ MF_DEFUN(ptr_validate, NUMBER, STRING s) } END -MF_INIT diff --git a/src/builtin/dspam.bi b/src/builtin/dspam.bi index cc4b7d23..d1ab7e71 100644 --- a/src/builtin/dspam.bi +++ b/src/builtin/dspam.bi @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE MF_COND(WITH_DSPAM) #include "srvcfg.h" @@ -529,4 +530,3 @@ MF_DEFUN(dspam, NUMBER, NUMBER nmsg, NUMBER mode_flags, OPTIONAL, NUMBER class_s } END -MF_INIT diff --git a/src/builtin/email.bi b/src/builtin/email.bi index 2d90abcc..a396f24d 100644 --- a/src/builtin/email.bi +++ b/src/builtin/email.bi @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE #include "mflib/email.h" MF_DEFUN(domainpart, STRING, STRING str) @@ -77,4 +78,3 @@ MF_DEFUN(email_map, NUMBER, STRING str) } END -MF_INIT diff --git a/src/builtin/from.bi b/src/builtin/from.bi index 57201520..73a84cd5 100644 --- a/src/builtin/from.bi +++ b/src/builtin/from.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_DEFUN(set_from, VOID, STRING addr, OPTIONAL, STRING args) { struct mu_locus_range locus; @@ -29,4 +31,3 @@ MF_DEFUN(set_from, VOID, STRING addr, OPTIONAL, STRING args) } END -MF_INIT diff --git a/src/builtin/geoip.bi b/src/builtin/geoip.bi index b2dcad93..c40a1845 100644 --- a/src/builtin/geoip.bi +++ b/src/builtin/geoip.bi @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE MF_COND(WITH_GEOIP) #include @@ -55,5 +56,3 @@ MF_DEFUN(geoip_country_code_by_name, STRING, STRING name, } END -MF_INIT - diff --git a/src/builtin/gethostname.bi b/src/builtin/gethostname.bi index 3d616683..9914a574 100644 --- a/src/builtin/gethostname.bi +++ b/src/builtin/gethostname.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #ifndef ENAMETOOLONG # define ENAMETOOLONG 0 #endif @@ -134,5 +136,4 @@ MF_DEFUN(getdomainname, STRING) MF_RETURN_OBSTACK(); } END - -MF_INIT + diff --git a/src/builtin/getopt.bi b/src/builtin/getopt.bi index 3303052e..e50f3eb0 100644 --- a/src/builtin/getopt.bi +++ b/src/builtin/getopt.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include #include #include diff --git a/src/builtin/getpw.bi b/src/builtin/getpw.bi index a148a713..7e127198 100644 --- a/src/builtin/getpw.bi +++ b/src/builtin/getpw.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + static void return_passwd(eval_environ_t env, struct passwd *pw) { @@ -75,5 +77,3 @@ MF_DEFUN(getpwuid, STRING, NUMBER uid) } END - -MF_INIT diff --git a/src/builtin/gettext.bi b/src/builtin/gettext.bi index 070c294e..329feae9 100644 --- a/src/builtin/gettext.bi +++ b/src/builtin/gettext.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_DEFUN(bindtextdomain, STRING, STRING domain, STRING dirname) { const char *s = bindtextdomain(domain[0] ? domain : NULL, dirname); @@ -37,6 +39,3 @@ MF_DEFUN(dngettext, STRING, STRING domain, } END -MF_INIT - - diff --git a/src/builtin/header.bi b/src/builtin/header.bi index 2922157e..e46183df 100644 --- a/src/builtin/header.bi +++ b/src/builtin/header.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_DEFUN(header_add, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) { struct mu_locus_range locus; @@ -117,4 +119,3 @@ MF_DEFUN(header_replace_nth, VOID, NUMBER idx, STRING name, STRING value) } END -MF_INIT diff --git a/src/builtin/init.m4 b/src/builtin/init.m4 index 64cdd9d7..73168b58 100644 --- a/src/builtin/init.m4 +++ b/src/builtin/init.m4 @@ -18,12 +18,6 @@ m4_divert(-1) m4_changequote([<,>]) m4_changecom(/*,*/) -m4_define([],[]) - -m4_define([],[]MF_MODULE_NAME()>]) - m4_define([<__MODNO__>],0) m4_define([],[]) -m4_define([],[],MF_MODULE_NAME()) +m4_define([], +[], +m4_ifelse([<$1>],,[],[<$1>])) +m4_pushdef([],[<[]MF_MODULE_NAME()>]) m4_define([<__MODNO__>],m4_incr(__MODNO__)) m4_divert(1)m4_dnl #define MF_MODULE_IDX (__MODNO__) m4_divert(2)m4_dnl -extern void MODNAME[<>]_init_builtin(void); +extern void MF_MODULE_NAME[<>]_init_builtin(void); m4_divert(3)m4_dnl - { "MODNAME", MODNAME[<>]_init_builtin, 0 }, -m4_divert(-1)m4_dnl>]) + { "MF_MODULE_NAME", MF_MODULE_NAME[<>]_init_builtin, 0 }, +m4_divert(-1)>]) diff --git a/src/builtin/io.bi b/src/builtin/io.bi index 2ca80e2a..d1512ad8 100644 --- a/src/builtin/io.bi +++ b/src/builtin/io.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include #include #include diff --git a/src/builtin/ipaddr.bi b/src/builtin/ipaddr.bi index 9ede3b4d..a586342c 100644 --- a/src/builtin/ipaddr.bi +++ b/src/builtin/ipaddr.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include #include #include @@ -97,6 +99,3 @@ MF_DEFUN(netmask_to_len, NUMBER, NUMBER x) } END -MF_INIT - - diff --git a/src/builtin/macro.bi b/src/builtin/macro.bi index 757bbf8f..2d41ff71 100644 --- a/src/builtin/macro.bi +++ b/src/builtin/macro.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + /* #pragma miltermacros [name...] */ MF_PRAGMA(miltermacros, 3, 0) { @@ -46,4 +48,3 @@ MF_DEFUN(macro_defined, NUMBER, STRING name) } END -MF_INIT diff --git a/src/builtin/mail.bi b/src/builtin/mail.bi index dc7ea34b..edf21b3b 100644 --- a/src/builtin/mail.bi +++ b/src/builtin/mail.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "msg.h" static int @@ -335,4 +337,3 @@ MF_DEFUN(send_dsn, VOID, STRING to, } END -MF_INIT diff --git a/src/builtin/mbox.bi b/src/builtin/mbox.bi index a0226ce2..df4f3ec2 100644 --- a/src/builtin/mbox.bi +++ b/src/builtin/mbox.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "msg.h" #include "global.h" diff --git a/src/builtin/mmq.bi b/src/builtin/mmq.bi index c9c24bc5..5ad0e32c 100644 --- a/src/builtin/mmq.bi +++ b/src/builtin/mmq.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + /* Clear the list of message modification requests. This function undoes the effect of the following functions, if they had been called previously: rcpt_add, rcpt_delete, header_add, header_insert, @@ -25,4 +27,3 @@ MF_DEFUN(mmq_purge, VOID) } END -MF_INIT diff --git a/src/builtin/msg.bi b/src/builtin/msg.bi index faaa7bf5..46e63cd2 100644 --- a/src/builtin/msg.bi +++ b/src/builtin/msg.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "msg.h" #include "global.h" diff --git a/src/builtin/other.bi b/src/builtin/other.bi index 673f4515..5063885e 100644 --- a/src/builtin/other.bi +++ b/src/builtin/other.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "mflib/_register.h" static int @@ -69,4 +71,3 @@ MF_DEFUN(interval, NUMBER, STRING str) } END -MF_INIT diff --git a/src/builtin/prereq.bi b/src/builtin/prereq.bi index d51c0e39..9d92b0a6 100644 --- a/src/builtin/prereq.bi +++ b/src/builtin/prereq.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + /* #pragma prereq */ MF_PRAGMA(prereq, 1, 0) { @@ -42,4 +44,3 @@ MF_DEFUN(vercmp, NUMBER, STRING a, STRING b) } END -MF_INIT diff --git a/src/builtin/progress.bi b/src/builtin/progress.bi index 00bb1a5a..484b8bb4 100644 --- a/src/builtin/progress.bi +++ b/src/builtin/progress.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_STATE(eom) MF_DEFUN(progress, VOID) { @@ -29,4 +31,3 @@ MF_DEFUN(progress, VOID) } END -MF_INIT diff --git a/src/builtin/qrnt.bi b/src/builtin/qrnt.bi index 85a961bd..74fc8331 100644 --- a/src/builtin/qrnt.bi +++ b/src/builtin/qrnt.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_DEFUN(quarantine, VOID, STRING reason) { struct mu_locus_range locus; @@ -29,4 +31,3 @@ MF_DEFUN(quarantine, VOID, STRING reason) } END -MF_INIT diff --git a/src/builtin/rate.bi b/src/builtin/rate.bi index bfbc8260..adf7a492 100644 --- a/src/builtin/rate.bi +++ b/src/builtin/rate.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_DEFUN(rate, NUMBER, STRING key, NUMBER interval, OPTIONAL, NUMBER mincnt, NUMBER threshold) { @@ -43,4 +45,3 @@ MF_DEFUN(tbf_rate, NUMBER, STRING key, NUMBER cost, } END -MF_INIT diff --git a/src/builtin/rcpt.bi b/src/builtin/rcpt.bi index bbd63fcc..9f053f77 100644 --- a/src/builtin/rcpt.bi +++ b/src/builtin/rcpt.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_DEFUN(rcpt_add, VOID, STRING addr) { struct mu_locus_range locus; @@ -44,4 +46,3 @@ MF_DEFUN(rcpt_delete, VOID, STRING addr) } END -MF_INIT diff --git a/src/builtin/sa.bi b/src/builtin/sa.bi index ca4c6165..fd3fa0b7 100644 --- a/src/builtin/sa.bi +++ b/src/builtin/sa.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include #include #include @@ -588,5 +590,3 @@ MF_DEFUN(clamav, NUMBER, NUMBER nmsg, STRING urlstr) } END -MF_INIT - diff --git a/src/builtin/sieve.bi b/src/builtin/sieve.bi index ba23f4d4..0e594a37 100644 --- a/src/builtin/sieve.bi +++ b/src/builtin/sieve.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include #include #include "msg.h" @@ -147,4 +149,3 @@ MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags, } END -MF_INIT diff --git a/src/builtin/snarf.m4 b/src/builtin/snarf.m4 index bafd12c4..2a32b02a 100644 --- a/src/builtin/snarf.m4 +++ b/src/builtin/snarf.m4 @@ -27,7 +27,7 @@ m4_changecom(/*,*/) m4_define([<__mf_dataseg>]) /* The MF_DSEXP attribute indicates that the MF_DEFUN that follows it - * can cause dataseg expansion + * can cause dataseg expansion. */ m4_define([],[],[])>]) @@ -37,7 +37,7 @@ m4_define([],[],[])>]) * The intent is to warn the programmer that the function in question can * result in dataseg being expanded. The warning is suppressed by MF_DSEXP * attribute (for MF_DEFUNs) or by the use of MF_DSEXP_SUPPRESS macro (for - * C functions). + * C functions). */ m4_define([<__MF_DSEXP_REQ>],[],[],[],[< m4_define([<$1>],[<__MF_DSEXP_REQ() [<$1>]([<$2>])>])>]) -/* MF_DSEXP_SUPPRESS(NAME, DEFN) - Suppresses dataseg expansion warnings - * within DEFN and redeclares NAME to produce a warning if used in a - * context which is not safe for dataseg expansion. +/* MF_DSEXP_SUPPRESS(NAME, DEFN) + * ----------------------------- + * Suppresses dataseg expansion warnings within DEFN and redeclares NAME to + * produce a warning if used in a context which is not safe for dataseg + * expansion. */ m4_define([],[],[]) $2 m4_popdef([<__mf_dataseg>]) __mf_define_fun([<$1>])>]) -/* MF_MODULE_NAME() - Returns the name of the current module. +/* MF_MODULE_NAME() + * ---------------- + * Expand to the name of this module. */ -m4_define([],[]) +m4_pushdef([]) -/* MF_SOURCE_DEBUG_NAME(MODULE) - Return the "debug" name for the MODULE. +/* MF_BUILTIN_MODULE([NAME]) + * ------------------------- + * Start MFL built-in module text. Optional NAME is the name of the module. + * If not supplied, the name is defined as the base name of the module file. + */ +m4_define([],m4_dnl +[],m4_dnl +m4_ifelse([<$1>],,[],[<$1>]))>])m4_dnl + +/* MF_SOURCE_DEBUG_NAME(MODULE) + * ---------------------------- + * Expand to the "debug" name for the MODULE. */ m4_define([],[],[])>]) -/* MF_MODULE_IDX() - Returns BUILTIN_IDX_ constant for the current module. +/* MF_MODULE_IDX() + * --------------- + * Expand to the BUILTIN_IDX_ constant for the current module. */ m4_define([],[]MF_MODULE_NAME()>]) -/* __mf_argtype(arg) -- return Mailfromd value type code corresponding to - * ARG: +/* __mf_argtype(arg) + * ----------------- + * Expand to Mailfromd value type code corresponding to ARG: + * * __mf_argtype(STRING) => dtype_string * __mf_argtype(NUMBER) => dtype_number * __mf_argtype(POINTER) => dtype_pointer @@ -92,15 +111,19 @@ m4_define([<__mf_argtype>],m4_dnl $1,POINTER,dtype_pointer,m4_dnl dtype_unspecified)>]) -/* mf_argtype(TYPE NAME) -- return Mailfromd value type code corresponding to +/* mf_argtype(TYPE NAME) + * --------------------- + * Expand to the Mailfromd value type code corresponding to * TYPE. See __mf_argtype above. */ m4_define([],m4_dnl [<__mf_argtype(m4_patsubst([<$1>],[<[ \t].*>],))>]) -/* mf_typelist(arglist) -- convert ARGLIST into a list of corresponding - * Mailfromd value type codes. e.g.: - * mf_typelist(STRING a, NUMBER b) => dtype_string, dtype_number +/* mf_typelist(ARGLIST) + * -------------------- + * Convert ARGLIST into a list of corresponding Mailfromd value type codes. + * E.g.: + * mf_typelist(STRING a, NUMBER b) => dtype_string, dtype_number */ m4_define([],m4_dnl [], m4_dnl, @@ -108,43 +131,51 @@ $1, [], [], []m4_dnl [])>]) -/* __mf_has_optarg(ARGS..) -- return 1 if ARGS contain OPTIONAL keyword, and - * 0 otherwise +/* __mf_has_optarg(ARGS...) + * ------------------------ + * Expand to 1 if ARGS contain OPTIONAL keyword, and to 0 otherwise */ m4_define([<__mf_has_optarg>],m4_dnl [], 1,[])>]) -/* __mf_c_type(TYPE) -- return a C type corresponding to the Mailfromd one +/* __mf_c_type(TYPE) + * ----------------- + * Expand to a C type corresponding to the Mailfromd TYPE */ m4_define([<__mf_c_type>],m4_dnl []) -/* __mf_c_getarg(TYPE) -- return a get_(.*)_arg function for the given MFL - * TYPE +/* __mf_c_getarg(TYPE) + * ------------------- + * Expand to the get_(.*)_arg function call for the given MFL TYPE */ m4_define([<__mf_c_getarg>],m4_dnl []) -/* mf_c_argdcl(TYPE NAME) -- translate Mailfromd declaration "TYPE NAME" - * into the corresponding C one: +/* mf_c_argdcl(TYPE NAME) + * ---------------------- + * Translate MFL declaration "TYPE NAME" to the corresponding C one: * * mf_c_argdcl(STRING str) => char *str */ m4_define([],m4_dnl [],[<\(\w+\)\W+\(\w+\)>],[<__mf_c_type(\1)>] \2)>]) -/* mf_c_arginit(TYPE NAME, NUM) -- translate Mailfromd declaration "TYPE NAME" - * into the corresponding C initialization: +/* mf_c_arginit(TYPE NAME, NUM) + * ---------------------------- + * Translate MFL declaration "TYPE NAME" to the corresponding C initialization: * - * mf_c_argdcl(STRING str) => get_string_arg(env, NUM, &str) + * mf_c_arginit(STRING str, NUM) => get_string_arg(env, NUM, &str) */ m4_define([],m4_dnl [],[<\(\w+\)\W+\(\w+\)>],[<__mf_c_getarg(\1)(env, $2, &\2)>])>]) -/* __mf_c_argdcl_list(NARG, LIST) -- translate Mailfromd declaration list - * into a set of corresponding C variable declarations. +/* __mf_c_argdcl_list(NARG, LIST) + * ------------------------------ + * Translate MFL declaration list to a set of corresponding C variable + * declarations. * For more details, see mf_c_arglist below. */ m4_define([<__mf_c_argdcl_list>],m4_dnl @@ -153,8 +184,10 @@ __mf_c_argdcl_list($1, m4_shift(m4_shift($@)))>], [])>]) -/* __mf_c_arginit_list(NARG, LIST) -- translate Mailfromd declaration list - * into a set of corresponding C variable initializations. +/* __mf_c_arginit_list(NARG, LIST) + * ------------------------------- + * Translate MFL declaration list to a set of corresponding C variable + * initializations. * For more details, see mf_c_arglist below. */ m4_define([<__mf_c_arginit_list>],m4_dnl @@ -163,8 +196,10 @@ __mf_c_arginit_list($1, m4_shift(m4_shift($@)))>], [])>]) -/* __mf_c_arglist(NARG, LIST) -- translate Mailfromd declaration list - * into a set of corresponding C variable declarations and initializations. +/* __mf_c_arglist(NARG, LIST) + * -------------------------- + * Translate MFL declaration list to a set of corresponding C variable + * declarations and initializations. * Arguments: * NARG -- ordinal number of the first variable in LIST * LIST -- comma-separated list of Mailfromd declarations @@ -172,8 +207,10 @@ __mf_c_arginit_list($1, m4_shift(m4_shift($@)))>], m4_define([<__mf_c_arglist>],[<__mf_c_argdcl_list($@) __mf_c_arginit_list($@)>]) -/* mf_c_arglist(LIST) -- translate Mailfromd declaration list - * into a set of corresponding C variable declarations with initializations. +/* mf_c_arglist(LIST) + * ------------------ + * Translate MFL declaration list to a set of corresponding C variable + * declarations with initializations. * Insert an instruction to adjust the stack parameters after obtaining the * variables. * E.g.: @@ -205,96 +242,118 @@ m4_ifelse(__ARG1__,0,,[]) m4_popdef([<__ARG1__>])m4_dnl >]) -/* __mf_printf_type(TYPE) -- translate the Mailfromd data type TYPE into the - * printf metacharacter useful to output it. +/* __mf_printf_type(TYPE) + * ---------------------- + * Translate the MFL data type TYPE to the printf conversion specification + * suitable for outputting it. */ m4_define([<__mf_printf_type>],m4_dnl []) -/* mf_printf_macro(TYPE NAME) -- translate TYPE to the printf metacharacter - * for use in *printf functions. +/* mf_printf_macro(TYPE NAME) + * -------------------------- + * Translate TYPE to the printf conversion */ m4_define([],m4_dnl [<%[<>]m4_regexp([<$1>],[<\(\w+\)\W+.*>],[<__mf_printf_type(\1)>])>]) -/* mf_printf_list(LIST) -- convert the list of Mailfromd variable declarations - * to a space-separated list of printf macros to print them: - * mf_printf_list(STRING a, NUMBER b) => %s %lu - */ +/* mf_printf_list(LIST) + * -------------------- + * Convert the list of MFL variable declarations to a space-delimited + * list of printf conversion specifications: + * mf_printf_list(STRING a, NUMBER b) => %s %lu + * Notice, that the expansion begins with the space character. + */ m4_define([],m4_dnl [],m4_dnl [],m4_dnl [< mf_printf_macro($1)[<>]mf_printf_list(m4_shift($@))>])>]) -/* __mf_argname(TYPE NAME) -- return NAME - */ +/* __mf_argname(TYPE NAME) + * ----------------------- + * Expand to NAME + */ m4_define([<__mf_argname>],m4_dnl [],\1)>]) -/* mf_argnames(LIST) -- extract names from the Mailfromd declaration list: +/* mf_argnames(LIST) + * ----------------- + * Extract names from the Mailfromd declaration list: * mf_argnames(STRING a, NUMBER b) => a, b - */ + */ m4_define([],m4_dnl [],m4_dnl $1,[],[],m4_dnl [<__mf_argname($1), mf_argnames(m4_shift($@))>])>]) -/* __mf_defined_argname(TYPE NAME) -- Same as __mf_argname, but wrap the - * argument into MF_OPTVAL if necessary - */ +/* __mf_defined_argname(OPT, TYPE NAME) + * ------------------------------------ + * Same as __mf_argname, but wrap the argument into MF_OPTVAL if OPT is 1. + */ m4_define([<__mf_defined_argname>],m4_dnl [],"",0))>],m4_dnl [<__mf_argname($2)>])>]) -/* __mf_defined_argnames(LIST) -- Same as __mf_argnames, but arguments after - * the OPTIONAL keywords are protected by MF_OPTVAL - */ +/* __mf_defined_argnames(OPT, LIST) + * -------------------------------- + * Same as mf_argnames, if OPT is 0. + * Otherwise, if OPT is 1, expands to list of MF_OPTVAL constructs with + * consecutive parameter names as arguments. + * After encountering the OPTIONAL keyword, changes OPT to 1. + */ m4_define([<__mf_defined_argnames>],m4_dnl [],m4_dnl $2,[],[<__mf_defined_argnames(1,m4_shift(m4_shift($@)))>],m4_dnl [<__mf_defined_argname($1,$2), m4_dnl __mf_defined_argnames($1,m4_shift(m4_shift($@)))>])>]) -/* mf_defined_argnames(LIST) -- Same as mf_argnames, but arguments after - * the OPTIONAL keywords are protected by MF_OPTVAL - */ +/* mf_defined_argnames(LIST) + * ------------------------- + * Same as mf_argnames, but arguments after the OPTIONAL keywords are + * protected by MF_OPTVAL + */ m4_define([],m4_dnl [<__mf_defined_argnames(0,$@)>]) -/* __mf_argpos(POS,NEEDLE,STACK...) - Return position at which NEEDLE occurs in - * STACK +/* __mf_argpos(POS,NEEDLE,STACK...) + * -------------------------------- + * Expands to position at which NEEDLE occurs in STACK * Arguments: * POS - Current position * NEEDLE - String to find * STACK - Argument list * Example: * __mf_argpos(0, x, a, b, x) => 2 - */ + */ m4_define([<__mf_argpos>],m4_dnl []$2[< )>],[<__mf_argpos(m4_incr($1), $2, m4_shift(m4_shift(m4_shift($@))))>])>]) -/* mf_argpos(ARG, TYPE1 ARG1, TYPE2 ARG2 ...) - Return (zero-based) position - * of ARG in the argument list: +/* mf_argpos(ARG, TYPE1 ARG1, TYPE2 ARG2 ...) + * ------------------------------------------ + * Expand to the (zero-based) position of ARG in the argument list: * * mf_argpos(x, STRING a, NUMBER b, OPTIONAL, STRING x) => 3 */ m4_define([],m4_dnl [<__mf_argpos(0, $1, mf_argnames(m4_shift($@)))>]) -/* __mf_defined(NAME, ARGS...) -- Scan ARGS... for the definition - * of the built-in function parameter NAME, and return a C conditional - * expression that yields true if it is defined. +/* __mf_defined(NAME, ARGS...) + * --------------------------- + * Scan ARGS... for the definition of the built-in function parameter NAME, + * and expand to a C conditional expression that yields true if it is defined. * ARGS are parameter declarations in the form: * TYPE NAME - */ + */ m4_define([<__mf_defined>], [ mf_argpos($1,__MF_ARGLIST__)>])>]) -/* MF_DEFINED(NAME) -- Return a C conditional expression - * that yields true if the parameter NAME is defined. +/* MF_DEFINED(NAME) + * ---------------- + * Expand to a C conditional expression that yields true if the parameter + * NAME is defined. * * __MF_ARGLIST__ => STRING a, NUMBER b, OPTIONAL, STRING x * MF_DEFINED(x) => (__bi_argcnt > 2) @@ -307,18 +366,22 @@ m4_define([], [])>])>]) -/* MF_OPTVAL(NAME[, DEFVAL]) -- If the parameter NAME is defined, return - * its value, otherwise return DEFVAL or 0 - */ +/* MF_OPTVAL(NAME[, DEFVAL]) + * ------------------------- + * If the parameter NAME is defined, expand to its value, otherwise expand + * to DEFVAL or 0 + */ m4_define([], [],m4_dnl [<(MF_DEFINED($1) ? $1 : m4_ifelse([<$2>],,0,$2))>],m4_dnl [])>])>]) -/* __mf_check_end() -- signal error if the previous MF_DEFUN statement was - * not properly closed with END - */ +/* __mf_check_end() + * ---------------- + * Signal error if the previous MF_DEFUN statement was not properly closed + * with END + */ m4_define([<__mf_check_end>],m4_dnl [],m4_dnl []__MF_FUNCTION__[<' was not closed @@ -326,9 +389,11 @@ m4_define([<__mf_check_end>],m4_dnl m4_popdef([<__MF_FUNCTION__>]) m4_define([<__mf_error_code>],1)>])>]) -/* MF_STATE(state) - Declare next MF_DEFUN as valid only in the given state. +/* MF_STATE(state) + * --------------- + * Declare next MF_DEFUN as valid only in the given state. * The state argument is any valid milter state, as declared in - * enum smtp_state (see mailfromd.h around line 74--87), but withouth the + * enum smtp_state (see mailfromd.h around line 74--87), but without the * `smtp_state_' prefix. * * Multiple occurrences of MF_STATE accumulate. @@ -338,17 +403,21 @@ m4_define([], [],__MF_STATE__[< | STATMASK(smtp_state_$1)>])>],m4_dnl [],[])>])>]) -/* MF_CAPTURE([str]) - Declare next MF_DEFUN as requiring message capturing. - The form with the STR argument can be used only in MF_STATE(eom) - functions (FIXME: this should be enforced at compile time). In that - case a reference to the capture stream is stored in STR. +/* MF_CAPTURE([str]) + * ----------------- + * Declare next MF_DEFUN as requiring message capturing. + * The form with the STR argument can be used only in MF_STATE(eom) + * functions (FIXME: this should be enforced at compile time). In that + * case a reference to the capture stream is stored in STR. */ m4_define([],m4_dnl [],1)m4_dnl m4_ifelse([<$1>],,,[],[<$1>])>])>]) -/* env_get_stream - prohibit the use of the library function of the same name. - */ +/* env_get_stream() + * ---------------- + * Prohibit the use of the library function of the same name. + */ m4_define([],m4_dnl [],m4_dnl [],m4_dnl @@ -357,12 +426,16 @@ m4_define([],m4_dnl m4_define([<__mf_error_code>],1)>],[<[]($@)>])>],m4_dnl [])>]) -/* mf_optcount(ARGS...) -- Return the number of optional arguments in ARGS - */ +/* mf_optcount(ARGS...) + * -------------------- + * Return the number of optional arguments in ARGS + */ m4_define([],[],m4_eval($# - 1),[])>]) -/* __mf_argcount(COUNT, ARGS...) -- Auxiliary function for mf_argcount +/* __mf_argcount(COUNT, ARGS...) + * ----------------------------- + * Auxiliary function for mf_argcount * COUNT is number of arguments counted so far * ARGS are the rest of the arguments */ @@ -370,21 +443,38 @@ m4_define([<__mf_argcount>],[],[<__mf_argcount($1, m4_shift(m4_shift($@)))>],m4_dnl [<__mf_argcount(m4_incr($1), m4_shift(m4_shift($@)))>])>]) -/* mf_argcount(ARGS...) -- Return the number of arguments in ARGS, not - * counting eventual OPTIONAL modifier. - */ +/* mf_argcount(ARGS...) + * -------------------- + * Return the number of arguments in ARGS, not counting eventual OPTIONAL + * modifier. + * FIXME: same as m4_eval($# - __mf_has_optarg($@)) + */ m4_define([],[]) -/* mf_prog_trace(fname[, args...]) - */ +/* mf_prog_trace(FNAME[, ARGS...]) + * ------------------------------- + * Expand to the prog_trace call for function FNAME with arguments ARGS. + */ m4_define([],[]mf_printf_list(m4_shift($@))"m4_dnl m4_ifelse($2,,,[<,mf_defined_argnames(m4_shift($@))>]));>]) -/* __mf_defun(VARARG, NAME, RETTYPE, ARGS...) -- Begin a built-in function - declaration - */ +/* __mf_defun(VARARG, NAME, RETTYPE, ARGS...) + * ------------------------------------------ + * Begin a built-in function declaration. + * Arguments: + * VARARG + * Initial value for the FLAGS argument to the va_builtin_install_ex + * function. Actually, MFD_BUILTIN_VARIADIC if NAME is a variadic + * function, and 0 otherwise. + * NAME + * Name of the function. + * RETTYPE + * Return type (STRING or NUMBER). + * ARGS + * List of arguments with types. + */ m4_define([<__mf_defun>],m4_dnl [<__mf_check_end[<>]m4_dnl void @@ -417,6 +507,17 @@ m4_define([<__MF_ENV_GET_STREAM_PROHIBIT>])m4_dnl mf_prog_trace($2,m4_shift(m4_shift(m4_shift($@)))); >]) +/* MF_DEFUN(NAME, RETTYPE, ARGS...) + * -------------------------------- + * Start a declaration of the built-in function NAME. The declaration + * must be terminated with END. + * Arguments: + * NAME - function name + * RETTYPE - return type + * ARGS - list of argument declarations, each one of the form + * TYPE ARGNAME; special argument OPTIONAL begins the list of + * optional parameters. + */ m4_define([],[], 0)m4_dnl __mf_defun(0, $@)>]) @@ -428,21 +529,40 @@ m4_ifelse(__mf_has_optarg(m4_shift(m4_shift(m4_shift(m4_shift($@))))),0,m4_dnl ) m4_define([<__mf_error_code>],1)>])>]) +/* MF_DEFUN_VARARGS(NAME, RETTYPE. [TYPE PARAM...]) + * ------------------------------------------------ + * Start the declaration of the built-in variadic function NAME. + * The declarationl must be terminated with END. + * Arguments: + * NAME - function name + * RETTYPE - return type + * TYPE PARAM - declarations of mandatory parameters. + * Actual parameters can be retrieved using MF_VA_ARG(), which see, + * See also MF_VA_START and MF_VA_END + */ m4_define([],[<__mf_defun_varargs(MFD_BUILTIN_VARIADIC,$@)>]) +/* MF_DEFUN_VARARGS_NO_PROM(NAME, RETTYPE, [TYPE PARAM...]) + * -------------------------------------------------------- + * Same as MF_DEFUN_VARARGS, but actual parameters are not promoted to + * STRING. + */ m4_define([],[]) -/* Prevent the use of the return statement in defuns. - */ +/* Prevent the use of the `return' statement in defuns. + */ m4_define([],[],[] ) m4_define([<__mf_error_code>],1)>],[<[]>])>]) -/* MF_RETURN(value[,type]) - Return a value - */ +/* MF_RETURN(VALUE[,TYPE]) + * ----------------------- + * Expand to C code for returning VALUE from the current function. If TYPE + * is supplied, cast value to this type. + */ m4_define([],[< m4_ifdef([<__MF_VA_START_USED__>],[] used before [] @@ -462,28 +582,36 @@ m4_popdef([<__type>])m4_dnl m4_define([<__MF_ENDLAB__>])m4_dnl } while (0)>])>]) -/* MF_ALLOC_HEAP(off, len) - Allocate LEN bytes from the heap - */ +/* MF_ALLOC_HEAP(OFF, LEN) + * ----------------------- + * Allocate LEN bytes from the heap. Return the offset of the allocated + * space in OFF. + */ m4_define([],[] = heap_reserve(env, $2)))>]) -/* MF_ALLOC_HEAP_TEMP(len) - Temporarly allocate LEN bytes from the heap. - */ +/* MF_ALLOC_HEAP_TEMP(LEN) + * ----------------------- + * Temporarly allocate LEN bytes from the heap. + */ m4_define([],[<__MF_DSEXP_REQ()m4_dnl mf_c_val(heap_tempspace(env, $1), ptr)>]) -/* MF_COPY_STRING(off, string) - Copy STRING to the heap. Return the - * pointer to the copy. - */ +/* MF_COPY_STRING(off, string) + * --------------------------- + * Copy STRING to the heap. Return the pointer to the copy. + */ m4_define([],[]) -/* MF_OBSTACK_BEGIN() - Begin temporary space manipulations +/* MF_OBSTACK_BEGIN() + * ------------------ + * Begin temporary space manipulations. * NOTE: No other heap manipulation function can be used between * MF_OBSTACK_BEGIN and MF_OBSTACK_CANCEL/MF_RETURN_OBSTACK/MF_OBSTACK_FINISH - */ + */ m4_define([],[]) m4_define([],[],[]) -/* MF_OBSTACK_CANCEL - Cancel temporary heap allocation initiated by - * MF_OBSTACK_BEGIN - */ +/* MF_OBSTACK_CANCEL() + * ------------------- + * Cancel temporary heap allocation initiated by MF_OBSTACK_BEGIN + */ m4_define([],[]) -/* MF_OBSTACK_BASE - Return a C pointer to the beginning of the currently +/* MF_OBSTACK_BASE() + * ----------------- + * Return a C pointer to the beginning of the currently * allocated obstack space. - */ + */ m4_define([],[]) -/* MF_RETURN_OBSTACK() - Relocate and return temporary space - */ +/* MF_RETURN_OBSTACK() + * ------------------- + * Relocate and return temporary space + */ m4_define([],[])>]) -/* MF_OBSTACK_FINISH() - Relocate temporary space and return its starting - offset. -*/ +/* MF_OBSTACK_FINISH() + * ------------------- + * Relocate temporary space and return its starting offset. + */ m4_define([],[]) -/* MF_VA_START() -- Begin a code section for handing varying number - of arguments. */ +/* MF_VA_START() + * ------------- + * Begin a code section for handling variable number of arguments. + */ m4_define([],[< m4_ifelse(__MF_VARARGS__,1,[],m4___file__:m4___line__)m4_dnl @@ -525,7 +661,10 @@ unroll_stack(env, __bi_argcnt + 1)>], )m4_dnl m4_define([<__mf_error_code>],1)>])>]) -/* MF_VA_END() -- End a section, started with MF_VA_START */ +/* MF_VA_END() + * ----------- + * End the section started with MF_VA_START + */ m4_define([],[],[])m4_dnl @@ -534,21 +673,29 @@ adjust_stack(env, __bi_argcnt + 1)>],m4_dnl ) m4_define([<__mf_error_code>],1)>])>]) -/* __mf_va_count() -- return number of variable arguments passed to the current - vararg function */ +/* __mf_va_count() + * --------------- + * Return number of variable arguments passed to the current vararg function + */ m4_define([<__mf_va_count>],[]) -/* MF_VA_COUNT() -- return actual number of variable arguments passed to the - function. Bail out if the function is not a vararg one. */ +/* MF_VA_COUNT() + * ------------- + * Return actual number of variable arguments passed to the + * function. Bail out if the function is not a vararg one. + */ m4_define([],[], [] used but `__MF_FUNCTION__' does not take variable number of arguments )m4_dnl m4_define([<__mf_error_code>],1)>])>]) -/* MF_VA_ARG(N, TYPE, VAR) -- Produce a code for assigning to VAR the Nth - argument of the given TYPE in a vararg section. */ +/* MF_VA_ARG(N, TYPE, VAR) + * ----------------------- + * Produce a code for assigning to VAR the Nth + * argument of the given TYPE in a vararg section. + */ m4_define([],[],m4_dnl [],[<($1+mf_argcount(__MF_ARGLIST__))>]) @@ -561,8 +708,11 @@ m4_popdef([<__ARGN__>])>], ) m4_define([<__mf_error_code>],1)>])>]) -/* MF_VAR(name,type[,flag]) - Declare a global variable NAME of type TYPE. - */ +/* MF_VAR(NAME,TYPE[,FLAG]) + * ------------------------ + * Declare a global variable NAME of type TYPE. FLAGS are additional flags + * (SYM_VOLATILE is always used). + */ m4_define([],[]) -/* MF_VAR_REF(name, type[, value]) - Reference global variable NAME - * In two-argument form, return its value. In three-arguments form, assign +/* MF_VAR_REF(NAME, TYPE[, VALUE]) + * ------------------------------- + * Reference the global variable NAME. + * In two-argument form, expand to its value. In three-arguments form, assign * the VALUE to it. - */ + */ m4_define([],[]) m4_define([],[]) -/* MF_VAR_SET_STRING(name, value) - Set variable NAME to the string VALUE */ +/* MF_VAR_SET_STRING(NAME, VALUE) + * ------------------------------ + * Set variable NAME to the string VALUE + */ m4_define([],[< { size_t __off; const char *__s = $2; @@ -592,18 +747,23 @@ m4_define([],[< MF_VAR_REF($1, size, __off); } >]) -/* MF_VAR_INC(name) - Increment the value of the global variable NAME - */ +/* MF_VAR_INC(NAME) + * ---------------- + * Increment the value of the global variable NAME + */ m4_define([],[]) -/* MF_DECLARE_DATA(name, init [, destr, freecap]) - Declare private data for - * the current module. +/* MF_DECLARE_DATA(NAME, INIT [, DESTR, FREECAP]) + * ---------------------------------------------- + * Declare private data for the current module. + * The data can be accessed using MF_GET_DATA (see below). + * Arguments: * NAME - data identifier. * INIT - initialization function (void init(void)) * DESTR - destructor function (void destr(void*)) * FREECAP - free capture function (void freecap(void*)) - */ + */ m4_define([],[< m4_define([<__MF_PRIV_ID__>],$1_id) static int __MF_PRIV_ID__; @@ -614,9 +774,10 @@ m4_ifelse($4,,NULL,$4)); m4_divert(2)m4_dnl >]) -/* MF_GET_DATA - Return pointer to the private data, declared with - * MF_DECLARE_DATA - */ +/* MF_GET_DATA + * ----------- + * Return pointer to the private data, declared with MF_DECLARE_DATA + */ m4_define([],[],[],m4_dnl @@ -625,12 +786,18 @@ env_get_builtin_priv(m4_ifelse($1,,env,$1),__MF_PRIV_ID__)>],m4_dnl m4_define([<__mf_error_code>],1) >])>]) -/* MF_VASTRING(off) - */ +/* MF_VASTRING(OFF) + * ---------------- + * Extract string from VAPTR array at offset OFF. + */ m4_define([],[]) -/* MF_THROW(exception, ...) - */ +/* MF_THROW(EXCODE, ...) + * ------------------------ + * Throw exception. First argument (EXCODE) is the exception code. + * Rest of arguments supply additional parameters for the env_throw_bi + * call. + */ m4_define([],[],[< @@ -640,19 +807,26 @@ m4_ifdef([<__MF_CAPTURE__>],[< "__MF_FUNCTION__", NULL), m4_shift($@)) )>]) +/* MF_STREAM_TO_MESSAGE(STR) + * ------------------------- + * Convert mailutils stream STR to a message. + */ m4_define([],[],m4_dnl "__MF_FUNCTION__", NULL))>]) -/* MF_ASSERT(cond, exception, ...) - */ +/* MF_ASSERT(COND, EXCEPTION, ...) + * ------------------------------- + * Throw EXCEPTION unless condition COND is true. Additional arguments + * are passed to MF_THROW. + */ m4_define([],[]) /* END -- Finish the built-in function declaration, created with MF_DEFUN - */ + */ m4_define([],m4_dnl [],[]) m4_ifdef([<__MF_CAPTURE__>],[< @@ -679,23 +853,52 @@ m4_define([<__mf_dataseg>])m4_dnl return; }>]) -/* MF_DCL_CLEANUP(ptr[, func]) */ +/* MF_DCL_CLEANUP(PTR[, FUNC]) + * --------------------------- + * Register clean-up function FUNC for data pointer PTR. FUNC(PTR) will + * be called if an exception is thrown or MF_CLEANUP(PTR) is explicitly + * used. If neither of these occurs, it will be called upon destroying + * the evaluation environment. + * Registration can be undone using MF_CLR_CLEANUP. + */ m4_define([],[]) -/* MF_CLR_CLEANUP(ptr) */ +/* MF_CLR_CLEANUP(PTR) + * ------------------- + * Undo registration of the clean-up routine for PTR. + */ m4_define([],[]) -/* MF_CLEANUP(ptr) */ +/* MF_CLEANUP(PTR) + * --------------- + * Invoke a previously registered clean-up routine for pointer PTR. + */ m4_define([],[]) m4_define([],[<_MFL_>]) -/* MF_TRANS(NAME) - expands to a struct builtin_const_trans for - translating constant NAME between MFL and C */ +/* MF_TRANS(NAME) + * -------------- + * Expands to a struct builtin_const_trans for translating constant NAME + * between MFL and C. + * See syslog.bi for an example of its use. + */ m4_define([],[<{ MF_TRANS_PREFIX[<>]$1, $1 }>]) -/* MF_PRAGMA(name,min,max) - */ +/* MF_PRAGMA(NAME, MIN, MAX) + * ------------------------- + * Register a pragma NAME. + * Arguments: + * NAME - name of the new pragma + * MIN - minimum number of arguments (including pragma name) + * MAX - maximum number of arguments (or 0, if unlimited). + * + * The macro must be followed by a C block with the code for handling + * the pragma. The code can access the following three parameters: + * int argc - number of actual arguments in argv array; + * char **argv - NULL terminated array of actual arguments; + * text - actual pragma text, with built-in constants expanded; + */ m4_define([],m4_dnl [],[<_pragma_>]m4_translit($1,-,_)) @@ -705,11 +908,20 @@ m4_divert(2) m4_popdef([])m4_dnl >]) +/* MF_COND(SYM) + * ------------ + * Protect the code below by the `#ifdef SYM' / `#endif' + */ m4_define([],[],$1)m4_dnl #ifdef __MF_COND_SYMBOL >]) +/* MF_DEBUG(LEV, (ARGS...)) + * ------------------------ + * Expand to a mu_debug call with the debug handle for this built-in + * module and LEV, (ARGS...) as arguments. + */ m4_define([],[< m4_ifdef([<__MF_DEBUG>],,[],1)m4_dnl @@ -718,14 +930,24 @@ static mu_debug_handle_t debug_handle; m4_divert(2)>]) [](debug_handle, $@)>])>]) -/* MF_INIT(CODE) -- create the initialization function for the curent module. - * The function will be named MODNAME_init_builtin. - */ +m4_pushdef([<__MF_INIT_SEQUENCE>]) + +/* MF_INIT(CODE) + * ------------- + * Insert CODE into the initialization function for the + * curent module (MODNAME_init_builtin). + */ m4_define([],m4_dnl -[<__mf_check_end[<>]m4_dnl + [],[<$1>])>]) + +/* Expand to the generated text upon the end of input. + */ +m4_m4wrap([< +m4_ifelse(MF_MODULE_NAME,,[]) +m4_m4exit(1)>]) m4_undefine([<__MF_PRIV_ID__>])m4_dnl -m4_define([<__MF_INIT__>],1)m4_dnl -m4_ifdef([<__MF_COND_SYMBOL>],[<#endif /* __MF_COND_SYMBOL */ +m4_ifdef([<__MF_COND_SYMBOL>],[<#endif /[<>]* __MF_COND_SYMBOL */ >]) void MF_MODULE_NAME()_init_builtin() @@ -737,8 +959,9 @@ m4_ifdef([<__MF_COND_SYMBOL>],[<#ifdef __MF_COND_SYMBOL pp_define("__MF_COND_SYMBOL"); >])m4_dnl m4_undivert(1) - $1 -m4_ifdef([<__MF_COND_SYMBOL>],[<#endif /* __MF_COND_SYMBOL */ + __MF_INIT_SEQUENCE +m4_popdef([<__MF_INIT_SEQUENCE>])m4_dnl +m4_ifdef([<__MF_COND_SYMBOL>],[<#endif /[<>]* __MF_COND_SYMBOL */ m4_popdef([<__MF_COND_SYMBOL>])>])m4_dnl } m4_divert(0)m4_dnl @@ -756,13 +979,8 @@ m4_divert(0)m4_dnl m4_undivert(3) m4_undivert(2) +m4_popdef([])m4_dnl >]) -m4_m4wrap([<__mf_check_end -m4_ifdef([<__MF_INIT__>],,[] not defined -) -m4_define([<__mf_error_code>],1)>]) -m4_ifdef([<__mf_error_code>],[])>]) - m4_divert(2) -m4_dnl End of snarf.m4 +/* End of snarf.m4 */ diff --git a/src/builtin/spf.bi b/src/builtin/spf.bi index ea57f2fa..698469cb 100644 --- a/src/builtin/spf.bi +++ b/src/builtin/spf.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "spf.h" MF_VAR(spf_explanation, STRING); @@ -83,4 +85,3 @@ MF_DEFUN(spf_test_record, NUMBER, STRING record, } END -MF_INIT diff --git a/src/builtin/sprintf.bi b/src/builtin/sprintf.bi index f08cf4d8..6e2cdd88 100644 --- a/src/builtin/sprintf.bi +++ b/src/builtin/sprintf.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #define FMT_ALTPOS 0x01 #define FMT_ALTERNATE 0x02 #define FMT_PADZERO 0x04 @@ -417,4 +419,3 @@ MF_DEFUN_VARARGS_NO_PROM(sprintf, STRING, STRING format) } END -MF_INIT diff --git a/src/builtin/string.bi b/src/builtin/string.bi index ffb4a1c1..4422b3ad 100644 --- a/src/builtin/string.bi +++ b/src/builtin/string.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + MF_DEFUN(toupper, STRING, STRING string) { size_t off; @@ -283,4 +285,3 @@ MF_DEFUN(rtrim, STRING, STRING input, OPTIONAL, STRING cset) } END -MF_INIT diff --git a/src/builtin/syslog.bi b/src/builtin/syslog.bi index 3abfcb0b..65c78882 100644 --- a/src/builtin/syslog.bi +++ b/src/builtin/syslog.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "syslog.h" #include "mflib/syslog.h" @@ -67,4 +69,3 @@ MF_DEFUN(syslog, VOID, NUMBER priority, STRING text) } END -MF_INIT diff --git a/src/builtin/system.bi b/src/builtin/system.bi index 796e1247..64abca44 100644 --- a/src/builtin/system.bi +++ b/src/builtin/system.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include #include @@ -158,4 +160,3 @@ MF_DEFUN(unlink, VOID, STRING name) } END -MF_INIT diff --git a/src/builtin/vars.bi b/src/builtin/vars.bi index 7e583917..975bed75 100644 --- a/src/builtin/vars.bi +++ b/src/builtin/vars.bi @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +MF_BUILTIN_MODULE + #include "filenames.h" /* For DEFAULT_FROM_ADDRESS */ MF_VAR(rcpt_count, NUMBER); MF_VAR(milter_client_family, NUMBER, SYM_PRECIOUS); @@ -113,4 +115,3 @@ set_milter_server_id(eval_environ_t env, const char *id) } >]) -MF_INIT -- cgit v1.2.1