Subject: questions

From: Ian Smith <[email-masked]>
Date: Sun, 27 Feb 1994 21:25:19 -0500

C-Client developers:
I've been porting my mail program to over to use C Client for the last
few
weeks and I'm generally very pleased.  It seems to be "just what the
doctor
ordered."  I have a few questions that have  arisen that haven't worked
themselves out, and I was hoping that some C-Client veterans might
answer
them....
1) I seem unable to put an arbitrary string in as a "flag".  C-Client
seems to be rejecting flags which are not "\\answered", "\\seen", etc.
This seems strange to me as there are lots of other types of marking
that could be useful, the most of obvious one (that I have been unable
to
get to work) is: "forwarded".  I'm also confused by this because the
IMAP spec seems to idicate (p. 17) that one can search for an arbitrary
keyword... what I am confused about here?
2) I'd like to be able to retreive an entire message (complete) as text
for the purpose of forwarding it under the MIME rules. I have built all
the MIME boundaries and everything to wrap the message in, and I just
want
the WHOLE message (all headers, body (mime cruft and all)) for
inclusion...
I couldn't find this in the API, espcially since I would like to
preserve
all MIME cruft in the original, so I don't want to get the message part
by
part and copy it onto disk (for sending with /bin/mail). Are there
other
(undocumented?) calls to get at more of the MIME cruft (epilogue,
prologue
etc) if I wanted to get the pieces individually (using fetchbody)?
Any suggestions?
3) Mark mentioned before that I should use a "hands-off" policy with
respect to memory mangement and the toolkit... are there exceptions
to this involving retreiving messages? I don't use C-Client's
facilities
for sending mail (I don't use any "create" functions...) I've noticed
a difficult bug to track down involving a heap corruption which will
appear if I am getting large (this probably just accelerates the
problem)
messages via MIME, e.g. a big base-64 encoded image. Also, I'm using
rfc822_base64 to decode this stuff and it was my understanding that
I needed to "fs_give(memoryptr)" the memory back after decoding...
is this working for other people?
thanks for the help,
ian
---------------------------------------------------------------------------
"Who watches the watchmen?"  --epigraph of the Tower Commission Report, 1987
ian smith, multimedia computing group, georgia tech, [email-masked]

---

From: Mike Macgirvin <[email-masked]>
Date: Mon, 28 Feb 1994 08:45:52 -0800 (PST)

>  1) I seem unable to put an arbitrary string in as a "flag".

	User flags ("keywords") are only implemented in Tenex mode mailboxes 
that I'm aware. The values for these strings need to be defined to the server 
using ".mminit" or .imapinit". There doesn't seem to be any way of defining 
them via the client. You can set or clear the flag bits, but not define the 
name for them. I'll let somebody more knowledgeable supply the exact details.

>  2) I'd like to be able to retreive an entire message (complete)
>  as text for the purpose of forwarding it under the MIME rules.

	Try mail_fetchheader followed by mail_fetchtext(). Cat the two 
together, change newlines to local convention (argggh, the c-client should 
really do this, IMHO), and you've got it.

>  3) Mark mentioned before that I should use a "hands-off" policy
>  with respect to memory mangement and the toolkit... are there
>  exceptions to this involving retreiving messages?

	I don't believe so. The encode/decode functions are different, though. 
They live outside of the cache and you must manage their memory. 

>  it was my understanding that
>  I needed to "fs_give(memoryptr)" the memory back after decoding

	Careful. fs_give takes (void **) (!!!). So if memoryptr is (char *), 
you need "fs_give((void **) &memoryptr);"

---

From: Mark Crispin <[email-masked]>
Date: Mon, 28 Feb 1994 15:17:16 -0800 (PST)

Mike Macgirvin's reply pretty much says everything I would have said.  Here
are a couple of additions:

1) At the present time, the creation of arbitrary user flags (or ``keywords'')
is not supported in IMAP.  I hope that IMSP will support keyword creation.
The current c-client only supports user flags in the Tenex and MTX formats,
although perhaps after there is some reasonable way to define them (other than
``edit your .imaprc file'') this may happen.

2) In general, use the CR/LF convention as the newline convention in your
program.  Let c-client worry about changing to local convention when writing
files.  Your message display code and message editor will have to be aware of
CR/LF newlines instead of the local convention, but if you ever port your
application to some other platform you'll be glad that you did it that way
instead of trying to support 69 different local conventions.  The biggest
trouble you may have is in handing off the message to an external editor; then
you may have to do convention converting.  But, calling an external editor is
a local OS-dependent operation anyway.

It may be hard to be used to writing C code using a different newline
convention than ordinary C, but it will pay off when you port to DOS or Mac.

3) It is very important to remember that fs_give() takes (void **).  This has
the very nice side effect of zeroing the pointer when it is freed, sparing you
countless hours in hunting down dangling pointer bugs later on...  ;-)

---

From: Terry Gray <[email-masked]>
Date: Mon, 28 Feb 1994 15:34:06 -0800 (PST)

> ``edit your .imaprc file'') this may happen.

I believe I read that CMU's Cyrus IMAP server allows dynamic creation of 
user flags.

-teg

---

From: Mark Crispin <[email-masked]>
Date: Mon, 28 Feb 1994 16:45:54 -0800 (PST)

> I believe I read that CMU's Cyrus IMAP server allows dynamic creation of

I think I read the same thing, and certainly IMAP4 makes the concept more
viable.

Unfortunately, the only way to do this in IMAP is to do the ``just create''
action that was rejected for COPY.  I could implement this, but it would be a
slippery slope with no going back.  So, I would like to get group concensus
first...

---

From: John Gardiner Myers <[email-masked]>
Date: Tue, 1 Mar 1994 14:26:48 -0500 (EST)

This is a protocol issue--I'm moving to the topic over to the imap list.

> I believe I read that CMU's Cyrus IMAP server allows dynamic creation of

You read correctly.  It just seemed obvious to me that this was the
only way to get user flags to exist in the first place.

> slippery slope with no going back.  So, I would like to get group concensus

I could go either way--"just create" or explicit CREATEKEYWORD and
DELETEKEYWORD commands.  I was opposed to the "just create" action for
COPY because it was likely that the user could make a typo in the
destination mailbox name and inadvertently lose track of the message.
It also turns out that this action makes doing IMSP slightly harder.

It is possible to make a typo in a keyword name (when first testing
the Cyrus IMAPD, I once created a "/deleted" keyword), but the
potential consequences are less severe.  The fact that there is
currently no mechanism to remove a keyword, short of creating a new
mailbox and COPYing over all the messages, does merit some
consideration.

-- 
_.John G. Myers		Internet: [email-masked]
			LoseNet:  ...!seismo!ihnp4!wiscvm.wisc.edu!give!up