From: Pierre Habouzit Date: Mon, 13 Nov 2006 01:30:25 +0000 (+0100) Subject: move some global settings into alias.c where it belongs. X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=0d52617ab7fc6b2d78b5835ad5230edaf5aafa4f move some global settings into alias.c where it belongs. Signed-off-by: Pierre Habouzit --- diff --git a/alias.c b/alias.c index e03536b..8128587 100644 --- a/alias.c +++ b/alias.c @@ -47,10 +47,14 @@ #include #include -#include "mutt.h" #include "mutt_idna.h" #include "sort.h" +char *AliasFmt; +char *AliasFile; +alias_t *Aliases; +rx_t GecosMask; + #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x static struct mapping_t AliasHelp[] = { @@ -62,12 +66,13 @@ static struct mapping_t AliasHelp[] = { {NULL, OP_NULL} }; -const address_t *alias_lookup(const alias_t *list, const char *s) +const address_t *alias_lookup(const char *s) { - while (list) { + alias_t *list; + + for (list = Aliases; list; list = list->next) { if (!m_strcasecmp(s, list->name)) return list->addr; - list = list->next; } return NULL; @@ -75,12 +80,14 @@ const address_t *alias_lookup(const alias_t *list, const char *s) /* This routine looks to see if the user has an alias defined for the given address. */ -const address_t *alias_reverse_lookup(const alias_t *list, const address_t *a) +const address_t *alias_reverse_lookup(const address_t *a) { + alias_t *list; + if (!a || !a->mailbox) return NULL; - for (; list; list = list->next) { + for (list = Aliases; list; list = list->next) { address_t *ap; /* cycle through all addresses if this is a group alias */ @@ -225,7 +232,7 @@ void mutt_create_alias(ENVELOPE *cur, address_t *iadr) return; /* check to see if the user already has an alias defined */ - if (alias_lookup(Aliases, buf)) { + if (alias_lookup(buf)) { mutt_error _("You already have an alias defined with that name!"); return; } @@ -319,7 +326,7 @@ static address_t *mutt_expand_aliases_r(address_t *a, string_list_t **expn) if (!pop->group && !pop->personal && pop->mailbox && !strchr(pop->mailbox, '@')) { - const address_t *t = alias_lookup(Aliases, pop->mailbox); + const address_t *t = alias_lookup(pop->mailbox); if (t) { string_list_t *u; @@ -673,5 +680,4 @@ new_aliases: mutt_menuDestroy (&menu); p_delete(&AliasTable); - } diff --git a/alias.h b/alias.h index 80ba447..e5d081c 100644 --- a/alias.h +++ b/alias.h @@ -39,17 +39,21 @@ typedef struct alias_t { short num; } alias_t; +extern char *AliasFmt; +extern char *AliasFile; +extern alias_t *Aliases; +extern rx_t GecosMask; + DO_INIT(alias_t, alias); static inline void alias_wipe(alias_t *a) { address_list_wipe(&a->addr); } - DO_NEW(alias_t, alias); DO_DELETE(alias_t, alias); DO_SLIST(alias_t, alias, alias_delete); -const address_t *alias_lookup(const alias_t *list, const char *s); -const address_t *alias_reverse_lookup(const alias_t *list, const address_t *); +const address_t *alias_lookup(const char *s); +const address_t *alias_reverse_lookup(const address_t *); int mutt_addr_is_user(address_t *); address_t *mutt_get_address(ENVELOPE *, const char **); diff --git a/globals.h b/globals.h index 3f3a45c..6fc4da3 100644 --- a/globals.h +++ b/globals.h @@ -32,8 +32,6 @@ WHERE char *MuttDotlock; WHERE address_t *EnvFrom; WHERE address_t *From; -WHERE char *AliasFile; -WHERE char *AliasFmt; WHERE char *AssumedCharset; WHERE char *AttachSep; WHERE char *Attribution; @@ -87,7 +85,6 @@ WHERE rx_t Mask; WHERE rx_t QuoteRegexp; WHERE rx_t ReplyRegexp; WHERE rx_t Smileys; -WHERE rx_t GecosMask; WHERE rx_t StripWasRegexp; WHERE char *Preconnect INITVAL (NULL); @@ -249,7 +246,6 @@ WHERE SIG_ATOMIC_VOLATILE_T SigWinch INITVAL (0); WHERE int CurrentMenu; -WHERE alias_t *Aliases INITVAL (0); WHERE string_list_t *UserHeader INITVAL (0); /*-- formerly in pgp.h --*/ diff --git a/main.c b/main.c index beade2d..e3a0b83 100644 --- a/main.c +++ b/main.c @@ -721,7 +721,7 @@ int main (int argc, char **argv) address_t *a; for (; alias_queries; alias_queries = alias_queries->next) { - if ((a = alias_lookup(Aliases, alias_queries->data))) { + if ((a = alias_lookup(alias_queries->data))) { /* output in machine-readable form */ mutt_addrlist_to_idna (a, NULL); mutt_write_address_list (a, stdout, 0, 0); diff --git a/muttlib.c b/muttlib.c index 00d0e90..d07c643 100644 --- a/muttlib.c +++ b/muttlib.c @@ -322,7 +322,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) HEADER *h; address_t *alias; - if ((alias = alias_lookup(Aliases, s + 1))) { + if ((alias = alias_lookup(s + 1))) { h = header_new(); h->env = envelope_new(); h->env->from = h->env->to = alias; diff --git a/pattern.c b/pattern.c index 868d7ab..c4eb3c4 100644 --- a/pattern.c +++ b/pattern.c @@ -1112,7 +1112,7 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, */ return (h->env && h->env->from && (mutt_addr_is_user(h->env->from) - || alias_reverse_lookup(Aliases, h->env->from) + || alias_reverse_lookup(h->env->from) || (h->env->from->personal && valid_realname(h->env-> from->personal) && h->env->from->mailbox) diff --git a/sort.c b/sort.c index 38e9d87..028630b 100644 --- a/sort.c +++ b/sort.c @@ -94,7 +94,7 @@ const char *mutt_get_name (address_t * a) const char *name = ""; if (a) { - if (option (OPTREVALIAS) && (ali = alias_reverse_lookup(Aliases, a)) + if (option (OPTREVALIAS) && (ali = alias_reverse_lookup(a)) && ali->personal) name = ali->personal; else if (a->personal)