net-snmp 5.7
output_api.h
00001 #ifndef NET_SNMP_OUTPUT_API_H
00002 #define NET_SNMP_OUTPUT_API_H
00003 
00009 #include <net-snmp/types.h>
00010 #include <stdarg.h>     /* for va_list */
00011 
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015 
00016     /* Error reporting */
00017     NETSNMP_IMPORT
00018     void    snmp_error(netsnmp_session *sess, int *clib_errorno,
00019                            int *snmp_errorno, char **errstring);
00020     NETSNMP_IMPORT
00021     void    snmp_sess_error(      void *sess, int *clib_errorno,
00022                            int *snmp_errorno, char **errstring);
00023 
00024     NETSNMP_IMPORT
00025     const char *snmp_api_errstring(int snmp_errorno);  /*  library errors */
00026     NETSNMP_IMPORT
00027     const char     *snmp_errstring(int snmp_errorno);  /* protocol errors */
00028 
00029     NETSNMP_IMPORT
00030     void    snmp_perror(const char *msg);   /* for parsing errors only */
00031 
00032     NETSNMP_IMPORT
00033     void    snmp_sess_perror(const char *msg, netsnmp_session *sess);
00034                                        /* for all other SNMP library errors */
00035     NETSNMP_IMPORT
00036     void    snmp_log_perror(const char *msg);
00037                                        /* for system library errors */
00038 
00039     /* Logging messages */
00040 
00041 #if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
00042 #define _LOG_ATTR
00043 #else
00044 #define _LOG_ATTR   __attribute__ ((__format__ (__printf__, 2, 3)))
00045 #endif
00046 
00047     NETSNMP_IMPORT
00048     int  snmp_log( int priority, const char *format, ...) _LOG_ATTR;
00049     NETSNMP_IMPORT
00050     int  snmp_vlog(int priority, const char *format, va_list ap);
00051     NETSNMP_IMPORT
00052     int  snmp_get_do_logging(    void);
00053     NETSNMP_IMPORT
00054     void netsnmp_logging_restart(void);
00055     NETSNMP_IMPORT
00056     void snmp_disable_log(       void);
00057     NETSNMP_IMPORT
00058     void shutdown_snmp_logging(  void);
00059 
00060 #undef _LOG_ATTR
00061 
00062     /* Debug messages */
00063 #ifndef NETSNMP_NO_DEBUGGING
00064 #include <net-snmp/library/snmp_debug.h>        /* for internal macros */
00065 #define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
00066 #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
00067 #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
00068 #define DEBUGTRACETOK(x)   do {if (_DBG_IF_) {__DBGTRACETOK(x);} }while(0)
00069 #define DEBUGMSGL(x)       do {if (_DBG_IF_) {__DBGMSGL(x);} }while(0)
00070 #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
00071 #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
00072 #define DEBUGMSGSUBOID(x)  do {if (_DBG_IF_) {__DBGMSGSUBOID(x);} }while(0)
00073 #define DEBUGMSGVAR(x)     do {if (_DBG_IF_) {__DBGMSGVAR(x);} }while(0)
00074 #define DEBUGMSGOIDRANGE(x) do {if (_DBG_IF_) {__DBGMSGOIDRANGE(x);} }while(0)
00075 #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
00076 #define DEBUGMSGHEXTLI(x)  do {if (_DBG_IF_) {__DBGMSGHEXTLI(x);} }while(0)
00077 #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
00078 #define DEBUGINDENTMORE()  do {if (_DBG_IF_) {__DBGINDENTMORE();} }while(0)
00079 #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
00080 #define DEBUGPRINTINDENT(token) \
00081         do {if (_DBG_IF_) {__DBGPRINTINDENT(token);} }while(0)
00082 #define DEBUGDUMPHEADER(token,x) \
00083         do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
00084 #define DEBUGDUMPSECTION(token,x) \
00085         do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
00086 #define DEBUGDUMPSETUP(token,buf,len) \
00087         do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
00088 #define DEBUGMSG_NC(x)  do { __DBGMSG_NC(x); }while(0)
00089 #define DEBUGMSGT_NC(x) do { __DBGMSGT_NC(x); }while(0)
00090 
00091 #else        /* NETSNMP_NO_DEBUGGING := enable streamlining of the code */
00092 
00093 #define DEBUGMSG(x)
00094 #define DEBUGMSGT(x)
00095 #define DEBUGTRACE
00096 #define DEBUGTRACETOK(x)
00097 #define DEBUGMSGL(x)
00098 #define DEBUGMSGTL(x)
00099 #define DEBUGMSGOID(x)
00100 #define DEBUGMSGSUBOID(x)
00101 #define DEBUGMSGVAR(x)
00102 #define DEBUGMSGOIDRANGE(x)
00103 #define DEBUGMSGHEX(x)
00104 #define DEBUGIF(x)        if(0)
00105 #define DEBUGDUMP(t,b,l,p)
00106 #define DEBUGINDENTMORE()
00107 #define DEBUGINDENTLESS()
00108 #define DEBUGINDENTADD(x)
00109 #define DEBUGMSGHEXTLI(x)
00110 #define DEBUGPRINTINDENT(token)
00111 #define DEBUGDUMPHEADER(token,x)
00112 #define DEBUGDUMPSECTION(token,x)
00113 #define DEBUGDUMPSETUP(token, buf, len)
00114 
00115 #define DEBUGMSG_NC(x)
00116 #define DEBUGMSGT_NC(x)
00117 
00118 #endif    /* NETSNMP_NO_DEBUGGING */
00119 
00120     NETSNMP_IMPORT
00121     void            debug_register_tokens(const char *tokens);
00122     NETSNMP_IMPORT
00123     int             debug_is_token_registered(const char *token);
00124     NETSNMP_IMPORT
00125     void            snmp_set_do_debugging(int);
00126     NETSNMP_IMPORT
00127     int             snmp_get_do_debugging(void);
00128 
00129     /*
00130      *    Having extracted the main ("public API") calls relevant
00131      *  to this area of the Net-SNMP project, the next step is to
00132      *  identify the related "public internal API" routines.
00133      *
00134      *    In due course, these should probably be gathered
00135      *  together into a companion 'library/output_api.h' header file.
00136      *  [Or some suitable name]
00137      *
00138      *    But for the time being, the expectation is that the
00139      *  traditional headers that provided the above definitions
00140      *  will probably also cover the relevant internal API calls.
00141      *  Hence they are listed here:
00142      */
00143 
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147 
00148 #include <net-snmp/library/snmp_api.h>
00149 #include <net-snmp/library/snmp_client.h>
00150 #include <net-snmp/library/snmp_debug.h>
00151 #include <net-snmp/library/snmp_logging.h>
00152 
00153 #ifndef ERROR_MSG
00154 #define ERROR_MSG(string)       snmp_set_detail(string)
00155 #endif
00156 
00157 #endif                          /* NET_SNMP_OUTPUT_API_H */