Subject: mail_criteria() for IMAP4

From: "Oliver Schulze L." <[email-masked]>
Date: Fri, 25 Oct 2002 16:05:18 -0300

Hi,
I have read that the function mail_criteria() only 
support IMAP2 search criteria. 
Is there any function available for IMAP4?

I need this same function:
SEARCHPGM *mail_criteria (char *criteria);
but I need that the function understand IMAP4 search criteria.
In particular, the criteria: SENTSINCE

Thanks
Oliver
-- 
Oliver Schulze L.
[email-masked]

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Fri, 25 Oct 2002 12:13:44 -0700 (PDT)

mail_criteria() is a compatibility function for old programs and supports
IMAP2 criteria only.

Modern programs should build a SEARCHPGM and use mail_search_full() instead of
using the old interface.

---

From: "Oliver Schulze L." <[email-masked]>
Date: Fri, 25 Oct 2002 16:30:29 -0300

Hi,
thanks for the email
mail_criteria() is used in php 4.1.2 for creating a SEARCHPGM and
then a call to mail_search_full() is made.
How do I create a IMAP4 compatible SEARCHPGM?
Can I just create a new variable of type SEARCHPGM and edit
its structure variable by hand? Or is there a function for doing this?

I also just patched src/c-client/mail.c for accepting SENTSINCE criteria.
Can I post the patch here? Is just a 1 line patch.

Oliver

-- 
Oliver Schulze L.
[email-masked]

---

From: "Oliver Schulze L." <[email-masked]>
Date: Fri, 25 Oct 2002 16:37:25 -0300

Hi Steve,
thanks, that will work fine in that case.

I trying to fix bug#
http://bugs.php.net/bug.php?id=15238
and I think a IMAP4 version of mail_criteria will do the work.
I'm studing mail.c and I think a IMAP4 version of mail_criteria
should be posible to make.
I'm comparing the search criteria in both RFC(IMAP2 and 4)
to patch mail_criteria the right way.

Regards
Oliver

Steve Hubert wrote:

>On Fri, 25 Oct 2002, Oliver Schulze L. wrote:
>
>  
>
>For this special case I use
>
>   pgm = mail_criteria("SINCE <date>");
>   pgm->sentsince = pgm->since;
>   pgm->since = 0;
>
>which is easier than figuring out the correct number to put in sentsince
>yourself.
>
>  
>

-- 
Oliver Schulze L.
[email-masked]

---

From: Mark Crispin <[email-masked]>
Date: Fri, 25 Oct 2002 12:33:54 -0700 (PDT)

To create a SEARCHPGM, call mail_new_searchpgm() and then set the fields as
you wish.  When you call mail_search_full(), either set SE_FREE or be sure to
call mail_free_searchpgm() when you are finished with the SEARCHPGM.

It should be easier to manipulate a SEARCHPGM than it is to build a search
string.

If you use a static structure, be sure to zero it out (e.g. with a memset())
and do *not* set SE_FREE.

You're welcome to post patches.  However, as I indicated in my previous
message, mail_criteria() is an obsolete interface and I am not going to
support it for IMAP4.

---

From: "Oliver Schulze L." <[email-masked]>
Date: Fri, 25 Oct 2002 16:52:14 -0300

Hi Mark,
thanks for the instrucctions. Will check it.

Also, is there a function that can parse a string and convert
it to a SEARCHPGM?

In php the string provided by the user must be parsed and then
a SEARCHPGM must be created.

mail_criteria() does this, thats because it is still used in php 4.1.2

About the patch, it is comming in a few hours.

Oliver

-- 
Oliver Schulze L.
[email-masked]

---

From: "Oliver Schulze L." <[email-masked]>
Date: Tue, 29 Oct 2002 19:23:14 -0300

Hi Mark,
here is a little patch to
src/c-client/mail.c
that add supports some IMAP4 search criteria:
DRAFT
HEADER
SENTBEFORE
SENTON
SENTSINCE
UNDRAFT
I could not add support for the rest because I don't know
how to read a numeric parameters to this criterias:
LARGER
SMALLER
UID

What I need is a function like mail_criteria() that receives a IMAP4 
search string
and returns a (SEARCHPGM *). Since I could not find any function that does
this, I opted to modify mail_criteria()

If mail_criteria() is deprecated, is there an equivalent function for imap4?

Thanks
Oliver

-- 
Oliver Schulze L.
[email-masked]

--- mail.c.old	Fri Oct 25 16:25:11 2002
+++ mail.c	Tue Oct 29 19:14:09 2002
@@ -3460,13 +3460,17 @@
     case 'C':			/* possible CC */
       if (!strcmp (criteria+1,"C")) f = mail_criteria_string (&pgm->cc);
       break;
-    case 'D':			/* possible DELETED */
+    case 'D':			/* possible DELETED, DRAFT */
       if (!strcmp (criteria+1,"ELETED")) f = pgm->deleted = T;
+      else if (!strcmp (criteria+1,"RAFT")) f = pgm->draft = T;
       break;
     case 'F':			/* possible FLAGGED, FROM */
       if (!strcmp (criteria+1,"LAGGED")) f = pgm->flagged = T;
       else if (!strcmp (criteria+1,"ROM")) f=mail_criteria_string (&pgm->from);
       break;
+    case 'H':			/* possible HEADER */
+      if (!strcmp (criteria+1,"EADER")) f = mail_criteria_string (&pgm->header);
+      break;
     case 'K':			/* possible KEYWORD */
       if (!strcmp (criteria+1,"EYWORD"))
 	f = mail_criteria_string (&pgm->keyword);
@@ -3484,9 +3488,11 @@
       break;
     case 'S':			/* possible SEEN, SINCE, SUBJECT */
       if (!strcmp (criteria+1,"EEN")) f = pgm->seen = T;
+      else if (!strcmp (criteria+1,"ENTBEFORE")) f = mail_criteria_date (&pgm->sentbefore);
+      else if (!strcmp (criteria+1,"ENTON")) f = mail_criteria_date (&pgm->senton);
+      else if (!strcmp (criteria+1,"ENTSINCE")) f = mail_criteria_date (&pgm->sentsince);
       else if (!strcmp (criteria+1,"INCE")) f=mail_criteria_date (&pgm->since);
-      else if (!strcmp (criteria+1,"UBJECT"))
-	f = mail_criteria_string (&pgm->subject);
+      else if (!strcmp (criteria+1,"UBJECT")) f = mail_criteria_string (&pgm->subject);
       break;
     case 'T':			/* possible TEXT, TO */
       if (!strcmp (criteria+1,"EXT")) f = mail_criteria_string (&pgm->text);
@@ -3495,6 +3501,7 @@
     case 'U':			/* possible UN* */
       if (criteria[1] == 'N') {
 	if (!strcmp (criteria+2,"ANSWERED")) f = pgm->unanswered = T;
+	else if (!strcmp (criteria+2,"DRAFT")) f = pgm->undraft = T;
 	else if (!strcmp (criteria+2,"DELETED")) f = pgm->undeleted = T;
 	else if (!strcmp (criteria+2,"FLAGGED")) f = pgm->unflagged = T;
 	else if (!strcmp (criteria+2,"KEYWORD"))