Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 721 lines (583 sloc) 18.186 kB
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
1 /* -*-Mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
e55eb4e @djcb * MuResult/MuExitCode => MuError
authored
2
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
3 /*
b563128 * make colorized output the default
djcb authored
4 ** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
5 **
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 3, or (at your option) any
9 ** later version.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software Foundation,
18 ** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **
20 */
21
141b729 @djcb * add 'mu_runtime' for initialization, keeping global state during ru…
authored
22 #if HAVE_CONFIG_H
c2ff9b3 @djcb * mu-config: make cleanup the default, and nocleanup an option; + som…
authored
23 #include "config.h"
01ff6d4 @djcb * remove some of the lesser-used single-char versions of command line…
authored
24 #endif /*HAVE_CONFIG_H*/
c2ff9b3 @djcb * mu-config: make cleanup the default, and nocleanup an option; + som…
authored
25
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
26 #include <glib.h>
b7e3786 @djcb * mu-config.c: cosmetics
authored
27 #include <string.h> /* memset */
c60e03a @djcb * mu-config.[ch]: do tty-checking here (for --color), add mu_config_p…
authored
28 #include <unistd.h>
29 #include <stdio.h>
06ad732 @djcb * expand dir names (ie. ~/Maildir => /home/user/Maildir); add init/un…
authored
30
31 #include "mu-util.h"
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
32 #include "mu-config.h"
fade417 @djcb * many changes to the config system
authored
33 #include "mu-cmd.h"
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
34
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
35 static MuConfig MU_CONFIG;
36
0a6161a @djcb * centralize formatstr parsing, cleanup
authored
37 static MuConfigFormat
38 get_output_format (const char *formatstr)
39 {
40 int i;
41 struct {
42 const char* name;
43 MuConfigFormat format;
44 } formats [] = {
45 {"mutt-alias", MU_CONFIG_FORMAT_MUTT_ALIAS},
46 {"mutt-ab", MU_CONFIG_FORMAT_MUTT_AB},
47 {"wl", MU_CONFIG_FORMAT_WL},
48 {"csv", MU_CONFIG_FORMAT_CSV},
49 {"org-contact", MU_CONFIG_FORMAT_ORG_CONTACT},
50 {"bbdb", MU_CONFIG_FORMAT_BBDB},
51 {"links", MU_CONFIG_FORMAT_LINKS},
52 {"plain", MU_CONFIG_FORMAT_PLAIN},
53 {"sexp", MU_CONFIG_FORMAT_SEXP},
54 {"xml", MU_CONFIG_FORMAT_XML},
55 {"xquery", MU_CONFIG_FORMAT_XQUERY}
56 };
57
58 for (i = 0; i != G_N_ELEMENTS(formats); i++)
59 if (strcmp (formats[i].name, formatstr) == 0)
60 return formats[i].format;
61
62 return MU_CONFIG_FORMAT_UNKNOWN;
63 }
64
65
0b88f86 @djcb * mu-config.c: cosmetics
authored
66 static void
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
67 set_group_mu_defaults (void)
6408c63 @djcb * add --summary and --summary-len cmdline params
authored
68 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
69 gchar *exp;
6408c63 @djcb * add --summary and --summary-len cmdline params
authored
70
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
71 if (!MU_CONFIG.muhome)
72 MU_CONFIG.muhome = mu_util_guess_mu_homedir();
6408c63 @djcb * add --summary and --summary-len cmdline params
authored
73
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
74 exp = mu_util_dir_expand(MU_CONFIG.muhome);
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
75 if (exp) {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
76 g_free(MU_CONFIG.muhome);
77 MU_CONFIG.muhome = exp;
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
78 }
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
79
b563128 * make colorized output the default
djcb authored
80 /* check for the MU_NOCOLOR env var; but in any case don't
81 * use colors unless we're writing to a tty */
82 if (g_getenv (MU_NOCOLOR) != NULL)
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
83 MU_CONFIG.nocolor = TRUE;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
84
fc338b5 @djcb * mu-config: don't log ansi stuff when writing to non-tty's
authored
85 if (!isatty(fileno(stdout)) || !isatty(fileno(stderr)))
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
86 MU_CONFIG.nocolor = TRUE;
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
87 }
88
0b88f86 @djcb * mu-config.c: cosmetics
authored
89 static GOptionGroup*
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
90 config_options_group_mu (void)
b7e3786 @djcb * mu-config.c: cosmetics
authored
91 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
92 GOptionGroup *og;
93 GOptionEntry entries[] = {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
94 {"debug", 'd', 0, G_OPTION_ARG_NONE, &MU_CONFIG.debug,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
95 "print debug output to standard error (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
96 {"quiet", 'q', 0, G_OPTION_ARG_NONE, &MU_CONFIG.quiet,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
97 "don't give any progress information (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
98 {"version", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.version,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
99 "display version and copyright information (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
100 {"muhome", 0, 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.muhome,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
101 "specify an alternative mu directory", "<dir>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
102 {"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
103 "log to standard error (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
104 {"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
105 "don't use ANSI-colors in output (false)", NULL},
bf2585b @djcb * crypto: implement 'mu verify' command -- WIP
authored
106 {"verbose", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.verbose,
107 "verbose output (false)", NULL},
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
108
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
109 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
110 &MU_CONFIG.params, "parameters", NULL},
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
111 {NULL, 0, 0, 0, NULL, NULL, NULL}
112 };
113
114 og = g_option_group_new("mu", "general mu options", "", NULL, NULL);
115 g_option_group_add_entries(og, entries);
116
117 return og;
b7e3786 @djcb * mu-config.c: cosmetics
authored
118 }
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
119
dcb64c0 @djcb * mu-config: properly expand the dirs in mu find (--linksdir) and ext…
authored
120
121 #define expand_dir(D) \
122 if ((D)) { \
123 char *exp; \
124 exp = mu_util_dir_expand((D)); \
125 if (exp) { \
126 g_free((D)); \
127 (D) = exp; \
128 } \
129 }
130
131
132
0b88f86 @djcb * mu-config.c: cosmetics
authored
133 static void
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
134 set_group_index_defaults (void)
6408c63 @djcb * add --summary and --summary-len cmdline params
authored
135 {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
136 if (!MU_CONFIG.maildir)
137 MU_CONFIG.maildir = mu_util_guess_maildir ();
9c7d990 * mu-config.c: expand --maildir arguments
djcb authored
138
dcb64c0 @djcb * mu-config: properly expand the dirs in mu find (--linksdir) and ext…
authored
139 expand_dir (MU_CONFIG.maildir);
6408c63 @djcb * add --summary and --summary-len cmdline params
authored
140 }
141
0b88f86 @djcb * mu-config.c: cosmetics
authored
142 static GOptionGroup*
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
143 config_options_group_index (void)
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
144 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
145 GOptionGroup *og;
146 GOptionEntry entries[] = {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
147 {"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.maildir,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
148 "top of the maildir", "<maildir>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
149 {"reindex", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.reindex,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
150 "index even already indexed messages (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
151 {"rebuild", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.rebuild,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
152 "rebuild the database from scratch (false)", NULL},
6a1a63b @djcb * mu-config.c: restore the --summary-len option for mu view
authored
153 {"my-address", 0, 0, G_OPTION_ARG_STRING_ARRAY,
154 &MU_CONFIG.my_addresses,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
155 "my e-mail address (regexp); can be used multiple times",
156 "<address>"},
7d8a588 @djcb * some fixes for the help system
authored
157 {"autoupgrade", 0, 0, G_OPTION_ARG_NONE,
158 &MU_CONFIG.autoupgrade,
159 "auto-upgrade the database with new mu versions (false)",
160 NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
161 {"nocleanup", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocleanup,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
162 "don't clean up the database after indexing (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
163 {"xbatchsize", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.xbatchsize,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
164 "set transaction batchsize for xapian commits (0)", NULL},
7d8a588 @djcb * some fixes for the help system
authored
165 {"max-msg-size", 0, 0, G_OPTION_ARG_INT,
166 &MU_CONFIG.max_msg_size,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
167 "set the maximum size for message files", "<size>"},
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
168 {NULL, 0, 0, 0, NULL, NULL, NULL}
169 };
170
171 og = g_option_group_new("index",
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
172 "Options for the 'index' command",
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
173 "", NULL, NULL);
174 g_option_group_add_entries(og, entries);
175
176 return og;
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
177 }
178
0b88f86 @djcb * mu-config.c: cosmetics
authored
179 static void
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
180 set_group_find_defaults (void)
6408c63 @djcb * add --summary and --summary-len cmdline params
authored
181 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
182 /* note, when no fields are specified, we use
183 * date-from-subject, and sort descending by date. If fields
184 * *are* specified, we sort in ascending order. */
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
185 if (!MU_CONFIG.fields) {
186 MU_CONFIG.fields = "d f s";
187 if (!MU_CONFIG.sortfield)
188 MU_CONFIG.sortfield = "d";
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
189 }
6408c63 @djcb * add --summary and --summary-len cmdline params
authored
190
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
191 if (!MU_CONFIG.formatstr) /* by default, use plain output */
192 MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
0a6161a @djcb * centralize formatstr parsing, cleanup
authored
193 else
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
194 MU_CONFIG.format =
195 get_output_format (MU_CONFIG.formatstr);
dcb64c0 @djcb * mu-config: properly expand the dirs in mu find (--linksdir) and ext…
authored
196
197 expand_dir (MU_CONFIG.linksdir);
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
198 }
199
0b88f86 @djcb * mu-config.c: cosmetics
authored
200 static GOptionGroup*
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
201 config_options_group_find (void)
eaf8b1c @djcb * overhaul the configuration system (part 1)
authored
202 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
203 GOptionGroup *og;
204 GOptionEntry entries[] = {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
205 {"fields", 'f', 0, G_OPTION_ARG_STRING, &MU_CONFIG.fields,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
206 "fields to display in the output", "<fields>"},
7d8a588 @djcb * some fixes for the help system
authored
207 {"sortfield", 's', 0, G_OPTION_ARG_STRING,
208 &MU_CONFIG.sortfield,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
209 "field to sort on", "<field>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
210 {"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads,
9a5888f @djcb * enable the --threads/t argument for mu-find / queries
authored
211 "show message threads", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
212 {"bookmark", 'b', 0, G_OPTION_ARG_STRING, &MU_CONFIG.bookmark,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
213 "use a bookmarked query", "<bookmark>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
214 {"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse,
e2fc573 * src/, man/, NEWS: rename --descending into --reverse
Dirk-Jan C. Binnema authored
215 "sort in reverse (descending) order (z -> a)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
216 {"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
217 "output as symbolic links to a target maildir", "<dir>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
218 {"clearlinks", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.clearlinks,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
219 "clear old links before filling a linksdir (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
220 {"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
221 "output format ('plain'(*), 'links', 'xml',"
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
222 "'sexp', 'xquery')", "<format>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
223 {"exec", 'e', 0, G_OPTION_ARG_STRING, &MU_CONFIG.exec,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
224 "execute command on each match message", "<command>"},
a9df392 @djcb * mu find: add support for '--after', to only consider messages with …
authored
225 {"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after,
7d8a588 @djcb * some fixes for the help system
authored
226 "only show messages whose m_time > T (t_time)",
227 "<timestamp>"},
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
228 {NULL, 0, 0, 0, NULL, NULL, NULL}
229 };
230
231 og = g_option_group_new("find",
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
232 "Options for the 'find' command",
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
233 "", NULL, NULL);
234 g_option_group_add_entries(og, entries);
235
236 return og;
b1a9cf8 @djcb * refactoring, cleanup of the configuration / command system
authored
237 }
238
0b88f86 @djcb * mu-config.c: cosmetics
authored
239 static GOptionGroup *
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
240 config_options_group_mkdir (void)
b7e3786 @djcb * mu-config.c: cosmetics
authored
241 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
242 GOptionGroup *og;
243 GOptionEntry entries[] = {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
244 {"mode", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.dirmode,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
245 "set the mode (as in chmod), in octal notation", "<mode>"},
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
246 {NULL, 0, 0, 0, NULL, NULL, NULL}
247 };
b7e3786 @djcb * mu-config.c: cosmetics
authored
248
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
249 /* set dirmode before, because '0000' is a valid mode */
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
250 MU_CONFIG.dirmode = 0755;
b7e3786 @djcb * mu-config.c: cosmetics
authored
251
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
252 og = g_option_group_new("mkdir", "Options for the 'mkdir' command",
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
253 "", NULL, NULL);
254 g_option_group_add_entries(og, entries);
b7e3786 @djcb * mu-config.c: cosmetics
authored
255
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
256 return og;
b7e3786 @djcb * mu-config.c: cosmetics
authored
257 }
2ef4ceb @djcb * move config handling to mu-config, add --mode parameter for mkdir
authored
258
86971d5 @djcb * WIP: basic 'mu cfind' command + start of man page
authored
259
260 static void
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
261 set_group_cfind_defaults (void)
86971d5 @djcb * WIP: basic 'mu cfind' command + start of man page
authored
262 {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
263 if (!MU_CONFIG.formatstr) /* by default, use plain output */
264 MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
0a6161a @djcb * centralize formatstr parsing, cleanup
authored
265 else
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
266 MU_CONFIG.format = get_output_format (MU_CONFIG.formatstr);
86971d5 @djcb * WIP: basic 'mu cfind' command + start of man page
authored
267 }
268
269
270 static GOptionGroup *
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
271 config_options_group_cfind (void)
86971d5 @djcb * WIP: basic 'mu cfind' command + start of man page
authored
272 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
273 GOptionGroup *og;
274 GOptionEntry entries[] = {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
275 {"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
276 "output format ('plain'(*), 'mutt', 'wanderlust',"
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
277 "'org-contact', 'csv')", "<format>"},
2c99e59 @djcb * cfind: add support for the --after and --personal parameters, and d…
authored
278 {"personal", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.personal,
279 "whether to only get 'personal' contacts", NULL},
280 {"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
281 "only get addresses last seen after T", "<timestamp>"},
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
282 {NULL, 0, 0, 0, NULL, NULL, NULL}
283 };
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
284
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
285 og = g_option_group_new("cfind", "Options for the 'cfind' command",
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
286 "", NULL, NULL);
287 g_option_group_add_entries(og, entries);
86971d5 @djcb * WIP: basic 'mu cfind' command + start of man page
authored
288
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
289 return og;
86971d5 @djcb * WIP: basic 'mu cfind' command + start of man page
authored
290 }
291
292
0a6161a @djcb * centralize formatstr parsing, cleanup
authored
293 static void
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
294 set_group_view_defaults (void)
0a6161a @djcb * centralize formatstr parsing, cleanup
authored
295 {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
296 if (!MU_CONFIG.formatstr) /* by default, use plain output */
297 MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
0a6161a @djcb * centralize formatstr parsing, cleanup
authored
298 else
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
299 MU_CONFIG.format = get_output_format (MU_CONFIG.formatstr);
0a6161a @djcb * centralize formatstr parsing, cleanup
authored
300 }
301
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
302
303 /* crypto options are used in a few different commands */
304 static GOptionEntry*
305 crypto_option_entries (void)
306 {
307 static GOptionEntry entries[] = {
308 {"auto-retrieve", 'r', 0, G_OPTION_ARG_NONE,
309 &MU_CONFIG.auto_retrieve,
310 "attempt to retrieve keys online (false)", NULL},
311 {"use-agent", 'a', 0, G_OPTION_ARG_NONE, &MU_CONFIG.use_agent,
312 "attempt to use the GPG agent (false)", NULL},
313 {"decrypt", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.decrypt,
314 "attempt to decrypt the message", NULL},
315 {NULL, 0, 0, 0, NULL, NULL, NULL}
316 };
317
318 return entries;
319 }
320
321
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
322 static GOptionGroup *
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
323 config_options_group_view (void)
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
324 {
325 GOptionGroup *og;
326 GOptionEntry entries[] = {
6a1a63b @djcb * mu-config.c: restore the --summary-len option for mu view
authored
327 {"summary-len", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.summary_len,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
328 "use up to <n> lines for the summary, or 0 for none (0)",
329 "<len>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
330 {"terminate", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.terminator,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
331 "terminate messages with ascii-0x07 (\\f, form-feed)",
332 "<term>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
333 {"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
334 "output format ('plain'(*), 'sexp')", "<format>"},
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
335 {NULL, 0, 0, 0, NULL, NULL, NULL}
336 };
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
337
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
338 og = g_option_group_new("view", "Options for the 'view' command",
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
339 "", NULL, NULL);
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
340
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
341 g_option_group_add_entries(og, entries);
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
342 g_option_group_add_entries(og, crypto_option_entries());
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
343
344 return og;
345 }
346
347
86971d5 @djcb * WIP: basic 'mu cfind' command + start of man page
authored
348
dcb64c0 @djcb * mu-config: properly expand the dirs in mu find (--linksdir) and ext…
authored
349 static void
350 set_group_extract_defaults (void)
351 {
352 expand_dir (MU_CONFIG.targetdir);
353 }
354
355
356
0b88f86 @djcb * mu-config.c: cosmetics
authored
357 static GOptionGroup*
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
358 config_options_group_extract (void)
d5329d3 @djcb * mu-config: add some config options for mu extract
authored
359 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
360 GOptionGroup *og;
361 GOptionEntry entries[] = {
362 {"save-attachments", 'a', 0, G_OPTION_ARG_NONE,
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
363 &MU_CONFIG.save_attachments,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
364 "save all attachments (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
365 {"save-all", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.save_all,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
366 "save all parts (incl. non-attachments) (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
367 {"parts", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.parts,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
368 "save specific parts (comma-separated list)", "<parts>"},
7d8a588 @djcb * some fixes for the help system
authored
369 {"target-dir", 0, 0, G_OPTION_ARG_FILENAME,
370 &MU_CONFIG.targetdir,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
371 "target directory for saving", "<dir>"},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
372 {"overwrite", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.overwrite,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
373 "overwrite existing files (false)", NULL},
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
374 {"play", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.play,
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
375 "try to 'play' (open) the extracted parts", NULL},
376 {NULL, 0, 0, 0, NULL, NULL, NULL}
377 };
378
7d8a588 @djcb * some fixes for the help system
authored
379 MU_CONFIG.targetdir = g_strdup("."); /* default is the current dir */
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
380
381 og = g_option_group_new("extract",
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
382 "Options for the 'extract' command",
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
383 "", NULL, NULL);
384 g_option_group_add_entries(og, entries);
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
385 g_option_group_add_entries(og, crypto_option_entries());
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
386
387 return og;
d5329d3 @djcb * mu-config: add some config options for mu extract
authored
388 }
389
091dedf @djcb * make option parsing specific for the mu command
authored
390
93ec32d @djcb * mu-config.[ch]: support the new mu-server command
authored
391 static GOptionGroup*
bf2585b @djcb * crypto: implement 'mu verify' command -- WIP
authored
392 config_options_group_verify (void)
393 {
394 GOptionGroup *og;
395 og = g_option_group_new("verify",
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
396 "Options for the 'verify' command",
bf2585b @djcb * crypto: implement 'mu verify' command -- WIP
authored
397 "", NULL, NULL);
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
398 g_option_group_add_entries(og, crypto_option_entries());
bf2585b @djcb * crypto: implement 'mu verify' command -- WIP
authored
399
400 return og;
401 }
402
403
404 static GOptionGroup*
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
405 config_options_group_server (void)
93ec32d @djcb * mu-config.[ch]: support the new mu-server command
authored
406 {
407 GOptionGroup *og;
408 GOptionEntry entries[] = {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
409 {"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.maildir,
81c3724 @djcb * mu-config.c: use the GOptionArg arg_description
authored
410 "top of the maildir", "<maildir>"},
93ec32d @djcb * mu-config.[ch]: support the new mu-server command
authored
411 {NULL, 0, 0, 0, NULL, NULL, NULL}
412 };
413
414 og = g_option_group_new("server",
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
415 "Options for the 'server' command",
93ec32d @djcb * mu-config.[ch]: support the new mu-server command
authored
416 "", NULL, NULL);
417 g_option_group_add_entries(og, entries);
418
419 return og;
420 }
421
422
2f7f3a0 @djcb * add mu help command (WIP)
authored
423 static MuConfigCmd
424 cmd_from_string (const char *str)
091dedf @djcb * make option parsing specific for the mu command
authored
425 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
426 int i;
93ec32d @djcb * mu-config.[ch]: support the new mu-server command
authored
427 struct {
2f7f3a0 @djcb * add mu help command (WIP)
authored
428 const gchar* name;
429 MuConfigCmd cmd;
93ec32d @djcb * mu-config.[ch]: support the new mu-server command
authored
430 } cmd_map[] = {
bf2585b @djcb * crypto: implement 'mu verify' command -- WIP
authored
431 { "add", MU_CONFIG_CMD_ADD },
4707300 @djcb * added the mu mv command for moving, removing messages (WIP)
authored
432 { "cfind", MU_CONFIG_CMD_CFIND },
433 { "extract", MU_CONFIG_CMD_EXTRACT },
434 { "find", MU_CONFIG_CMD_FIND },
2f7f3a0 @djcb * add mu help command (WIP)
authored
435 { "help", MU_CONFIG_CMD_HELP },
4707300 @djcb * added the mu mv command for moving, removing messages (WIP)
authored
436 { "index", MU_CONFIG_CMD_INDEX },
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
437 { "mkdir", MU_CONFIG_CMD_MKDIR },
48cf82f @djcb * mu-cmd.c, mu-config.c: enable 'mu add' and 'mu remove' and fix line…
authored
438 { "remove", MU_CONFIG_CMD_REMOVE },
bf2585b @djcb * crypto: implement 'mu verify' command -- WIP
authored
439 { "server", MU_CONFIG_CMD_SERVER },
440 { "verify", MU_CONFIG_CMD_VERIFY },
441 { "view", MU_CONFIG_CMD_VIEW }
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
442 };
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
443
ca2fccf @djcb * mu: some better command error / help output
authored
444 if (!str)
445 return MU_CONFIG_CMD_UNKNOWN;
2f7f3a0 @djcb * add mu help command (WIP)
authored
446
447 for (i = 0; i != G_N_ELEMENTS(cmd_map); ++i)
448 if (strcmp (str, cmd_map[i].name) == 0)
449 return cmd_map[i].cmd;
450
451 return MU_CONFIG_CMD_UNKNOWN;
452 }
453
454
455
456 static gboolean
457 parse_cmd (int *argcp, char ***argvp)
458 {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
459 MU_CONFIG.cmd = MU_CONFIG_CMD_NONE;
460 MU_CONFIG.cmdstr = NULL;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
461
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
462 if (*argcp < 2) /* no command found at all */
463 return TRUE;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
464 else if ((**argvp)[1] == '-')
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
465 /* if the first param starts with '-', there is no
466 * command, just some option (like --version, --help
467 * etc.)*/
468 return TRUE;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
469
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
470 MU_CONFIG.cmdstr = (*argvp)[1];
2f7f3a0 @djcb * add mu help command (WIP)
authored
471 MU_CONFIG.cmd = cmd_from_string (MU_CONFIG.cmdstr);
fade417 @djcb * many changes to the config system
authored
472
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
473 return TRUE;
091dedf @djcb * make option parsing specific for the mu command
authored
474 }
475
476
2f7f3a0 @djcb * add mu help command (WIP)
authored
477 static GOptionGroup*
478 get_option_group (MuConfigCmd cmd)
b7e3786 @djcb * mu-config.c: cosmetics
authored
479 {
2f7f3a0 @djcb * add mu help command (WIP)
authored
480 switch (cmd) {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
481 case MU_CONFIG_CMD_INDEX:
2f7f3a0 @djcb * add mu help command (WIP)
authored
482 return config_options_group_index();
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
483 case MU_CONFIG_CMD_FIND:
2f7f3a0 @djcb * add mu help command (WIP)
authored
484 return config_options_group_find();
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
485 case MU_CONFIG_CMD_MKDIR:
2f7f3a0 @djcb * add mu help command (WIP)
authored
486 return config_options_group_mkdir();
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
487 case MU_CONFIG_CMD_EXTRACT:
2f7f3a0 @djcb * add mu help command (WIP)
authored
488 return config_options_group_extract();
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
489 case MU_CONFIG_CMD_CFIND:
2f7f3a0 @djcb * add mu help command (WIP)
authored
490 return config_options_group_cfind();
bf2585b @djcb * crypto: implement 'mu verify' command -- WIP
authored
491 case MU_CONFIG_CMD_VERIFY:
2f7f3a0 @djcb * add mu help command (WIP)
authored
492 return config_options_group_verify ();
2b56e46 @djcb * mu-config: add the --color option, to enable color output in some c…
authored
493 case MU_CONFIG_CMD_VIEW:
2f7f3a0 @djcb * add mu help command (WIP)
authored
494 return config_options_group_view();
93ec32d @djcb * mu-config.[ch]: support the new mu-server command
authored
495 case MU_CONFIG_CMD_SERVER:
2f7f3a0 @djcb * add mu help command (WIP)
authored
496 return config_options_group_server();
4ce44f6 @djcb * add 'mu server', which starts a process that accepts some commands
authored
497 default:
2f7f3a0 @djcb * add mu help command (WIP)
authored
498 return NULL; /* no group to add */
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
499 }
2f7f3a0 @djcb * add mu help command (WIP)
authored
500 }
501
502
503
1c2a87a @djcb * help: generate help texts from text file / awk
authored
504 /* ugh yuck massaging the GOption text output; glib prepares some text
505 * which has a 'Usage:' for the 'help' commmand. However, we need the
506 * help for the command we're asking help for. So, we remove the Usage:
507 * from what glib generates. :-( */
2f7f3a0 @djcb * add mu help command (WIP)
authored
508 static gchar*
509 massage_help (const char *help)
510 {
511 GRegex *rx;
512 char *str;
513
514 rx = g_regex_new ("^Usage:.*\n.*\n",
515 0, G_REGEX_MATCH_NEWLINE_ANY, NULL);
516 str = g_regex_replace (rx, help,
517 -1, 0, "",
518 G_REGEX_MATCH_NEWLINE_ANY, NULL);
519 g_regex_unref (rx);
520 return str;
521 }
522
523
ca2fccf @djcb * mu: some better command error / help output
authored
524
525 static const gchar*
526 get_help_string (MuConfigCmd cmd, gboolean long_help)
527 {
528 unsigned u;
529
530 /* this include gets us MU_HELP_STRINGS */
531 #include "mu-help-strings.h"
532
533 for (u = 0; u != G_N_ELEMENTS(MU_HELP_STRINGS); ++u)
534 if (cmd == MU_HELP_STRINGS[u].cmd) {
535 if (long_help)
536 return MU_HELP_STRINGS[u].long_help;
537 else
538 return MU_HELP_STRINGS[u].usage ;
539 }
540
541 g_return_val_if_reached ("");
542 return "";
543 }
544
545
546 void
547 mu_config_show_help (MuConfigCmd cmd)
2f7f3a0 @djcb * add mu help command (WIP)
authored
548 {
549 GOptionContext *ctx;
550 GOptionGroup *group;
551 char *cleanhelp;
552
7d8a588 @djcb * some fixes for the help system
authored
553 g_return_if_fail (mu_config_cmd_is_valid(cmd));
554
2f7f3a0 @djcb * add mu help command (WIP)
authored
555 ctx = g_option_context_new ("");
ca2fccf @djcb * mu: some better command error / help output
authored
556 g_option_context_set_main_group (ctx, config_options_group_mu());
557
2f7f3a0 @djcb * add mu help command (WIP)
authored
558 group = get_option_group (cmd);
559 if (group)
560 g_option_context_add_group (ctx, group);
561
ca2fccf @djcb * mu: some better command error / help output
authored
562 g_option_context_set_description (ctx,
563 get_help_string (cmd, TRUE));
2f7f3a0 @djcb * add mu help command (WIP)
authored
564 cleanhelp = massage_help
565 (g_option_context_get_help (ctx, TRUE, group));
566
ca2fccf @djcb * mu: some better command error / help output
authored
567 g_print ("usage:\n\t%s\n%s",
568 get_help_string (cmd, FALSE), cleanhelp);
569
2f7f3a0 @djcb * add mu help command (WIP)
authored
570 g_free (cleanhelp);
ca2fccf @djcb * mu: some better command error / help output
authored
571 }
2f7f3a0 @djcb * add mu help command (WIP)
authored
572
ca2fccf @djcb * mu: some better command error / help output
authored
573
574
575 static gboolean
576 cmd_help (void)
577 {
578 MuConfigCmd cmd;
579
580 cmd = cmd_from_string (MU_CONFIG.params[1]);
581 if (cmd == MU_CONFIG_CMD_UNKNOWN) {
582 mu_config_show_help (MU_CONFIG_CMD_HELP);
583 return TRUE;
584 }
585
586 mu_config_show_help (cmd);
2f7f3a0 @djcb * add mu help command (WIP)
authored
587 return TRUE;
ca2fccf @djcb * mu: some better command error / help output
authored
588 }
2f7f3a0 @djcb * add mu help command (WIP)
authored
589
ca2fccf @djcb * mu: some better command error / help output
authored
590
591 static void
592 show_usage (void)
593 {
594 g_print ("usage: mu <command> [options] [parameters]\n");
595 g_print ("try 'mu help <command>', or ");
596 g_print ("see the mu, mu-<command> or mu-easy manpages.\n");
1a504b5 @djcb * mu-config: some refactoring to satisfy make line33
authored
597 }
598
599
600 static gboolean
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
601 parse_params (int *argcp, char ***argvp)
1a504b5 @djcb * mu-config: some refactoring to satisfy make line33
authored
602 {
2f7f3a0 @djcb * add mu help command (WIP)
authored
603 GError *err;
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
604 GOptionContext *context;
605 gboolean rv;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
606
2f7f3a0 @djcb * add mu help command (WIP)
authored
607 context = g_option_context_new("- mu general options");
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
608 g_option_context_set_main_group(context, config_options_group_mu());
2f7f3a0 @djcb * add mu help command (WIP)
authored
609 g_option_context_set_help_enabled (context, TRUE);
610
611 err = NULL;
612
ca2fccf @djcb * mu: some better command error / help output
authored
613 if (MU_CONFIG.cmd == MU_CONFIG_CMD_NONE) {
614 show_usage ();
615 return TRUE;
616 }
617
2f7f3a0 @djcb * add mu help command (WIP)
authored
618 /* help is special */
619 if (MU_CONFIG.cmd == MU_CONFIG_CMD_HELP) {
620 rv = g_option_context_parse (context, argcp, argvp, &err) &&
ca2fccf @djcb * mu: some better command error / help output
authored
621 cmd_help ();
2f7f3a0 @djcb * add mu help command (WIP)
authored
622 } else {
623 GOptionGroup *group;
624 group = get_option_group (MU_CONFIG.cmd);
625 if (group)
626 g_option_context_add_group(context, group);
627 rv = g_option_context_parse (context, argcp, argvp, &err);
628 }
1a504b5 @djcb * mu-config: some refactoring to satisfy make line33
authored
629
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
630 g_option_context_free (context);
631 if (!rv) {
2f7f3a0 @djcb * add mu help command (WIP)
authored
632 g_printerr ("mu: error in options: %s\n",
633 err ? err->message : "?");
634 g_clear_error (&err);
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
635 return FALSE;
636 }
2f7f3a0 @djcb * add mu help command (WIP)
authored
637
6090bf8 @djcb * cosmetic
authored
638 return TRUE;
639 }
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
640
8262f2c @djcb * mu-config.[ch]: better option checking, default setting, fix some s…
authored
641
fade417 @djcb * many changes to the config system
authored
642 MuConfig*
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
643 mu_config_init (int *argcp, char ***argvp)
2ef4ceb @djcb * move config handling to mu-config, add --mode parameter for mkdir
authored
644 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
645 g_return_val_if_fail (argcp && argvp, NULL);
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
646
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
647 memset (&MU_CONFIG, 0, sizeof(MU_CONFIG));
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
648
2f7f3a0 @djcb * add mu help command (WIP)
authored
649 if (!parse_cmd (argcp, argvp))
650 goto errexit;
651
652 if (!parse_params(argcp, argvp))
653 goto errexit;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
654
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
655 /* fill in the defaults if user did not specify */
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
656 set_group_mu_defaults();
657 set_group_index_defaults();
658 set_group_find_defaults();
659 set_group_cfind_defaults();
660 set_group_view_defaults();
dcb64c0 @djcb * mu-config: properly expand the dirs in mu find (--linksdir) and ext…
authored
661 set_group_extract_defaults();
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
662 /* set_group_mkdir_defaults (config); */
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
663
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
664 return &MU_CONFIG;
2f7f3a0 @djcb * add mu help command (WIP)
authored
665
666 errexit:
667 mu_config_uninit (&MU_CONFIG);
668 return NULL;
2ef4ceb @djcb * move config handling to mu-config, add --mode parameter for mkdir
authored
669 }
06ad732 @djcb * expand dir names (ie. ~/Maildir => /home/user/Maildir); add init/un…
authored
670
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
671
0b88f86 @djcb * mu-config.c: cosmetics
authored
672 void
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
673 mu_config_uninit (MuConfig *opts)
06ad732 @djcb * expand dir names (ie. ~/Maildir => /home/user/Maildir); add init/un…
authored
674 {
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
675 if (!opts)
676 return;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
677
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
678 g_free (opts->muhome);
679 g_free (opts->maildir);
680 g_free (opts->linksdir);
681 g_free (opts->targetdir);
4ce44f6 @djcb * add 'mu server', which starts a process that accepts some commands
authored
682
f7a3915 @djcb * completely remove '--xquery', re-indent mu-config.c
authored
683 g_strfreev (opts->params);
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
684
685 memset (opts, 0, sizeof(MU_CONFIG));
fade417 @djcb * many changes to the config system
authored
686 }
687
688
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
689 size_t
690 mu_config_param_num (MuConfig *opts)
c60e03a @djcb * mu-config.[ch]: do tty-checking here (for --color), add mu_config_p…
authored
691 {
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
692 size_t n;
c7d7965 @djcb * mu-config: move command handling to mu-cmd
authored
693
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
694 g_return_val_if_fail (opts && opts->params, 0);
695 for (n = 0; opts->params[n]; ++n);
c60e03a @djcb * mu-config.[ch]: do tty-checking here (for --color), add mu_config_p…
authored
696
daaec40 @djcb * fix compiler warning for newest gcc/g++
authored
697 return n;
c60e03a @djcb * mu-config.[ch]: do tty-checking here (for --color), add mu_config_p…
authored
698 }
00dcfae @djcb * mu-config: add support for crypto options, decode message options
authored
699
700
701 MuMsgOptions
702 mu_config_get_msg_options (MuConfig *muopts)
703 {
704 MuMsgOptions opts;
705
706 opts = MU_MSG_OPTION_NONE;
707
708 if (muopts->decrypt)
709 opts |= MU_MSG_OPTION_DECRYPT;
710 if (muopts->verify)
711 opts |= MU_MSG_OPTION_VERIFY;
712 if (muopts->use_agent)
713 opts |= MU_MSG_OPTION_USE_AGENT;
714 if (muopts->auto_retrieve)
715 opts |= MU_MSG_OPTION_AUTO_RETRIEVE;
716 if (muopts->overwrite)
717 opts |= MU_MSG_OPTION_OVERWRITE;
718
719 return opts;
720 }
Something went wrong with that request. Please try again.