commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-282-g4fe4792
Date: Tue, 07 Jul 2009 12:01:28 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=4fe47925e890ad37d75e4ad5fa75d68a48419176

The branch, master has been updated
       via  4fe47925e890ad37d75e4ad5fa75d68a48419176 (commit)
      from  56d50498700d28bb7bf3bab5e23973d29669e101 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4fe47925e890ad37d75e4ad5fa75d68a48419176
Author: Sergey Poznyakoff <address@hidden>
Date:   Tue Jul 7 14:47:04 2009 +0300

    Introduce locale-independent character type and string functions.
    
    * include/mailutils/cctype.h: New file.
    * include/mailutils/cstr.h: New file.
    * include/mailutils/Makefile.am: Add new files.
    * mailbox/cstrcasecmp.c: New file.
    * mailbox/cstrlower.c: New file.
    * mailbox/cstrupper.c: New file.
    * mailbox/muctype.c: New file.
    * mailbox/strltrim.c: New file.
    * mailbox/strrtrim.c: New file.
    * mailbox/strskip.c: New file.
    * mailbox/Makefile.am: Add new files.
    * .gitignore: Update
    
    * gnulib.modules: Remove strcase.
    
    * comsat/comsat.h, imap4d/imap4d.h, include/mailutils/mailutils.h,
    include/mailutils/mutil.h, include/mailutils/sys/pop3.h,
    libmu_scm/mu_scm.h, mail/mail.h: Include cstr.h and cctype.h.
    
    * comsat/oldcfg.c, config/mailutils-config.c,
    examples/mimetest.c, examples/mta.c, examples/nntpclient.c,
    examples/pop3client.c, imap4d/append.c, imap4d/create.c,
    imap4d/delete.c, imap4d/fetch.c, imap4d/id.c,
    imap4d/idle.c, imap4d/list.c, imap4d/namespace.c,
    imap4d/rename.c, imap4d/search.c, imap4d/status.c,
    imap4d/store.c, imap4d/uid.c, imap4d/util.c,
    libmu_argp/compat.c, libmu_auth/ldap.c,
    libmu_auth/sql.c, libmu_scm/mu_message.c,
    libmu_sieve/actions.c, libmu_sieve/comparator.c,
    libmu_sieve/extensions/list.c, libmu_sieve/extensions/spamd.c,
    libmu_sieve/extensions/vacation.c, libmu_sieve/load.c,
    libmu_sieve/sieve.l, libmu_sieve/tests.c,
    libproto/imap/folder.c, libproto/mailer/smtp.c,
    libproto/mbox/mbox.c, libproto/mh/folder.c,
    libproto/mh/mbox.c, libproto/pop/folder.c,
    libproto/pop/mbox.c, libproto/pop/pop3_connect.c,
    maidag/forward.c, maidag/lmtp.c, maidag/maidag.c,
    maidag/maidag.h, maidag/mailquota.c, mail/alt.c,
    mail/copy.c, mail/decode.c, mail/escape.c,
    mail/followup.c, mail/mail.c, mail/mailline.c,
    mail/msgset.y, mail/print.c, mail/reply.c,
    mail/send.c, mail/shell.c, mail/util.c,
    mail/write.c, mailbox/address.c,
    mailbox/amd.c, mailbox/assoc.c,
    mailbox/attachment.c, mailbox/attribute.c,
    mailbox/cfg_lexer.l, mailbox/date.c,
    mailbox/filter.c, mailbox/gdebug.c,
    mailbox/header.c, mailbox/kwd.c,
    mailbox/locale.c, mailbox/mailcap.c,
    mailbox/mailer.c, mailbox/message.c,
    mailbox/message_stream.c, mailbox/mime.c,
    mailbox/msrv.c, mailbox/mutil.c,
    mailbox/parse822.c, mailbox/progmailer.c,
    mailbox/rfc2047.c, mailbox/syslog.c, mailbox/url.c,
    mailbox/version.c, mh/mh.h, mh/mh_alias.l,
    mh/mh_ctx.c, mh/mh_fmtgram.y, mh/mh_init.c,
    mh/mh_list.c, mh/mh_msgset.c, mh/mh_sequence.c,
    mh/mh_whatnow.c, mh/mh_whom.c, mh/mhn.c,
    mh/mhparam.c, mh/pick.y, mh/sortm.c,
    mimeview/mimetypes.y, pop3d/bulletin.c,
    pop3d/expire.c, pop3d/pop3d.c, pop3d/pop3d.h,
    pop3d/popauth.c, pop3d/user.c, readmsg/msglist.c,
    readmsg/readmsg.c, readmsg/readmsg.h, sql/mysql.c,
    sql/postgres.c: Use locale-independent cclass and str functions.

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                                     |    2 +-
 comsat/comsat.h                                |    4 +-
 comsat/oldcfg.c                                |    5 +-
 config/mailutils-config.c                      |    2 +-
 examples/mimetest.c                            |    9 +-
 examples/mta.c                                 |   13 +-
 examples/nntpclient.c                          |   33 +++---
 examples/pop3client.c                          |   14 +-
 gnulib.modules                                 |    1 -
 imap4d/append.c                                |    4 +-
 imap4d/create.c                                |    4 +-
 imap4d/delete.c                                |    4 +-
 imap4d/fetch.c                                 |   42 ++++----
 imap4d/id.c                                    |    4 +-
 imap4d/idle.c                                  |    4 +-
 imap4d/imap4d.h                                |    4 +-
 imap4d/list.c                                  |    4 +-
 imap4d/namespace.c                             |    2 +-
 imap4d/rename.c                                |    4 +-
 imap4d/search.c                                |   16 ++--
 imap4d/status.c                                |    5 +-
 imap4d/store.c                                 |    4 +-
 imap4d/uid.c                                   |   10 +-
 imap4d/util.c                                  |   29 ++---
 include/mailutils/Makefile.am                  |    2 +
 include/mailutils/cctype.h                     |   74 ++++++++++++
 include/mailutils/{io.h => cstr.h}             |   29 +++--
 include/mailutils/mailutils.h                  |    2 +
 include/mailutils/mutil.h                      |    6 +-
 include/mailutils/sys/pop3.h                   |    5 +-
 libmu_argp/compat.c                            |    7 +-
 libmu_auth/ldap.c                              |   14 +--
 libmu_auth/sql.c                               |    4 +-
 libmu_scm/mu_message.c                         |    5 +-
 libmu_scm/mu_scm.h                             |    4 +-
 libmu_sieve/actions.c                          |    6 +-
 libmu_sieve/comparator.c                       |   24 ++--
 libmu_sieve/extensions/list.c                  |    4 +-
 libmu_sieve/extensions/spamd.c                 |    7 +-
 libmu_sieve/extensions/vacation.c              |    4 +-
 libmu_sieve/load.c                             |    6 +-
 libmu_sieve/sieve.l                            |   16 ++--
 libmu_sieve/tests.c                            |    6 +-
 libproto/imap/folder.c                         |  131 ++++++++++----------
 libproto/mailer/smtp.c                         |   15 ++-
 libproto/mbox/mbox.c                           |    7 +-
 libproto/mh/folder.c                           |    8 +-
 libproto/mh/mbox.c                             |    6 +-
 libproto/pop/folder.c                          |    7 +-
 libproto/pop/mbox.c                            |   39 +++---
 libproto/pop/pop3_connect.c                    |    4 +-
 maidag/forward.c                               |    6 +-
 maidag/lmtp.c                                  |    6 +-
 maidag/maidag.c                                |    4 +-
 maidag/maidag.h                                |    1 +
 maidag/mailquota.c                             |   10 +-
 mail/alt.c                                     |    7 +-
 mail/copy.c                                    |    4 +-
 mail/decode.c                                  |    6 +-
 mail/escape.c                                  |   14 +-
 mail/followup.c                                |    4 +-
 mail/mail.c                                    |    2 +-
 mail/mail.h                                    |    6 +-
 mail/mailline.c                                |    4 +-
 mail/msgset.y                                  |   14 +-
 mail/print.c                                   |    4 +-
 mail/reply.c                                   |    2 +-
 mail/send.c                                    |    6 +-
 mail/shell.c                                   |    4 +-
 mail/util.c                                    |   34 ++----
 mail/write.c                                   |    4 +-
 mailbox/Makefile.am                            |   15 ++-
 mailbox/address.c                              |    3 +-
 mailbox/amd.c                                  |   21 ++--
 mailbox/assoc.c                                |    4 +-
 mailbox/attachment.c                           |   16 ++-
 mailbox/attribute.c                            |    3 +-
 mailbox/cfg_lexer.l                            |   10 +-
 mailbox/cstrcasecmp.c                          |   58 +++++++++
 python/libmu_py/c_api.c => mailbox/cstrlower.c |   25 ++--
 python/libmu_py/c_api.c => mailbox/cstrupper.c |   25 ++--
 mailbox/date.c                                 |   10 +-
 mailbox/filter.c                               |    6 +-
 mailbox/gdebug.c                               |   11 +-
 mailbox/header.c                               |    5 +-
 mailbox/kwd.c                                  |    8 +-
 mailbox/locale.c                               |    8 +-
 mailbox/mailcap.c                              |   21 ++--
 mailbox/mailer.c                               |   11 +-
 mailbox/message.c                              |    4 +-
 mailbox/message_stream.c                       |   15 ++-
 mailbox/mime.c                                 |   36 +++---
 mailbox/msrv.c                                 |    6 +-
 mailbox/muctype.c                              |  152 ++++++++++++++++++++++++
 mailbox/mutil.c                                |    6 +-
 mailbox/parse822.c                             |   15 ++-
 mailbox/progmailer.c                           |    6 +-
 mailbox/rfc2047.c                              |    9 +-
 mailbox/strltrim.c                             |   63 ++++++++++
 mailbox/{asprintf.c => strrtrim.c}             |   49 +++++---
 mailbox/{asprintf.c => strskip.c}              |   42 ++++----
 mailbox/syslog.c                               |    3 +-
 mailbox/url.c                                  |   15 ++-
 mailbox/version.c                              |    7 +-
 mh/mh.h                                        |    4 +-
 mh/mh_alias.l                                  |   14 +--
 mh/mh_ctx.c                                    |    4 +-
 mh/mh_fmtgram.y                                |   10 +-
 mh/mh_init.c                                   |   22 ++--
 mh/mh_list.c                                   |   19 ++--
 mh/mh_msgset.c                                 |    4 +-
 mh/mh_sequence.c                               |    4 +-
 mh/mh_whatnow.c                                |    6 +-
 mh/mh_whom.c                                   |    2 +-
 mh/mhn.c                                       |   49 ++++----
 mh/mhparam.c                                   |    6 +-
 mh/pick.y                                      |    5 +-
 mh/sortm.c                                     |   13 +-
 mimeview/mimetypes.y                           |    6 +-
 pop3d/bulletin.c                               |    4 +-
 pop3d/expire.c                                 |    4 +-
 pop3d/pop3d.c                                  |   30 +++---
 pop3d/pop3d.h                                  |    5 +-
 pop3d/popauth.c                                |    4 +-
 pop3d/user.c                                   |    7 +-
 readmsg/msglist.c                              |    7 +-
 readmsg/readmsg.c                              |    4 +-
 readmsg/readmsg.h                              |    5 +-
 sql/mysql.c                                    |    6 +-
 sql/postgres.c                                 |    6 +-
 130 files changed, 1073 insertions(+), 672 deletions(-)
 create mode 100644 include/mailutils/cctype.h
 copy include/mailutils/{io.h => cstr.h} (54%)
 create mode 100644 mailbox/cstrcasecmp.c
 copy python/libmu_py/c_api.c => mailbox/cstrlower.c (66%)
 copy python/libmu_py/c_api.c => mailbox/cstrupper.c (66%)
 create mode 100644 mailbox/muctype.c
 create mode 100644 mailbox/strltrim.c
 copy mailbox/{asprintf.c => strrtrim.c} (50%)
 copy mailbox/{asprintf.c => strskip.c} (55%)

diff --git a/.gitignore b/.gitignore
index 24a7202..6f60162 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,10 @@
 *.a
+*.cflow
 *.la
 *.lo
 *.o
 *.so
 *~
-*.cflow
 .bootstrap
 .deps
 .emacs*
diff --git a/comsat/comsat.h b/comsat/comsat.h
index 38e97ca..5d6d320 100644
--- a/comsat/comsat.h
+++ b/comsat/comsat.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2007, 
-   2008 Free Software Foundation, Inc.
+   2008, 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
@@ -37,7 +37,6 @@
 #include <syslog.h>
 #include <string.h>
 #include <pwd.h>
-#include <ctype.h>
 
 #ifdef HAVE_PATHS_H
 # include <paths.h>
@@ -63,6 +62,7 @@
 #include <mailutils/daemon.h>
 #include <mailutils/acl.h>
 #include <mailutils/server.h>
+#include <mailutils/cctype.h>
 
 #ifndef INADDR_NONE
 # define INADDR_NONE -1
diff --git a/comsat/oldcfg.c b/comsat/oldcfg.c
index cea0b74..b4f235f 100644
--- a/comsat/oldcfg.c
+++ b/comsat/oldcfg.c
@@ -1,5 +1,6 @@
 /* This file is part of GNU Mailutils.
-   Copyright (C) 1998, 2001, 2002, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2002, 2005, 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
@@ -70,7 +71,7 @@ convert_config (const char *config_file, FILE *outfile)
       if (len > 0 && ptr[len-1] == '\n')
        ptr[--len] = 0;
 
-      while (*ptr && isspace (*ptr))
+      while (*ptr && mu_isblank (*ptr))
        ptr++;
       if (!*ptr || *ptr == '#')
        {
diff --git a/config/mailutils-config.c b/config/mailutils-config.c
index 11335f1..99689b9 100644
--- a/config/mailutils-config.c
+++ b/config/mailutils-config.c
@@ -242,7 +242,7 @@ main (int argc, char **argv)
                  struct lib_descr *p;
                  
                  for (p = lib_descr; p->name; p++)
-                   if (strcasecmp (p->name, argv[0]) == 0)
+                   if (mu_c_strcasecmp (p->name, argv[0]) == 0)
                      break;
 
                  if (p->name)
diff --git a/examples/mimetest.c b/examples/mimetest.c
index ef12a40..488bb31 100644
--- a/examples/mimetest.c
+++ b/examples/mimetest.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2005, 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
@@ -199,7 +200,7 @@ message_display_parts (mu_message_t msg, int indent)
        encoding = "";
       ismulti = 0;
       if ((type[0]
-           && strncasecmp (type, "message/rfc822", strlen (type)) == 0)
+           && mu_c_strncasecmp (type, "message/rfc822", strlen (type)) == 0)
           || (mu_message_is_multipart (part, &ismulti) == 0 && ismulti))
         {
           if (!ismulti)
@@ -218,9 +219,9 @@ message_display_parts (mu_message_t msg, int indent)
           mu_message_destroy (&part, NULL);
         }
       else if (type[0] == '\0'
-               || (strncasecmp (type, "text/plain", strlen ("text/plain")) ==
+               || (mu_c_strncasecmp (type, "text/plain", strlen 
("text/plain")) ==
                    0)
-               || (strncasecmp (type, "text/html", strlen ("text/html")) ==
+               || (mu_c_strncasecmp (type, "text/html", strlen ("text/html")) 
==
                    0))
         {
           printf ("%*.*sText Message\n", indent, indent, "");
diff --git a/examples/mta.c b/examples/mta.c
index 0e84180..226aab2 100644
--- a/examples/mta.c
+++ b/examples/mta.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2005, 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
@@ -537,7 +538,7 @@ smtp_kw (const char *name)
   int i;
 
   for (i = 0; kw[i].name != NULL; i++)
-    if (strcasecmp (name, kw[i].name) == 0)
+    if (mu_c_strcasecmp (name, kw[i].name) == 0)
       return kw[i].code;
   return -1;
 }
@@ -546,7 +547,7 @@ static char *
 check_prefix (char *str, const char *prefix)
 {
   int pflen = strlen (prefix);
-  if (strlen (str) > pflen && strncasecmp (str, prefix, pflen) == 0)
+  if (strlen (str) > pflen && mu_c_strncasecmp (str, prefix, pflen) == 0)
     return str + pflen;
   else
     return NULL;
@@ -622,7 +623,7 @@ smtp (int fd)
            case KW_MAIL:
              if (argc == 2)
                from_person = check_prefix (argv[1], "from:");
-             else if (argc == 3 && strcasecmp (argv[1], "from:") == 0)
+             else if (argc == 3 && mu_c_strcasecmp (argv[1], "from:") == 0)
                from_person = argv[2];
              else
                from_person = NULL;
@@ -648,7 +649,7 @@ smtp (int fd)
            case KW_RCPT:
              if (argc == 2)
                rcpt_addr = check_prefix (argv[1], "to:");
-             else if (argc == 3 && strcasecmp (argv[1], "to:") == 0)
+             else if (argc == 3 && mu_c_strcasecmp (argv[1], "to:") == 0)
                rcpt_addr = argv[2];
              else
                rcpt_addr = NULL;
@@ -678,7 +679,7 @@ smtp (int fd)
            case KW_RCPT:
              if (argc == 2)
                rcpt_addr = check_prefix (argv[1], "to:");
-             else if (argc == 3 && strcasecmp (argv[1], "to:") == 0)
+             else if (argc == 3 && mu_c_strcasecmp (argv[1], "to:") == 0)
                rcpt_addr = argv[2];
              else
                rcpt_addr = NULL;
diff --git a/examples/nntpclient.c b/examples/nntpclient.c
index 61d4b65..6d4a6bc 100644
--- a/examples/nntpclient.c
+++ b/examples/nntpclient.c
@@ -2,7 +2,7 @@
    GNU Mailutils nntp functions.  This application interactively allows users
    to contact a nntp server.
 
-   Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation
+   Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation
 
    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
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <termios.h>
 #include <signal.h>
-#include <ctype.h>
 #include <time.h>
 
 #ifdef WITH_READLINE
@@ -43,6 +42,8 @@
 #include <mailutils/iterator.h>
 #include <mailutils/error.h>
 #include <mailutils/errno.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cctype.h>
 
 /* A structure which contains information on the commands this program
    can understand. */
@@ -299,11 +300,11 @@ execute_line (char *line)
 
   /* Isolate the command word. */
   i = 0;
-  while (line[i] && isspace (line[i]))
+  while (line[i] && mu_isblank (line[i]))
     i++;
   word = line + i;
 
-  while (line[i] && !isspace (line[i]))
+  while (line[i] && !mu_isblank (line[i]))
     i++;
 
   if (line[i])
@@ -318,7 +319,7 @@ execute_line (char *line)
     }
 
   /* Get argument to command, if any. */
-  while (isspace (line[i]))
+  while (mu_isblank (line[i]))
     i++;
 
   word = line + i;
@@ -349,14 +350,14 @@ stripwhite (char *string)
 {
   register char *s, *t;
 
-  for (s = string; isspace (*s); s++)
+  for (s = string; mu_isblank (*s); s++)
     ;
 
   if (*s == 0)
     return (s);
 
   t = s + strlen (s) - 1;
-  while (t > s && isspace (*t))
+  while (t > s && mu_isblank (*t))
     t--;
   *++t = '\0';
 
@@ -392,7 +393,7 @@ int com_mode (char *arg)
 {
   if (!valid_argument("mode", arg))
     return EINVAL;
-  if (strncasecmp (arg, "READER", 6) == 0)
+  if (mu_c_strncasecmp (arg, "READER", 6) == 0)
     return com_mode_reader (arg);
   return EINVAL;
 }
@@ -533,27 +534,27 @@ int com_list (char *arg)
     {
       status = com_list_active (arg);
    }
-  else if (strncasecmp (keyword, "ACTIVE.TIMES", 12) == 0)
+  else if (mu_c_strncasecmp (keyword, "ACTIVE.TIMES", 12) == 0)
     {
       status = com_list_active_times (arg);
     }
-  else if (strncasecmp (keyword, "ACTIVE", 6) == 0)
+  else if (mu_c_strncasecmp (keyword, "ACTIVE", 6) == 0)
     {
       status = com_list_active (arg);
     }
-  else if (strncasecmp (keyword, "EXTENSIONS", 10) == 0)
+  else if (mu_c_strncasecmp (keyword, "EXTENSIONS", 10) == 0)
     {
       status = com_list_extensions (arg);
     }
-  else if (strncasecmp (keyword, "DISTRIBUTIONS", 13) == 0)
+  else if (mu_c_strncasecmp (keyword, "DISTRIBUTIONS", 13) == 0)
     {
       status = com_list_distributions (arg);
     }
-  else if (strncasecmp (keyword, "DISTRIB.PATS", 12) == 0)
+  else if (mu_c_strncasecmp (keyword, "DISTRIB.PATS", 12) == 0)
     {
       status = com_list_distrib_pats (arg);
     }
-  else if (strncasecmp (keyword, "NEWSGROUPS", 10) == 0)
+  else if (mu_c_strncasecmp (keyword, "NEWSGROUPS", 10) == 0)
     {
       status = com_list_newsgroups (arg);
     }
@@ -806,7 +807,7 @@ com_newgroups (char *arg)
       char gmt[4];
       memset (gmt, 0, 4);
       sscanf (arg, "%4d%2d%2d %2d%2d%2d %3s", &year, &month, &day, &hour, 
&min, &sec, gmt);
-      is_gmt = strncasecmp ("GMT", gmt, 3) == 0;
+      is_gmt = mu_c_strncasecmp ("GMT", gmt, 3) == 0;
     }
 
   /* If nothing defined take the current time.  */
@@ -865,7 +866,7 @@ com_newnews (char *arg)
 
   wildmat = calloc (1, 512);
   sscanf (arg, "%511s %4d%2d%2d %2d%2d%2d %3s", wildmat, &year, &month, &day, 
&hour, &min, &sec, gmt);
-  is_gmt = strncasecmp ("GMT", gmt, 3) == 0;
+  is_gmt = mu_c_strncasecmp ("GMT", gmt, 3) == 0;
 
   if (year == 0)
     {
diff --git a/examples/pop3client.c b/examples/pop3client.c
index 7f1d8e6..e4367c9 100644
--- a/examples/pop3client.c
+++ b/examples/pop3client.c
@@ -2,7 +2,7 @@
    GNU Mailutils pop3 functions.  This application interactively allows users
    to contact a pop3 server.
 
-   Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation
+   Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation
 
    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,7 +33,6 @@
 #include <stdlib.h>
 #include <termios.h>
 #include <signal.h>
-#include <ctype.h>
 
 #ifdef WITH_READLINE
 # include <readline/readline.h>
@@ -46,6 +45,7 @@
 #include <mailutils/errno.h>
 #include <mailutils/vartab.h>
 #include <mailutils/argcv.h>
+#include <mailutils/cctype.h>
 
 /* A structure which contains information on the commands this program
    can understand. */
@@ -348,11 +348,11 @@ execute_line (char *line)
 
   /* Isolate the command word. */
   i = 0;
-  while (line[i] && isspace (line[i]))
+  while (line[i] && mu_isblank (line[i]))
     i++;
   word = line + i;
 
-  while (line[i] && !isspace (line[i]))
+  while (line[i] && !mu_isblank (line[i]))
     i++;
 
   if (line[i])
@@ -367,7 +367,7 @@ execute_line (char *line)
     }
 
   /* Get argument to command, if any. */
-  while (isspace (line[i]))
+  while (mu_isblank (line[i]))
     i++;
 
   word = line + i;
