Fix -u, change meaning of $USER to be EQ -u etc..
[s-mailx.git] / main.c
blobfcc6feab6c634b0bf664c29a6acf1346d6c73521
1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ Startup -- interface with user.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2013 Steffen "Daode" Nurpmeso <sdaoden@users.sf.net>.
6 */
7 /*
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
13 * are met:
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. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
41 * Most strcpy/sprintf functions have been changed to strncpy/snprintf to
42 * correct several buffer overruns (at least one ot them was exploitable).
43 * Sat Jun 20 04:58:09 CEST 1998 Alvaro Martinez Echevarria <alvaro@lander.es>
44 * ---
45 * Note: We set egid to realgid ... and only if we need the egid we will
46 * switch back temporary. Nevertheless, I do not like seg faults.
47 * Werner Fink, <werner@suse.de>
50 #define _MAIN_SOURCE
51 #include "nail.h"
53 #include <sys/ioctl.h>
55 #include <fcntl.h>
56 #include <pwd.h>
58 #ifdef HAVE_NL_LANGINFO
59 # include <langinfo.h>
60 #endif
61 #ifdef HAVE_SETLOCALE
62 # include <locale.h>
63 #endif
65 #include "version.h"
67 struct a_arg {
68 struct a_arg *aa_next;
69 char *aa_file;
72 /* Perform basic startup initialization */
73 static void _startup(void);
75 /* Grow a char** */
76 static int _grow_cpp(char const ***cpp, int size, int cnt);
78 /* Initialize *tempdir*, *myname*, *homedir* */
79 static void _setup_vars(void);
81 /* We're in an interactive session - compute what the screen size for printing
82 * headers etc. should be; notify tty upon resize if *is_sighdl* is not 0.
83 * We use the following algorithm for the height:
84 * If baud rate < 1200, use 9
85 * If baud rate = 1200, use 14
86 * If baud rate > 1200, use 24 or ws_row
87 * Width is either 80 or ws_col */
88 static void _setscreensize(int is_sighdl);
90 /* Ok, we are reading mail. Decide whether we are editing a mailbox or reading
91 * the system mailbox, and open up the right stuff */
92 static int _rcv_mode(char const *folder);
94 /* Interrupt printing of the headers */
95 static void _hdrstop(int signo);
97 static void
98 _startup(void)
100 char *cp;
102 /* Absolutely the first thing we do is save our egid
103 * and set it to the rgid, so that we can safely run
104 * setgid. We use the sgid (saved set-gid) to allow ourselves
105 * to revert to the egid if we want (temporarily) to become
106 * privileged XXX (s-nail-)*dotlock(-program)* */
107 effectivegid = getegid();
108 realgid = getgid();
109 if (setgid(realgid) < 0) {
110 perror("setgid");
111 exit(1);
114 image = -1;
116 if ((cp = strrchr(progname, '/')) != NULL)
117 progname = ++cp;
119 /* Set up a reasonable environment.
120 * Figure out whether we are being run interactively,
121 * start the SIGCHLD catcher, and so forth */
122 safe_signal(SIGCHLD, sigchild);
124 if (isatty(STDIN_FILENO)) /* TODO should be isatty(0) && isatty(2)?? */
125 options |= OPT_TTYIN | OPT_INTERACTIVE;
126 if (isatty(STDOUT_FILENO))
127 options |= OPT_TTYOUT;
128 if (IS_TTY_SESSION())
129 safe_signal(SIGPIPE, dflpipe = SIG_IGN);
130 assign("header", "");
131 assign("save", "");
133 #ifdef HAVE_SETLOCALE
134 setlocale(LC_ALL, "");
135 mb_cur_max = MB_CUR_MAX;
136 # if defined HAVE_NL_LANGINFO && defined CODESET
137 if (voption("ttycharset") == NULL && (cp = nl_langinfo(CODESET)) != NULL)
138 assign("ttycharset", cp);
139 # endif
141 # if defined HAVE_MBTOWC && defined HAVE_WCTYPE_H
142 if (mb_cur_max > 1) {
143 wchar_t wc;
144 if (mbtowc(&wc, "\303\266", 2) == 2 && wc == 0xF6 &&
145 mbtowc(&wc, "\342\202\254", 3) == 3 && wc == 0x20AC)
146 utf8 = 1;
147 /* Reset state - it may have been messed up; luckily this also
148 * gives us an indication wether the encoding has locking shift
149 * state sequences */
150 /* TODO temporary - use option bits! */
151 enc_has_state = mbtowc(&wc, NULL, mb_cur_max);
153 # endif
154 #else
155 mb_cur_max = 1;
156 #endif
158 #ifdef HAVE_CATGETS
159 # ifdef NL_CAT_LOCALE
160 catd = catopen(CATNAME, NL_CAT_LOCALE);
161 # else
162 catd = catopen(CATNAME, 0);
163 # endif
164 #endif
166 #ifdef HAVE_ICONV
167 iconvd = (iconv_t)-1;
168 #endif
171 static int
172 _grow_cpp(char const ***cpp, int size, int cnt)
174 /* Before spreserve(): use our string pool instead of LibC heap;
175 * Increment *size* by at least 5! */
176 char const **newcpp = salloc(sizeof(char*) * (size += 8));
178 if (cnt > 0)
179 memcpy(newcpp, *cpp, (size_t)cnt * sizeof(char*));
180 *cpp = newcpp;
181 return size;
184 static void
185 _setup_vars(void)
187 /* Before spreserve(): use our string pool instead of LibC heap */
188 /* XXX further check paths? */
189 char const *cp;
190 uid_t uid;
191 struct passwd *pwuid, *pw;
193 tempdir = ((cp = getenv("TMPDIR")) != NULL) ? savestr(cp) : TMPDIR_FALLBACK;
195 cp = (myname == NULL) ? getenv("USER") : myname;
196 uid = getuid();
197 if ((pwuid = getpwuid(uid)) == NULL)
198 panic(tr(201, "Cannot associate a name with uid %lu"), (ul_it)uid);
199 if (cp == NULL)
200 myname = pwuid->pw_name;
201 else if ((pw = getpwnam(cp)) == NULL)
202 panic(tr(236, "`%s' is not a user of this system"), cp);
203 else {
204 myname = pw->pw_name;
205 if (pw->pw_uid != uid)
206 options |= OPT_u_FLAG;
208 myname = savestr(myname);
209 /* XXX myfullname = pw->pw_gecos[OPTIONAL!] -> GUT THAT; TODO pw_shell */
211 if ((cp = getenv("HOME")) == NULL)
212 cp = "."; /* XXX User and Login objects; Login: pw->pw_dir */
213 homedir = savestr(cp);
216 static void
217 _setscreensize(int is_sighdl)
219 struct termios tbuf;
220 #ifdef TIOCGWINSZ
221 struct winsize ws;
222 #elif defined TIOCGSIZE
223 struct ttysize ts;
224 #endif
226 scrnheight = realscreenheight = scrnwidth = 0;
228 /* (Also) POSIX: LINES and COLUMNS always override. Adjust this
229 * a little bit to be able to honour resizes during our lifetime and
230 * only honour it upon first run; abuse *is_sighdl* as an indicator */
231 if (!is_sighdl) {
232 char *cp;
233 long i;
235 if ((cp = getenv("LINES")) != NULL && (i = strtol(cp, NULL, 10)) > 0)
236 scrnheight = realscreenheight = (int)i;
237 if ((cp = getenv("COLUMNS")) != NULL && (i = strtol(cp, NULL, 10)) > 0)
238 scrnwidth = (int)i;
240 if (scrnwidth != 0 && scrnheight != 0)
241 goto jleave;
244 #ifdef TIOCGWINSZ
245 if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
246 ws.ws_col = ws.ws_row = 0;
247 #elif defined TIOCGSIZE
248 if (ioctl(STDOUT_FILENO, TIOCGSIZE, &ws) < 0)
249 ts.ts_lines = ts.ts_cols = 0;
250 #endif
252 if (scrnheight == 0) {
253 speed_t ospeed = ((tcgetattr(STDOUT_FILENO, &tbuf) < 0)
254 ? B9600 : cfgetospeed(&tbuf));
256 if (ospeed < B1200)
257 scrnheight = 9;
258 else if (ospeed == B1200)
259 scrnheight = 14;
260 #ifdef TIOCGWINSZ
261 else if (ws.ws_row != 0)
262 scrnheight = ws.ws_row;
263 #elif defined TIOCGSIZE
264 else if (ts.ts_lines != 0)
265 scrnheight = ts.ts_lines;
266 #endif
267 else
268 scrnheight = 24;
270 #if defined TIOCGWINSZ || defined TIOCGSIZE
271 if (0 ==
272 # ifdef TIOCGWINSZ
273 (realscreenheight = ws.ws_row)
274 # else
275 (realscreenheight = ts.ts_lines)
276 # endif
278 realscreenheight = 24;
279 #endif
282 if (scrnwidth == 0 && 0 ==
283 #ifdef TIOCGWINSZ
284 (scrnwidth = ws.ws_col)
285 #elif defined TIOCGSIZE
286 (scrnwidth = ts.ts_cols)
287 #endif
289 scrnwidth = 80;
291 jleave:
292 #ifdef SIGWINCH
293 if (is_sighdl && IS_TTY_SESSION())
294 tty_signal(SIGWINCH);
295 #endif
298 static sigjmp_buf __hdrjmp; /* XXX */
300 static int
301 _rcv_mode(char const *folder)
303 char *cp;
304 int i;
305 sighandler_type prevint;
307 if (folder == NULL)
308 folder = "%";
309 else if (*folder == '@') {
310 /* This must be treated specially to make invocation like
311 * -A imap -f @mailbox work */
312 if ((cp = value("folder")) != NULL && which_protocol(cp) == PROTO_IMAP)
313 (void)n_strlcpy(mailname, cp, MAXPATHLEN);
316 i = setfile(folder, 0);
317 if (i < 0)
318 exit(1); /* error already reported */
319 if (options & OPT_EXISTONLY)
320 exit(i);
322 if (options & OPT_HEADERSONLY) {
323 #ifdef HAVE_IMAP
324 if (mb.mb_type == MB_IMAP)
325 imap_getheaders(1, msgCount);
326 #endif
327 time_current_update(&time_current, FAL0);
328 for (i = 1; i <= msgCount; ++i)
329 printhead(i, stdout, 0);
330 exit(exit_status);
333 callhook(mailname, 0);
334 if (i > 0 && !boption("emptystart"))
335 exit(1);
337 if (sigsetjmp(__hdrjmp, 1) == 0) {
338 if ((prevint = safe_signal(SIGINT, SIG_IGN)) != SIG_IGN)
339 safe_signal(SIGINT, _hdrstop);
340 if (!(options & OPT_N_FLAG)) {
341 if (!value("quiet"))
342 printf(tr(140, "%s version %s. Type ? for help.\n"),
343 (boption("bsdcompat") ? "Mail" : uagent), version);
344 announce(1);
345 fflush(stdout);
347 safe_signal(SIGINT, prevint);
350 /* Enter the command loop */
351 if (options & OPT_INTERACTIVE)
352 tty_init();
353 commands();
354 if (options & OPT_INTERACTIVE)
355 tty_destroy();
357 if (mb.mb_type == MB_FILE || mb.mb_type == MB_MAILDIR) {
358 safe_signal(SIGHUP, SIG_IGN);
359 safe_signal(SIGINT, SIG_IGN);
360 safe_signal(SIGQUIT, SIG_IGN);
362 if ((cp = expand("&")) == NULL)
363 cp = UNCONST("");
364 n_strlcpy(mboxname, cp, sizeof(mboxname));
365 quit();
366 return exit_status;
369 static void
370 _hdrstop(int signo)
372 UNUSED(signo);
374 fflush(stdout);
375 fprintf(stderr, tr(141, "\nInterrupt\n"));
376 siglongjmp(__hdrjmp, 1);
379 char const weekday_names[7 + 1][4] = {
380 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ""
382 char const month_names[12 + 1][4] = {
383 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
384 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""
387 char const uagent[] = UAGENT;
388 char const version[] = VERSION;
390 sighandler_type dflpipe = SIG_DFL;
392 int
393 main(int argc, char *argv[])
395 static char const optstr[] = "A:a:Bb:c:DdEeFfHiNnO:q:Rr:S:s:tu:Vv~#",
396 usagestr[] =
397 "Synopsis:\n"
398 " %s [-BDdEFintv~] [-A acc] [-a attachment] "
399 "[-b bcc-addr] [-c cc-addr]\n"
400 "\t [-O mtaopt [-O mtaopt-arg]] [-q file] [-r from-addr] "
401 "[-S var[=value]]\n"
402 "\t [-s subject] to-addr...\n"
403 " %s [-BDdEeHiNnRv~#] [-A acct] "
404 "[-S var[=value]] -f [file]\n"
405 " %s [-BDdEeiNnRv~#] [-A acc] [-S var[=value]] [-u user]\n";
407 struct a_arg *a_head = NULL, *a_curr = /* silence CC */ NULL;
408 struct name *to = NULL, *cc = NULL, *bcc = NULL;
409 struct attachment *attach = NULL;
410 char *cp = NULL, *subject = NULL, *qf = NULL, *Aflag = NULL;
411 char const *okey, **oargs = NULL, *folder = NULL;
412 int oargs_size = 0, oargs_count = 0, smopts_size = 0, i;
415 * Start our lengthy setup
418 starting =
419 unset_allow_undefined = TRU1;
421 progname = argv[0];
422 _startup();
424 /* Command line parsing */
425 while ((i = getopt(argc, argv, optstr)) >= 0) {
426 switch (i) {
427 case 'A':
428 /* Execute an account command later on */
429 Aflag = optarg;
430 break;
431 case 'a':
432 { struct a_arg *nap = ac_alloc(sizeof(struct a_arg));
433 if (a_head == NULL)
434 a_head = nap;
435 else
436 a_curr->aa_next = nap;
437 nap->aa_next = NULL;
438 nap->aa_file = optarg;
439 a_curr = nap;
441 options |= OPT_SENDMODE;
442 break;
443 case 'B':
444 /* Make 0/1 line buffered */
445 setvbuf(stdin, NULL, _IOLBF, 0);
446 setvbuf(stdout, NULL, _IOLBF, 0);
447 break;
448 case 'b':
449 /* Get Blind Carbon Copy Recipient list */
450 bcc = cat(bcc, checkaddrs(lextract(optarg, GBCC | GFULL)));
451 options |= OPT_SENDMODE;
452 break;
453 case 'c':
454 /* Get Carbon Copy Recipient list */
455 cc = cat(cc, checkaddrs(lextract(optarg, GCC | GFULL)));
456 options |= OPT_SENDMODE;
457 break;
458 case 'D':
459 #ifdef HAVE_IMAP
460 okey = "disconnected";
461 goto joarg;
462 #else
463 break;
464 #endif
465 case 'd':
466 okey = "debug";
467 #ifdef WANT_ASSERTS
468 assign(okey, "");
469 #endif
470 goto joarg;
471 case 'E':
472 okey = "skipemptybody";
473 goto joarg;
474 case 'e':
475 options |= OPT_EXISTONLY;
476 break;
477 case 'F':
478 options |= OPT_F_FLAG | OPT_SENDMODE;
479 break;
480 case 'f':
481 /* User is specifying file to "edit" with Mail, as opposed to reading
482 * system mailbox. If no argument is given, we read his mbox file.
483 * Check for remaining arguments later */
484 folder = "&";
485 break;
486 case 'H':
487 options |= OPT_HEADERSONLY;
488 break;
489 case 'i':
490 /* Ignore interrupts */
491 okey = "ignore";
492 goto joarg;
493 case 'N':
494 /* Avoid initial header printing */
495 okey = "noheader";
496 goto joarg;
497 case 'n':
498 /* Don't source "unspecified system start-up file" */
499 options |= OPT_NOSRC;
500 break;
501 case 'O':
502 /* Additional options to pass-through to MTA */
503 if (smopts_count == (size_t)smopts_size)
504 smopts_size = _grow_cpp(&smopts, smopts_size, (int)smopts_count);
505 smopts[smopts_count++] = skin(optarg);
506 break;
507 case 'q':
508 /* Quote file TODO drop? -Q with real quote?? what ? */
509 if (*optarg != '-')
510 qf = optarg;
511 options |= OPT_SENDMODE;
512 break;
513 case 'R':
514 /* Open folders read-only */
515 options |= OPT_R_FLAG;
516 break;
517 case 'r':
518 /* Set From address. */
519 options |= OPT_r_FLAG;
520 if ((option_r_arg = optarg)[0] != '\0') {
521 struct name *fa = nalloc(optarg, GFULL);
523 if (is_addr_invalid(fa, 1) || is_fileorpipe_addr(fa)) {
524 fprintf(stderr, tr(271, "Invalid address argument with -r\n"));
525 goto jusage;
527 option_r_arg = fa->n_name;
528 /* TODO -r options is set in smopts, but may
529 * TODO be overwritten by setting from= in
530 * TODO an interactive session!
531 * TODO Maybe disable setting of from?
532 * TODO Warn user? Update manual!! */
533 okey = savecat("from=", fa->n_fullname);
534 goto joarg;
535 /* ..and fa goes even though it is ready :/ */
537 break;
538 case 'S':
539 /* Set variable. We need to do this twice, since the
540 * user surely wants the setting to take effect
541 * immediately, but also doesn't want it to be
542 * overwritten from within resource files */
543 { char *a[2];
544 okey = a[0] = optarg;
545 a[1] = NULL;
546 set(a);
548 joarg:
549 if (oargs_count == oargs_size)
550 oargs_size = _grow_cpp(&oargs, oargs_size, oargs_count);
551 oargs[oargs_count++] = okey;
552 break;
553 case 's':
554 /* Subject: */
555 subject = optarg;
556 options |= OPT_SENDMODE;
557 break;
558 case 't':
559 /* Read defined set of headers from mail to be send */
560 options |= OPT_SENDMODE | OPT_t_FLAG;
561 break;
562 case 'u':
563 /* Set user name to pretend to be; don't set OPT_u_FLAG yet, this is
564 * done as necessary in _setup_vars() above */
565 myname = optarg;
566 break;
567 case 'V':
568 puts(version);
569 exit(0);
570 /* NOTREACHED */
571 case 'v':
572 /* Be verbose */
573 okey = "verbose";
574 #ifdef WANT_ASSERTS
575 assign(okey, "");
576 #endif
577 goto joarg;
578 case '~':
579 /* Enable tilde escapes even in non-interactive mode */
580 options |= OPT_TILDE_FLAG;
581 break;
582 case '#':
583 /* Work in batch mode, even if non-interactive */
584 if (oargs_count + 3 >= oargs_size)
585 oargs_size = _grow_cpp(&oargs, oargs_size, oargs_count);
586 oargs[oargs_count++] = "dot";
587 oargs[oargs_count++] = "emptystart";
588 oargs[oargs_count++] = "noheader";
589 oargs[oargs_count++] = "sendwait";
590 options |= OPT_TILDE_FLAG | OPT_BATCH_FLAG;
591 break;
592 case '?':
593 jusage:
594 fprintf(stderr, tr(135, usagestr), progname, progname, progname);
595 exit(2);
599 if (folder != NULL) {
600 if (optind < argc) {
601 if (optind + 1 < argc) {
602 fprintf(stderr, tr(205, "More than one file given with -f\n"));
603 goto jusage;
605 folder = argv[optind];
607 } else {
608 for (i = optind; argv[i]; ++i)
609 to = cat(to, checkaddrs(lextract(argv[i], GTO | GFULL)));
610 if (to != NULL)
611 options |= OPT_SENDMODE;
614 /* Check for inconsistent arguments */
615 if (folder != NULL && to != NULL) {
616 fprintf(stderr, tr(137, "Cannot give -f and people to send to.\n"));
617 goto jusage;
619 if ((options & (OPT_SENDMODE | OPT_t_FLAG)) == OPT_SENDMODE && to == NULL) {
620 fprintf(stderr, tr(138,
621 "Send options without primary recipient specified.\n"));
622 goto jusage;
624 if ((options & OPT_R_FLAG) && to != NULL) {
625 fprintf(stderr, tr(235, "The -R option is meaningless in send mode.\n"));
626 goto jusage;
630 * Likely to go, perform more setup
633 _setup_vars();
635 if (options & OPT_INTERACTIVE) {
636 _setscreensize(0);
637 #ifdef SIGWINCH
638 # ifndef TTY_WANTS_SIGWINCH
639 if (safe_signal(SIGWINCH, SIG_IGN) != SIG_IGN)
640 # endif
641 safe_signal(SIGWINCH, _setscreensize);
642 #endif
643 } else
644 scrnheight = realscreenheight = 24, scrnwidth = 80;
646 /* Snapshot our string pools. Memory is auto-reclaimed from now on */
647 spreserve();
649 if (!(options & OPT_NOSRC) && getenv("NAIL_NO_SYSTEM_RC") == NULL)
650 load(SYSCONFRC);
651 /* *expand() returns a savestr(), but load only uses the file name for
652 * fopen(), so it's safe to do this */
653 if ((cp = getenv("MAILRC")) != NULL)
654 load(file_expand(cp));
655 else if ((cp = getenv("NAILRC")) != NULL)
656 load(file_expand(cp));
657 else
658 load(file_expand(MAILRC));
659 if (getenv("NAIL_EXTRA_RC") == NULL && (cp = value("NAIL_EXTRA_RC")) != NULL)
660 load(file_expand(cp));
662 /* Now we can set the account */
663 if (Aflag != NULL) {
664 char *a[2];
665 a[0] = Aflag;
666 a[1] = NULL;
667 c_account(a);
670 /* Ensure the -S and other command line options take precedence over
671 * anything that may have been placed in resource files */
672 for (i = 0; i < oargs_count; ++i) {
673 char const *a[2];
674 a[0] = oargs[i];
675 a[1] = NULL;
676 set(a);
680 * We're finally completely setup and ready to go
683 starting =
684 unset_allow_undefined = FAL0;
686 if (options & OPT_DEBUG)
687 fprintf(stderr, tr(199, "user = %s, homedir = %s\n"), myname, homedir);
689 if (!(options & OPT_SENDMODE)) {
690 exit_status = _rcv_mode(folder);
691 goto jleave;
694 /* Now that full mailx(1)-style file expansion is possible handle the
695 * attachments which we had delayed due to this.
696 * This may use savestr(), but since we won't enter the command loop we
697 * don't need to care about that */
698 while (a_head != NULL) {
699 attach = add_attachment(attach, a_head->aa_file, NULL);
700 if (attach != NULL) {
701 a_curr = a_head;
702 a_head = a_head->aa_next;
703 ac_free(a_curr);
704 } else {
705 perror(a_head->aa_file);
706 exit(1);
710 /* xxx exit_status = EXIT_OK; */
711 if (options & OPT_INTERACTIVE)
712 tty_init();
713 mail(to, cc, bcc, subject, attach, qf, ((options & OPT_F_FLAG) != 0));
714 if (options & OPT_INTERACTIVE)
715 tty_destroy();
716 jleave:
717 return exit_status;
720 /* vim:set fenc=utf-8:s-it-mode */