PreviousNext

The OM_OID_DESC and OMP_LENGTH Macros

The OM_OID_DESC macro initializes the type, syntax, and value of an OM attribute that holds an object identifier; in other words, it initializes OM_descriptor. It takes as input an OM attribute type and the name of an object identifier. The object identifier should have already been exported to the program module, as shown in the previous topic.

The output of the macro is an OM_descriptor composed of a type, syntax, and value. The type is the name of the OM class. The syntax is OM_S_OBJECT_IDENTIFIER. The value is a two-member structure with the length of the object identifier and a pointer to the actual object identifier string. It is defined as a pointer to void so that it can be used as a generic pointer; it can point to any data type.

OM_OID_DESC calls OMP_LENGTH to calculate the length of the object identifier string.

The following code fragment from xom.h shows the OM_OID_DESC and OMP_LENGTH macros:

/* Private macro to calculate length

* of an object identifier

*/

#define OMP_LENGTH(oid_string) (sizeof(OMP_O_##oid_string)-1)

/* Macro to initialize the syntax and value

* of an object identifier

*/

#define OM_OID_DESC(type, oid_name)

{ (type), OM_S_OBJECT_IDENTIFIER_STRING,

{ OMP_LENGTH(oid_name) , OMP_D_##oid_name } }