日期:2014-05-16  浏览次数:20768 次

谁能一起来分析一下这个API

errlog_open   Subroutine   (摘自AIX5.2 Technical   Reference:   Base   Operating   System   and   Extensions,   Volume   1)

Purpose
  Opens   an   error   log   and   returns   a   handle   for   use   with   other   liberrlog.a   functions.  

Syntax
  library   liberrlog.a  
  #include   <fcntl.h>  
  #include   <sys/errlog.h>  
  int   errlog_open(path,   mode,   magic,   handle)  
  char   *path;   int   mode;   unsigned   int   magic;  
  errlog_handle_t   *handle;  

Description  

The   error   log   specified   by   the   path   argument   will   be   opened   using   mode.   The   handle   pointed   to   by   the   handle   parameter   must   be   used   with   subsequent   operations.  

Parameters  

The   path   parameter   specifies   the   path   to   the   log   file   to   be   opened.   If   path   is   NULL,   the   default   errlog   file   will   be   opened.   The   valid   values   for   mode   are   the   same   as   they   are   for   the   open   system   subroutine.   They   can   be   found   in   the   fcntl.h   files.   The   magic   argument   takes   the   LE_MAGIC   value,   indicating   which   version   of   the   errlog_entry_t   structure   this   application   was   compiled   with.  

Return   Values  
Upon   successful   completion,   the   errlog_open   subroutine   returns   a   0   and   sets   the   memory   pointed   to   by   handle   to   a   handle   used   by   subsequent   liberrlog   operations.  

Upon   error,   the   errlog_open   subroutine   returns   one   of   the   following:
LE_ERR_INVARG           A   parameter   error   was   detected.
LE_ERR_NOFILE           The   log   file   does   not   exist.  
LE_ERR_NOMEM             Memory   could   not   be   allocated.
LE_ERR_IO                   An   i/o   error   occurred.
LE_ERR_INVFILE         The   file   is   not   a   valid   error   log.


我在开发一个监控AIX   system   error   log的程序,虽然用shell更简单一些,但我必须用C来实现它。上面这个API就是用来打开system   error   log的系统调用,在程序中这个系统调用返回值为1,请问我如何判断错误返回类型是:LE_ERR_INVARG     LE_ERR_NOFILE   LE_ERR_NOMEM     LE_ERR_IO     LE_ERR_INVFILE中的哪一种?

以下是我的程序代码及运行输出,请帮忙查看我的程序和方法是否有错误?(共两个问题)
asm@zhguowen_sv:/asmdev/asm$vi   errlog_op.c
"errlog_op.c "   30   lines,   509   characters
#include   <stdio.h>
#include   <fcntl.h>
#include   <sys/errlog.h>
#include &n