summaryrefslogtreecommitdiffstats
path: root/contrib/dma/aliases_parse.y
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2014-02-21 07:26:49 +0000
committerbapt <bapt@FreeBSD.org>2014-02-21 07:26:49 +0000
commit44c7fbcbb3b7c13b5be4cf327f496c5f7e93fee2 (patch)
tree50c8cd4c6b55c353a3f982a5f9f8c8590d1ba5ec /contrib/dma/aliases_parse.y
parent3e0732cf3e211d62b325cfd4d0dfc2e43c6b249a (diff)
parentd38539d80511f5f603eb076cdc91cbdb5d69e1b4 (diff)
downloadFreeBSD-src-44c7fbcbb3b7c13b5be4cf327f496c5f7e93fee2.zip
FreeBSD-src-44c7fbcbb3b7c13b5be4cf327f496c5f7e93fee2.tar.gz
Import Dragonfly Mail Agent into base system
It is a small and lightweight Mail Transport Agent. It accepts mails from locally installed Mail User Agents (MUA) and delivers the mails either locally or to a remote destination. Remote delivery includes several features like TLS/SSL support, SMTP authentication and NULLCLIENT. Make dma conditional to new WITHOUT_DMA option and make it respect WITHOUT_MAIL Reviewed by: peter Discussed with: emaste, bz, peter
Diffstat (limited to 'contrib/dma/aliases_parse.y')
-rw-r--r--contrib/dma/aliases_parse.y112
1 files changed, 112 insertions, 0 deletions
diff --git a/contrib/dma/aliases_parse.y b/contrib/dma/aliases_parse.y
new file mode 100644
index 0000000..a5a9e7b
--- /dev/null
+++ b/contrib/dma/aliases_parse.y
@@ -0,0 +1,112 @@
+%{
+
+#include <err.h>
+#include <string.h>
+#include <syslog.h>
+#include "dma.h"
+
+extern int yylineno;
+static void yyerror(const char *);
+int yywrap(void);
+int yylex(void);
+
+static void
+yyerror(const char *msg)
+{
+ /**
+ * Because we do error '\n' below, we need to report the error
+ * one line above of what yylineno points to.
+ */
+ syslog(LOG_CRIT, "aliases line %d: %s", yylineno - 1, msg);
+ fprintf(stderr, "aliases line %d: %s\n", yylineno - 1, msg);
+}
+
+int
+yywrap(void)
+{
+ return (1);
+}
+
+%}
+
+%union {
+ char *ident;
+ struct stritem *strit;
+ struct alias *alias;
+}
+
+%token <ident> T_IDENT
+%token T_ERROR
+%token T_EOF 0
+
+%type <strit> dests
+%type <alias> alias aliases
+
+%%
+
+start : aliases T_EOF
+ {
+ LIST_FIRST(&aliases) = $1;
+ }
+
+aliases : /* EMPTY */
+ {
+ $$ = NULL;
+ }
+ | alias aliases
+ {
+ if ($2 != NULL && $1 != NULL)
+ LIST_INSERT_AFTER($2, $1, next);
+ else if ($2 == NULL)
+ $2 = $1;
+ $$ = $2;
+ }
+ ;
+
+alias : T_IDENT ':' dests '\n'
+ {
+ struct alias *al;
+
+ if ($1 == NULL)
+ YYABORT;
+ al = calloc(1, sizeof(*al));
+ if (al == NULL)
+ YYABORT;
+ al->alias = $1;
+ SLIST_FIRST(&al->dests) = $3;
+ $$ = al;
+ }
+ | error '\n'
+ {
+ YYABORT;
+ }
+ ;
+
+dests : T_IDENT
+ {
+ struct stritem *it;
+
+ if ($1 == NULL)
+ YYABORT;
+ it = calloc(1, sizeof(*it));
+ if (it == NULL)
+ YYABORT;
+ it->str = $1;
+ $$ = it;
+ }
+ | T_IDENT ',' dests
+ {
+ struct stritem *it;
+
+ if ($1 == NULL)
+ YYABORT;
+ it = calloc(1, sizeof(*it));
+ if (it == NULL)
+ YYABORT;
+ it->str = $1;
+ SLIST_NEXT(it, next) = $3;
+ $$ = it;
+ }
+ ;
+
+%%
OpenPOWER on IntegriCloud