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 |
/* MH folder command */ |
/* MH folder command */ |
34 |
|
|
35 |
const char *argp_program_version = "folder (" PACKAGE_STRING ")"; |
const char *argp_program_version = "folder (" PACKAGE_STRING ")"; |
36 |
static char doc[] = "GNU MH folder"; |
static char doc[] = "GNU MH folder"; |
37 |
static char args_doc[] = "[action] [msg]"; |
static char args_doc[] = N_("[action] [msg]"); |
38 |
|
|
39 |
#define ARG_PUSH 1 |
#define ARG_PUSH 1 |
40 |
#define ARG_POP 2 |
#define ARG_POP 2 |
41 |
|
|
42 |
static struct argp_option options[] = { |
static struct argp_option options[] = { |
43 |
{"Actions are:", 0, 0, OPTION_DOC, "", 0 }, |
{N_("Actions are:"), 0, 0, OPTION_DOC, "", 0 }, |
44 |
{"print", 'p', NULL, 0, "List the folders (default)", 1 }, |
{"print", 'p', NULL, 0, N_("List the folders (default)"), 1 }, |
45 |
{"list", 'l', NULL, 0, "List the contents of the folder stack", 1}, |
{"list", 'l', NULL, 0, N_("List the contents of the folder stack"), 1}, |
46 |
{"push", ARG_PUSH, "FOLDER", OPTION_ARG_OPTIONAL, "Push the folder on the folder stack. If FOLDER is specified, it is pushed. Otherwise, if a folder is given in the command line (via + or --folder), it is pushed on stack. Otherwise, the current folder and the top of the folder stack are exchanged", 1}, |
{"push", ARG_PUSH, "FOLDER", OPTION_ARG_OPTIONAL, |
47 |
{"pop", ARG_POP, NULL, 0, "Pop the folder off the folder stack", 1}, |
N_("Push the folder on the folder stack. If FOLDER is specified, it is pushed. " |
48 |
|
"Otherwise, if a folder is given in the command line (via + or --folder), " |
49 |
|
"it is pushed on stack. Otherwise, the current folder and the top of the folder " |
50 |
|
"stack are exchanged"), 1}, |
51 |
|
{"pop", ARG_POP, NULL, 0, N_("Pop the folder off the folder stack"), 1}, |
52 |
|
|
53 |
{"Options are:", 0, 0, OPTION_DOC, "", 2 }, |
{N_("Options are:"), 0, 0, OPTION_DOC, "", 2 }, |
54 |
{"folder", 'f', "FOLDER", 0, "Specify folder to operate upon", 3}, |
{"folder", 'f', "FOLDER", 0, N_("Specify folder to operate upon"), 3}, |
55 |
{"all", 'a', NULL, 0, "List all folders", 3}, |
{"all", 'a', NULL, 0, N_("List all folders"), 3}, |
56 |
{"create", 'c', "BOOL", OPTION_ARG_OPTIONAL, "Create non-existing folders", 3}, |
{"create", 'c', "BOOL", OPTION_ARG_OPTIONAL, N_("Create non-existing folders"), 3}, |
57 |
{"fast", 'F', "BOOL", OPTION_ARG_OPTIONAL, "List only the folder names", 3}, |
{"fast", 'F', "BOOL", OPTION_ARG_OPTIONAL, N_("List only the folder names"), 3}, |
58 |
{"header", 'h', "BOOL", OPTION_ARG_OPTIONAL, "Print the header line", 3}, |
{"header", 'h', "BOOL", OPTION_ARG_OPTIONAL, N_("Print the header line"), 3}, |
59 |
{"recurse", 'r', "BOOL", OPTION_ARG_OPTIONAL, "Scan folders recursively", 3}, |
{"recurse", 'r', "BOOL", OPTION_ARG_OPTIONAL, N_("Scan folders recursively"), 3}, |
60 |
{"total", 't', "BOOL", OPTION_ARG_OPTIONAL, "Output the total statistics", 3}, |
{"total", 't', "BOOL", OPTION_ARG_OPTIONAL, N_("Output the total statistics"), 3}, |
61 |
{ "\nUse -help switch to obtain the list of traditional MH options. ", 0, 0, OPTION_DOC, "", 4 }, |
{ N_("\nUse -help switch to obtain the list of traditional MH options. "), 0, 0, OPTION_DOC, "", 4 }, |
62 |
|
|
63 |
{NULL}, |
{NULL}, |
64 |
}; |
}; |
250 |
|
|
251 |
if (!dir) |
if (!dir) |
252 |
{ |
{ |
253 |
mh_error ("can't scan folder %s: %s", name, strerror (errno)); |
mh_error (_("can't scan folder %s: %s"), name, strerror (errno)); |
254 |
return; |
return; |
255 |
} |
} |
256 |
|
|
267 |
{ |
{ |
268 |
asprintf (&p, "%s/%s", name, entry->d_name); |
asprintf (&p, "%s/%s", name, entry->d_name); |
269 |
if (stat (p, &st) < 0) |
if (stat (p, &st) < 0) |
270 |
mh_error ("can't stat %s: %s", p, strerror (errno)); |
mh_error (_("can't stat %s: %s"), p, strerror (errno)); |
271 |
else if (S_ISDIR (st.st_mode)) |
else if (S_ISDIR (st.st_mode)) |
272 |
{ |
{ |
273 |
info.others++; |
info.others++; |
324 |
if (info->message_count) |
if (info->message_count) |
325 |
{ |
{ |
326 |
printf (info->message_count == 1 ? |
printf (info->message_count == 1 ? |
327 |
" has %4lu message (%4lu-%4lu)" : |
_(" has %4lu message (%4lu-%4lu)") : |
328 |
" has %4lu messages (%4lu-%4lu)", |
_(" has %4lu messages (%4lu-%4lu)"), |
329 |
(unsigned long) info->message_count, |
(unsigned long) info->message_count, |
330 |
(unsigned long) info->min, |
(unsigned long) info->min, |
331 |
(unsigned long) info->max); |
(unsigned long) info->max); |
334 |
} |
} |
335 |
else |
else |
336 |
{ |
{ |
337 |
printf (" has no messages"); |
printf (_(" has no messages")); |
338 |
} |
} |
339 |
|
|
340 |
if (info->others) |
if (info->others) |
343 |
printf ("; "); |
printf ("; "); |
344 |
else |
else |
345 |
printf ("; "); |
printf ("; "); |
346 |
printf ("(others)"); |
printf (_("(others)")); |
347 |
} |
} |
348 |
printf (".\n"); |
printf (".\n"); |
349 |
} |
} |
401 |
print_all (); |
print_all (); |
402 |
|
|
403 |
if (print_total) |
if (print_total) |
404 |
printf ("\n%24.24s=%4lu messages in %4lu folders\n", |
printf (_("\n%24.24s=%4lu messages in %4lu folders\n"), |
405 |
"TOTAL", |
_("TOTAL"), |
406 |
(unsigned long) message_count, |
(unsigned long) message_count, |
407 |
(unsigned long) folder_info_count); |
(unsigned long) folder_info_count); |
408 |
} |
} |
485 |
{ |
{ |
486 |
int index = 0; |
int index = 0; |
487 |
mh_msgset_t msgset; |
mh_msgset_t msgset; |
488 |
|
|
489 |
|
/* Native Language Support */ |
490 |
|
mu_init_nls (); |
491 |
|
|
492 |
mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, |
mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, |
493 |
opt_handler, NULL, &index); |
opt_handler, NULL, &index); |
494 |
|
|
508 |
} |
} |
509 |
else if (argc - index > 1) |
else if (argc - index > 1) |
510 |
{ |
{ |
511 |
mh_error ("too many arguments"); |
mh_error (_("too many arguments")); |
512 |
exit (1); |
exit (1); |
513 |
} |
} |
514 |
|
|