X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=init.c;h=f71f3637ed1c520f79bd1be7793b6d300e2fde86;hp=c55a0da6cc725f95584a21e13e089e9a1786baee;hb=f779db722043d8c6767149a9afef8c10159516f5;hpb=ac813896ca32d850febc2d95065ac4fa040f11f9 diff --git a/init.c b/init.c index c55a0da..f71f363 100644 --- a/init.c +++ b/init.c @@ -10,21 +10,11 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include +#include #include #include @@ -36,27 +26,16 @@ #include #include "mutt_idna.h" -#if defined(USE_SSL) || defined(USE_GNUTLS) -#include -#endif - #if defined (USE_LIBESMTP) && (defined (USE_SSL) || defined (USE_GNUTLS)) #include "mutt_libesmtp.h" #endif +#include "alias.h" #include "mx.h" #include "init.h" #include "lib/list.h" -#include -#include -#include -#include -#include -#include -#include - /* * prototypes */ @@ -92,10 +71,6 @@ static int check_history (const char* option, unsigned long val, /* this checks that numbers are >= 0 */ static int check_num (const char* option, unsigned long val, char* errbuf, ssize_t errlen); -#ifdef DEBUG -static int check_debug (const char* option, unsigned long val, - char* errbuf, ssize_t errlen); -#endif /* use this to check only */ static int check_special (const char* option, unsigned long val, @@ -117,9 +92,6 @@ static struct { #endif { "history", check_history }, { "pager_index_lines", check_num }, -#ifdef DEBUG - { "debug_level", check_debug }, -#endif /* last */ { NULL, NULL } }; @@ -266,14 +238,14 @@ static void sys_to_string (char* dst, ssize_t dstlen, int clean = 0; /* get some $madmutt_ values dynamically */ - if (ascii_strcmp ("madmutt_pwd", option->option) == 0) { + if (m_strcmp("madmutt_pwd", option->option) == 0) { val = p_new(char, _POSIX_PATH_MAX); val = getcwd (val, _POSIX_PATH_MAX-1); clean = 1; - } else if (ascii_strcmp ("madmutt_folder_path", option->option) == 0 && + } else if (m_strcmp("madmutt_folder_path", option->option) == 0 && CurrentFolder && *CurrentFolder) { val = CurrentFolder; - } else if (ascii_strcmp ("madmutt_folder_name", option->option) == 0 && + } else if (m_strcmp("madmutt_folder_name", option->option) == 0 && CurrentFolder && *CurrentFolder) { ssize_t Maildirlength = m_strlen(Maildir); @@ -540,7 +512,6 @@ int mutt_option_value (const char* val, char* dst, ssize_t dstlen) { ssize_t l = 0; if (!(option = hash_find (ConfigOptions, val))) { - debug_print (1, ("var '%s' not found\n", val)); *dst = '\0'; return (0); } @@ -549,7 +520,6 @@ int mutt_option_value (const char* val, char* dst, ssize_t dstlen) { /* as we get things of type $var=value and don't want to bloat the * above "just" for expansion, we do the stripping here */ - debug_print (1, ("orig == '%s'\n", tmp)); t = strchr (tmp, '='); t++; l = m_strlen(t); @@ -561,7 +531,6 @@ int mutt_option_value (const char* val, char* dst, ssize_t dstlen) { } memcpy (dst, t, l+1); p_delete(&tmp); - debug_print (1, ("stripped == '%s'\n", dst)); return (1); } @@ -582,7 +551,7 @@ static void syn_del (void** p) { p_delete(p); } -void toggle_quadoption (int opt) +static void toggle_quadoption (int opt) { int n = opt / 4; int b = (opt % 4) * 2; @@ -1101,11 +1070,8 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, string_list_t **ldata, /* Find the last item in the list that data points to. */ lastp = NULL; - debug_print (5, ("parse_attach_list: ldata = %p, *ldata = %p\n", - ldata, *ldata)); for (listp = *ldata; listp; listp = listp->next) { a = (ATTACH_MATCH *)listp->data; - debug_print (5, ("parse_attach_list: skipping %s/%s\n", a->major, a->minor)); lastp = listp; } @@ -1145,9 +1111,6 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, string_list_t **ldata, p_delete(&tmpminor); - debug_print (5, ("parse_attach_list: added %s/%s [%d]\n", - a->major, a->minor, a->major_int)); - listp = p_new(string_list_t, 1); listp->data = (char *)a; listp->next = NULL; @@ -1195,11 +1158,7 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, string_list_t **ldata, lastp = NULL; for(lp = *ldata; lp; ) { a = (ATTACH_MATCH *)lp->data; - debug_print(5, ("parse_unattach_list: check %s/%s [%d] : %s/%s [%d]\n", - a->major, a->minor, a->major_int, tmp, minor, major)); if (a->major_int == major && !m_strcasecmp(minor, a->minor)) { - debug_print(5, ("parse_unattach_list: removed %s/%s [%d]\n", - a->major, a->minor, a->major_int)); regfree(&a->minor_rx); p_delete(&a->major); @@ -1428,7 +1387,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s, { alias_t *tmp = Aliases; alias_t *last = NULL; - const char *estr = NULL; + char *estr = NULL; if (!MoreArgs (s)) { m_strcpy(err->data, err->dsize, _("alias: no address")); @@ -1437,8 +1396,6 @@ static int parse_alias (BUFFER * buf, BUFFER * s, mutt_extract_token (buf, s, 0); - debug_print (2, ("first token is '%s'.\n", buf->data)); - /* check to see if an alias with this name already exists */ for (; tmp; tmp = tmp->next) { if (!m_strcasecmp(tmp->name, buf->data)) @@ -1463,7 +1420,6 @@ static int parse_alias (BUFFER * buf, BUFFER * s, mutt_extract_token (buf, s, M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON); - debug_print (2, ("second token is '%s'.\n", buf->data)); tmp->addr = mutt_parse_adrlist (tmp->addr, buf->data); if (last) last->next = tmp; @@ -1472,21 +1428,10 @@ static int parse_alias (BUFFER * buf, BUFFER * s, if (mutt_addrlist_to_idna (tmp->addr, &estr)) { snprintf (err->data, err->dsize, _("Warning: Bad IDN '%s' in alias '%s'.\n"), estr, tmp->name); + p_delete(&estr); return -1; } -#ifdef DEBUG - if (DebugLevel >= 2) { - address_t *a; - /* A group is terminated with an empty address, so check a->mailbox */ - for (a = tmp->addr; a && a->mailbox; a = a->next) { - if (!a->group) - debug_print (2, ("%s\n", a->mailbox)); - else - debug_print (2, ("group %s\n", a->mailbox)); - } - } -#endif return 0; } @@ -1622,8 +1567,6 @@ static struct option_t* add_option (const char* name, const char* init, short type, short dodup) { struct option_t* option = p_new(struct option_t, 1); - debug_print (1, ("adding $%s\n", name)); - option->option = m_strdup(name); option->type = type; if (init) @@ -1640,7 +1583,6 @@ static struct option_t* add_user_option (const char* name) { static void del_option (void* p) { struct option_t *ptr = (struct option_t*) p; char* s = (char*) ptr->data; - debug_print (1, ("removing option '%s' from table\n", NONULL (ptr->option))); p_delete(&ptr->option); p_delete(&s); p_delete(&ptr->init); @@ -1736,7 +1678,7 @@ static int check_dsn_return (const char* option __attribute__ ((unused)), unsign } /* check whether value for $dsn_notify would be valid */ -static int check_dsn_notify (const char* option, unsigned long p, +static int check_dsn_notify (const char* option __attribute__ ((unused)), unsigned long p, char* errbuf, ssize_t errlen) { list2_t* list = NULL; ssize_t i = 0; @@ -1774,19 +1716,6 @@ static int check_num (const char* option, unsigned long p, return (1); } -#ifdef DEBUG -static int check_debug (const char* option, unsigned long p, - char* errbuf, ssize_t errlen) { - if ((int) p <= DEBUG_MAX_LEVEL && - (int) p >= DEBUG_MIN_LEVEL) - return (1); - - if (errbuf) - snprintf (errbuf, errlen, _("'%d' is invalid for $%s"), (int) p, option); - return (0); -} -#endif - static int check_history (const char* option __attribute__ ((unused)), unsigned long p, char* errbuf, ssize_t errlen) { if (!check_num ("history", p, errbuf, errlen)) @@ -1882,11 +1811,10 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, } /* see if we need to add $user_ var */ - if (!option && ascii_strncmp ("user_", tmp->data, 5) == 0) { + if (!option && m_strncmp("user_", tmp->data, 5) == 0) { /* there's no option named like this yet so only add one * if the action isn't any of: reset, unset, query */ if (!(reset || unset || query || *s->dptr != '=')) { - debug_print (1, ("adding user option '%s'\n", tmp->data)); option = add_user_option (tmp->data); hash_insert (ConfigOptions, option->option, option, 0); } @@ -2094,8 +2022,6 @@ static int source_rc (const char *rcfile, BUFFER * err) ssize_t buflen; pid_t pid; - debug_print (2, ("reading configuration file '%s'.\n", rcfile)); - if ((f = mutt_open_read (rcfile, &pid)) == NULL) { snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno)); return (-1); @@ -2193,8 +2119,6 @@ int mutt_parse_rc_line ( /* const */ char *line, BUFFER * token, BUFFER * err) *err->data = 0; - debug_print (1, ("expand '%s'\n", line)); - expn.dptr = vskipspaces(expn.dptr); while (*expn.dptr) { if (*expn.dptr == '#') @@ -2570,7 +2494,7 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) const char *p; char buffer[STRING], error[STRING]; int default_rc = 0, need_pause = 0; - unsigned int i; + int i; BUFFER err; p_clear(&err, 1); @@ -2629,8 +2553,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) Shell = m_strdup((p = getenv ("SHELL")) ? p : "/bin/sh"); } - debug_start(Homedir); - /* And about the host... */ uname (&utsname); /* some systems report the FQDN instead of just the hostname */ @@ -2722,9 +2644,7 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) if ((p = getenv ("EMAIL")) != NULL) From = rfc822_parse_adrlist (NULL, p); - mutt_set_langinfo_charset (); - mutt_set_charset (Charset); - + charset_initialize(); /* Set standard defaults */ hash_map (ConfigOptions, mutt_set_default, 0); @@ -2732,12 +2652,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) CurrentMenu = MENU_MAIN; - /* Do we have a locale definition? */ - if (((p = getenv ("LC_ALL")) != NULL && p[0]) || - ((p = getenv ("LANG")) != NULL && p[0]) || - ((p = getenv ("LC_CTYPE")) != NULL && p[0])) - set_option (OPTLOCALES); - #ifdef HAVE_GETSID /* Unset suspend by default if we're the session leader */ if (getsid (0) == getpid ()) @@ -2746,22 +2660,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) mutt_init_history (); - - - - /* - * - * BIG FAT WARNING - * - * When changing the code which looks for a configuration file, - * please also change the corresponding code in muttbug.sh.in. - * - * - */ - - - - if (!Muttrc) { #if 0 snprintf (buffer, sizeof(buffer), "%s/.madmuttrc-%s", NONULL (Homedir),