Skip to content

Commit

Permalink
mailcap_path -> slist
Browse files Browse the repository at this point in the history
Convert `$mailcap_path` to use the new DT_SLIST type (string list).
  • Loading branch information
flatcap committed Jun 12, 2019
1 parent 33e0fff commit ac36fd4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ WHERE char *C_IndexFormat; ///< Config: printf-like format str
WHERE char *C_ImapUser; ///< Config: (imap) Username for the IMAP server
#endif
WHERE char *C_Mbox; ///< Config: Folder that receives read emails (see Move)
WHERE char *C_MailcapPath; ///< Config: Colon-separated list of mailcap files
WHERE struct Slist *C_MailcapPath; ///< Config: Colon-separated list of mailcap files
WHERE char *C_Folder; ///< Config: Base folder for a set of mailboxes
#ifdef USE_HCACHE
WHERE char *C_HeaderCache; ///< Config: (hcache) Directory/file for the header cache database
Expand Down
2 changes: 1 addition & 1 deletion init.h
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ struct ConfigDef MuttVars[] = {
** When $$mail_check_stats is \fIset\fP, this variable configures
** how often (in seconds) NeoMutt will update message counts.
*/
{ "mailcap_path", DT_STRING, &C_MailcapPath, IP "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap" },
{ "mailcap_path", DT_SLIST|SLIST_SEP_COLON, &C_MailcapPath, IP "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap" },
/*
** .pp
** This variable specifies which files to consult when attempting to
Expand Down
28 changes: 9 additions & 19 deletions rfc1524.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,42 +468,32 @@ void rfc1524_free_entry(struct Rfc1524MailcapEntry **entry)
bool rfc1524_mailcap_lookup(struct Body *a, char *type,
struct Rfc1524MailcapEntry *entry, enum MailcapLookup opt)
{
char path[PATH_MAX];
int found = false;
char *curr = C_MailcapPath;

/* rfc1524 specifies that a path of mailcap files should be searched.
* joy. They say
* $HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap, etc
* and overridden by the MAILCAPS environment variable, and, just to be nice,
* we'll make it specifiable in .neomuttrc */
if (!curr || !*curr)
if (!C_MailcapPath || (C_MailcapPath->count == 0))
{
mutt_error(_("No mailcap path specified"));
return false;
}

mutt_check_lookup_list(a, type, 128);

while (!found && *curr)
{
int x = 0;
while (*curr && (*curr != ':') && (x < sizeof(path) - 1))
{
path[x++] = *curr;
curr++;
}
if (*curr)
curr++;

if (x == 0)
continue;
char path[PATH_MAX];
bool found = false;

path[x] = '\0';
struct ListNode *np = NULL;
STAILQ_FOREACH(np, &C_MailcapPath->head, entries)
{
mutt_str_strfcpy(path, np->data, sizeof(path));
mutt_expand_path(path, sizeof(path));

mutt_debug(LL_DEBUG2, "Checking mailcap file: %s\n", path);
found = rfc1524_mailcap_parse(a, path, type, entry, opt);
if (found)
break;
}

if (entry && !found)
Expand Down

0 comments on commit ac36fd4

Please sign in to comment.