From c3ee26badace01bfa1ca8bb78337512d29323b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 18 Feb 2004 10:57:19 +0000 Subject: Fail when no configuration file is found. Fix typo in the lexer. Fix compiler warning. --- TODO | 5 +++-- local.c | 1 - parser.y | 38 +++++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/TODO b/TODO index 19a390a..b0a2a8e 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,8 @@ To do * Include simple scripts to queue emails for dial-up connections. - * In conjunction with "preconnect", a "postconnect" configuration option - would be a good idea (example: tear down a SSH tunnel). + * In order to facilitate translation, it would be a good idea to run + debconf-gettextize (from the po-debconf package). See the documentation + that comes with po-debconf. Don't forget to update Build-depends. diff --git a/local.c b/local.c index 98878fa..f7a51c6 100644 --- a/local.c +++ b/local.c @@ -43,7 +43,6 @@ static void sanitize(char *s) */ void local_init(message_t *message) { - struct idlist *idp; int length = 0, fromlen = 0, nameslen = 0; char *names = NULL, *before, *after, *from = NULL; diff --git a/parser.y b/parser.y index 145fd18..e122193 100644 --- a/parser.y +++ b/parser.y @@ -19,6 +19,8 @@ #include "local.h" #include "xmalloc.h" +extern int yylex (void); + /** Path name of dot file */ static const char *rcfile = NULL; @@ -101,7 +103,7 @@ statement : HOSTNAME map STRING { identity->host = xstrdup($3); SET_DEFAULT_IDEN | STARTTLS map REQUIRED { identity->starttls = Starttls_REQUIRED; SET_DEFAULT_IDENTITY; } | CERTIFICATE_PASSPHRASE map STRING { identity->certificate_passphrase = xstrdup($3); SET_DEFAULT_IDENTITY; } | PRECONNECT map STRING { identity->preconnect = xstrdup($3); SET_DEFAULT_IDENTITY; } - | PRECONNECT map STRING { identity->postconnect = xstrdup($3); SET_DEFAULT_IDENTITY; } + | POSTCONNECT map STRING { identity->postconnect = xstrdup($3); SET_DEFAULT_IDENTITY; } | MDA map STRING { mda = xstrdup($3); } | DEFAULT { default_identity = identity; } ; @@ -129,15 +131,15 @@ void yyerror (const char *s) void rcfile_parse(const char *_rcfile) { - char *temp = NULL; + char *dot_rcfile = NULL; if(_rcfile) { /* Configuration file specified on the command line */ - if(!(yyin = fopen(_rcfile, "r"))) + rcfile = _rcfile; + if(!(yyin = fopen(rcfile, "r"))) goto failure; - rcfile = _rcfile; goto success; } @@ -149,14 +151,15 @@ void rcfile_parse(const char *_rcfile) if (!(home = getenv("HOME"))) break; - temp = xmalloc(strlen(home) + strlen(DOT_RCFILE) + 2); + dot_rcfile = xmalloc(strlen(home) + strlen(DOT_RCFILE) + 2); - strcpy(temp, home); - if (temp[strlen(temp) - 1] != '/') - strcat(temp, "/"); - strcat(temp, DOT_RCFILE); + strcpy(dot_rcfile, home); + if (dot_rcfile[strlen(dot_rcfile) - 1] != '/') + strcat(dot_rcfile, "/"); + strcat(dot_rcfile, DOT_RCFILE); - if(!(yyin = fopen(temp, "r"))) + rcfile = dot_rcfile; + if(!(yyin = fopen(rcfile, "r"))) { if(errno == ENOENT) break; @@ -164,14 +167,15 @@ void rcfile_parse(const char *_rcfile) goto failure; } - rcfile = temp; goto success; } while(0); /* Search for the global configuration file */ - do { - if(!(yyin = fopen(ETC_RCFILE, "r"))) + do + { + rcfile = ETC_RCFILE; + if(!(yyin = fopen(rcfile, "r"))) { if(errno == ENOENT) break; @@ -179,13 +183,13 @@ void rcfile_parse(const char *_rcfile) goto failure; } - rcfile = ETC_RCFILE; goto success; } while(0); /* No configuration file found */ - return; + fprintf(stderr, "No configuration file found at %s or " ETC_RCFILE "\n", dot_rcfile); + exit(EX_CONFIG); success: /* Configuration file opened */ @@ -200,8 +204,8 @@ success: fclose(yyin); /* not checking this should be safe, file mode was r */ rcfile = NULL; - if(temp) - free(temp); + if(dot_rcfile) + free(dot_rcfile); return; -- cgit v1.2.3