[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Communications Programming Concepts

SMUX Error Logging Subroutines Examples

The advise and adios subroutines are example subroutines created to illustrate how the SNMP multiplexing (SMUX) _ll_log logging subroutine can be used. The adios and advise sample subroutines are in the unixd.c and sampled.c sample programs.

The adios subroutine exits on a fatal error. This subroutine sends a fatal message to the log file and exits. If needed, other functionality can be added to the subroutine to help the failing program exit cleanly.

The advise subroutine sends an advisory message to the log. This subroutine allows the programmer to specify the message logging event type.

adios Sample Subroutine

/* Function: adios
*
* Inputs: 
* what - the thing that went wrong
* fmt - the string to be printed in printf format (char*)
* variables - variable needed to fill in the fmt.
*
* Outputs: none
* Returns: none
*
* NOTE: The adios function calls the logging function with the  
* variables above and a LLOG_FATAL error code. The function then
* exits with a return code of 1, thereby terminating the sampled
* process.
*/
#ifndef lint
void    adios (va_list)
va_dcl
{
   va_list ap;
   va_start (ap);
   _ll_log (pgm_log, LLOG_FATAL, ap); /*Prints to the log*/
                                  /*specified by pgm_log.a*/
                                  /* Fatal error         */
   va_end (ap);
   _exit (1);
}
#else
/*  VARAGS  */
void adios (what,fmt)
char *what,
     *fmt;
{
   adios (what, fmt);
}
#endif

advise Sample Subroutine

/* Function: advise
*
* Inputs:
* code - the logging level to associate with this error (int) 
* what - the thing that went wrong
* fmt - the string to be printed in printf format (char*)
* variables - variable needed to fill in the fmt.
*
* Outputs: none
* Returns: none
*
* NOTE: The advise function calls the logging function with the  
* variables above. This is a usability front end to the logging 
* functions.
*/
#ifndef lint
void    advise (va_list)
va_dcl
{
   int code;
   va_list ap;
   va_start (ap);
   code = va_arg (ap, int);  /*Gets the code variable */ 
                             /* from the list of parameters */ 
   _ll_log (pgm_log, code, ap);
   va_end (ap);
}
#else
/*  VARAGS  */
void advise (code, what, fmt)
char *what,
     *fmt;
int   code;
{
   advise (code, what, fmt);
}
#endif

[ Previous | Next | Contents | Glossary | Home | Search ]