diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-08-02 18:09:11 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-08-02 18:09:11 +0300 |
commit | b9a6afb98df574662bbebb320ea4d24ce1448027 (patch) | |
tree | 4cbfed1916d51028680614c37ab465e4cf1b5588 | |
parent | 8ed6243a664ab6ff8adf68e39b108a81eaf424d0 (diff) | |
download | mailfromd-b9a6afb98df574662bbebb320ea4d24ce1448027.tar.gz mailfromd-b9a6afb98df574662bbebb320ea4d24ce1448027.tar.bz2 |
Register the "i" macro for use in the lowest SMTP state declared in the program.
* mfd/engine.c (first_used_state): New variable.
(mlfi_negotiate): If first_used_state is set, register "i"
macro for it.
(milter_enable_state): Set first_used_state.
* mfd/gram.y (register_macro): Remove static qualifier.
* mfd/builtin/macro.bi (mta_state_macros): New pragma.
* mfd/lex.l (paren_follows): Remove tie-in variable.
* mfd/mailfromd.h (register_macro): New proto.
(paren_follows): Remove extern.
-rw-r--r-- | mfd/builtin/macro.bi | 15 | ||||
-rw-r--r-- | mfd/engine.c | 9 | ||||
-rw-r--r-- | mfd/gram.y | 3 | ||||
-rw-r--r-- | mfd/lex.l | 4 | ||||
-rw-r--r-- | mfd/mailfromd.h | 3 |
5 files changed, 26 insertions, 8 deletions
diff --git a/mfd/builtin/macro.bi b/mfd/builtin/macro.bi index 8fca5f4e..2300005f 100644 --- a/mfd/builtin/macro.bi +++ b/mfd/builtin/macro.bi @@ -14,6 +14,21 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* #pragma mta_state_macros <handler> <name> [name...] */ +MF_PRAGMA(mta_state_macros, 4, 0) +{ + enum smtp_state state; + int i = 1; + + state = string_to_state(argv[i]); + if (state == smtp_state_none) { + parse_error(_("unknown smtp state tag: %s"), argv[i]); + return; + } + for (i++; i < argc; i++) + register_macro(state, argv[i]); +} + MF_DEFUN(getmacro, STRING, STRING name) { const char *s = env_get_macro(env, name); diff --git a/mfd/engine.c b/mfd/engine.c index 2e3fa0b1..8e539de4 100644 --- a/mfd/engine.c +++ b/mfd/engine.c @@ -785,6 +785,8 @@ child_start() return 0; } +enum smtp_state first_used_state = smtp_state_end; + sfsistat mlfi_negotiate(SMFICTX *ctx, unsigned long mta_actions, @@ -801,6 +803,10 @@ mlfi_negotiate(SMFICTX *ctx, debug4(70, "Negotiate: mta_actions=%#lx, mta_capa=%#lx, " "filter_actions=%#lx, filter_capa=%#lx", mta_actions, mta_capa, *filter_actions, *filter_capa); + + if (first_used_state > smtp_state_first + && first_used_state < smtp_state_end) + register_macro(first_used_state, "i"); for (i = 0; i < gacopyz_stage_max; i++) { char *str = get_stage_macro_string(i); @@ -868,6 +874,9 @@ milter_settimeout(time_t t) void milter_enable_state(enum smtp_state state) { + if (state < first_used_state) + first_used_state = state; + switch (state) { case smtp_state_connect: smfilter.xxfi_connect = mlfi_connect; @@ -265,7 +265,6 @@ check_builtin_usage(const struct builtin *bp) static void jump_fixup(prog_counter_t pos, prog_counter_t endpos); static NODE *create_on_node(NODE *sel, struct case_stmt *cases); -static void register_macro(enum smtp_state tag, const char *macro); #define LITERAL_TEXT(lit) ((lit) ? (lit)->text : NULL) #define LITERAL_OFF(lit) ((lit) ? (lit)->off : 0) @@ -1032,7 +1031,7 @@ retdecl : /* empty */ state_ident: T_IDENTIFIER { $$ = string_to_state($1->text); - if ($$ == smtp_state_none) + if ($$ == smtp_state_none) parse_error_locus(&@1.beg, _("unknown smtp state tag: %s"), $1->text); @@ -41,10 +41,6 @@ static int multiline_unescape; /* Unescape here-document contents */ static int (*char_to_strip)(char); /* Strip matching characters of each here-document line */ -int paren_follows = 0; /* Tie-in used by the grammar to emit deprecation - warnings about function names being used as - prefix operators. */ - static int is_tab(char c) { diff --git a/mfd/mailfromd.h b/mfd/mailfromd.h index e3adbffe..6edcf331 100644 --- a/mfd/mailfromd.h +++ b/mfd/mailfromd.h @@ -876,11 +876,10 @@ char *mf_strdup(const char *str); void regex_push(void); void regex_pop(void); +void register_macro(enum smtp_state tag, const char *macro); char *get_stage_macro_string(enum gacopyz_stage i); struct exmask *exmask_create(void); -extern int paren_follows; - /* Data types and declarations for handling compiled configuration code */ |