summaryrefslogtreecommitdiff
path: root/parser.y
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@users.sourceforge.net>2003-07-03 17:37:11 +0000
committerJosé Fonseca <jrfonseca@users.sourceforge.net>2003-07-03 17:37:11 +0000
commit2867d16bc9bae9764904efbf44cd5131fca1bc9b (patch)
tree1e910b1566a40e9b02961bf5aed2958b9fa7b974 /parser.y
parent2b266bab3687c078061c7b8bf3676ef3a61d53a7 (diff)
Modularization of the code.
Hability to get the recipients from the message headers. Local delivery via a MDA.
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y43
1 files changed, 21 insertions, 22 deletions
diff --git a/parser.y b/parser.y
index aebdd75..f142e75 100644
--- a/parser.y
+++ b/parser.y
@@ -1,11 +1,11 @@
%{
-/*
- * parser.y -- parser for the rcfile
+/**
+ * \file parser.y
+ * Parser for the rcfile.
+ *
+ * \author Adapted from fetchmail's rcfile_y.y by José Fonseca
*/
-/*
- * Adapted from fetchmail's rcfile_y.y by José Fonseca
- */
#include <errno.h>
#include <stdio.h>
@@ -14,7 +14,10 @@
#include <libesmtp.h>
-#include "esmtp.h"
+#include "main.h"
+#include "smtp.h"
+#include "local.h"
+
/* parser reads these */
char *rcfile = NULL; /* path name of dot file */
@@ -22,7 +25,7 @@ char *rcfile = NULL; /* path name of dot file */
/* parser sets these */
int yydebug; /* in case we didn't generate with -- debug */
-static identity_t *identity = &default_identity;
+static identity_t *identity = NULL;
/* using Bison, this arranges that yydebug messages will show actual tokens */
extern char * yytext;
@@ -36,7 +39,7 @@ void yyerror (const char *s);
char *sval;
}
-%token IDENTITY HOSTNAME USERNAME PASSWORD STARTTLS CERTIFICATE_PASSPHRASE
+%token IDENTITY HOSTNAME USERNAME PASSWORD STARTTLS CERTIFICATE_PASSPHRASE MDA
%token MAP
@@ -64,17 +67,9 @@ map : /* empty */
identity : IDENTITY map STRING
{
- identity_list_t *item;
-
- item = malloc(sizeof(identity_list_t));
- memset(item, 0, sizeof(identity_list_t));
-
- *identities_tail = item;
- identities_tail = &item->next;
- identity = &item->identity;
-
- identity->identity = strdup($3);
- identity->starttls = Starttls_DISABLED;
+ identity = identity_new();
+ identity_add(identity);
+ identity->address = strdup($3);
}
;
@@ -90,6 +85,7 @@ statement : HOSTNAME map STRING { identity->host = strdup($3); }
| STARTTLS map ENABLED { identity->starttls = Starttls_ENABLED; }
| STARTTLS map REQUIRED { identity->starttls = Starttls_REQUIRED; }
| CERTIFICATE_PASSPHRASE map STRING { identity->certificate_passphrase = strdup($3); }
+ | MDA map STRING { mda = strdup($3); }
;
%%
@@ -102,8 +98,9 @@ extern FILE *yyin;
void yyerror (const char *s)
/* report a syntax error */
{
- fprintf(stderr, "%s:%d: %s at %s\n", rcfile, lineno, s,
- (yytext && yytext[0]) ? yytext : "end of input");
+ fprintf(stderr, "%s:%d: %s at %s\n", rcfile, lineno, s,
+ (yytext && yytext[0]) ? yytext : "end of input");
+ exit(EX_CONFIG);
}
#define RCFILE ".esmtprc"
@@ -126,7 +123,9 @@ void parse_rcfile (void)
strcat(rcfile, "/");
strcat(rcfile, RCFILE);
}
-
+
+ identity = default_identity;
+
/* Open the configuration file and feed it to the lexer. */
if (!(yyin = fopen(rcfile, "r")))
{