File er/er.c

  $Revision: 1.30 $

Error reporting (er) er.c - library of functions to uniformly report errors.
Status: NOT REVUED, PARTLY TESTED
NOTE: MALLOC ALERT!!! THE REPORTING FUNCTIONS MAY NOT USE DYNAMIC MEMORY!!! for one: they wouldn't work if we run out of memory... for two: the memory wrappers may have logging enabled, and it would loop.
Design and implementation by: Marek Bukowy
References Variables: AC_mod_errer/er.c
  ER_mod_errer/er.c
  IP_mod_errer/er.c
  MM_mod_errer/er.c
  PA_mod_errer/er.c
  PC_mod_errer/er.c
  PM_mod_errer/er.c
  PW_mod_errer/er.c
  QC_mod_errer/er.c
  QI_mod_errer/er.c
  RP_mod_errer/er.c
  RX_mod_errer/er.c
  SK_mod_errer/er.c
  SQ_mod_errer/er.c
  SV_mod_errer/er.c
  TH_mod_errer/er.c
  UD_mod_errer/er.c
  UP_mod_errer/er.c
  UT_mod_errer/er.c
  WH_mod_errer/er.c

Included Files


Preprocessor definitions

#define ER_IMPL

Fork & exec a program specified with argv, the print msg on its stdin and exit. No redirection of stdout/stderr is done.
MT-note: Solaris fork1() duplicates only the calling thread. So does Posix fork().
char **argv argv array for the exec call
char *msg text payload to be printed on the stdin of forked process
int usepath flag indicating if the PATH environmental variable should be used by the exec call.

#define PIP_WR 1

#define PIP_RD 0

#define fork1 fork


Global Variable er_pathtypes

char* er_pathtypes[]
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c

Global Variable RX_mod_err

er_list_t RX_mod_err[]
Included from /home/shane/release/RIP/include/er_RX_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable ER_mod_err

er_list_t ER_mod_err[]
Included from /home/shane/release/RIP/include/er_ER_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable IP_mod_err

er_list_t IP_mod_err[]
Included from /home/shane/release/RIP/include/er_IP_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable UP_mod_err

er_list_t UP_mod_err[]
Included from /home/shane/release/RIP/include/er_UP_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable UT_mod_err

er_list_t UT_mod_err[]
Included from /home/shane/release/RIP/include/er_UT_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable WH_mod_err

er_list_t WH_mod_err[]
Included from /home/shane/release/RIP/include/er_WH_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable RP_mod_err

er_list_t RP_mod_err[]
Included from /home/shane/release/RIP/include/er_RP_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable QI_mod_err

er_list_t QI_mod_err[]
Included from /home/shane/release/RIP/include/er_QI_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable QC_mod_err

er_list_t QC_mod_err[]
Included from /home/shane/release/RIP/include/er_QC_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable PW_mod_err

er_list_t PW_mod_err[]
Included from /home/shane/release/RIP/include/er_PW_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable SK_mod_err

er_list_t SK_mod_err[]
Included from /home/shane/release/RIP/include/er_SK_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable TH_mod_err

er_list_t TH_mod_err[]
Included from /home/shane/release/RIP/include/er_TH_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable SQ_mod_err

er_list_t SQ_mod_err[]
Included from /home/shane/release/RIP/include/er_SQ_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable PM_mod_err

er_list_t PM_mod_err[]
Included from /home/shane/release/RIP/include/er_PM_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable MM_mod_err

er_list_t MM_mod_err[]
Included from /home/shane/release/RIP/include/er_MM_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable SV_mod_err

er_list_t SV_mod_err[]
Included from /home/shane/release/RIP/include/er_SV_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable AC_mod_err

er_list_t AC_mod_err[]
Included from /home/shane/release/RIP/include/er_AC_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable UD_mod_err

er_list_t UD_mod_err[]
Included from /home/shane/release/RIP/include/er_UD_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable PA_mod_err

er_list_t PA_mod_err[]
Included from /home/shane/release/RIP/include/er_PA_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable PC_mod_err

