PreviousNext

The OM_EXPORT and OM_IMPORT Macros

Most application programs find it convenient to export all the names they use from the same C source module. OM_EXPORT allocates memory for the constants that represent an object OM class or an object identifier, as shown in the following code fragment from example.c:

/* Define necessary Object Identifier constants

*/

OM_EXPORT(DS_A_COMMON_NAME)

OM_EXPORT(DS_A_COUNTRY_NAME)

OM_EXPORT(DS_A_ORG_NAME)

OM_EXPORT(DS_A_ORG_UNIT_NAME)

OM_EXPORT(DS_A_PHONE_NBR)

OM_EXPORT(DS_C_AVA)

OM_EXPORT(DS_C_DS_DN)

OM_EXPORT(DS_C_DS_RDN)

OM_EXPORT(DS_C_ENTRY_INFO_SELECTION)

In this code fragment, object identifier constants that represent OM classes defined in the xds.h and xdsbdcp.h header files are exported to the main program module. The object identifier constants are defined in xds.h with the OMP_O prefix followed by the variable name for the object identifier. The constant itself provides the hexadecimal value of the object identifier string.

The OM_EXPORT macro takes the OM class name as input and creates two new data structures: a character string and a structure of type OM_string. The structure of type OM_string contains a length and a pointer to a string that may be used later in an application program by the OM_OID_DESC macro to initialize the value of an object identifier.

OM_IMPORT marks the identifiers as external for the compiler. It is used if OM_EXPORT is called in a different file from where its values are referenced. OM_IMPORT is not used in example.c because OM_EXPORT is called in the file where the object identifiers are referenced.