move more things in the lib-ui.
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index e9e1cf6..a40194d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -29,7 +29,6 @@
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
 #include <lib-lib/mapping.h>
-#include <lib-lib/debug.h>
 #include <lib-lib/rx.h>
 
 #include <lib-sys/unix.h>
@@ -90,10 +89,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,
@@ -115,9 +110,6 @@ static struct {
 #endif
   { "history",                  check_history },
   { "pager_index_lines",        check_num },
-#ifdef DEBUG
-  { "debug_level",              check_debug },
-#endif
   /* last */
   { NULL,         NULL }
 };
@@ -538,7 +530,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);
   }
@@ -547,7 +538,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);
@@ -559,7 +549,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);
 }
@@ -1099,11 +1088,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;
   }
 
@@ -1143,9 +1129,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;
@@ -1193,11 +1176,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);
 
@@ -1426,7 +1405,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"));
@@ -1435,8 +1414,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))
@@ -1461,7 +1438,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;
@@ -1470,21 +1446,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;
 }
 
@@ -1620,8 +1585,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)
@@ -1638,7 +1601,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);
@@ -1734,7 +1696,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;
@@ -1772,19 +1734,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))
@@ -1884,7 +1833,6 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
       /* 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);
       }
@@ -2092,8 +2040,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);
@@ -2191,8 +2137,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 == '#')
@@ -2568,7 +2512,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);
@@ -2627,8 +2571,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 */
@@ -2720,9 +2662,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);