- 论坛徽章:
- 0
|
环境:AIX V5.2
compile:IBM VAC enterprise V7.0
程序代码:
root@zhguowen_sv:/asmdev/asm#cat errlog_find.c
#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");
}
执行结果:
root@zhguowen_sv:/asmdev/asm#xlc errlog_find.c /usr/lib/liberrlog.a
root@zhguowen_sv:/asmdev/asm#./a.out
open errlog sucessful!
direction errlog sucessful!
find errlog failed!
return LE_ERR_IO
root@zhguowen_sv:/asmdev/asm#
问题:
此段程序的大部门代码摘自《Technical Reference: Base Operating System and Extensions, Volume 1》,少部分由自己编写。关于errlog_open errlog_find_first API见此书P212页。
程序运行返回错误代码 LE_ERR_IO 书上解释是An i/o error occurred.
因资料有限,请教这样的错误应当如何解决?或者是否有其它相关资料可以查询?
多谢!
[ 本帖最后由 zhguowen 于 2007-7-31 09:53 编辑 ] |
|