#include "mutt.h"
#include "mapping.h"
#include "mutt_curses.h"
+#include "mutt_menu.h"
#include "mutt_regex.h"
#include "history.h"
#include "keymap.h"
snprintf (err->data, err->dsize, \
_("Not available in this menu.")); \
return (-1); \
- } else
+ }
typedef struct myvar
{
static const char* myvar_get (const char* var);
static void myvar_del (const char* var);
-void toggle_quadoption (int opt)
+static void toggle_quadoption (int opt)
{
int n = opt/4;
int b = (opt % 4) * 2;
/* given the variable ``s'', return the index into the rc_vars array which
matches, or -1 if the variable is not found. */
-int mutt_option_index (char *s)
+static int mutt_option_index (char *s)
{
int i;
} while (pc && *pc != '`');
if (!pc)
{
- dprint (1, (debugfile, "mutt_get_token: mismatched backtics\n"));
+ dprint (1, (debugfile, "mutt_get_token: mismatched backticks\n"));
return (-1);
}
cmd = mutt_substrdup (tok->dptr, pc);
/* Find the last item in the list that data points to. */
lastp = NULL;
- dprint(5, (debugfile, "parse_attach_list: ldata = %08x, *ldata = %08x\n",
- (unsigned int)ldata, (unsigned int)*ldata));
+ dprint(5, (debugfile, "parse_attach_list: ldata = %p, *ldata = %p\n",
+ (void *)ldata, (void *)*ldata));
for (listp = *ldata; listp; listp = listp->next)
{
a = (ATTACH_MATCH *)listp->data;
{
if (CurrentMenu == MENU_ALIAS)
{
- for (tmp = Aliases; tmp ; tmp = tmp->next)
+ for (tmp = Aliases; tmp ; tmp = tmp->next)
tmp->del = 1;
set_option (OPTFORCEREDRAWINDEX);
}
}
else
{
+ mutt_alias_delete_reverse (tmp);
/* override the previous value */
rfc822_free_address (&tmp->addr);
if (CurrentMenu == MENU_ALIAS)
}
mutt_extract_token (buf, s, M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON);
- dprint (2, (debugfile, "parse_alias: Second token is '%s'.\n",
+ dprint (3, (debugfile, "parse_alias: Second token is '%s'.\n",
buf->data));
tmp->addr = mutt_parse_adrlist (tmp->addr, buf->data);
}
mutt_group_context_add_adrlist (gc, tmp->addr);
-
+ mutt_alias_add_reverse (tmp);
#ifdef DEBUG
if (debuglevel >= 2)
for (a = tmp->addr; a && a->mailbox; a = a->next)
{
if (!a->group)
- dprint (2, (debugfile, "parse_alias: %s\n",
+ dprint (3, (debugfile, "parse_alias: %s\n",
a->mailbox));
else
- dprint (2, (debugfile, "parse_alias: Group %s\n",
+ dprint (3, (debugfile, "parse_alias: Group %s\n",
a->mailbox));
}
}
*p = 0;
}
+static int check_charset (struct option_t *opt, const char *val)
+{
+ char *p, *q = NULL, *s = safe_strdup (val);
+ int rc = 0, strict = strcmp (opt->option, "send_charset") == 0;
+
+ for (p = strtok_r (s, ":", &q); p; p = strtok_r (NULL, ":", &q))
+ {
+ if (!*p)
+ continue;
+ if (mutt_check_charset (p, strict) < 0)
+ {
+ rc = -1;
+ break;
+ }
+ }
+
+ FREE(&s);
+ return rc;
+}
+
static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
{
int query, unset, inv, reset, r = 0;
}
else if (query || *s->dptr != '=')
{
- char _tmp[STRING];
+ char _tmp[LONG_STRING];
const char *val = NULL;
if (myvar)
{
_tmp[0] = '\0';
strfcpy (_tmp, NONULL(*((char **) MuttVars[idx].data)), sizeof (_tmp));
- mutt_pretty_mailbox (_tmp);
+ mutt_pretty_mailbox (_tmp, sizeof (_tmp));
val = _tmp;
}
else
myvar = safe_strdup (myvar);
myvar_del (myvar);
}
- else if (DTYPE (MuttVars[idx].type) == DT_ADDR)
- rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
- else
- /* MuttVars[idx].data is already 'char**' (or some 'void**') or...
- * so cast to 'void*' is okay */
- FREE ((void *) MuttVars[idx].data); /* __FREE_CHECKED__ */
mutt_extract_token (tmp, s, 0);
+
if (myvar)
{
myvar_set (myvar, tmp->data);
}
else if (DTYPE (MuttVars[idx].type) == DT_PATH)
{
+ /* MuttVars[idx].data is already 'char**' (or some 'void**') or...
+ * so cast to 'void*' is okay */
+ FREE ((void *) MuttVars[idx].data); /* __FREE_CHECKED__ */
+
strfcpy (scratch, tmp->data, sizeof (scratch));
mutt_expand_path (scratch, sizeof (scratch));
*((char **) MuttVars[idx].data) = safe_strdup (scratch);
}
else if (DTYPE (MuttVars[idx].type) == DT_STR)
{
+ if (strstr (MuttVars[idx].option, "charset") &&
+ check_charset (&MuttVars[idx], tmp->data) < 0)
+ {
+ snprintf (err->data, err->dsize, _("Invalid value for option %s: \"%s\""),
+ MuttVars[idx].option, tmp->data);
+ return (-1);
+ }
+
+ FREE ((void *) MuttVars[idx].data); /* __FREE_CHECKED__ */
*((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
if (mutt_strcmp (MuttVars[idx].option, "charset") == 0)
mutt_set_charset (Charset);
}
else
{
+ rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
*((ADDRESS **) MuttVars[idx].data) = rfc822_parse_adrlist (NULL, tmp->data);
}
}
else
*ptr = -*ptr;
}
+#ifdef USE_IMAP
+ else if (mutt_strcmp (MuttVars[idx].option, "imap_pipeline_depth") == 0)
+ {
+ if (*ptr < 0)
+ *ptr = 0;
+ }
+#endif
}
else if (DTYPE (MuttVars[idx].type) == DT_QUAD)
{
int i, r = -1;
BUFFER expn;
+ if (!line || !*line)
+ return 0;
+
memset (&expn, 0, sizeof (expn));
expn.data = expn.dptr = line;
expn.dsize = mutt_strlen (line);
#define NUMCOMMANDS (sizeof (Commands)/sizeof (Commands[0]))
/* initial string that starts completion. No telling how much crap
* the user has typed so far. Allocate LONG_STRING just to be sure! */
-char User_typed [LONG_STRING] = {0};
+static char User_typed [LONG_STRING] = {0};
-int Num_matched = 0; /* Number of matches for completion */
-char Completed [STRING] = {0}; /* completed string (command or variable) */
-const char **Matches;
+static int Num_matched = 0; /* Number of matches for completion */
+static char Completed [STRING] = {0}; /* completed string (command or variable) */
+static const char **Matches;
/* this is a lie until mutt_init runs: */
-int Matches_listsize = MAX(NUMVARS,NUMCOMMANDS) + 10;
+static int Matches_listsize = MAX(NUMVARS,NUMCOMMANDS) + 10;
static void matches_ensure_morespace(int current)
{
{
strfcpy (tmp, NONULL (*((char **) MuttVars[idx].data)), sizeof (tmp));
if (DTYPE (MuttVars[idx].type) == DT_PATH)
- mutt_pretty_mailbox (tmp);
+ mutt_pretty_mailbox (tmp, sizeof (tmp));
}
else if (DTYPE (MuttVars[idx].type) == DT_ADDR)
{
{
LIST *p;
- char errbuff[STRING];
+ char errbuff[LONG_STRING];
char command[STRING];
BUFFER err, token;
{
int i;
- char errbuff[STRING];
+ char errbuff[LONG_STRING];
char command[STRING];
BUFFER err, token;
err.dsize = sizeof (error);
Groups = hash_create (1031);
+ ReverseAlias = hash_create (1031);
+ mutt_menu_init ();
+
/*
* XXX - use something even more difficult to predict?
*/