git clone https://orangeshoelaces.net/git/tttm.git
Author: Vasily Kolobkov on 05/24/2016
Committer: Vasily Kolobkov on 05/24/2016
Mark off EXPUNGE and FETCH responses
imap.c | 11 +++-
parser.c | 25 +++++---
parser.h | 2 +
pshades.c | 2 +
4 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/imap.c b/imap.c
index 829d8a3..550fd3d 100644
--- a/imap.c
+++ b/imap.c
@@ -45,7 +45,7 @@ static int dig_bye(struct imapctx *, int, void *);
static int dig_uxbye(struct imapctx *, int, void *);
static int dig_caps(struct imapctx *, int, void *);
static int dig_exists(struct imapctx *, int, void *);
-static int dig_res(struct imapctx *, int, void *);
+static int dig_expunge(struct imapctx *, int, void *);
static int state2res(union parnode *);
static int str2cap(struct capmap *, char *, size_t);
@@ -63,6 +63,7 @@ static struct respcard freeresp[] = {
static struct respcard unilat[] = {
UNILAT_COMMON,
+ { IP_EXPUNGE, dig_expunge },
{ -1 },
};
@@ -323,6 +324,14 @@ dig_exists(struct imapctx *con, int buf, void *ctx)
return 0;
}
+int
+dig_expunge(struct imapctx *con, int buf, void *ctx)
+{
+ if (con->mb.exists > 0)
+ con->mb.exists--;
+ return 0;
+}
+
int
state2res(union parnode *respstate)
{
diff --git a/parser.c b/parser.c
index 97cab66..308571f 100644
--- a/parser.c
+++ b/parser.c
@@ -227,7 +227,8 @@ static int p_dig(struct parctx *, size_t);
static int p_dquotedchar(struct parctx *);
static int p_env(struct parctx *);
static int p_envaddr(struct parctx *);
-static int p_fetchrec(struct parctx *);
+static int p_expunge(struct parctx *);
+static int p_fetch(struct parctx *);
static int p_flag(struct parctx *);
static int p_flext(struct parctx *);
static int p_flfetch(struct parctx *);
@@ -1249,12 +1250,23 @@ p_envaddr(struct parctx *p)
}
int
-p_fetchrec(struct parctx *p)
+p_expunge(struct parctx *p)
{
struct parcur b;
- return p_chk(p, &b) && p_lit(p, IL_FETCH) && p_sp(p) &&
- p_opar(p) && p_list(p, p_msgatt) && p_cpar(p) || p_rwd(p, &b);
+ return p_beg(p, &b, IP_EXPUNGE) && p_nznum(p) && p_sp(p) &&
+ p_lit(p, IL_EXPUNGE) && p_end(p, &b) || p_rwd(p, &b);
+}
+
+int
+p_fetch(struct parctx *p)
+{
+ struct parcur b;
+
+ return p_beg(p, &b, IP_FETCH) && p_nznum(p) && p_sp(p) &&
+ p_lit(p, IL_FETCH) && p_sp(p) && p_opar(p) &&
+ p_list(p, p_msgatt) && p_cpar(p) && p_end(p, &b) ||
+ p_rwd(p, &b);
}
int
@@ -1673,10 +1685,7 @@ p_month(struct parctx *p)
int
p_msgdata(struct parctx *p)
{
- struct parcur b;
-
- return p_chk(p, &b) && p_nznum(p) && p_sp(p) &&
- (p_lit(p, IL_EXPUNGE) || p_fetchrec(p)) || p_rwd(p, &b);
+ return p_expunge(p) || p_fetch(p);
}
int
diff --git a/parser.h b/parser.h
index d3d58b5..26d03fc 100644
--- a/parser.h
+++ b/parser.h
@@ -21,6 +21,8 @@ enum {
IP_CAPDATA,
IP_CONTREQ,
IP_EXISTS,
+ IP_EXPUNGE,
+ IP_FETCH,
IP_RESPAUTH,
IP_RESPBYE,
IP_RESPDATA,
diff --git a/pshades.c b/pshades.c
index cfb78a7..21287a8 100644
--- a/pshades.c
+++ b/pshades.c
@@ -17,6 +17,8 @@ char *prod[] = {
"CAPDATA",
"CONTREQ",
"EXISTS",
+ "EXPUNGE",
+ "FETCH",
"RESPAUTH",
"RESPBYE",
"RESPDATA",