On Sun, 28 Jan 2007, tsuraan wrote:
Using c-client, is it possible to get the full source of a message without
reading it entirely to RAM using mail_fetch_message(...)? It seems like
most of c-client is really pluggable and would allow for this, but I'm not
sure what I need to do. Do I need to write a custom mailbox backend, or am
I just missing some alternative to mail_fetch_message that doesn't load
everything to memory?
First comment: why are you calling mail_fetch_message()? The only reason
why a well-written client would need to do call that function is if it is
downloading the entire message to save on the client's hard drive.
Otherwise, you should be calling mail_fetch_structure() and using the
resulting ENVELOPE and BODY information to fetch portions of the message
as needed.
Now, as to your main question. Yes, you can do this for IMAP, POP, and
NNTP; but not with mail_fetch_message(). mail_fetch_message() is
generally a function to avoid.
The secret is to arm a mailgets_t callback function via the SET_GETS
operation of mail_parameters(). Then, use mail_partial_text() and/or
mail_partial_body() to access the desired data.
There is a secondary functionality of the mailgets_t callback which will
also happen on certain other calls, but you can't assume whether it will
happen and whether it will save memory space even if it does happen. The
mailgets_t callback routine has to look at the data identifier to
determine what it wants to do with it, and it must also set up a return
value for the application to look it in order to determine whether the
mailgets_t action happened or if a char* string was returned. This
secondary functionality of mailgets_t was created for the old 16-bit
DOS/Windows 3.1 version of PC Pine which was abandoned a decade ago; and
is no longer supported. [Put another way, if you use this secondary
functionality and it works, I'm happy for you; if it doesn't work, I don't
care and I'm not going to waste time looking at it.]
For this reason, modern (including 32-bit Windows which is Windows 95 or
later) software which uses the mailgets_t functionality avoids the
secondary functionality by arming the mailgets_t function immediately
prior to a mail_partial_body()/mail_partial_text() call, and then
disarming it:
mail_parameters (NIL,SET_GETS,(void *) myMailGets);
retval = mail_partial_text (.....);
mail_parameters (NIL,SET_GETS,NIL);
if (retval)
success_action;
else
error_action;
Generally, the only time this is actually used is when processing
attachments. Specifically, the normal mail_fetch_body() calls are called
for text message parts (which generally are of manageable size), and the
mail_partial_body() call is used to read a big attachment. Take a look at
the code in Pine/Alpine to see how this is done.
For certain local mailbox formats (mbx and mix), there is also a mechanism
to stream message texts without reading the entire text. This is used by
UW imapd, but AFAIK by nothing else.
-- 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.
_______________________________________________
Imap-uw mailing list
[email protected]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw