Commit 96dc9ab9 96dc9ab99e9518f5f21a7710e396da8c3fd833b5 by Sergey Poznyakoff

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
1 parent b66ffedc
......@@ -340,7 +340,8 @@ attach_auth_ticket (mu_mailbox_t mbox)
mu_authority_t auth = NULL;
if (mu_mailbox_get_folder (mbox, &folder) == 0
&& mu_folder_get_authority (folder, &auth) == 0)
&& mu_folder_get_authority (folder, &auth) == 0
&& auth)
{
char *filename = mu_tilde_expansion (mu_ticket_file, "/", NULL);
mu_wicket_t wicket;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
/* 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);
ret = data->handler (ARG_FOLDER, arg + 1, state);
break;
}
return ARGP_ERR_UNKNOWN;
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;
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......