EMS Manual
Example of Retrieving Event Messages
EMS Manual—426909-005
A-31
C Source File
send_spi_cmd();
/* Find the event message within the GETEVENT response */
tkn = ZEMS_TKN_EVENT;
/* Returns the offset of the event in the */
/* spi buffer via event_buf_loc. */
spi_err = SSGETTKN( (int *)spi_buf, ZSPI_TKN_OFFSET,
(char *)&tkn, 1, (int *)&byteoffset);
if (spi_err != ZSPI_ERR_OK)
DEBUG();
event_buf = (EMSBUFDEF *)((char *)(spi_buf) +
byteoffset + 2);
/* Display the event message at your terminal */
displ_event( event_buf );
/* Save CONTEXT token from this GETEVENT response for */
/* the next GETEVENT request */
spi_err = SSMOVETKN(ZSPI_TKN_CONTEXT,
(int *)spi_buf, 1, /* Source */
(int *)sav_buf, 1); /* Destination */
if (spi_err != ZSPI_ERR_OK)
DEBUG();
/* Move the updated command to spi_buf for next time */
/* through the loop */
movmem( (char *)sav_buf, (char *)spi_buf,
sizeof(EMSBUFDEF) );
} /* end while */
return(0);
} /* end getevent_loop() */
#pragma PAGE "main program code"
/* ---------- main: -------------------
* Starts a distributor and calls procedures that use SPI
* commands to connect a source collector, to load a filter,
* and to position the distributor within the log files.
* Then the getevent_loop procedure is called to retrieve
* and process event messages. */
main(int argc, char **argv)
{
/* local pointer to the startup message struct */
CISTART *startup;
char *cptr;
int ccval = 0;
static char zspi_name[] = "#ZSPI";
/* Initialize subsystem IDs */
cptr = strncpy(zems_val_ssid.u_z_filler.z_filler,
ZSPI_VAL_TANDEM, 8);
zems_val_ssid.z_number = ZSPI_SSN_ZEMS;