Rewrite the mailutils tool
The subcommands are re-implemented as standalone binaries installed to pkglibexecdir. The main binary acts as a dispatcher. * configure.ac: Build mu/libexec/Makefile * include/mailutils/.gitignore: Ignore gitinfo.h * include/mailutils/opt.h (mu_parseopt_help_stream_create): New proto. * libmailutils/cli/cli.c (mu_cli_ext): Honor MU_PARSEOPT_PROG_NAME setting. * libmailutils/opt/help.c (mu_parseopt_create_help_stream): New function. (mu_program_help,mu_program_usage) (mu_program_version): Use it. * mu/Makefile.am: Move commands to separate executables under libexec. * mu/mu.c: Rewrite. * mu/dispatch.c: Remove. * mu/help.c: Remove. * mu/libexec/.gitignore: New file. * mu/libexec/Makefile.am: New file. * mu/libexec/getopt.c: New file. * mu/getans.c: Move to mu/libexec. * mu/getarg.c: Likewise. * mu/getyn.c: Likewise. * mu/util.c: Likewise. * mu/verbose.c: Likewise. * mu/shell.c: Likewise. * mu/mu.h: Remove. * mu/libexec/mu.h: New file. * mu/acl.c: Move to mu/libexec; Rewrite as a standalone program. * mu/cflags.c: Likewise. * mu/dbm.c: Likewise. * mu/filter.c: Likewise. * mu/flt2047.c: Likewise. * mu/imap.c: Likewise. * mu/info.c: Likewise. * mu/ldflags.c: Likewise. * mu/logger.c: Likewise. * mu/pop.c: Likewise. * mu/query.c: Likewise. * mu/send.c: Likewise. * mu/smtp.c: Likewise. * mu/stat.c: Likewise. * mu/wicket.c: Likewise. * mu/mu-setup.awk: Remove. * po/POTFILES.in: Update.
Showing
36 changed files
with
540 additions
and
589 deletions
... | @@ -1541,6 +1541,7 @@ AC_CONFIG_FILES([ | ... | @@ -1541,6 +1541,7 @@ AC_CONFIG_FILES([ |
1541 | mu-aux/mailutils.spec | 1541 | mu-aux/mailutils.spec |
1542 | sieve/Makefile | 1542 | sieve/Makefile |
1543 | mu/Makefile | 1543 | mu/Makefile |
1544 | mu/libexec/Makefile | ||
1544 | ]) | 1545 | ]) |
1545 | AC_OUTPUT | 1546 | AC_OUTPUT |
1546 | 1547 | ... | ... |
... | @@ -185,6 +185,9 @@ void mu_parseopt_error (struct mu_parseopt *po, char const *fmt, ...); | ... | @@ -185,6 +185,9 @@ void mu_parseopt_error (struct mu_parseopt *po, char const *fmt, ...); |
185 | int mu_parseopt_apply (struct mu_parseopt *p); | 185 | int mu_parseopt_apply (struct mu_parseopt *p); |
186 | void mu_parseopt_free (struct mu_parseopt *p); | 186 | void mu_parseopt_free (struct mu_parseopt *p); |
187 | 187 | ||
188 | int mu_parseopt_help_stream_create (mu_stream_t *retstr, | ||
189 | struct mu_parseopt *po, | ||
190 | mu_stream_t outstr); | ||
188 | unsigned mu_parseopt_getcolumn (const char *name); | 191 | unsigned mu_parseopt_getcolumn (const char *name); |
189 | 192 | ||
190 | void mu_option_describe_options (mu_stream_t str, struct mu_parseopt *p); | 193 | void mu_option_describe_options (mu_stream_t str, struct mu_parseopt *p); | ... | ... |
... | @@ -483,6 +483,7 @@ run_commit (void *item, void *data) | ... | @@ -483,6 +483,7 @@ run_commit (void *item, void *data) |
483 | | MU_PARSEOPT_BUG_ADDRESS \ | 483 | | MU_PARSEOPT_BUG_ADDRESS \ |
484 | | MU_PARSEOPT_EXTRA_INFO \ | 484 | | MU_PARSEOPT_EXTRA_INFO \ |
485 | | MU_PARSEOPT_VERSION_HOOK \ | 485 | | MU_PARSEOPT_VERSION_HOOK \ |
486 | | MU_PARSEOPT_PROG_NAME \ | ||
486 | | MU_PARSEOPT_NEGATION) | 487 | | MU_PARSEOPT_NEGATION) |
487 | 488 | ||
488 | void | 489 | void |
... | @@ -520,8 +521,13 @@ mu_cli_ext (int argc, char **argv, | ... | @@ -520,8 +521,13 @@ mu_cli_ext (int argc, char **argv, |
520 | /* Set program name */ | 521 | /* Set program name */ |
521 | if (!(hints.flags & MU_CFHINT_PROGRAM)) | 522 | if (!(hints.flags & MU_CFHINT_PROGRAM)) |
522 | { | 523 | { |
523 | mu_set_program_name (argv[0]); | 524 | if (pohint->po_flags & MU_PARSEOPT_PROG_NAME) |
524 | hints.program = (char*) mu_program_name; | 525 | hints.program = (char *) pohint->po_prog_name; |
526 | else | ||
527 | { | ||
528 | mu_set_program_name (argv[0]); | ||
529 | hints.program = (char*) mu_program_name; | ||
530 | } | ||
525 | hints.flags |= MU_CFHINT_PROGRAM; | 531 | hints.flags |= MU_CFHINT_PROGRAM; |
526 | } | 532 | } |
527 | 533 | ||
... | @@ -610,7 +616,9 @@ mu_cli_ext (int argc, char **argv, | ... | @@ -610,7 +616,9 @@ mu_cli_ext (int argc, char **argv, |
610 | po.po_version_hook = pohint->po_version_hook; | 616 | po.po_version_hook = pohint->po_version_hook; |
611 | if (flags & MU_PARSEOPT_NEGATION) | 617 | if (flags & MU_PARSEOPT_NEGATION) |
612 | po.po_negation = pohint->po_negation; | 618 | po.po_negation = pohint->po_negation; |
613 | 619 | if (flags & MU_PARSEOPT_PROG_NAME) | |
620 | po.po_prog_name = pohint->po_prog_name; | ||
621 | |||
614 | appd.setup = setup; | 622 | appd.setup = setup; |
615 | appd.hints = &hints; | 623 | appd.hints = &hints; |
616 | appd.append_tree = NULL; | 624 | appd.append_tree = NULL; | ... | ... |
... | @@ -345,19 +345,21 @@ mu_option_describe_options (mu_stream_t str, struct mu_parseopt *po) | ... | @@ -345,19 +345,21 @@ mu_option_describe_options (mu_stream_t str, struct mu_parseopt *po) |
345 | static void print_program_usage (struct mu_parseopt *po, int optsum, | 345 | static void print_program_usage (struct mu_parseopt *po, int optsum, |
346 | mu_stream_t str); | 346 | mu_stream_t str); |
347 | 347 | ||
348 | int | ||
349 | mu_parseopt_help_stream_create (mu_stream_t *retstr, | ||
350 | struct mu_parseopt *po, mu_stream_t outstr) | ||
351 | { | ||
352 | init_usage_vars (po); | ||
353 | return mu_wordwrap_stream_create (retstr, outstr, 0, rmargin); | ||
354 | } | ||
355 | |||
348 | void | 356 | void |
349 | mu_program_help (struct mu_parseopt *po, mu_stream_t outstr) | 357 | mu_program_help (struct mu_parseopt *po, mu_stream_t outstr) |
350 | { | 358 | { |
351 | mu_stream_t str; | 359 | mu_stream_t str; |
352 | int rc; | ||
353 | 360 | ||
354 | init_usage_vars (po); | 361 | if (mu_parseopt_help_stream_create (&str, po, outstr)) |
355 | 362 | abort (); | |
356 | rc = mu_wordwrap_stream_create (&str, outstr, 0, rmargin); | ||
357 | if (rc) | ||
358 | { | ||
359 | abort ();//FIXME | ||
360 | } | ||
361 | 363 | ||
362 | print_program_usage (po, 0, str); | 364 | print_program_usage (po, 0, str); |
363 | 365 | ||
... | @@ -575,16 +577,10 @@ print_program_usage (struct mu_parseopt *po, int optsum, mu_stream_t str) | ... | @@ -575,16 +577,10 @@ print_program_usage (struct mu_parseopt *po, int optsum, mu_stream_t str) |
575 | void | 577 | void |
576 | mu_program_usage (struct mu_parseopt *po, int optsum, mu_stream_t outstr) | 578 | mu_program_usage (struct mu_parseopt *po, int optsum, mu_stream_t outstr) |
577 | { | 579 | { |
578 | int rc; | ||
579 | mu_stream_t str; | 580 | mu_stream_t str; |
580 | |||
581 | init_usage_vars (po); | ||
582 | 581 | ||
583 | rc = mu_wordwrap_stream_create (&str, outstr, 0, rmargin); | 582 | if (mu_parseopt_help_stream_create (&str, po, outstr)) |
584 | if (rc) | 583 | abort (); |
585 | { | ||
586 | abort ();//FIXME | ||
587 | } | ||
588 | print_program_usage (po, optsum, str); | 584 | print_program_usage (po, optsum, str); |
589 | mu_stream_destroy (&str); | 585 | mu_stream_destroy (&str); |
590 | } | 586 | } |
... | @@ -592,16 +588,11 @@ mu_program_usage (struct mu_parseopt *po, int optsum, mu_stream_t outstr) | ... | @@ -592,16 +588,11 @@ mu_program_usage (struct mu_parseopt *po, int optsum, mu_stream_t outstr) |
592 | void | 588 | void |
593 | mu_program_version (struct mu_parseopt *po, mu_stream_t outstr) | 589 | mu_program_version (struct mu_parseopt *po, mu_stream_t outstr) |
594 | { | 590 | { |
595 | int rc; | ||
596 | mu_stream_t str; | 591 | mu_stream_t str; |
597 | |||
598 | init_usage_vars (po); | ||
599 | 592 | ||
600 | rc = mu_wordwrap_stream_create (&str, outstr, 0, rmargin); | 593 | if (mu_parseopt_help_stream_create (&str, po, outstr)) |
601 | if (rc) | 594 | abort (); |
602 | { | 595 | |
603 | abort ();//FIXME | ||
604 | } | ||
605 | po->po_version_hook (po, str); | 596 | po->po_version_hook (po, str); |
606 | 597 | ||
607 | mu_stream_destroy (&str); | 598 | mu_stream_destroy (&str); | ... | ... |
... | @@ -15,99 +15,15 @@ | ... | @@ -15,99 +15,15 @@ |
15 | ## You should have received a copy of the GNU General Public License | 15 | ## You should have received a copy of the GNU General Public License |
16 | ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | 16 | ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SUBDIRS = libexec | ||
19 | |||
18 | bin_PROGRAMS = mailutils | 20 | bin_PROGRAMS = mailutils |
19 | bin_SCRIPTS = mailutils-config | 21 | bin_SCRIPTS = mailutils-config |
22 | EXTRA_DIST = mailutils-config | ||
20 | 23 | ||
21 | IDLE_MODULES= | 24 | mailutils_SOURCES = mu.c |
22 | 25 | mailutils_CPPFLAGS = @MU_APP_COMMON_INCLUDES@ -DMAILUTILSDIR=\"$(pkglibexecdir)\" | |
23 | if MU_COND_SUPPORT_POP | ||
24 | POP_C=pop.c | ||
25 | else | ||
26 | IDLE_MODULES+=pop.c | ||
27 | endif | ||
28 | |||
29 | if MU_COND_SUPPORT_IMAP | ||
30 | IMAP_C=imap.c | ||
31 | else | ||
32 | IDLE_MODULES+=imap.c | ||
33 | endif | ||
34 | |||
35 | if MU_COND_DBM | ||
36 | DBM_C=dbm.c | ||
37 | LIBMU_DBM=../libmu_dbm/libmu_dbm.la | ||
38 | else | ||
39 | IDLE_MODULES+=dbm.c | ||
40 | endif | ||
41 | |||
42 | if MU_COND_SUPPORT_SMTP | ||
43 | SMTP_C=smtp.c | ||
44 | else | ||
45 | IDLE_MODULES+=smtp.c | ||
46 | endif | ||
47 | |||
48 | MODULES = \ | ||
49 | acl.c\ | ||
50 | cflags.c\ | ||
51 | $(DBM_C)\ | ||
52 | $(IMAP_C)\ | ||
53 | filter.c\ | ||
54 | flt2047.c\ | ||
55 | help.c\ | ||
56 | info.c\ | ||
57 | ldflags.c\ | ||
58 | logger.c\ | ||
59 | $(POP_C)\ | ||
60 | query.c\ | ||
61 | send.c\ | ||
62 | stat.c\ | ||
63 | $(SMTP_C)\ | ||
64 | wicket.c | ||
65 | |||
66 | mailutils_SOURCES = \ | ||
67 | dispatch.c\ | ||
68 | getans.c\ | ||
69 | getarg.c\ | ||
70 | getyn.c\ | ||
71 | mu.h\ | ||
72 | mu.c\ | ||
73 | shell.c\ | ||
74 | util.c\ | ||
75 | verbose.c\ | ||
76 | $(MODULES) | ||
77 | |||
78 | mailutils_LDADD = \ | ||
79 | ${MU_APP_LIBRARIES}\ | ||
80 | ${MU_LIB_MBOX}\ | ||
81 | ${MU_LIB_IMAP}\ | ||
82 | ${MU_LIB_POP}\ | ||
83 | ${MU_LIB_NNTP}\ | ||
84 | ${MU_LIB_MH}\ | ||
85 | ${MU_LIB_MAILDIR}\ | ||
86 | ${MU_LIB_MAILER}\ | ||
87 | ${MU_LIB_AUTH}\ | ||
88 | @MU_AUTHLIBS@\ | ||
89 | ${MU_LIB_MAILUTILS}\ | ||
90 | ${LIBMU_DBM} @DBMLIBS@\ | ||
91 | @READLINE_LIBS@ @MU_COMMON_LIBRARIES@ | ||
92 | |||
93 | AM_CPPFLAGS = \ | ||
94 | @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@\ | ||
95 | -DCOMPILE_FLAGS="\"-I$(includedir)\"" \ | ||
96 | -DLINK_FLAGS="\"-L$(libdir)\"" \ | ||
97 | -DLINK_POSTFLAGS="\"$(MU_LINK_POSTFLAGS)\"" \ | ||
98 | -DAUTHLIBS="\"$(MU_AUTHLIBS)\"" \ | ||
99 | -DGUILE_LIBS="\"$(GUILE_LIBS)\"" \ | ||
100 | -DPYTHON_LIBS="\"$(PYTHON_LIBS)\"" \ | ||
101 | -DI18NLIBS="\"$(LIBINTL)\"" \ | ||
102 | -DDBMLIBS="\"$(DBMLIBS)\"" | ||
103 | |||
104 | BUILT_SOURCES=mu-setup.c mu-setup.h | ||
105 | EXTRA_DIST=mu-setup.awk mu-setup.c mu-setup.h template.c mailutils-config | ||
106 | 26 | ||
107 | mu-setup.h: Makefile.am $(MODULES) $(IDLE_MODULES) | 27 | LDADD = ${MU_APP_LIBRARIES} ${MU_LIB_MAILUTILS} |
108 | $(AM_V_GEN)$(AWK) -f $(srcdir)/mu-setup.awk -v mode=h \ | ||
109 | $(MODULES) $(IDLE_MODULES) > mu-setup.h | ||
110 | 28 | ||
111 | mu-setup.c: Makefile.am $(MODULES) $(IDLE_MODULES) | 29 | AM_CPPFLAGS = @MU_APP_COMMON_INCLUDES@ |
112 | $(AM_V_GEN)$(AWK) -f $(srcdir)/mu-setup.awk -v mode=c \ | ||
113 | $(MODULES) $(IDLE_MODULES) > mu-setup.c | ... | ... |
mu/dispatch.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2010-2012, 2014-2017 Free Software Foundation, Inc. | ||
3 | |||
4 | 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 | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <stdlib.h> | ||
21 | #include <string.h> | ||
22 | #include <mailutils/alloc.h> | ||
23 | #include <mailutils/stream.h> | ||
24 | #include <mailutils/stdstream.h> | ||
25 | #include <mailutils/nls.h> | ||
26 | #include "mu.h" | ||
27 | #include "mu-setup.h" | ||
28 | |||
29 | struct mutool_action_tab | ||
30 | { | ||
31 | const char *name; | ||
32 | mutool_action_t action; | ||
33 | const char *docstring; | ||
34 | }; | ||
35 | |||
36 | struct mutool_action_tab mutool_action_tab[] = { | ||
37 | #include "mu-setup.c" | ||
38 | { NULL } | ||
39 | }; | ||
40 | |||
41 | mutool_action_t | ||
42 | dispatch_find_action (const char *name) | ||
43 | { | ||
44 | struct mutool_action_tab *p; | ||
45 | |||
46 | for (p = mutool_action_tab; p->name; p++) | ||
47 | if (strcmp (p->name, name) == 0) | ||
48 | return p->action; | ||
49 | return NULL; | ||
50 | } | ||
51 | |||
52 | void | ||
53 | subcommand_help (mu_stream_t str) | ||
54 | { | ||
55 | struct mutool_action_tab *p; | ||
56 | unsigned margin; | ||
57 | |||
58 | mu_stream_printf (str, "%s\n\n", _("Commands are:")); | ||
59 | for (p = mutool_action_tab; p->name; p++) | ||
60 | { | ||
61 | margin = 2; | ||
62 | mu_stream_ioctl (str, MU_IOCTL_WORDWRAPSTREAM, | ||
63 | MU_IOCTL_WORDWRAP_SET_MARGIN, | ||
64 | &margin); | ||
65 | mu_stream_printf (str, "%s %s", mu_program_name, p->name); | ||
66 | margin = 29; | ||
67 | mu_stream_ioctl (str, MU_IOCTL_WORDWRAPSTREAM, | ||
68 | MU_IOCTL_WORDWRAP_SET_MARGIN, | ||
69 | &margin); | ||
70 | mu_stream_printf (str, "%s", gettext (p->docstring)); | ||
71 | } | ||
72 | margin = 0; | ||
73 | mu_stream_ioctl (str, MU_IOCTL_WORDWRAPSTREAM, | ||
74 | MU_IOCTL_WORDWRAP_SET_MARGIN, | ||
75 | &margin); | ||
76 | mu_stream_printf (str, | ||
77 | _("\nTry `%s COMMAND --help' to get help on a particular " | ||
78 | "COMMAND.\n\n"), | ||
79 | mu_program_name); | ||
80 | mu_stream_printf (str, "%s\n", _("OPTIONs are:")); | ||
81 | } | ||
82 |
mu/help.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2010-2012, 2014-2017 Free Software Foundation, Inc. | ||
3 | |||
4 | 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 | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | /* mu help - specjalnie dla Wojtka :) */ | ||
18 | |||
19 | #if defined(HAVE_CONFIG_H) | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include <stdlib.h> | ||
23 | #include <mailutils/nls.h> | ||
24 | #include <mailutils/io.h> | ||
25 | #include "mu.h" | ||
26 | |||
27 | static char help_doc[] = N_("mu help - display a terse help summary"); | ||
28 | char help_docstring[] = N_("display a terse help summary"); | ||
29 | static char help_args_doc[] = N_("[COMMAND]"); | ||
30 | |||
31 | int | ||
32 | mutool_help (int argc, char **argv) | ||
33 | { | ||
34 | mu_action_getopt (&argc, &argv, NULL, help_doc, help_args_doc); | ||
35 | |||
36 | if (argc == 1) | ||
37 | { | ||
38 | char *hargv[3]; | ||
39 | mutool_action_t action = dispatch_find_action (argv[0]); | ||
40 | if (!action) | ||
41 | { | ||
42 | mu_error (_("don't know what %s is"), argv[0]); | ||
43 | exit (1); | ||
44 | } | ||
45 | hargv[0] = argv[0]; | ||
46 | hargv[1] = "--help"; | ||
47 | hargv[2] = NULL; | ||
48 | return action (3, hargv); | ||
49 | } | ||
50 | else if (argc > 1) | ||
51 | { | ||
52 | mu_error (_("too many arguments")); | ||
53 | exit (1); | ||
54 | } | ||
55 | return mu_help (); | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | MU Setup: help | ||
60 | mu-handler: mutool_help | ||
61 | mu-docstring: help_docstring | ||
62 | End MU Setup: | ||
63 | */ |
mu/libexec/.gitignore
0 → 100644
1 | /mailutils-* |
mu/libexec/Makefile.am
0 → 100644
1 | pkglibexec_PROGRAMS=\ | ||
2 | mailutils-acl\ | ||
3 | mailutils-cflags\ | ||
4 | mailutils-ldflags\ | ||
5 | mailutils-filter\ | ||
6 | mailutils-flt2047\ | ||
7 | mailutils-info\ | ||
8 | mailutils-logger\ | ||
9 | mailutils-query\ | ||
10 | mailutils-send\ | ||
11 | mailutils-smtp\ | ||
12 | mailutils-stat\ | ||
13 | mailutils-wicket | ||
14 | |||
15 | noinst_HEADERS = mu.h | ||
16 | noinst_LIBRARIES = libmutool.a | ||
17 | libmutool_a_SOURCES = \ | ||
18 | getopt.c\ | ||
19 | getans.c\ | ||
20 | getarg.c\ | ||
21 | getyn.c\ | ||
22 | shell.c\ | ||
23 | util.c\ | ||
24 | verbose.c | ||
25 | |||
26 | mailutils_acl_SOURCES = acl.c | ||
27 | mailutils_filter_SOURCES = filter.c | ||
28 | mailutils_flt2047_SOURCES = flt2047.c | ||
29 | mailutils_info_SOURCES = info.c | ||
30 | mailutils_logger_SOURCES = logger.c | ||
31 | mailutils_query_SOURCES = query.c | ||
32 | mailutils_wicket_SOURCES = wicket.c | ||
33 | |||
34 | mailutils_cflags_SOURCES=cflags.c | ||
35 | mailutils_cflags_CPPFLAGS = $(AM_CPPFLAGS)\ | ||
36 | -DCOMPILE_FLAGS="\"-I$(includedir)\"" | ||
37 | |||
38 | mailutils_ldflags_SOURCES=ldflags.c | ||
39 | mailutils_ldflags_CPPFLAGS = $(AM_CPPFLAGS)\ | ||
40 | -DLINK_FLAGS="\"-L$(libdir)\"" \ | ||
41 | -DLINK_POSTFLAGS="\"$(MU_LINK_POSTFLAGS)\"" \ | ||
42 | -DAUTHLIBS="\"$(MU_AUTHLIBS)\"" \ | ||
43 | -DGUILE_LIBS="\"$(GUILE_LIBS)\"" \ | ||
44 | -DPYTHON_LIBS="\"$(PYTHON_LIBS)\"" \ | ||
45 | -DI18NLIBS="\"$(LIBINTL)\"" \ | ||
46 | -DDBMLIBS="\"$(DBMLIBS)\"" | ||
47 | |||
48 | if MU_COND_DBM | ||
49 | pkglibexec_PROGRAMS += mailutils-dbm | ||
50 | mailutils_dbm_SOURCES = dbm.c | ||
51 | mailutils_dbm_LDFLAGS = \ | ||
52 | ${MU_APP_LIBRARIES}\ | ||
53 | ../../libmu_dbm/libmu_dbm.la\ | ||
54 | @DBMLIBS@\ | ||
55 | $(MUTOOL_LIBRARIES_TAIL) | ||
56 | endif | ||
57 | |||
58 | if MU_COND_SUPPORT_POP | ||
59 | pkglibexec_PROGRAMS += mailutils-pop | ||
60 | mailutils_pop_SOURCES = pop.c | ||
61 | mailutils_pop_CPPFLAGS = \ | ||
62 | $(AM_CPPFLAGS)\ | ||
63 | @MU_AUTHINCS@ | ||
64 | mailutils_pop_LDADD =\ | ||
65 | ${MU_APP_LIBRARIES}\ | ||
66 | ${MU_LIB_POP}\ | ||
67 | ${MU_LIB_AUTH}\ | ||
68 | @MU_AUTHLIBS@\ | ||
69 | $(MUTOOL_LIBRARIES_TAIL) | ||
70 | endif | ||
71 | |||
72 | if MU_COND_SUPPORT_IMAP | ||
73 | pkglibexec_PROGRAMS += mailutils-imap | ||
74 | mailutils_imap_SOURCES = imap.c | ||
75 | mailutils_imap_CPPFLAGS = \ | ||
76 | $(AM_CPPFLAGS)\ | ||
77 | @MU_AUTHINCS@ | ||
78 | mailutils_imap_LDADD =\ | ||
79 | ${MU_APP_LIBRARIES}\ | ||
80 | ${MU_LIB_IMAP}\ | ||
81 | ${MU_LIB_AUTH}\ | ||
82 | @MU_AUTHLIBS@\ | ||
83 | $(MUTOOL_LIBRARIES_TAIL) | ||
84 | endif | ||
85 | |||
86 | mailutils_send_SOURCES = send.c | ||
87 | mailutils_send_CPPFLAGS = \ | ||
88 | $(AM_CPPFLAGS)\ | ||
89 | @MU_AUTHINCS@ | ||
90 | mailutils_send_LDADD = \ | ||
91 | ${MU_APP_LIBRARIES}\ | ||
92 | ${MU_LIB_MAILER}\ | ||
93 | ${MU_LIB_AUTH}\ | ||
94 | @MU_AUTHLIBS@\ | ||
95 | $(MUTOOL_LIBRARIES_TAIL) | ||
96 | |||
97 | mailutils_stat_SOURCES = stat.c | ||
98 | mailutils_stat_LDADD = \ | ||
99 | ${MU_APP_LIBRARIES}\ | ||
100 | ${MU_LIB_MBOX}\ | ||
101 | ${MU_LIB_IMAP}\ | ||
102 | ${MU_LIB_POP}\ | ||
103 | ${MU_LIB_NNTP}\ | ||
104 | ${MU_LIB_MH}\ | ||
105 | ${MU_LIB_MAILDIR}\ | ||
106 | ${MU_LIB_AUTH}\ | ||
107 | @MU_AUTHLIBS@\ | ||
108 | $(MUTOOL_LIBRARIES_TAIL) | ||
109 | |||
110 | mailutils_smtp_SOURCES = smtp.c | ||
111 | mailutils_smtp_CPPFLAGS = \ | ||
112 | $(AM_CPPFLAGS)\ | ||
113 | @MU_AUTHINCS@ | ||
114 | mailutils_smtp_LDADD = \ | ||
115 | ${MU_APP_LIBRARIES}\ | ||
116 | ${MU_LIB_MAILER}\ | ||
117 | ${MU_LIB_AUTH}\ | ||
118 | @MU_AUTHLIBS@\ | ||
119 | $(MUTOOL_LIBRARIES_TAIL) | ||
120 | |||
121 | MUTOOL_LIBRARIES_TAIL = \ | ||
122 | ${MU_APP_LIBRARIES}\ | ||
123 | ./libmutool.a\ | ||
124 | ${MU_LIB_MAILUTILS}\ | ||
125 | @READLINE_LIBS@\ | ||
126 | @MU_COMMON_LIBRARIES@ | ||
127 | |||
128 | LDADD = ${MU_APP_LIBRARIES} $(MUTOOL_LIBRARIES_TAIL) | ||
129 | |||
130 | AM_CPPFLAGS = \ | ||
131 | @MU_APP_COMMON_INCLUDES@ |
... | @@ -14,6 +14,10 @@ | ... | @@ -14,6 +14,10 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #include <config.h> | ||
18 | #include <mailutils/mailutils.h> | ||
19 | #include <mailutils/nls.h> | ||
20 | #include <sysexits.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | char acl_docstring[] = N_("test access control lists"); | 23 | char acl_docstring[] = N_("test access control lists"); |
... | @@ -41,7 +45,7 @@ static struct mu_cfg_param acl_cfg_param[] = { | ... | @@ -41,7 +45,7 @@ static struct mu_cfg_param acl_cfg_param[] = { |
41 | }; | 45 | }; |
42 | 46 | ||
43 | int | 47 | int |
44 | mutool_acl (int argc, char **argv) | 48 | main (int argc, char **argv) |
45 | { | 49 | { |
46 | int rc; | 50 | int rc; |
47 | mu_acl_result_t result; | 51 | mu_acl_result_t result; |
... | @@ -126,10 +130,3 @@ mutool_acl (int argc, char **argv) | ... | @@ -126,10 +130,3 @@ mutool_acl (int argc, char **argv) |
126 | 130 | ||
127 | return 0; | 131 | return 0; |
128 | } | 132 | } |
129 | |||
130 | /* | ||
131 | MU Setup: acl | ||
132 | mu-handler: mutool_acl | ||
133 | mu-docstring: acl_docstring | ||
134 | End MU Setup: | ||
135 | */ | ... | ... |
... | @@ -14,12 +14,16 @@ | ... | @@ -14,12 +14,16 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #include <config.h> | ||
18 | #include <mailutils/mailutils.h> | ||
19 | #include <mailutils/nls.h> | ||
20 | #include <sysexits.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | char cflags_docstring[] = N_("show compiler options"); | 23 | char cflags_docstring[] = N_("show compiler options"); |
20 | 24 | ||
21 | int | 25 | int |
22 | mutool_cflags (int argc, char **argv) | 26 | main (int argc, char **argv) |
23 | { | 27 | { |
24 | mu_action_getopt (&argc, &argv, NULL, cflags_docstring, NULL); | 28 | mu_action_getopt (&argc, &argv, NULL, cflags_docstring, NULL); |
25 | if (argc) | 29 | if (argc) |
... | @@ -31,10 +35,3 @@ mutool_cflags (int argc, char **argv) | ... | @@ -31,10 +35,3 @@ mutool_cflags (int argc, char **argv) |
31 | return 0; | 35 | return 0; |
32 | } | 36 | } |
33 | 37 | ||
34 | /* | ||
35 | MU Setup: cflags | ||
36 | mu-handler: mutool_cflags | ||
37 | mu-docstring: cflags_docstring | ||
38 | End MU Setup: | ||
39 | */ | ||
40 | ... | ... |
... | @@ -14,14 +14,17 @@ | ... | @@ -14,14 +14,17 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #include "mu.h" | 17 | #include <config.h> |
18 | #include <mailutils/mailutils.h> | ||
18 | #include <mailutils/dbm.h> | 19 | #include <mailutils/dbm.h> |
19 | #include <fnmatch.h> | 20 | #include <fnmatch.h> |
20 | #include <regex.h> | 21 | #include <regex.h> |
21 | #include <sys/stat.h> | 22 | #include <sys/stat.h> |
22 | #include <grp.h> | 23 | #include <grp.h> |
24 | #include <sysexits.h> | ||
25 | #include "mu.h" | ||
23 | 26 | ||
24 | static char dbm_doc[] = N_("mu dbm - DBM management tool\n" | 27 | static char dbm_doc[] = N_("DBM management tool\n" |
25 | "Valid COMMANDs are:\n" | 28 | "Valid COMMANDs are:\n" |
26 | "\n" | 29 | "\n" |
27 | " create or load - create the database\n" | 30 | " create or load - create the database\n" |
... | @@ -1765,7 +1768,7 @@ struct mu_kwd mode_tab[] = | ... | @@ -1765,7 +1768,7 @@ struct mu_kwd mode_tab[] = |
1765 | }; | 1768 | }; |
1766 | 1769 | ||
1767 | int | 1770 | int |
1768 | mutool_dbm (int argc, char **argv) | 1771 | main (int argc, char **argv) |
1769 | { | 1772 | { |
1770 | int index; | 1773 | int index; |
1771 | 1774 | ||
... | @@ -1852,12 +1855,3 @@ mutool_dbm (int argc, char **argv) | ... | @@ -1852,12 +1855,3 @@ mutool_dbm (int argc, char **argv) |
1852 | return 0; | 1855 | return 0; |
1853 | } | 1856 | } |
1854 | 1857 | ||
1855 | /* | ||
1856 | MU Setup: dbm | ||
1857 | mu-handler: mutool_dbm | ||
1858 | mu-docstring: dbm_docstring | ||
1859 | mu-cond: ENABLE_DBM | ||
1860 | End MU Setup: | ||
1861 | */ | ||
1862 | |||
1863 | ... | ... |
... | @@ -92,7 +92,7 @@ negate_filter_mode (int mode) | ... | @@ -92,7 +92,7 @@ negate_filter_mode (int mode) |
92 | } | 92 | } |
93 | 93 | ||
94 | int | 94 | int |
95 | mutool_filter (int argc, char **argv) | 95 | main (int argc, char **argv) |
96 | { | 96 | { |
97 | int rc; | 97 | int rc; |
98 | mu_stream_t flt, prev_stream; | 98 | mu_stream_t flt, prev_stream; |
... | @@ -173,10 +173,3 @@ mutool_filter (int argc, char **argv) | ... | @@ -173,10 +173,3 @@ mutool_filter (int argc, char **argv) |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | |||
177 | /* | ||
178 | MU Setup: filter | ||
179 | mu-handler: mutool_filter | ||
180 | mu-docstring: filter_docstring | ||
181 | End MU Setup: | ||
182 | */ | ... | ... |
... | @@ -14,6 +14,10 @@ | ... | @@ -14,6 +14,10 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <mailutils/mailutils.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | char flt2047_docstring[] = N_("decode/encode email message headers"); | 23 | char flt2047_docstring[] = N_("decode/encode email message headers"); |
... | @@ -51,7 +55,7 @@ static struct mu_option flt2047_options[] = { | ... | @@ -51,7 +55,7 @@ static struct mu_option flt2047_options[] = { |
51 | }; | 55 | }; |
52 | 56 | ||
53 | int | 57 | int |
54 | mutool_flt2047 (int argc, char **argv) | 58 | main (int argc, char **argv) |
55 | { | 59 | { |
56 | int rc; | 60 | int rc; |
57 | char *p; | 61 | char *p; |
... | @@ -103,10 +107,3 @@ mutool_flt2047 (int argc, char **argv) | ... | @@ -103,10 +107,3 @@ mutool_flt2047 (int argc, char **argv) |
103 | 107 | ||
104 | return 0; | 108 | return 0; |
105 | } | 109 | } |
106 | |||
107 | /* | ||
108 | MU Setup: 2047 | ||
109 | mu-handler: mutool_flt2047 | ||
110 | mu-docstring: flt2047_docstring | ||
111 | End MU Setup: | ||
112 | */ | ... | ... |
File moved
File moved
mu/libexec/getopt.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2010-2012, 2014-2017 Free Software Foundation, Inc. | ||
3 | |||
4 | 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 | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #include <config.h> | ||
18 | #include <mailutils/mailutils.h> | ||
19 | #include <mailutils/nls.h> | ||
20 | |||
21 | static void | ||
22 | describe (struct mu_parseopt *po, struct mu_option *opt, char const *unused) | ||
23 | { | ||
24 | int len = strcspn (po->po_prog_doc, "\n"); | ||
25 | mu_printf ("%.*s\n", len, po->po_prog_doc); | ||
26 | exit (0); | ||
27 | } | ||
28 | |||
29 | struct mu_option common_options[] = { | ||
30 | { "describe", 0, NULL, MU_OPTION_HIDDEN, | ||
31 | "describe the program", | ||
32 | mu_c_string, NULL, describe }, | ||
33 | MU_OPTION_END | ||
34 | }; | ||
35 | |||
36 | void | ||
37 | mu_action_getopt (int *pargc, char ***pargv, struct mu_option *opt, | ||
38 | char const *docstring, char const *argdoc) | ||
39 | { | ||
40 | static struct mu_parseopt pohint = { | ||
41 | .po_flags = MU_PARSEOPT_PACKAGE_NAME | ||
42 | | MU_PARSEOPT_PACKAGE_URL | ||
43 | | MU_PARSEOPT_BUG_ADDRESS | ||
44 | | MU_PARSEOPT_VERSION_HOOK, | ||
45 | .po_package_name = PACKAGE_NAME, | ||
46 | .po_package_url = PACKAGE_URL, | ||
47 | .po_bug_address = PACKAGE_BUGREPORT, | ||
48 | .po_version_hook = mu_version_hook | ||
49 | }; | ||
50 | static char *defcapa[] = { "debug", NULL }; | ||
51 | struct mu_cfg_parse_hints cfhint = { .flags = 0 }; | ||
52 | struct mu_option *options[3] = { common_options, opt, NULL }; | ||
53 | struct mu_cli_setup cli = { | ||
54 | .prog_doc = (char*) docstring, | ||
55 | .prog_args = (char*) argdoc, | ||
56 | .optv = options | ||
57 | }; | ||
58 | char *p; | ||
59 | |||
60 | p = getenv ("MAILUTILS_PROGNAME"); | ||
61 | if (p) | ||
62 | { | ||
63 | pohint.po_flags |= MU_PARSEOPT_PROG_NAME; | ||
64 | pohint.po_prog_name = p; | ||
65 | } | ||
66 | |||
67 | MU_APP_INIT_NLS (); | ||
68 | mu_cli_ext (*pargc, *pargv, &cli, &pohint, &cfhint, defcapa, NULL, | ||
69 | pargc, pargv); | ||
70 | } | ||
71 | |||
72 |
File moved
... | @@ -1292,7 +1292,7 @@ struct mutool_command imap_comtab[] = { | ... | @@ -1292,7 +1292,7 @@ struct mutool_command imap_comtab[] = { |
1292 | }; | 1292 | }; |
1293 | 1293 | ||
1294 | int | 1294 | int |
1295 | mutool_imap (int argc, char **argv) | 1295 | main (int argc, char **argv) |
1296 | { | 1296 | { |
1297 | mu_action_getopt (&argc, &argv, NULL, imap_docstring, NULL); | 1297 | mu_action_getopt (&argc, &argv, NULL, imap_docstring, NULL); |
1298 | 1298 | ||
... | @@ -1308,11 +1308,3 @@ mutool_imap (int argc, char **argv) | ... | @@ -1308,11 +1308,3 @@ mutool_imap (int argc, char **argv) |
1308 | mutool_shell ("imap", imap_comtab); | 1308 | mutool_shell ("imap", imap_comtab); |
1309 | return 0; | 1309 | return 0; |
1310 | } | 1310 | } |
1311 | |||
1312 | /* | ||
1313 | MU Setup: imap | ||
1314 | mu-handler: mutool_imap | ||
1315 | mu-docstring: imap_docstring | ||
1316 | mu-cond: ENABLE_IMAP | ||
1317 | End MU Setup: | ||
1318 | */ | ... | ... |
... | @@ -14,12 +14,13 @@ | ... | @@ -14,12 +14,13 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <mailutils/mailutils.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | static char info_doc[] = N_("mu info - print a list of configuration\ | 23 | static char info_doc[] = N_("show Mailutils configuration"); |
20 | options used to build mailutils; optional arguments are interpreted\ | ||
21 | as a list of configuration options to check for."); | ||
22 | char info_docstring[] = N_("show Mailutils configuration"); | ||
23 | static char info_args_doc[] = N_("[capa...]"); | 24 | static char info_args_doc[] = N_("[capa...]"); |
24 | 25 | ||
25 | static int verbose; | 26 | static int verbose; |
... | @@ -32,7 +33,7 @@ static struct mu_option info_options[] = { | ... | @@ -32,7 +33,7 @@ static struct mu_option info_options[] = { |
32 | }; | 33 | }; |
33 | 34 | ||
34 | int | 35 | int |
35 | mutool_info (int argc, char **argv) | 36 | main (int argc, char **argv) |
36 | { | 37 | { |
37 | mu_action_getopt (&argc, &argv, info_options, info_doc, info_args_doc); | 38 | mu_action_getopt (&argc, &argv, info_options, info_doc, info_args_doc); |
38 | 39 | ||
... | @@ -55,10 +56,3 @@ mutool_info (int argc, char **argv) | ... | @@ -55,10 +56,3 @@ mutool_info (int argc, char **argv) |
55 | } | 56 | } |
56 | return 0; | 57 | return 0; |
57 | } | 58 | } |
58 | |||
59 | /* | ||
60 | MU Setup: info | ||
61 | mu-handler: mutool_info | ||
62 | mu-docstring: info_docstring | ||
63 | End MU Setup: | ||
64 | */ | ... | ... |
... | @@ -14,6 +14,10 @@ | ... | @@ -14,6 +14,10 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #include <config.h> | ||
18 | #include <mailutils/mailutils.h> | ||
19 | #include <mailutils/nls.h> | ||
20 | #include <sysexits.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | char ldflags_docstring[] = N_("list libraries required to link"); | 23 | char ldflags_docstring[] = N_("list libraries required to link"); |
... | @@ -121,7 +125,7 @@ sort_entries (void) | ... | @@ -121,7 +125,7 @@ sort_entries (void) |
121 | 125 | ||
122 | 126 | ||
123 | int | 127 | int |
124 | mutool_ldflags (int argc, char **argv) | 128 | main (int argc, char **argv) |
125 | { | 129 | { |
126 | int j; | 130 | int j; |
127 | 131 | ||
... | @@ -181,10 +185,3 @@ mutool_ldflags (int argc, char **argv) | ... | @@ -181,10 +185,3 @@ mutool_ldflags (int argc, char **argv) |
181 | mu_printf ("\n"); | 185 | mu_printf ("\n"); |
182 | return 0; | 186 | return 0; |
183 | } | 187 | } |
184 | |||
185 | /* | ||
186 | MU Setup: ldflags | ||
187 | mu-handler: mutool_ldflags | ||
188 | mu-docstring: ldflags_docstring | ||
189 | End MU Setup: | ||
190 | */ | ... | ... |
... | @@ -14,6 +14,10 @@ | ... | @@ -14,6 +14,10 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <mailutils/mailutils.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | char logger_docstring[] = N_("log data using Mailutils log facility"); | 23 | char logger_docstring[] = N_("log data using Mailutils log facility"); |
... | @@ -133,7 +137,7 @@ static struct mu_option logger_options[] = { | ... | @@ -133,7 +137,7 @@ static struct mu_option logger_options[] = { |
133 | }; | 137 | }; |
134 | 138 | ||
135 | int | 139 | int |
136 | mutool_logger (int argc, char **argv) | 140 | main (int argc, char **argv) |
137 | { | 141 | { |
138 | mu_stream_t logger, input; | 142 | mu_stream_t logger, input; |
139 | int rc, mode; | 143 | int rc, mode; |
... | @@ -202,13 +206,3 @@ mutool_logger (int argc, char **argv) | ... | @@ -202,13 +206,3 @@ mutool_logger (int argc, char **argv) |
202 | mu_stream_unref (logger); | 206 | mu_stream_unref (logger); |
203 | return !!rc; | 207 | return !!rc; |
204 | } | 208 | } |
205 | |||
206 | /* | ||
207 | MU Setup: logger | ||
208 | mu-handler: mutool_logger | ||
209 | mu-docstring: logger_docstring | ||
210 | End MU Setup: | ||
211 | */ | ||
212 | |||
213 | |||
214 | ... | ... |
... | @@ -18,18 +18,23 @@ | ... | @@ -18,18 +18,23 @@ |
18 | # include <config.h> | 18 | # include <config.h> |
19 | #endif | 19 | #endif |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <string.h> | 21 | #include <stdarg.h> |
22 | #include <sys/socket.h> | ||
23 | #include <netinet/in.h> | ||
24 | #include <sys/un.h> | ||
25 | #include <arpa/inet.h> | ||
26 | #include <sysexits.h> | ||
27 | #include <mailutils/mailutils.h> | 22 | #include <mailutils/mailutils.h> |
28 | 23 | ||
29 | typedef int (*mutool_action_t) (int argc, char **argv); | 24 | void mu_action_getopt (int *pargc, char ***pargv, struct mu_option *opt, |
25 | char const *docstring, char const *argdoc); | ||
26 | int mu_vgetans (const char *variants, const char *fmt, va_list ap); | ||
27 | int mu_getans (const char *variants, const char *fmt, ...); | ||
28 | int get_bool (const char *str, int *pb); | ||
29 | int get_port (const char *port_str, int *pn); | ||
30 | int mu_vgetyn (const char *fmt, va_list ap); | ||
31 | int mu_getyn (const char *fmt, ...); | ||
32 | int port_from_sa (struct mu_sockaddr *sa); | ||
30 | 33 | ||
31 | #define CMD_COALESCE_EXTRA_ARGS 0x01 | 34 | #define CMD_COALESCE_EXTRA_ARGS 0x01 |
32 | 35 | ||
36 | typedef int (*mutool_action_t) (int argc, char **argv); | ||
37 | |||
33 | struct mutool_command | 38 | struct mutool_command |
34 | { | 39 | { |
35 | const char *name; /* User printable name of the function. */ | 40 | const char *name; /* User printable name of the function. */ |
... | @@ -48,12 +53,6 @@ mu_assoc_t mutool_shell_prompt_assoc (void); | ... | @@ -48,12 +53,6 @@ mu_assoc_t mutool_shell_prompt_assoc (void); |
48 | int mutool_shell (const char *name, struct mutool_command *cmd); | 53 | int mutool_shell (const char *name, struct mutool_command *cmd); |
49 | mu_stream_t mutool_open_pager (void); | 54 | mu_stream_t mutool_open_pager (void); |
50 | 55 | ||
51 | int mu_help (void); | ||
52 | mutool_action_t dispatch_find_action (const char *name); | ||
53 | void subcommand_help (mu_stream_t str); | ||
54 | |||
55 | int port_from_sa (struct mu_sockaddr *sa); | ||
56 | |||
57 | 56 | ||
58 | #define VERBOSE_MASK(n) (1<<((n)+1)) | 57 | #define VERBOSE_MASK(n) (1<<((n)+1)) |
59 | #define SET_VERBOSE_MASK(n) (shell_verbose_flags |= VERBOSE_MASK (n)) | 58 | #define SET_VERBOSE_MASK(n) (shell_verbose_flags |= VERBOSE_MASK (n)) |
... | @@ -68,12 +67,4 @@ extern int shell_verbose_flags; | ... | @@ -68,12 +67,4 @@ extern int shell_verbose_flags; |
68 | int shell_verbose (int argc, char **argv, | 67 | int shell_verbose (int argc, char **argv, |
69 | void (*set_verbose) (void), void (*set_mask) (void)); | 68 | void (*set_verbose) (void), void (*set_mask) (void)); |
70 | 69 | ||
71 | |||
72 | int get_bool (const char *str, int *pb); | ||
73 | int get_port (const char *port_str, int *pn); | ||
74 | |||
75 | int mu_getans (const char *variants, const char *fmt, ...); | ||
76 | |||
77 | void mu_action_getopt (int *pargc, char ***pargv, struct mu_option *opt, | ||
78 | char const *docstring, char const *argdoc); | ||
79 | 70 | ... | ... |
... | @@ -597,8 +597,12 @@ struct mutool_command pop_comtab[] = { | ... | @@ -597,8 +597,12 @@ struct mutool_command pop_comtab[] = { |
597 | 597 | ||
598 | 598 | ||
599 | int | 599 | int |
600 | mutool_pop (int argc, char **argv) | 600 | main (int argc, char **argv) |
601 | { | 601 | { |
602 | |||
603 | mu_registrar_record (mu_pop_record); | ||
604 | mu_registrar_record (mu_pops_record); | ||
605 | |||
602 | mu_action_getopt (&argc, &argv, NULL, pop_docstring, NULL); | 606 | mu_action_getopt (&argc, &argv, NULL, pop_docstring, NULL); |
603 | 607 | ||
604 | if (argc) | 608 | if (argc) |
... | @@ -613,11 +617,3 @@ mutool_pop (int argc, char **argv) | ... | @@ -613,11 +617,3 @@ mutool_pop (int argc, char **argv) |
613 | mutool_shell ("pop", pop_comtab); | 617 | mutool_shell ("pop", pop_comtab); |
614 | return 0; | 618 | return 0; |
615 | } | 619 | } |
616 | |||
617 | /* | ||
618 | MU Setup: pop | ||
619 | mu-handler: mutool_pop | ||
620 | mu-docstring: pop_docstring | ||
621 | mu-cond: ENABLE_POP | ||
622 | End MU Setup: | ||
623 | */ | ... | ... |
... | @@ -14,6 +14,10 @@ | ... | @@ -14,6 +14,10 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <mailutils/mailutils.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | char query_docstring[] = N_("query configuration values"); | 23 | char query_docstring[] = N_("query configuration values"); |
... | @@ -45,7 +49,7 @@ static struct mu_option query_options[] = { | ... | @@ -45,7 +49,7 @@ static struct mu_option query_options[] = { |
45 | }; | 49 | }; |
46 | 50 | ||
47 | int | 51 | int |
48 | mutool_query (int argc, char **argv) | 52 | main (int argc, char **argv) |
49 | { | 53 | { |
50 | static struct mu_cfg_parse_hints hints; | 54 | static struct mu_cfg_parse_hints hints; |
51 | mu_cfg_tree_t *tree = NULL; | 55 | mu_cfg_tree_t *tree = NULL; |
... | @@ -89,12 +93,3 @@ mutool_query (int argc, char **argv) | ... | @@ -89,12 +93,3 @@ mutool_query (int argc, char **argv) |
89 | } | 93 | } |
90 | return 0; | 94 | return 0; |
91 | } | 95 | } |
92 | |||
93 | |||
94 | /* | ||
95 | MU Setup: query | ||
96 | mu-handler: mutool_query | ||
97 | mu-docstring: query_docstring | ||
98 | End MU Setup: | ||
99 | */ | ||
100 | ... | ... |
... | @@ -14,6 +14,10 @@ | ... | @@ -14,6 +14,10 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <mailutils/mailutils.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | static int read_recipients; | 23 | static int read_recipients; |
... | @@ -68,7 +72,7 @@ static struct mu_option send_options[] = { | ... | @@ -68,7 +72,7 @@ static struct mu_option send_options[] = { |
68 | }; | 72 | }; |
69 | 73 | ||
70 | int | 74 | int |
71 | mutool_send (int argc, char **argv) | 75 | main (int argc, char **argv) |
72 | { | 76 | { |
73 | char *infile; | 77 | char *infile; |
74 | mu_stream_t instr; | 78 | mu_stream_t instr; |
... | @@ -76,7 +80,9 @@ mutool_send (int argc, char **argv) | ... | @@ -76,7 +80,9 @@ mutool_send (int argc, char **argv) |
76 | size_t count; | 80 | size_t count; |
77 | mu_url_t urlhint, url; | 81 | mu_url_t urlhint, url; |
78 | mu_mailer_t mailer; | 82 | mu_mailer_t mailer; |
79 | 83 | ||
84 | MU_AUTH_REGISTER_ALL_MODULES (); | ||
85 | |||
80 | MU_ASSERT (mu_address_create_null (&rcpt_addr)); | 86 | MU_ASSERT (mu_address_create_null (&rcpt_addr)); |
81 | mu_register_all_mailer_formats (); | 87 | mu_register_all_mailer_formats (); |
82 | 88 | ... | ... |
File moved
... | @@ -908,7 +908,7 @@ struct mutool_command smtp_comtab[] = { | ... | @@ -908,7 +908,7 @@ struct mutool_command smtp_comtab[] = { |
908 | }; | 908 | }; |
909 | 909 | ||
910 | int | 910 | int |
911 | mutool_smtp (int argc, char **argv) | 911 | main (int argc, char **argv) |
912 | { | 912 | { |
913 | mu_registrar_record (mu_smtp_record); | 913 | mu_registrar_record (mu_smtp_record); |
914 | mu_registrar_record (mu_smtps_record); | 914 | mu_registrar_record (mu_smtps_record); |
... | @@ -929,10 +929,3 @@ mutool_smtp (int argc, char **argv) | ... | @@ -929,10 +929,3 @@ mutool_smtp (int argc, char **argv) |
929 | 929 | ||
930 | return 0; | 930 | return 0; |
931 | } | 931 | } |
932 | |||
933 | /* | ||
934 | MU Setup: smtp | ||
935 | mu-handler: mutool_smtp | ||
936 | mu-docstring: smtp_docstring | ||
937 | End MU Setup: | ||
938 | */ | ... | ... |
... | @@ -14,6 +14,11 @@ | ... | @@ -14,6 +14,11 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <mailutils/mailutils.h> | ||
21 | #include <sysexits.h> | ||
17 | #include "mu.h" | 22 | #include "mu.h" |
18 | 23 | ||
19 | char stat_docstring[] = N_("display mailbox status"); | 24 | char stat_docstring[] = N_("display mailbox status"); |
... | @@ -235,7 +240,7 @@ format_stat (char const *fmt, mu_mailbox_t mbx, const char *name) | ... | @@ -235,7 +240,7 @@ format_stat (char const *fmt, mu_mailbox_t mbx, const char *name) |
235 | } | 240 | } |
236 | 241 | ||
237 | int | 242 | int |
238 | mutool_stat (int argc, char **argv) | 243 | main (int argc, char **argv) |
239 | { | 244 | { |
240 | int rc; | 245 | int rc; |
241 | mu_mailbox_t mbox; | 246 | mu_mailbox_t mbox; |
... | @@ -363,20 +368,3 @@ get_name (mu_mailbox_t mbox, char const *mbname, mu_c_storage_t *cstor) | ... | @@ -363,20 +368,3 @@ get_name (mu_mailbox_t mbox, char const *mbname, mu_c_storage_t *cstor) |
363 | cstor->c_string = mu_strdup (mbname); | 368 | cstor->c_string = mu_strdup (mbname); |
364 | return 0; | 369 | return 0; |
365 | } | 370 | } |
366 | |||
367 | /* | ||
368 | MU Setup: stat | ||
369 | mu-handler: mutool_stat | ||
370 | mu-docstring: stat_docstring | ||
371 | End MU Setup: | ||
372 | */ | ||
373 | |||
374 | |||
375 | |||
376 | |||
377 | |||
378 | |||
379 | |||
380 | |||
381 | |||
382 | ... | ... |
File moved
File moved
... | @@ -14,6 +14,10 @@ | ... | @@ -14,6 +14,10 @@ |
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #if defined(HAVE_CONFIG_H) | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <mailutils/mailutils.h> | ||
17 | #include "mu.h" | 21 | #include "mu.h" |
18 | 22 | ||
19 | char wicket_docstring[] = N_("scan wickets for matching URLs"); | 23 | char wicket_docstring[] = N_("scan wickets for matching URLs"); |
... | @@ -97,7 +101,7 @@ wicket_match (mu_stream_t stream, const char *str) | ... | @@ -97,7 +101,7 @@ wicket_match (mu_stream_t stream, const char *str) |
97 | } | 101 | } |
98 | 102 | ||
99 | int | 103 | int |
100 | mutool_wicket (int argc, char **argv) | 104 | main (int argc, char **argv) |
101 | { | 105 | { |
102 | mu_stream_t stream; | 106 | mu_stream_t stream; |
103 | int rc, i, exit_code; | 107 | int rc, i, exit_code; |
... | @@ -142,11 +146,3 @@ mutool_wicket (int argc, char **argv) | ... | @@ -142,11 +146,3 @@ mutool_wicket (int argc, char **argv) |
142 | mu_stream_destroy (&stream); | 146 | mu_stream_destroy (&stream); |
143 | return exit_code; | 147 | return exit_code; |
144 | } | 148 | } |
145 | |||
146 | |||
147 | /* | ||
148 | MU Setup: wicket | ||
149 | mu-handler: mutool_wicket | ||
150 | mu-docstring: wicket_docstring | ||
151 | End MU Setup: | ||
152 | */ | ... | ... |
mu/mu-setup.awk
deleted
100644 → 0
1 | # This file is part of GNU Mailutils. | ||
2 | # Copyright (C) 2010-2012, 2014-2017 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 2, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | state == 0 && /MU Setup:/ { | ||
18 | if (NF != 3) { | ||
19 | print FILENAME ":" NR ":", "missing module name" > "/dev/stderr" | ||
20 | exit(1) | ||
21 | } else { | ||
22 | state = 1; | ||
23 | module_name=$3; | ||
24 | if (modules[module_name]) { | ||
25 | print FILENAME ":" NR ":", "this module already declared" > "/dev/stderr" | ||
26 | print modules[module_name] ":", "location of the prior declaration" > "/dev/stderr" | ||
27 | } else | ||
28 | modules[module_name] = (FILENAME":"NR); | ||
29 | } | ||
30 | } | ||
31 | state == 1 && /mu-.*:/ { | ||
32 | setup[module_name,substr($1,4,length($1)-4)] = $2; | ||
33 | next | ||
34 | } | ||
35 | state == 1 && /End MU Setup/ { state = 0 } | ||
36 | END { | ||
37 | print "/* -*- buffer-read-only: t -*- vi: set ro:" | ||
38 | print " THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT." | ||
39 | print "*/" | ||
40 | |||
41 | vartab[1] = "handler" | ||
42 | vartab[2] = "docstring" | ||
43 | n = asorti(modules,modname) | ||
44 | for (i = 1; i <= n; i++) { | ||
45 | name = modname[i] | ||
46 | for (j in vartab) { | ||
47 | if (!setup[name,vartab[j]]) { | ||
48 | print modules[name] ":", "mu-" vartab[j], "not defined" | ||
49 | err = 1 | ||
50 | } | ||
51 | } | ||
52 | if (err) | ||
53 | continue | ||
54 | if (mode == "h") { | ||
55 | print "extern int", setup[name,"handler"], "(int argc, char **argv);" | ||
56 | print "extern char " setup[name,"docstring"] "[];" | ||
57 | } else { | ||
58 | if (setup[name,"cond"]) | ||
59 | print "#ifdef", setup[name,"cond"] | ||
60 | print "{", "\"" name "\",", setup[name,"handler"] ",", setup[name,"docstring"], "}," | ||
61 | if (setup[name,"cond"]) | ||
62 | print "#endif" | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | |||
67 | |||
68 |
... | @@ -19,10 +19,117 @@ | ... | @@ -19,10 +19,117 @@ |
19 | #endif | 19 | #endif |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <sys/stat.h> | ||
22 | #include <mailutils/mailutils.h> | 23 | #include <mailutils/mailutils.h> |
23 | #include <mailutils/tls.h> | ||
24 | #include "mailutils/cli.h" | 24 | #include "mailutils/cli.h" |
25 | #include "mu.h" | 25 | #include <assert.h> |
26 | #include <glob.h> | ||
27 | |||
28 | char *mailutilsdir; | ||
29 | |||
30 | struct mu_tool | ||
31 | { | ||
32 | char *name; | ||
33 | char cmd[1]; | ||
34 | }; | ||
35 | |||
36 | #define MUTOOL_PREFIX "mailutils-" | ||
37 | |||
38 | mu_list_t | ||
39 | find_tools (char *pat) | ||
40 | { | ||
41 | mu_list_t tool_list; | ||
42 | char *fpat, *pattern; | ||
43 | glob_t gbuf; | ||
44 | |||
45 | mu_list_create (&tool_list); | ||
46 | mu_list_set_destroy_item (tool_list, mu_list_free_item); | ||
47 | |||
48 | fpat = mu_alloc (sizeof MUTOOL_PREFIX + strlen (pat)); | ||
49 | strcat (strcpy (fpat, MUTOOL_PREFIX), pat); | ||
50 | pattern = mu_make_file_name (mailutilsdir, fpat); | ||
51 | free (fpat); | ||
52 | |||
53 | if (glob (pattern, 0, NULL, &gbuf) == 0) | ||
54 | { | ||
55 | int i; | ||
56 | for (i = 0; i < gbuf.gl_pathc; i++) | ||
57 | { | ||
58 | char *p; | ||
59 | struct mu_tool *tp = mu_alloc (sizeof (*tp) + strlen (gbuf.gl_pathv[i])); | ||
60 | strcpy (tp->cmd, gbuf.gl_pathv[i]); | ||
61 | p = strrchr (tp->cmd, '/'); | ||
62 | assert (p != NULL); | ||
63 | tp->name = p + sizeof MUTOOL_PREFIX; | ||
64 | mu_list_push (tool_list, tp); | ||
65 | } | ||
66 | globfree (&gbuf); | ||
67 | } | ||
68 | |||
69 | return tool_list; | ||
70 | } | ||
71 | |||
72 | static int | ||
73 | mutool_comp (const void *a, const void *b) | ||
74 | { | ||
75 | struct mu_tool const *pa = a; | ||
76 | struct mu_tool const *pb = b; | ||
77 | return strcmp (pa->name, pb->name); | ||
78 | } | ||
79 | |||
80 | static int | ||
81 | show_help (void *item, void *data) | ||
82 | { | ||
83 | struct mu_tool *t = item; | ||
84 | mu_stream_t ostr = data; | ||
85 | mu_stream_t istr; | ||
86 | char *argv[3]; | ||
87 | int rc; | ||
88 | |||
89 | argv[0] = t->cmd; | ||
90 | argv[1] = "--describe"; | ||
91 | argv[2] = NULL; | ||
92 | rc = mu_prog_stream_create (&istr, t->cmd, | ||
93 | 2, argv, | ||
94 | 0, NULL, MU_STREAM_READ); | ||
95 | if (rc == 0) | ||
96 | { | ||
97 | unsigned margin; | ||
98 | |||
99 | margin = 2; | ||
100 | mu_stream_ioctl (ostr, MU_IOCTL_WORDWRAPSTREAM, | ||
101 | MU_IOCTL_WORDWRAP_SET_MARGIN, | ||
102 | &margin); | ||
103 | mu_stream_printf (ostr, "%s %s", mu_program_name, t->name); | ||
104 | |||
105 | margin = 29; | ||
106 | mu_stream_ioctl (ostr, MU_IOCTL_WORDWRAPSTREAM, | ||
107 | MU_IOCTL_WORDWRAP_SET_MARGIN, | ||
108 | &margin); | ||
109 | rc = mu_stream_copy (ostr, istr, 0, NULL); | ||
110 | if (rc) | ||
111 | mu_diag_funcall (MU_DIAG_ERR, "mu_stream_copy", t->cmd, rc); | ||
112 | |||
113 | mu_stream_destroy (&istr); | ||
114 | } | ||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | void | ||
119 | subcommand_help (mu_stream_t str) | ||
120 | { | ||
121 | mu_list_t tool_list = find_tools ("*"); | ||
122 | if (mu_list_is_empty (tool_list)) | ||
123 | { | ||
124 | mu_stream_printf (str, _("No commands found.\n")); | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | mu_list_sort (tool_list, mutool_comp); | ||
129 | mu_list_foreach (tool_list, show_help, str); | ||
130 | mu_list_destroy (&tool_list); | ||
131 | } | ||
132 | } | ||
26 | 133 | ||
27 | struct mu_cli_setup cli = { | 134 | struct mu_cli_setup cli = { |
28 | .prog_doc = N_("GNU Mailutils multi-purpose tool."), | 135 | .prog_doc = N_("GNU Mailutils multi-purpose tool."), |
... | @@ -31,108 +138,122 @@ struct mu_cli_setup cli = { | ... | @@ -31,108 +138,122 @@ struct mu_cli_setup cli = { |
31 | .prog_doc_hook = subcommand_help | 138 | .prog_doc_hook = subcommand_help |
32 | }; | 139 | }; |
33 | 140 | ||
34 | static char *capa[] = { | 141 | struct mu_parseopt pohint = { |
35 | "debug", | 142 | .po_flags = MU_PARSEOPT_PACKAGE_NAME |
36 | "locking", | 143 | | MU_PARSEOPT_PACKAGE_URL |
37 | "mailbox", | 144 | | MU_PARSEOPT_BUG_ADDRESS |
38 | "auth", | 145 | | MU_PARSEOPT_EXTRA_INFO |
39 | NULL | 146 | | MU_PARSEOPT_VERSION_HOOK, |
147 | .po_package_name = PACKAGE_NAME, | ||
148 | .po_package_url = PACKAGE_URL, | ||
149 | .po_bug_address = PACKAGE_BUGREPORT, | ||
150 | .po_extra_info = mu_general_help_text, | ||
151 | .po_version_hook = mu_version_hook, | ||
40 | }; | 152 | }; |
153 | struct mu_cfg_parse_hints cfhint = { .flags = 0 }; | ||
41 | 154 | ||
42 | int | 155 | int |
43 | main (int argc, char **argv) | 156 | main (int argc, char **argv) |
44 | { | 157 | { |
45 | mutool_action_t action; | 158 | size_t len; |
46 | static struct mu_parseopt pohint = { | 159 | mu_list_t tool_list; |
47 | .po_flags = MU_PARSEOPT_PACKAGE_NAME | 160 | size_t cnt; |
48 | | MU_PARSEOPT_PACKAGE_URL | 161 | struct mu_tool *tp; |
49 | | MU_PARSEOPT_BUG_ADDRESS | 162 | int rc; |
50 | | MU_PARSEOPT_EXTRA_INFO | 163 | char *str; |
51 | | MU_PARSEOPT_VERSION_HOOK, | ||
52 | .po_package_name = PACKAGE_NAME, | ||
53 | .po_package_url = PACKAGE_URL, | ||
54 | .po_bug_address = PACKAGE_BUGREPORT, | ||
55 | .po_extra_info = mu_general_help_text, | ||
56 | .po_version_hook = mu_version_hook, | ||
57 | }; | ||
58 | struct mu_cfg_parse_hints cfhint = { .flags = 0 }; | ||
59 | 164 | ||
165 | #define DEVSFX "/.libs/lt-mailutils" | ||
166 | #define DEVSFX_LEN (sizeof (DEVSFX) - 1) | ||
167 | #define SUBDIR "libexec" | ||
168 | #define SUBDIR_LEN (sizeof (SUBDIR) - 1) | ||
169 | len = strlen (argv[0]); | ||
170 | if (len > DEVSFX_LEN | ||
171 | && strcmp (argv[0] + len - DEVSFX_LEN, DEVSFX) == 0) | ||
172 | { | ||
173 | len -= DEVSFX_LEN; | ||
174 | mailutilsdir = mu_alloc (len + 1 + SUBDIR_LEN + 1); | ||
175 | memcpy (mailutilsdir, argv[0], len); | ||
176 | mailutilsdir[len++] = '/'; | ||
177 | strcpy (mailutilsdir + len, SUBDIR); | ||
178 | } | ||
179 | else | ||
180 | mailutilsdir = MAILUTILSDIR; | ||
181 | |||
60 | /* Native Language Support */ | 182 | /* Native Language Support */ |
61 | MU_APP_INIT_NLS (); | 183 | MU_APP_INIT_NLS (); |
62 | MU_AUTH_REGISTER_ALL_MODULES (); | ||
63 | |||
64 | /* Register the desired mailbox formats. */ | ||
65 | mu_register_all_mbox_formats (); | ||
66 | 184 | ||
67 | mu_cli_ext (argc, argv, &cli, &pohint, &cfhint, capa, NULL, &argc, &argv); | 185 | mu_cli_ext (argc, argv, &cli, &pohint, &cfhint, NULL, NULL, &argc, &argv); |
68 | 186 | ||
69 | if (argc < 1) | 187 | if (argc < 1) |
70 | { | 188 | { |
71 | mu_error (_("what do you want me to do?")); | 189 | mu_error (_("what do you want me to do?")); |
72 | exit (1); | 190 | exit (1); |
73 | } | 191 | } |
74 | 192 | ||
75 | action = dispatch_find_action (argv[0]); | 193 | if (strcmp (argv[0], "help") == 0) |
76 | if (!action) | ||
77 | { | 194 | { |
78 | mu_error (_("don't know what %s is"), argv[0]); | 195 | cli.prog_doc_hook = NULL; |
79 | exit (1); | 196 | cli.prog_doc = N_("display help on mailutils subcommands"); |
80 | } | 197 | cli.prog_args = N_("[COMMAND]"); |
198 | pohint.po_flags |= MU_PARSEOPT_PROG_NAME; | ||
199 | mu_asprintf (&str, "%s %s", mu_program_name, argv[0]); | ||
200 | pohint.po_prog_name = str; | ||
201 | |||
202 | mu_cli_ext (argc, argv, &cli, &pohint, &cfhint, | ||
203 | NULL, NULL, &argc, &argv); | ||
81 | 204 | ||
82 | /* Run the action. */ | 205 | if (argc == 0) |
83 | exit (action (argc, argv)); | 206 | { |
84 | } | 207 | mu_stream_t str; |
85 | 208 | unsigned margin; | |
86 | int | 209 | |
87 | mu_help (void) | 210 | if (mu_parseopt_help_stream_create (&str, &pohint, mu_strout)) |
88 | { | 211 | abort (); |
89 | char *argv[3]; | 212 | subcommand_help (str); |
90 | argv[0] = mu_full_program_name; | ||
91 | argv[1] = "--help"; | ||
92 | argv[2] = NULL; | ||
93 | mu_cli (2, argv, &cli, capa, NULL, NULL, NULL); | ||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | void | ||
98 | mu_action_getopt (int *pargc, char ***pargv, struct mu_option *opt, | ||
99 | char const *docstring, char const *argdoc) | ||
100 | { | ||
101 | struct mu_parseopt po; | ||
102 | int flags = MU_PARSEOPT_IMMEDIATE; | ||
103 | struct mu_option *options[2]; | ||
104 | char const *prog_args[2]; | ||
105 | char *progname; | ||
106 | |||
107 | options[0] = opt; | ||
108 | options[1] = NULL; | ||
109 | 213 | ||
110 | mu_asprintf (&progname, "%s %s", mu_program_name, (*pargv)[0]); | 214 | margin = 0; |
111 | po.po_prog_name = progname; | 215 | mu_stream_ioctl (str, MU_IOCTL_WORDWRAPSTREAM, |
112 | flags |= MU_PARSEOPT_PROG_NAME; | 216 | MU_IOCTL_WORDWRAP_SET_MARGIN, |
113 | 217 | &margin); | |
114 | po.po_prog_doc = docstring; | ||
115 | flags |= MU_PARSEOPT_PROG_DOC; | ||
116 | 218 | ||
117 | if (argdoc) | 219 | mu_stream_printf (str, "\n"); |
118 | { | 220 | mu_stream_printf (str, |
119 | prog_args[0] = argdoc; | 221 | _("Run `%s help COMMAND' to get help on a particular mailutils command."), |
120 | prog_args[1] = NULL; | 222 | mu_program_name); |
121 | po.po_prog_args = prog_args; | 223 | mu_stream_destroy (&str); |
122 | flags |= MU_PARSEOPT_PROG_ARGS; | 224 | exit (0); |
225 | } | ||
226 | else if (argc == 1) | ||
227 | { | ||
228 | argv--; | ||
229 | argv[0] = argv[1]; | ||
230 | argv[1] = "--help"; | ||
231 | argv[2] = NULL; | ||
232 | } | ||
233 | else | ||
234 | { | ||
235 | mu_error (_("too many arguments")); | ||
236 | exit (1); | ||
237 | } | ||
123 | } | 238 | } |
124 | 239 | ||
125 | po.po_bug_address = PACKAGE_BUGREPORT; | 240 | tool_list = find_tools (argv[0]); |
126 | flags |= MU_PARSEOPT_BUG_ADDRESS; | 241 | mu_list_count (tool_list, &cnt); |
127 | 242 | if (cnt != 1) | |
128 | if (mu_parseopt (&po, *pargc, *pargv, options, flags)) | 243 | { |
129 | exit (po.po_exit_error); | 244 | mu_error (_("don't know what %s is"), argv[0]); |
245 | exit (1); | ||
246 | } | ||
247 | rc = mu_list_head (tool_list, (void**) &tp); | ||
248 | if (rc) | ||
249 | { | ||
250 | mu_diag_funcall (MU_DIAG_CRIT, "mu_list_head", NULL, rc); | ||
251 | exit (2); | ||
252 | } | ||
130 | 253 | ||
131 | *pargc -= po.po_arg_start; | 254 | mu_asprintf (&str, "%s %s", mu_program_name, tp->name); |
132 | *pargv += po.po_arg_start; | 255 | setenv ("MAILUTILS_PROGNAME", str, 1); |
133 | 256 | execv (tp->cmd, argv); | |
134 | mu_parseopt_free (&po); | 257 | mu_diag_funcall (MU_DIAG_CRIT, "execv", tp->cmd, errno); |
258 | return 2; | ||
135 | } | 259 | } |
136 | |||
137 | |||
138 | ... | ... |
... | @@ -196,20 +196,19 @@ sieve/sieve.c | ... | @@ -196,20 +196,19 @@ sieve/sieve.c |
196 | 196 | ||
197 | sql/mysql.c | 197 | sql/mysql.c |
198 | 198 | ||
199 | mu/acl.c | ||
200 | mu/dispatch.c | ||
201 | mu/filter.c | ||
202 | mu/flt2047.c | ||
203 | mu/help.c | ||
204 | mu/info.c | ||
205 | mu/mu.c | 199 | mu/mu.c |
206 | mu/pop.c | 200 | mu/libexec/acl.c |
207 | mu/query.c | 201 | mu/libexec/filter.c |
208 | mu/shell.c | 202 | mu/libexec/flt2047.c |
209 | mu/cflags.c | 203 | mu/libexec/info.c |
210 | mu/ldflags.c | 204 | mu/libexec/pop.c |
211 | mu/wicket.c | 205 | mu/libexec/query.c |
212 | mu/logger.c | 206 | mu/libexec/shell.c |
207 | mu/libexec/cflags.c | ||
208 | mu/libexec/ldflags.c | ||
209 | mu/libexec/wicket.c | ||
210 | mu/libexec/logger.c | ||
211 | mu/libexec/stat.c | ||
213 | 212 | ||
214 | # EOF | 213 | # EOF |
215 | 214 | ... | ... |
-
Please register or sign in to post a comment