Improve command module system in mu. Add a `help' command.
* mu/Makefile.am (MODULES): New variable. Put all commands there. (mu_SOURCES): Include $(MODULES). (EXTRA_DIST): Add mu-setup.h mu-setup.c mu-setup.awk (BUILT_SOURCES): New variable. (mu-setup.h, mu-setup.c): New goals. * mu/mu.c (doc): Remove command description: it is generated automatically. (mu_help_filter): New function. (argp): Use mu_help_filter. (mutool_action_tab): Remove. (mutool_nosys,find_action): Remove. (mu_help): New function. (main): Use dispatch_find_action. * mu/mu.h: Include mailutils/types.h (mutool_pop, mutool_filter, mutool_flt2047) (mutool_info, mutool_query, mutool_acl) (mutool_wicket, mutool_ldflags, mutool_cflags): Remove protos. (mu_help, dispatch_find_action, dispatch_docstring): New protos. * mu/acl.c: Add MU Setup comment. * mu/cflags.c: Likewise. * mu/filter.c: Likewise. * mu/flt2047.c: Likewise. * mu/info.c: Likewise. * mu/ldflags.c: Likewise. * mu/pop.c: Likewise. * mu/query.c: Likewise. * mu/wicket.c: Likewise. * mu/mu-setup.awk: New file. * mu/help.c: New file. * mu/dispatch.c: New file. * mu/.gitignore: Add mu-status.[ch] * po/POTFILES.in: Add mu/dispatch.c and mu/help.c.
Showing
18 changed files
with
346 additions
and
77 deletions
... | @@ -22,22 +22,28 @@ if MU_COND_SUPPORT_POP | ... | @@ -22,22 +22,28 @@ if MU_COND_SUPPORT_POP |
22 | POP_C=pop.c | 22 | POP_C=pop.c |
23 | endif | 23 | endif |
24 | 24 | ||
25 | EXTRA_DIST=pop.c | 25 | EXTRA_DIST=pop.c mu-setup.h mu-setup.c mu-setup.awk |
26 | BUILT_SOURCES=mu-setup.h mu-setup.c | ||
26 | 27 | ||
27 | mu_SOURCES = \ | 28 | MODULES = \ |
28 | acl.c\ | 29 | acl.c\ |
29 | cflags.c\ | 30 | cflags.c\ |
30 | info.c\ | ||
31 | mu.h\ | ||
32 | mu.c\ | ||
33 | filter.c\ | 31 | filter.c\ |
34 | flt2047.c\ | 32 | flt2047.c\ |
33 | help.c\ | ||
34 | info.c\ | ||
35 | ldflags.c\ | 35 | ldflags.c\ |
36 | $(POP_C)\ | 36 | $(POP_C)\ |
37 | query.c\ | 37 | query.c\ |
38 | shell.c\ | ||
39 | wicket.c | 38 | wicket.c |
40 | 39 | ||
40 | mu_SOURCES = \ | ||
41 | dispatch.c\ | ||
42 | mu.h\ | ||
43 | mu.c\ | ||
44 | shell.c\ | ||
45 | $(MODULES) | ||
46 | |||
41 | mu_LDADD = \ | 47 | mu_LDADD = \ |
42 | ${MU_APP_LIBRARIES}\ | 48 | ${MU_APP_LIBRARIES}\ |
43 | ${MU_LIB_MBOX}\ | 49 | ${MU_LIB_MBOX}\ |
... | @@ -61,3 +67,9 @@ AM_CPPFLAGS = \ | ... | @@ -61,3 +67,9 @@ AM_CPPFLAGS = \ |
61 | -DGUILE_LIBS="\"$(GUILE_LIBS)\"" \ | 67 | -DGUILE_LIBS="\"$(GUILE_LIBS)\"" \ |
62 | -DPYTHON_LIBS="\"$(PYTHON_LIBS)\"" \ | 68 | -DPYTHON_LIBS="\"$(PYTHON_LIBS)\"" \ |
63 | -DI18NLIBS="\"$(LIBINTL)\"" | 69 | -DI18NLIBS="\"$(LIBINTL)\"" |
70 | |||
71 | mu-setup.h: Makefile.am $(MODULES) | ||
72 | $(AM_V_GEN)$(AWK) -f $(top_srcdir)/mu/mu-setup.awk -v mode=h $(MODULES) > mu-setup.h | ||
73 | |||
74 | mu-setup.c: Makefile.am $(MODULES) | ||
75 | $(AM_V_GEN)$(AWK) -f $(top_srcdir)/mu/mu-setup.awk -v mode=c $(MODULES) > mu-setup.c | ... | ... |
... | @@ -30,6 +30,7 @@ | ... | @@ -30,6 +30,7 @@ |
30 | #include "xalloc.h" | 30 | #include "xalloc.h" |
31 | 31 | ||
32 | static char acl_doc[] = N_("mu acl - test access control lists."); | 32 | static char acl_doc[] = N_("mu acl - test access control lists."); |
33 | char acl_docstring[] = N_("test access control lists"); | ||
33 | static char acl_args_doc[] = N_("ADDRESS [ADDRESS...]"); | 34 | static char acl_args_doc[] = N_("ADDRESS [ADDRESS...]"); |
34 | 35 | ||
35 | static struct argp_option acl_options[] = { | 36 | static struct argp_option acl_options[] = { |
... | @@ -191,3 +192,10 @@ mutool_acl (int argc, char **argv) | ... | @@ -191,3 +192,10 @@ mutool_acl (int argc, char **argv) |
191 | 192 | ||
192 | return 0; | 193 | return 0; |
193 | } | 194 | } |
195 | |||
196 | /* | ||
197 | MU Setup: acl | ||
198 | mu-handler: mutool_acl | ||
199 | mu-docstring: acl_docstring | ||
200 | End MU Setup: | ||
201 | */ | ... | ... |
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | #include <argp.h> | 23 | #include <argp.h> |
24 | 24 | ||
25 | static char cflags_doc[] = N_("mu cflags - show compiler options"); | 25 | static char cflags_doc[] = N_("mu cflags - show compiler options"); |
26 | char cflags_docstring[] = N_("show compiler options"); | ||
26 | 27 | ||
27 | static struct argp cflags_argp = { | 28 | static struct argp cflags_argp = { |
28 | NULL, | 29 | NULL, |
... | @@ -43,4 +44,10 @@ mutool_cflags (int argc, char **argv) | ... | @@ -43,4 +44,10 @@ mutool_cflags (int argc, char **argv) |
43 | return 0; | 44 | return 0; |
44 | } | 45 | } |
45 | 46 | ||
47 | /* | ||
48 | MU Setup: cflags | ||
49 | mu-handler: mutool_cflags | ||
50 | mu-docstring: cflags_docstring | ||
51 | End MU Setup: | ||
52 | */ | ||
46 | 53 | ... | ... |
mu/dispatch.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2010 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/stream.h> | ||
23 | #include <mailutils/nls.h> | ||
24 | #include "mu.h" | ||
25 | #include "mu-setup.h" | ||
26 | #include "xalloc.h" | ||
27 | |||
28 | struct mutool_action_tab | ||
29 | { | ||
30 | const char *name; | ||
31 | mutool_action_t action; | ||
32 | const char *docstring; | ||
33 | }; | ||
34 | |||
35 | struct mutool_action_tab mutool_action_tab[] = { | ||
36 | #include "mu-setup.c" | ||
37 | { NULL } | ||
38 | }; | ||
39 | |||
40 | mutool_action_t | ||
41 | dispatch_find_action (const char *name) | ||
42 | { | ||
43 | struct mutool_action_tab *p; | ||
44 | |||
45 | for (p = mutool_action_tab; p->name; p++) | ||
46 | if (strcmp (p->name, name) == 0) | ||
47 | return p->action; | ||
48 | return NULL; | ||
49 | } | ||
50 | |||
51 | char * | ||
52 | dispatch_docstring (const char *text) | ||
53 | { | ||
54 | mu_stream_t str; | ||
55 | struct mutool_action_tab *p; | ||
56 | mu_off_t size; | ||
57 | size_t n; | ||
58 | char *ret; | ||
59 | |||
60 | mu_memory_stream_create (&str, MU_STREAM_RDWR); | ||
61 | mu_stream_printf (str, "%s\n%s\n\n", text, _("Commands are:")); | ||
62 | for (p = mutool_action_tab; p->name; p++) | ||
63 | mu_stream_printf (str, " mu %-16s - %s\n", | ||
64 | p->name, gettext (p->docstring)); | ||
65 | mu_stream_printf (str, "\n%s\n\n", | ||
66 | _("Try `mu COMMAND --help' to get help on a particular " | ||
67 | "COMMAND.")); | ||
68 | mu_stream_printf (str, "%s\n", _("Options are:")); | ||
69 | mu_stream_flush (str); | ||
70 | mu_stream_size (str, &size); | ||
71 | ret = xmalloc (size + 1); | ||
72 | mu_stream_seek (str, 0, MU_SEEK_SET, NULL); | ||
73 | mu_stream_read (str, ret, size, &n); | ||
74 | ret[n] = 0; | ||
75 | mu_stream_destroy (&str); | ||
76 | return ret; | ||
77 | } | ||
78 |
... | @@ -23,7 +23,8 @@ | ... | @@ -23,7 +23,8 @@ |
23 | #include "argp.h" | 23 | #include "argp.h" |
24 | #include "mu.h" | 24 | #include "mu.h" |
25 | 25 | ||
26 | static char filter_doc[] = N_("mu filter"); | 26 | static char filter_doc[] = N_("mu filter - apply a filter to the input"); |
27 | char filter_docstring[] = N_("apply a filter to the input"); | ||
27 | static char filter_args_doc[] = N_("NAME"); | 28 | static char filter_args_doc[] = N_("NAME"); |
28 | 29 | ||
29 | static struct argp_option filter_options[] = { | 30 | static struct argp_option filter_options[] = { |
... | @@ -157,3 +158,10 @@ mutool_filter (int argc, char **argv) | ... | @@ -157,3 +158,10 @@ mutool_filter (int argc, char **argv) |
157 | 158 | ||
158 | return 0; | 159 | return 0; |
159 | } | 160 | } |
161 | |||
162 | /* | ||
163 | MU Setup: filter | ||
164 | mu-handler: mutool_filter | ||
165 | mu-docstring: filter_docstring | ||
166 | End MU Setup: | ||
167 | */ | ... | ... |
... | @@ -24,6 +24,7 @@ | ... | @@ -24,6 +24,7 @@ |
24 | #include "mu.h" | 24 | #include "mu.h" |
25 | 25 | ||
26 | static char flt2047_doc[] = N_("mu 2047 - decode/encode message headers."); | 26 | static char flt2047_doc[] = N_("mu 2047 - decode/encode message headers."); |
27 | char flt2047_docstring[] = N_("decode/encode email message headers"); | ||
27 | static char flt2047_args_doc[] = N_("[text]"); | 28 | static char flt2047_args_doc[] = N_("[text]"); |
28 | 29 | ||
29 | static struct argp_option flt2047_options[] = { | 30 | static struct argp_option flt2047_options[] = { |
... | @@ -153,3 +154,10 @@ mutool_flt2047 (int argc, char **argv) | ... | @@ -153,3 +154,10 @@ mutool_flt2047 (int argc, char **argv) |
153 | 154 | ||
154 | return 0; | 155 | return 0; |
155 | } | 156 | } |
157 | |||
158 | /* | ||
159 | MU Setup: 2047 | ||
160 | mu-handler: mutool_flt2047 | ||
161 | mu-docstring: flt2047_docstring | ||
162 | End MU Setup: | ||
163 | */ | ... | ... |
mu/help.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2010 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/libargp.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 | static struct argp help_argp = { | ||
32 | NULL, | ||
33 | NULL, | ||
34 | help_args_doc, | ||
35 | help_doc, | ||
36 | NULL, | ||
37 | NULL, | ||
38 | NULL | ||
39 | }; | ||
40 | |||
41 | int | ||
42 | mutool_help (int argc, char **argv) | ||
43 | { | ||
44 | int index; | ||
45 | |||
46 | if (argp_parse (&help_argp, argc, argv, ARGP_IN_ORDER, &index, NULL)) | ||
47 | return 1; | ||
48 | |||
49 | if (index == argc - 1) | ||
50 | { | ||
51 | mutool_action_t action = dispatch_find_action (argv[index]); | ||
52 | if (!action) | ||
53 | { | ||
54 | mu_error (_("don't know what %s is"), argv[index]); | ||
55 | exit (1); | ||
56 | } | ||
57 | argv[0] = argv[index]; | ||
58 | argv[1] = "--help"; | ||
59 | return action (2, argv); | ||
60 | } | ||
61 | else if (argc != index) | ||
62 | { | ||
63 | mu_error (_("too many arguments")); | ||
64 | exit (1); | ||
65 | } | ||
66 | return mu_help (); | ||
67 | } | ||
68 | |||
69 | /* | ||
70 | MU Setup: help | ||
71 | mu-handler: mutool_help | ||
72 | mu-docstring: help_docstring | ||
73 | End MU Setup: | ||
74 | */ |
... | @@ -26,6 +26,7 @@ | ... | @@ -26,6 +26,7 @@ |
26 | static char info_doc[] = N_("mu info - print a list of configuration\ | 26 | static char info_doc[] = N_("mu info - print a list of configuration\ |
27 | options used to build mailutils; optional arguments are interpreted\ | 27 | options used to build mailutils; optional arguments are interpreted\ |
28 | as a list of configuration options to check for."); | 28 | as a list of configuration options to check for."); |
29 | char info_docstring[] = N_("show Mailutils configuration"); | ||
29 | static char info_args_doc[] = N_("[capa...]"); | 30 | static char info_args_doc[] = N_("[capa...]"); |
30 | 31 | ||
31 | static struct argp_option info_options[] = { | 32 | static struct argp_option info_options[] = { |
... | @@ -91,3 +92,10 @@ mutool_info (int argc, char **argv) | ... | @@ -91,3 +92,10 @@ mutool_info (int argc, char **argv) |
91 | } | 92 | } |
92 | return 0; | 93 | return 0; |
93 | } | 94 | } |
95 | |||
96 | /* | ||
97 | MU Setup: info | ||
98 | mu-handler: mutool_info | ||
99 | mu-docstring: info_docstring | ||
100 | End MU Setup: | ||
101 | */ | ... | ... |
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | #include <argp.h> | 23 | #include <argp.h> |
24 | 24 | ||
25 | static char ldflags_doc[] = N_("mu ldflags - list libraries required to link"); | 25 | static char ldflags_doc[] = N_("mu ldflags - list libraries required to link"); |
26 | char ldflags_docstring[] = N_("list libraries required to link"); | ||
26 | static char ldflags_args_doc[] = N_("KEYWORD [KEYWORD...]"); | 27 | static char ldflags_args_doc[] = N_("KEYWORD [KEYWORD...]"); |
27 | 28 | ||
28 | static struct argp ldflags_argp = { | 29 | static struct argp ldflags_argp = { |
... | @@ -191,3 +192,9 @@ mutool_ldflags (int argc, char **argv) | ... | @@ -191,3 +192,9 @@ mutool_ldflags (int argc, char **argv) |
191 | return 0; | 192 | return 0; |
192 | } | 193 | } |
193 | 194 | ||
195 | /* | ||
196 | MU Setup: ldflags | ||
197 | mu-handler: mutool_ldflags | ||
198 | mu-docstring: ldflags_docstring | ||
199 | End MU Setup: | ||
200 | */ | ... | ... |
mu/mu-setup.awk
0 → 100644
1 | # This file is part of GNU Mailutils. | ||
2 | # Copyright (C) 2010 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 | print "{", "\"" name "\",", setup[name,"handler"] ",", setup[name,"docstring"], "}," | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | |||
63 | |||
64 |
... | @@ -25,25 +25,7 @@ | ... | @@ -25,25 +25,7 @@ |
25 | #include "mu.h" | 25 | #include "mu.h" |
26 | 26 | ||
27 | static char args_doc[] = N_("COMMAND [CMDOPTS]"); | 27 | static char args_doc[] = N_("COMMAND [CMDOPTS]"); |
28 | static char doc[] = N_("mu -- GNU Mailutils multi-purpose tool.\n\ | 28 | static char doc[] = N_("mu -- GNU Mailutils multi-purpose tool."); |
29 | Commands are:\n\ | ||
30 | mu info - show Mailutils configuration\n\ | ||
31 | mu query - query configuration values\n\ | ||
32 | mu pop - POP3 client program\n\ | ||
33 | mu filter - filter program\n\ | ||
34 | mu 2047 - decode/encode message headers as per RFC 2047\n\ | ||
35 | mu acl - test access control lists\n\ | ||
36 | mu wicket - find matching URL in wicket\n\ | ||
37 | mu ldflags- list libraries required to link\n\ | ||
38 | mu cflags - list compiler flags\n\ | ||
39 | \n\ | ||
40 | Try `mu COMMAND --help' to get help on a particular COMMAND.\n\ | ||
41 | \n\ | ||
42 | Options are:\n"); | ||
43 | /* FIXME: add | ||
44 | mu imap | ||
45 | mu send [opts] | ||
46 | */ | ||
47 | 29 | ||
48 | static struct argp_option options[] = { | 30 | static struct argp_option options[] = { |
49 | { NULL } | 31 | { NULL } |
... | @@ -60,13 +42,31 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -60,13 +42,31 @@ parse_opt (int key, char *arg, struct argp_state *state) |
60 | return 0; | 42 | return 0; |
61 | } | 43 | } |
62 | 44 | ||
45 | static char * | ||
46 | mu_help_filter (int key, const char *text, void *input) | ||
47 | { | ||
48 | char *s; | ||
49 | |||
50 | switch (key) | ||
51 | { | ||
52 | case ARGP_KEY_HELP_PRE_DOC: | ||
53 | s = dispatch_docstring (text); | ||
54 | break; | ||
55 | |||
56 | default: | ||
57 | s = (char*) text; | ||
58 | } | ||
59 | return s; | ||
60 | } | ||
61 | |||
62 | |||
63 | static struct argp argp = { | 63 | static struct argp argp = { |
64 | options, | 64 | options, |
65 | parse_opt, | 65 | parse_opt, |
66 | args_doc, | 66 | args_doc, |
67 | doc, | 67 | doc, |
68 | NULL, | 68 | NULL, |
69 | NULL, | 69 | mu_help_filter, |
70 | NULL | 70 | NULL |
71 | }; | 71 | }; |
72 | 72 | ||
... | @@ -83,46 +83,16 @@ struct mu_cfg_param mu_tool_param[] = { | ... | @@ -83,46 +83,16 @@ struct mu_cfg_param mu_tool_param[] = { |
83 | { NULL } | 83 | { NULL } |
84 | }; | 84 | }; |
85 | 85 | ||
86 | struct mutool_action_tab | 86 | int |
87 | { | 87 | mu_help () |
88 | const char *name; | ||
89 | mutool_action_t action; | ||
90 | }; | ||
91 | |||
92 | static int | ||
93 | mutool_nosys (int argc, char **argv) | ||
94 | { | ||
95 | mu_error (_("%s is not available because required code is not compiled"), | ||
96 | argv[0]); | ||
97 | return 1; | ||
98 | } | ||
99 | |||
100 | struct mutool_action_tab mutool_action_tab[] = { | ||
101 | { "info", mutool_info }, | ||
102 | #ifdef ENABLE_POP | ||
103 | { "pop", mutool_pop }, | ||
104 | #else | ||
105 | { "pop", mutool_nosys }, | ||
106 | #endif | ||
107 | { "filter", mutool_filter }, | ||
108 | { "2047", mutool_flt2047 }, | ||
109 | { "query", mutool_query }, | ||
110 | { "acl", mutool_acl }, | ||
111 | { "wicket", mutool_wicket }, | ||
112 | { "ldflags", mutool_ldflags }, | ||
113 | { "cflags", mutool_cflags }, | ||
114 | { NULL } | ||
115 | }; | ||
116 | |||
117 | static mutool_action_t | ||
118 | find_action (const char *name) | ||
119 | { | 88 | { |
120 | struct mutool_action_tab *p; | 89 | char *x_argv[3]; |
121 | 90 | ||
122 | for (p = mutool_action_tab; p->name; p++) | 91 | x_argv[0] = (char*) mu_program_name; |
123 | if (strcmp (p->name, name) == 0) | 92 | x_argv[1] = "--help"; |
124 | return p->action; | 93 | x_argv[2] = NULL; |
125 | return NULL; | 94 | return mu_app_init (&argp, mu_tool_capa, mu_tool_param, |
95 | 2, x_argv, 0, NULL, NULL); | ||
126 | } | 96 | } |
127 | 97 | ||
128 | int | 98 | int |
... | @@ -155,7 +125,7 @@ main (int argc, char **argv) | ... | @@ -155,7 +125,7 @@ main (int argc, char **argv) |
155 | exit (1); | 125 | exit (1); |
156 | } | 126 | } |
157 | 127 | ||
158 | action = find_action (argv[0]); | 128 | action = dispatch_find_action (argv[0]); |
159 | if (!action) | 129 | if (!action) |
160 | { | 130 | { |
161 | mu_error (_("don't know what %s is"), argv[0]); | 131 | mu_error (_("don't know what %s is"), argv[0]); | ... | ... |
... | @@ -14,6 +14,8 @@ | ... | @@ -14,6 +14,8 @@ |
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 <mailutils/types.h> | ||
18 | |||
17 | typedef int (*mutool_action_t) (int argc, char **argv); | 19 | typedef int (*mutool_action_t) (int argc, char **argv); |
18 | 20 | ||
19 | struct mutool_command | 21 | struct mutool_command |
... | @@ -28,20 +30,13 @@ struct mutool_command | ... | @@ -28,20 +30,13 @@ struct mutool_command |
28 | const char *docstring;/* Documentation for this function. */ | 30 | const char *docstring;/* Documentation for this function. */ |
29 | }; | 31 | }; |
30 | 32 | ||
31 | |||
32 | int mutool_pop (int argc, char **argv); | ||
33 | int mutool_filter (int argc, char **argv); | ||
34 | int mutool_flt2047 (int argc, char **argv); | ||
35 | int mutool_info (int argc, char **argv); | ||
36 | int mutool_query (int argc, char **argv); | ||
37 | int mutool_acl (int argc, char **argv); | ||
38 | int mutool_wicket (int argc, char **argv); | ||
39 | int mutool_ldflags (int argc, char **argv); | ||
40 | int mutool_cflags (int argc, char **argv); | ||
41 | |||
42 | extern char *mutool_shell_prompt; | 33 | extern char *mutool_shell_prompt; |
43 | extern char **mutool_prompt_env; | 34 | extern char **mutool_prompt_env; |
44 | extern int mutool_shell_interactive; | 35 | extern int mutool_shell_interactive; |
45 | extern mu_stream_t mustrin, mustrout; | 36 | extern mu_stream_t mustrin, mustrout; |
46 | int mutool_shell (const char *name, struct mutool_command *cmd); | 37 | int mutool_shell (const char *name, struct mutool_command *cmd); |
47 | mu_stream_t mutool_open_pager (void); | 38 | mu_stream_t mutool_open_pager (void); |
39 | |||
40 | int mu_help (void); | ||
41 | mutool_action_t dispatch_find_action (const char *name); | ||
42 | char *dispatch_docstring (const char *text); | ... | ... |
... | @@ -28,6 +28,7 @@ | ... | @@ -28,6 +28,7 @@ |
28 | #include "xalloc.h" | 28 | #include "xalloc.h" |
29 | 29 | ||
30 | static char pop_doc[] = N_("mu pop - POP3 client shell."); | 30 | static char pop_doc[] = N_("mu pop - POP3 client shell."); |
31 | char pop_docstring[] = N_("POP3 client shell"); | ||
31 | static char pop_args_doc[] = ""; | 32 | static char pop_args_doc[] = ""; |
32 | 33 | ||
33 | static struct argp_option pop_options[] = { | 34 | static struct argp_option pop_options[] = { |
... | @@ -807,3 +808,10 @@ mutool_pop (int argc, char **argv) | ... | @@ -807,3 +808,10 @@ mutool_pop (int argc, char **argv) |
807 | mutool_shell ("pop", pop_comtab); | 808 | mutool_shell ("pop", pop_comtab); |
808 | return 0; | 809 | return 0; |
809 | } | 810 | } |
811 | |||
812 | /* | ||
813 | MU Setup: pop | ||
814 | mu-handler: mutool_pop | ||
815 | mu-docstring: pop_docstring | ||
816 | End MU Setup: | ||
817 | */ | ... | ... |
... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
25 | #include "mu.h" | 25 | #include "mu.h" |
26 | 26 | ||
27 | static char query_doc[] = N_("mu query - query configuration values."); | 27 | static char query_doc[] = N_("mu query - query configuration values."); |
28 | char query_docstring[] = N_("query configuration values"); | ||
28 | static char query_args_doc[] = N_("path [path...]"); | 29 | static char query_args_doc[] = N_("path [path...]"); |
29 | 30 | ||
30 | char *file_name; | 31 | char *file_name; |
... | @@ -119,3 +120,10 @@ mutool_query (int argc, char **argv) | ... | @@ -119,3 +120,10 @@ mutool_query (int argc, char **argv) |
119 | } | 120 | } |
120 | 121 | ||
121 | 122 | ||
123 | /* | ||
124 | MU Setup: query | ||
125 | mu-handler: mutool_query | ||
126 | mu-docstring: query_docstring | ||
127 | End MU Setup: | ||
128 | */ | ||
129 | ... | ... |
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | #include <argp.h> | 23 | #include <argp.h> |
24 | 24 | ||
25 | static char wicket_doc[] = N_("mu wicket - find matching URL in wicket"); | 25 | static char wicket_doc[] = N_("mu wicket - find matching URL in wicket"); |
26 | char wicket_docstring[] = N_("scan wickets for matching URLs"); | ||
26 | static char wicket_args_doc[] = N_("NAME"); | 27 | static char wicket_args_doc[] = N_("NAME"); |
27 | 28 | ||
28 | static struct argp_option wicket_options[] = { | 29 | static struct argp_option wicket_options[] = { |
... | @@ -172,3 +173,11 @@ mutool_wicket (int argc, char **argv) | ... | @@ -172,3 +173,11 @@ mutool_wicket (int argc, char **argv) |
172 | mu_stream_destroy (&stream); | 173 | mu_stream_destroy (&stream); |
173 | return exit_code; | 174 | return exit_code; |
174 | } | 175 | } |
176 | |||
177 | |||
178 | /* | ||
179 | MU Setup: wicket | ||
180 | mu-handler: mutool_wicket | ||
181 | mu-docstring: wicket_docstring | ||
182 | End MU Setup: | ||
183 | */ | ... | ... |
... | @@ -212,8 +212,10 @@ sieve/sieve.c | ... | @@ -212,8 +212,10 @@ sieve/sieve.c |
212 | sql/mysql.c | 212 | sql/mysql.c |
213 | 213 | ||
214 | mu/acl.c | 214 | mu/acl.c |
215 | mu/dispatch.c | ||
215 | mu/filter.c | 216 | mu/filter.c |
216 | mu/flt2047.c | 217 | mu/flt2047.c |
218 | mu/help.c | ||
217 | mu/info.c | 219 | mu/info.c |
218 | mu/mu.c | 220 | mu/mu.c |
219 | mu/pop.c | 221 | mu/pop.c | ... | ... |
-
Please register or sign in to post a comment