PreviousNext

Partially Defined Static Public Objects

The program partially defines static XDS objects with placeholders so that values for the surname and telephone number entered by the user can be added later, as shown in the following code fragment:

static OM_descriptor xdsSurname[] = {

/* This object is an attribute -- a surname. */

OM_OID_DESC( OM_CLASS, DS_C_ATTRIBUTE ),

OM_OID_DESC( DS_ATTRIBUTE_TYPE, DS_A_SURNAME ),

/* No default -- so we need a placeholder for the actual surname. */

OM_NULL_DESCRIPTOR,

/* Null terminator */

OM_NULL_DESCRIPTOR

};

static OM_descriptor xdsPhoneNum[] = {

/* This object is an attribute -- a telephone number. */

OM_OID_DESC( OM_CLASS, DS_C_ATTRIBUTE ),

OM_OID_DESC( DS_ATTRIBUTE_TYPE, DS_A_PHONE_NBR ),

/* By default, phone numbers are unlisted. If the user specifies */

/* an actual phone number, it will go into this position. */

{ DS_ATTRIBUTE_VALUES, OM_S_PRINTABLE_STRING,

OM_STRING( "unlisted" ) },

/* Null terminator */

OM_NULL_DESCRIPTOR

};

The program prompts the user for the surname of the person whose number will be changed and uses the FILL_OMD_STRING macro to fill in values, as shown in the following code fragment:

if ( operation == 'a' ) {

/* add operation requires additional input */

/*

* Get the person's real name from the user and place it in the

* XDS object already defined at the

* top of the program (xdsSurname).

* We are requiring a name, so we will loop until we get one.

*/

do {

printf( "What is this person's surname? " );

gets( newSurname );

} while ( *newSurname == '\0' );

FILL_OMD_STRING( xdsSurname, 2, DS_ATTRIBUTE_VALUES,

OM_S_TELETEX_STRING, newSurname )