compile:IBM VAC enterprise V7.0
programe code:
root@zhguowen_sv:/asmdev/asm#cat errlog_find.c
Code:
#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");
}
execute result£º
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#
-------------------------------------------------------------------------------------
Problem:
errlog_open,errlog_directory and errlog_find_first subroutine come from the book of Technical Reference: Base Operating System and Extensions, Volume 1.
1.Return error code:LE_ERR_IO, means An i/o error occurred. How to solve this question?
2.Are there any other book to explain errlog subroutine? It has too little infomation in Technical Reference: Base Operating System and Extensions, Volume 1.
3.My mail address:zhguowen0103@hotmail.com
Thanks alot!
