⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hdrline.c

📁 mutt-1.5.12 源代码。linux 下邮件接受的工具。
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 1996-2000,2002 Michael R. Elkins <me@mutt.org> *  *     This program is free software; you can redistribute it and/or modify *     it under the terms of the GNU General Public License as published by *     the Free Software Foundation; either version 2 of the License, or *     (at your option) any later version. *  *     This program is distributed in the hope that it will be useful, *     but WITHOUT ANY WARRANTY; without even the implied warranty of *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *     GNU General Public License for more details. *  *     You should have received a copy of the GNU General Public License *     along with this program; if not, write to the Free Software *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. */ #if HAVE_CONFIG_H# include "config.h"#endif#include "mutt.h"#include "mutt_curses.h"#include "sort.h"#include "charset.h"#include "mutt_crypt.h"#include "mutt_idna.h"#include <ctype.h>#include <stdlib.h>#include <string.h>#include <locale.h>int mutt_is_mail_list (ADDRESS *addr){  if (!mutt_match_rx_list (addr->mailbox, UnMailLists))    return mutt_match_rx_list (addr->mailbox, MailLists);  return 0;}int mutt_is_subscribed_list (ADDRESS *addr){  if (!mutt_match_rx_list (addr->mailbox, UnMailLists)      && !mutt_match_rx_list (addr->mailbox, UnSubscribedLists))    return mutt_match_rx_list (addr->mailbox, SubscribedLists);  return 0;}/* Search for a mailing list in the list of addresses pointed to by adr. * If one is found, print pfx and the name of the list into buf, then * return 1.  Otherwise, simply return 0. */static intcheck_for_mailing_list (ADDRESS *adr, char *pfx, char *buf, int buflen){  for (; adr; adr = adr->next)  {    if (mutt_is_subscribed_list (adr))    {      if (pfx && buf && buflen)	snprintf (buf, buflen, "%s%s", pfx, mutt_get_name (adr));      return 1;    }  }  return 0;}/* Search for a mailing list in the list of addresses pointed to by adr. * If one is found, print the address of the list into buf, then return 1. * Otherwise, simply return 0. */static intcheck_for_mailing_list_addr (ADDRESS *adr, char *buf, int buflen){  for (; adr; adr = adr->next)  {    if (mutt_is_subscribed_list (adr))    {      if (buf && buflen)	snprintf (buf, buflen, "%s", adr->mailbox);      return 1;    }  }  return 0;}static int first_mailing_list (char *buf, size_t buflen, ADDRESS *a){  for (; a; a = a->next)  {    if (mutt_is_subscribed_list (a))    {      mutt_save_path (buf, buflen, a);      return 1;    }  }  return 0;}static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists){  int me;  me = mutt_addr_is_user (hdr->from);  if (do_lists || me)  {    if (check_for_mailing_list (hdr->to, "To ", buf, len))      return;    if (check_for_mailing_list (hdr->cc, "Cc ", buf, len))      return;  }  if (me && hdr->to)    snprintf (buf, len, "To %s", mutt_get_name (hdr->to));  else if (me && hdr->cc)    snprintf (buf, len, "Cc %s", mutt_get_name (hdr->cc));  else if (hdr->from)    strfcpy (buf, mutt_get_name (hdr->from), len);  else    *buf = 0;}static void make_from_addr (ENVELOPE *hdr, char *buf, size_t len, int do_lists){  int me;  me = mutt_addr_is_user (hdr->from);  if (do_lists || me)  {    if (check_for_mailing_list_addr (hdr->to, buf, len))      return;    if (check_for_mailing_list_addr (hdr->cc, buf, len))      return;  }  if (me && hdr->to)    snprintf (buf, len, "%s", hdr->to->mailbox);  else if (me && hdr->cc)    snprintf (buf, len, "%s", hdr->cc->mailbox);  else if (hdr->from)    strfcpy (buf, hdr->from->mailbox, len);  else    *buf = 0;}static int user_in_addr (ADDRESS *a){  for (; a; a = a->next)    if (mutt_addr_is_user (a))      return 1;  return 0;}/* Return values: * 0: user is not in list * 1: user is unique recipient * 2: user is in the TO list * 3: user is in the CC list * 4: user is originator * 5: sent to a subscribed mailinglist */int mutt_user_is_recipient (HEADER *h){  ENVELOPE *env = h->env;  if(!h->recip_valid)  {    h->recip_valid = 1;        if (mutt_addr_is_user (env->from))      h->recipient = 4;    else if (user_in_addr (env->to))    {      if (env->to->next || env->cc)	h->recipient = 2; /* non-unique recipient */      else	h->recipient = 1; /* unique recipient */    }    else if (user_in_addr (env->cc))      h->recipient = 3;    else if (check_for_mailing_list (env->to, NULL, NULL, 0))      h->recipient = 5;    else if (check_for_mailing_list (env->cc, NULL, NULL, 0))      h->recipient = 5;    else      h->recipient = 0;  }    return h->recipient;}/* %a = address of author * %A = reply-to address (if present; otherwise: address of author * %b = filename of the originating folder * %B = the list to which the letter was sent * %c = size of message in bytes * %C = current message number * %d = date and time of message using $date_format and sender's timezone * %D = date and time of message using $date_format and local timezone * %e = current message number in thread * %E = number of messages in current thread * %f = entire from line * %F = like %n, unless from self * %i = message-id * %l = number of lines in the message * %L = like %F, except `lists' are displayed first * %m = number of messages in the mailbox * %n = name of author * %N = score * %O = like %L, except using address instead of name * %s = subject * %S = short message status (e.g., N/O/D/!/r/-) * %t = `to:' field (recipients) * %T = $to_chars * %u = user (login) name of author * %v = first name of author, unless from self * %X = number of MIME attachments * %y = `x-label:' field (if present) * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label) * %Z = status flags	*/struct hdr_format_info{  CONTEXT *ctx;  HEADER *hdr;};static const char *hdr_format_str (char *dest,		size_t destlen,		char op,		const char *src,		const char *prefix,		const char *ifstring,		const char *elsestring,		unsigned long data,		format_flag flags){  struct hdr_format_info *hfi = (struct hdr_format_info *) data;  HEADER *hdr, *htmp;  CONTEXT *ctx;  char fmt[SHORT_STRING], buf2[SHORT_STRING], ch, *p;  int do_locales, i;  int optional = (flags & M_FORMAT_OPTIONAL);  int threads = ((Sort & SORT_MASK) == SORT_THREADS);  int is_index = (flags & M_FORMAT_INDEX);#define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1)#define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2)  size_t len;  hdr = hfi->hdr;  ctx = hfi->ctx;  dest[0] = 0;  switch (op)  {    case 'A':      if(hdr->env->reply_to && hdr->env->reply_to->mailbox)      {	mutt_format_s (dest, destlen, prefix, mutt_addr_for_display (hdr->env->reply_to));	break;      }      /* fall through if 'A' returns nothing */    case 'a':      if(hdr->env->from && hdr->env->from->mailbox)      {	mutt_format_s (dest, destlen, prefix, mutt_addr_for_display (hdr->env->from));      }      else        dest[0] = '\0';      break;    case 'B':      if (!first_mailing_list (dest, destlen, hdr->env->to) &&	  !first_mailing_list (dest, destlen, hdr->env->cc))	dest[0] = 0;      if (dest[0])      {	strfcpy (buf2, dest, sizeof(buf2));	mutt_format_s (dest, destlen, prefix, buf2);	break;      }      /* fall through if 'B' returns nothing */    case 'b':      if(ctx)      {	if ((p = strrchr (ctx->path, '/')))	  strfcpy (dest, p + 1, destlen);	else	  strfcpy (dest, ctx->path, destlen);      }      else 	strfcpy(dest, "(null)", destlen);      strfcpy (buf2, dest, sizeof(buf2));      mutt_format_s (dest, destlen, prefix, buf2);      break;        case 'c':      mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length);      mutt_format_s (dest, destlen, prefix, buf2);      break;    case 'C':      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);      snprintf (dest, destlen, fmt, hdr->msgno + 1);      break;    case 'd':    case 'D':    case '{':    case '[':    case '(':    case '<':      /* preprocess $date_format to handle %Z */      {	const char *cp;	struct tm *tm; 	time_t T;	p = dest;	cp = (op == 'd' || op == 'D') ? (NONULL (DateFmt)) : src;	if (*cp == '!')	{	  do_locales = 0;	  cp++;	}	else	  do_locales = 1;	len = destlen - 1;	while (len > 0 && (((op == 'd' || op == 'D') && *cp) ||			   (op == '{' && *cp != '}') || 			   (op == '[' && *cp != ']') ||			   (op == '(' && *cp != ')') ||			   (op == '<' && *cp != '>')))	{	  if (*cp == '%')	  {	    cp++;	    if ((*cp == 'Z' || *cp == 'z') && (op == 'd' || op == '{'))	    {	      if (len >= 5)	      {		sprintf (p, "%c%02u%02u", hdr->zoccident ? '-' : '+',			 hdr->zhours, hdr->zminutes);		p += 5;		len -= 5;	      }	      else		break; /* not enough space left */	    }	    else	    {	      if (len >= 2)	      {		*p++ = '%';		*p++ = *cp;		len -= 2;	      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -