X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=init.c;h=775cb213b64b06adc0224f0d989f14347e1e3e11;hp=3d17e76124348a70fd84a4be4dcadf1634a158fe;hb=11a177822f648694f442b3038fdc60a4e50e6edb;hpb=16534e98723674fa391e3fc29d2a07ce419c13dd diff --git a/init.c b/init.c index 3d17e76..775cb21 100644 --- a/init.c +++ b/init.c @@ -11,7 +11,6 @@ */ #include -#include #include #include @@ -558,52 +557,6 @@ add_to_rx_list(rx_t **list, const char *s, int flags, BUFFER *err) return 0; } -static int add_to_spam_list(rx_t **list, const char *pat, - const char *templ, BUFFER * err) -{ - rx_t *rx; - - if (m_strisempty(pat) || !templ) - return 0; - - if (!(rx = rx_compile (pat, REG_ICASE))) { - snprintf (err->data, err->dsize, _("Bad regexp: %s"), pat); - return -1; - } - - /* check to make sure the item is not already on this list */ - while (*list) { - if (!ascii_strcasecmp(rx->pattern, (*list)->pattern)) { - rx_t *tmp = rx_list_pop(list); - rx_delete(&tmp); - } else { - list = &(*list)->next; - } - } - - *list = rx; - rx_set_template(rx, templ); - return 0; -} - -static int remove_from_spam_list (rx_t ** list, const char *pat) -{ - int nremoved = 0; - - while (*list) { - if (!m_strcmp((*list)->pattern, pat)) { - rx_t *spam = rx_list_pop(list); - rx_delete(&spam); - nremoved++; - } else { - list = &(*list)->next; - } - } - - return nremoved; -} - - static void remove_from_list(string_list_t **l, const char *str) { if (!m_strcmp("*", str)) { @@ -723,74 +676,6 @@ static int parse_unalternates (BUFFER * buf, BUFFER * s, return 0; } -static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data, - BUFFER * err) -{ - BUFFER templ; - - p_clear(&templ, 1); - - /* Insist on at least one parameter */ - if (!MoreArgs (s)) { - if (data == M_SPAM) - m_strcpy(err->data, err->dsize, _("spam: no matching pattern")); - else - m_strcpy(err->data, err->dsize, _("nospam: no matching pattern")); - return -1; - } - - /* Extract the first token, a regexp */ - mutt_extract_token (buf, s, 0); - - /* data should be either M_SPAM or M_NOSPAM. M_SPAM is for spam commands. */ - if (data == M_SPAM) { - /* If there's a second parameter, it's a template for the spam tag. */ - if (MoreArgs (s)) { - mutt_extract_token (&templ, s, 0); - - /* Add to the spam list. */ - if (add_to_spam_list (&SpamList, buf->data, templ.data, err) != 0) { - p_delete(&templ.data); - return -1; - } - p_delete(&templ.data); - } - - /* If not, try to remove from the nospam list. */ - else { - remove_from_rx_list (&NoSpamList, buf->data); - } - - return 0; - } - - /* M_NOSPAM is for nospam commands. */ - else if (data == M_NOSPAM) { - /* nospam only ever has one parameter. */ - - /* "*" is a special case. */ - if (!m_strcmp(buf->data, "*")) { - rx_list_wipe(&SpamList); - rx_list_wipe(&NoSpamList); - return 0; - } - - /* If it's on the spam list, just remove it. */ - if (remove_from_spam_list (&SpamList, buf->data) != 0) - return 0; - - /* Otherwise, add it to the nospam list. */ - if (add_to_rx_list (&NoSpamList, buf->data, REG_ICASE, err) != 0) - return -1; - - return 0; - } - - /* This should not happen. */ - m_strcpy(err->data, err->dsize, "This is no good at all."); - return -1; -} - static int parse_unlist (BUFFER * buf, BUFFER * s, unsigned long data, BUFFER * err __attribute__ ((unused))) { @@ -2142,7 +2027,6 @@ static int mutt_execute_commands (string_list_t * p) void mutt_init (int skip_sys_rc, string_list_t * commands) { struct passwd *pw; - struct utsname utsname; const char *p; char buffer[STRING], error[STRING]; int default_rc = 0, need_pause = 0; @@ -2172,27 +2056,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) Realname = m_strdup(rnbuf); } - /* And about the host... */ - uname (&utsname); - /* some systems report the FQDN instead of just the hostname */ - if ((p = strchr (utsname.nodename, '.'))) { - Hostname = p_dupstr(utsname.nodename, p - utsname.nodename); - p++; - m_strcpy(buffer, sizeof(buffer), p); /* save the domain for below */ - } - else - Hostname = m_strdup(utsname.nodename); - - if (!p && getdnsdomainname(buffer, sizeof(buffer)) == -1) - Fqdn = m_strdup("@"); - else - if (*buffer != '@') { - Fqdn = p_new(char, m_strlen(buffer) + m_strlen(Hostname) + 2); - sprintf (Fqdn, "%s.%s", NONULL(Hostname), buffer); - } - else - Fqdn = m_strdup(NONULL (Hostname)); - #ifdef USE_NNTP { FILE *f; @@ -2214,11 +2077,9 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) NewsServer = m_strdup(p); #endif - if ((p = getenv ("MAIL"))) + if ((p = getenv("MAIL") ?: getenv("MAILDIR"))) { Spoolfile = m_strdup(p); - else if ((p = getenv ("MAILDIR"))) - Spoolfile = m_strdup(p); - else { + } else { #ifdef HOMESPOOL mutt_concat_path(buffer, sizeof(buffer), NONULL(MCore.homedir), MAILPATH); #else @@ -2253,8 +2114,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) if ((p = getenv ("EMAIL")) != NULL) From = rfc822_parse_adrlist (NULL, p); - charset_initialize(); - /* Set standard defaults */ hash_map (ConfigOptions, mutt_set_default, 0); hash_map (ConfigOptions, mutt_restore_default, 0);