imap-match.c revision 6ef7e31619edfaa17ed044b45861d106a86191ef
/* Copyright (C) 2002 Timo Sirainen
imap_match_init() logic originates from Cyrus, but the code is fully
rewritten.
*/
#include "lib.h"
#include "imap-match.h"
#include <ctype.h>
struct imap_match_glob {
bool inboxcase;
const char *inboxcase_end;
char sep_char;
char mask[1];
};
/* name of "INBOX" - must not have repeated substrings */
static const char inbox[] = "INBOX";
struct imap_match_glob *
{
struct imap_match_glob *glob;
const char *p, *inboxp;
char *dst;
/* +1 from struct */
/* @UNSAFE: compress the mask */
while (*mask != '\0') {
/* remove duplicate hierarchy wildcards */
/* "%*" -> "*" */
if (*mask == '*') {
/* remove duplicate wildcards */
mask++;
*dst++ = '*';
} else {
*dst++ = '%';
}
} else {
}
}
*dst++ = '\0';
if (inboxcase) {
/* check if we could be comparing INBOX. */
if (*p != '%') {
break;
}
if (*++inboxp == '\0') {
/* now check that it doesn't end with
any invalid chars */
if (*++p == '%') p++;
if (*p != '\0' && *p != '*' &&
*p != separator)
break;
}
}
}
}
return glob;
}
{
}
{
}
static enum imap_match_result
const char **mask_p)
{
}
}
while (*mask == '%') {
mask++;
if (*mask == '\0') {
data++;
break;
}
while (*data != '\0') {
if (ret > 0)
break;
if (ret == IMAP_MATCH_CHILDREN ||
(ret == IMAP_MATCH_PARENT &&
best_ret == IMAP_MATCH_NO))
}
break;
data++;
}
}
if (*mask != '*') {
if (*data != '\0') {
return best_ret != IMAP_MATCH_NO ||
}
}
return IMAP_MATCH_YES;
}
enum imap_match_result
{
const char *mask;
int ret;
else
if (*mask != '*') {
return ret;
if (*mask == '\0')
return IMAP_MATCH_YES;
}
while (*mask == '*') {
mask++;
if (*mask == '\0')
return IMAP_MATCH_YES;
while (*data != '\0') {
break;
}
data++;
}
}
}