EMS Manual
Example of Retrieving Event Messages
EMS Manual—426909-005
A-30
C Source File
lines */
actual_len,0,0, /* actual line
length */
1); /* console-
compatible */
/* check for EMSTEXT calling errors */
if ( (high(etxt_stat) == 0) && (low(etxt_stat) != 0) )
DEBUG();
for(i=0; i < NUM_EVT_LINES; i++) {
if( actual_len[i] != -1 ) {
movmem(&evt_text_buf[i*EVT_TEXT_LEN], text,
actual_len[i]);
/* add null to conform to C convention */
text[ actual_len[i] ] = 0;
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, procedure gets an
* event message and calls displ_event to display it at the
* terminal. The procedure returns in the following cases:
* (1) the GETEVENT response contains a ZEMS_TKN_PASSVAL of 0
* (from a PASS 0 filter statement),
* (2) 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 */
/* Byte offset to event returned by SSGETTKN */
int byteoffset;
unsigned long tkn;
/* Initialize spi_buf for GETEVENT SPI 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 */