OSI/TS Management Programming Manual
Sample Programs
056786 Tandem Computers Incorporated C–33
unsigned long etxt_stat;
# define high(x) (x >> 16)
# define low(x) (x & 0xFFFF)
char text[EVT_TEXT_LEN+1]; /* needed for printf() call */
int i;
/* Generate display text from event message. */
etxt_stat = EMSTEXT( (int *)event_buf,
evt_text_buf,
EVT_TEXT_LEN, /* displayable line length */
NUM_EVT_LINES, /* number of display lines */
actual_len,0,0, /* line length to display */
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]);
text[ actual_len[i] ] = 0; /* Add null to conform to
* C convention. */
printf("%s\n", text);
}
}
}
#pragma PAGE
/************************************************************
* 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 );