diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-12-16 00:02:14 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-12-16 00:02:14 +0200 |
commit | 96dc9ab99e9518f5f21a7710e396da8c3fd833b5 (patch) | |
tree | afc811d9f053e41d3747806eafafbda7be1f0017 /mh | |
parent | b66ffedcecf7506efc8631dfe1047c0a1d28af80 (diff) | |
download | mailutils-96dc9ab99e9518f5f21a7710e396da8c3fd833b5.tar.gz mailutils-96dc9ab99e9518f5f21a7710e396da8c3fd833b5.tar.bz2 |
Add TLS to MH. Handle --debug-level and --debug-line-info options.
* mailbox/mbx_default.c (attach_auth_ticket): Do not
proceed if auth is NULL.
* mh/mh_getopt.h (struct mh_argp_data): Change return type
and signature of handler.
(mh_argp_parse): Likewise.
* mh/mh_argp.c (parse_opt): Rewrite using new
handler prototype.
(mh_argp_parse): Use new hanlder type.
Assign argp children.
* mh/mh_init.c (mh_init): Call mu_init_tls_libs.
* mh/ali.c: Update opt_handler
* mh/anno.c: Update opt_handler
* mh/burst.c: Update opt_handler
* mh/comp.c: Update opt_handler
* mh/fmtcheck.c: Update opt_handler
* mh/folder.c: Update opt_handler
* mh/forw.c: Update opt_handler
* mh/inc.c: Update opt_handler
* mh/install-mh.c: Update opt_handler
* mh/mark.c: Update opt_handler
* mh/mhl.c: Update opt_handler
* mh/mhn.c: Update opt_handler
* mh/mhparam.c: Update opt_handler
* mh/mhpath.c: Update opt_handler
* mh/pick.c: Update opt_handler
* mh/refile.c: Update opt_handler
* mh/repl.c: Update opt_handler
* mh/rmf.c: Update opt_handler
* mh/rmm.c: Update opt_handler
* mh/scan.c: Update opt_handler
* mh/send.c: Update opt_handler
* mh/sortm.c: Update opt_handler
* mh/whatnow.c: Update opt_handler
* mh/whom.c: Update opt_handler
Diffstat (limited to 'mh')
-rw-r--r-- | mh/ali.c | 6 | ||||
-rw-r--r-- | mh/anno.c | 6 | ||||
-rw-r--r-- | mh/burst.c | 6 | ||||
-rw-r--r-- | mh/comp.c | 6 | ||||
-rw-r--r-- | mh/fmtcheck.c | 6 | ||||
-rw-r--r-- | mh/folder.c | 4 | ||||
-rw-r--r-- | mh/forw.c | 4 | ||||
-rw-r--r-- | mh/inc.c | 6 | ||||
-rw-r--r-- | mh/install-mh.c | 6 | ||||
-rw-r--r-- | mh/mark.c | 6 | ||||
-rw-r--r-- | mh/mh_argp.c | 70 | ||||
-rw-r--r-- | mh/mh_getopt.h | 5 | ||||
-rw-r--r-- | mh/mh_init.c | 4 | ||||
-rw-r--r-- | mh/mhl.c | 6 | ||||
-rw-r--r-- | mh/mhn.c | 6 | ||||
-rw-r--r-- | mh/mhparam.c | 6 | ||||
-rw-r--r-- | mh/mhpath.c | 6 | ||||
-rw-r--r-- | mh/pick.c | 6 | ||||
-rw-r--r-- | mh/refile.c | 4 | ||||
-rw-r--r-- | mh/repl.c | 6 | ||||
-rw-r--r-- | mh/rmf.c | 6 | ||||
-rw-r--r-- | mh/rmm.c | 6 | ||||
-rw-r--r-- | mh/scan.c | 6 | ||||
-rw-r--r-- | mh/send.c | 6 | ||||
-rw-r--r-- | mh/sortm.c | 6 | ||||
-rw-r--r-- | mh/whatnow.c | 6 | ||||
-rw-r--r-- | mh/whom.c | 6 |
27 files changed, 134 insertions, 83 deletions
@@ -64,8 +64,8 @@ static int user_mode; static int normalize_mode; static int nolist_mode; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -94,7 +94,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -58,8 +58,8 @@ static int anno_date = 1; /* Add date to the annotation */ static char *component; /* header field */ static char *anno_text; /* header field value */ -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -96,7 +96,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/burst.c b/mh/burst.c index e78f55c2a..4f93ed129 100644 --- a/mh/burst.c +++ b/mh/burst.c @@ -69,8 +69,8 @@ int eb_min_length = 1; /* Minimal length of encapsulation boundary */ #define VERBOSE(c) do { if (verbose) { printf c; putchar ('\n'); } } while (0) -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -121,7 +121,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -83,8 +83,8 @@ static int build_only = 0; /* --build flag */ static int use_draft = 0; /* --use flag */ static char *draftmessage = "new"; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -148,7 +148,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/fmtcheck.c b/mh/fmtcheck.c index ae8ea5381..2a01440b7 100644 --- a/mh/fmtcheck.c +++ b/mh/fmtcheck.c @@ -68,8 +68,8 @@ action_dump () static action_fp action = action_dump; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -94,7 +94,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/folder.c b/mh/folder.c index 1d51f52a4..a9fdf7ab7 100644 --- a/mh/folder.c +++ b/mh/folder.c @@ -136,7 +136,7 @@ size_t max_depth = 1; /* Maximum recursion depth (0 means infinity) */ #define OPTION_IS_SET(opt) ((opt) == -1 ? show_all : opt) static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -234,7 +234,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -117,7 +117,7 @@ static mh_msgset_t msgset; static mu_mailbox_t mbox; static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -214,7 +214,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -79,8 +79,8 @@ static int truncate_source = -1; static int quiet = 0; static const char *append_folder; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -147,7 +147,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/install-mh.c b/mh/install-mh.c index 0104ea089..68d3c7270 100644 --- a/mh/install-mh.c +++ b/mh/install-mh.c @@ -40,8 +40,8 @@ struct mh_option mh_option[] = { int automode; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -57,7 +57,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -75,8 +75,8 @@ add_sequence (char *name) mu_list_append (seq_list, name); } -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -121,7 +121,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/mh_argp.c b/mh/mh_argp.c index 1144ed514..be989a278 100644 --- a/mh/mh_argp.c +++ b/mh/mh_argp.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2002, 2005, - 2006, 2007 Free Software Foundation, Inc. + 2006, 2007, 2009 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,26 +33,25 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { struct mh_argp_data *data = state->input; + error_t ret = ARGP_ERR_UNKNOWN; + switch (key) { case ARGP_KEY_ARG: if (arg[0] == '+') - { - data->handler (ARG_FOLDER, arg + 1, data->closure); - break; - } - return ARGP_ERR_UNKNOWN; - + ret = data->handler (ARG_FOLDER, arg + 1, state); + break; + default: - if (data->handler (key, arg, data->closure, state) == 0) + ret = data->handler (key, arg, state); + if (ret == 0) { if (key == ARGP_KEY_ERROR) data->errind = state->next; - break; } - return ARGP_ERR_UNKNOWN; } - return 0; + + return ret; } static int @@ -101,13 +100,59 @@ mh_argp_init (const char *vers) argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; } + +enum + { + OPT_DEBUG_LEVEL = 256, + OPT_DEBUG_LINE_INFO, + }; + +static struct argp_option mu_debug_argp_options[] = +{ + { "debug-level", OPT_DEBUG_LEVEL, N_("LEVEL"), 0, + N_("set Mailutils debugging level"), 0 }, + { "debug-line-info", OPT_DEBUG_LINE_INFO, NULL, 0, + N_("show source info with debugging messages"), 0 }, + { NULL } +}; + +static error_t +mu_debug_argp_parser (int key, char *arg, struct argp_state *state) +{ + switch (key) + { + case OPT_DEBUG_LEVEL: + mu_global_debug_from_string (arg, "command line"); + break; + + case OPT_DEBUG_LINE_INFO: + mu_debug_line_info = 1; + break; + + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +struct argp mu_debug_argp = { + mu_debug_argp_options, + mu_debug_argp_parser, +}; + +struct argp_child mh_argp_children[] = { + { &mu_debug_argp, 0, N_("Global debugging settings"), 0 }, + { NULL } +}; + int mh_argp_parse (int *pargc, char **pargv[], int flags, struct argp_option *option, struct mh_option *mh_option, char *argp_doc, char *doc, - int (*handler)(), void *closure, int *pindex) + argp_parser_t handler, + void *closure, int *pindex) { struct argp argp; struct mh_argp_data data; @@ -123,6 +168,7 @@ mh_argp_parse (int *pargc, char **pargv[], argp.parser = parse_opt; argp.args_doc = argp_doc; argp.doc = doc; + argp.children = mh_argp_children; data.mh_option = mh_option; data.closure = closure; data.handler = handler; diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h index eabf98357..710da5b98 100644 --- a/mh/mh_getopt.h +++ b/mh/mh_getopt.h @@ -34,7 +34,7 @@ struct mh_option struct mh_argp_data { struct mh_option *mh_option; - int (*handler)(); + argp_parser_t handler; int errind; void *closure; char *doc; @@ -190,7 +190,8 @@ int mh_argp_parse (int *argc, char **argv[], struct argp_option *option, struct mh_option *mh_option, char *argp_doc, char *doc, - int (*handler)(), void *closure, int *index); + argp_parser_t handler, + void *closure, int *index); void mh_help (struct mh_option *mh_option, const char *doc); void mh_license (const char *name); diff --git a/mh/mh_init.c b/mh/mh_init.c index 3cb48c899..3594374e3 100644 --- a/mh/mh_init.c +++ b/mh/mh_init.c @@ -21,6 +21,7 @@ #include <mh.h> #include <mailutils/url.h> +#include <mailutils/tls.h> #include <pwd.h> #include <sys/types.h> #include <sys/stat.h> @@ -46,6 +47,9 @@ mh_init () { /* Register all mailbox and mailer formats */ mu_register_all_formats (); +#ifdef WITH_TLS + mu_init_tls_libs (); +#endif /* Read user's profile */ mh_read_profile (); @@ -75,8 +75,8 @@ static int nomoreproc; static mu_list_t format; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -137,7 +137,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -242,8 +242,8 @@ _get_content_encoding (mu_header_t hdr, char **value) return 0; } -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -398,7 +398,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/mhparam.c b/mh/mhparam.c index ad56c43ec..ff444f17a 100644 --- a/mh/mhparam.c +++ b/mh/mhparam.c @@ -46,8 +46,8 @@ struct mh_option mh_option[] = { static int display_all; static int display_comp_name = -1; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -64,7 +64,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/mhpath.c b/mh/mhpath.c index 13d5b1d91..483da3495 100644 --- a/mh/mhpath.c +++ b/mh/mhpath.c @@ -39,8 +39,8 @@ struct mh_option mh_option[] = { { 0 } }; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -53,7 +53,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -143,8 +143,8 @@ add_sequence (char *name) mu_list_append (seq_list, name); } -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { char *s, *p; @@ -291,7 +291,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; diff --git a/mh/refile.c b/mh/refile.c index b6d12db73..26b66a53e 100644 --- a/mh/refile.c +++ b/mh/refile.c @@ -151,7 +151,7 @@ close_folders () } static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -184,7 +184,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -138,8 +138,8 @@ decode_cc_flag (const char *opt, const char *arg) return rc; } -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { char *s; @@ -271,7 +271,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -64,8 +64,8 @@ static char *cur_folder_path; /* Full pathname of the current folder */ static char *folder_name; /* Name of the (topmost) folder to be deleted */ -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -95,7 +95,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -39,8 +39,8 @@ struct mh_option mh_option[] = { { 0 } }; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -53,7 +53,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -87,8 +87,8 @@ void list_message (mu_mailbox_t mbox, mu_message_t msg, size_t num, void *data); void print_header (mu_mailbox_t mbox); void clear_screen (void); -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -142,7 +142,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -131,8 +131,8 @@ static int keep_files; /* Keep draft files */ watch_printf c;\ } while (0) -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { char *p; @@ -257,7 +257,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/sortm.c b/mh/sortm.c index 7649e2ec8..8f5d4671a 100644 --- a/mh/sortm.c +++ b/mh/sortm.c @@ -116,8 +116,8 @@ static int comp_text (void *a, void *b); static int comp_date (void *a, void *b); static int comp_number (void *a, void *b); -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -196,7 +196,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } diff --git a/mh/whatnow.c b/mh/whatnow.c index aa3f07ab1..e45161d6f 100644 --- a/mh/whatnow.c +++ b/mh/whatnow.c @@ -57,8 +57,8 @@ struct mh_whatnow_env wh_env = { 0 }; static int initial_edit = 1; static char *draftmessage = "cur"; -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -96,7 +96,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } @@ -60,8 +60,8 @@ static int check_recipients; static int use_draft; /* Use the prepared draft */ static const char *draft_folder; /* Use this draft folder */ -static int -opt_handler (int key, char *arg, void *unused, struct argp_state *state) +static error_t +opt_handler (int key, char *arg, struct argp_state *state) { switch (key) { @@ -100,7 +100,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) break; default: - return 1; + return ARGP_ERR_UNKNOWN; } return 0; } |