Commit 24a868b2 24a868b2f1158ef2ae82f9d342b0039226a761a3 by Sergey Poznyakoff

Minor fix.

* imap4d/list.c (list_ref): Use mu_imap_wildmatch_ci to check for
a request matching INBOX.
* include/mailutils/imaputil.h (mu_imap_wildmatch_ci): New prototype.
* libmailutils/imapio/wildmatch.c (mu_imap_wildmatch_ci): New function.
1 parent 014c99be
......@@ -171,8 +171,7 @@ list_ref (char const *ref, char const *wcard, char const *cwd,
on this or some other server. */
if (!*ref &&
(mu_imap_wildmatch (wcard, "INBOX", MU_HIERARCHY_DELIMITER) == 0
|| mu_imap_wildmatch (wcard, "inbox", MU_HIERARCHY_DELIMITER) == 0))
mu_imap_wildmatch_ci (wcard, "INBOX", MU_HIERARCHY_DELIMITER) == 0)
io_untagged_response (RESP_NONE, "LIST (\\NoInferiors) NIL INBOX");
mu_folder_enumerate (folder, NULL, (void*) wcard, 0, 0, NULL,
......
......@@ -24,9 +24,10 @@ extern "C" {
# include <mailutils/types.h>
int mu_imap_wildmatch (const char *pattern, const char *name, int delim);
int mu_imap_wildmatch_ci (const char *pattern, const char *name, int delim);
int mu_imap_flag_to_attribute (const char *item, int *attr);
int mu_imap_format_flags (mu_stream_t str, int flags, int include_recent);
int mu_imap_format_flags (mu_stream_t str, int flags, int include_recent);
#ifdef __cplusplus
}
......
......@@ -18,6 +18,7 @@
#include <string.h>
#include <mailutils/types.h>
#include <mailutils/imaputil.h>
#include <mailutils/cctype.h>
/* Match STRING against the IMAP4 wildcard pattern PATTERN. */
......@@ -26,7 +27,7 @@
#define WILD_ABORT 2
int
_wild_match (const char *pat, const char *name, char delim)
_wild_match (const char *pat, const char *name, char delim, int icase)
{
while (pat && *pat)
{
......@@ -41,7 +42,7 @@ _wild_match (const char *pat, const char *name, char delim)
return WILD_TRUE;
while (*name)
{
int res = _wild_match (pat, name++, delim);
int res = _wild_match (pat, name++, delim, icase);
if (res != WILD_FALSE)
return res;
}
......@@ -54,14 +55,15 @@ _wild_match (const char *pat, const char *name, char delim)
return strchr (name, delim) ? WILD_FALSE : WILD_TRUE;
while (*name && *name != delim)
{
int res = _wild_match (pat, name++, delim);
int res = _wild_match (pat, name++, delim, icase);
if (res != WILD_FALSE)
return res;
}
return _wild_match (pat, name, delim);
return _wild_match (pat, name, delim, icase);
default:
if (*pat != *name)
if (icase ? mu_toupper (*pat) != mu_toupper (*name)
: *pat != *name)
return WILD_FALSE;
pat++;
name++;
......@@ -73,6 +75,11 @@ _wild_match (const char *pat, const char *name, char delim)
int
mu_imap_wildmatch (const char *pattern, const char *name, int delim)
{
return _wild_match (pattern, name, delim) != WILD_TRUE;
return _wild_match (pattern, name, delim, 0) != WILD_TRUE;
}
int
mu_imap_wildmatch_ci (const char *pattern, const char *name, int delim)
{
return _wild_match (pattern, name, delim, 1) != WILD_TRUE;
}
......