[dovecot-cvs] dovecot/src/lib-imap imap-match.c,1.4,1.5 imap-match.h,1.4,1.5
cras at procontrol.fi
cras at procontrol.fi
Wed Feb 19 21:55:30 EET 2003
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/subscription-file subscription-file.c,1.16,1.17 subscription-file.h,1.5,1.6
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-list.c,1.13,1.14 mbox-storage.c,1.39,1.40 mbox-storage.h,1.14,1.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-imap
In directory danu:/tmp/cvs-serv21976/src/lib-imap
Modified Files:
imap-match.c imap-match.h
Log Message:
Rewrote LIST, LSUB and subscription file handling. LIST replies aren't
sorted anymore by default, it can be enabled with client_workarounds =
list-sort.
Index: imap-match.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-match.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imap-match.c 5 Jan 2003 13:09:52 -0000 1.4
+++ imap-match.c 19 Feb 2003 19:55:28 -0000 1.5
@@ -10,6 +10,8 @@
#include <ctype.h>
struct imap_match_glob {
+ pool_t pool;
+
int inboxcase;
const char *inboxcase_end;
@@ -21,15 +23,16 @@
static const char inbox[] = "INBOX";
#define INBOXLEN (sizeof(inbox) - 1)
-struct imap_match_glob *imap_match_init(const char *mask, int inboxcase,
- char separator)
+struct imap_match_glob *
+imap_match_init(pool_t pool, const char *mask, int inboxcase, char separator)
{
struct imap_match_glob *glob;
const char *p, *inboxp;
char *dst;
/* +1 from struct */
- glob = t_malloc(sizeof(struct imap_match_glob) + strlen(mask));
+ glob = p_malloc(pool, sizeof(struct imap_match_glob) + strlen(mask));
+ glob->pool = pool;
glob->sep_char = separator;
/* @UNSAFE: compress the mask */
@@ -79,13 +82,18 @@
}
if (glob->inboxcase && inboxp != NULL && *inboxp != '\0' &&
- *p != '*' && (p != glob->mask && p[-1] == '%'))
+ *p != '*' && (p != glob->mask && p[-1] != '%'))
glob->inboxcase = FALSE;
}
return glob;
}
+void imap_match_deinit(struct imap_match_glob *glob)
+{
+ p_free(glob->pool, glob);
+}
+
static inline int cmp_chr(const struct imap_match_glob *glob,
const char *data, char maskchr)
{
@@ -94,23 +102,24 @@
i_toupper(*data) == i_toupper(maskchr));
}
-static int match_sub(const struct imap_match_glob *glob, const char **data_p,
- const char **mask_p)
+static enum imap_match_result
+match_sub(const struct imap_match_glob *glob, const char **data_p,
+ const char **mask_p)
{
const char *mask, *data;
- int ret, best_ret;
+ enum imap_match_result ret, best_ret;
data = *data_p; mask = *mask_p;
while (*mask != '\0' && *mask != '*' && *mask != '%') {
if (!cmp_chr(glob, data, *mask)) {
return *data == '\0' && *mask == glob->sep_char ?
- 0 : -1;
+ IMAP_MATCH_CHILDREN : IMAP_MATCH_NO;
}
data++; mask++;
}
- best_ret = -1;
+ best_ret = IMAP_MATCH_NO;
while (*mask == '%') {
mask++;
@@ -126,8 +135,8 @@
if (ret > 0)
break;
- if (ret == 0)
- best_ret = 0;
+ if (ret == IMAP_MATCH_CHILDREN)
+ best_ret = IMAP_MATCH_CHILDREN;
}
if (*data == glob->sep_char)
@@ -139,18 +148,23 @@
if (*mask != '*') {
if (*data == '\0' && *mask != '\0')
- return *mask == glob->sep_char ? 0 : best_ret;
+ return *mask == glob->sep_char ?
+ IMAP_MATCH_CHILDREN : best_ret;
- if (*data != '\0')
- return best_ret;
+ if (*data != '\0') {
+ return best_ret != IMAP_MATCH_NO ||
+ *mask != '\0' || *data != glob->sep_char ?
+ best_ret : IMAP_MATCH_PARENT;
+ }
}
*data_p = data;
*mask_p = mask;
- return 1;
+ return IMAP_MATCH_YES;
}
-int imap_match(struct imap_match_glob *glob, const char *data)
+enum imap_match_result
+imap_match(struct imap_match_glob *glob, const char *data)
{
const char *mask;
int ret;
@@ -168,14 +182,14 @@
return ret;
if (*mask == '\0')
- return 1;
+ return IMAP_MATCH_YES;
}
while (*mask == '*') {
mask++;
if (*mask == '\0')
- return 1;
+ return IMAP_MATCH_YES;
while (*data != '\0') {
if (cmp_chr(glob, data, *mask)) {
@@ -187,5 +201,6 @@
}
}
- return *data == '\0' && *mask == '\0' ? 1 : 0;
+ return *data == '\0' && *mask == '\0' ?
+ IMAP_MATCH_YES : IMAP_MATCH_CHILDREN;
}
Index: imap-match.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-match.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imap-match.h 5 Jan 2003 13:09:52 -0000 1.4
+++ imap-match.h 19 Feb 2003 19:55:28 -0000 1.5
@@ -1,15 +1,24 @@
#ifndef __IMAP_MATCH_H
#define __IMAP_MATCH_H
+enum imap_match_result {
+ IMAP_MATCH_YES = 1, /* match */
+ IMAP_MATCH_NO = -1, /* definite non-match */
+
+ IMAP_MATCH_CHILDREN = 0, /* it's children might match */
+ IMAP_MATCH_PARENT = -2 /* one of it's parents would match */
+};
+
struct imap_match_glob;
/* If inboxcase is TRUE, the "INBOX" string at the beginning of line is
compared case-insensitively */
-struct imap_match_glob *imap_match_init(const char *mask, int inboxcase,
- char separator);
+struct imap_match_glob *
+imap_match_init(pool_t pool, const char *mask, int inboxcase, char separator);
-/* Returns 1 if matched, 0 if it didn't match, but could match with additional
- hierarchies, -1 if definitely didn't match */
-int imap_match(struct imap_match_glob *glob, const char *data);
+void imap_match_deinit(struct imap_match_glob *glob);
+
+enum imap_match_result
+imap_match(struct imap_match_glob *glob, const char *data);
#endif
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/subscription-file subscription-file.c,1.16,1.17 subscription-file.h,1.5,1.6
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-list.c,1.13,1.14 mbox-storage.c,1.39,1.40 mbox-storage.h,1.14,1.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list