1.7. Retrieving Current Option Values

Most UM objects allow their current attributes' option values to be retrieved during operation. UM API functions supporting such actions operate on the object itself.

The UM objects which support these actions are lbm_src_t, lbm_rcv_t, lbm_context_t, and lbm_event_queue_t. For each such object, there are corresponding API functions to get an option as a binary value, and get an option as a string value. These function names are based on the object name, suffixed with _getopt(), and _str_getopt(). As an illustration of this convention, the API functions for working with lbm_event_queue_t objects are shown in the following table.

Table 1-4. UM API Functions For Retrieving Option Values from lbm_event_queue_t Objects

Action UM API function
Get Option as a Binary Value lbm_event_queue_getopt()
Get Option as a String Value lbm_event_queue_str_getopt()

The following sections describe in detail the use of these UM API functions. The functions related to lbm_event_queue_t objects are used for the purpose of illustration, but the instructions (if not the specifics) apply to all such UM objects.

1.7.1. Getting An Option as a Binary Value

Getting an option as a binary value is very similar to setting an option from a binary value: it requires knowledge of not only the option name, but its type as well. The final two parameters in the call to lbm_event_queue_getopt() are a pointer to a variable to receive the current option value, and a pointer to a variable of type size_t which contains the length of the option value variable. This length must be be correct for the specified option.

In the example code below, the option value for the queue size warning is retrieved.

unsigned long int optval;
size_t optlen;
lbm_event_queue_t evq; /* must be previously created */
int rc;

/* Get the queue size warning value */
optlen = sizeof(optval);
rc = lbm_event_queue_getopt(&evq, "queue_size_warning", &optval, &optlen);
if (rc != 0)
{
   /* Handle error */
}
/* optval now contains the value of queue_size_warning, which should be 5000 */

1.7.2. Getting An Option as a String Value

Getting an option as a string value effectively does the same thing that getting an option as a binary value does. However, the option value is returned as a null-terminated string, just as you would specify the option value in a configuration file. The final two parameters in the call to lbm_event_queue_str_getopt() are a pointer to a string variable to receive the current option value, and a pointer to a variable of type size_t which contains the maximum size of the option value string variable.

In the example code below, the option value for the queue size warning is retrieved.

char optval_string[256];
size_t optlen;
lbm_event_queue_t evq; /* must be previously created */
int rc;

/* Get the queue size warning value */
optlen = sizeof(optval_string);
rc = lbm_event_queue_str_getopt(&evq, "queue_size_warning", optval_string, &optlen);
if (rc != 0)
{
   /* Handle error */
}
/* optval now contains the value of queue_size_warning, which should be "5000" */

Copyright (c) 2004 - 2014 Informatica Corporation. All rights reserved.