er_list_t PC_mod_err[]
Included from /home/shane/release/RIP/include/er_PC_errors.h
Visible in:  er/er.c
Used in:  er/er.c

Global Variable er_fac_err

er_fac_t er_fac_err[]
Included from /home/shane/release/RIP/include/er_facilities.h
Visible in:  er/er.c
Used in: er_format_line()er/er.c

Global Variable er_asparr

er_aspstr_t er_asparr[]
Included from /home/shane/release/RIP/include/er_aspects.h
Visible in:  er/er.c

Global Variable er_formarr

er_form_el er_formarr[]
Included from /home/shane/release/RIP/include/er_formats.h
Visible in:  er/er.c

Global Variable er_level_a

er_level_t er_level_a[]
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c

Global Variable er_pathlist

GList* er_pathlist
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c
Used in: er_logit()er/er.c

Global Variable er_asparray

er_mask_t er_asparray[FAC_LAST]
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c
Used in: ER_is_traced()er/er.c

Global Variable er_paths_lock

rw_lock_t er_paths_lock
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c
Used in: ER_init()er/er.c
  ER_is_traced()er/er.c
  er_logit()er/er.c

Global Variable er_macro_hash

GHashTable* er_macro_hash
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c
Used in: ER_init()er/er.c

Global Variable er_progname

char er_progname[32]
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c
Used in: ER_init()er/er.c
  er_format_line()er/er.c

Global Variable er_pid

char er_pid[16]
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c
Used in: ER_init()er/er.c
  er_format_line()er/er.c

Global Variable er_pathlist_mutex

pthread_mutex_t er_pathlist_mutex
Included from /home/shane/release/RIP/include/erroutines.h
Visible in:  er/er.c

Global Variable Lock

pthread_mutex_t Lock
Included from /home/shane/release/RIP/include/ca_defs.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
Used in: ca_get_adminIntElement()ca/ca_configFns.c
  ca_get_adminStrElement()ca/ca_configFns.c
  ca_get_boolean()ca/ca_configFns.c
  ca_get_dirlist()ca/ca_configFns.c
  ca_get_int()ca/ca_configFns.c
  ca_get_string()ca/ca_configFns.c
  ca_set_boolean()ca/ca_configFns.c
  ca_srchandle2Intelement()ca/ca_configFns.c
  ca_srchandle2Strelement()ca/ca_configFns.c

Global Function ER_dbg_va()

  Entry point for debug/trace messages - this function will display a
  message tagged with the DEBUG severity.

int sev severity of the message
void ER_dbg_va ( er_fac_code_t facwhere, er_mask_t asp, char* txt, ... )
er_fac_code_t facwhere
code of facility from which the error is reported
er_mask_t asp
aspect of the message
char* txt
printf-style format
...
printf-style arguments, if any
Prototyped in: /home/shane/release/RIP/include/erroutines.h
Calls: ER_is_traced()er/er.c
  er_getmsg_parts()er/er.c
  er_logit()er/er.c
  __builtin_next_arg(), __builtin_saveregs()
Called by: AC_decay()ac/access_control.c
  AC_prune()ac/access_control.c

Global Function ER_inf_va()

  Entry point for informational messages - this function will display a
  message tagged with the INFO severity.

int sev severity of the message
void ER_inf_va ( er_fac_code_t facwhere, er_mask_t asp, char* txt, ... )
er_fac_code_t facwhere
code of facility from which the error is reported
er_mask_t asp
aspect of the message
char* txt
printf-style format
...
printf-style arguments, if any
Prototyped in: /home/shane/release/RIP/include/erroutines.h
Calls: er_asp_va()er/er.c
  __builtin_next_arg(), __builtin_saveregs()
Called by: AC_ban_set()ac/access_control.c

Global Function ER_init()

  Initialisation function - setting global variables.
  Can be done only by the master thread 
