1 |
/* GNU mailutils - a suite of utilities for electronic mail |
/* GNU Mailutils -- a suite of utilities for electronic mail |
2 |
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
GNU Mailutils is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
7 |
any later version. |
any later version. |
8 |
|
|
9 |
This program is distributed in the hope that it will be useful, |
GNU Mailutils is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
GNU General Public License for more details. |
13 |
|
|
14 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
15 |
along with this program; if not, write to the Free Software |
along with GNU Mailutils; if not, write to the Free Software |
16 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
17 |
|
|
18 |
#include "mail.h" |
#include "mail.h" |
26 |
int interactive; |
int interactive; |
27 |
|
|
28 |
const char *argp_program_version = "mail (" PACKAGE_STRING ")"; |
const char *argp_program_version = "mail (" PACKAGE_STRING ")"; |
29 |
static char doc[] = "GNU mail -- the standard /bin/mail interface"; |
static char doc[] = N_("GNU mail -- the standard /bin/mail interface"); |
30 |
static char args_doc[] = "[address...]"; |
static char args_doc[] = N_("[address...]"); |
31 |
|
|
32 |
static struct argp_option options[] = { |
static struct argp_option options[] = { |
33 |
{"exist", 'e', 0, 0, "Return true if mail exists", 0}, |
{"exist", 'e', 0, 0, N_("Return true if mail exists"), 0}, |
34 |
{"file", 'f', "FILE", OPTION_ARG_OPTIONAL, |
{"file", 'f', "FILE", OPTION_ARG_OPTIONAL, |
35 |
"Operate on mailbox FILE (default ~/mbox)", 0}, |
N_("Operate on mailbox FILE (default ~/mbox)"), 0}, |
36 |
{"byname", 'F', 0, 0, "Save messages according to sender", 0}, |
{"byname", 'F', 0, 0, N_("Save messages according to sender"), 0}, |
37 |
{"headers", 'H', 0, 0, "Write a header summary and exit", 0}, |
{"headers", 'H', 0, 0, N_("Write a header summary and exit"), 0}, |
38 |
{"ignore", 'i', 0, 0, "Ignore interrupts", 0}, |
{"ignore", 'i', 0, 0, N_("Ignore interrupts"), 0}, |
39 |
{"norc", 'n', 0, 0, "Do not read the system mailrc file", 0}, |
{"norc", 'n', 0, 0, N_("Do not read the system mailrc file"), 0}, |
40 |
{"nosum", 'N', 0, 0, "Do not display initial header summary", 0}, |
{"nosum", 'N', 0, 0, N_("Do not display initial header summary"), 0}, |
41 |
{"print", 'p', 0, 0, "Print all mail to standard output", 0}, |
{"print", 'p', 0, 0, N_("Print all mail to standard output"), 0}, |
42 |
{"quit", 'q', 0, 0, "Cause interrupts to terminate program", 0}, |
{"quit", 'q', 0, 0, N_("Cause interrupts to terminate program"), 0}, |
43 |
{"read", 'r', 0, 0, "Same as -p", 0}, |
{"read", 'r', 0, 0, N_("Same as -p"), 0}, |
44 |
{"subject", 's', "SUBJ", 0, "Send a message with a Subject of SUBJ", 0}, |
{"subject", 's', "SUBJ", 0, N_("Send a message with a Subject of SUBJ"), 0}, |
45 |
{"to", 't', 0, 0, "Precede message by a list of addresses", 0}, |
{"to", 't', 0, 0, N_("Precede message by a list of addresses"), 0}, |
46 |
{"user", 'u', "USER", 0, "Operate on USER's mailbox", 0}, |
{"user", 'u', "USER", 0, N_("Operate on USER's mailbox"), 0}, |
47 |
{NULL, 0, NULL, OPTION_DOC, |
{NULL, 0, NULL, OPTION_DOC, |
48 |
"Note: Argument to --file (-f) option is optional. If it is present, " |
N_("Note: Argument to --file (-f) option is optional. If it is present, " |
49 |
"it must follow the short option immediately, without any intervening " |
"it must follow the short option immediately, without any intervening " |
50 |
"whitespace. If it is used with the long option, it must be separated " |
"whitespace. If it is used with the long option, it must be separated " |
51 |
"from it by an equal sign, with no intervening whitespace.", 0}, |
"from it by an equal sign, with no intervening whitespace."), 0}, |
52 |
{ NULL, 0, NULL, 0, NULL, 0 } |
{ NULL, 0, NULL, 0, NULL, 0 } |
53 |
}; |
}; |
54 |
|
|
135 |
|
|
136 |
if (args->file) |
if (args->file) |
137 |
{ |
{ |
138 |
util_error ("Usage error: --file takes an optional argument, it must follow the option\n" |
util_error (_("Usage error: --file takes an optional argument, " |
139 |
"without any intervening whitespace."); |
"it must follow the option\n" |
140 |
util_error ("Run mail --help for more info."); |
"without any intervening whitespace.")); |
141 |
|
util_error (_("Run mail --help for more info.")); |
142 |
util_do_command ("set quiet"); |
util_do_command ("set quiet"); |
143 |
args->file = arg; |
args->file = arg; |
144 |
} |
} |
188 |
&& !mailbox_is_updated (mbox)) |
&& !mailbox_is_updated (mbox)) |
189 |
{ |
{ |
190 |
mailbox_messages_count (mbox, &total); |
mailbox_messages_count (mbox, &total); |
191 |
fprintf (ofile, "New mail has arrived\n"); |
fprintf (ofile, _("New mail has arrived.\n")); |
192 |
} |
} |
193 |
|
|
194 |
rc = ml_readline (prompt); |
rc = ml_readline (prompt); |
195 |
|
|
196 |
if (ml_got_interrupt()) |
if (ml_got_interrupt()) |
197 |
{ |
{ |
198 |
util_error("Interrupt"); |
util_error(_("Interrupt")); |
199 |
continue; |
continue; |
200 |
} |
} |
201 |
|
|
202 |
if (!rc && util_getenv (NULL, "ignoreeof", Mail_env_boolean, 0) == 0) |
if (!rc && util_getenv (NULL, "ignoreeof", Mail_env_boolean, 0) == 0) |
203 |
{ |
{ |
204 |
util_error ("Use \"quit\" to quit."); |
util_error (_("Use \"quit\" to quit.")); |
205 |
continue; |
continue; |
206 |
} |
} |
207 |
|
|
222 |
cursor = 1; |
cursor = 1; |
223 |
realcursor = cursor; |
realcursor = cursor; |
224 |
|
|
225 |
|
/* Native Language Support */ |
226 |
|
mu_init_nls (); |
227 |
|
|
228 |
/* Register the desire formats. */ |
/* Register the desire formats. */ |
229 |
{ |
{ |
230 |
list_t bookie; |
list_t bookie; |
354 |
if (util_getenv (NULL, "quiet", Mail_env_boolean, 0)) |
if (util_getenv (NULL, "quiet", Mail_env_boolean, 0)) |
355 |
{ |
{ |
356 |
fprintf (ofile, |
fprintf (ofile, |
357 |
"%s, Copyright (C) 2001 Free Software Foundation, Inc.\n" |
_("%s, Copyright (C) 2001 Free Software Foundation, Inc.\n" |
358 |
"mail is free software with ABSOLUTELY NO WARRANTY.\n" |
"mail is free software with ABSOLUTELY NO WARRANTY.\n" |
359 |
"For details type `warranty'.\n" |
"For details type `warranty'.\n" |
360 |
"Send bug reports to %s.\n", |
"Send bug reports to %s.\n"), |
361 |
argp_program_version, |
argp_program_version, |
362 |
argp_program_bug_address); |
argp_program_bug_address); |
363 |
} |
} |
395 |
rc = mailbox_create_default (&mbox, NULL); |
rc = mailbox_create_default (&mbox, NULL); |
396 |
if (rc != 0) |
if (rc != 0) |
397 |
{ |
{ |
398 |
util_error ("Can not create mailbox for %s: %s", args.user, |
util_error (_("Can not create mailbox for %s: %s"), args.user, |
399 |
mu_errstring (rc)); |
mu_errstring (rc)); |
400 |
exit (EXIT_FAILURE); |
exit (EXIT_FAILURE); |
401 |
} |
} |
402 |
} |
} |
403 |
else if ((rc = mailbox_create_default (&mbox, args.file)) != 0) |
else if ((rc = mailbox_create_default (&mbox, args.file)) != 0) |
404 |
{ |
{ |
405 |
util_error ("Can not create mailbox %s: %s", args.file, |
util_error (_("Can not create mailbox %s: %s"), args.file, |
406 |
mu_errstring (rc)); |
mu_errstring (rc)); |
407 |
exit (EXIT_FAILURE); |
exit (EXIT_FAILURE); |
408 |
} |
} |
419 |
{ |
{ |
420 |
url_t url = NULL; |
url_t url = NULL; |
421 |
mailbox_get_url (mbox, &url); |
mailbox_get_url (mbox, &url); |
422 |
util_error ("Can not open mailbox %s: %s", |
util_error (_("Can not open mailbox %s: %s"), |
423 |
url_to_string (url), mu_errstring (rc)); |
url_to_string (url), mu_errstring (rc)); |
424 |
exit (EXIT_FAILURE); |
exit (EXIT_FAILURE); |
425 |
} |
} |
432 |
{ |
{ |
433 |
url_t url = NULL; |
url_t url = NULL; |
434 |
mailbox_get_url (mbox, &url); |
mailbox_get_url (mbox, &url); |
435 |
util_error ("Can not read mailbox %s: %s", |
util_error (_("Can not read mailbox %s: %s"), |
436 |
url_to_string (url), mu_errstring (rc)); |
url_to_string (url), mu_errstring (rc)); |
437 |
exit (EXIT_FAILURE); |
exit (EXIT_FAILURE); |
438 |
} |
} |
450 |
if (total == 0) |
if (total == 0) |
451 |
{ |
{ |
452 |
if (args.file) |
if (args.file) |
453 |
fprintf (ofile, "%s: 0 messages\n", args.file); |
fprintf (ofile, _("%s: 0 messages\n"), args.file); |
454 |
else |
else |
455 |
fprintf (ofile, "No mail for %s\n", |
fprintf (ofile, _("No mail for %s\n"), |
456 |
args.user ? args.user : mail_whoami ()); |
args.user ? args.user : mail_whoami ()); |
457 |
return 1; |
return 1; |
458 |
} |
} |
512 |
} |
} |
513 |
} |
} |
514 |
|
|
|
static char warranty_stmt[] = |
|
|
"GNU mailutils - a suite of utilities for electronic mail\n\ |
|
|
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.\n\ |
|
|
\n\ |
|
|
This program is free software; you can redistribute it and/or modify\n\ |
|
|
it under the terms of the GNU General Public License as published by\n\ |
|
|
the Free Software Foundation; either version 2, or (at your option)\n\ |
|
|
any later version.\n\ |
|
|
\n\ |
|
|
This program is distributed in the hope that it will be useful,\n\ |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ |
|
|
GNU General Public License for more details.\n\ |
|
|
\n\ |
|
|
You should have received a copy of the GNU General Public License\n\ |
|
|
along with this program; if not, write to the Free Software\n\ |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"; |
|
|
|
|
515 |
int |
int |
516 |
mail_warranty(int argc, char **argv) |
mail_warranty (int argc, char **argv) |
517 |
{ |
{ |
518 |
(void)argc; (void)argv; |
(void)argc; (void)argv; |
519 |
fprintf (ofile, "%s", warranty_stmt); |
|
520 |
|
fputs (_("GNU Mailutils -- a suite of utilities for electronic mail\n" |
521 |
|
"Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.\n\n"), |
522 |
|
ofile); |
523 |
|
fputs (_("GNU Mailutils is free software; you can redistribute it and/or modify\n" |
524 |
|
"it under the terms of the GNU General Public License as published by\n" |
525 |
|
"the Free Software Foundation; either version 2, or (at your option)\n" |
526 |
|
"any later version.\n\n"), ofile); |
527 |
|
fputs (_("GNU Mailutils is distributed in the hope that it will be useful,\n" |
528 |
|
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" |
529 |
|
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" |
530 |
|
"GNU General Public License for more details.\n\n"), ofile); |
531 |
|
fputs (_("You should have received a copy of the GNU General Public License\n" |
532 |
|
"along with GNU Mailutils; if not, write to the Free Software\n" |
533 |
|
"Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"), ofile); |
534 |
return 0; |
return 0; |
535 |
} |
} |