RFC 822 Support Functions 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); header buffer to write RFC 822 header env message ENVELOPE (used to obtain RFC 822 information) body message BODY (used to obtain MIME information) 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); dest buffer to write address list adr RFC 822 ADDRESS list 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); en destination pointer where message ENVELOPE will be stored bdy destination pointer where message BODY will be stored s RFC 822 header to parse (character string) i length of RFC 822 header b stringstruct of message body host default host name if an address lacks an @host. temp scratch buffer, must be long enough to hold unwound header lines (a buffer that is i octets long is OK) 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); lst destination pointer where ADDRESS will be stored string string of addresses to parse host default host name if an address lacks an @host. This function parses the address list in the given string into an address list in lst. Any addresses missing a host name are 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); t scratch buffer, large enough to hold message header env message ENVELOPE body message BODY f I/O function to write to s stream for I/O function f ok8bit non-zero if OK to output 8-bit data 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 typedef long (*soutr_t) (void *stream,char *string); where stream 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); src source string srcl size of source string in octets len pointer to where destination string length in octets will be returned 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); src source string srcl size of source string in octets len pointer to where destination string length in octets will be returned 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.