summaryrefslogtreecommitdiffabout
path: root/mh/mh_getopt.c
Side-by-side diff
Diffstat (limited to 'mh/mh_getopt.c') (more/less context) (ignore whitespace changes)
-rw-r--r--mh/mh_getopt.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/mh/mh_getopt.c b/mh/mh_getopt.c
index 65fe3e8..16a6e5c 100644
--- a/mh/mh_getopt.c
+++ b/mh/mh_getopt.c
@@ -179,10 +179,39 @@ has_folder_option (struct mu_option *opt)
return 0;
}
+static void
+opt_init (struct mu_parseopt *po,
+ struct mu_option **optv, struct mh_optinit *optinit)
+{
+ if (!optinit)
+ return;
+ for (; optinit->opt; optinit++)
+ {
+ size_t i;
+ for (i = 0; optv[i]; i++)
+ {
+ struct mu_option *opt;
+ for (opt = optv[i]; !MU_OPTION_IS_END (opt); opt++)
+ {
+ if (strcmp (opt->opt_long, optinit->opt) == 0)
+ {
+ char const *val = mh_global_profile_get (optinit->var, NULL);
+ if (val)
+ {
+ (opt->opt_set ?
+ opt->opt_set : mu_option_set_value) (po, opt, val);
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
void
-mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
- int mhflags,
- char *argdoc, char *progdoc, char *extradoc)
+mh_getopt_ext (int *pargc, char ***pargv, struct mu_option *options,
+ int mhflags, struct mh_optinit *optinit,
+ char *argdoc, char *progdoc, char *extradoc)
{
int argc = *pargc;
char **argv = *pargv;
@@ -256,6 +285,7 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
if (options)
optv[i++] = options;
optv[i] = NULL;
+ opt_init (&po, optv, optinit);
if (mu_parseopt (&po, argc, argv, optv, flags))
exit (po.po_exit_error);
@@ -285,6 +315,14 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
}
void
+mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
+ int mhflags, char *argdoc, char *progdoc, char *extradoc)
+{
+ mh_getopt_ext (pargc, pargv, options, mhflags, NULL, argdoc, progdoc,
+ extradoc);
+}
+
+void
mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
{
mu_error (_("option is not yet implemented: %s"), opt->opt_long);

Return to:

Send suggestions and report system problems to the System administrator.