return 0;
}
-static short check_all_msg (ATTACHPTR ** idx, short idxlen,
+static short check_all_msg (ATTACH_CONTEXT *actx,
BODY * cur, short err)
{
short i;
return -1;
else if (!cur)
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged)
+ if (actx->idx[i]->content->tagged)
{
- if (check_msg (idx[i]->content, err) == -1)
+ if (check_msg (actx->idx[i]->content, err) == -1)
return -1;
}
}
/* can we decode all tagged attachments? */
-static short check_can_decode (ATTACHPTR ** idx, short idxlen,
- BODY * cur)
+static short check_can_decode (ATTACH_CONTEXT *actx, BODY * cur)
{
short i;
if (cur)
return mutt_can_decode (cur);
- for (i = 0; i < idxlen; i++)
- if (idx[i]->content->tagged && !mutt_can_decode (idx[i]->content))
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged && !mutt_can_decode (actx->idx[i]->content))
return 0;
return 1;
}
-static short count_tagged (ATTACHPTR **idx, short idxlen)
+static short count_tagged (ATTACH_CONTEXT *actx)
{
short count = 0;
short i;
- for (i = 0; i < idxlen; i++)
- if (idx[i]->content->tagged)
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged)
count++;
return count;
* attachment.
*/
-static short count_tagged_children (ATTACHPTR ** idx,
- short idxlen, short i)
+static short count_tagged_children (ATTACH_CONTEXT *actx, short i)
{
- short level = idx[i]->level;
+ short level = actx->idx[i]->level;
short count = 0;
- while ((++i < idxlen) && (level < idx[i]->level))
- if (idx[i]->content->tagged)
+ while ((++i < actx->idxlen) && (level < actx->idx[i]->level))
+ if (actx->idx[i]->content->tagged)
count++;
return count;
**
**/
-void mutt_attach_bounce (FILE * fp, HEADER * hdr,
- ATTACHPTR ** idx, short idxlen, BODY * cur)
+void mutt_attach_bounce (FILE * fp, HEADER * hdr,
+ ATTACH_CONTEXT *actx, BODY * cur)
{
short i;
char prompt[STRING];
int ret = 0;
int p = 0;
- if (check_all_msg (idx, idxlen, cur, 1) == -1)
+ if (check_all_msg (actx, cur, 1) == -1)
return;
/* one or more messages? */
- p = (cur || count_tagged (idx, idxlen) == 1);
+ p = (cur || count_tagged (actx) == 1);
/* RfC 5322 mandates a From: header, so warn before bouncing
* messages without one */
}
else
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged)
+ if (actx->idx[i]->content->tagged)
{
- if (!idx[i]->content->hdr->env->from)
+ if (!actx->idx[i]->content->hdr->env->from)
{
mutt_error _("Warning: message contains no From: header");
mutt_sleep (2);
ret = mutt_bounce_message (fp, cur->hdr, adr);
else
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged)
- if (mutt_bounce_message (fp, idx[i]->content->hdr, adr))
+ if (actx->idx[i]->content->tagged)
+ if (mutt_bounce_message (fp, actx->idx[i]->content->hdr, adr))
ret = 1;
}
}
**
**/
-void mutt_attach_resend (FILE * fp, HEADER * hdr, ATTACHPTR ** idx,
- short idxlen, BODY * cur)
+void mutt_attach_resend (FILE * fp, HEADER * hdr, ATTACH_CONTEXT *actx,
+ BODY * cur)
{
short i;
- if (check_all_msg (idx, idxlen, cur, 1) == -1)
+ if (check_all_msg (actx, cur, 1) == -1)
return;
if (cur)
mutt_resend_message (fp, Context, cur->hdr);
else
{
- for (i = 0; i < idxlen; i++)
- if (idx[i]->content->tagged)
- mutt_resend_message (fp, Context, idx[i]->content->hdr);
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged)
+ mutt_resend_message (fp, Context, actx->idx[i]->content->hdr);
}
}
/* try to find a common parent message for the tagged attachments. */
-static HEADER *find_common_parent (ATTACHPTR ** idx, short idxlen,
- short nattach)
+static HEADER *find_common_parent (ATTACH_CONTEXT *actx, short nattach)
{
short i;
short nchildren;
- for (i = 0; i < idxlen; i++)
- if (idx[i]->content->tagged)
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged)
break;
while (--i >= 0)
{
- if (mutt_is_message_type (idx[i]->content->type, idx[i]->content->subtype))
+ if (mutt_is_message_type (actx->idx[i]->content->type, actx->idx[i]->content->subtype))
{
- nchildren = count_tagged_children (idx, idxlen, i);
+ nchildren = count_tagged_children (actx, i);
if (nchildren == nattach)
- return idx[i]->content->hdr;
+ return actx->idx[i]->content->hdr;
}
}
* bit. For now, it's not worth the effort.
*/
-static int is_parent (short i, ATTACHPTR **idx, short idxlen, BODY *cur)
+static int is_parent (short i, ATTACH_CONTEXT *actx, BODY *cur)
{
- short level = idx[i]->level;
+ short level = actx->idx[i]->level;
- while ((++i < idxlen) && idx[i]->level > level)
+ while ((++i < actx->idxlen) && actx->idx[i]->level > level)
{
- if (idx[i]->content == cur)
+ if (actx->idx[i]->content == cur)
return 1;
}
return 0;
}
-static HEADER *find_parent (ATTACHPTR **idx, short idxlen, BODY *cur, short nattach)
+static HEADER *find_parent (ATTACH_CONTEXT *actx, BODY *cur, short nattach)
{
short i;
HEADER *parent = NULL;
if (cur)
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (mutt_is_message_type (idx[i]->content->type, idx[i]->content->subtype)
- && is_parent (i, idx, idxlen, cur))
- parent = idx[i]->content->hdr;
- if (idx[i]->content == cur)
+ if (mutt_is_message_type (actx->idx[i]->content->type, actx->idx[i]->content->subtype)
+ && is_parent (i, actx, cur))
+ parent = actx->idx[i]->content->hdr;
+ if (actx->idx[i]->content == cur)
break;
}
}
else if (nattach)
- parent = find_common_parent (idx, idxlen, nattach);
+ parent = find_common_parent (actx, nattach);
return parent;
}
static BODY ** copy_problematic_attachments (FILE *fp,
BODY **last,
- ATTACHPTR **idx,
- short idxlen,
+ ATTACH_CONTEXT *actx,
short force)
{
short i;
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged &&
- (force || !mutt_can_decode (idx[i]->content)))
+ if (actx->idx[i]->content->tagged &&
+ (force || !mutt_can_decode (actx->idx[i]->content)))
{
- if (mutt_copy_body (fp, last, idx[i]->content) == -1)
+ if (mutt_copy_body (fp, last, actx->idx[i]->content) == -1)
return NULL; /* XXXXX - may lead to crashes */
last = &((*last)->next);
}
*/
static void attach_forward_bodies (FILE * fp, HEADER * hdr,
- ATTACHPTR ** idx, short idxlen,
+ ATTACH_CONTEXT *actx,
BODY * cur,
short nattach)
{
*/
- parent = find_parent (idx, idxlen, cur, nattach);
+ parent = find_parent (actx, cur, nattach);
if (parent == NULL)
parent = hdr;
*/
if (!mime_fwd_all && !cur && (nattach > 1)
- && !check_can_decode (idx, idxlen, cur))
+ && !check_can_decode (actx, cur))
{
if ((rc = query_quadoption (OPT_MIMEFWDREST,
_("Can't decode all tagged attachments. MIME-forward the others?"))) == -1)
if (!mime_fwd_all)
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content))
+ if (actx->idx[i]->content->tagged && mutt_can_decode (actx->idx[i]->content))
{
- mutt_body_handler (idx[i]->content, &st);
+ mutt_body_handler (actx->idx[i]->content, &st);
state_putc ('\n', &st);
}
}
}
if (mime_fwd_any &&
- copy_problematic_attachments (fp, last, idx, idxlen, mime_fwd_all) == NULL)
+ copy_problematic_attachments (fp, last, actx, mime_fwd_all) == NULL)
goto bail;
}
*/
static void attach_forward_msgs (FILE * fp, HEADER * hdr,
- ATTACHPTR ** idx, short idxlen, BODY * cur)
+ ATTACH_CONTEXT *actx, BODY * cur)
{
HEADER *curhdr = NULL;
HEADER *tmphdr;
curhdr = cur->hdr;
else
{
- for (i = 0; i < idxlen; i++)
- if (idx[i]->content->tagged)
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged)
{
- curhdr = idx[i]->content->hdr;
+ curhdr = actx->idx[i]->content->hdr;
break;
}
}
}
else
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged)
+ if (actx->idx[i]->content->tagged)
{
/* mutt_message_hook (idx[i]->content->hdr, MUTT_MESSAGEHOOK); */
- mutt_forward_intro (Context, idx[i]->content->hdr, tmpfp);
- _mutt_copy_message (tmpfp, fp, idx[i]->content->hdr,
- idx[i]->content->hdr->content, cmflags, chflags);
- mutt_forward_trailer (Context, idx[i]->content->hdr, tmpfp);
+ mutt_forward_intro (Context, actx->idx[i]->content->hdr, tmpfp);
+ _mutt_copy_message (tmpfp, fp, actx->idx[i]->content->hdr,
+ actx->idx[i]->content->hdr->content, cmflags, chflags);
+ mutt_forward_trailer (Context, actx->idx[i]->content->hdr, tmpfp);
}
}
}
mutt_copy_body (fp, last, cur);
else
{
- for (i = 0; i < idxlen; i++)
- if (idx[i]->content->tagged)
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged)
{
- mutt_copy_body (fp, last, idx[i]->content);
+ mutt_copy_body (fp, last, actx->idx[i]->content);
last = &((*last)->next);
}
}
}
void mutt_attach_forward (FILE * fp, HEADER * hdr,
- ATTACHPTR ** idx, short idxlen, BODY * cur)
+ ATTACH_CONTEXT *actx, BODY * cur)
{
short nattach;
- if (check_all_msg (idx, idxlen, cur, 0) == 0)
- attach_forward_msgs (fp, hdr, idx, idxlen, cur);
+ if (check_all_msg (actx, cur, 0) == 0)
+ attach_forward_msgs (fp, hdr, actx, cur);
else
{
- nattach = count_tagged (idx, idxlen);
- attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
+ nattach = count_tagged (actx);
+ attach_forward_bodies (fp, hdr, actx, cur, nattach);
}
}
*/
static int
-attach_reply_envelope_defaults (ENVELOPE *env, ATTACHPTR **idx, short idxlen,
+attach_reply_envelope_defaults (ENVELOPE *env, ATTACH_CONTEXT *actx,
HEADER *parent, int flags)
{
ENVELOPE *curenv = NULL;
if (!parent)
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged)
+ if (actx->idx[i]->content->tagged)
{
- curhdr = idx[i]->content->hdr;
+ curhdr = actx->idx[i]->content->hdr;
curenv = curhdr->env;
break;
}
}
else
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged
- && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
+ if (actx->idx[i]->content->tagged
+ && mutt_fetch_recips (env, actx->idx[i]->content->hdr->env, flags) == -1)
return -1;
}
}
{
LIST **p = NULL, **q = NULL;
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged)
- mutt_add_to_reference_headers (env, idx[i]->content->hdr->env, &p, &q);
+ if (actx->idx[i]->content->tagged)
+ mutt_add_to_reference_headers (env, actx->idx[i]->content->hdr->env, &p, &q);
}
}
mutt_make_post_indent (Context, cur, tmpfp);
}
-void mutt_attach_reply (FILE * fp, HEADER * hdr,
- ATTACHPTR ** idx, short idxlen, BODY * cur,
+void mutt_attach_reply (FILE * fp, HEADER * hdr,
+ ATTACH_CONTEXT *actx, BODY * cur,
int flags)
{
short mime_reply_any = 0;
char prefix[SHORT_STRING];
int rc;
- if (check_all_msg (idx, idxlen, cur, 0) == -1)
+ if (check_all_msg (actx, cur, 0) == -1)
{
- nattach = count_tagged (idx, idxlen);
- if ((parent = find_parent (idx, idxlen, cur, nattach)) == NULL)
+ nattach = count_tagged (actx);
+ if ((parent = find_parent (actx, cur, nattach)) == NULL)
parent = hdr;
}
- if (nattach > 1 && !check_can_decode (idx, idxlen, cur))
+ if (nattach > 1 && !check_can_decode (actx, cur))
{
if ((rc = query_quadoption (OPT_MIMEFWDREST,
_("Can't decode all tagged attachments. MIME-encapsulate the others?"))) == -1)
tmphdr = mutt_new_header ();
tmphdr->env = mutt_new_envelope ();
- if (attach_reply_envelope_defaults (tmphdr->env, idx, idxlen,
+ if (attach_reply_envelope_defaults (tmphdr->env, actx,
parent ? parent : (cur ? cur->hdr : NULL), flags) == -1)
{
mutt_free_header (&tmphdr);
attach_include_reply (fp, tmpfp, cur->hdr, flags);
else
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged)
- attach_include_reply (fp, tmpfp, idx[i]->content->hdr, flags);
+ if (actx->idx[i]->content->tagged)
+ attach_include_reply (fp, tmpfp, actx->idx[i]->content->hdr, flags);
}
}
}
}
else
{
- for (i = 0; i < idxlen; i++)
+ for (i = 0; i < actx->idxlen; i++)
{
- if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content))
+ if (actx->idx[i]->content->tagged && mutt_can_decode (actx->idx[i]->content))
{
- mutt_body_handler (idx[i]->content, &st);
+ mutt_body_handler (actx->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)
+ copy_problematic_attachments (fp, &tmphdr->content, actx, 0) == NULL)
{
mutt_free_header (&tmphdr);
safe_fclose (&tmpfp);