void ER_init ( char* progname, int processdefs )
char* progname
program name to be used in the log entries
int processdefs
flag if the error definitions of the CA config file should be processed.
Prototyped in: /home/shane/release/RIP/include/erroutines.h
Calls: ER_macro_predef(), ER_proc_ca_err(), ER_proc_ca_macro(), TH_init_read_write_lock(), g_hash_table_new(), getpid(), snprintf(), strncpy()
References Functions: g_str_equal(), g_str_hash()
References Variables: er_macro_hasher/er.c
  er_paths_locker/er.c
  er_pider/er.c
  er_prognameer/er.c

Global Function ER_is_errorlogged()

int ER_is_errorlogged ( er_fac_code_t facwhere, int errcode )
Called by: ER_perror()er/er.c

Global Function ER_is_traced()

int ER_is_traced ( er_fac_code_t facwhere, er_mask_t asp )
Prototyped in: /home/shane/release/RIP/include/erroutines.h
Calls: TH_acquire_read_lock(), TH_release_read_lock()
Called by: ER_dbg_va()er/er.c
References Variables: er_asparrayer/er.c
  er_paths_locker/er.c

Global Function ER_perror()

  Entry point for predefined errors - this function will display a
  predefined message for this error along with additional text.
void ER_perror ( er_fac_code_t facwhere, int errcode, char* format, ... )
er_fac_code_t facwhere
code of facility from which the error is reported
int errcode
error code
char* format
printf-style format for additional text, or ""
...
printf-style arguments, if any
Prototyped in: /home/shane/release/RIP/include/erroutines.h
Calls: ER_is_errorlogged()er/er.c
  er_getmsg_parts()er/er.c
  er_logit()er/er.c
  __builtin_next_arg(), __builtin_saveregs()
Called by: AC_findcreate_account_l()ac/access_control.c
  AC_persistence_load()ac/ac_persistence.c
  AC_persistence_walk_l()ac/ac_persistence.c
  ep_GetPasswords()ep/mail_parser.c

Global Function NOERR()

  Simple check if the error code is a success (severity = 0).
  Detects (some) invalid codes - those whose facility part is 0.
int NOERR ( er_ret_t a )
int NOERR
returns 1 if the code is valid and is a success returns 0 if the code is invalid or is a real error (the severity is non-zero).
er_ret_t a
error code to be checked.
Prototyped in: /home/shane/release/RIP/include/erroutines.h
Called by: AC_asc_acl_command_set()ac/access_control.c
  AC_asc_all_set()ac/access_control.c
  AC_asc_ban_set()ac/access_control.c
  AC_asc_set_nodeny()ac/access_control.c
  AC_ban_set()ac/access_control.c
  AC_commit()ac/access_control.c
  AC_commit_credit_l()ac/access_control.c
  AC_findcreate_acl_l()ac/access_control.c
  AC_prune()ac/access_control.c

Global Function er_forkexec()

  Fork & exec a program specified with argv, the print msg
  on its stdin and exit. No redirection of stdout/stderr is done.

MT-note: Solaris fork1() duplicates only the calling thread. So does Posix fork().
void er_forkexec ( char** argv, char* msg, int usepath )
char** argv
argv array for the exec call
char* msg
text payload to be printed on the stdin of forked process
int usepath
flag indicating if the PATH environmental variable should be used by the exec call.
Calls: dup2(), execv(), execvp(), exit(), fdwrap_close(), fork(), perror(), pipe(), strlen(), wait(), write()
Called by: er_logtopath()er/er.c

Global Function er_format_line()

char* er_format_line ( char* erbuf, er_fac_code_t facwhere, er_mask_t asp, int mode, int errcode, char* tmbuf )
Calls: __eprintf(), er_getfacsym(), er_getsevsym(), pthread_self(), snprintf(), sprintf()
Called by: er_logit()er/er.c
References Variables: er_fac_errer/er.c
  er_pider/er.c
  er_prognameer/er.c

Global Function er_get_printmode()

int er_get_printmode ( er_path_t* pathstruct )

