Address Parsing API

The goal of this API is to facilitate the task of programmers by providing a robust set of utilities to parse email addresses. A task which can rarely be avoided.

This API can be used to parse a list of addresses, or a single address. Parsing an address means being able to extract properties from it. Given the address

"John B. Smith" <@gw.com:jbsmith@abcd.com>

this API distinguishes the following address properties:

TABLE 1 Address properties
Property
Value
IM_ADRPROP_PROPER "John B. Smith" <@gw.com:jbsmith@abcd.com>
IM_ADRPROP_ADDRESS @gw.com:jbsmith@abcd.com
IM_ADRPROP_LOCAL jbsmith
IM_ADRPROP_DOMAIN abcd.com
IM_ADRPROP_PHRASE "John B. Smith"
IM_ADRPROP_ROUTE @gw.com:


In order to parse a list of addresses, the string containing the list of addresses is first processed by imadr_parse_list which allocates internal datastructures to hold the address.
If the list successfully parsed and indexed, individual addresses or address properties can be retrieved by calling imadr_get or imadr_get_property.

If exactly one address is to be parsed, the more lightweight imadr_parse_one can be used instead of the calls described earlier.

Example programs


The example C program parse_addresses.c, is a simple interactive utility parses kist of addresses and displays the properties of each address.



Copyright © 1999 Sun Microsystems, Inc. All Rights Reserved.