|
|
Although rfc822.c contains several additional functions besides these, only the functions documented here should be used by applications. The other functions are for internal use only.
void rfc822_header(char *header, ENVELOPE *env, BODY *body);
This function writes an RFC 822 format header into header based on the information in the envelope and body. The header buffer must be large enough to contain the full text of the resulting header.
void rfc822_write_address(char *dest, ADDRESS *adr);
This function writes an RFC 822 format address list into dest based on the information in adr. The dest buffer must be large enough to contain the full text of the resulting address list.
void rfc822_parse_msg(ENVELOPE **en, BODY **bdy, char *s, unsigned long i, STRING *b, char *host, char *tmp);
This function parses the RFC 822 header pointed to by s with body pointed to by string structure b into the specified destination envelope and body pointers, using host as the default host name and tmp as a scratch buffer. New ENVELOPE and BODY structures are created; when finished with them the application must free them with mail_free_envelope and mail_free_body. Any parsing errors are noted via the mm_log mechanism using log type PARSE.
void rfc822_parse_adrlist(ADDRESS **lst, char *string, char *host);
This function parses the address list in the given string into an address list in lst. Any addresses missing a host name have the host name defaulted from the host argument. If the destination list is non-empty it appends the new addresses to the list. Any parsing errors are noted via the mm_log mechanism using log type PARSE.
long rfc822_output(char *t, ENVELOPE *env, BODY *body, soutr_t f, void *s, long ok8bit);
This function writes the message described with the given envelope and body. Any body part contents of type ENCBINARY is converted to ENCBASE64 before sending. If ok8bit is NIL, any message data of type ENC8BIT is converted to ENCQUOTEDPRINTABLE before sending; if ok8bit is non-NIL then ENC8BIT data is sent as-is. T is returned if the function succeeds, else NIL is returned.
The function f is typically net_soutr, but it can be any function which matches the following:
typedef long (*soutr_t)(void *stream, char *string);The stream argument holds sufficient information to enable the output routine to know where to output to, and the string is a null-terminated string to output. This function returns either T or NIL, and that value is passed up to rfc822_output for its return.
void *rfc822_base64(char *src, unsigned long srcl, unsigned long *len);
This function decodes a BASE64 body part given a source string and its length. The decoded body part as a sequence of binary octets is returned, and its length is returned in len.
char *rfc822_qprint(char *src, unsigned long srcl, unsigned long *len);
This function decodes a QUOTED-PRINTABLE body part given a source string and its length. The decoded body part as an 8-bit character string is returned, and its length is returned in len.