X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=muttlib.c;h=27cbdbd9d394e4bcc6f7954c960995903de4592e;hp=c5be0b78dfb816e6c7c8790d5e41f849a26ee333;hb=723f7ae3f24f7881c9ce87abf933cd5bec4ac0bc;hpb=22601f25ede6703ba7cd06ee84eddd2045308570 diff --git a/muttlib.c b/muttlib.c index c5be0b7..27cbdbd 100644 --- a/muttlib.c +++ b/muttlib.c @@ -12,20 +12,34 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include #include +#include +#include #include +#include +#include + #include "mutt.h" -#include "enter.h" -#include "mutt_curses.h" #include "mx.h" -#include "url.h" #include "attach.h" #include "version.h" @@ -35,20 +49,6 @@ #include -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #define SW (option(OPTMBOXPANE)?SidebarWidth:0) BODY *mutt_new_body (void) @@ -322,7 +322,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) HEADER *h; address_t *alias; - if ((alias = mutt_lookup_alias (s + 1))) { + if ((alias = alias_lookup(Aliases, s + 1))) { h = header_new(); h->env = envelope_new(); h->env->from = h->env->to = alias; @@ -387,7 +387,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) } if (rx && *p && !recurse) { - mutt_rx_sanitize_string (q, sizeof (q), p); + rx_sanitize_string (q, sizeof (q), p); snprintf (tmp, sizeof (tmp), "%s%s", q, tail); } else @@ -400,51 +400,6 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) return (s); } -/* Extract the real name from /etc/passwd's GECOS field. - * When set, honor the regular expression in GecosMask, - * otherwise assume that the GECOS field is a - * comma-separated list. - * Replace "&" by a capitalized version of the user's login - * name. - */ - -char *mutt_gecos_name (char *dest, size_t destlen, struct passwd *pw) -{ - regmatch_t pat_match[1]; - size_t pwnl; - int idx; - char *p; - - if (!pw || !pw->pw_gecos) - return NULL; - - p_clear(dest, destlen); - - if (GecosMask.rx) { - if (regexec (GecosMask.rx, pw->pw_gecos, 1, pat_match, 0) == 0) - m_strcpy(dest, MIN(pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen), - pw->pw_gecos + pat_match[0].rm_so); - } - else if ((p = strchr (pw->pw_gecos, ','))) - m_strcpy(dest, MIN(destlen, p - pw->pw_gecos + 1), pw->pw_gecos); - else - m_strcpy(dest, destlen, pw->pw_gecos); - - pwnl = m_strlen(pw->pw_name); - - for (idx = 0; dest[idx]; idx++) { - if (dest[idx] == '&') { - memmove (&dest[idx + pwnl], &dest[idx + 1], - MAX (destlen - idx - pwnl - 1, 0)); - memcpy (&dest[idx], pw->pw_name, MIN (destlen - idx - 1, pwnl)); - dest[idx] = toupper ((unsigned char) dest[idx]); - } - } - - return dest; -} - - char *mutt_get_parameter (const char *s, PARAMETER * p) { for (; p; p = p->next) @@ -590,26 +545,13 @@ void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra) void _mutt_mktemp (char *s, const char *src, int line) { - snprintf (s, _POSIX_PATH_MAX, "%s/muttng-%s-%d-%d-%d-%x%x", NONULL (Tempdir), + snprintf (s, _POSIX_PATH_MAX, "%s/madmutt-%s-%d-%d-%d-%x%x", NONULL (Tempdir), NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++, (unsigned int) rand(), (unsigned int) rand()); debug_print (1, ("%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s)); unlink (s); } -void mutt_free_alias (ALIAS ** p) -{ - ALIAS *t; - - while (*p) { - t = *p; - *p = (*p)->next; - p_delete(&t->name); - address_delete (&t->addr); - p_delete(&t); - } -} - /* collapse the pathname using ~ or = when possible */ void mutt_pretty_mailbox (char *s) { @@ -853,7 +795,7 @@ int mutt_skipchars (const char *s, const char *c) } void mutt_FormatString (char *dest, /* output buffer */ - size_t destlen, /* output buffer len */ + ssize_t destlen, /* output buffer len */ const char *src, /* template string */ format_t * callback, /* callback for processing */ unsigned long data, /* callback data */ @@ -861,7 +803,7 @@ void mutt_FormatString (char *dest, /* output buffer */ { /* callback flags */ char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch; char ifstring[SHORT_STRING], elsestring[SHORT_STRING]; - size_t wlen, count, len, col, wid; + ssize_t wlen, wid, count, col, len; prefix[0] = '\0'; destlen--; /* save room for the terminal \0 */ @@ -888,7 +830,7 @@ void mutt_FormatString (char *dest, /* output buffer */ /* eat the format string */ cp = prefix; count = 0; - while (count < sizeof (prefix) && + while (count < ssizeof (prefix) && (isdigit ((unsigned char) *src) || *src == '.' || *src == '-')) { *cp++ = *src++; @@ -910,7 +852,7 @@ void mutt_FormatString (char *dest, /* output buffer */ /* eat the `if' part of the string */ cp = ifstring; count = 0; - while (count < sizeof (ifstring) && *src && *src != '?' + while (count < ssizeof (ifstring) && *src && *src != '?' && *src != '&') { *cp++ = *src++; count++; @@ -922,7 +864,7 @@ void mutt_FormatString (char *dest, /* output buffer */ src++; /* skip the & */ cp = elsestring; count = 0; - while (count < sizeof (elsestring) && *src && *src != '?') { + while (count < ssizeof (elsestring) && *src && *src != '?') { *cp++ = *src++; count++; } @@ -1219,10 +1161,10 @@ const char *mutt_make_version (int full) if (full) snprintf (vstring, sizeof (vstring), - "Mutt-ng %s-r%s (based on Mutt 1.5.11)", + "Madmutt/%s-r%s (based on Mutt 1.5.11)", MUTT_VERSION, MUTT_REVISION); else - snprintf (vstring, sizeof (vstring), "mutt-ng/%s-r%s", + snprintf (vstring, sizeof (vstring), "Madmutt/%s-%s", MUTT_VERSION, MUTT_REVISION); return vstring; } @@ -1236,7 +1178,7 @@ void mutt_free_spam_list (SPAM_LIST ** list) while (*list) { p = *list; *list = (*list)->next; - rx_free (&p->rx); + rx_delete(&p->rx); p_delete(&p->template); p_delete(&p); }