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

📄 recvcmd.c

📁 mutt-1.5.12 源代码。linux 下邮件接受的工具。
💻 C
📖 第 1 页 / 共 2 页
字号:
    else if (rc == M_NO)      mime_fwd_any = 0;  }  /* initialize a state structure */    memset (&st, 0, sizeof (st));    if (option (OPTFORWQUOTE))    st.prefix = prefix;  st.flags = M_CHARCONV;  if (option (OPTWEED))    st.flags |= M_WEED;  st.fpin = fp;  st.fpout = tmpfp;  /* where do we append new MIME parts? */  last = &tmphdr->content;  if (cur)  {    /* single body case */    if (!mime_fwd_all && mutt_can_decode (cur))    {      mutt_body_handler (cur, &st);      state_putc ('\n', &st);    }    else    {      if (mutt_copy_body (fp, last, cur) == -1)	goto bail;      last = &((*last)->next);    }  }  else  {    /* multiple body case */    if (!mime_fwd_all)    {      for (i = 0; i < idxlen; i++)      {	if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content))	{	  mutt_body_handler (idx[i]->content, &st);	  state_putc ('\n', &st);	}      }    }    if (mime_fwd_any && 	(last = copy_problematic_attachments (fp, last, idx, idxlen, mime_fwd_all)) == NULL)      goto bail;  }    mutt_forward_trailer (tmpfp);    fclose (tmpfp);  tmpfp = NULL;  /* now that we have the template, send it. */  ci_send_message (0, tmphdr, tmpbody, NULL, parent);  return;    bail:    if (tmpfp)  {    fclose (tmpfp);    mutt_unlink (tmpbody);  }  mutt_free_header (&tmphdr);}/*  * Forward one or several message-type attachments. This  * is different from the previous function * since we want to mimic the index menu's behaviour. * * Code reuse from ci_send_message is not possible here - * ci_send_message relies on a context structure to find messages, * while, on the attachment menu, messages are referenced through * the attachment index.  */static void attach_forward_msgs (FILE * fp, HEADER * hdr, 	       ATTACHPTR ** idx, short idxlen, BODY * cur){  HEADER *curhdr = NULL;  HEADER *tmphdr;  short i;  int rc;  BODY **last;  char tmpbody[_POSIX_PATH_MAX];  FILE *tmpfp = NULL;  int cmflags = 0;  int chflags = CH_XMIT;    if (cur)    curhdr = cur->hdr;  else  {    for (i = 0; i < idxlen; i++)      if (idx[i]->content->tagged)      {	curhdr = idx[i]->content->hdr;	break;      }  }  tmphdr = mutt_new_header ();  tmphdr->env = mutt_new_envelope ();  mutt_make_forward_subject (tmphdr->env, Context, curhdr);  tmpbody[0] = '\0';  if ((rc = query_quadoption (OPT_MIMEFWD, 		 _("Forward MIME encapsulated?"))) == M_NO)  {        /* no MIME encapsulation */        mutt_mktemp (tmpbody);    if (!(tmpfp = safe_fopen (tmpbody, "w")))    {      mutt_error (_("Can't create %s."), tmpbody);      mutt_free_header (&tmphdr);      return;    }    if (option (OPTFORWQUOTE))    {      chflags |= CH_PREFIX;      cmflags |= M_CM_PREFIX;    }    if (option (OPTFORWDECODE))    {      cmflags |= M_CM_DECODE | M_CM_CHARCONV;      if (option (OPTWEED))      {	chflags |= CH_WEED | CH_REORDER;	cmflags |= M_CM_WEED;      }    }            if (cur)    {      /* mutt_message_hook (cur->hdr, M_MESSAGEHOOK); */       mutt_forward_intro (tmpfp, cur->hdr);      _mutt_copy_message (tmpfp, fp, cur->hdr, cur->hdr->content, cmflags, chflags);      mutt_forward_trailer (tmpfp);    }    else    {      for (i = 0; i < idxlen; i++)      {	if (idx[i]->content->tagged)	{	  /* mutt_message_hook (idx[i]->content->hdr, M_MESSAGEHOOK); */ 	  mutt_forward_intro (tmpfp, idx[i]->content->hdr);	  _mutt_copy_message (tmpfp, fp, idx[i]->content->hdr,			      idx[i]->content->hdr->content, cmflags, chflags);	  mutt_forward_trailer (tmpfp);	}      }    }    fclose (tmpfp);  }  else if (rc == M_YES)	/* do MIME encapsulation - we don't need to do much here */  {    last = &tmphdr->content;    if (cur)      mutt_copy_body (fp, last, cur);    else    {      for (i = 0; i < idxlen; i++)	if (idx[i]->content->tagged)	{	  mutt_copy_body (fp, last, idx[i]->content);	  last = &((*last)->next);	}    }  }  else    mutt_free_header (&tmphdr);  ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL, 		   NULL, curhdr);}void mutt_attach_forward (FILE * fp, HEADER * hdr, 			  ATTACHPTR ** idx, short idxlen, BODY * cur){  short nattach;    if (check_all_msg (idx, idxlen, cur, 0) == 0)    attach_forward_msgs (fp, hdr, idx, idxlen, cur);  else  {    nattach = count_tagged (idx, idxlen);    attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);  }}/** **  ** the various reply functions, from the attachment menu ** ** **//* Create the envelope defaults for a reply. * * This function can be invoked in two ways. *  * Either, parent is NULL.  In this case, all tagged bodies are of a message type, * and the header information is fetched from them. *  * Or, parent is non-NULL.  In this case, cur is the common parent of all the * tagged attachments. *  * Note that this code is horribly similar to envelope_defaults () from send.c. */  static intattach_reply_envelope_defaults (ENVELOPE *env, ATTACHPTR **idx, short idxlen,				HEADER *parent, int flags){  ENVELOPE *curenv = NULL;  HEADER *curhdr = NULL;  short i;    if (!parent)  {    for (i = 0; i < idxlen; i++)    {      if (idx[i]->content->tagged)      {	curhdr = idx[i]->content->hdr;	curenv = curhdr->env;	break;      }    }  }  else  {    curenv = parent->env;    curhdr = parent;  }  if (curenv == NULL  ||  curhdr == NULL)  {    mutt_error _("Can't find any tagged messages.");    return -1;  }  if (parent)  {    if (mutt_fetch_recips (env, curenv, flags) == -1)      return -1;  }  else  {    for (i = 0; i < idxlen; i++)    {      if (idx[i]->content->tagged	  && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)	return -1;    }  }    if ((flags & SENDLISTREPLY) && !env->to)  {    mutt_error _("No mailing lists found!");    return (-1);  }    mutt_fix_reply_recipients (env);  mutt_make_misc_reply_headers (env, Context, curhdr, curenv);  if (parent)    mutt_add_to_reference_headers (env, curenv, NULL, NULL);  else  {    LIST **p = NULL, **q = NULL;        for (i = 0; i < idxlen; i++)    {      if (idx[i]->content->tagged)	mutt_add_to_reference_headers (env, idx[i]->content->hdr->env, &p, &q);    }  }    return 0;}/*  This is _very_ similar to send.c's include_reply(). */static void attach_include_reply (FILE *fp, FILE *tmpfp, HEADER *cur, int flags){  int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV;  int chflags = CH_DECODE;  /* mutt_message_hook (cur, M_MESSAGEHOOK); */     mutt_make_attribution (Context, cur, tmpfp);    if (!option (OPTHEADER))    cmflags |= M_CM_NOHEADER;  if (option (OPTWEED))  {    chflags |= CH_WEED;    cmflags |= M_CM_WEED;  }  _mutt_copy_message (tmpfp, fp, cur, cur->content, cmflags, chflags);  mutt_make_post_indent (Context, cur, tmpfp);}  void mutt_attach_reply (FILE * fp, HEADER * hdr, 			ATTACHPTR ** idx, short idxlen, BODY * cur, 			int flags){  short mime_reply_any = 0;    short nattach = 0;  HEADER *parent = NULL;  HEADER *tmphdr = NULL;  short i;  STATE st;  char tmpbody[_POSIX_PATH_MAX];  FILE *tmpfp;    char prefix[SHORT_STRING];  int rc;    if (check_all_msg (idx, idxlen, cur, 0) == -1)  {    nattach = count_tagged (idx, idxlen);    if ((parent = find_parent (idx, idxlen, cur, nattach)) == NULL)      parent = hdr;  }  if (nattach > 1 && !check_can_decode (idx, idxlen, cur))  {    if ((rc = query_quadoption (OPT_MIMEFWDREST,      _("Can't decode all tagged attachments.  MIME-encapsulate the others?"))) == -1)      return;    else if (rc == M_YES)      mime_reply_any = 1;  }  else if (nattach == 1)    mime_reply_any = 1;  tmphdr = mutt_new_header ();  tmphdr->env = mutt_new_envelope ();  if (attach_reply_envelope_defaults (tmphdr->env, idx, idxlen, 				      parent ? parent : (cur ? cur->hdr : NULL), flags) == -1)  {    mutt_free_header (&tmphdr);    return;  }    mutt_mktemp (tmpbody);  if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL)  {    mutt_error (_("Can't create %s."), tmpbody);    mutt_free_header (&tmphdr);    return;  }  if (!parent)  {    if (cur)      attach_include_reply (fp, tmpfp, cur->hdr, flags);    else    {      for (i = 0; i < idxlen; i++)      {	if (idx[i]->content->tagged)	  attach_include_reply (fp, tmpfp, idx[i]->content->hdr, flags);      }    }  }  else  {    mutt_make_attribution (Context, parent, tmpfp);        memset (&st, 0, sizeof (STATE));    st.fpin = fp;    st.fpout = tmpfp;    if (!option (OPTTEXTFLOWED))      _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), 			 Context, parent, 0);    else      strfcpy (prefix, ">", sizeof (prefix));    st.prefix = prefix;    st.flags  = M_CHARCONV;        if (option (OPTWEED))       st.flags |= M_WEED;    if (option (OPTHEADER))      include_header (1, fp, parent, tmpfp, prefix);    if (cur)    {      if (mutt_can_decode (cur))      {	mutt_body_handler (cur, &st);	state_putc ('\n', &st);      }      else	mutt_copy_body (fp, &tmphdr->content, cur);    }    else    {      for (i = 0; i < idxlen; i++)      {	if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content))	{	  mutt_body_handler (idx[i]->content, &st);	  state_putc ('\n', &st);	}      }    }    mutt_make_post_indent (Context, parent, tmpfp);    if (mime_reply_any && !cur && 	copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen, 0) == NULL)    {      mutt_free_header (&tmphdr);      fclose (tmpfp);      return;    }  }  fclose (tmpfp);    if (ci_send_message (flags, tmphdr, tmpbody, NULL, parent) == 0)    mutt_set_flag (Context, hdr, M_REPLIED, 1);}

⌨️ 快捷键说明

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