OSI/AS Management Programming Manual
Event-Retrieval Example
Sample Programs
056785 Tandem Computers Incorporated C–45
movmem(&evt_text_buf[i*EVT_TEXT_LEN],
text, actual_len[i]);
text[ actual_len[i] ] = 0; /* Add null to conform to
* C convention. */
printf("%s\n", text);
}
}
}
#pragma PAGE "getevent_loop()"
/* ---------- getevent_loop() -------------------------------
* This procedure consists of a loop to retrieve event
* messages. Each time through the loop, the procedure gets
* an event message and calls displ_event to display it at
* the terminal. The procedure returns in the following
* cases:
* (1) If the GETEVENT response contains a ZEMS_TKN_PASSVAL
* of 0 (from a PASS 0 filter statement);
* (2) If the GETEVENT response contains an EOF warning, or
* the messages-processed limit (msglimit) is exceeded.
*/
int getevent_loop(void)
{
EMSBUFDEF *event_buf; /* pointer to storage in stack */
int byteoffset; /* byte offset to event, as
* returned by SSGETTKN */
unsigned long tkn;
/* Initialize spi_buf for GETEVENT command. */
spi_err = SSINIT( (int *)spi_buf, ZEMS_VAL_BUFLEN,
(int *)&zems_val_ssid,
ZSPI_VAL_CMDHDR, ZEMS_CMD_GETEVENT );
if (spi_err != ZSPI_ERR_OK)
DEBUG();
/* Save the original command. */
movmem( (char *)spi_buf, (char *)sav_buf,
sizeof(EMSBUFDEF) );
/* Begin loop that gets and displays event messages. */
while ( (msgcount < msglimit) || (msglimit == 0) ) {
msgcount++;
/* Send GETEVENT command to distributor. */
send_spi_cmd();
/* Extract event message from GETEVENT response. */
tkn = ZEMS_TKN_EVENT;
/* Return offset of event in 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();