#include "mutt_ssl.h"
#endif
+#if defined (USE_LIBESMTP) && (defined (USE_SSL) || defined (USE_GNUTLS))
+#include "mutt_libesmtp.h"
+#endif
+
#include "mx.h"
#include "init.h"
} syn_t;
/* for synonym warning reports: list of synonyms found */
-list2_t* Synonyms;
+static list2_t* Synonyms;
/* for synonym warning reports: current rc file */
-char* CurRCFile = NULL;
+static const char* CurRCFile = NULL;
/* for synonym warning reports: current rc line */
-int CurRCLine = 0;
+static int CurRCLine = 0;
+
+/* prototypes for checking for special vars */
+static int check_dsn_return (const char*);
+static int check_dsn_notify (const char*);
+
+static struct {
+ const char* name;
+ int (*check) (const char*);
+} SpecialVars[] = {
+ { "dsn_notify", check_dsn_notify },
+ { "dsn_return", check_dsn_return },
+#if defined (USE_LIBESMTP) && (defined (USE_SSL) || defined (USE_GNUTLS))
+ { "smtp_use_tls", mutt_libesmtp_check_usetls },
+#endif
+ /* last */
+ { NULL, NULL }
+};
/* for synonym warning reports: adds synonym to end of list */
static void syn_add (int n, int o) {
set_option (OPTREDRAWTREE);
}
+/* check whether value for $dsn_return would be valid */
+static int check_dsn_return (const char* val) {
+ if (val && *val && str_ncmp (val, "hdrs", 4) != 0 &&
+ str_ncmp (val, "full", 4) != 0)
+ return (0);
+ return (1);
+}
+
+/* check whether value for $dsn_notify would be valid */
+static int check_dsn_notify (const char* val) {
+ list2_t* list = NULL;
+ int i = 0, rc = 1;
+
+ if (!val || !*val)
+ return (1);
+ list = list_from_str (val, ",");
+ if (list_empty (list))
+ return (1);
+
+ for (i = 0; i < list->length; i++)
+ if (str_ncmp (list->data[i], "never", 5) != 0 &&
+ str_ncmp (list->data[i], "failure", 7) != 0 &&
+ str_ncmp (list->data[i], "delay", 5) != 0 &&
+ str_ncmp (list->data[i], "success", 7) != 0) {
+ rc = 0;
+ break;
+ }
+ list_del (&list, (list_del_t*) _mem_free);
+ return (rc);
+}
+
+static int check_special (const char* name, const char* val) {
+ int i = 0;
+
+ for (i = 0; SpecialVars[i].name; i++) {
+ if (str_cmp (SpecialVars[i].name, name) == 0)
+ return (SpecialVars[i].check (val));
+ }
+ return (1);
+}
+
static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
BUFFER * err)
{
*((char **) MuttVars[idx].data) = str_dup (scratch);
}
else if (DTYPE (MuttVars[idx].type) == DT_STR) {
- *((char **) MuttVars[idx].data) = str_dup (tmp->data);
- if (str_cmp (MuttVars[idx].option, "charset") == 0)
- mutt_set_charset (Charset);
+ /* see if the value may only be a certain value... */
+ if (check_special (MuttVars[idx].option, tmp->data)) {
+ *((char **) MuttVars[idx].data) = str_dup (tmp->data);
+ if (str_cmp (MuttVars[idx].option, "charset") == 0)
+ mutt_set_charset (Charset);
+ } else {
+ /* ... and abort if it fails */
+ snprintf (err->data, err->dsize, "'%s' is invalid for $%s",
+ tmp->data, MuttVars[idx].option);
+ return (-1);
+ }
}
else {
*((ADDRESS **) MuttVars[idx].data) =
pid_t pid;
debug_print (2, ("reading configuration file '%s'.\n", rcfile));
- str_replace (&CurRCFile, rcfile);
- CurRCLine = 0;
if ((f = mutt_open_read (rcfile, &pid)) == NULL) {
snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno));
memset (&token, 0, sizeof (token));
while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line)) != NULL) {
- CurRCLine++;
conv = ConfigCharset && (*ConfigCharset) && Charset;
if (conv) {
currentline = str_dup (linebuf);
else
currentline = linebuf;
+ CurRCLine = line;
+ CurRCFile = rcfile;
+
if (mutt_parse_rc_line (currentline, &token, err) == -1) {
mutt_error (_("Error in %s, line %d: %s"), rcfile, line, err->data);
if (--rc < -MAXERRS) {
if (!Muttrc) {
+#if 0
snprintf (buffer, sizeof (buffer), "%s/.muttngrc-%s", NONULL (Homedir),
MUTT_VERSION);
if (access (buffer, F_OK) == -1)
+#endif
snprintf (buffer, sizeof (buffer), "%s/.muttngrc", NONULL (Homedir));
if (access (buffer, F_OK) == -1)
+#if 0
snprintf (buffer, sizeof (buffer), "%s/.muttng/muttngrc-%s",
NONULL (Homedir), MUTT_VERSION);
if (access (buffer, F_OK) == -1)
+#endif
snprintf (buffer, sizeof (buffer), "%s/.muttng/muttngrc",
NONULL (Homedir));
MuttVars[((syn_t*) Synonyms->data[i])->n].option,
NONULL(((syn_t*) Synonyms->data[i])->f),
((syn_t*) Synonyms->data[i])->l);
- fprintf (stderr, _("Warning: Synonym variables are scheduled for removal.\n"));
+ fprintf (stderr, _("Warning: synonym variables are scheduled for removal.\n"));
list_del (&Synonyms, syn_del);
need_pause = 1;
}
- /* this is not needed during runtime */
- mem_free(&CurRCFile);
if (need_pause && !option (OPTNOCURSES)) {
if (mutt_any_key_to_continue (NULL) == -1)
snprintf (command, sizeof (command), "set ?%s\n",
((struct option_t*) tmp->data[i])->option);
if (mutt_parse_rc_line (command, &token, &err) == -1) {
- fprintf (stderr, "%s\n", err.data);
+ printf ("%s\n", err.data);
mem_free (&token.data);
list_del (&tmp, NULL);
return 1;