[Imap-uw] Using spg (search) in mail_sort

Mark Crispin mrc at Washington.EDU
Mon May 19 09:35:18 PDT 2008


On Mon, 19 May 2008, bhayden at umn.edu wrote:

> From what I can tell it seems to be down to the app to walk the results and

> make a count.


That's one way. What is returned is a 0-terminated array.


> for (i = 0; sort_result[i] > 0; i++)


Note that message numbers are unsigned, so test for non-zero, not
greater than zero.
for (i = 0; sort_result[i]; i++)

There are two other ways to get the number of sorted messages.

If you arm a sortresults_t callback, the number of messages sorted is
returned as the third argument to the callback.

Last, and certainly least, the number of sorted messages is returned in
the nmsgs member of the sortpgm (assuming that you don't use SO_FREE). I
won't count upon that however; it's intended to use against the progress
member and not to size the return array.

So, either use the callback or count the members of the array.

-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.



More information about the Imap-uw mailing list