- }
- break;
-
- case '=':
- case '+':
- {
-#ifdef USE_IMAP
- /* if folder = imap[s]://host/: don't append slash */
- if (imap_is_magic (NONULL (Maildir), NULL) == M_IMAP &&
- Maildir[mutt_strlen (Maildir) - 1] == '/')
- strfcpy (p, NONULL (Maildir), sizeof (p));
- else
-#endif
- snprintf (p, sizeof (p), "%s/", NONULL (Maildir));
-
- tail = s + 1;
- }
- break;
-
- /* elm compatibility, @ expands alias to user name */
-
- case '@':
- {
- HEADER *h;
- ADDRESS *alias;
-
- if ((alias = mutt_lookup_alias (s + 1))) {
- h = mutt_new_header ();
- h->env = mutt_new_envelope ();
- h->env->from = h->env->to = alias;
- mutt_default_save (p, sizeof (p), h);
- h->env->from = h->env->to = NULL;
- mutt_free_header (&h);
- /* Avoid infinite recursion if the resulting folder starts with '@' */
- if (*p != '@')
- recurse = 1;
-
- tail = "";
- }
- }
- break;
-
- case '>':
- {
- strfcpy (p, NONULL (Inbox), sizeof (p));
- tail = s + 1;
- }
- break;
-
- case '<':
- {
- strfcpy (p, NONULL (Outbox), sizeof (p));
- tail = s + 1;
- }
- break;
-
- case '!':
- {
- if (*(s + 1) == '!') {
- strfcpy (p, NONULL (LastFolder), sizeof (p));
- tail = s + 2;
- }
- else {
- strfcpy (p, NONULL (Spoolfile), sizeof (p));
- tail = s + 1;
- }
- }
- break;
-
- case '-':
- {
- strfcpy (p, NONULL (LastFolder), sizeof (p));
- tail = s + 1;
- }
- break;
-
- case '^':
- {
- strfcpy (p, NONULL (CurrentFolder), sizeof (p));
- tail = s + 1;
- }
- break;
-
- default:
- {
- *p = '\0';
- tail = s;
- }
- }
-
- if (rx && *p && !recurse) {
- mutt_rx_sanitize_string (q, sizeof (q), p);
- snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
- }
- else
- snprintf (tmp, sizeof (tmp), "%s%s", p, tail);
-
- strfcpy (s, tmp, slen);
- }
- while (recurse);
-
- 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;
-
- memset (dest, 0, destlen);
-
- if (GecosMask.rx) {
- if (regexec (GecosMask.rx, pw->pw_gecos, 1, pat_match, 0) == 0)
- strfcpy (dest, pw->pw_gecos + pat_match[0].rm_so,
- MIN (pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen));
- }
- else if ((p = strchr (pw->pw_gecos, ',')))
- strfcpy (dest, pw->pw_gecos, MIN (destlen, p - pw->pw_gecos + 1));
- else
- strfcpy (dest, pw->pw_gecos, destlen);
-
- pwnl = mutt_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)
- if (ascii_strcasecmp (s, p->attribute) == 0)
- return (p->value);
-
- return NULL;
-}
-
-void mutt_set_parameter (const char *attribute, const char *value,
- PARAMETER ** p)
-{
- PARAMETER *q;
-
- if (!value) {
- mutt_delete_parameter (attribute, p);
- return;
- }
-
- for (q = *p; q; q = q->next) {
- if (ascii_strcasecmp (attribute, q->attribute) == 0) {
- str_replace (&q->value, value);
- return;