OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [snmp/] [lib/] [current/] [include/] [snmp_debug.h] - Blame information for rev 844

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      ./lib/current/include/snmp_debug.h
4
//
5
//
6
//==========================================================================
7
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
8
// -------------------------------------------                              
9
// This file is part of eCos, the Embedded Configurable Operating System.   
10
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
11
//
12
// eCos is free software; you can redistribute it and/or modify it under    
13
// the terms of the GNU General Public License as published by the Free     
14
// Software Foundation; either version 2 or (at your option) any later      
15
// version.                                                                 
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT      
18
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
20
// for more details.                                                        
21
//
22
// You should have received a copy of the GNU General Public License        
23
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
24
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
25
//
26
// As a special exception, if other files instantiate templates or use      
27
// macros or inline functions from this file, or you compile this file      
28
// and link it with other works to produce a work based on this file,       
29
// this file does not by itself cause the resulting work to be covered by   
30
// the GNU General Public License. However the source code for this file    
31
// must still be made available in accordance with section (3) of the GNU   
32
// General Public License v2.                                               
33
//
34
// This exception does not invalidate any other reasons why a work based    
35
// on this file might be covered by the GNU General Public License.         
36
// -------------------------------------------                              
37
// ####ECOSGPLCOPYRIGHTEND####                                              
38
//####UCDSNMPCOPYRIGHTBEGIN####
39
//
40
// -------------------------------------------
41
//
42
// Portions of this software may have been derived from the UCD-SNMP
43
// project,  <http://ucd-snmp.ucdavis.edu/>  from the University of
44
// California at Davis, which was originally based on the Carnegie Mellon
45
// University SNMP implementation.  Portions of this software are therefore
46
// covered by the appropriate copyright disclaimers included herein.
47
//
48
// The release used was version 4.1.2 of May 2000.  "ucd-snmp-4.1.2"
49
// -------------------------------------------
50
//
51
//####UCDSNMPCOPYRIGHTEND####
52
//==========================================================================
53
//#####DESCRIPTIONBEGIN####
54
//
55
// Author(s):    hmt
56
// Contributors: hmt
57
// Date:         2000-05-30
58
// Purpose:      Port of UCD-SNMP distribution to eCos.
59
// Description:  
60
//              
61
//
62
//####DESCRIPTIONEND####
63
//
64
//==========================================================================
65
/********************************************************************
66
       Copyright 1989, 1991, 1992 by Carnegie Mellon University
67
 
68
                          Derivative Work -
69
Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
70
 
71
                         All Rights Reserved
72
 
73
Permission to use, copy, modify and distribute this software and its
74
documentation for any purpose and without fee is hereby granted,
75
provided that the above copyright notice appears in all copies and
76
that both that copyright notice and this permission notice appear in
77
supporting documentation, and that the name of CMU and The Regents of
78
the University of California not be used in advertising or publicity
79
pertaining to distribution of the software without specific written
80
permission.
81
 
82
CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
83
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
84
WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL CMU OR
85
THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
86
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
87
FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
88
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
89
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
90
*********************************************************************/
91
#ifndef SNMP_DEBUG_H
92
#define SNMP_DEBUG_H
93
 
94
#ifdef __cplusplus
95
extern "C" {
96
#endif
97
 
98
/* snmp_debug.h:
99
 
100
   - prototypes for snmp debugging routines.
101
   - easy to use macros to wrap around the functions.  This also provides
102
     the ability to reove debugging code easily from the applications at
103
     compile time.
104
*/
105
 
106
 
107
/* These functions should not be used, if at all possible.  Instead, use
108
   the macros below. */
109
#if HAVE_STDARG_H
110
void debugmsg(const char *token, const char *format, ...);
111
void debugmsgtoken(const char *token, const char *format, ...);
112
#else
113
void debugmsg(va_alist);
114
void debugmsgtoken(va_alist);
115
#endif
116
void debugmsg_oid(const char *token, oid *theoid, size_t len);
117
void debugmsg_hex(const char *token, u_char *thedata, size_t len);
118
void debugmsg_hextli(const char *token, u_char *thedata, size_t len);
119
void debug_indent_add(int amount);
120
char *debug_indent(void);
121
 
122
/* Use these macros instead of the functions above to allow them to be
123
   re-defined at compile time to NOP for speed optimization.
124
 
125
   They need to be called enclosing all the arguments in a single set of ()s.
126
   Example:
127
      DEBUGMSGTL(("token", "debugging of something %s related\n", "snmp"));
128
 
129
Usage:
130
   All of the functions take a "token" argument that helps determine when
131
   the output in question should be printed.  See the snmpcmd.1 manual page
132
   on the -D flag to turn on/off output for a given token on the command line.
133
 
134
     DEBUGMSG((token, format, ...)):      equivelent to printf(format, ...)
135
                                          (if "token" debugging output
136
                                          is requested by the user)
137
 
138
     DEBUGMSGT((token, format, ...)):     equivelent to DEBUGMSG, but prints
139
                                          "token: " at the beginning of the
140
                                          line for you.
141
 
142
     DEBUGTRACE                           Insert this token anywhere you want
143
                                          tracing output displayed when the
144
                                          "trace" debugging token is selected.
145
 
146
     DEBUGMSGL((token, format, ...)):     equivelent to DEBUGMSG, but includes
147
                                          DEBUGTRACE debugging line just before
148
                                          yours.
149
 
150
     DEBUGMSGTL((token, format, ...)):    Same as DEBUGMSGL and DEBUGMSGT
151
                                          combined.
152
 
153
Important:
154
   It is considered best if you use DEBUGMSGTL() everywhere possible, as it
155
   gives the nicest format output and provides tracing support just before
156
   every debugging statement output.
157
 
158
To print multiple pieces to a single line in one call, use:
159
 
160
     DEBUGMSGTL(("token", "line part 1"));
161
     DEBUGMSG  (("token", " and part 2\n"));
162
 
163
   to get:
164
 
165
     token: line part 1 and part 2
166
 
167
   as debugging output.
168
*/
169
 
170
#ifndef SNMP_NO_DEBUGGING  /* make sure we're wanted */
171
 
172
/*
173
 * define two macros : one macro with, one without,
174
 *                     a test if debugging is enabled.
175
 *
176
 * Generally, use the macro with _DBG_IF_
177
 */
178
 
179
/******************* Start private macros ************************/
180
#define _DBG_IF_            snmp_get_do_debugging()
181
#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
182
 
183
#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
184
 
185
#ifdef  HAVE_CPP_UNDERBAR_FUNCTION_DEFINED
186
#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d\n",__FUNCTION__,\
187
                                 __FILE__,__LINE__))
