EMS Manual

Example of Retrieving Event Messages
EMS Manual426909-005
A-28
C Source File
/* Determine how much buffer was used */
spi_err = SSGETTKN( (int *)spi_buf, ZSPI_TKN_USEDLEN,
(char *)&used_len );
if (spi_err != ZSPI_ERR_OK)
DEBUG();
/* Send the used part to the distributor */
ccval = WRITEREAD( distr, (int *)spi_buf, used_len,
ZEMS_VAL_BUFLEN );
if (ccval != CCE)
DEBUG();
/* reset the buffer length to what was declared for
spi_buf */
spi_err = SSPUTTKN( (int *)spi_buf, ZSPI_TKN_RESET_BUFFER,
(char *)ibuflen );
if (spi_err != ZSPI_ERR_OK)
DEBUG();
/* Response is in the buffer--check for return code */
spi_err = SSGETTKN( (int *)spi_buf, ZSPI_TKN_RETCODE,
(char *)&ems_err, 1 );
if (spi_err != ZSPI_ERR_OK)
DEBUG();
if (ems_err != 0)
DEBUG();
}
#pragma PAGE "spi_cmd_set_source()"
/* ---------- spi_cmd_set_source -------------------
* Builds an SPI command that directs the distributor to use
* a collector as a source of event messages.
*/
void spi_cmd_set_source(void)
{
/* Initialize the spi_buf for distributor CONTROL
command */
spi_err = SSINIT( (int *)spi_buf, ZEMS_VAL_BUFLEN,
(int *)&zems_val_ssid,
ZSPI_VAL_CMDHDR, ZEMS_CMD_CONTROL );
if (spi_err != ZSPI_ERR_OK)
DEBUG();
/* place the connect-source-collector token in buffer */
spi_err = SSPUTTKN( (int *)spi_buf,
ZEMS_TKN_CONNECT_SRC_COLL,
coll_name );
if (spi_err != ZSPI_ERR_OK)
DEBUG();
/* Send the command to the distributor */