immd_get_recipient - Obtain the next envelope To: address from a message.
#include <imta.h>
int immd_get_recipient(immd_t md, int *flags, char **adr, char **origadr);
immd_get_recipient() should be called repeatedly to obtain each envelope To: address from a message. The address is placed in a buffer referenced by adr . For each call, a single envelope To: address will be returned in address.
Each call to immd_get_recipient() overwrites values previously output by calls to the same function. Therefore, the contents of adr or origadr must be copied to a buffer allocated by the caller if it is to be re-used after immd_get_recipient() is again called.
md is the dequeue context output by an earlier call to immd_init() .
After all addresses have been output, immd_get_recipient() will return IMRC_EOF. For example, if the message envelope has two To: addresses, then three calls to immd_get_recipient() should be made. In the first two calls, the two addresses will be output along with the return IMRC_OK. In the third call no address will be output and IMRC_EOF will be returned. After all of the envelope To: addresses have been read, the message header and body may be read with immd_read_header() and/or immd_read_text() .
The origadr gives, if known, the original form of the envelope To: address. This is useful when dealing with messaging formats such as X.400 which retain such information. When re-enqueuing a message, this information can be subsequently passed back into imme_add_recipient() and otherwised used or discarded as appropriate.
flags is set by the library to the notary flags for this recipient the value is a bitwise OR of zero or more of the following constants:
The calling program should then abort processing of the current message and call either immd_dequeue() or immd_defer(). In this particular case, both calls have the same effect.
A textual version reason for the failure can be obtained by calling imta_error() immediately afterwards.
_______________________________________
immd_init(3) , imta_error(3) , immd_read_header(3)