[exim-cvs] Add predefined macros for expansions

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] Add predefined macros for expansions
Gitweb: https://git.exim.org/exim.git/commitdiff/fc37f2acaaa440c5265dc01fd693d8f5406f5cf9
Commit:     fc37f2acaaa440c5265dc01fd693d8f5406f5cf9
Parent:     340e5f5781abb5388c41fa326d6e1cabf7ba96ff
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Tue Nov 29 15:55:05 2022 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Tue Nov 29 16:03:48 2022 +0000


    Add predefined macros for expansions
---
 doc/doc-txt/NewStuff   |  4 +++
 src/OS/Makefile-Base   |  7 +++--
 src/src/expand.c       | 77 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/src/macro_predef.c |  1 +
 src/src/macro_predef.h |  1 +
 5 files changed, 87 insertions(+), 3 deletions(-)


diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index d9a9f6cda..4a912268b 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -13,6 +13,10 @@ Version 4.97

2. An event on a failing SMTP AUTH, for both client and server operations.

+ 3. Variable $sender_helo_verified with the result of an ACL "verify = helo".
+
+ 4. Predefined macros for expansion items, operators, conditions and variables.
+
Version 4.96
------------

diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base
index 4e1f61a26..a290b90b0 100644
--- a/src/OS/Makefile-Base
+++ b/src/OS/Makefile-Base
@@ -111,8 +111,8 @@ MACRO_HSRC = macro_predef.h os.h globals.h config.h macros.h \
     routers/redirect.h


 OBJ_MACRO = macro_predef.o \
-    macro-globals.o macro-readconf.o macro-route.o macro-transport.o macro-drtables.o \
-    macro-acl.o macro-tls.o \
+    macro-globals.o macro-readconf.o macro-expand.o macro-route.o \
+    macro-transport.o macro-drtables.o macro-acl.o macro-tls.o \
     macro-appendfile.o macro-autoreply.o macro-lmtp.o macro-pipe.o macro-queuefile.o \
     macro-smtp.o macro-accept.o macro-dnslookup.o macro-ipliteral.o macro-iplookup.o \
     macro-manualroute.o macro-queryprogram.o macro-redirect.o \
@@ -131,6 +131,9 @@ macro-globals.o :    globals.c
 macro-readconf.o :    readconf.c
     @echo "$(CC) -DMACRO_PREDEF readconf.c"
     $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ readconf.c
+macro-expand.o :    expand.c
+    @echo "$(CC) -DMACRO_PREDEF expand.c"
+    $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ expand.c
 macro-route.o :        route.c
     @echo "$(CC) -DMACRO_PREDEF route.c"
     $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ route.c
diff --git a/src/src/expand.c b/src/src/expand.c
index 657cf3cb9..6def3c102 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -13,6 +13,10 @@


#include "exim.h"

+#ifdef MACRO_PREDEF
+# include "macro_predef.h"
+#endif
+
 typedef unsigned esi_flags;
 #define ESI_NOFLAGS        0
 #define ESI_BRACE_ENDS        BIT(0)    /* expansion should stop at } */
@@ -831,6 +835,76 @@ static var_entry var_table[] = {
 };


 static int var_table_size = nelem(var_table);
+
+#ifdef MACRO_PREDEF
+
+/* dummies */
+uschar * fn_arc_domains(void) {return NULL;}
+uschar * fn_hdrs_added(void) {return NULL;}
+uschar * fn_queue_size(void) {return NULL;}
+uschar * fn_recipients(void) {return NULL;}
+uschar * sender_helo_verified_boolstr(void) {return NULL;}
+uschar * smtp_cmd_hist(void) {return NULL;}
+
+
+
+static void
+expansion_items(void)
+{
+uschar buf[64];
+for (int i = 0; i < nelem(item_table); i++)
+  {
+  spf(buf, sizeof(buf), CUS"_EXP_ITEM_%T", item_table[i]);
+  builtin_macro_create(buf);
+  }
+}
+static void
+expansion_operators(void)
+{
+uschar buf[64];
+for (int i = 0; i < nelem(op_table_underscore); i++)
+  {
+  spf(buf, sizeof(buf), CUS"_EXP_OP_%T", op_table_underscore[i]);
+  builtin_macro_create(buf);
+  }
+for (int i = 0; i < nelem(op_table_main); i++)
+  {
+  spf(buf, sizeof(buf), CUS"_EXP_OP_%T", op_table_main[i]);
+  builtin_macro_create(buf);
+  }
+}
+static void
+expansion_conditions(void)
+{
+uschar buf[64];
+for (int i = 0; i < nelem(cond_table); i++)
+  {
+  spf(buf, sizeof(buf), CUS"_EXP_COND_%T", cond_table[i]);
+  builtin_macro_create(buf);
+  }
+}
+static void
+expansion_variables(void)
+{
+uschar buf[64];
+for (int i = 0; i < nelem(var_table); i++)
+  {
+  spf(buf, sizeof(buf), CUS"_EXP_VAR_%T", var_table[i].name);
+  builtin_macro_create(buf);
+  }
+}
+
+void
+expansions(void)
+{
+expansion_items();
+expansion_operators();
+expansion_conditions();
+expansion_variables();
+}
+
+#else    /*!MACRO_PREDEF*/
+
 static uschar var_buffer[256];
 static BOOL malformed_header;


@@ -8861,8 +8935,9 @@ search_tidyup();
return 0;
}

-#endif
+#endif    /*STAND_ALONE*/


+#endif    /*!MACRO_PREDEF*/
 /* vi: aw ai sw=2
 */
 /* End of expand.c */
diff --git a/src/src/macro_predef.c b/src/src/macro_predef.c
index 618c914dc..0053cb245 100644
--- a/src/src/macro_predef.c
+++ b/src/src/macro_predef.c
@@ -338,6 +338,7 @@ printf("#include \"exim.h\"\n");
 features();
 exp_features();
 options();
+expansions();
 params();


printf("macro_item * macros = &p%d;\n", mp_index-1);
diff --git a/src/src/macro_predef.h b/src/src/macro_predef.h
index 8b7b375c6..94f68dfa3 100644
--- a/src/src/macro_predef.h
+++ b/src/src/macro_predef.h
@@ -22,6 +22,7 @@ extern void options_routers(void);
extern void options_transports(void);
extern void options_auths(void);
extern void options_logging(void);
+extern void expansions(void);
extern void params_dkim(void);
#ifndef DISABLE_TLS
extern void options_tls(void);