Global Function er_getmsg_parts()

  Internal message construction. Message parts are gathered according to the
  specified format bitmask. The resulting message consisting of those parts
  as well as the printf-style constructed message text itself is printed into 
  the given buffer.
void er_getmsg_parts ( char* buf, unsigned buflen, char* fmttxt, va_list args )
char* buf
pointer to the predefined buffer
unsigned buflen
buffer length
char* fmttxt
printf-style format
va_list args
printf-style arguments, if any
Calls: vsnprintf()
Called by: ER_dbg_va()er/er.c
  ER_perror()er/er.c
  er_asp_va()er/er.c

Global Function er_logit()

  Browses the list of available paths, runs the filter check on every
  path and logs the given message to all suitable paths.
void er_logit ( er_fac_code_t facwhere, er_mask_t asp, int errcode, char* msg )
er_fac_code_t facwhere
message's facility of call
er_mask_t asp
message's aspect (if severity is INFO or DEBUG)
int errcode
message's error code
char* msg
text payload of the message
Calls: er_format_line()er/er.c
  er_logtopath()er/er.c
  er_msgsel()er/er.c
  TH_acquire_read_lock(), TH_release_read_lock(), g_list_first(), gettimeofday(), localtime_r(), strftime()
Called by: ER_dbg_va()er/er.c
  ER_perror()er/er.c
  er_asp_va()er/er.c
References Variables: er_pathlister/er.c
  er_paths_locker/er.c

Global Function er_msgsel()

  Message selection routine. Checks if the message coming from the
  current thread, tagged with the given error code, facility and
  aspect matches the given filter.
int er_msgsel ( er_filter_t* filtptr, er_fac_code_t facwhere, er_mask_t asp, er_ret_t errcode )
int er_msgsel
returns 1 for a match, 0 otherwise.
er_filter_t* filtptr
filter to be matched
er_fac_code_t facwhere
message's facility of call
er_mask_t asp
message's aspect (if severity is INFO or DEBUG)
er_ret_t errcode
message's error code
Calls: MA_isset(), pthread_self()
Called by: er_logit()er/er.c

Local Function asctime_r()

static char* asctime_r ( const struct tm* __tm, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_asctime_r()

Local Function ctime_r()

static char* ctime_r ( const time_t* __time, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_ctime_r()

Local Function er_asp_va()

  Internal function for message collection.
static void er_asp_va ( er_fac_code_t facwhere, int sev, er_mask_t asp, char* txt, va_list args )
er_fac_code_t facwhere
code of facility from which the error is reported
int sev
severity of the message
er_mask_t asp
aspect of the message
char* txt
printf-style format
va_list args
printf-style arguments, if any
Calls: er_getmsg_parts()er/er.c
  er_logit()er/er.c
Called by: ER_inf_va()er/er.c

Local Function er_logtopath()

  Main function logging a message to a path. The formatted message
  parts and the message text itself are given separately to avoid
  wasting time to remake them, because the message text may be the
  same while the path formats are different.
static void er_logtopath ( er_path_t* pathptr, char* form, char* msg )
er_path_t* pathptr
pointer to the path structure where the message should go.
char* form
format part of the message
char* msg
payload part of the message
Calls: er_forkexec()er/er.c
  fdwrap_close(), fprintf(), gettimeofday(), localtime_r(), open(), perror(), strcat(), strcpy(), strftime(), strlen(), write()
Called by: er_logit()er/er.c

Local Function getlogin_r()

static int getlogin_r ( char* __name, int __len )
Included from: /usr/include/unistd.h
Calls: __posix_getlogin_r()

Local Function readdir_r()

static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
Included from: /usr/include/dirent.h
Calls: __posix_readdir_r()

Local Function sigwait()

static int sigwait ( const sigset_t* __setp, int* __signo )
Included from: /usr/include/signal.h
Calls: __posix_sigwait()

Local Function ttyname_r()

static int ttyname_r ( int __fildes, char* __buf, size_t __size )
Included from: /usr/include/unistd.h
Calls: __posix_ttyname_r()