From: Pierre Habouzit Date: Sat, 31 Mar 2007 14:29:07 +0000 (+0200) Subject: code simplification, fixes. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=c22cd6df714617b338e9a23bcb61543c4f3ba97e;p=apps%2Fmadmutt.git code simplification, fixes. Signed-off-by: Pierre Habouzit --- diff --git a/init.c b/init.c index 061f35e..80b669d 100644 --- a/init.c +++ b/init.c @@ -96,57 +96,6 @@ static struct { { NULL, NULL } }; -/* protos for config type handles: convert value to string */ -static void bool_to_string (char* dst, ssize_t dstlen, struct option_t* option); -static void num_to_string (char* dst, ssize_t dstlen, struct option_t* option); -static void str_to_string (char* dst, ssize_t dstlen, struct option_t* option); -static void quad_to_string (char* dst, ssize_t dstlen, struct option_t* option); -static void sort_to_string (char* dst, ssize_t dstlen, struct option_t* option); -static void rx_to_string (char* dst, ssize_t dstlen, struct option_t* option); -static void magic_to_string (char* dst, ssize_t dstlen, struct option_t* option); -static void addr_to_string (char* dst, ssize_t dstlen, struct option_t* option); - -/* protos for config type handles: convert to value from string */ -static int bool_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int num_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int str_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int path_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int quad_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int sort_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int rx_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int magic_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -static int addr_from_string (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); - -static struct { - unsigned short type; - void (*opt_tostr) (char* dst, ssize_t dstlen, struct option_t* option); - int (*opt_fromstr) (struct option_t* dst, const char* val, - char* errbuf, ssize_t errlen); -} FuncTable[] = { - { 0, NULL, NULL }, /* there's no DT_ type with 0 */ - { DT_BOOL, bool_to_string, bool_from_string }, - { DT_NUM, num_to_string, num_from_string }, - { DT_STR, str_to_string, str_from_string }, - { DT_PATH, str_to_string, path_from_string }, - { DT_QUAD, quad_to_string, quad_from_string }, - { DT_SORT, sort_to_string, sort_from_string }, - { DT_RX, rx_to_string, rx_from_string }, - { DT_MAGIC, magic_to_string, magic_from_string }, - /* synonyms should be resolved already so we don't need this - * but must define it as DT_ is used for indexing */ - { DT_SYN, NULL, NULL }, - { DT_ADDR, addr_to_string, addr_from_string }, -}; - static void bool_to_string (char* dst, ssize_t dstlen, struct option_t* option) { snprintf (dst, dstlen, "%s=%s", option->option, @@ -433,6 +382,28 @@ static int addr_from_string (struct option_t* dst, const char* val, return (1); } +static struct { + unsigned short type; + void (*opt_tostr) (char* dst, ssize_t dstlen, struct option_t* option); + int (*opt_fromstr) (struct option_t* dst, const char* val, + char* errbuf, ssize_t errlen); +} FuncTable[] = { + { 0, NULL, NULL }, /* there's no DT_ type with 0 */ + { DT_BOOL, bool_to_string, bool_from_string }, + { DT_NUM, num_to_string, num_from_string }, + { DT_STR, str_to_string, str_from_string }, + { DT_PATH, str_to_string, path_from_string }, + { DT_QUAD, quad_to_string, quad_from_string }, + { DT_SORT, sort_to_string, sort_from_string }, + { DT_RX, rx_to_string, rx_from_string }, + { DT_MAGIC, magic_to_string, magic_from_string }, + /* synonyms should be resolved already so we don't need this + * but must define it as DT_ is used for indexing */ + { DT_SYN, NULL, NULL }, + { DT_ADDR, addr_to_string, addr_from_string }, +}; + + int mutt_option_value (const char* val, char* dst, ssize_t dstlen) { struct option_t* option = NULL; char* tmp = NULL, *t = NULL; diff --git a/init.h b/init.h index 89457d3..d25f618 100644 --- a/init.h +++ b/init.h @@ -3336,8 +3336,6 @@ static int parse_attachments (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_unattachments (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_set (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_my_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *); diff --git a/mutt_libesmtp.c b/mutt_libesmtp.c index fce3580..eda907e 100644 --- a/mutt_libesmtp.c +++ b/mutt_libesmtp.c @@ -280,7 +280,7 @@ static void do_dsn_ret (smtp_message_t message) { #if defined (USE_LIBESMTP) && (defined (USE_SSL) || defined (USE_GNUTLS)) int mutt_libesmtp_check_usetls (const char* option, unsigned long p, - char* errbuf, size_t errlen) { + char* errbuf, ssize_t errlen) { char* val = (char*) p; if (m_strisempty(val)) return (1); diff --git a/mutt_libesmtp.h b/mutt_libesmtp.h index ef72a8d..1fef3be 100644 --- a/mutt_libesmtp.h +++ b/mutt_libesmtp.h @@ -13,7 +13,7 @@ #ifdef USE_LIBESMTP #if (defined (USE_SSL) || defined (USE_GNUTLS)) int mutt_libesmtp_check_usetls (const char* option, unsigned long p, - char* errbuf, size_t errlen); + char* errbuf, ssize_t errlen); #endif int mutt_libesmtp_invoke (address_t * from, /* the sender */