The program uses the function stringToXdsName to convert the DCE name entered by a user into an XDS name object of OM class DS_C_DS_DN, which is the representation of a distinguished name. In the other two sample programs, arrays of descriptor lists are statically declared to represent the AVAs and RDNs that make up the public object that represents a distinguished name. The function stringToXdsName parses the DCE name and dynamically converts it to a public object.
For example, the following code fragment shows how space for a DS_C_AVA object is allocated and its entries are filled by using the FILL_OMD_XOM_STRING and FILL_OMD_NULL macros:
/*
* Allocate space for a DS_C_AVA object and fill in its entries:
* DS_C_AVA class identifier
* AVA's type
* AVA's value
* null terminator
*/
ava = (OM_descriptor *)malloc( sizeof(OM_descriptor) * 4 );
if( ava == NULL ) /* malloc() failed */
return OM_MEMORY_INSUFFICIENT;
FILL_OMD_XOM_STRING( ava, 0, OM_CLASS, OM_S_OBJECT_IDENTIFIER_STRING,
DS_C_AVA )
splitNamePiece( start, &type, &value );
FILL_OMD_XOM_STRING( ava, 1, DS_ATTRIBUTE_TYPE,
OM_S_OBJECT_IDENTIFIER_STRING, type )
FILL_OMD_STRING( ava, 2, DS_ATTRIBUTE_VALUES, OM_S_PRINTABLE_STRING,
value )
FILL_OMD_NULL( ava, 3 )
The program uses the same method to build the RDNs that make up the the distinguished name. The distinguished name is NULL terminated by using the FILL_OMD_NULL macro and the location of the new public object is provided for the calling routine (main) in the pointer xdsNameObj, as shown in the following code fragment:
/* Add the DS_C_RDN object to the DS_C_DS_DN object. */
FILL_OMD_STRUCT( dsdn, index, DS_RDNS, OM_S_OBJECT, rdn )
}
/*
* Null terminate the DS_C_DS_DN, tell the calling routine
* where to find it, and return.
*/
FILL_OMD_NULL( dsdn, index )
*xdsNameObj = dsdn;
return( OM_SUCCESS );
} /* end stringToXdsName() */