aix中错误:常由命令errpt获得:
常用:errlog_open,errlog_close, errlog_find_first, errlog_find_next, errlog_find_sequence, errlog_write, and errlog subroutines 获得:
实现例子如下:
#include <stdio.h>
#include <fcntl.h>
#include <sys/errlog.h>
int mode=0;
unsigned int magic;
errlog_handle_t errlog_va;
errlog_handle_t *hdl=&errlog_va;
int begintime=0710000007,endtime=0727000007;
/*MMDDHHMMYY (month, day, hour, minute, and year).*/
main()
{
magic=LE_MAGIC;
int rc;
rc=errlog_open(NULL,mode,magic,hdl);
if (rc==0)
{
printf("/nopen errlog sucessful!/n";
}
else
{
printf("/nopen errlog failed!/n";
}
extern int begintime, endtime;
errlog_match_t beginstamp, endstamp, andstamp;
errlog_match_t hardclass, softclass, orclass;
errlog_match_t andtop;
errlog_match_t *p=&andtop;
int ret;
errlog_entry_t result;
/* * Select begin and end times */
beginstamp.em_op = LE_OP_GT; /* Expression ¡¯A¡¯ */
beginstamp.em_field = LE_MATCH_TIMESTAMP;
beginstamp.em_intvalue=begintime;
endstamp.em_op = LE_OP_LT; /* Expression ¡¯B¡¯ */
endstamp.em_field = LE_MATCH_TIMESTAMP;
endstamp.em_intvalue=endtime;
andstamp.em_op = LE_OP_AND; /* ¡¯A¡¯ and ¡¯B¡¯ */
andstamp.em_left = &beginstamp;
andstamp.em_right = &endstamp; /* * Select the classes we¡¯re interested in. */
hardclass.em_op = LE_OP_EQUAL; /* Expression ¡¯C¡¯ */
hardclass.em_field = LE_MATCH_CLASS;
hardclass.em_strvalue = "H";
softclass.em_op = LE_OP_EQUAL; /* Expression ¡¯D¡¯ */
softclass.em_field = LE_MATCH_CLASS;
softclass.em_strvalue = "S";
orclass.em_op = LE_OP_OR; /* ¡¯C¡¯ or ¡¯D¡¯ */
orclass.em_left = &hardclass;
orclass.em_right = &softclass;
andtop.em_op = LE_OP_AND; /* (¡¯A¡¯ and ¡¯B¡¯ and (¡¯C¡¯ or ¡¯D¡¯ */
andtop.em_left = &andstamp;
andtop.em_right = &orclass;
int direction=LE_REVERSE;
rc=errlog_set_direction(hdl, direction);
if (rc==0)
{
printf("/ndirection errlog sucessful!/n";
}
else
{
printf("/ndirection errlog failed!/n";
}
ret = errlog_find_first(hdl,&andtop,&result);
if (ret==0)
{
printf("/nfind errlog sucessful!/n";
}
else
{
printf("/nfind errlog failed!/n";
}
if (LE_ERR_INVARG == ret)
printf("/n/n return LE_ERR_INVARG /n";
if (LE_ERR_NOMEM == ret)
printf("/n/n return LE_ERR_NOMEM /n";
if (LE_ERR_IO == ret)
printf("/n/n return LE_ERR_IO /n");
if (LE_ERR_DONE == ret)
printf("/n/n return LE_ERR_INVFILE /n");
}
链接程序时请使用 liberrlog.a 库