@@ -398,14 +398,14 @@ stripwhite (char *string)
 {
   register char *s, *t;
 
-  for (s = string; isspace (*s); s++)
+  for (s = string; mu_isblank (*s); s++)
     ;
 
   if (*s == 0)
     return (s);
 
   t = s + strlen (s) - 1;
-  while (t > s && isspace (*t))
+  while (t > s && mu_isblank (*t))
     t--;
   *++t = '\0';
 
diff --git a/gnulib.modules b/gnulib.modules
index 1d667f8..37093a7 100644
--- a/gnulib.modules
+++ b/gnulib.modules
@@ -20,7 +20,6 @@ realloc
 setenv
 snprintf
 stdint
-strcase
 strtok_r
 vasprintf
 xalloc
diff --git a/imap4d/append.c b/imap4d/append.c
index b3fc561..3e54090 100644
--- a/imap4d/append.c
+++ b/imap4d/append.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2005, 2006, 2007,
-   2008 Free Software Foundation, Inc.
+   2008, 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
@@ -98,7 +98,7 @@ imap4d_append0 (mu_mailbox_t mbox, int flags, char 
*date_time, char *text,
   
   tm = gmtime(&t);
 
-  while (*text && isspace (*text))
+  while (*text && mu_isblank (*text))
     text++;
 
   mu_stream_write (stream, text, strlen (text), len, &len);
diff --git a/imap4d/create.c b/imap4d/create.c
index dd59ae2..9de4c89 100644
--- a/imap4d/create.c
+++ b/imap4d/create.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2007, 2008, 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
@@ -98,7 +98,7 @@ imap4d_create (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
     return util_finish (command, RESP_BAD, "Too few arguments");
 
   /* Creating, "Inbox" should always fail.  */
-  if (strcasecmp (name, "INBOX") == 0)
+  if (mu_c_strcasecmp (name, "INBOX") == 0)
     return util_finish (command, RESP_BAD, "Already exist");
 
   /* RFC 3501:
diff --git a/imap4d/delete.c b/imap4d/delete.c
index 514800b..ae15030 100644
--- a/imap4d/delete.c
+++ b/imap4d/delete.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2007, 2008, 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
@@ -45,7 +45,7 @@ imap4d_delete (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
 
   /* It is an error to attempt to delele "INBOX or a mailbox
      name that dos not exists.  */
-  if (strcasecmp (name, "INBOX") == 0)
+  if (mu_c_strcasecmp (name, "INBOX") == 0)
     return util_finish (command, RESP_NO, "Already exist");
 
  /* Allocates memory.  */
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 092f740..2d1b939 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -359,9 +359,9 @@ bodystructure (mu_message_t msg, int extension)
          
       mu_argcv_get (buffer, " \t\r\n;=", NULL, &argc, &argv);
 
-      if (strcasecmp (argv[0], "MESSAGE/RFC822") == 0)
+      if (mu_c_strcasecmp (argv[0], "MESSAGE/RFC822") == 0)
         message_rfc822 = 1;
-      else if (strcasecmp (argv[0], "TEXT/PLAIN") == 0)
+      else if (mu_c_strcasecmp (argv[0], "TEXT/PLAIN") == 0)
         text_plain = 1;
 
       s = strchr (argv[0], '/');
@@ -410,7 +410,7 @@ bodystructure (mu_message_t msg, int extension)
                  
                default:
                  lvalue = argv[i];
-                 if (strcasecmp (lvalue, "charset") == 0)
+                 if (mu_c_strcasecmp (lvalue, "charset") == 0)
                    have_charset = 1;
 
                }
@@ -1136,7 +1136,7 @@ find_macro (const char *name)
 {
   int i;
   for (i = 0; fetch_macro_tab[i].macro; i++)
-    if (strcasecmp (fetch_macro_tab[i].macro, name) == 0)
+    if (mu_c_strcasecmp (fetch_macro_tab[i].macro, name) == 0)
       return fetch_macro_tab[i].exp;
   return NULL;
 }
@@ -1161,7 +1161,7 @@ find_fetch_att_tab (char *name)
 {
   struct fetch_att_tab *p;
   for (p = fetch_att_tab; p->name; p++)
-    if (strcasecmp (p->name, name) == 0)
+    if (mu_c_strcasecmp (p->name, name) == 0)
       return p;
   return NULL;
 }
@@ -1191,7 +1191,7 @@ parse_fetch_rfc822 (imap4d_parsebuf_t p)
   else if (p->token[0] == '.')
     {
       imap4d_parsebuf_next (p, 1);
-      if (strcasecmp (p->token, "HEADER") == 0)
+      if (mu_c_strcasecmp (p->token, "HEADER") == 0)
        {
          /* RFC822.HEADER
             Equivalent to BODY[HEADER].  Note that this did not result in
@@ -1205,14 +1205,14 @@ parse_fetch_rfc822 (imap4d_parsebuf_t p)
          ffc.peek = 1;
          imap4d_parsebuf_next (p, 0);
        }
-      else if (strcasecmp (p->token, "SIZE") == 0)
+      else if (mu_c_strcasecmp (p->token, "SIZE") == 0)
        {
          /* A number expressing the [RFC-2822] size of the message. */
          ffc.name = "RFC822.SIZE";
          ffc.fun = _frt_size;
          imap4d_parsebuf_next (p, 0);
        }
-      else if (strcasecmp (p->token, "TEXT") == 0)
+      else if (mu_c_strcasecmp (p->token, "TEXT") == 0)
        {
          /* RFC822.TEXT
             Equivalent to BODY[TEXT]. */
@@ -1231,7 +1231,7 @@ parse_fetch_rfc822 (imap4d_parsebuf_t p)
 static int
 _header_cmp (const void *a, const void *b)
 {
-  return strcasecmp ((char*)a, (char*)b);
+  return mu_c_strcasecmp ((char*)a, (char*)b);
 }
 
 /*
@@ -1266,21 +1266,21 @@ static int
 parse_section_text (imap4d_parsebuf_t p, struct fetch_function_closure *ffc,
                    int allow_mime)
 {
-  if (strcasecmp (p->token, "HEADER") == 0)
+  if (mu_c_strcasecmp (p->token, "HEADER") == 0)
     {
       /* "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list  */
       imap4d_parsebuf_next (p, 1);
       if (p->token[0] == '.')
        {
          imap4d_parsebuf_next (p, 1);
-         if (strcasecmp (p->token, "FIELDS"))
+         if (mu_c_strcasecmp (p->token, "FIELDS"))
            imap4d_parsebuf_exit (p, "Expected FIELDS");
          ffc->fun = _frt_header_fields;
          imap4d_parsebuf_next (p, 1);
          if (p->token[0] == '.')
            {
              imap4d_parsebuf_next (p, 1);
-             if (strcasecmp (p->token, "NOT") == 0)
+             if (mu_c_strcasecmp (p->token, "NOT") == 0)
                {
                  ffc->not = 1;
                  imap4d_parsebuf_next (p, 1);
@@ -1293,12 +1293,12 @@ parse_section_text (imap4d_parsebuf_t p, struct 
fetch_function_closure *ffc,
       else
        ffc->fun = _frt_header;
     }
-  else if (strcasecmp (p->token, "TEXT") == 0)
+  else if (mu_c_strcasecmp (p->token, "TEXT") == 0)
     {
       imap4d_parsebuf_next (p, 1);
       ffc->fun = _frt_body_text;
     }
-  else if (allow_mime && strcasecmp (p->token, "MIME") == 0)
+  else if (allow_mime && mu_c_strcasecmp (p->token, "MIME") == 0)
     {
       imap4d_parsebuf_next (p, 1);
       ffc->fun = _frt_mime;
@@ -1355,7 +1355,7 @@ parse_section_part (imap4d_parsebuf_t p, struct 
fetch_function_closure *ffc)
       
       if (p->token[0] == '.'
          && (cp = imap4d_parsebuf_peek (p))
-         && isascii (*cp) && isdigit (*cp))
+         && mu_isdigit (*cp))
        imap4d_parsebuf_next (p, 1);
       else
        break;
@@ -1381,7 +1381,7 @@ parse_section (imap4d_parsebuf_t p, struct 
fetch_function_closure *ffc)
     {
       if (p->token[0] == ']')
        /* OK */;
-      else if (isascii (p->token[0]) && isdigit (p->token[0]))
+      else if (mu_isdigit (p->token[0]))
        {
          parse_section_part (p, ffc);
          if (p->token[0] == '.')
@@ -1437,7 +1437,7 @@ static void
 parse_body_peek (imap4d_parsebuf_t p)
 {
   imap4d_parsebuf_next (p, 1);
-  if (strcasecmp (p->token, "PEEK") == 0)
+  if (mu_c_strcasecmp (p->token, "PEEK") == 0)
     {
       imap4d_parsebuf_next (p, 1);
       if (parse_body_args (p, 1))
@@ -1458,7 +1458,7 @@ parse_fetch_body (imap4d_parsebuf_t p)
                            "BODY", _frt_bodystructure0);
   else if (p->token[0] == '.')
     parse_body_peek (p);
-  else if (strcasecmp (p->token, "STRUCTURE") == 0)
+  else if (mu_c_strcasecmp (p->token, "STRUCTURE") == 0)
     {
       /* For compatibility with previous versions */
       append_simple_function (imap4d_parsebuf_data (p),
@@ -1483,11 +1483,11 @@ parse_fetch_att (imap4d_parsebuf_t p)
        append_simple_function (pclos, ent->name, ent->fun);
       imap4d_parsebuf_next (p, 0);
     }
-  else if (strcasecmp (p->token, "RFC822") == 0)
+  else if (mu_c_strcasecmp (p->token, "RFC822") == 0)
     parse_fetch_rfc822 (p);
-  else if (strcasecmp (p->token, "BODY") == 0)
+  else if (mu_c_strcasecmp (p->token, "BODY") == 0)
     parse_fetch_body (p);
-  else if (strcasecmp (p->token, "BODYSTRUCTURE") == 0)
+  else if (mu_c_strcasecmp (p->token, "BODYSTRUCTURE") == 0)
     {
       append_simple_function (pclos, "BODYSTRUCTURE", _frt_bodystructure);
       imap4d_parsebuf_next (p, 0);
diff --git a/imap4d/id.c b/imap4d/id.c
index 8a14848..201f9bd 100644
--- a/imap4d/id.c
+++ b/imap4d/id.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 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
@@ -32,7 +32,7 @@ eat_args (imap4d_tokbuf_t tok)
   p = imap4d_tokbuf_getarg (tok, n++);
   if (!p)
     return RESP_BAD;
-  if (strcasecmp (p, "NIL") == 0)
+  if (mu_c_strcasecmp (p, "NIL") == 0)
     {
       if (imap4d_tokbuf_getarg (tok, n))
        return RESP_BAD;
diff --git a/imap4d/idle.c b/imap4d/idle.c
index 6a73a15..1fc7519 100644
--- a/imap4d/idle.c
+++ b/imap4d/idle.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2007, 2008, 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
@@ -41,7 +41,7 @@ imap4d_idle (struct imap4d_command *command, imap4d_tokbuf_t 
tok)
        {
           imap4d_getline (&token_str, &token_size, &token_len);          
          token_len = util_trim_nl (token_str, token_len);
-         if (token_len == 4 && strcasecmp (token_str, "done") == 0)
+         if (token_len == 4 && mu_c_strcasecmp (token_str, "done") == 0)
            break;
        }
       else if (time (NULL) - start > idle_timeout)
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index 4b523ca..f78b5f7 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -57,7 +57,6 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <ctype.h>
 
 #ifdef HAVE_ALLOCA_H
 # include <alloca.h>
@@ -103,6 +102,8 @@
 #include <mailutils/argcv.h>
 #include <mailutils/alloc.h>
 #include <mailutils/vartab.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
 #include <mu_asprintf.h>
 #include <mu_umaxtostr.h>
@@ -340,7 +341,6 @@ extern int  util_do_command (imap4d_tokbuf_t);
 extern char *util_tilde_expansion (const char *, const char *);
 extern char *util_getfullpath (const char *, const char *);
 extern int  util_msgset (char *, size_t **, int *, int);
-extern int  util_upper (char *);
 extern struct imap4d_command *util_getcommand (char *, 
                                                struct imap4d_command []);
 extern int util_parse_internal_date (char *date, time_t *timep);
diff --git a/imap4d/list.c b/imap4d/list.c
index e19091f..f7049b4 100644
--- a/imap4d/list.c
+++ b/imap4d/list.c
@@ -159,8 +159,8 @@ imap4d_list (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
                (*ref) ? delim : "");
     }
   /* There is only one mailbox in the "INBOX" hierarchy ... INBOX.  */
-  else if (strcasecmp (ref, "INBOX") == 0
-          || (ref[0] == 0 && strcasecmp (wcard, "INBOX") == 0))
+  else if (mu_c_strcasecmp (ref, "INBOX") == 0
+          || (ref[0] == 0 && mu_c_strcasecmp (wcard, "INBOX") == 0))
     {
       util_out (RESP_NONE, "LIST (\\NoInferiors) NIL INBOX");
     }
diff --git a/imap4d/namespace.c b/imap4d/namespace.c
index c6d344d..f2abf66 100644
--- a/imap4d/namespace.c
+++ b/imap4d/namespace.c
@@ -231,7 +231,7 @@ char *
 namespace_getfullpath (const char *name, const char *delim, int *nspace)
 {
   char *ret;
-  if (strcasecmp (name, "INBOX") == 0 && auth_data->change_uid)
+  if (mu_c_strcasecmp (name, "INBOX") == 0 && auth_data->change_uid)
     {
       ret = strdup (auth_data->mailbox);
       if (nspace)
diff --git a/imap4d/rename.c b/imap4d/rename.c
index d6cc9d4..d9aaf0e 100644
--- a/imap4d/rename.c
+++ b/imap4d/rename.c
@@ -53,7 +53,7 @@ imap4d_rename (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
   oldname = imap4d_tokbuf_getarg (tok, IMAP4_ARG_1);
   newname = imap4d_tokbuf_getarg (tok, IMAP4_ARG_2);
 
-  if (strcasecmp (newname, "INBOX") == 0)
+  if (mu_c_strcasecmp (newname, "INBOX") == 0)
     return util_finish (command, RESP_NO, "Name Inbox is reservered");
 
   /* Allocates memory.  */
@@ -75,7 +75,7 @@ imap4d_rename (struct imap4d_command *command, 
imap4d_tokbuf_t tok)
   /* Renaming INBOX is permitted, and has special behavior.  It moves
      all messages in INBOX to a new mailbox with the given name,
      leaving INBOX empty.  */
-  if (strcasecmp (oldname, "INBOX") == 0)
+  if (mu_c_strcasecmp (oldname, "INBOX") == 0)
     {
       mu_mailbox_t newmbox = NULL;
       mu_mailbox_t inbox = NULL;
diff --git a/imap4d/search.c b/imap4d/search.c
index 4c8ce35..816c1ab 100644
--- a/imap4d/search.c
+++ b/imap4d/search.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2005, 2007,
-   2008 Free Software Foundation, Inc.
+   2008, 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
@@ -290,7 +290,7 @@ imap4d_search0 (imap4d_tokbuf_t tok, int isuid, char 
**err_text)
       return RESP_BAD;
     }
   
-  if (strcasecmp (parsebuf.token, "CHARSET") == 0)
+  if (mu_c_strcasecmp (parsebuf.token, "CHARSET") == 0)
     {
       if (!parse_gettoken (&parsebuf, 0))
        {
@@ -299,7 +299,7 @@ imap4d_search0 (imap4d_tokbuf_t tok, int isuid, char 
**err_text)
        }
 
       /* Currently only ASCII is supported */
-      if (strcasecmp (parsebuf.token, "US-ASCII"))
+      if (mu_c_strcasecmp (parsebuf.token, "US-ASCII"))
        {
          *err_text = "Charset not supported";
          return RESP_NO;
@@ -493,7 +493,7 @@ parse_search_key (struct parsebuf *pb)
       parse_gettoken (pb, 0);
       return node;
     }
-  else if (strcasecmp (pb->token, "ALL") == 0)
+  else if (mu_c_strcasecmp (pb->token, "ALL") == 0)
     {
       node = parse_alloc (pb, sizeof *node);
       node->type = node_value;
@@ -503,7 +503,7 @@ parse_search_key (struct parsebuf *pb)
       parse_gettoken (pb, 0);
       return node;
     }
-  else if (strcasecmp (pb->token, "NOT") == 0)
+  else if (mu_c_strcasecmp (pb->token, "NOT") == 0)
     {
       struct search_node *np;
       
@@ -520,7 +520,7 @@ parse_search_key (struct parsebuf *pb)
       
       return node;
     }
-  else if (strcasecmp (pb->token, "OR") == 0)
+  else if (mu_c_strcasecmp (pb->token, "OR") == 0)
     {
       struct search_node *leftarg, *rightarg;
       
@@ -550,7 +550,7 @@ parse_equiv_key (struct parsebuf *pb)
   int save_arg;
   imap4d_tokbuf_t save_tok;
   
-  for (condp = equiv_list; condp->name && strcasecmp (condp->name, pb->token);
+  for (condp = equiv_list; condp->name && mu_c_strcasecmp (condp->name, 
pb->token);
        condp++)
     ;
 
@@ -589,7 +589,7 @@ parse_simple_key (struct parsebuf *pb)
   size_t *set = NULL;
   int n = 0;
   
-  for (condp = condlist; condp->name && strcasecmp (condp->name, pb->token);
+  for (condp = condlist; condp->name && mu_c_strcasecmp (condp->name, 
pb->token);
        condp++)
     ;
 
diff --git a/imap4d/status.c b/imap4d/status.c
index 7546e5d..2f1c0b1 100644
--- a/imap4d/status.c
+++ b/imap4d/status.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2005, 2007, 2008, 
+   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
@@ -48,7 +49,7 @@ status_get_handler (const char *name)
   struct status_table *p;
 
   for (p = status_table; p->name; p++)
-    if (strcasecmp (p->name, name) == 0)
+    if (mu_c_strcasecmp (p->name, name) == 0)
       return p->fun;
   return NULL;
 }
diff --git a/imap4d/store.c b/imap4d/store.c
index c47c482..c4839a3 100644
--- a/imap4d/store.c
+++ b/imap4d/store.c
@@ -55,14 +55,14 @@ store_thunk (imap4d_parsebuf_t p)
   else
     pclos->how = STORE_SET;
   
-  if (strcasecmp (data, "FLAGS"))
+  if (mu_c_strcasecmp (data, "FLAGS"))
     imap4d_parsebuf_exit (p, "Bogus data item");
   data = imap4d_parsebuf_next (p, 1);
 
   if (*data == '.')
     {
       data = imap4d_parsebuf_next (p, 1);
-      if (strcasecmp (data, "SILENT") == 0)
+      if (mu_c_strcasecmp (data, "SILENT") == 0)
        {
          pclos->ack = 0;
          imap4d_parsebuf_next (p, 1);
diff --git a/imap4d/uid.c b/imap4d/uid.c
index d0afe26..40b9edb 100644
--- a/imap4d/uid.c
+++ b/imap4d/uid.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2007, 2008, 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
@@ -35,13 +35,13 @@ imap4d_uid (struct imap4d_command *command, imap4d_tokbuf_t 
tok)
 
   cmd = imap4d_tokbuf_getarg (tok, IMAP4_ARG_1);
   
-  if (strcasecmp (cmd, "FETCH") == 0)
+  if (mu_c_strcasecmp (cmd, "FETCH") == 0)
     rc = imap4d_fetch0 (tok, 1, &err_text);
-  else if (strcasecmp (cmd, "COPY") == 0)
+  else if (mu_c_strcasecmp (cmd, "COPY") == 0)
     rc = imap4d_copy0 (tok, 1, &err_text);
-  else if (strcasecmp (cmd, "STORE") == 0)
+  else if (mu_c_strcasecmp (cmd, "STORE") == 0)
     rc = imap4d_store0 (tok, 1, &err_text);
-  else if (strcasecmp (cmd, "SEARCH") == 0)
+  else if (mu_c_strcasecmp (cmd, "SEARCH") == 0)
     rc = imap4d_search0 (tok, 1, &err_text);
   else
     {
diff --git a/imap4d/util.c b/imap4d/util.c
index 618cab0..48e7077 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -452,16 +452,6 @@ util_do_command (imap4d_tokbuf_t tok)
   return command->func (command, tok);
 }
 
-int
-util_upper (char *s)
-{
-  if (!s)
-    return 0;
-  for (; *s; s++)
-    *s = toupper ((unsigned) *s);
-  return 0;
-}
-
 struct imap4d_command *
 util_getcommand (char *cmd, struct imap4d_command command_table[])
 {
@@ -470,7 +460,7 @@ util_getcommand (char *cmd, struct imap4d_command 
command_table[])
   for (i = 0; command_table[i].name != 0; i++)
     {
       if (strlen (command_table[i].name) == len &&
-         !strcasecmp (command_table[i].name, cmd))
+         !mu_c_strcasecmp (command_table[i].name, cmd))
        return &command_table[i];
     }
   return NULL;
@@ -598,7 +588,7 @@ util_attribute_to_type (const char *item, int *type)
 {
   int i;
   for (i = 0; i < _imap4d_nattr; i++)
-    if (strcasecmp (item, _imap4d_attrlist[i].name) == 0)
+    if (mu_c_strcasecmp (item, _imap4d_attrlist[i].name) == 0)
       {
        *type = _imap4d_attrlist[i].flag;
        return 0;
@@ -1100,7 +1090,7 @@ is_atom (const char *s)
     return 0;
   for (; *s; s++)
     {
-      if (*(const unsigned char *)s > 127 || iscntrl (*s))
+      if (mu_iscntrl (*s))
        return 0;
     }
   return 1;
@@ -1227,7 +1217,6 @@ imap4d_tokbuf_expand (struct imap4d_tokbuf *tok, size_t 
size)
 }
 
 #define ISDELIM(c) (strchr ("()", (c)) != NULL)
-#define ISWS(c) (c == ' ' || c == '\t')
 
 int
 util_isdelim (const char *str)
@@ -1253,7 +1242,7 @@ gettok (struct imap4d_tokbuf *tok, size_t off)
 {
   char *buf = tok->buffer;
   
-  while (off < tok->level && ISWS (buf[off]))
+  while (off < tok->level && mu_isblank (buf[off]))
     off++;
 
   if (tok->argc == tok->argmax)
@@ -1294,7 +1283,7 @@ gettok (struct imap4d_tokbuf *tok, size_t off)
   if (ISDELIM (buf[off]))
     return insert_nul (tok, off + 1);
 
-  while (off < tok->level && !ISWS (buf[off]))
+  while (off < tok->level && !mu_isblank (buf[off]))
     {
       if (ISDELIM (buf[off]))
        return insert_nul (tok, off);
@@ -1371,13 +1360,13 @@ imap4d_readline (struct imap4d_tokbuf *tok)
       if (transcript)
         {
           int len;
-          char *p = strcasestr (tok->buffer, "LOGIN");
-          if (p && p > tok->buffer && isspace(p[-1]))
+          char *p = mu_strcasestr (tok->buffer, "LOGIN");
+          if (p && p > tok->buffer && mu_isblank (p[-1]))
             {
               char *q = p + 5;
-              while (*q && isspace (*q))
+              while (*q && mu_isblank (*q))
                 q++;
-              while (*q && !isspace (*q))
+              while (*q && !mu_isblank (*q))
                 q++;
               len = q - tok->buffer; 
               mu_diag_output (MU_DIAG_DEBUG, "recv: %*.*s {censored}", len, 
len,
diff --git a/include/mailutils/Makefile.am b/include/mailutils/Makefile.am
index 9c200d5..b38f239 100644
--- a/include/mailutils/Makefile.am
+++ b/include/mailutils/Makefile.am
@@ -40,7 +40,9 @@ pkginclude_HEADERS = \
  attribute.h\
  auth.h\
  body.h\
+ cctype.h\
  cfg.h\
+ cstr.h\
  daemon.h\
  debug.h\
  diag.h\
diff --git a/include/mailutils/cctype.h b/include/mailutils/cctype.h
new file mode 100644
index 0000000..8a23eef
--- /dev/null
+++ b/include/mailutils/cctype.h
@@ -0,0 +1,74 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+/* Ctype functions for ASCII character set */
+
+#ifndef _MAILUTILS_MUCTYPE_H
+#define _MAILUTILS_MUCTYPE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MU_CTYPE_ALPHA   0x001
+#define MU_CTYPE_DIGIT   0x002
+#define MU_CTYPE_BLANK   0x004
+#define MU_CTYPE_CNTRL   0x008
+#define MU_CTYPE_GRAPH   0x010
+#define MU_CTYPE_LOWER   0x020
+#define MU_CTYPE_UPPER   0x040
+#define MU_CTYPE_PRINT   0x080
+#define MU_CTYPE_PUNCT   0x100
+#define MU_CTYPE_SPACE   0x200
+#define MU_CTYPE_XLETR   0x400
+
+#define MU_C_TAB_MAX     128
+
+extern int mu_c_tab[MU_C_TAB_MAX];
+
+#define mu_c_is_class(c, class) \
+  (((unsigned)(c)) < 128 && mu_c_tab[(unsigned)(c)] & (class))  
+
+#define mu_isalpha(c) mu_c_is_class (c, MU_CTYPE_ALPHA)
+#define mu_iscntrl(c) mu_c_is_class (c, MU_CTYPE_CNTRL)
+#define mu_isdigit(c) mu_c_is_class (c, MU_CTYPE_DIGIT)
+#define mu_isgraph(c) mu_c_is_class (c, MU_CTYPE_GRAPH)
+#define mu_islower(c) mu_c_is_class (c, MU_CTYPE_LOWER)
+#define mu_isprint(c) mu_c_is_class (c, MU_CTYPE_PRINT)
+#define mu_ispunct(c) mu_c_is_class (c, MU_CTYPE_PUNCT)
+#define mu_isspace(c) mu_c_is_class (c, MU_CTYPE_SPACE)
+#define mu_isupper(c) mu_c_is_class (c, MU_CTYPE_UPPER)
+#define mu_isxdigit(c) mu_c_is_class (c, MU_CTYPE_DIGIT|MU_CTYPE_XLETR)
+#define mu_isalnum(c) mu_c_is_class (c, MU_CTYPE_ALPHA|MU_CTYPE_DIGIT)
+#define mu_isascii(c) (((unsigned)c) < MU_C_TAB_MAX)
+#define mu_isblank(c) ((c) == ' ' || (c) == '\t')
+
+#define mu_tolower(c)                                  \
+  ({ int __c = (c);                                    \
+    (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
+  })
+
+#define mu_toupper(c)                                  \
+  ({ int __c = (c);                                    \
+    (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
+  })
+  
+#ifdef __cplusplus
+}
+#endif
+  
+#endif
diff --git a/include/mailutils/io.h b/include/mailutils/cstr.h
similarity index 54%
copy from include/mailutils/io.h
copy to include/mailutils/cstr.h
index b108743..fc80789 100644
--- a/include/mailutils/io.h
+++ b/include/mailutils/cstr.h
@@ -12,23 +12,34 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General
-   Public License along with this library; if not, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
 
-#ifndef _MAILUTILS_IO_H
-#define _MAILUTILS_IO_H
+#ifndef _MAILUTILS_CSTR_H
+#define _MAILUTILS_CSTR_H
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-int mu_asprintf (char **pbuf, const char *fmt, ...);
-int mu_asnprintf (char **pbuf, size_t *psize, const char *fmt, ...);
-int mu_vasnprintf (char **pbuf, size_t *psize, const char *fmt, va_list ap);
+int mu_strlower (char *);
+int mu_strupper (char *);
 
+int mu_c_strcasecmp (const char *a, const char *b);
+int mu_c_strncasecmp (const char *a, const char *b, size_t n);
+
+size_t mu_rtrim_class (char *str, int class);
+size_t mu_rtrim_cset (char *str, const char *cset);
+size_t mu_ltrim_class (char *str, int class);
+size_t mu_ltrim_cset (char *str, const char *cset);
+
+char *mu_str_skip_class (const char *str, int class);
+char *mu_str_skip_cset (const char *str, const char *cset);
+
+  
 #ifdef __cplusplus
 }
 #endif
-
+  
 #endif
+
diff --git a/include/mailutils/mailutils.h b/include/mailutils/mailutils.h
index a297ed7..68a0b68 100644
--- a/include/mailutils/mailutils.h
+++ b/include/mailutils/mailutils.h
@@ -63,5 +63,7 @@
 #include <mailutils/vartab.h>
 #include <mailutils/io.h>
 #include <mailutils/secret.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
 /* EOF */
diff --git a/include/mailutils/mutil.h b/include/mailutils/mutil.h
index bcb6292..7254f52 100644
--- a/include/mailutils/mutil.h
+++ b/include/mailutils/mutil.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2004, 2005, 
-   2006, 2007 Free Software Foundation, Inc.
+   2006, 2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -128,7 +128,7 @@ extern int mu_string_unfold (char *text, size_t *plen);
 extern int mu_unre_set_regex (const char *str, int caseflag, char **errp);
 extern int mu_unre_subject  (const char *subject, const char **new_subject);
 
-extern char *mu_charset_lookup (char *lang, char *terr);
+extern const char *mu_charset_lookup (char *lang, char *terr);
 
 extern int mu_true_answer_p (const char *p);
 extern int mu_scheme_autodetect_p (mu_url_t);
@@ -160,7 +160,7 @@ extern int mu_stream_flags_to_mode (int flags, int isdir);
 extern int mu_parse_stream_perm_string (int *pmode, const char *str,
                                        const char **endp);
   
-  
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/sys/pop3.h b/include/mailutils/sys/pop3.h
index c6dc142..35b1165 100644
--- a/include/mailutils/sys/pop3.h
+++ b/include/mailutils/sys/pop3.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2003, 2004, 
-   2007 Free Software Foundation, Inc.
+   2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <mailutils/pop3.h>
 #include <mailutils/errno.h>
+#include <mailutils/cstr.h>
 
 #ifdef DMALLOC
 # include <dmalloc.h>
@@ -138,7 +139,7 @@ while (0)
 #define MU_POP3_CHECK_OK(pop3) \
 do \
   { \
-     if (strncasecmp (pop3->ack.buf, "+OK", 3) != 0) \
+     if (mu_c_strncasecmp (pop3->ack.buf, "+OK", 3) != 0) \
        { \
           pop3->state = MU_POP3_NO_STATE; \
           return EACCES; \
diff --git a/libmu_argp/compat.c b/libmu_argp/compat.c
index d8ef7ee..efacd5a 100644
--- a/libmu_argp/compat.c
+++ b/libmu_argp/compat.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
+#include "mailutils/cctype.h"
 #include "mailutils/libargp.h"
 #include "mailutils/argcv.h"
 #include "mailutils/mutil.h"
@@ -83,7 +84,7 @@ read_rc (const char *progname, const char *name, const char 
*capa[],
       char *kwp, *p;
       int len;
       
-      for (kwp = buf; *kwp && isspace (*kwp); kwp++)
+      for (kwp = buf; *kwp && mu_isspace (*kwp); kwp++)
        ;
 
       if (*kwp == '#' || *kwp == 0)
@@ -125,7 +126,7 @@ read_rc (const char *progname, const char *name, const char 
*capa[],
       len = 0;
       if (progname)
        {
-         for (p = kwp; *p && !isspace (*p); p++)
+         for (p = kwp; *p && !mu_isspace (*p); p++)
            len++;
        }
       else
diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c
index 760c695..28fb084 100644
--- a/libmu_auth/ldap.c
+++ b/libmu_auth/ldap.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -569,16 +569,6 @@ _mu_ldap_search (LDAP *ld, const char *filter_pat, const 
char *key,
 }
 
 
-static int
-my_strncasecmp (const char *p, const char *q, size_t len)
-{
-  for ( ;len; len--, p++, q++)
-    {
-      if (*p != toupper (*q))
-       return 1;
-    }
-  return 0;
-}
 
 typedef int (*pwcheck_fp) (const char *, const char *);
 
@@ -755,7 +745,7 @@ find_pwcheck (const char *algo, int len)
 {
   struct passwd_algo *p;
   for (p = pwtab; p->algo; p++)
-    if (len == p->len && my_strncasecmp (p->algo, algo, len) == 0)
+    if (len == p->len && mu_strncasecmp (p->algo, algo, len) == 0)
       return p->pwcheck;
   return NULL;
 }
diff --git a/libmu_auth/sql.c b/libmu_auth/sql.c
index 58b6609..adb38fc 100644
--- a/libmu_auth/sql.c
+++ b/libmu_auth/sql.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 2002, 2003, 2004, 2005, 2006,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -250,7 +250,7 @@ decode_tuple_new (mu_sql_connection_t conn, int n,
   rc = get_field (conn, MU_AUTH_QUOTA, &squota, 0);
   if (rc == 0)
     {
-      if (strcasecmp (squota, "none") == 0)
+      if (mu_c_strcasecmp (squota, "none") == 0)
        quota = 0;
       else
        {
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index 5c73e42..7d9b363 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2006, 2007, 
+   2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -425,7 +426,7 @@ string_sloppy_member (SCM lst, char *name)
     {
       SCM car = SCM_CAR (lst);
       if (scm_is_string (car)
-         && strcasecmp (scm_i_string_chars (car), name) == 0)
+         && mu_c_strcasecmp (scm_i_string_chars (car), name) == 0)
        return 1;
     }
   return 0;
diff --git a/libmu_scm/mu_scm.h b/libmu_scm/mu_scm.h
index 8f04bf5..39e1e2e 100644
--- a/libmu_scm/mu_scm.h
+++ b/libmu_scm/mu_scm.h
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007 Free Software Foundation, 
Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007, 
+   2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -46,6 +47,7 @@
 #include <mailutils/mime.h>
 #include <mailutils/registrar.h>
 #include <mailutils/mu_auth.h>
+#include <mailutils/cstr.h>
 
 #include <mailutils/guile.h>
 
diff --git a/libmu_sieve/actions.c b/libmu_sieve/actions.c
index 65585dc..ae0bf21 100644
--- a/libmu_sieve/actions.c
+++ b/libmu_sieve/actions.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005, 
-   2006, 2007, 2008 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -382,7 +382,7 @@ check_redirect_loop (mu_message_t msg)
   for (i = 1; !loop && i <= num; i++)
     {
       mu_header_get_field_name (hdr, i, buf, sizeof buf, NULL);
-      if (strcasecmp (buf, "X-Loop-Prevention") == 0)
+      if (mu_c_strcasecmp (buf, "X-Loop-Prevention") == 0)
        {
          size_t j, cnt = 0;
          mu_address_t addr;
@@ -395,7 +395,7 @@ check_redirect_loop (mu_message_t msg)
          for (j = 1; !loop && j <= cnt; j++)
            {
              mu_address_get_email (addr, j, buf, sizeof buf, NULL);
-             if (strcasecmp (buf, email) == 0)
+             if (mu_c_strcasecmp (buf, email) == 0)
                loop = 1;
            }
          mu_address_destroy (&addr);
diff --git a/libmu_sieve/comparator.c b/libmu_sieve/comparator.c
index e9cf453..352c31b 100644
--- a/libmu_sieve/comparator.c
+++ b/libmu_sieve/comparator.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2004, 
-   2005, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,8 @@
 #include <sieve-priv.h>
 #include <fnmatch.h>
 #include <regex.h>
-#include <ctype.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
 typedef struct {
   const char *name;
@@ -148,10 +149,7 @@ struct regex_data {
 static int
 _pattern_upcase (void *item, void *data)
 {
-  char *p;
-
-  for (p = item; *p; p++)
-    *p = toupper (*p);
+  mu_strupper (item);
   return 0;
 }
 #endif
@@ -417,7 +415,7 @@ i_octet_eq (const char *pattern, const char *text)
 static int
 i_ascii_casemap_is (const char *pattern, const char *text)
 {
-  return strcasecmp (pattern, text) == 0;
+  return mu_c_strcasecmp (pattern, text) == 0;
 }
 
 static int
@@ -450,21 +448,21 @@ i_ascii_casemap_regex (const char *pattern, const char 
*text)
 static int
 i_ascii_casemap_eq (const char *pattern, const char *text)
 {
-  return strcasecmp (text, pattern);
+  return mu_c_strcasecmp (text, pattern);
 }
 
 /* :comparator i;ascii-numeric */
 static int
 i_ascii_numeric_is (const char *pattern, const char *text)
 {
-  if (isdigit ((int) *pattern))
+  if (mu_isdigit (*pattern))
     {
-      if (isdigit ((int) *text))
+      if (mu_isdigit (*text))
        return strtol (pattern, NULL, 10) == strtol (text, NULL, 10);
       else 
        return 0;
     }
-  else if (isdigit ((int) *text))
+  else if (mu_isdigit (*text))
     return 0;
   else
     return 1;
@@ -473,9 +471,9 @@ i_ascii_numeric_is (const char *pattern, const char *text)
 static int
 i_ascii_numeric_eq (const char *pattern, const char *text)
 {
-  if (isdigit ((int) *pattern))
+  if (mu_isdigit (*pattern))
     {
-      if (isdigit ((int) *text))
+      if (mu_isdigit (*text))
        {
          size_t a = strtoul (pattern, NULL, 10);
          size_t b = strtoul (text, NULL, 10);
diff --git a/libmu_sieve/extensions/list.c b/libmu_sieve/extensions/list.c
index 7eb896e..c10cf79 100644
--- a/libmu_sieve/extensions/list.c
+++ b/libmu_sieve/extensions/list.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 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 Lesser General Public License as published by
@@ -56,7 +56,7 @@ retrieve_next_header (struct header_closure *hc, char *name, 
char **pval)
   while (!mu_header_get_field_name (hc->header, hc->index, buf, sizeof(buf), 
&n))
     {
       int i = hc->index++;
-      if (strcasecmp (buf, name) == 0)
+      if (mu_c_strcasecmp (buf, name) == 0)
        {
          if (mu_header_aget_field_value (hc->header, i, &hc->value))
            return 1;
diff --git a/libmu_sieve/extensions/spamd.c b/libmu_sieve/extensions/spamd.c
index c502684..af3e594 100644
--- a/libmu_sieve/extensions/spamd.c
+++ b/libmu_sieve/extensions/spamd.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2007, 2008, 
+   2009 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -185,9 +186,9 @@ decode_float (long *vn, char *str, int digits)
 static int
 decode_boolean (char *str)
 {
-  if (strcasecmp (str, "true") == 0)
+  if (mu_c_strcasecmp (str, "true") == 0)
     return 1;
-  else if (strcasecmp (str, "false") == 0)
+  else if (mu_c_strcasecmp (str, "false") == 0)
     return 0;
   /*else?*/
   return 0;
diff --git a/libmu_sieve/extensions/vacation.c 
b/libmu_sieve/extensions/vacation.c
index 72715d2..e4a9cf1 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -252,8 +252,8 @@ bulk_precedence_p (mu_header_t hdr)
   char *str;
   if (mu_header_aget_value (hdr, MU_HEADER_PRECEDENCE, &str) == 0)
     {
-      rc = strcasecmp (str, "bulk") == 0
-          || strcasecmp (str, "junk") == 0;
+      rc = mu_c_strcasecmp (str, "bulk") == 0
+          || mu_c_strcasecmp (str, "junk") == 0;
       free (str);
     }
   return rc;
diff --git a/libmu_sieve/load.c b/libmu_sieve/load.c
index d160688..650c7ae 100644
--- a/libmu_sieve/load.c
+++ b/libmu_sieve/load.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,7 @@
 #include <string.h>
 #include <sieve-priv.h>
 #include <ltdl.h>
-#include <ctype.h>
+#include <mailutils/cctype.h>
 
 typedef int (*sieve_module_init_t) (mu_sieve_machine_t mach);
 
@@ -107,7 +107,7 @@ fix_module_name (char *name)
 {
   for (; *name; name++)
     {
-      if (isalnum (*name) || *name == '.' || *name == ',')
+      if (mu_isalnum (*name) || *name == '.' || *name == ',')
        continue;
       *name = '-';
     }
diff --git a/libmu_sieve/sieve.l b/libmu_sieve/sieve.l
index 3b50ae2..8322049 100644
--- a/libmu_sieve/sieve.l
+++ b/libmu_sieve/sieve.l
@@ -1,7 +1,7 @@
 %{
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -29,7 +29,7 @@
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
-#include <ctype.h>
+#include <mailutils/cctype.h>
 #include <mailutils/argcv.h>
 #include <sieve-priv.h>
 #include <sieve-gram.h>
@@ -368,7 +368,7 @@ sieve_include ()
   int usepath;
   
   p = strstr (yytext, "include");
-  for (p += 7; p < endp && isspace (*p); p++)
+  for (p += 7; p < endp && mu_isspace (*p); p++)
     ;
 
   name = get_file_name (p, endp, &usepath);
@@ -399,12 +399,12 @@ sieve_searchpath ()
   char *p, *endp = yytext + yyleng, *name;
   
   p = strstr (yytext, "searchpath");
-  for (p += 10; p < endp && isspace (*p); p++)
+  for (p += 10; p < endp && mu_isspace (*p); p++)
     ;
   if (strcmp (p, "add") == 0)
     {
       append = 1;
-      for (p += 3; p < endp && isspace (*p); p++)
+      for (p += 3; p < endp && mu_isspace (*p); p++)
        ;
     }
   name = get_file_name (p, endp, NULL);
@@ -482,7 +482,7 @@ string ()
 static int
 isemptystr (char *text)
 {
-  for (; *text && isspace (*text); text++)
+  for (; *text && mu_isspace (*text); text++)
     ;
   return *text == 0;
 }
@@ -551,13 +551,13 @@ multiline_begin ()
   else
     strip_tabs = 0;
 
-  if (!isspace (*p))
+  if (!mu_isspace (*p))
     {
       char *endp;
       int len;
       
       for (endp = p; *endp; endp++)
-       if (isspace (*endp))
+       if (mu_isspace (*endp))
          break;
 
       len = endp - p;
diff --git a/libmu_sieve/tests.c b/libmu_sieve/tests.c
index 9148a87..fd0f824 100644
--- a/libmu_sieve/tests.c
+++ b/libmu_sieve/tests.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -166,7 +166,7 @@ retrieve_header (void *item, void *data, int idx, char 
**pval)
   while (!mu_header_get_field_name (hc->header, hc->index, buf, sizeof(buf), 
&n))
     {
       int i = hc->index++;
-      if (strcasecmp (buf, (char*)item) == 0)
+      if (mu_c_strcasecmp (buf, (char*)item) == 0)
        {
          if (mu_header_aget_field_value_unfold (hc->header, i, pval))
            return 1;
@@ -245,7 +245,7 @@ retrieve_envelope (void *item, void *data, int idx, char 
**pval)
     {
       const char *buf;
       
-      if (strcasecmp ((char*)item, "from") != 0)
+      if (mu_c_strcasecmp ((char*)item, "from") != 0)
        return 1;
 
       if (mu_envelope_sget_sender ((mu_envelope_t)ap->data, &buf))
diff --git a/libproto/imap/folder.c b/libproto/imap/folder.c
index e34e874..81faa71 100644
--- a/libproto/imap/folder.c
+++ b/libproto/imap/folder.c
@@ -24,7 +24,6 @@
 #ifdef ENABLE_IMAP
 
 #include <stdlib.h>
-#include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <string.h>
@@ -51,6 +50,9 @@
 #include <mailutils/tls.h>
 #include <mailutils/nls.h>
 #include <mailutils/secret.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
 /* For dbg purposes set to one to see different level of traffic.  */
 /* Print to stderr the command sent to the IMAP server.  */
@@ -382,7 +384,7 @@ find_auth_method (const char *name)
   struct auth_tab *p;
 
   for (p = auth_tab; p->name; p++)
-    if (strcasecmp (p->name, name) == 0)
+    if (mu_c_strcasecmp (p->name, name) == 0)
       return p->method;
 
   return NULL;
@@ -484,7 +486,7 @@ folder_imap_get_authority (mu_folder_t folder, 
mu_authority_t *pauth)
        return EINVAL;
 
       if (folder->url->auth == NULL
-         || strcasecmp (folder->url->auth, "*") == 0)
+         || strcmp (folder->url->auth, "*") == 0)
        {
          status = folder_set_auth_method (folder, authenticate_imap_select);
        }
@@ -552,7 +554,7 @@ check_capa (f_imap_t f_imap, char *capa)
 
   read_capa (f_imap, 0);
   for (i = 0; i < f_imap->capac; i++)
-    if (strcasecmp (f_imap->capav[i], capa) == 0)
+    if (mu_c_strcasecmp (f_imap->capav[i], capa) == 0)
       return 0;
   return 1;
 }
@@ -722,13 +724,13 @@ folder_imap_open (mu_folder_t folder, int flags)
        /* Are they open for business ?  The server send an untagged response
           for greeting. Tecnically it can be OK/PREAUTH/BYE.  The BYE is
           the one that we do not want, server being unfriendly.  */
-       if (strncasecmp (f_imap->buffer, "* PREAUTH", 9) == 0)
+       if (mu_c_strncasecmp (f_imap->buffer, "* PREAUTH", 9) == 0)
          {
            f_imap->state = IMAP_AUTH_DONE;
          }
        else
          {
-            if (strncasecmp (f_imap->buffer, "* OK", 4) != 0)
+            if (mu_c_strncasecmp (f_imap->buffer, "* OK", 4) != 0)
               CHECK_ERROR_CLOSE (folder, f_imap, EACCES);
             f_imap->state = IMAP_AUTH;
          }
@@ -1334,7 +1336,7 @@ imap_digits (f_imap_t f_imap, char **ptr)
   char *start = *ptr;
   int len;
   
-  for (++*ptr; **ptr && isdigit(**ptr); ++*ptr)
+  for (++*ptr; **ptr && mu_isdigit(**ptr); ++*ptr)
     ;
   len = *ptr - start;
   mu_stream_write (f_imap->string.stream, start, len,
@@ -1379,7 +1381,7 @@ imap_string (f_imap_t f_imap, char **ptr)
       break;
       
     default:
-      if (isdigit (**ptr))
+      if (mu_isdigit (**ptr))
        status = imap_digits (f_imap, ptr);
       else
        /* Problem. FIXME: Return a more appropriate error code */
@@ -1433,12 +1435,12 @@ imap_list (f_imap_t f_imap)
       char *p = tok;
       while ((tok = strtok_r (p, " ()", &s)) != NULL)
        {
-         if (strcasecmp (tok, "\\Noselect") == 0)
+         if (mu_c_strcasecmp (tok, "\\Noselect") == 0)
            lr->type |= MU_FOLDER_ATTRIBUTE_DIRECTORY;
-         else if (strcasecmp (tok, "\\Noinferiors") == 0)
+         else if (mu_c_strcasecmp (tok, "\\Noinferiors") == 0)
            lr->type |= MU_FOLDER_ATTRIBUTE_FILE;
-         else if (strcasecmp (tok, "\\Marked") == 0
-                  || strcasecmp (tok, "\\Unmarked") == 0)
+         else if (mu_c_strcasecmp (tok, "\\Marked") == 0
+                  || mu_c_strcasecmp (tok, "\\Unmarked") == 0)
            /* nothing */;
          else
            lr->type |= MU_FOLDER_ATTRIBUTE_DIRECTORY;
@@ -1453,7 +1455,7 @@ imap_list (f_imap_t f_imap)
       
       /* Hiearchy delimeter.  */
       tok = argv[0];
-      if (tok && tok[1] == 0 && strcasecmp (tok, "NIL"))
+      if (tok && tok[1] == 0 && mu_c_strcasecmp (tok, "NIL"))
        lr->separator = tok[0];
       /* The path.  */
       tok = argv[1];
@@ -1607,7 +1609,7 @@ imap_bodystructure0 (msg_imap_t msg_imap, char **ptr)
            no_arg = 0;
        }
 
-      if (isdigit ((unsigned)**ptr))
+      if (mu_isdigit ((unsigned)**ptr))
        {
          char *start = *ptr;
          size_t size = strtoul (*ptr, ptr, 10);
@@ -1751,7 +1753,7 @@ imap_flags (char **ptr, int *pflags)
       while (**ptr && **ptr != ' ' && **ptr != ')')
         ++(*ptr);
 
-      /* Save the end for the strcasecmp.  */
+      /* Save the end for the mu_c_strcasecmp.  */
       end = *ptr;
 
       /* Bail out.  */
@@ -1763,27 +1765,27 @@ imap_flags (char **ptr, int *pflags)
        flags |= MU_ATTRIBUTE_SEEN;
       else
        {
-         if (strncasecmp (start, "\\Seen", end - start) == 0)
+         if (mu_c_strncasecmp (start, "\\Seen", end - start) == 0)
            {
              flags |= MU_ATTRIBUTE_READ;
            }
-         else if (strncasecmp (start, "\\Answered", end - start) == 0)
+         else if (mu_c_strncasecmp (start, "\\Answered", end - start) == 0)
            {
              flags |= MU_ATTRIBUTE_ANSWERED;
            }
-         else if (strncasecmp (start, "\\Flagged", end - start) == 0)
+         else if (mu_c_strncasecmp (start, "\\Flagged", end - start) == 0)
            {
              flags |= MU_ATTRIBUTE_FLAGGED;
            }
-         else if (strncasecmp (start, "\\Deleted", end - start) == 0)
+         else if (mu_c_strncasecmp (start, "\\Deleted", end - start) == 0)
            {
              flags |= MU_ATTRIBUTE_DELETED;
            }
-         else if (strncasecmp (start, "\\Draft", end - start) == 0)
+         else if (mu_c_strncasecmp (start, "\\Draft", end - start) == 0)
            {
              flags |= MU_ATTRIBUTE_DRAFT;
            }
-         else if (strncasecmp (start, "\\Recent", end - start))
+         else if (mu_c_strncasecmp (start, "\\Recent", end - start))
            flags |= MU_ATTRIBUTE_SEEN;
        }
     }
@@ -1823,8 +1825,7 @@ imap_body (f_imap_t f_imap, char **ptr)
          strncpy (section, *ptr, len);
          section[len] = '\0';
          /* strupper.  */
-         for (p = section; *p; p++)
-           *p = toupper ((unsigned)*p);
+         mu_strupper (section);
          
          /* Set the string type to update the correct line count.  */
          /*if (!strstr (section, "FIELD"))*/
@@ -2007,14 +2008,14 @@ imap_fetch (f_imap_t f_imap)
        {
          status = imap_fetch_flags (f_imap, &sp);
        }
-      else if (strcasecmp (token, "BODY") == 0)
+      else if (mu_c_strcasecmp (token, "BODY") == 0)
        {
          if (*sp == '[')
            status = imap_body (f_imap, &sp);
          else
            status = imap_bodystructure (f_imap, &sp);
        }
-      else if (strcasecmp (token, "BODYSTRUCTURE") == 0)
+      else if (mu_c_strcasecmp (token, "BODYSTRUCTURE") == 0)
        {
          status = imap_bodystructure (f_imap, &sp);
        }
@@ -2028,15 +2029,15 @@ imap_fetch (f_imap_t f_imap)
            {
              sp++;
              imap_token (token, sizeof token, &sp);
-             if (strcasecmp (token, "SIZE") == 0)
+             if (mu_c_strcasecmp (token, "SIZE") == 0)
                {
                  status = imap_rfc822_size (f_imap, &sp);
                }
-             else if (strcasecmp (token, "TEXT") == 0)
+             else if (mu_c_strcasecmp (token, "TEXT") == 0)
                {
                  status = imap_rfc822_text (f_imap, &sp);
                }
-             else if (strcasecmp (token, "HEADER") == 0)
+             else if (mu_c_strcasecmp (token, "HEADER") == 0)
                {
                  status = imap_rfc822_header (f_imap, &sp);
                }
@@ -2117,13 +2118,13 @@ imap_token (char *buf, size_t len, char **ptr)
    name no matter what the case is).
    */
 static int
-imap_mailbox_name_match(const char* pattern, const char* mailbox)
+imap_mailbox_name_match (const char* pattern, const char* mailbox)
 {
-  if(strcasecmp(pattern, "inbox") == 0)
-  {
-    return strcasecmp(pattern, mailbox);
-  }
-  return fnmatch(pattern, mailbox, 0);
+  if (mu_c_strcasecmp (pattern, "inbox") == 0)
+    {
+      return mu_c_strcasecmp (pattern, mailbox);
+    }
+  return fnmatch (pattern, mailbox, 0);
 }
 
 /* C99 says that a conforming implementations of snprintf () should return the
@@ -2351,7 +2352,7 @@ imap_parse (f_imap_t f_imap)
          MU_DEBUG2 (folder->debug, MU_DEBUG_PROT, "* %s %s\n",
                     response, remainder);
          /* Is it a Status Response.  */
-         if (strcasecmp (response, "OK") == 0)
+         if (mu_c_strcasecmp (response, "OK") == 0)
            {
              /* Check for status response [code].  */
              if (*remainder == '[')
@@ -2364,14 +2365,14 @@ imap_parse (f_imap_t f_imap)
                  subtag = strtok_r (cruft, " ", &sp1);
                  if (!subtag) subtag = empty;
 
-                 if (strcasecmp (subtag, "ALERT") == 0)
+                 if (mu_c_strcasecmp (subtag, "ALERT") == 0)
                    {
                      /* The human-readable text contains a special alert that
                         MUST be presented to the user in a fashion that calls
                         the user's attention to the message.  */
                      mu_error (_("ALERT: %s"), (sp) ? sp : "");
                    }
-                 else if (strcasecmp (subtag, "BADCHARSET") == 0)
+                 else if (mu_c_strcasecmp (subtag, "BADCHARSET") == 0)
                    {
                      /* Optionally followed by a parenthesized list of
                         charsets.  A SEARCH failed because the given charset
@@ -2380,7 +2381,7 @@ imap_parse (f_imap_t f_imap)
                         charsets that are supported by this implementation. */
                      mu_error (_("BAD CHARSET: %s"), (sp) ? sp : "");
                    }
-                 else if (strcasecmp (subtag, "CAPABILITY") == 0)
+                 else if (mu_c_strcasecmp (subtag, "CAPABILITY") == 0)
                    {
                      /* Followed by a list of capabilities.  This can appear
                         in the initial OK or PREAUTH response to transmit an
@@ -2389,7 +2390,7 @@ imap_parse (f_imap_t f_imap)
                         it recognizes this response.  */
                      parse_capa (f_imap, cruft);
                    }
-                 else if (strcasecmp (subtag, "NEWNAME") == 0)
+                 else if (mu_c_strcasecmp (subtag, "NEWNAME") == 0)
                    {
                      /* Followed by a mailbox name and a new mailbox name.  A
                         SELECT or EXAMINE failed because the target mailbox
@@ -2399,14 +2400,14 @@ imap_parse (f_imap_t f_imap)
                         reissued with the new mailbox name. */
                      mu_error ("NEWNAME: %s", (sp) ? sp : "");
                    }
-                 else if (strcasecmp (subtag, "PARSE") == 0)
+                 else if (mu_c_strcasecmp (subtag, "PARSE") == 0)
                    {
                      /* The human-readable text represents an error in
                         parsing the [RFC-822] header or [MIME-IMB] headers
                         of a message in the mailbox.  */
                      mu_error ("PARSE: %s", (sp) ? sp : "");
                    }
-                 else if (strcasecmp (subtag, "PERMANENTFLAGS") == 0)
+                 else if (mu_c_strcasecmp (subtag, "PERMANENTFLAGS") == 0)
                    {
                      /* Followed by a parenthesized list of flags, indicates
                         which of the known flags that the client can change
@@ -2421,19 +2422,19 @@ imap_parse (f_imap_t f_imap)
                         that it is possible to create new keywords by
                         attempting to store those flags in the mailbox.  */
                    }
-                 else if (strcasecmp (subtag, "READ-ONLY") == 0)
+                 else if (mu_c_strcasecmp (subtag, "READ-ONLY") == 0)
                    {
                      /* The mailbox is selected read-only, or its access
                         while selected has changed from read-write to
                         read-only.  */
                    }
-                 else if (strcasecmp (subtag, "READ-WRITE") == 0)
+                 else if (mu_c_strcasecmp (subtag, "READ-WRITE") == 0)
                    {
                      /* The mailbox is selected read-write, or its access
                         while selected has changed from read-only to
                         read-write.  */
                    }
-                 else if (strcasecmp (subtag, "TRYCREATE") == 0)
+                 else if (mu_c_strcasecmp (subtag, "TRYCREATE") == 0)
                    {
                      /* An APPEND or COPY attempt is failing because the
                         target mailbox does not exist (as opposed to some
@@ -2442,7 +2443,7 @@ imap_parse (f_imap_t f_imap)
                         created by the CREATE command.  */
                      mu_error ("TRYCREATE: %s", (sp) ? sp : "");
                    }
-                 else if (strcasecmp (subtag, "UIDNEXT") == 0)
+                 else if (mu_c_strcasecmp (subtag, "UIDNEXT") == 0)
                    {
                      /* Followed by a decimal number, indicates the next
                         unique identifier value.  Refer to section 2.3.1.1
@@ -2451,7 +2452,7 @@ imap_parse (f_imap_t f_imap)
                      if (value)
                        f_imap->selected->uidnext = strtol (value, NULL, 10);
                    }
-                 else if (strcasecmp (subtag, "UIDVALIDITY") == 0)
+                 else if (mu_c_strcasecmp (subtag, "UIDVALIDITY") == 0)
                    {
                      /* Followed by a decimal number, indicates the unique
                         identifier validity value.  Refer to section 2.3.1.1
@@ -2461,7 +2462,7 @@ imap_parse (f_imap_t f_imap)
                        f_imap->selected->uidvalidity = strtol (value,
                                                                NULL, 10);
                    }
-                 else if (strcasecmp (subtag, "UNSEEN") == 0)
+                 else if (mu_c_strcasecmp (subtag, "UNSEEN") == 0)
                    {
                      /* Followed by a decimal number, indicates the number of
                         the first message without the \Seen flag set.  */
@@ -2485,21 +2486,21 @@ imap_parse (f_imap_t f_imap)
                  mu_error (_("Untagged OK: %s"), remainder);
                }
            }
-         else if (strcasecmp (response, "NO") == 0)
+         else if (mu_c_strcasecmp (response, "NO") == 0)
            {
              /* This does not mean failure but rather a strong warning.  */
              mu_error (_("Untagged NO: %s"), remainder);
            }
-         else if (strcasecmp (response, "BAD") == 0)
+         else if (mu_c_strcasecmp (response, "BAD") == 0)
            {
              /* We're dead, protocol/syntax error.  */
              mu_error (_("Untagged BAD: %s"), remainder);
            }
-         else if (strcasecmp (response, "PREAUTH") == 0)
+         else if (mu_c_strcasecmp (response, "PREAUTH") == 0)
            {
              /* Should we be dealing with this?  */
            }
-         else if (strcasecmp (response, "BYE") == 0)
+         else if (mu_c_strcasecmp (response, "BYE") == 0)
            {
              /* We should close the stream. This is not recoverable.  */
              done = 1;
@@ -2509,47 +2510,47 @@ imap_parse (f_imap_t f_imap)
              mu_monitor_unlock (f_imap->folder->monitor);
              mu_stream_close (f_imap->folder->stream);
            }
-         else if (strcasecmp (response, "CAPABILITY") == 0)
+         else if (mu_c_strcasecmp (response, "CAPABILITY") == 0)
            {
              parse_capa (f_imap, remainder);
            }
-         else if (strcasecmp (remainder, "EXISTS") == 0)
+         else if (mu_c_strcasecmp (remainder, "EXISTS") == 0)
            {
              f_imap->selected->messages_count = strtol (response, NULL, 10);
            }
-         else if (strcasecmp (remainder, "EXPUNGE") == 0)
+         else if (mu_c_strcasecmp (remainder, "EXPUNGE") == 0)
            {
              unsigned int msgno = strtol (response, NULL, 10);
              status = imap_expunge (f_imap, msgno);
            }
-         else if (strncasecmp (remainder, "FETCH", 5) == 0)
+         else if (mu_c_strncasecmp (remainder, "FETCH", 5) == 0)
            {
              status = imap_fetch (f_imap);
              if (status != 0)
                break;
            }
-         else if (strcasecmp (response, "FLAGS") == 0)
+         else if (mu_c_strcasecmp (response, "FLAGS") == 0)
            {
              /* Flags define on the mailbox not a message flags.  */
              status = imap_permanentflags (f_imap, &remainder);
            }
-         else if (strcasecmp (response, "LIST") == 0)
+         else if (mu_c_strcasecmp (response, "LIST") == 0)
            {
              status = imap_list (f_imap);
            }
-         else if (strcasecmp (response, "LSUB") == 0)
+         else if (mu_c_strcasecmp (response, "LSUB") == 0)
            {
              status = imap_list (f_imap);
            }
-         else if (strcasecmp (remainder, "RECENT") == 0)
+         else if (mu_c_strcasecmp (remainder, "RECENT") == 0)
            {
              f_imap->selected->recent = strtol (response, NULL, 10);
            }
-         else if (strcasecmp (response, "SEARCH") == 0)
+         else if (mu_c_strcasecmp (response, "SEARCH") == 0)
            {
              status = imap_search (f_imap);
            }
-         else if (strcasecmp (response, "STATUS") == 0)
+         else if (mu_c_strcasecmp (response, "STATUS") == 0)
            {
              status = imap_status (f_imap);
            }
@@ -2569,13 +2570,13 @@ imap_parse (f_imap_t f_imap)
        {
          /* Every transaction ends with a tagged response.  */
          done = 1;
-         if (strcasecmp (response, "OK") == 0)
+         if (mu_c_strcasecmp (response, "OK") == 0)
            {
              /* Cool we are doing ok.  */
            }
-         else if (strcasecmp (response, "NO") == 0)
+         else if (mu_c_strcasecmp (response, "NO") == 0)
            {
-             if (strncasecmp (remainder, "LOGIN", 5) == 0)
+             if (mu_c_strncasecmp (remainder, "LOGIN", 5) == 0)
                {
                  mu_observable_t observable = NULL;
                  mu_folder_get_observable (f_imap->folder, &observable);
@@ -2583,7 +2584,7 @@ imap_parse (f_imap_t f_imap)
                                        NULL);
                  status = MU_ERR_AUTH_FAILURE;
                }
-             else if (strncasecmp (remainder, "LIST", 4) == 0)
+             else if (mu_c_strncasecmp (remainder, "LIST", 4) == 0)
                status = MU_ERR_NOENT;
              else
                status = MU_ERR_FAILURE;
diff --git a/libproto/mailer/smtp.c b/libproto/mailer/smtp.c
index da5e820..e64daef 100644
--- a/libproto/mailer/smtp.c
+++ b/libproto/mailer/smtp.c
@@ -28,7 +28,6 @@
 #ifdef ENABLE_SMTP
 
 #include <errno.h>
-#include <ctype.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <stdarg.h>
@@ -49,6 +48,8 @@
 #include <mailutils/stream.h>
 #include <mailutils/url.h>
 #include <mailutils/tls.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
 #include <mailer0.h>
 #include <url0.h>
@@ -529,7 +530,7 @@ smtp_writer (void *iodata, char *buf)
 {
   smtp_t iop = iodata;
   int status;
-  if (strncasecmp (buf, "EHLO", 4) == 0)
+  if (mu_c_strncasecmp (buf, "EHLO", 4) == 0)
     status = smtp_writeline (iop, "%s %s\r\n", buf, iop->localhost);
   else
     status = smtp_writeline (iop, "%s\r\n", buf);
@@ -829,8 +830,8 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t argmsg, 
mu_address_t argfrom
                status = smtp_writeline (smtp, ".%s", data);
                CHECK_ERROR (smtp, status);
              }
-           else if (strncasecmp (data, MU_HEADER_FCC,
-                                 sizeof (MU_HEADER_FCC) - 1))
+           else if (mu_c_strncasecmp (data, MU_HEADER_FCC,
+                                      sizeof (MU_HEADER_FCC) - 1))
              {
                status = smtp_writeline (smtp, "%s", data);
                CHECK_ERROR (smtp, status);
@@ -1066,7 +1067,7 @@ smtp_writeline (smtp_t smtp, const char *format, ...)
 
   smtp->ptr = smtp->buffer + len;
 
-  while (len > 0 && isspace (smtp->buffer[len - 1]))
+  while (len > 0 && mu_isblank (smtp->buffer[len - 1]))
     len--;
 
   if ((smtp->state != SMTP_SEND && smtp->state != SMTP_SEND_DOT)
@@ -1138,9 +1139,9 @@ smtp_parse_ehlo_ack (smtp_t smtp)
       if (status == 0) {
        smtp->ptr = smtp->buffer;
 
-       if (!strncasecmp (smtp->buffer, "250-STARTTLS", 12))
+       if (!mu_c_strncasecmp (smtp->buffer, "250-STARTTLS", 12))
          smtp->capa |= CAPA_STARTTLS;
-       else if (!strncasecmp (smtp->buffer, "250-SIZE", 8))
+       else if (!mu_c_strncasecmp (smtp->buffer, "250-SIZE", 8))
          {
            smtp->capa |= CAPA_SIZE;
            if (smtp->buffer[8] == '=')
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c
index 37b980c..2d8fbdb 100644
--- a/libproto/mbox/mbox.c
+++ b/libproto/mbox/mbox.c
@@ -24,6 +24,7 @@
 #endif
 
 #include <mbox0.h>
+#include <mailutils/cstr.h>
 #include <mailutils/io.h>
 
 #define ATTRIBUTE_IS_DELETED(flag)        (flag & MU_ATTRIBUTE_DELETED)
@@ -1550,11 +1551,11 @@ mbox_append_message0 (mu_mailbox_t mailbox, 
mu_message_t msg, mu_off_t *psize,
               FIXME:
               - We have a problem here the header may not fit the buffer.
               - Should  we skip the IMAP "X-Status"? */
-           if ((strncasecmp (buffer, "Status", 6) == 0)
-               || (strncasecmp (buffer, "X-IMAPbase", 10) == 0)
+           if ((mu_c_strncasecmp (buffer, "Status", 6) == 0)
+               || (mu_c_strncasecmp (buffer, "X-IMAPbase", 10) == 0)
                /* FIXME: isn't the length of "X-UID" 5, not 4? And
                 this will match X-UID and X-UIDL, is this intended? */
-               || (strncasecmp (buffer, "X-UID", 4) == 0
+               || (mu_c_strncasecmp (buffer, "X-UID", 4) == 0
                    && (buffer[5] == ':' || buffer[5] == ' '
                        || buffer[5] == '\t')))
              continue;
diff --git a/libproto/mh/folder.c b/libproto/mh/folder.c
index de5ba9d..5a40b4a 100644
--- a/libproto/mh/folder.c
+++ b/libproto/mh/folder.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2003, 2004, 2005,
-   2007 Free Software Foundation, Inc.
+   2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,6 @@
 #include <sys/stat.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <errno.h>
 #include <unistd.h>
 #include <dirent.h>
@@ -37,6 +36,7 @@
 #include <registrar0.h>
 #include <amd.h>
 #include <mailutils/mutil.h>
+#include <mailutils/cctype.h>
 
 static int
 _mh_folder_init (mu_folder_t folder MU_ARG_UNUSED)
@@ -49,7 +49,7 @@ static int
 mh_message_name_p (const char *name)
 {
   for ( ; *name; name++)
-    if (!isdigit (*name))
+    if (!mu_isdigit (*name))
       return 0;
   return 1;
 }
@@ -130,7 +130,7 @@ _mh_list_p (mu_record_t record, const char *name, int flags 
MU_ARG_UNUSED)
     return 0;
 
   for (; *name; name++)
-    if (!(isascii (*name) && isdigit (*name)))
+    if (!mu_isdigit (*name))
       return 1;
   return 0;
 }
diff --git a/libproto/mh/mbox.c b/libproto/mh/mbox.c
index f2bdb9c..8c5df9d 100644
--- a/libproto/mh/mbox.c
+++ b/libproto/mh/mbox.c
@@ -33,7 +33,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-#include <ctype.h>
 #include <dirent.h>
 
 #ifdef WITH_PTHREAD
@@ -64,6 +63,7 @@
 #include <mailutils/url.h>
 #include <mailutils/observer.h>
 #include <mailutils/io.h>
+#include <mailutils/cctype.h>
 #include <mailbox0.h>
 #include <registrar0.h>
 #include <amd.h>
@@ -302,10 +302,10 @@ mh_qfetch (struct _amd_data *amd, mu_message_qid_t qid)
   struct _mh_message *msg;
 
   p = qid + strlen (qid) - 1;
-  if (!isdigit (*p))
+  if (!mu_isdigit (*p))
     return EINVAL;
   
-  for (p--; p >= qid && isdigit (*p); p--)
+  for (p--; p >= qid && mu_isdigit (*p); p--)
     ;
 
   if (p == qid)
diff --git a/libproto/pop/folder.c b/libproto/pop/folder.c
index f80f6db..5aa4dc0 100644
--- a/libproto/pop/folder.c
+++ b/libproto/pop/folder.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2003, 2005, 
-   2007 Free Software Foundation, Inc.
+   2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -34,6 +34,7 @@
 #include <mailutils/auth.h>
 #include <mailutils/errno.h>
 #include <mailutils/mailbox.h>
+#include <mailutils/mutil.h>
 
 #include <folder0.h>
 #include <registrar0.h>
@@ -131,7 +132,7 @@ folder_pop_get_authority (mu_folder_t folder, 
mu_authority_t *pauth)
        return EINVAL;
 
       if (folder->url->auth == NULL
-         || strcasecmp (folder->url->auth, "*") == 0)
+         || strcmp (folder->url->auth, "*") == 0)
        {
          status = mu_authority_create (&folder->authority, NULL, folder);
          mu_authority_set_authenticate (folder->authority, _pop_user, folder);
@@ -141,7 +142,7 @@ folder_pop_get_authority (mu_folder_t folder, 
mu_authority_t *pauth)
        Anything else starting with "+" is an extension mechanism.
        Without a "+" it's a SASL mechanism.
       */
-      else if (strcasecmp (folder->url->auth, "+APOP") == 0)
+      else if (mu_c_strcasecmp (folder->url->auth, "+APOP") == 0)
        {
          status = mu_authority_create (&folder->authority, NULL, folder);
          mu_authority_set_authenticate (folder->authority, _pop_apop, folder);
diff --git a/libproto/pop/mbox.c b/libproto/pop/mbox.c
index 655af16..83f01cf 100644
--- a/libproto/pop/mbox.c
+++ b/libproto/pop/mbox.c
@@ -33,7 +33,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdarg.h>
-#include <ctype.h>
 
 #ifdef HAVE_STRINGS_H
 # include <strings.h>
@@ -55,6 +54,8 @@
 #include <mailutils/tls.h>
 #include <mailutils/md5.h>
 #include <mailutils/io.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cctype.h>
 
 #include <folder0.h>
 #include <mailbox0.h>
@@ -424,7 +425,7 @@ static int
 pop_parse_capa (pop_data_t mpd)
 {
   int status;
-  if (!strncasecmp (mpd->buffer, "+OK", 3))
+  if (!mu_c_strncasecmp (mpd->buffer, "+OK", 3))
     {
       mpd->capa = 0;
       do
@@ -443,13 +444,13 @@ pop_parse_capa (pop_data_t mpd)
             Note that there is no APOP capability, even though APOP
             is an optional command in POP3. -- W.P. */
 
-         if (!strncasecmp (mpd->buffer, "TOP", 3))
+         if (!mu_c_strncasecmp (mpd->buffer, "TOP", 3))
            mpd->capa |= CAPA_TOP;
-         else if (!strncasecmp (mpd->buffer, "USER", 4))
+         else if (!mu_c_strncasecmp (mpd->buffer, "USER", 4))
            mpd->capa |= CAPA_USER;
-         else if (!strncasecmp (mpd->buffer, "UIDL", 4))
+         else if (!mu_c_strncasecmp (mpd->buffer, "UIDL", 4))
            mpd->capa |= CAPA_UIDL;
-         else if (!strncasecmp (mpd->buffer, "STLS", 4))
+         else if (!mu_c_strncasecmp (mpd->buffer, "STLS", 4))
            mpd->capa |= CAPA_STLS;
        }
       while (mpd->nl);
@@ -525,7 +526,7 @@ _pop_user (mu_authority_t auth)
       status = pop_read_ack (mpd);
       CHECK_EAGAIN (mpd, status);
       MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
-      if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+      if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
        {
          mu_observable_t observable = NULL;
          mu_mailbox_get_observable (mbox, &observable);
@@ -564,7 +565,7 @@ _pop_user (mu_authority_t auth)
       status = pop_read_ack (mpd);
       CHECK_EAGAIN (mpd, status);
       MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
-      if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+      if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
        {
          mu_observable_t observable = NULL;
          mu_mailbox_get_observable (mbox, &observable);
@@ -636,7 +637,7 @@ _pop_apop (mu_authority_t auth)
       status = pop_read_ack (mpd);
       CHECK_EAGAIN (mpd, status);
       MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
-      if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+      if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
         {
           mu_observable_t observable = NULL;
           mu_mailbox_get_observable (mbox, &observable);
@@ -666,7 +667,7 @@ pop_reader (void *iodata)
   status = pop_read_ack (iop);
   CHECK_EAGAIN (iop, status);
   MU_DEBUG (iop->mbox->debug, MU_DEBUG_PROT, iop->buffer);
-  return status;//strncasecmp (iop->buffer, "+OK", 3) == 0;
+  return status;/*mu_c_strncasecmp (iop->buffer, "+OK", 3) == 0;*/
 }
 
 static int
@@ -822,7 +823,7 @@ pop_open (mu_mailbox_t mbox, int flags)
        status = pop_read_ack (mpd);
        CHECK_EAGAIN (mpd, status);
        MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
-       if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+       if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
          {
            CHECK_ERROR_CLOSE (mbox, mpd, EACCES);
          }
@@ -918,7 +919,7 @@ pop_close (mu_mailbox_t mbox)
       /*  Now what ! and how can we tell them about errors ?  So far now
          lets just be verbose about the error but close the connection
          anyway.  */
-      if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+      if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
        mu_error ("pop_close: %s\n", mpd->buffer);
       mu_stream_close (mbox->stream);
       break;
@@ -1111,10 +1112,10 @@ parse_answer0 (const char *buffer, size_t *n1, size_t 
*n2)
   if (strlen (buffer) < 3 || memcmp (buffer, "+OK", 3))
     return 1;
   m = *n1 = strtoul (buffer + 3, &p, 10);
-  if (!isspace (*p) || m != *n1)
+  if (!mu_isspace (*p) || m != *n1)
     return 1;
   m = *n2 = strtoul (p, &p, 10);
-  if (!(*p == 0 || isspace (*p)) || m != *n2)
+  if (!(*p == 0 || mu_isspace (*p)) || m != *n2)
     return 1;
   return 0;
 }
@@ -1128,9 +1129,9 @@ parse_answer1 (const char *buffer, size_t *n1, char *buf, 
size_t bufsize)
   if (strlen (buffer) < 3 || memcmp (buffer, "+OK", 3))
     return 1;
   m = *n1 = strtoul (buffer + 3, &p, 0);
-  if (!isspace (*p) || m != *n1)
+  if (!mu_isspace (*p) || m != *n1)
     return 1;
-  while (*p && isspace (*p))
+  while (*p && mu_isspace (*p))
     p++;
   if (strlen (p) >= bufsize)
     return 1;
@@ -1318,7 +1319,7 @@ pop_expunge (mu_mailbox_t mbox)
                  status = pop_read_ack (mpd);
                  CHECK_EAGAIN (mpd, status);
                  MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
-                 if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+                 if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
                    {
                      CHECK_ERROR (mpd, ERANGE);
                    }
@@ -1735,7 +1736,7 @@ pop_top (mu_header_t header, char *buffer, size_t buflen,
       status = pop_read_ack (mpd);
       CHECK_EAGAIN (mpd, status);
       MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
-      /* if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+      /* if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
           mu_error ("TOP not implemented\n"); */ /* FIXME */
       mpd->state = POP_TOP_RX;
 
@@ -1954,7 +1955,7 @@ pop_retr (pop_message_t mpm, char *buffer, size_t buflen,
       CHECK_EAGAIN (mpd, status);
       MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
 
-      if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
+      if (mu_c_strncasecmp (mpd->buffer, "+OK", 3) != 0)
        {
          CHECK_ERROR (mpd, EACCES);
        }
diff --git a/libproto/pop/pop3_connect.c b/libproto/pop/pop3_connect.c
index 2818ab0..b7e7547 100644
--- a/libproto/pop/pop3_connect.c
+++ b/libproto/pop/pop3_connect.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -81,7 +81,7 @@ mu_pop3_connect (mu_pop3_t pop3)
        status = mu_pop3_response (pop3, NULL, 0, &len);
        MU_POP3_CHECK_EAGAIN (pop3, status);
        mu_pop3_debug_ack (pop3);
-       if (strncasecmp (pop3->ack.buf, "+OK", 3) != 0)
+       if (mu_c_strncasecmp (pop3->ack.buf, "+OK", 3) != 0)
          {
            mu_stream_close (pop3->carrier);
            pop3->state = MU_POP3_NO_STATE;
diff --git a/maidag/forward.c b/maidag/forward.c
index 786b68f..735f011 100644
--- a/maidag/forward.c
+++ b/maidag/forward.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 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
@@ -221,14 +221,14 @@ process_forward (mu_message_t msg, char *filename, const 
char *myname)
   while (getline (&buf, &size, fp) > 0)
     {
       char *p, *q;
-      for (p = buf; *p && isascii (*p) && isspace (*p); p++)
+      for (p = buf; *p && mu_isblank (*p); p++)
        ;
       q = p + strlen (p);
       if (q > p)
        {
          if (*--q == '\n')
            q--;
-         for (; q > p && isascii (*q) && isspace (*q); q--)
+         for (; q > p && mu_isblank (*q); q--)
            ;
          q[1] = 0;
        }
diff --git a/maidag/lmtp.c b/maidag/lmtp.c
index ed33a61..a06a3f9 100644
--- a/maidag/lmtp.c
+++ b/maidag/lmtp.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 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
@@ -486,7 +486,7 @@ getcmd (char *buf, char **sp)
   for (cp = command_tab; cp->cmd_verb; cp++)
     {
       if (cp->cmd_len <= len
-         && strncasecmp (cp->cmd_verb, buf, cp->cmd_len) == 0)
+         && mu_c_strncasecmp (cp->cmd_verb, buf, cp->cmd_len) == 0)
        {
          *sp = buf + cp->cmd_len;
          return cp;
@@ -552,7 +552,7 @@ lmtp_loop (FILE *in, FILE *out, unsigned int timeout)
            {
              if (cp->cmd_fun)
                {
-                 while (*sp && isspace (*sp))
+                 while (*sp && mu_isblank (*sp))
                    sp++;
                  if (cp->cmd_fun (out, sp))
                    continue;
diff --git a/maidag/maidag.c b/maidag/maidag.c
index 460deda..6ca71a0 100644
--- a/maidag/maidag.c
+++ b/maidag/maidag.c
@@ -142,7 +142,7 @@ set_debug_flags (mu_debug_t debug, const char *arg)
 {
   while (*arg)
     {
-      if (isdigit (*arg))
+      if (mu_isdigit (*arg))
        debug_level = strtoul (arg, (char**)&arg, 10);
       else
        for (; *arg && *arg != ','; arg++)
@@ -325,7 +325,7 @@ cb2_forward_file_checks (mu_debug_t debug, const char 
*name, void *data)
   const char *str;
   int val;
   
-  if (strlen (name) > 2 && strncasecmp (name, "no", 2) == 0)
+  if (strlen (name) > 2 && mu_c_strncasecmp (name, "no", 2) == 0)
     {
       negate = 1;
       str = name + 2;
diff --git a/maidag/maidag.h b/maidag/maidag.h
index c3f5219..06b593f 100644
--- a/maidag/maidag.h
+++ b/maidag/maidag.h
@@ -85,6 +85,7 @@
 #include <mailutils/daemon.h>
 #include <mailutils/acl.h>
 #include <mailutils/server.h>
+#include <mailutils/cctype.h>
 
 #include <mu_dbm.h>
 #include <mu_asprintf.h>
diff --git a/maidag/mailquota.c b/maidag/mailquota.c
index faa4082..d5f29d7 100644
--- a/maidag/mailquota.c
+++ b/maidag/mailquota.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2004,
-   2005, 2007 Free Software Foundation, Inc.
+   2005, 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
@@ -106,9 +106,9 @@ dbm_retrieve_quota (char *name, mu_off_t *quota)
        return RETR_FAILURE;
     }
 
-  if (strncasecmp("none",
-                 MU_DATUM_PTR (contentd),
-                 MU_DATUM_SIZE (contentd)) == 0) 
+  if (mu_c_strncasecmp("none",
+                      MU_DATUM_PTR (contentd),
+                      MU_DATUM_SIZE (contentd)) == 0) 
       unlimited = 1;
   else if (MU_DATUM_SIZE (contentd) > sizeof(buffer)-1)
     {
@@ -229,7 +229,7 @@ sql_retrieve_quota (char *name, mu_off_t *quota)
                    mu_strerror (status));
          rc = RETR_FAILURE;
        }
-      else if (tmp == NULL || tmp[0] == 0 || strcasecmp (tmp, "none") == 0)
+      else if (tmp == NULL || tmp[0] == 0 || mu_c_strcasecmp (tmp, "none") == 
0)
        rc = RETR_UNLIMITED;
       else
        {
diff --git a/mail/alt.c b/mail/alt.c
index 76629c8..fc26d8a 100644
--- a/mail/alt.c
+++ b/mail/alt.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2002, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002, 2005, 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
@@ -79,9 +80,9 @@ mail_set_my_name (char *name)
 int
 mail_is_my_name (const char *name)
 {
-  if (strchr(name, '@') == NULL && strcasecmp (name, my_name) == 0)
+  if (strchr(name, '@') == NULL && mu_c_strcasecmp (name, my_name) == 0)
     return 1;
-  if (strcasecmp (name, my_email) == 0)
+  if (mu_c_strcasecmp (name, my_email) == 0)
     return 1;
   return util_slist_lookup (alternate_names, name);
 }
diff --git a/mail/copy.c b/mail/copy.c
index 6ebfcb5..effba42 100644
--- a/mail/copy.c
+++ b/mail/copy.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2005,
-   2007 Free Software Foundation, Inc.
+   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
@@ -41,7 +41,7 @@ mail_copy0 (int argc, char **argv, int mark)
   size_t total_size = 0, total_lines = 0, size;
   int status;
 
-  if (isupper (argv[0][0]))
+  if (mu_isupper (argv[0][0]))
     sender = 1;
   else if (argc >= 2)
     filename = mail_expand_name (argv[--argc]);
diff --git a/mail/decode.c b/mail/decode.c
index 58f66b4..159f413 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 
-   2005, 2007 Free Software Foundation, Inc.
+   2005, 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
@@ -46,7 +46,7 @@ mail_decode (int argc, char **argv)
   if (msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &msgset))
     return 1;
 
-  decode_closure.select_hdr = islower (argv[0][0]);
+  decode_closure.select_hdr = mu_islower (argv[0][0]);
 
   util_msgset_iterate (msgset, display_message, (void *)&decode_closure);
 
@@ -175,7 +175,7 @@ display_message0 (mu_message_t mesg, const msgset_t *msgset,
            }
        }
     }
-  else if (strncasecmp (type, "message/rfc822", strlen (type)) == 0)
+  else if (mu_c_strncasecmp (type, "message/rfc822", strlen (type)) == 0)
     {
       mu_message_t submsg = NULL;
 
diff --git a/mail/escape.c b/mail/escape.c
index 7733ec5..a95528a 100644
--- a/mail/escape.c
+++ b/mail/escape.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2005, 2006, 
-   2007 Free Software Foundation, Inc.
+   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
@@ -72,7 +72,7 @@ parse_headers (FILE *fp, compose_env_t *env)
       switch (state)
        {
        case STATE_INIT:
-         if (!buf[0] || isspace (buf[0]))
+         if (!buf[0] || mu_isspace (buf[0]))
            continue;
          else
            state = STATE_READ;
@@ -81,7 +81,7 @@ parse_headers (FILE *fp, compose_env_t *env)
        case STATE_READ:
          if (buf[0] == 0)
            state = STATE_BODY;
-         else if (isspace (buf[0]))
+         else if (mu_isspace (buf[0]))
            {
              /* A continuation line */
              if (name)
@@ -112,7 +112,7 @@ parse_headers (FILE *fp, compose_env_t *env)
              if (p)
                {
                  *p++ = 0;
-                 while (*p && isspace (*p))
+                 while (*p && mu_isspace (*p))
                    p++;
                  value = strdup (p);
                  name = strdup (buf);
@@ -234,11 +234,11 @@ escape_sign (int argc MU_ARG_UNUSED, char **argv, 
compose_env_t *env MU_ARG_UNUS
 {
   char *p;
 
-  if (util_getenv (&p, isupper (argv[0][0]) ? "Sign" : "sign",
+  if (util_getenv (&p, mu_isupper (argv[0][0]) ? "Sign" : "sign",
                   Mail_env_string, 1) == 0)
     {
       fputs ("-- \n", ofile);
-      if (isupper (argv[0][0]))
+      if (mu_isupper (argv[0][0]))
        {
          char *name = util_fullpath (p);
          FILE *fp = fopen (name, "r");
@@ -509,7 +509,7 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data)
 int
 escape_quote (int argc, char **argv, compose_env_t *env)
 {
-  int lower = islower (argv[0][0]);
+  int lower = mu_islower (argv[0][0]);
   util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT, quote0, &lower);
   escape_continue ();
   return 0;
diff --git a/mail/followup.c b/mail/followup.c
index 069cb85..bc905fa 100644
--- a/mail/followup.c
+++ b/mail/followup.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2005, 
-   2007 Free Software Foundation, Inc.
+   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
@@ -83,7 +83,7 @@ mail_followup (int argc, char **argv)
   fprintf (ofile, "Subject: %s\n\n",
           compose_header_get (&env, MU_HEADER_SUBJECT, ""));
 
-  status = mail_send0 (&env, isupper (argv[0][0]));
+  status = mail_send0 (&env, mu_isupper (argv[0][0]));
   compose_destroy (&env);
   return status;
 }
diff --git a/mail/mail.c b/mail/mail.c
index 2f2fb55..c07cae9 100644
--- a/mail/mail.c
+++ b/mail/mail.c
@@ -532,7 +532,7 @@ mail_mainloop (char *(*input) (void *, int),
       cmd = util_stripwhite (command);
       util_do_command ("%s", cmd);
 #ifdef WITH_READLINE
-      if (do_history && !(isspace(cmd[0]) || cmd[0] == '#'))
+      if (do_history && !(mu_isspace(cmd[0]) || cmd[0] == '#'))
        add_history (cmd);
 #endif
       if (command)
diff --git a/mail/mail.h b/mail/mail.h
index 831d022..bca79c2 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -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
@@ -51,7 +51,6 @@
 # include <varargs.h>
 #endif
 #include <signal.h>
-#include <ctype.h>
 #ifdef HAVE_PATHS_H
 # include <paths.h>
 #endif
@@ -85,6 +84,8 @@
 #include <mailutils/nls.h>
 #include <mailutils/tls.h>
 #include <mailutils/argcv.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mu_asprintf.h>
 
 #ifdef __cplusplus
@@ -351,7 +352,6 @@ extern void util_slist_remove (mu_list_t *list, char 
*value);
 extern void util_slist_destroy (mu_list_t *list);
 extern char *util_slist_to_string (mu_list_t list, const char *delim);
 extern void util_strcat (char **dest, const char *str);
-extern void util_strupper (char *str);
 extern char *util_outfolder_name (char *str);
 extern void util_save_outgoing (mu_message_t msg, char *savefile);
 extern void util_error (const char *format, ...) MU_PRINTFLIKE(1,2);
diff --git a/mail/mailline.c b/mail/mailline.c
index 4011597..863c8e1 100644
--- a/mail/mailline.c
+++ b/mail/mailline.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005, 
-   2007 Free Software Foundation, Inc.
+   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
@@ -237,7 +237,7 @@ ml_command_completion (char *cmd, int start, int end)
   char **ret;
   char *p;
 
-  for (p = rl_line_buffer; p < rl_line_buffer + start && isspace (*p); p++)
+  for (p = rl_line_buffer; p < rl_line_buffer + start && mu_isblank (*p); p++)
     ;
   
   if (mu_argcv_get_n (p, end, NULL, NULL, &argc, &argv))
diff --git a/mail/msgset.y b/mail/msgset.y
index e935293..138d39b 100644
--- a/mail/msgset.y
+++ b/mail/msgset.y
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005,
-   2007 Free Software Foundation, Inc.
+   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
@@ -275,13 +275,13 @@ yylex()
       return yylex ();
     }
 
-  if (isdigit (*cur_p))
+  if (mu_isdigit (*cur_p))
     {
       yylval.number = strtoul (cur_p, &cur_p, 10);
       return NUMBER;
     }
 
-  if (isalpha (*cur_p))
+  if (mu_isalpha (*cur_p))
     {
       char *p = cur_p;
       int len;
@@ -584,7 +584,7 @@ select_header (mu_message_t msg, void *closure)
           int status;
          int flags = REG_EXTENDED;
 
-         if (islower (header[0]))
+         if (mu_islower (header[0]))
            flags |= REG_ICASE;
           if (regcomp (&re, hd->expr, flags) != 0)
            {
@@ -599,7 +599,7 @@ select_header (mu_message_t msg, void *closure)
       else
        {
          int rc;
-         util_strupper (contents);
+         mu_strupper (contents);
          rc = strstr (contents, hd->expr) != NULL;
          free (contents);
          return rc;
@@ -623,7 +623,7 @@ select_body (mu_message_t msg, void *closure)
   off_t offset = 0;
 
   if (noregex)
-    util_strupper (expr);
+    mu_strupper (expr);
   else if (regcomp (&re, expr, REG_EXTENDED | REG_ICASE) != 0)
     return 0;
 
@@ -639,7 +639,7 @@ select_body (mu_message_t msg, void *closure)
       offset += n;
       if (noregex)
        {
-         util_strupper (buffer);
+         mu_strupper (buffer);
          status = strstr (buffer, expr) != NULL;
        }
       else
diff --git a/mail/print.c b/mail/print.c
index 36c959e..c2a07ba 100644
--- a/mail/print.c
+++ b/mail/print.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005, 
-   2007 Free Software Foundation, Inc.
+   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
@@ -115,7 +115,7 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void 
*data)
 int
 mail_print (int argc, char **argv)
 {
-  int lower = islower (argv[0][0]);
+  int lower = mu_islower (argv[0][0]);
   int rc = util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT,
                             mail_print_msg, &lower);
   return rc;
diff --git a/mail/reply.c b/mail/reply.c
index cdf6f75..81c49f6 100644
--- a/mail/reply.c
+++ b/mail/reply.c
@@ -132,7 +132,7 @@ reply0 (msgset_t *mspec, mu_message_t msg, void *data)
 int
 mail_reply (int argc, char **argv)
 {
-  int lower = islower (argv[0][0]);
+  int lower = mu_islower (argv[0][0]);
   if (util_getenv (NULL, "flipr", Mail_env_boolean, 0) == 0)
     lower = !lower;
   return util_foreach_msg (argc, argv, MSG_NODELETED, reply0, &lower);
diff --git a/mail/send.c b/mail/send.c
index 31e3e14..b427940 100644
--- a/mail/send.c
+++ b/mail/send.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2004, 
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 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
@@ -98,7 +98,7 @@ send_append_header (char *text)
   name = xmalloc (len + 1);
   memcpy (name, text, len);
   name[len] = 0;
-  for (p++; *p && isspace (*p); p++)
+  for (p++; *p && mu_isspace (*p); p++)
     ;
 
   add_header (name, strdup (p), COMPOSE_APPEND);
@@ -166,7 +166,7 @@ mail_send (int argc, char **argv)
 {
   compose_env_t env;
   int status;
-  int save_to = isupper (argv[0][0]);
+  int save_to = mu_isupper (argv[0][0]);
   compose_init (&env);
 
   if (argc < 2)
diff --git a/mail/shell.c b/mail/shell.c
index b22a5fb..ef296ab 100644
--- a/mail/shell.c
+++ b/mail/shell.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2005, 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
@@ -70,7 +70,7 @@ mail_execute (int shell, int argc, char **argv)
       argv0 = argv[0]; 
   
       /* Skip leading whitespace from argv[0] */
-      while (isspace (**argv))
+      while (mu_isspace (**argv))
        (*argv)++;
     }
 
diff --git a/mail/util.c b/mail/util.c
index 5a5b8ca..b1878e1 100644
--- a/mail/util.c
+++ b/mail/util.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 
-   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2004, 2005, 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
@@ -36,8 +36,6 @@
 
 mu_list_t environment = NULL;
 
-#define is_ascii_alpha(c) (isascii(c) && isalpha(c))
-
 /*
  * expands command into its command and arguments, then runs command
  * cmd is the command to parse and run
@@ -111,7 +109,7 @@ util_do_command (const char *c, ...)
       char *p;
       
       for (p = argv[0] + strlen (argv[0]) - 1;
-          p > argv[0] && !is_ascii_alpha (*p);
+          p > argv[0] && !mu_isalpha (*p);
           p--)
        ;
 
@@ -344,12 +342,12 @@ char *
 util_stripwhite (char *string)
 {
   register char *s, *t;
-  for (s = string; isspace ((unsigned)*s); s++)
+  for (s = string; mu_isspace ((unsigned)*s); s++)
     ;
   if (*s == 0)
     return s;
   t = s + strlen (s) - 1;
-  while (t > s && isspace ((unsigned)*t))
+  while (t > s && mu_isspace ((unsigned)*t))
     t--;
   *++t = '\0';
   return s;
@@ -879,7 +877,7 @@ util_slist_lookup (mu_list_t list, const char *str)
   for (mu_iterator_first (itr); !mu_iterator_is_done (itr); mu_iterator_next 
(itr))
     {
       mu_iterator_current (itr, (void **)&name);
-      if (strcasecmp (name, str) == 0)
+      if (mu_c_strcasecmp (name, str) == 0)
        {
          rc = 1;
          break;
@@ -981,20 +979,6 @@ util_strcat(char **dest, const char *str)
     }
 }
 
-/* Upper case the entire string.  Assume it is NULL terminated.  */
-void
-util_strupper (char *s)
-{
-  if (s)
-    {
-      size_t i;
-      size_t len = strlen (s);
-      for (i = 0; i < len; i++)
-       s[i] = toupper ((unsigned int)(s[i]));
-    }
-}
-
-
 char *
 util_outfolder_name (char *str)
 {
@@ -1110,7 +1094,7 @@ util_descend_subparts (mu_message_t mesg, msgset_t 
*msgset, mu_message_t *part)
 
       mu_message_get_header (mesg, &hdr);
       util_get_content_type (hdr, &type);
-      if (strncasecmp (type, "message/rfc822", strlen (type)) == 0)
+      if (mu_c_strncasecmp (type, "message/rfc822", strlen (type)) == 0)
        {
          if (mu_message_unencapsulate (mesg, &submsg, NULL))
            {
@@ -1239,7 +1223,7 @@ is_address_field (const char *name)
   char **p;
   
   for (p = address_fields; *p; p++)
-    if (strcasecmp (*p, name) == 0)
+    if (mu_c_strcasecmp (*p, name) == 0)
       return 1;
   return 0;
 }
@@ -1287,7 +1271,7 @@ util_header_expand (mu_header_t *phdr)
            {
              mu_address_t new_addr;
              
-             while (*p && isspace (*p))
+             while (*p && mu_isspace (*p))
                p++;
              /* If inplacealiases was set, the value was already expanded */
              if (util_getenv (NULL, "inplacealiases", Mail_env_boolean, 0))
@@ -1416,7 +1400,7 @@ util_rfc2047_decode (char **value)
   if (!*value || util_getenv (&charset, "charset", Mail_env_string, 0))
     return;
 
-  if (strcasecmp (charset, "auto") == 0)
+  if (mu_c_strcasecmp (charset, "auto") == 0)
     {
       memset (locale, 0, sizeof (locale));
 
diff --git a/mail/write.c b/mail/write.c
index 7e12b4a..511b921 100644
--- a/mail/write.c
+++ b/mail/write.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2005, 
-   2007 Free Software Foundation, Inc.
+   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
@@ -37,7 +37,7 @@ mail_write (int argc, char **argv)
   int sender = 0;
   size_t total_size = 0, total_lines = 0, size;
 
-  if (isupper (argv[0][0]))
+  if (mu_isupper (argv[0][0]))
     sender = 1;
   else if (argc >= 2)
     filename = util_outfolder_name (argv[--argc]);
diff --git a/mailbox/Makefile.am b/mailbox/Makefile.am
index 6684d3a..0447643 100644
--- a/mailbox/Makefile.am
+++ b/mailbox/Makefile.am
@@ -56,15 +56,18 @@ libmailutils_la_SOURCES = \
  attribute.c\
  auth.c\
  body.c\
+ cstrcasecmp.c\
+ cfg_driver.c\
+ cfg_format.c\
+ cfg_lexer.c\
+ cfg_parser.c\
+ cstrlower.c\
+ cstrupper.c\
  daemon.c\
  date.c\
  dbgstderr.c\
  dbgsyslog.c\
  debug.c\
- cfg_driver.c\
- cfg_format.c\
- cfg_lexer.c\
- cfg_parser.c\
  diag.c\
  envelope.c\
  fgetpwent.c\
@@ -97,6 +100,7 @@ libmailutils_la_SOURCES = \
  monitor.c\
  msrv.c\
  mu_auth.c\
+ muctype.c\
  munre.c\
  mutil.c\
  muerror.c\
@@ -117,6 +121,9 @@ libmailutils_la_SOURCES = \
  server.c\
  socket_stream.c\
  stream.c\
+ strltrim.c\
+ strskip.c\
+ strrtrim.c\
  syslog.c\
  system.c\
  ticket.c\
diff --git a/mailbox/address.c b/mailbox/address.c
index 8c81f45..28ab506 100644
--- a/mailbox/address.c
+++ b/mailbox/address.c
@@ -35,6 +35,7 @@
 #include <mailutils/mutil.h>
 #include <mailutils/parse822.h>
 #include <mailutils/address.h>
+#include <mailutils/cstr.h>
 
 /* Get email addresses from rfc822 address.  */
 int
@@ -519,7 +520,7 @@ int
 mu_address_contains_email (mu_address_t addr, const char *email)
 {
   for (; addr; addr = addr->next)
-    if (strcasecmp (addr->email, email) == 0)
+    if (mu_c_strcasecmp (addr->email, email) == 0)
       return 1;
   return 0;
 }
diff --git a/mailbox/amd.c b/mailbox/amd.c
index 27850f0..24410c4 100644
--- a/mailbox/amd.c
+++ b/mailbox/amd.c
@@ -36,7 +36,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-#include <ctype.h>
 #include <dirent.h>
 
 #ifdef WITH_PTHREAD
@@ -53,6 +52,8 @@
 # include <strings.h>
 #endif
 
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mailutils/attribute.h>
 #include <mailutils/body.h>
 #include <mailutils/debug.h>
@@ -665,11 +666,13 @@ _amd_message_save (struct _amd_data *amd, struct 
_amd_message *mhm,
       if (_amd_delim (buf))
        break;
 
-      if (!(strncasecmp (buf, "status:", 7) == 0
-           || strncasecmp (buf, "x-imapbase:", 11) == 0
-           || strncasecmp (buf, "x-uid:", 6) == 0
-           || strncasecmp (buf, MU_HEADER_ENV_DATE ":", sizeof 
(MU_HEADER_ENV_DATE)) == 0
-           || strncasecmp (buf, MU_HEADER_ENV_SENDER ":", sizeof 
(MU_HEADER_ENV_SENDER)) == 0))
+      if (!(mu_c_strncasecmp (buf, "status:", 7) == 0
+           || mu_c_strncasecmp (buf, "x-imapbase:", 11) == 0
+           || mu_c_strncasecmp (buf, "x-uid:", 6) == 0
+           || mu_c_strncasecmp (buf, 
+                MU_HEADER_ENV_DATE ":", sizeof (MU_HEADER_ENV_DATE)) == 0
+           || mu_c_strncasecmp (buf, 
+                MU_HEADER_ENV_SENDER ":", sizeof (MU_HEADER_ENV_SENDER)) == 0))
        {
          nlines++;
          nbytes += fprintf (fp, "%s", buf);
@@ -693,7 +696,7 @@ _amd_message_save (struct _amd_data *amd, struct 
_amd_message *mhm,
   if (mu_envelope_sget_date (env, &sbuf) == 0)
     {
       /* NOTE: buffer might be terminated with \n */
-      while (*sbuf && isspace (*sbuf))
+      while (*sbuf && mu_isspace (*sbuf))
        sbuf++;
       nbytes += fprintf (fp, "%s: %s", MU_HEADER_ENV_DATE, sbuf);
 
@@ -1338,13 +1341,13 @@ amd_scan_message (struct _amd_message *mhm)
            hlines++;
 
          /* Process particular attributes */
-         if (strncasecmp (buf, "status:", 7) == 0)
+         if (mu_c_strncasecmp (buf, "status:", 7) == 0)
            {
              int deleted = mhm->attr_flags & MU_ATTRIBUTE_DELETED;
              mu_string_to_flags (buf, &mhm->attr_flags);
              mhm->attr_flags |= deleted;
            }
-         else if (strncasecmp (buf, "x-imapbase:", 11) == 0)
+         else if (mu_c_strncasecmp (buf, "x-imapbase:", 11) == 0)
            {
              char *p;
              mhm->amd->uidvalidity = strtoul (buf + 11, &p, 10);
diff --git a/mailbox/assoc.c b/mailbox/assoc.c
index 6b53e86..7aba103 100644
--- a/mailbox/assoc.c
+++ b/mailbox/assoc.c
@@ -27,6 +27,8 @@
 #include <mailutils/errno.h>
 #include <mailutils/error.h>
 #include <mailutils/iterator.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 #include <iterator0.h>
 
 /* |hash_size| defines a sequence of symbol table sizes. These are prime
@@ -177,7 +179,7 @@ assoc_remove (mu_assoc_t assoc, struct _mu_assoc_elem *elem)
 }
 
 #define name_cmp(assoc,a,b) (((assoc)->flags & MU_ASSOC_ICASE) ? \
-                             strcasecmp(a,b) : strcmp(a,b))
+                             mu_c_strcasecmp(a,b) : strcmp(a,b))
 
 static int
 assoc_lookup_or_install (struct _mu_assoc_elem **elp,
diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 5501156..e72265b 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2004, 2005,
-   2007 Free Software Foundation, Inc.
+   2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -26,7 +26,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <ctype.h>
 
 #ifdef HAVE_LIBGEN_H
 # include <libgen.h>
@@ -36,12 +35,15 @@
 # include <strings.h>
 #endif
 
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mailutils/body.h>
 #include <mailutils/filter.h>
 #include <mailutils/header.h>
 #include <mailutils/message.h>
 #include <mailutils/stream.h>
 #include <mailutils/errno.h>
+#include <mailutils/mutil.h>
 
 #define MAX_HDR_LEN 256
 #define BUF_SIZE       2048
@@ -203,13 +205,13 @@ _header_get_param (char *field_body, const char *param, 
size_t * len)
   while (p)
     {
       p++;
-      while (isspace ((unsigned) *p))  /* walk upto start of param */
+      while (mu_isspace (*p))  /* walk upto start of param */
        p++;
       if ((v = strchr (p, '=')) == NULL)
        break;
       *len = 0;
       v = e = v + 1;
-      while (*e && (quoted || (!_ISSPECIAL (*e) && !isspace ((unsigned) *e))))
+      while (*e && (quoted || (!_ISSPECIAL (*e) && !mu_isspace (*e))))
        {                       /* skip pass value and calc len */
          if (*e == '\"')
            quoted = ~quoted, was_quoted = 1;
@@ -217,7 +219,7 @@ _header_get_param (char *field_body, const char *param, 
size_t * len)
            (*len)++;
          e++;
        }
-      if (strncasecmp (p, param, strlen (param)))
+      if (mu_c_strncasecmp (p, param, strlen (param)))
        {                       /* no match jump to next */
          p = strchr (e, ';');
          continue;
@@ -494,8 +496,8 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * 
newmsg, void **data)
          if ((content_type = malloc (size + 1)) == NULL)
            return ENOMEM;
          mu_header_get_value (hdr, "Content-Type", content_type, size + 1, 0);
-         ret = strncasecmp (content_type, "message/rfc822",
-                            strlen ("message/rfc822"));
+         ret = mu_c_strncasecmp (content_type, "message/rfc822",
+                                 strlen ("message/rfc822"));
           free (content_type);
           if (ret != 0)
            return EINVAL;
diff --git a/mailbox/attribute.c b/mailbox/attribute.c
index b5c03ec..dfe76ff 100644
--- a/mailbox/attribute.c
+++ b/mailbox/attribute.c
@@ -32,6 +32,7 @@
 
 #include <mailutils/errno.h>
 #include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 #include <attribute0.h>
 
 int
@@ -417,7 +418,7 @@ mu_string_to_flags (const char *buffer, int *pflags)
     return EINVAL;
 
   /* Set the attribute */
-  if (strncasecmp (buffer, "Status:", 7) == 0)
+  if (mu_c_strncasecmp (buffer, "Status:", 7) == 0)
     {
       sep = strchr(buffer, ':'); /* pass the ':' */
       sep++;
diff --git a/mailbox/cfg_lexer.l b/mailbox/cfg_lexer.l
index 0e4789f..293af03 100644
--- a/mailbox/cfg_lexer.l
+++ b/mailbox/cfg_lexer.l
@@ -1,6 +1,6 @@
 %{
 /* cfg_lexer.l -- default lexer for Mailutils configuration files
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 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
@@ -25,7 +25,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <unistd.h>
-#include <ctype.h>
+#include <mailutils/cctype.h>
 #include <mailutils/errno.h>
 #include <mailutils/error.h>
 #include <mailutils/debug.h>  
@@ -149,7 +149,7 @@ P [1-9][0-9]*
          /* Other tokens */
 \n       { mu_cfg_locus.line++; } 
 [,;{}()] return yytext[0];
-.        { if (isascii (yytext[0]) && isprint (yytext[0]))
+.        { if (mu_isprint (yytext[0]))
               mu_cfg_perror (&mu_cfg_locus,
                             _("stray character %c"), yytext[0]);
            else 
@@ -223,13 +223,13 @@ is_ws (char c)
 static int
 isemptystr (int off)
 {
-  for (; yytext[off] && isspace (yytext[off]); off++)
+  for (; yytext[off] && mu_isspace (yytext[off]); off++)
     ;
   if (yytext[off] == ';')
     {
       int i;
       for (i = off + 1; yytext[i]; i++) 
-       if (!isspace (yytext[i]))
+       if (!mu_isspace (yytext[i]))
          return 0;
       yyless (off);
       return 1;
diff --git a/mailbox/cstrcasecmp.c b/mailbox/cstrcasecmp.c
new file mode 100644
index 0000000..04f9e8a
--- /dev/null
+++ b/mailbox/cstrcasecmp.c
@@ -0,0 +1,58 @@
+/* This file is part of GNU Mailutils
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stddef.h>
+#include <mailutils/cctype.h>
+
+int
+mu_c_strcasecmp (const char *a, const char *b)
+{
+  int d = 0;
+  for (; d == 0; a++, b++)
+    {
+      int ac = (int) *a;
+      int bc = (int) *b;
+      if (ac == 0 || bc == 0) 
+       return ac - bc;
+      if (mu_isascii (ac) && mu_isascii (bc))
+       d = mu_toupper (ac) - mu_toupper (bc);
+      else
+       d = ac - bc;
+    }
+  return d;
+}
+                       
+int
+mu_c_strncasecmp (const char *a, const char *b, size_t n)
+{
+  int d = 0;
+  for (; d == 0 && n > 0; a++, b++, n--)
+    {
+      int ac = (int) *a;
+      int bc = (int) *b;
+      if (ac == 0 || bc == 0) 
+       return ac - bc;
+      if (mu_isascii (ac) && mu_isascii (bc))
+       d = mu_toupper (ac) - mu_toupper (bc);
+      else
+       d = ac - bc;
+    }
+  return d;
+}
diff --git a/python/libmu_py/c_api.c b/mailbox/cstrlower.c
similarity index 66%
copy from python/libmu_py/c_api.c
copy to mailbox/cstrlower.c
index 8b26a4b..058075b 100644
--- a/python/libmu_py/c_api.c
+++ b/mailbox/cstrlower.c
@@ -1,5 +1,4 @@
-/*
-   GNU Mailutils -- a suite of utilities for electronic mail
+/* This file is part of GNU Mailutils
    Copyright (C) 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
@@ -13,16 +12,20 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General
-   Public License along with this library; if not, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA
-*/
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
 
-#include "libmu_py.h"
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <mailutils/cctype.h>
 
-PyMODINIT_FUNC
-initc_api (void)
+int
+mu_strlower (char *s)
 {
-  mu_py_init ();
-  mu_py_attach_modules ();
+  if (!s)
+    return 0;
+  for (; *s; s++)
+    *s = mu_tolower (*s);
+  return 0;
 }
diff --git a/python/libmu_py/c_api.c b/mailbox/cstrupper.c
similarity index 66%
copy from python/libmu_py/c_api.c
copy to mailbox/cstrupper.c
index 8b26a4b..37d69f2 100644
--- a/python/libmu_py/c_api.c
+++ b/mailbox/cstrupper.c
@@ -1,5 +1,4 @@
-/*
-   GNU Mailutils -- a suite of utilities for electronic mail
+/* This file is part of GNU Mailutils
    Copyright (C) 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
@@ -13,16 +12,20 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General
-   Public License along with this library; if not, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA
-*/
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
 
-#include "libmu_py.h"
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <mailutils/cctype.h>
 
-PyMODINIT_FUNC
-initc_api (void)
+int
+mu_strupper (char *s)
 {
-  mu_py_init ();
-  mu_py_attach_modules ();
+  if (!s)
+    return 0;
+  for (; *s; s++)
+    *s = mu_toupper (*s);
+  return 0;
 }
diff --git a/mailbox/date.c b/mailbox/date.c
index 7f5067b..da5f1d2 100644
--- a/mailbox/date.c
+++ b/mailbox/date.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2007, 
+   2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -23,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 
 #define SECS_PER_DAY 86400
 #define ADJUSTMENT -719162L
@@ -145,7 +147,7 @@ mu_parse_imap_date_time (const char **p, struct tm *tm, 
mu_timezone *tz)
 
   for (i = 0; i < 12; i++)
     {
-      if (strncasecmp (month, months[i], 3) == 0)
+      if (mu_c_strncasecmp (month, months[i], 3) == 0)
        {
          mon = i;
          break;
@@ -203,7 +205,7 @@ mu_parse_ctime_date_time (const char **p, struct tm *tm, 
mu_timezone * tz)
 
   for (i = 0; i < 7; i++)
     {
-      if (strncasecmp (weekday, wdays[i], 3) == 0)
+      if (mu_c_strncasecmp (weekday, wdays[i], 3) == 0)
        {
          wday = i;
          break;
@@ -212,7 +214,7 @@ mu_parse_ctime_date_time (const char **p, struct tm *tm, 
mu_timezone * tz)
 
   for (i = 0; i < 12; i++)
     {
-      if (strncasecmp (month, months[i], 3) == 0)
+      if (mu_c_strncasecmp (month, months[i], 3) == 0)
        {
          mon = i;
          break;
diff --git a/mailbox/filter.c b/mailbox/filter.c
index e72fa6f..785f22d 100644
--- a/mailbox/filter.c
+++ b/mailbox/filter.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2004, 2005, 
-   2007 Free Software Foundation, Inc.
+   2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -39,6 +39,8 @@ First draft: Alain Magloire.
 #include <mailutils/iterator.h>
 #include <mailutils/stream.h>
 #include <mailutils/errno.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 
 static void
 filter_destroy (mu_stream_t stream)
@@ -188,7 +190,7 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, 
const char *name,
       mu_iterator_current (iterator, (void **)&filter_record);
       if ((filter_record->_is_filter
           && filter_record->_is_filter (filter_record, name))
-         || (strcasecmp (filter_record->name, name) == 0))
+         || (mu_c_strcasecmp (filter_record->name, name) == 0))
         {
          found = 1;
          if (filter_record->_get_filter)
diff --git a/mailbox/gdebug.c b/mailbox/gdebug.c
index b3041c4..f9dab9e 100644
--- a/mailbox/gdebug.c
+++ b/mailbox/gdebug.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2004, 2005,
-   2007, 2008  Free Software Foundation, Inc.
+   2007, 2008, 2009  Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -25,8 +25,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <ctype.h>
-
+#include <mailutils/cctype.h>
 #include <mailutils/assoc.h>
 #include <mailutils/error.h>
 #include <mailutils/errno.h>
@@ -89,7 +88,7 @@ decode_debug_level (const char *p, int *lev)
 {
   if (strcmp (p, "error") == 0)
     *lev = MU_DEBUG_ERROR;
-  else if (strncmp (p, "trace", 5) == 0 && isdigit (p[5]) && p[6] == 0)
+  else if (strncmp (p, "trace", 5) == 0 && mu_isdigit (p[5]) && p[6] == 0)
     *lev = MU_DEBUG_TRACE0 + atoi (p + 5);
   else if (strcmp (p, "proto") == 0)
     *lev = MU_DEBUG_PROT;
@@ -105,7 +104,7 @@ mu_debug_level_from_string (const char *string, 
mu_log_level_t *plev,
   char *q;
   unsigned level = MU_DEBUG_INHERIT;
   
-  if (isdigit (*string))
+  if (mu_isdigit (*string))
     {
       level = strtoul (string, &q, 0);
       if (*q)
@@ -193,7 +192,7 @@ mu_global_debug_from_string (const char *string, const char 
*errpfx)
          char *q;
          
          *p++ = 0;
-         if (isdigit (*p))
+         if (mu_isdigit (*p))
            {
              level = strtoul (p, &q, 0);
              if (*q)
diff --git a/mailbox/header.c b/mailbox/header.c
index 5f805f7..8360679 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -45,6 +45,7 @@
 #include <mailutils/address.h>
 #include <mailutils/mutil.h>
 #include <mailutils/errno.h>
+#include <mailutils/cstr.h>
 
 #include <header0.h>
 
@@ -79,13 +80,13 @@ mu_hdrent_find (struct _mu_header *hdr, const char *name, 
int pos)
   if (pos > 0)
     {
       for (p = hdr->head; p; p = p->next)
-       if (strcasecmp (MU_HDRENT_NAME (hdr,p), name) == 0 && pos-- == 1)
+       if (mu_c_strcasecmp (MU_HDRENT_NAME (hdr,p), name) == 0 && pos-- == 1)
          break;
     }
   else if (pos < 0)
     {
       for (p = hdr->tail; p; p = p->prev)
-       if (strcasecmp (MU_HDRENT_NAME (hdr,p), name) == 0 && ++pos == 0)
+       if (mu_c_strcasecmp (MU_HDRENT_NAME (hdr,p), name) == 0 && ++pos == 0)
          break;
     }
   else
diff --git a/mailbox/kwd.c b/mailbox/kwd.c
index 31eea19..9947fc6 100644
--- a/mailbox/kwd.c
+++ b/mailbox/kwd.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,8 @@
 #include <string.h>
 #include <mailutils/kwd.h>
 #include <mailutils/errno.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 
 int
 mu_kwd_xlat_name_len (mu_kwd_t *kwtab, const char *str, size_t len, int *pres)
@@ -45,7 +47,7 @@ mu_kwd_xlat_name_len_ci (mu_kwd_t *kwtab, const char *str, 
size_t len,
   for (; kwtab->name; kwtab++)
     {
       size_t kwlen = strlen (kwtab->name);
-      if (kwlen == len && strncasecmp (kwtab->name, str, len) == 0)
+      if (kwlen == len && mu_c_strncasecmp (kwtab->name, str, len) == 0)
        {
          *pres = kwtab->tok;
          return 0;
@@ -70,7 +72,7 @@ int
 mu_kwd_xlat_name_ci (mu_kwd_t *kwtab, const char *str, int *pres)
 {
   for (; kwtab->name; kwtab++)
-    if (strcasecmp (kwtab->name, str) == 0)
+    if (mu_c_strcasecmp (kwtab->name, str) == 0)
       {
        *pres = kwtab->tok;
        return 0;
diff --git a/mailbox/locale.c b/mailbox/locale.c
index 5420319..60a11b0 100644
--- a/mailbox/locale.c
+++ b/mailbox/locale.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,8 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 
 struct langtab
 {
@@ -230,10 +232,10 @@ mu_charset_lookup (char *lang, char *terr)
   if (!lang)
     return NULL;
   for (p = langtab; p->lang; p++)
-    if (strcasecmp (p->lang, lang) == 0
+    if (mu_c_strcasecmp (p->lang, lang) == 0
        && (terr == NULL 
            || p->terr == NULL
-           || !strcasecmp (p->terr, terr) == 0))
+           || !mu_c_strcasecmp (p->terr, terr) == 0))
       return p->charset;
   return NULL;
 }
diff --git a/mailbox/mailcap.c b/mailbox/mailcap.c
index f217c61..85fad9c 100644
--- a/mailbox/mailcap.c
+++ b/mailbox/mailcap.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2003, 2004, 2005, 2007 Free Software Foundation, 
Inc.
+   Copyright (C) 1999, 2000, 2003, 2004, 2005, 2007, 
+   2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -21,12 +22,14 @@
 #endif
 
 #include <stdlib.h>
-#include <ctype.h>
 #include <string.h>
 #include <errno.h>
 
+#include <mailutils/cctype.h>
 #include <mailutils/mailcap.h>
 #include <mailutils/stream.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 
 /* Definition of the structure, this should be in mailutils/sys/mailcap.h.  */
 struct _mu_mailcap_entry
@@ -299,7 +302,7 @@ mu_mailcap_entry_needsterminal (mu_mailcap_entry_t entry, 
int *on)
       int i;
       for (i = 0; i < entry->fields_count; i++)
        {
-         int n = strcasecmp (entry->fields[i], "needsterminal");
+         int n = mu_c_strcasecmp (entry->fields[i], "needsterminal");
          if (n == 0)
            {
              found = 1;
@@ -326,7 +329,7 @@ mu_mailcap_entry_copiousoutput (mu_mailcap_entry_t entry, 
int *on)
       int i;
       for (i = 0; i < entry->fields_count; i++)
        {
-         int n = strcasecmp (entry->fields[i], "copiousoutput");
+         int n = mu_c_strcasecmp (entry->fields[i], "copiousoutput");
          if (n == 0)
            {
              found = 1;
@@ -354,7 +357,7 @@ mu_mailcap_entry_get_value (mu_mailcap_entry_t entry, const 
char *key,
       int key_len = strlen (key);
       for (i = 0; i < entry->fields_count; i++)
        {
-         int n = strncasecmp (entry->fields[i], key, key_len);
+         int n = mu_c_strncasecmp (entry->fields[i], key, key_len);
          if (n == 0)
            {
              int field_len = strlen(entry->fields[i]);
@@ -362,14 +365,14 @@ mu_mailcap_entry_get_value (mu_mailcap_entry_t entry, 
const char *key,
              if (field_len > key_len)
                {
                  int c = entry->fields[i][key_len];
-                 if (isspace(c) || c == '=')
+                 if (mu_isspace (c) || c == '=')
                    {
                      char *value = strchr (entry->fields[i], '=');
                      if (value != NULL)
                        {
                          value++; /* Pass the equal.  */
                          /* Remove prepend space.  */
-                         for (; isspace ((unsigned char)*value); value++)
+                         for (; mu_isspace ((unsigned char)*value); value++)
                            ;
                          len = strlen (value);
                          /* Strip surrounding double quotes */
@@ -404,14 +407,14 @@ stripwhite (char *string)
 {
   register char *s, *t;
 
-  for (s = string; isspace ((unsigned char)*s); s++)
+  for (s = string; mu_isspace ((unsigned char)*s); s++)
     ;
 
   if (*s == 0)
     return (s);
 
   t = s + strlen (s) - 1;
-  while (t > s && isspace (*t))
+  while (t > s && mu_isspace (*t))
     t--;
   *++t = '\0';
 
diff --git a/mailbox/mailer.c b/mailbox/mailer.c
index 33cd37c..9b0e54e 100644
--- a/mailbox/mailer.c
+++ b/mailbox/mailer.c
@@ -30,6 +30,7 @@
 
 #include <sys/time.h>
 
+#include <mailutils/cstr.h>
 #include <mailutils/address.h>
 #include <mailutils/debug.h>
 #include <mailutils/errno.h>
@@ -304,7 +305,7 @@ save_fcc (mu_message_t msg)
       mu_mailbox_t mbox;
       
       mu_header_get_field_name (hdr, i, buf, sizeof buf, NULL);
-      if (strcasecmp (buf, MU_HEADER_FCC) == 0
+      if (mu_c_strcasecmp (buf, MU_HEADER_FCC) == 0
          && mu_header_aget_field_value (hdr, i, &fcc) == 0)
        {
          int i, argc;
@@ -461,15 +462,15 @@ merge_headers (mu_message_t newmsg, mu_header_t hdr)
 
       mu_header_sget_field_name (hdr, i, &fn);
       mu_header_sget_field_value (hdr, i, &fv);
-      if (strcasecmp (fn, MU_HEADER_MESSAGE_ID) == 0)
+      if (mu_c_strcasecmp (fn, MU_HEADER_MESSAGE_ID) == 0)
        continue;
-      else if (strcasecmp (fn, MU_HEADER_MIME_VERSION) == 0)
+      else if (mu_c_strcasecmp (fn, MU_HEADER_MIME_VERSION) == 0)
        mu_header_append (newhdr, "X-Orig-" MU_HEADER_MIME_VERSION,
                          fv);
-      else if (strcasecmp (fn, MU_HEADER_CONTENT_TYPE) == 0)
+      else if (mu_c_strcasecmp (fn, MU_HEADER_CONTENT_TYPE) == 0)
        mu_header_append (newhdr, "X-Orig-" MU_HEADER_CONTENT_TYPE,
                          fv);
-      else if (strcasecmp (fn, MU_HEADER_CONTENT_DESCRIPTION) == 0)
+      else if (mu_c_strcasecmp (fn, MU_HEADER_CONTENT_DESCRIPTION) == 0)
        mu_header_append (newhdr, "X-Orig-" MU_HEADER_CONTENT_DESCRIPTION,
                          fv);
       else
diff --git a/mailbox/message.c b/mailbox/message.c
index 15a6f3f..2001986 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -29,11 +29,11 @@
 #include <time.h>
 #include <unistd.h>
 #include <string.h>
-#include <ctype.h>
 #include <pwd.h>
 
 #include <message0.h>
 
+#include <mailutils/cctype.h>
 #include <mailutils/address.h>
 #include <mailutils/attribute.h>
 #include <mailutils/auth.h>
@@ -605,7 +605,7 @@ mu_message_get_uidl (mu_message_t msg, char *buffer, size_t 
buflen, size_t *pwri
       char *s, *e;
       for (s = buffer, e = buffer + n; s <= e; s++)
        {
-         if (isspace ((unsigned char)*s) || *s == '<' || *s == '>')
+         if (mu_isspace ((unsigned char)*s) || *s == '<' || *s == '>')
            {
              memmove (s, s + 1, e - (s + 1));
              e -= 1;
diff --git a/mailbox/message_stream.c b/mailbox/message_stream.c
index 2ece545..aa7b993 100644
--- a/mailbox/message_stream.c
+++ b/mailbox/message_stream.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
@@ -39,6 +39,7 @@
 #include <mailutils/mutil.h>
 #include <mailutils/errno.h>
 #include <mailutils/error.h>
+#include <mailutils/cstr.h>
 
 struct _mu_rfc822_stream
 {
@@ -265,16 +266,16 @@ restore_envelope (mu_stream_t str, struct 
_mu_rfc822_message **pmenv)
 
       if (!env_from || !env_date)
        {
-         if (!from && strncasecmp (buffer, MU_HEADER_FROM,
-                                   sizeof (MU_HEADER_FROM) - 1) == 0)
+         if (!from && mu_c_strncasecmp (buffer, MU_HEADER_FROM,
+                                        sizeof (MU_HEADER_FROM) - 1) == 0)
            from = strdup (skipws (buffer, sizeof (MU_HEADER_FROM)));
          else if (!env_from
-                  && strncasecmp (buffer, MU_HEADER_ENV_SENDER,
-                                  sizeof (MU_HEADER_ENV_SENDER) - 1) == 0)
+                  && mu_c_strncasecmp (buffer, MU_HEADER_ENV_SENDER,
+                                       sizeof (MU_HEADER_ENV_SENDER) - 1) == 0)
            env_from = strdup (skipws (buffer, sizeof (MU_HEADER_ENV_SENDER)));
          else if (!env_date
-                  && strncasecmp (buffer, MU_HEADER_ENV_DATE,
-                                  sizeof (MU_HEADER_ENV_DATE) - 1) == 0)
+                  && mu_c_strncasecmp (buffer, MU_HEADER_ENV_DATE,
+                                       sizeof (MU_HEADER_ENV_DATE) - 1) == 0)
            env_date = strdup (skipws (buffer, sizeof (MU_HEADER_ENV_DATE)));
        }
     }
diff --git a/mailbox/mime.c b/mailbox/mime.c
index d217826..04c1e11 100644
--- a/mailbox/mime.c
+++ b/mailbox/mime.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2003, 2004,
-   2007 Free Software Foundation, Inc.
+   2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -25,18 +25,20 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <time.h>
 #include <unistd.h>
 #ifdef HAVE_STRINGS_H
 # include <strings.h>
 #endif
 
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mailutils/message.h>
 #include <mailutils/stream.h>
 #include <mailutils/body.h>
 #include <mailutils/header.h>
 #include <mailutils/errno.h>
+#include <mailutils/mutil.h>
 #include <mime0.h>
 
 #ifndef TRUE
@@ -53,7 +55,7 @@ static int
 _mime_is_multipart_digest (mu_mime_t mime)
 {
   if (mime->content_type)
-    return (strncasecmp
+    return (mu_c_strncasecmp
            ("multipart/digest", mime->content_type,
             strlen ("multipart/digest")) ? 0 : 1);
   return 0;
@@ -136,7 +138,7 @@ _strltrim (char *str)
 {
   char *p;
 
-  for (p = str; isspace ((unsigned char) *p) && *p != '\0'; ++p);
+  for (p = str; mu_isspace (*p) && *p != '\0'; ++p);
   return ((p != str) ? memmove (str, p, strlen (p) + 1) : str);
 }
 
@@ -146,7 +148,7 @@ _strttrim (char *str)
   char *p;
 
   for (p = str + strlen (str) - 1;
-       isspace ((unsigned char) *p) && p >= str; --p);
+       mu_isspace (*p) && p >= str; --p);
   *++p = '\0';
   return (str);
 }
@@ -175,7 +177,7 @@ _mime_munge_content_header (char *field_body)
     {
       p = e;
       e++;
-      while (*e && isspace ((unsigned char) *e)) /* remove space up to param */
+      while (*e && mu_isspace (*e)) /* remove space up to param */
        e++;
       memmove (p + 1, e, strlen (e) + 1);
       e = p + 1;
@@ -185,7 +187,7 @@ _mime_munge_content_header (char *field_body)
       e = p = e + 1;
       while (*e
             && (quoted
-                || (!_ISSPECIAL (*e) && !isspace ((unsigned char) *e))))
+                || (!_ISSPECIAL (*e) && !mu_isspace (*e))))
        {
          if (*e == '\\')
            {                   /* escaped */
@@ -218,7 +220,7 @@ _mime_get_param (char *field_body, const char *param, int 
*len)
       was_quoted = 0;
       while (*e
             && (quoted
-                || (!_ISSPECIAL (*e) && !isspace ((unsigned char) *e))))
+                || (!_ISSPECIAL (*e) && !mu_isspace (*e))))
        {                       /* skip pass value and calc len */
          if (*e == '\"')
            quoted = ~quoted, was_quoted = 1;
@@ -226,7 +228,7 @@ _mime_get_param (char *field_body, const char *param, int 
*len)
            (*len)++;
          e++;
        }
-      if (strncasecmp (p, param, strlen (param)))
+      if (mu_c_strncasecmp (p, param, strlen (param)))
        {                       /* no match jump to next */
          p = strchr (e, ';');
          continue;
@@ -328,10 +330,10 @@ _mime_parse_mpart_message (mu_mime_t mime)
                    '\n' ? mime->cur_line + 1 : mime->cur_line;
                  if (mime->line_ndx >= blength)
                    {
-                     if ((!strncasecmp (cp2, "--", 2)
-                          && !strncasecmp (cp2 + 2, mime->boundary,
-                                           blength))
-                         || !strncasecmp (cp2, mime->boundary, blength))
+                     if ((!strncmp (cp2, "--", 2)
+                          && !mu_c_strncasecmp (cp2 + 2, mime->boundary,
+                                                blength))
+                         || !mu_c_strncasecmp (cp2, mime->boundary, blength))
                        {
                          mime->parser_state = MIME_STATE_HEADERS;
                          mime->flags &= ~MIME_PARSER_HAVE_CR;
@@ -365,10 +367,10 @@ _mime_parse_mpart_message (mu_mime_t mime)
 
                          if ((&mime->cur_line[mime->line_ndx] - cp2 - 1 >
                               blength
-                              && !strncasecmp (cp2 + blength + 2, "--", 2))
+                              && !strncmp (cp2 + blength + 2, "--", 2))
                              || (&mime->cur_line[mime->line_ndx] - cp2 - 1 ==
                                  blength
-                                 && !strncasecmp (cp2 + blength, "--", 2)))
+                                 && !strncmp (cp2 + blength, "--", 2)))
                            {   /* last boundary */
                              mime->parser_state = MIME_STATE_BEGIN_LINE;
                              mime->header_length = 0;
@@ -1027,7 +1029,7 @@ int
 mu_mime_is_multipart (mu_mime_t mime)
 {
   if (mime->content_type)
-    return (strncasecmp ("multipart", mime->content_type,
-                        strlen ("multipart")) ? 0 : 1);
+    return (mu_c_strncasecmp ("multipart", mime->content_type,
+                             strlen ("multipart")) ? 0 : 1);
   return 0;
 }
diff --git a/mailbox/msrv.c b/mailbox/msrv.c
index 72075f4..29c2a0f 100644
--- a/mailbox/msrv.c
+++ b/mailbox/msrv.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -32,8 +32,8 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/stat.h>
-#include <ctype.h>
 #include <limits.h>
+#include <mailutils/cctype.h>
 #include <mailutils/server.h>
 #include <mailutils/error.h>
 #include <mailutils/errno.h>
@@ -840,7 +840,7 @@ is_ip_addr (const char *arg)
            break;
          digit_count = 0;
        }
-      else if (!(isdigit (*arg) && ++digit_count <= 3))
+      else if (!(mu_isdigit (*arg) && ++digit_count <= 3))
        return 0;
     }
   return dot_count == 3;
diff --git a/mailbox/muctype.c b/mailbox/muctype.c
new file mode 100644
index 0000000..59447a3
--- /dev/null
+++ b/mailbox/muctype.c
@@ -0,0 +1,152 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <mailutils/cctype.h>
+
+int mu_c_tab[MU_C_TAB_MAX] = {
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL|MU_CTYPE_SPACE,
+  MU_CTYPE_CNTRL|MU_CTYPE_SPACE,
+  MU_CTYPE_CNTRL|MU_CTYPE_SPACE,
+  MU_CTYPE_CNTRL|MU_CTYPE_SPACE,
+  MU_CTYPE_CNTRL|MU_CTYPE_SPACE,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_CNTRL,
+  MU_CTYPE_PRINT|MU_CTYPE_SPACE,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_DIGIT|MU_CTYPE_GRAPH|MU_CTYPE_PRINT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_UPPER,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT|MU_CTYPE_XLETR,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_ALPHA|MU_CTYPE_GRAPH|MU_CTYPE_LOWER|MU_CTYPE_PRINT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_GRAPH|MU_CTYPE_PRINT|MU_CTYPE_PUNCT,
+  MU_CTYPE_CNTRL
+};
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index 69729da..c79366e 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -61,6 +61,8 @@
 #include <mailutils/sql.h>
 #include <mailutils/url.h>
 #include <mailutils/io.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
 #include <registrar0.h>
 
@@ -1122,7 +1124,7 @@ mu_strcasestr (const char *a_haystack, const char 
*a_needle)
     *needle = (unsigned char*) a_needle;
   register unsigned int b, c;
 
-#define U(c) toupper (c)
+#define U(c) mu_toupper (c)
   if ((b = U (*needle)))
     {
       haystack--;              
@@ -1354,7 +1356,7 @@ mu_decode_filter (mu_stream_t *pfilter, mu_stream_t input,
   if (status)
     return status;
 
-  if (fromcode && tocode && strcasecmp (fromcode, tocode))
+  if (fromcode && tocode && mu_c_strcasecmp (fromcode, tocode))
     {
       mu_stream_t cvt;
       status = mu_filter_iconv_create (&cvt, filter, fromcode, tocode,
diff --git a/mailbox/parse822.c b/mailbox/parse822.c
index 837fe6b..41d1bc0 100644
--- a/mailbox/parse822.c
+++ b/mailbox/parse822.c
@@ -79,7 +79,6 @@ actually help.
 
 #include <assert.h>
 #include <errno.h>
-#include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
 #include <time.h>
@@ -88,6 +87,8 @@ actually help.
 # include <strings.h>
 #endif
 
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mailutils/errno.h>
 #include <mailutils/parse822.h>
 #include <mailutils/address.h>
@@ -189,7 +190,7 @@ str_free (char **s)
 int
 mu_parse822_is_char (char c)
 {
-  return isascii (c);
+  return mu_isascii (c);
 }
 
 int
@@ -197,13 +198,13 @@ mu_parse822_is_digit (char c)
 {
   /* digit = <any ASCII decimal digit> */
 
-  return isdigit ((unsigned) c);
+  return mu_isdigit ((unsigned) c);
 }
 
 int
 mu_parse822_is_ctl (char c)
 {
-  return iscntrl ((unsigned) c) || c == 127 /* DEL */ ;
+  return mu_iscntrl ((unsigned) c) || c == 127 /* DEL */ ;
 }
 
 int
@@ -1509,7 +1510,7 @@ mu_parse822_day (const char **p, const char *e, int *day)
 
   for (d = 0; days[d]; d++)
     {
-      if (strncasecmp (*p, days[d], 3) == 0)
+      if (mu_c_strncasecmp (*p, days[d], 3) == 0)
        {
          *p += 3;
          if (day)
@@ -1566,7 +1567,7 @@ mu_parse822_date (const char **p, const char *e, int 
*day, int *mon, int *year)
 
   for (m = 0; mons[m]; m++)
     {
-      if (strncasecmp (*p, mons[m], 3) == 0)
+      if (mu_c_strncasecmp (*p, mons[m], 3) == 0)
        {
          *p += 3;
          if (mon)
@@ -1701,7 +1702,7 @@ mu_parse822_time (const char **p, const char *e,
   /* see if it's a timezone */
   for (; tzs[z].tzname; z++)
     {
-      if (strcasecmp (zone, tzs[z].tzname) == 0)
+      if (mu_c_strcasecmp (zone, tzs[z].tzname) == 0)
        break;
     }
   if (tzs[z].tzname)
diff --git a/mailbox/progmailer.c b/mailbox/progmailer.c
index da001dc..718e519 100644
--- a/mailbox/progmailer.c
+++ b/mailbox/progmailer.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2004, 2005, 
-   2006, 2007, 2008 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -40,6 +40,8 @@
 #include <mailutils/body.h>
 #include <mailutils/message.h>
 #include <mailutils/progmailer.h>
+#include <mailutils/mutil.h>
+#include <mailutils/cstr.h>
 
 struct _mu_progmailer
 {
@@ -194,7 +196,7 @@ mu_progmailer_send (struct _mu_progmailer *pm, mu_message_t 
msg)
                                       offset, &len)) == 0
         && len != 0)
     {
-      if (strncasecmp (buffer, MU_HEADER_FCC, sizeof (MU_HEADER_FCC) - 1))
+      if (mu_c_strncasecmp (buffer, MU_HEADER_FCC, sizeof (MU_HEADER_FCC) - 1))
        {
          MU_DEBUG1 (pm->debug, MU_DEBUG_PROT, "Header: %s", buffer);
          if (write (pm->fd, buffer, len) == -1)
diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index 094a0a8..28717a3 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 
+   2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -136,12 +137,14 @@ mu_rfc2047_decode (const char *tocode, const char *input, 
char **ptostr)
 
          size = strlen (encoded_text);
 
-         switch (toupper (encoding_type[0]))
+         switch (encoding_type[0])
            {
+            case 'b':
            case 'B':
              filter_type = "base64";
              break;
-             
+            
+            case 'q': 
            case 'Q':
              filter_type = "Q";
              break;
diff --git a/mailbox/strltrim.c b/mailbox/strltrim.c
new file mode 100644
index 0000000..867cf3c
--- /dev/null
+++ b/mailbox/strltrim.c
@@ -0,0 +1,63 @@
+/* This file is part of GNU Mailutils
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
+
+size_t
+mu_ltrim_class (char *str, int class)
+{
+  size_t i, len;
+  
+  if (!*str)
+    return 0;
+  len = strlen (str);
+  
+  for (i = 0; i < len && mu_c_is_class (str[i], class); i++)
+    ;
+  if (i)
+    {
+      len -= i;
+      memmove (str, str + i, len + 1);
+    }
+  return len;
+}
+
+size_t
+mu_ltrim_cset (char *str, const char *cset)
+{
+  size_t i, len;
+  
+  if (!*str)
+    return 0;
+  len = strlen (str);
+  
+  for (i = 0; i < len && strchr (cset, str[i]) != NULL; i++)
+    ;
+  if (i)
+    {
+      len -= i;
+      memmove (str, str + i, len + 1);
+    }
+  return len;
+}
+
diff --git a/mailbox/asprintf.c b/mailbox/strrtrim.c
similarity index 50%
copy from mailbox/asprintf.c
copy to mailbox/strrtrim.c
index 2bcd61d..5a1e230 100644
--- a/mailbox/asprintf.c
+++ b/mailbox/strrtrim.c
@@ -1,4 +1,4 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
+/* This file is part of GNU Mailutils
    Copyright (C) 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
@@ -12,31 +12,40 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General
-   Public License along with this library; if not, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
 #include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
-#include <mailutils/io.h>
+size_t
+mu_rtrim_class (char *str, int class)
+{
+  size_t len;
+  
+  if (!*str)
+    return 0;
+  for (len = strlen (str); len > 0 && mu_c_is_class (str[len-1], class); len--)
+    ;
+  str[len] = 0;
+  return len;
+}
 
-int
-mu_asprintf (char **pbuf, const char *fmt, ...)
+size_t
+mu_rtrim_cset (char *str, const char *cset)
 {
-  va_list ap;
-  size_t size;
-  int rc;
+  size_t len;
   
-  va_start (ap, fmt);
-  *pbuf = NULL;
-  size = 0;
-  rc = mu_vasnprintf (pbuf, &size, fmt, ap);
-  va_end (ap);
-  return rc;
+  if (!*str)
+    return 0;
+  for (len = strlen (str); len > 0 && strchr (cset, str[len-1]) != NULL; len--)
+    ;
+  str[len] = 0;
+  return len;
 }
diff --git a/mailbox/asprintf.c b/mailbox/strskip.c
similarity index 55%
copy from mailbox/asprintf.c
copy to mailbox/strskip.c
index 2bcd61d..1c974a3 100644
--- a/mailbox/asprintf.c
+++ b/mailbox/strskip.c
@@ -1,4 +1,4 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
+/* This file is part of GNU Mailutils
    Copyright (C) 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
@@ -12,31 +12,31 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General
-   Public License along with this library; if not, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
 #include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 
-#include <mailutils/io.h>
+char *
+mu_str_skip_class (const char *str, int class)
+{
+  for (; *str && mu_c_is_class (*str, class); str++)
+    ;
+  return (char*) str;
+}
 
-int
-mu_asprintf (char **pbuf, const char *fmt, ...)
+char *
+mu_str_skip_cset (const char *str, const char *cset)
 {
-  va_list ap;
-  size_t size;
-  int rc;
-  
-  va_start (ap, fmt);
-  *pbuf = NULL;
-  size = 0;
-  rc = mu_vasnprintf (pbuf, &size, fmt, ap);
-  va_end (ap);
-  return rc;
+  for (; *str && strchr (cset, *str) != NULL; str++)
+    ;
+  return (char*) str;
 }
+
diff --git a/mailbox/syslog.c b/mailbox/syslog.c
index 953167b..d931659 100644
--- a/mailbox/syslog.c
+++ b/mailbox/syslog.c
@@ -22,6 +22,7 @@
 #include <mailutils/diag.h>
 #include <mailutils/kwd.h>
 #include <mailutils/syslog.h>
+#include <mailutils/cstr.h>
 
 #ifndef LOG_AUTHPRIV
 # define LOG_AUTHPRIV
@@ -48,7 +49,7 @@ static mu_kwd_t kw_facility[] = {
 static int
 syslog_to_n (mu_kwd_t *kw, const char *str, int *pint)
 {
-  if (strncasecmp (str, "LOG_", 4) == 0)
+  if (mu_c_strncasecmp (str, "LOG_", 4) == 0)
     str += 4;
   return mu_kwd_xlat_name_ci (kw, str, pint);
 }
diff --git a/mailbox/url.c b/mailbox/url.c
index 5156dea..55b5220 100644
--- a/mailbox/url.c
+++ b/mailbox/url.c
@@ -33,6 +33,8 @@
 #include <mailutils/errno.h>
 #include <mailutils/argcv.h>
 #include <mailutils/secret.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <url0.h>
 
 #define AC2(a,b) a ## b
@@ -457,7 +459,7 @@ url_parse0 (mu_url_t u, char *name, size_t *poff)
 
       /* RFC 1738, section 2.1, lower the scheme case */
       for (; name < p; name++)
-       *name = tolower (*name);
+       *name = mu_tolower (*name);
 
       name = p;
     }
@@ -507,7 +509,7 @@ url_parse0 (mu_url_t u, char *name, size_t *poff)
                  else if (*name == ';')
                    {
                      /* Make sure it's the auth token. */
-                     if (strncasecmp (name + 1, "auth=", 5) == 0)
+                     if (mu_c_strncasecmp (name + 1, "auth=", 5) == 0)
                        {
                          *name++ = 0;
                          name += 5;
@@ -676,7 +678,7 @@ ACCESSOR(is_same,field) (mu_url_t url1, mu_url_t url2)      
                  \
                                                                          \
   if (status1 && status1 == status2) /* Both fields are missing */       \
     return 1;                                                            \
-  return strcasecmp (s1, s2) == 0;                                       \
+  return mu_c_strcasecmp (s1, s2) == 0;                                        
  \
 }
 
 #define DECL_ACCESSORS(field)                                            \
@@ -820,7 +822,8 @@ mu_url_set_scheme (mu_url_t url, const char *scheme)
 int
 mu_url_is_scheme (mu_url_t url, const char *scheme)
 {
-  if (url && scheme && url->scheme && strcasecmp (url->scheme, scheme) == 0)
+  if (url && scheme && url->scheme 
+      && mu_c_strcasecmp (url->scheme, scheme) == 0)
     return 1;
 
   return 0;
@@ -902,12 +905,12 @@ mu_url_is_ticket (mu_url_t ticket, mu_url_t url)
      equivalent must be defined and match. */
   if (defined (ticket->scheme))
     {
-      if (!url->scheme || strcasecmp (ticket->scheme, url->scheme) != 0)
+      if (!url->scheme || mu_c_strcasecmp (ticket->scheme, url->scheme) != 0)
        return 0;
     }
   if (defined (ticket->host))
     {
-      if (!url->host || strcasecmp (ticket->host, url->host) != 0)
+      if (!url->host || mu_c_strcasecmp (ticket->host, url->host) != 0)
        return 0;
     }
   if (ticket->port && ticket->port != url->port)
diff --git a/mailbox/version.c b/mailbox/version.c
index 2f04832..f56b31c 100644
--- a/mailbox/version.c
+++ b/mailbox/version.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,7 @@
 
 #include <mailutils/nls.h>
 #include <mailutils/version.h>
+#include <mailutils/cstr.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -171,10 +172,10 @@ mu_check_option (char *name)
       else
        len = strlen (mu_conf_option[i].name);
 
-      if (strncasecmp (mu_conf_option[i].name, name, len) == 0)
+      if (mu_c_strncasecmp (mu_conf_option[i].name, name, len) == 0)
        return &mu_conf_option[i];
       else if ((q = strchr (mu_conf_option[i].name, '_')) != NULL
-              && strncasecmp (q + 1, name,
+              && mu_c_strncasecmp (q + 1, name,
                               len - (q - mu_conf_option[i].name) - 1) == 0)
        return &mu_conf_option[i];
     }
diff --git a/mh/mh.h b/mh/mh.h
index 95b26c0..7a24642 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2004, 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
@@ -31,6 +31,8 @@
 
 #include <string.h>
 
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mailutils/parse822.h>
 #include <mailutils/mailbox.h>
 #include <mailutils/message.h>
diff --git a/mh/mh_alias.l b/mh/mh_alias.l
index 9b96701..af1293d 100644
--- a/mh/mh_alias.l
+++ b/mh/mh_alias.l
@@ -1,6 +1,6 @@
 %{
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2006, 2007  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 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
@@ -20,13 +20,9 @@
 #include <mh.h>
 #include <mh_alias.h>
 #include <sys/stat.h>
-#include <ctype.h>
+#include <mailutils/cctype.h>
 #include <mu_asprintf.h>
   
-#ifndef isblank
-# define isblank(c) ((c)==' ' || (c)=='\t')
-#endif  
-  
 char *ali_filename;  
 size_t ali_line_num;  
 ino_t ali_source_inode;
@@ -349,7 +345,7 @@ SPEC [,:;+=\*]
 ^[ \t]*\;.*\n  ali_line_num++; 
 ^[ \t]*{WORD}\*  { char *p;
                    for (p = yytext; p < yytext + yyleng; p++)
-                    if (!isspace (*p))
+                    if (!mu_isspace (*p))
                       break;
                   yylval.string = strdup (p);
                   return STRING;}
@@ -357,10 +353,10 @@ SPEC [,:;+=\*]
 {WORD}         { yylval.string = strdup (yytext); return STRING;}
 ^{WS}?"<"{WS}?{WORD} {
                  char *p;
-                 for (p = yytext; p < yytext + yyleng && isblank(*p); p++)
+                 for (p = yytext; p < yytext + yyleng && mu_isblank(*p); p++)
                   ;
                  for (p++; p < yytext + yyleng; p++)
-                  if (!isspace (*p))
+                  if (!mu_isspace (*p))
                     break;
                  push_source (p, 1); }
 {SPEC}         return yytext[0];
diff --git a/mh/mh_ctx.c b/mh/mh_ctx.c
index d5c9896..6d3bb56 100644
--- a/mh/mh_ctx.c
+++ b/mh/mh_ctx.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2004, 
-   2005, 2006, 2007 Free Software Foundation, Inc.
+   2005, 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
@@ -111,7 +111,7 @@ mh_context_read (mh_context_t *ctx)
     {
       char *q;
 
-      for (q = buf; *q && isspace (*q); q++)
+      for (q = buf; *q && mu_isspace (*q); q++)
        ;
       if (!*q || *q == '#')
        continue;
diff --git a/mh/mh_fmtgram.y b/mh/mh_fmtgram.y
index a4910ce..be9bfdf 100644
--- a/mh/mh_fmtgram.y
+++ b/mh/mh_fmtgram.y
@@ -1,7 +1,7 @@
 %{
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2004,
-   2007 Free Software Foundation, Inc.
+   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
@@ -136,7 +136,7 @@ escape    : component
 
 component : fmtspec OCURLY STRING CCURLY
             {
-             if (strcasecmp ($3, "body") == 0)
+             if (mu_c_strcasecmp ($3, "body") == 0)
                {
                  mh_code_op (mhop_body);
                }
@@ -382,7 +382,7 @@ yylex ()
     {
       curp++;
       percent = 1;
-      if (isdigit (*curp) || *curp == '-')
+      if (mu_isdigit (*curp) || *curp == '-')
        {
          int num = 0;
          int flags = 0;
@@ -394,7 +394,7 @@ yylex ()
            }
          if (*curp == '0')
            flags |= MH_FMT_ZEROPAD;
-         while (*curp && isdigit (*curp))
+         while (*curp && mu_isdigit (*curp))
            num = num * 10 + *curp++ - '0';
          yylval.num = num | flags;
          return FMTSPEC;
@@ -480,7 +480,7 @@ yylex ()
        {
          curp -= rest;
          yylval.builtin = bp;
-         while (*curp && isspace(*curp))
+         while (*curp && mu_isspace(*curp))
            curp++;
          return FUNCTION;
        }
diff --git a/mh/mh_init.c b/mh/mh_init.c
index 629fb04..fff162d 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -145,7 +145,7 @@ emailcmp (char *pattern, char *name)
   p = strchr (pattern, '@');
   if (p)
     for (p++; *p; p++)
-      *p = toupper (*p);
+      *p = mu_toupper (*p);
 
   return fnmatch (pattern, name, 0);
 }
@@ -160,7 +160,7 @@ mh_is_my_name (const char *name)
   p = strchr (pname, '@');
   if (p)
     for (p++; *p; p++)
-      *p = toupper (*p);
+      *p = mu_toupper (*p);
   
   if (!my_email)
     mh_get_my_name (NULL);
@@ -178,7 +178,7 @@ mh_is_my_name (const char *name)
          for (p = nlist; rc == 0 && *p; p = end)
            {
              
-             while (*p && isspace (*p))
+             while (*p && mu_isspace (*p))
                p++;
 
              end = strchr (p, ',');
@@ -193,7 +193,7 @@ mh_is_my_name (const char *name)
                  end = p + len;
                }
 
-             while (len > 0 && isspace (p[len-1]))
+             while (len > 0 && mu_isspace (p[len-1]))
                len--;
 
              pat = xmalloc (len + 1);
@@ -864,7 +864,7 @@ mh_decode_2047 (char *text, char **decoded_text)
 
   if (!charset)
     return 1;
-  if (strcasecmp (charset, "auto") == 0)
+  if (mu_c_strcasecmp (charset, "auto") == 0)
     {
       /* Try to deduce the charset from LC_ALL variable */
 
@@ -939,9 +939,9 @@ mh_expand_aliases (mu_message_t msg,
     {
       if (mu_header_sget_field_name (hdr, i, &buf) == 0)
        {
-         if (strcasecmp (buf, MU_HEADER_TO) == 0
-             || strcasecmp (buf, MU_HEADER_CC) == 0
-             || strcasecmp (buf, MU_HEADER_BCC) == 0)
+         if (mu_c_strcasecmp (buf, MU_HEADER_TO) == 0
+             || mu_c_strcasecmp (buf, MU_HEADER_CC) == 0
+             || mu_c_strcasecmp (buf, MU_HEADER_BCC) == 0)
            {
              char *value;
              mu_address_t addr = NULL;
@@ -951,11 +951,11 @@ mh_expand_aliases (mu_message_t msg,
              
              mh_alias_expand (value, &addr, &incl);
              free (value);
-             if (strcasecmp (buf, MU_HEADER_TO) == 0)
+             if (mu_c_strcasecmp (buf, MU_HEADER_TO) == 0)
                mu_address_union (addr_to, addr);
-             else if (strcasecmp (buf, MU_HEADER_CC) == 0)
+             else if (mu_c_strcasecmp (buf, MU_HEADER_CC) == 0)
                mu_address_union (addr_cc ? addr_cc : addr_to, addr);
-             else if (strcasecmp (buf, MU_HEADER_BCC) == 0)
+             else if (mu_c_strcasecmp (buf, MU_HEADER_BCC) == 0)
                mu_address_union (addr_bcc ? addr_bcc : addr_to, addr);
            }
        }
diff --git a/mh/mh_list.c b/mh/mh_list.c
index eb6d2e4..543ce1d 100644
--- a/mh/mh_list.c
+++ b/mh/mh_list.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 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
@@ -100,7 +100,7 @@ compdecl (char **str, char **compname)
 {
   char *p;
   
-  for (p = *str; *p && !isspace (*p); p++)
+  for (p = *str; *p && !mu_isspace (*p); p++)
     {
       if (*p == ':')
        {
@@ -278,7 +278,7 @@ mhl_format_compile (char *name)
     {
       char *p = buf;
 
-      while (*p && isspace (*p))
+      while (*p && mu_isspace (*p))
        ;
 
       if (*p == 0 || *p == ';')
@@ -461,7 +461,7 @@ static void print (struct eval_env *env, char *str, int 
nloff);
 static int
 _comp_name (void *item, void *date)
 {
-  return strcasecmp (item, date) == 0;
+  return mu_c_strcasecmp (item, date) == 0;
 }
 
 int
@@ -477,7 +477,7 @@ want_header (struct eval_env *env, char *name)
 
   for (p = strchrnul (str, ','); *str; p = strchrnul (str, ','))
     {
-      if (strncasecmp (name, str, p - str) == 0)
+      if (mu_c_strncasecmp (name, str, p - str) == 0)
        return 0;
       str = p;
       if (*str)
@@ -579,7 +579,7 @@ print (struct eval_env *env, char *str, int nloff)
          if (*p)
            {
              newline (env);
-             for (str++; *str && isspace (*str); str++)
+             for (str++; *str && mu_isspace (*str); str++)
                ;
            }
        }
@@ -629,10 +629,7 @@ print_header_value (struct eval_env *env, char *val)
     }
   
   if (env->bvar[B_UPPERCASE])
-    {
-      for (p = val; *p; p++)
-       *p = toupper (*p);
-    }
+    mu_toupper (val);
 
   if (env->bvar[B_COMPRESS])
     for (p = val; *p; p++)
@@ -641,7 +638,7 @@ print_header_value (struct eval_env *env, char *val)
 
   if (env->bvar[B_LEFTADJUST])
     {
-      for (p = val; *p && isspace (*p); p++)
+      for (p = val; *p && mu_isspace (*p); p++)
        ;
     }
   else
diff --git a/mh/mh_msgset.c b/mh/mh_msgset.c
index 0cdf81d..07d74ff 100644
--- a/mh/mh_msgset.c
+++ b/mh/mh_msgset.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2005, 2006, 
-   2007 Free Software Foundation, Inc.
+   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
@@ -325,7 +325,7 @@ _mh_msgset_parse (mu_mailbox_t mbox, mh_msgset_t *msgset, 
int argc, char **argv)
       long num;
       char *arg = msgset_preproc (mbox, argv[i]);
 
-      if (!isdigit (arg[0]))
+      if (!mu_isdigit (arg[0]))
        {
          int j;
          mh_msgset_t m;
diff --git a/mh/mh_sequence.c b/mh/mh_sequence.c
index ab78afe..6ec9ce9 100644
--- a/mh/mh_sequence.c
+++ b/mh/mh_sequence.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 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
@@ -101,7 +101,7 @@ mh_seq_add (const char *name, mh_msgset_t *mset, int flags)
     }
   *p = 0;
   write_sequence (name, new_value, flags & SEQ_PRIVATE);
-  if (strcasecmp (name, "cur") == 0)
+  if (mu_c_strcasecmp (name, "cur") == 0)
     current_message = strtoul (new_value, NULL, 0);
   free (new_value);
 }
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c
index d2bf887..ba251af 100644
--- a/mh/mh_whatnow.c
+++ b/mh/mh_whatnow.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 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
@@ -124,7 +124,7 @@ print_descr (int n, char *s)
        putchar (' ');
 
       for (p = s; *p && p < s + (RMARGIN - OPT_DOC_COL); p++)
-       if (isspace (*p))
+       if (mu_isspace (*p))
          space = p;
       
       if (!space || p < s + (RMARGIN - OPT_DOC_COL))
@@ -136,7 +136,7 @@ print_descr (int n, char *s)
        {
          for (; s < space; s++)
            putchar (*s);
-         for (; *s && isspace (*s); s++)
+         for (; *s && mu_isspace (*s); s++)
            ;
        }
       putchar ('\n');
diff --git a/mh/mh_whom.c b/mh/mh_whom.c
index d014691..b91d0ad 100644
--- a/mh/mh_whom.c
+++ b/mh/mh_whom.c
@@ -48,7 +48,7 @@ ismydomain (char *p)
   if (!p)
     return 1;
   mu_get_user_email_domain (&domain);
-  return strcasecmp (domain, p + 1) == 0;
+  return mu_c_strcasecmp (domain, p + 1) == 0;
 }
 
 /* FIXME: incl is not used */
diff --git a/mh/mhn.c b/mh/mhn.c
index c871c42..d4b380c 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 2006, 2007, 2008, 
+   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
@@ -616,7 +617,7 @@ mhn_compose_command (char *typestr, int *flags, char *file)
     %s  subtype */
 
   obstack_init (&stk);
-  for (p = str; *p && isspace (*p); p++)
+  for (p = str; *p && mu_isspace (*p); p++)
     ;
   
   if (*p == '|')
@@ -660,7 +661,7 @@ mhn_compose_command (char *typestr, int *flags, char *file)
   free (subtype);
 
   str = obstack_finish (&stk);
-  for (p = str; *p && isspace (*p); p++)
+  for (p = str; *p && mu_isspace (*p); p++)
     ;
   if (!*p)
     str = NULL;
@@ -699,7 +700,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int 
*flags,
     %d  content description */
 
   obstack_init (&stk);
-  for (p = str; *p && isspace (*p); p++)
+  for (p = str; *p && mu_isspace (*p); p++)
     ;
   
   if (*p == '|')
@@ -776,7 +777,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int 
*flags,
   free (subtype);
 
   str = obstack_finish (&stk);
-  for (p = str; *p && isspace (*p); p++)
+  for (p = str; *p && mu_isspace (*p); p++)
     ;
   if (!*p)
     str = NULL;
@@ -868,7 +869,7 @@ mhn_store_command (mu_message_t msg, msg_part_t part, char 
*name)
   free (subtype);
   
   str = obstack_finish (&stk);
-  for (p = str; *p && isspace (*p); p++)
+  for (p = str; *p && mu_isspace (*p); p++)
     ;
   if (!*p)
     str = NULL;
@@ -941,7 +942,7 @@ _get_env (char **env, char *name)
       int len = strlen (*env);
       if (nlen < len
          && (*env)[len+1] == '='
-         && strncasecmp (*env, name, nlen) == 0)
+         && mu_c_strncasecmp (*env, name, nlen) == 0)
        return *env + len + 1;
     }
   return NULL;
@@ -981,21 +982,21 @@ get_extbody_params (mu_message_t msg, char **content, 
char **descr)
        buf[len-1] = 0;
 
       if (descr
-         && strncasecmp (buf, MU_HEADER_CONTENT_DESCRIPTION ":",
-                         sizeof (MU_HEADER_CONTENT_DESCRIPTION)) == 0)
+         && mu_c_strncasecmp (buf, MU_HEADER_CONTENT_DESCRIPTION ":",
+                              sizeof (MU_HEADER_CONTENT_DESCRIPTION)) == 0)
        {
          for (p = buf + sizeof (MU_HEADER_CONTENT_DESCRIPTION);
-              *p && isspace (*p); p++)
+              *p && mu_isspace (*p); p++)
            ;
          *descr = strdup (p);
        }
       else if (content
-              && strncasecmp (buf, MU_HEADER_CONTENT_TYPE ":",
-                              sizeof (MU_HEADER_CONTENT_TYPE)) == 0)
+              && mu_c_strncasecmp (buf, MU_HEADER_CONTENT_TYPE ":",
+                                   sizeof (MU_HEADER_CONTENT_TYPE)) == 0)
        {
          char *q;
          for (p = buf + sizeof (MU_HEADER_CONTENT_TYPE);
-              *p && isspace (*p); p++)
+              *p && mu_isspace (*p); p++)
            ;
          q = strchr (p, ';');
          if (q)
@@ -1027,13 +1028,13 @@ match_content (char *content)
 
   split_content (content, &type, &subtype);
 
-  if ((rc = strcasecmp (content_type, type)) == 0)
+  if ((rc = mu_c_strcasecmp (content_type, type)) == 0)
     {
       if (content_subtype)
-       rc = strcasecmp (content_subtype, subtype);
+       rc = mu_c_strcasecmp (content_subtype, subtype);
     }
   else 
-    rc = strcasecmp (content_type, subtype);
+    rc = mu_c_strcasecmp (content_type, subtype);
 
   free (type);
   free (subtype);
@@ -1828,8 +1829,8 @@ parse_brace (char **pval, char **cmd, int c, struct 
compose_env *env)
   return 0;
 }
 
-#define isdelim(c) (isspace (c) || strchr (";<[(", c))
-#define skipws(ptr) do { while (*ptr && isspace (*ptr)) ptr++; } while (0)
+#define isdelim(c) (mu_isspace (c) || strchr (";<[(", c))
+#define skipws(ptr) do { while (*ptr && mu_isspace (*ptr)) ptr++; } while (0)
 
 int
 parse_content_type (struct compose_env *env,
@@ -1895,7 +1896,7 @@ parse_content_type (struct compose_env *env,
          obstack_1grow (stk, ' ');
          skipws (rest);
          sp = rest;
-         for (; *rest && !isspace (*rest) && *rest != '='; rest++)
+         for (; *rest && !mu_isspace (*rest) && *rest != '='; rest++)
            obstack_1grow (stk, *rest);
          skipws (rest);
          if (*rest != '=')
@@ -2300,7 +2301,7 @@ edit_mime (char *cmd, struct compose_env *env, 
mu_message_t *msg, int level)
   if (rc)
     return 1;
   
-  for (p = cmd + strlen (cmd) - 1; p > cmd && isspace (*p); p--)
+  for (p = cmd + strlen (cmd) - 1; p > cmd && mu_isspace (*p); p--)
     ;
   p[1] = 0;
 
@@ -2349,9 +2350,9 @@ edit_mime (char *cmd, struct compose_env *env, 
mu_message_t *msg, int level)
       
       _get_content_type (hdr, &typestr, NULL);
       split_content (typestr, &type, &subtype);
-      if (strcasecmp (type, "message") == 0)
+      if (mu_c_strcasecmp (type, "message") == 0)
        encoding = strdup ("7bit");
-      else if (strcasecmp (type, "text") == 0)
+      else if (mu_c_strcasecmp (type, "text") == 0)
        encoding = strdup ("quoted-printable");
       else
        encoding = strdup ("base64");
@@ -2393,7 +2394,7 @@ has_nonascii (char *buf, size_t n)
 {
   size_t i;
   for (i = 0; i < n; i++)
-    if (!isascii (buf[i]))
+    if (!mu_isascii (buf[i]))
       return 1;
   return 0;
 }
@@ -2463,7 +2464,7 @@ mhn_edit (struct compose_env *env, int level)
              
              /* Execute the directive */
              tok = sp = buf;
-             while (*sp && !isspace (*sp))
+             while (*sp && !mu_isspace (*sp))
                sp++;
              c = *sp;
              *sp = 0;
diff --git a/mh/mhparam.c b/mh/mhparam.c
index d4b7fe5..bd48953 100644
--- a/mh/mhparam.c
+++ b/mh/mhparam.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2007, 2008, 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
@@ -82,8 +82,8 @@ char *
 mhparam_defval (char *comp)
 {
   int i;
-  for (i = 0; i < sizeof(defvaltab)/sizeof(defvaltab[0]); i++)
-    if (strcasecmp(defvaltab[i].comp, comp) == 0)
+  for (i = 0; i < sizeof (defvaltab) / sizeof (defvaltab[0]); i++)
+    if (mu_c_strcasecmp (defvaltab[i].comp, comp) == 0)
       return defvaltab[i].val;
   return NULL;
 }
diff --git a/mh/pick.y b/mh/pick.y
index 2a4ffa3..0553371 100644
--- a/mh/pick.y
+++ b/mh/pick.y
@@ -1,6 +1,7 @@
 %{
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 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
@@ -303,7 +304,7 @@ match_header (mu_message_t msg, char *comp, regex_t *regex)
   for (i = 1; i <= count; i++)
     {
       mu_header_get_field_name (hdr, i, buf, sizeof buf, NULL);
-      if (strcasecmp (buf, comp) == 0)
+      if (mu_c_strcasecmp (buf, comp) == 0)
        {
          mu_header_get_field_value (hdr, i, buf, sizeof buf, NULL);
          if (regexec (regex, buf, 0, NULL, 0) == 0)
diff --git a/mh/sortm.c b/mh/sortm.c
index 231cdc0..17e1de0 100644
--- a/mh/sortm.c
+++ b/mh/sortm.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 2006, 2007, 2008, 
+   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
@@ -153,7 +154,7 @@ opt_handler (int key, char *arg, void *unused, struct 
argp_state *state)
       break;
       
     case ARG_VERBOSE:
-      if (!arg || isalpha (arg[0]))
+      if (!arg || mu_isalpha (arg[0]))
        verbose = is_true (arg);
       else
        verbose = arg[0] - '0';
@@ -276,11 +277,11 @@ compare_action (void *item, void *data)
 
   ap = a;
   bp = b;
-  if (strcasecmp (op->field, MU_HEADER_SUBJECT) == 0)
+  if (mu_c_strcasecmp (op->field, MU_HEADER_SUBJECT) == 0)
     {
-      if (strncasecmp (ap, "re:", 3) == 0)
+      if (mu_c_strncasecmp (ap, "re:", 3) == 0)
        ap += 3;
-      if (strncasecmp (b, "re:", 3) == 0)
+      if (mu_c_strncasecmp (b, "re:", 3) == 0)
        bp += 3;
     }
   
@@ -316,7 +317,7 @@ compare_messages (mu_message_t a, mu_message_t b, size_t 
anum, size_t bnum)
 static int
 comp_text (void *a, void *b)
 {
-  return strcasecmp (a, b);
+  return mu_c_strcasecmp (a, b);
 }
 
 static int
diff --git a/mimeview/mimetypes.y b/mimeview/mimetypes.y
index 86ee7e5..f46f29e 100644
--- a/mimeview/mimetypes.y
+++ b/mimeview/mimetypes.y
@@ -1,6 +1,6 @@
 %{
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2005, 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
@@ -21,7 +21,7 @@
 # include <config.h>
 #endif
   
-#include <ctype.h>
+#include <mailutils/cctype.h>
 #include <mimeview.h>
 #include <mimetypes-decl.h>
   
@@ -312,7 +312,7 @@ b_ascii (union argument *args)
       int c = getc (mimeview_fp);
       if (c == EOF)
        break;
-      if (!isascii (c))
+      if (!mu_isascii (c))
        return 0;
     }
       
diff --git a/pop3d/bulletin.c b/pop3d/bulletin.c
index 6d9a447..a8cd520 100644
--- a/pop3d/bulletin.c
+++ b/pop3d/bulletin.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 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
@@ -88,7 +88,7 @@ read_popbull_file (size_t *pnum)
       if (p)
        {
          *pnum = strtoul (buf, &p, 0);
-         rc = *p && !isspace (*p);
+         rc = *p && !mu_isspace (*p);
        }
       fclose (fp);
     }
diff --git a/pop3d/expire.c b/pop3d/expire.c
index bc1713c..f2b75a9 100644
--- a/pop3d/expire.c
+++ b/pop3d/expire.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 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
@@ -67,7 +67,7 @@ header_is_expired (mu_header_t hdr)
                        buf, sizeof buf, NULL))
     return 0;
   timestamp = strtoul (buf, &p, 0);
-  while (*p && isspace (*p))
+  while (*p && mu_isspace (*p))
     p++;
   if (*p)
     return 0;
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 52e6639..21d5609 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 
-   2005, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2007, 2008, 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
@@ -361,34 +361,34 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile)
        status = ERR_TOO_LONG;
       else if (strlen (cmd) > 4)
        status = ERR_BAD_CMD;
-      else if (strncasecmp (cmd, "RETR", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "RETR", 4) == 0)
        status = pop3d_retr (arg);
-      else if (strncasecmp (cmd, "DELE", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "DELE", 4) == 0)
        status = pop3d_dele (arg);
-      else if (strncasecmp (cmd, "USER", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "USER", 4) == 0)
        status = pop3d_user (arg);
-      else if (strncasecmp (cmd, "QUIT", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "QUIT", 4) == 0)
        status = pop3d_quit (arg);
-      else if (strncasecmp (cmd, "APOP", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "APOP", 4) == 0)
        status = pop3d_apop (arg);
-      else if (strncasecmp (cmd, "AUTH", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "AUTH", 4) == 0)
        status = pop3d_auth (arg);
-      else if (strncasecmp (cmd, "STAT", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "STAT", 4) == 0)
        status = pop3d_stat (arg);
-      else if (strncasecmp (cmd, "LIST", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "LIST", 4) == 0)
        status = pop3d_list (arg);
-      else if (strncasecmp (cmd, "NOOP", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "NOOP", 4) == 0)
        status = pop3d_noop (arg);
-      else if (strncasecmp (cmd, "RSET", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "RSET", 4) == 0)
        status = pop3d_rset (arg);
-      else if ((strncasecmp (cmd, "TOP", 3) == 0) && (strlen (cmd) == 3))
+      else if ((mu_c_strncasecmp (cmd, "TOP", 3) == 0) && (strlen (cmd) == 3))
        status = pop3d_top (arg);
-      else if (strncasecmp (cmd, "UIDL", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "UIDL", 4) == 0)
        status = pop3d_uidl (arg);
-      else if (strncasecmp (cmd, "CAPA", 4) == 0)
+      else if (mu_c_strncasecmp (cmd, "CAPA", 4) == 0)
        status = pop3d_capa (arg);
 #ifdef WITH_TLS
-      else if ((strncasecmp (cmd, "STLS", 4) == 0) && tls_available)
+      else if ((mu_c_strncasecmp (cmd, "STLS", 4) == 0) && tls_available)
        {
          status = pop3d_stls (arg);
          if (status)
diff --git a/pop3d/pop3d.h b/pop3d/pop3d.h
index 667ebf2..8621270 100644
--- a/pop3d/pop3d.h
+++ b/pop3d/pop3d.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 
-   2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   2004, 2005, 2007, 2008, 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
@@ -134,12 +134,13 @@ extern int expire_on_exit;
 #include <pwd.h>
 #include <grp.h>
 #include <syslog.h>
-#include <ctype.h>
 #ifdef HAVE_STRINGS_H
 # include <strings.h>
 #endif
 #include <sysexits.h>
 
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mailutils/attribute.h>
 #include <mailutils/body.h>
 #include <mailutils/daemon.h>
diff --git a/pop3d/popauth.c b/pop3d/popauth.c
index 1ab2b76..0b73e5e 100644
--- a/pop3d/popauth.c
+++ b/pop3d/popauth.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007,
-   2008 Free Software Foundation, Inc.
+   2008, 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
@@ -108,7 +108,7 @@ set_db_perms (struct argp_state *astate, char *opt, int 
*pperm)
 {
   int perm = 0;
    
-  if (isdigit(opt[0]))
+  if (mu_isdigit(opt[0]))
     {
       char *p;
       perm = strtoul (opt, &p, 8);
diff --git a/pop3d/user.c b/pop3d/user.c
index 91a4f44..50a972c 100644
--- a/pop3d/user.c
+++ b/pop3d/user.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2002, 2003, 2005, 2007 Free Software Foundation, 
Inc.
+   Copyright (C) 1999, 2001, 2002, 2003, 2005, 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
@@ -120,7 +121,7 @@ pop3d_user (const char *arg)
       free (tmp);
     }
 
-  if (strcasecmp (cmd, "PASS") == 0)
+  if (mu_c_strcasecmp (cmd, "PASS") == 0)
     {
       int rc;
 
@@ -155,7 +156,7 @@ pop3d_user (const char *arg)
          return ERR_BAD_LOGIN;
        }
     }
-  else if (strcasecmp (cmd, "QUIT") == 0)
+  else if (mu_c_strcasecmp (cmd, "QUIT") == 0)
     {
       mu_diag_output (MU_DIAG_INFO, _("Possible probe of account `%s'"), arg);
       free (cmd);
diff --git a/readmsg/msglist.c b/readmsg/msglist.c
index ebfa94d..c73229e 100644
--- a/readmsg/msglist.c
+++ b/readmsg/msglist.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2005, 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
@@ -46,7 +47,7 @@ is_number (const char *s)
     result = 0;
   for (; *s; s++)
     {
-      if (!isdigit ((unsigned char)*s))
+      if (!mu_isdigit ((unsigned char)*s))
        {
          result = 0;
          break;
@@ -135,7 +136,7 @@ msglist (mu_mailbox_t mbox, int show_all, int argc, char 
**argv, int **set, int
                break;
            }
        }
-      else if (isdigit (argv[i][0]))
+      else if (mu_isdigit (argv[i][0]))
        {
          /* single message */
          addset (set, n, strtol (argv[i], NULL, 10));
diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c
index 470ba3c..afb372a 100644
--- a/readmsg/readmsg.c
+++ b/readmsg/readmsg.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 
-   2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   2004, 2005, 2007, 2008, 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
@@ -355,7 +355,7 @@ main (int argc, char **argv)
 
   for (i = 0; i < weedc; i++)
     {
-      if (strcasecmp (weedv[i], "From_") == 0)
+      if (mu_c_strcasecmp (weedv[i], "From_") == 0)
        {
          int j;
          unix_header = 1;
diff --git a/readmsg/readmsg.h b/readmsg/readmsg.h
index ba4eee4..0bd5188 100644
--- a/readmsg/readmsg.h
+++ b/readmsg/readmsg.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005, 
-   2007  Free Software Foundation, Inc.
+   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
@@ -27,12 +27,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <unistd.h>
 #include <limits.h>
 #include <errno.h>
 #include <time.h>
 
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
 #include <mailutils/body.h>
 #include <mailutils/debug.h>
 #include <mailutils/errno.h>
diff --git a/sql/mysql.c b/sql/mysql.c
index 04a65e5..dc45c8c 100644
--- a/sql/mysql.c
+++ b/sql/mysql.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -19,7 +19,7 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-#include <ctype.h>
+#include <mailutils/cctype.h>
 #include <mailutils/mailutils.h>
 #include <mailutils/sql.h>
 
@@ -340,7 +340,7 @@ mu_check_mysql_scrambled_password (const char *scrambled, 
const char *message)
 
   /* Try to normalize it by cutting off trailing whitespace */
   for (p = scrambled + strlen (scrambled) - 1;
-       p > scrambled && isspace (*p); p--)
+       p > scrambled && mu_isspace (*p); p--)
     ;
   switch (p - scrambled)
     {
diff --git a/sql/postgres.c b/sql/postgres.c
index bbcd268..3406062 100644
--- a/sql/postgres.c
+++ b/sql/postgres.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -23,16 +23,16 @@
 #ifdef HAVE_PGSQL
 #include <mailutils/mailutils.h>
 #include <mailutils/sql.h>
+#include <mailutils/cctype.h>
 
 #include <libpq-fe.h>
-#include <ctype.h>
 
 static char *
 chop (char *str)
 {
   int len;
   
-  for (len = strlen(str); len > 0 && isspace(str[len-1]); len--)
+  for (len = strlen(str); len > 0 && mu_isspace(str[len-1]); len--)
     ;
   str[len] = 0;
   return str;


hooks/post-receive
-- 
GNU Mailutils




reply via email to

[Prev in Thread] Current Thread [Next in Thread]