1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ All sorts of `reply', `resend', `forward', and similar user commands.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
8 * Copyright (c) 1980, 1993
9 * The Regents of the University of California. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #define n_FILE cmd_resend
38 #ifndef HAVE_AMALGAMATION
42 /* Modify subject we reply to to begin with Re: if it does not already */
43 static char *a_crese_reedit(char const *subj
);
45 /* Fetch these headers, as appropriate */
46 static struct name
*a_crese_reply_to(struct message
*mp
);
47 static struct name
*a_crese_mail_followup_to(struct message
*mp
);
49 /* We honoured Reply-To: and/or Mail-Followup-To:, but *recipients-in-cc* is
50 * set so try to keep "secondary" addressees in Cc:, if possible, */
51 static void a_crese_polite_rt_mft_move(struct message
*mp
, struct header
*hp
,
54 /* References and charset, as appropriate */
55 static void a_crese_make_ref_and_cs(struct message
*mp
, struct header
*head
);
57 /* `reply' and `Lreply' workhorse */
58 static int a_crese_list_reply(int *msgvec
, enum header_flags hf
);
60 /* Get PTF to implementation of command c (i.e., take care for *flipr*) */
61 static int (*a_crese_reply_or_Reply(char c
))(int *, bool_t
);
63 /* Reply to a single message. Extract each name from the message header and
64 * send them off to mail1() */
65 static int a_crese_reply(int *msgvec
, bool_t recipient_record
);
67 /* Reply to a series of messages by simply mailing to the senders and not
68 * messing around with the To: and Cc: lists as in normal reply */
69 static int a_crese_Reply(int *msgvec
, bool_t recipient_record
);
71 /* Forward a message to a new recipient, in the sense of RFC 2822 */
72 static int a_crese_fwd(char *str
, int recipient_record
);
74 /* Modify the subject we are replying to to begin with Fwd: */
75 static char *a_crese__fwdedit(char *subj
);
77 /* Do the real work of resending */
78 static int a_crese_resend1(void *v
, bool_t add_resent
);
81 a_crese_reedit(char const *subj
){
87 if(subj
!= NULL
&& *subj
!= '\0'){
92 in
.l
= strlen(in
.s
= n_UNCONST(subj
));
93 mime_fromhdr(&in
, &out
, TD_ISPR
| TD_ICONV
);
95 i
= strlen(cp
= subject_re_trim(out
.s
)) +1;
96 /* RFC mandates english "Re: " */
97 newsubj
= n_autorec_alloc(sizeof("Re: ") -1 + i
);
98 memcpy(newsubj
, "Re: ", sizeof("Re: ") -1);
99 memcpy(&newsubj
[sizeof("Re: ") -1], cp
, i
);
108 a_crese_reply_to(struct message
*mp
){
109 char const *cp
, *cp2
;
110 struct name
*rt
, *np
;
114 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
117 if((cp
= ok_vlook(reply_to_honour
)) != NULL
&&
118 (cp2
= hfield1("reply-to", mp
)) != NULL
&&
119 (rt
= checkaddrs(lextract(cp2
, GTO
| gf
), EACM_STRICT
, NULL
)) != NULL
){
124 if(n_psonce
& n_PSO_INTERACTIVE
){
125 fprintf(n_stdout
, _("Reply-To: header contains:"));
126 for(np
= rt
; np
!= NULL
; np
= np
->n_flink
)
127 fprintf(n_stdout
, " %s", np
->n_name
);
128 putc('\n', n_stdout
);
131 tr
= _("Reply-To %s%s");
132 l
= strlen(tr
) + strlen(rt
->n_name
) + 3 +1;
133 sp
= n_lofi_alloc(l
);
135 snprintf(sp
, l
, tr
, rt
->n_name
, (rt
->n_flink
!= NULL
? "..." : n_empty
));
136 if(quadify(cp
, UIZ_MAX
, sp
, TRU1
) <= FAL0
)
146 a_crese_mail_followup_to(struct message
*mp
){
147 char const *cp
, *cp2
;
148 struct name
*mft
, *np
;
152 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
155 if((cp
= ok_vlook(followup_to_honour
)) != NULL
&&
156 (cp2
= hfield1("mail-followup-to", mp
)) != NULL
&&
157 (mft
= checkaddrs(lextract(cp2
, GTO
| gf
), EACM_STRICT
,NULL
)) != NULL
){
162 if(n_psonce
& n_PSO_INTERACTIVE
){
163 fprintf(n_stdout
, _("Mail-Followup-To: header contains:"));
164 for(np
= mft
; np
!= NULL
; np
= np
->n_flink
)
165 fprintf(n_stdout
, " %s", np
->n_name
);
166 putc('\n', n_stdout
);
169 tr
= _("Followup-To %s%s");
170 l
= strlen(tr
) + strlen(mft
->n_name
) + 3 +1;
171 sp
= n_lofi_alloc(l
);
173 snprintf(sp
, l
, tr
, mft
->n_name
, (mft
->n_flink
!= NULL
? "..." : n_empty
));
174 if(quadify(cp
, UIZ_MAX
, sp
, TRU1
) <= FAL0
)
184 a_crese_polite_rt_mft_move(struct message
*mp
, struct header
*hp
,
196 struct name
*nnp
, **xpp
, *xp
;
204 /* Try primary, then secondary */
205 for(xp
= hp
->h_mailx_orig_to
; xp
!= NULL
; xp
= xp
->n_flink
)
206 if(!asccasecmp(xp
->n_name
, nnp
->n_name
))
209 for(xp
= hp
->h_mailx_orig_cc
; xp
!= NULL
; xp
= xp
->n_flink
)
210 if(!asccasecmp(xp
->n_name
, nnp
->n_name
))
213 /* If this receiver came in only via R-T: or M-F-T:, place her/him/it in
214 * To: due to lack of a better place */
218 /* Link it at the end to not loose original sort order */
219 if((xp
= *xpp
) != NULL
)
220 while(xp
->n_flink
!= NULL
)
223 if((nnp
->n_blink
= xp
) != NULL
)
228 nnp
->n_type
= (nnp
->n_type
& ~GMASK
) | gf
;
231 /* If afterwards only Cc: data remains, upgrade all of it to To: */
232 if(hp
->h_to
== NULL
){
233 hp
->h_to
= np
= hp
->h_cc
;
236 for(; np
!= NULL
; np
= np
->n_flink
)
237 np
->n_type
= (np
->n_type
& ~GMASK
) | GTO
;
243 a_crese_make_ref_and_cs(struct message
*mp
, struct header
*head
) /* TODO ASAP */
245 char *oldref
, *oldmsgid
, *newref
, *cp
;
246 size_t oldreflen
= 0, oldmsgidlen
= 0, reflen
;
251 oldref
= hfield1("references", mp
);
252 oldmsgid
= hfield1("message-id", mp
);
253 if (oldmsgid
== NULL
|| *oldmsgid
== '\0') {
260 oldreflen
= strlen(oldref
);
261 reflen
+= oldreflen
+ 2;
264 oldmsgidlen
= strlen(oldmsgid
);
265 reflen
+= oldmsgidlen
;
268 newref
= smalloc(reflen
);
269 if (oldref
!= NULL
) {
270 memcpy(newref
, oldref
, oldreflen
+1);
271 if (oldmsgid
!= NULL
) {
272 newref
[oldreflen
++] = ',';
273 newref
[oldreflen
++] = ' ';
274 memcpy(newref
+ oldreflen
, oldmsgid
, oldmsgidlen
+1);
277 memcpy(newref
, oldmsgid
, oldmsgidlen
+1);
278 n
= extract(newref
, GREF
);
281 /* Limit number of references TODO better on parser side */
282 while (n
->n_flink
!= NULL
)
284 for (i
= 1; i
<= REFERENCES_MAX
; ++i
) {
285 if (n
->n_blink
!= NULL
)
292 if (ok_blook(reply_in_same_charset
) &&
293 (cp
= hfield1("content-type", mp
)) != NULL
){
294 if((head
->h_charset
= cp
= mime_param_get("charset", cp
)) != NULL
){
297 for(cpo
= cp
; (c
= *cpo
) != '\0'; ++cpo
)
300 head
->h_charset
= n_charsetalias_expand(cp
);
308 a_crese_list_reply(int *msgvec
, enum header_flags hf
){
311 char const *cp
, *cp2
;
313 struct name
*rt
, *mft
, *np
;
317 n_pstate_err_no
= n_ERR_NONE
;
319 /* TODO Since we may recur and do stuff with message lists we need to save
320 * TODO away the argument vector as long as that isn't done by machinery */
323 for(i
= 0; msgvec
[i
] != 0; ++i
)
326 save_msgvec
= n_lofi_alloc(sizeof(*save_msgvec
) * i
);
328 save_msgvec
[i
] = msgvec
[i
];
329 msgvec
= save_msgvec
;
332 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
335 n_autorec_relax_create();
336 mp
= &message
[*msgvec
- 1];
340 memset(&head
, 0, sizeof head
);
342 head
.h_subject
= a_crese_reedit(hfield1("subject", mp
));
343 head
.h_mailx_command
= (hf
& HF_LIST_REPLY
) ? "Lreply" : "reply";
344 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
345 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
346 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
347 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
349 /* First of all check for Reply-To: then Mail-Followup-To:, because these,
350 * if honoured, take precedence over anything else. We will join the
351 * resulting list together if so desired.
352 * So if we shall honour R-T: or M-F-T:, then these are our receivers! */
353 rt
= a_crese_reply_to(mp
);
354 mft
= a_crese_mail_followup_to(mp
);
356 if(rt
!= NULL
|| mft
!= NULL
){
359 head
.h_mft
= namelist_dup(np
, GTO
| gf
); /* xxx GTO: no "clone"! */
361 /* Optionally do not propagate a receiver that originally was in
362 * secondary Cc: to the primary To: list */
363 if(ok_blook(recipients_in_cc
)){
364 a_crese_polite_rt_mft_move(mp
, &head
, np
);
366 head
.h_mailx_raw_cc
= namelist_dup(head
.h_cc
, GCC
| gf
);
367 head
.h_cc
= n_alternates_remove(head
.h_cc
, FAL0
);
371 head
.h_mailx_raw_to
= namelist_dup(head
.h_to
, GTO
| gf
);
372 head
.h_to
= n_alternates_remove(head
.h_to
, FAL0
);
374 for(np
= head
.h_to
; np
!= NULL
; np
= np
->n_flink
)
375 assert((np
->n_type
& GMASK
) == GTO
);
376 for(np
= head
.h_cc
; np
!= NULL
; np
= np
->n_flink
)
377 assert((np
->n_type
& GMASK
) == GCC
);
379 goto jrecipients_done
;
382 /* Otherwise do the normal From: / To: / Cc: dance */
384 if((cp2
= hfield1("from", mp
)) == NULL
)
389 if(ok_blook(recipients_in_cc
) && (cp
= hfield1("to", mp
)) != NULL
)
390 np
= lextract(cp
, GCC
| gf
);
391 if((cp
= hfield1("cc", mp
)) != NULL
){
394 if((x
= lextract(cp
, GCC
| gf
)) != NULL
)
398 head
.h_mailx_raw_cc
= namelist_dup(np
, GCC
| gf
);
399 head
.h_cc
= n_alternates_remove(np
, FAL0
);
405 np
= lextract(cp2
, GTO
| gf
);
406 if(!ok_blook(recipients_in_cc
) && (cp
= hfield1("to", mp
)) != NULL
){
409 if((x
= lextract(cp
, GTO
| gf
)) != NULL
)
412 /* Delete my name from reply list, and with it, all my alternate names */
414 head
.h_mailx_raw_to
= namelist_dup(np
, GTO
| gf
);
415 np
= n_alternates_remove(np
, FAL0
);
416 /* The user may have send this to himself, don't ignore that */
418 np
= lextract(cp2
, GTO
| gf
);
419 head
.h_mailx_raw_to
= namelist_dup(np
, GTO
| gf
);
426 /* For list replies we want to automatically recognize the list address
427 * given in the List-Post: header, so that we will not throw away a possible
428 * corresponding receiver: temporarily "`mlist' the List-Post: address" */
429 if((hf
& HF_LIST_REPLY
) && (cp
= hfield1("list-post", mp
)) != NULL
){
432 if((x
= lextract(cp
, GEXTRA
| GSKIN
)) == NULL
|| x
->n_flink
!= NULL
||
433 (cp
= url_mailto_to_address(x
->n_name
)) == NULL
||
434 /* XXX terribly wasteful to create a new name, and can't we find
435 * XXX a way to mitigate that?? */
436 is_addr_invalid(x
= nalloc(cp
, GEXTRA
| GSKIN
), EACM_STRICT
)){
437 if(n_poption
& n_PO_D_V
)
438 n_err(_("Message contains invalid List-Post: header\n"));
440 /* A special case has been seen on e.g. ietf-announce@ietf.org:
441 * these usually post to multiple groups, with ietf-announce@
442 * in List-Post:, but with Reply-To: set to ietf@ietf.org (since
443 * -announce@ is only used for announcements, say).
444 * So our desire is to honour this request and actively overwrite
445 * List-Post: for our purpose; but only if its a single address.
446 * However, to avoid ambiguities with users that place themselve in
447 * Reply-To: and mailing lists which don't overwrite this (or only
448 * extend this, shall such exist), only do so if reply_to exists of
449 * a single address which points to the same domain as List-Post: */
450 if(rt
!= NULL
&& rt
->n_flink
== NULL
&&
451 name_is_same_domain(x
, rt
))
452 cp
= rt
->n_name
; /* rt is EACM_STRICT tested */
456 if(is_mlist(cp
, FAL0
) == MLIST_OTHER
)
457 head
.h_list_post
= cp
;
461 /* In case of list replies we actively sort out any non-list recipient */
462 if(hf
& HF_LIST_REPLY
){
463 struct name
**nhpp
, *nhp
, *tail
;
465 cp
= head
.h_list_post
;
467 nhp
= *(nhpp
= &head
.h_to
);
470 for(tail
= NULL
; nhp
!= NULL
;){
474 if((cp
!= NULL
&& !asccasecmp(cp
, np
->n_name
)) ||
475 is_mlist(np
->n_name
, FAL0
) != MLIST_OTHER
){
476 if((np
->n_blink
= tail
) != NULL
)
484 if(nhpp
== &head
.h_to
){
485 nhp
= *(nhpp
= &head
.h_cc
);
490 /* For `Lreply' only, fail immediately with DESTADDRREQ if there are no
491 * receivers at all! */
492 if(head
.h_to
== NULL
&& head
.h_cc
== NULL
){
493 n_err(_("No recipients specified for `Lreply'\n"));
495 n_pstate_err_no
= n_ERR_DESTADDRREQ
;
503 /* Move Cc: to To: as appropriate! */
504 if(head
.h_to
== NULL
&& (np
= head
.h_cc
) != NULL
){
506 for(head
.h_to
= np
; np
!= NULL
; np
= np
->n_flink
)
507 np
->n_type
= (np
->n_type
& ~GMASK
) | GTO
;
510 a_crese_make_ref_and_cs(mp
, &head
);
512 if(ok_blook(quote_as_attachment
)){
513 head
.h_attach
= csalloc(1, sizeof *head
.h_attach
);
514 head
.h_attach
->a_msgno
= *msgvec
;
515 head
.h_attach
->a_content_description
= _("Original message content");
518 if(mail1(&head
, 1, mp
, NULL
, !!(hf
& HF_RECIPIENT_RECORD
), 0) != OKAY
){
522 if(ok_blook(markanswered
) && !(mp
->m_flag
& MANSWERED
))
523 mp
->m_flag
|= MANSWER
| MANSWERED
;
524 n_autorec_relax_gut();
528 /* TODO message (error) ring.., less sleep */
529 if(n_psonce
& n_PSO_INTERACTIVE
){
531 _("Waiting a second before proceeding to the next message..\n"));
533 n_msleep(1000, FAL0
);
539 n_lofi_free(save_msgvec
);
541 return (msgvec
== NULL
);
545 (*a_crese_reply_or_Reply(char c
))(int *, bool_t
){
546 int (*rv
)(int*, bool_t
);
549 rv
= (ok_blook(flipr
) ^ (c
== 'R')) ? &a_crese_Reply
: &a_crese_reply
;
555 a_crese_reply(int *msgvec
, bool_t recipient_record
){
559 rv
= a_crese_list_reply(msgvec
,
560 (recipient_record
? HF_RECIPIENT_RECORD
: HF_NONE
));
566 a_crese_Reply(int *msgvec
, bool_t recipient_record
){
573 memset(&head
, 0, sizeof head
);
574 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
576 for(ap
= msgvec
; *ap
!= 0; ++ap
){
579 mp
= &message
[*ap
- 1];
583 if((np
= a_crese_reply_to(mp
)) == NULL
){
586 if((cp
= hfield1("from", mp
)) == NULL
)
588 np
= lextract(cp
, GTO
| gf
);
590 head
.h_to
= cat(head
.h_to
, np
);
593 mp
= &message
[msgvec
[0] - 1];
594 head
.h_subject
= hfield1("subject", mp
);
595 head
.h_subject
= a_crese_reedit(head
.h_subject
);
596 a_crese_make_ref_and_cs(mp
, &head
);
597 head
.h_mailx_command
= "Reply";
598 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
599 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
600 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
601 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
603 if(ok_blook(recipients_in_cc
)){
604 a_crese_polite_rt_mft_move(mp
, &head
, head
.h_to
);
606 head
.h_mailx_raw_cc
= namelist_dup(head
.h_cc
, GCC
| gf
);
607 head
.h_cc
= n_alternates_remove(head
.h_cc
, FAL0
);
609 head
.h_mailx_raw_to
= namelist_dup(head
.h_to
, GTO
| gf
);
610 head
.h_to
= n_alternates_remove(head
.h_to
, FAL0
);
612 if(ok_blook(quote_as_attachment
)){
613 head
.h_attach
= csalloc(1, sizeof *head
.h_attach
);
614 head
.h_attach
->a_msgno
= *msgvec
;
615 head
.h_attach
->a_content_description
= _("Original message content");
618 if(mail1(&head
, 1, mp
, NULL
, recipient_record
, 0) != OKAY
){
623 if(ok_blook(markanswered
) && !(mp
->m_flag
& MANSWERED
))
624 mp
->m_flag
|= MANSWER
| MANSWERED
;
627 return (msgvec
== NULL
);
631 a_crese_fwd(char *str
, int recipient_record
){
635 bool_t f
, forward_as_attachment
;
642 if((recipient
= laststring(str
, &f
, TRU1
)) == NULL
){
643 n_err(_("No recipient specified.\n"));
644 n_pstate_err_no
= n_ERR_DESTADDRREQ
;
648 forward_as_attachment
= ok_blook(forward_as_attachment
);
649 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
650 msgvec
= n_autorec_alloc((msgCount
+ 2) * sizeof *msgvec
);
652 n_pstate_err_no
= n_ERR_NODATA
;
654 *msgvec
= first(0, MMNORM
);
657 }else if(getmsglist(str
, msgvec
, 0) < 0)
661 n_err(_("No applicable messages.\n"));
665 n_err(_("Cannot forward multiple messages at once\n"));
666 n_pstate_err_no
= n_ERR_NOTSUP
;
670 memset(&head
, 0, sizeof head
);
671 head
.h_to
= lextract(recipient
,
672 (GTO
| (ok_blook(fullnames
) ? GFULL
: GSKIN
)));
674 mp
= &message
[*msgvec
- 1];
677 head
.h_subject
= hfield1("subject", mp
);
678 head
.h_subject
= a_crese__fwdedit(head
.h_subject
);
679 head
.h_mailx_command
= "forward";
680 head
.h_mailx_raw_to
= namelist_dup(head
.h_to
, GTO
| gf
);
681 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
682 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
683 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
684 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
686 if(forward_as_attachment
){
687 head
.h_attach
= csalloc(1, sizeof *head
.h_attach
);
688 head
.h_attach
->a_msgno
= *msgvec
;
689 head
.h_attach
->a_content_description
= _("Forwarded message");
692 rv
= (mail1(&head
, 1, (forward_as_attachment
? NULL
: mp
), NULL
,
693 recipient_record
, 1) != OKAY
); /* reverse! */
700 a_crese__fwdedit(char *subj
){
707 if(subj
== NULL
|| *subj
== '\0')
712 mime_fromhdr(&in
, &out
, TD_ISPR
| TD_ICONV
);
714 newsubj
= n_autorec_alloc(out
.l
+ 6);
715 if(!ascncasecmp(out
.s
, "Fwd: ", sizeof("Fwd: ") -1)) /* TODO EXTEND SUPP.. */
716 memcpy(newsubj
, out
.s
, out
.l
+1);
718 memcpy(newsubj
, "Fwd: ", 5); /* TODO ..a la subject_re_trim()! */
719 memcpy(&newsubj
[5], out
.s
, out
.l
+1);
729 a_crese_resend1(void *vp
, bool_t add_resent
){
731 struct name
*myto
, *myrawto
;
741 msgvec
= n_autorec_alloc((msgCount
+ 2) * sizeof *msgvec
);
742 name
= laststring(str
, &fail
, TRU1
);
744 n_err(_("No recipient specified.\n"));
745 n_pstate_err_no
= n_ERR_DESTADDRREQ
;
749 n_pstate_err_no
= n_ERR_NODATA
;
752 *msgvec
= first(0, MMNORM
);
755 }else if(getmsglist(str
, msgvec
, 0) < 0)
759 n_err(_("No applicable messages.\n"));
764 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
766 myrawto
= nalloc(name
, GTO
| gf
);
767 myto
= usermap(namelist_dup(myrawto
, myrawto
->n_type
), FAL0
);
768 myto
= n_alternates_remove(myto
, TRU1
);
770 n_pstate_err_no
= n_ERR_DESTADDRREQ
;
774 n_autorec_relax_create();
775 for(ip
= msgvec
; *ip
!= 0 && UICMP(z
, PTR2SIZE(ip
- msgvec
), <, msgCount
);
779 mp
= &message
[*ip
- 1];
783 memset(&head
, 0, sizeof head
);
785 head
.h_mailx_command
= "resend";
786 head
.h_mailx_raw_to
= myrawto
;
787 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
788 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
789 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
790 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
792 if(resend_msg(mp
, &head
, add_resent
) != OKAY
){
793 /* n_autorec_relax_gut(); XXX but is handled automatically? */
796 n_autorec_relax_unroll();
798 n_autorec_relax_gut();
801 n_pstate_err_no
= n_ERR_NONE
;
804 return (fail
!= FAL0
);
812 rv
= (*a_crese_reply_or_Reply('r'))(vp
, FAL0
);
818 c_replyall(void *vp
){
822 rv
= a_crese_reply(vp
, FAL0
);
828 c_replysender(void *vp
){
832 rv
= a_crese_Reply(vp
, FAL0
);
842 rv
= (*a_crese_reply_or_Reply('R'))(vp
, FAL0
);
852 rv
= a_crese_list_reply(vp
, HF_LIST_REPLY
);
858 c_followup(void *vp
){
862 rv
= (*a_crese_reply_or_Reply('r'))(vp
, TRU1
);
868 c_followupall(void *vp
){
872 rv
= a_crese_reply(vp
, TRU1
);
878 c_followupsender(void *vp
){
882 rv
= a_crese_Reply(vp
, TRU1
);
888 c_Followup(void *vp
){
892 rv
= (*a_crese_reply_or_Reply('R'))(vp
, TRU1
);
902 rv
= a_crese_fwd(vp
, 0);
912 rv
= a_crese_fwd(vp
, 1);
922 rv
= a_crese_resend1(vp
, TRU1
);
932 rv
= a_crese_resend1(vp
, FAL0
);