ACC Utilities Reference Guide

ZMLOG - Diagnostic Message Logging
ZCOM Diagnostic Message Logging Mechanism
Chapter 6 167
len = read (fd,&mlog,sizeof(mlog)); /*blocked read if no data.
if there is data, then read will
be satisfied on either ’buffer
1/3 threshold logic’ or in 1
sec. */
/* check buffer log size */
if (mlog.blen != ZCOM_MLSIZE - (sizeof(mlog) - len)) {handle_error()
} /* detected bad zcom log header */
/* so skip this log buffer */
/* check for overrun errors */
if (mlog.nerr !=0) {handle_error()
}
/* Now Process each record in this error message log buffer */
len = 0;
/* while more records, then continue */
while (len < mlog.blen) {
mp = (char*)mlog.mbuf + len; /* point to start of record */
rlen = *mp; /* get the record length */
/* check record length, which is in 1st and last byte of record */
if (rlen != *(mp+1+rlen)) {handle_error()
}
/* user application logging code to follow */
zp = (zlrec_type *)(mp+1); /* the record data structure starts
with the timestamp field */
zp->scode = sev; /* priority as retrieved from message file */
/* ... insert user code here ...*/
len += (rlen +2); /* advance to next record */
} /* end of while */
} /* end of for loop */