188
#else
189
#define __DBGTRACE       __DBGMSGT(("trace"," %s, %d\n", __FILE__,__LINE__))
190
#endif
191
 
192
#define __DBGMSGL(x)     __DBGTRACE, debugmsg x
193
#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
194
#define __DBGMSGOID(x)     debugmsg_oid x
195
#define __DBGMSGHEX(x)     debugmsg_hex x
196
#define __DBGMSGHEXTLI(x)  debugmsg_hextli x
197
#define __DBGINDENT()      debug_indent()
198
#define __DBGINDENTADD(x)  debug_indent_add(x)
199
#define __DBGINDENTMORE()  debug_indent_add(2)
200
#define __DBGINDENTLESS()  debug_indent_add(-2)
201
#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%s", __DBGINDENT()))
202
 
203
#define __DBGDUMPHEADER(token,x) \
204
        __DBGPRINTINDENT(token), \
205
        debugmsg(token,x), \
206
        __DBGINDENTMORE()
207
 
208
#define __DBGDUMPSETUP(token,buf,len) \
209
        __DBGTRACE, \
210
        __DBGMSGHEXTLI((token,buf,len)), \
211
        debugmsg(token,"\n"), \
212
        __DBGPRINTINDENT(token)
213
 
214
/******************* End   private macros ************************/
215
/*****************************************************************/
216
 
217
/*****************************************************************/
218
/********************Start public  macros ************************/
219
 
220
#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
221
#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
222
#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
223
#define DEBUGMSGL(x)       do {if (_DBG_IF_) {__DBGMSGL(x);} }while(0)
224
#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
225
#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
226
#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
227
#define DEBUGMSGHEXTLI(x)  do {if (_DBG_IF_) {__DBGMSGHEXTLI(x);} }while(0)
228
#define DEBUGINDENT()      do {if (_DBG_IF_) {__DBGINDENT();} }while(0)
229
#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
230
#define DEBUGINDENTMORE()  do {if (_DBG_IF_) {__DBGINDENTMORE();} }while(0)
231
#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
232
#define DEBUGPRINTINDENT(token) \
233
        do {if (_DBG_IF_) {__DBGPRINTINDENT(token);} }while(0)
234
 
235
 
236
#define DEBUGDUMPHEADER(token,x) \
237
        do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
238
 
239
#define DEBUGDUMPSETUP(token,buf,len) \
240
        do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
241
 
242
#else /* SNMP_NO_DEBUGGING := enable streamlining of the code */
243
 
244
#define DEBUGMSG(x)
245
#define DEBUGMSGT(x)
246
#define DEBUGTRACE
247
#define DEBUGMSGL(x)
248
#define DEBUGMSGTL(x)
249
#define DEBUGMSGOID(x)
250
#define DEBUGMSGHEX(x)
251
#define DEBUGIF(x)        if(0)
252
#define DEBUGDUMP(t,b,l,p)
253
#define DEBUGINDENT()
254
#define DEBUGINDENTMORE()
255
#define DEBUGINDENTLESS()
256
#define DEBUGINDENTADD(x)
257
#define DEBUGMSGHEXTLI(x)
258
#define DEBUGPRINTINDENT(token)
259
#define DEBUGDUMPHEADER(token,x)
260
#define DEBUGDUMPSETUP(token, buf, len)
261
 
262
#endif
263
 
264
#define MAX_DEBUG_TOKENS 256
265
#define MAX_DEBUG_TOKEN_LEN 128
266
#define DEBUG_TOKEN_DELIMITER ","
267
#define DEBUG_ALWAYS_TOKEN "all"
268
 
269
/*
270
  setup routines:
271
 
272
  debug_register_tokens(char *):     registers a list of tokens to
273
                                     print debugging output for.
274
 
275
  debug_is_token_registered(char *): returns SNMPERR_SUCCESS or SNMPERR_GENERR
276
                                     if a token has been registered or
277
                                     not (and debugging output is "on").
278
  snmp_debug_init(void):             registers .conf handlers.
279
*/
280
void debug_register_tokens(char *tokens);
281
int debug_is_token_registered(const char *token);
282
void snmp_debug_init(void);
283
 
284
/* provided for backwards compatability.  Don't use these functions. */
285
#if HAVE_STDARG_H
286
void DEBUGP (const char *, ...);
287
#else
288
void DEBUGP (va_alist);
289
#endif
290
void DEBUGPOID(oid *, size_t);
291
void snmp_set_do_debugging (int);
292
int snmp_get_do_debugging (void);
293
int debug_is_token_registered(const char *token);
294
 
295
#ifdef __cplusplus
296
}
297
#endif
298
 
299
#endif /* SNMP_DEBUG_H */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.