aug_debug.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * $Id$
  3. *
  4. * POSTGRES module, portions of this code were templated using
  5. * the mysql module, thus it's similarity.
  6. *
  7. *
  8. * Copyright (C) 2003 August.Net Services, LLC
  9. *
  10. * This file is part of ser, a free SIP server.
  11. *
  12. * ser is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version
  16. *
  17. * For a license to use the ser software under conditions
  18. * other than those described here, or to purchase support for this
  19. * software, please contact iptel.org by e-mail at the following addresses:
  20. * [email protected]
  21. *
  22. * ser is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  30. *
  31. * ---
  32. *
  33. * History
  34. * -------
  35. * 2003-04-06 initial code written (Greg Fausak/Andy Fullford)
  36. *
  37. */
  38. /*
  39. ** ________________________________________________________________________
  40. **
  41. **
  42. ** $RCSfile$
  43. ** $Revision$
  44. **
  45. ** Last change $Date$
  46. ** Last change $Author$
  47. ** $State$
  48. ** $Locker$
  49. **
  50. ** Original author: Andrew Fullford
  51. **
  52. ** Copyright (C) August Associates 1995
  53. **
  54. ** ________________________________________________________________________
  55. */
  56. /* AM_TYPE: (INSTALL_INC) */
  57. #ifndef AUG_DEBUG_H
  58. #define AUG_DEBUG_H
  59. #ifdef DEBUG
  60. #define augDAB_DEBUG augTRUE
  61. #ifdef __FILE__
  62. #define augDAB__FILE__ __FILE__
  63. #else
  64. #define augDAB__FILE__ ""
  65. #endif
  66. #ifdef __LINE__
  67. #define augDAB__LINE__ __LINE__
  68. #else
  69. #define augDAB__LINE__ 0
  70. #endif
  71. #else
  72. #define augDAB_DEBUG augFALSE
  73. #define augDAB__FILE__ ""
  74. #define augDAB__LINE__ 0
  75. #endif /* DEBUG */
  76. /*
  77. ** Debugging levels.
  78. **
  79. ** Each function is tagged with a debugging level. The initial
  80. ** state is ``don't know'' which will trigger a match, a relatively
  81. ** slow operation. The result of the match is recorded so future
  82. ** accesses will occur at integer test instruction speed.
  83. */
  84. #define DAB_UNKNOWN -1 /* Need to perform match */
  85. #define DAB_OFF 0 /* Matched, but debugs disabled */
  86. #define DAB_TRACE 25 /* Level implied by DABTRACE() macro */
  87. #define DAB_STD 50 /* Level implied by DAB() macro */
  88. #define DAB_BULK 75 /* Level implied by DABBULK() macro */
  89. #if augDAB_DEBUG == augTRUE
  90. #define DABNAME(name) static char *aug_dab_func=name, \
  91. aug_dab_file[]=augDAB__FILE__; \
  92. static short aug_dab_level=DAB_UNKNOWN, aug_dab_dummy
  93. #define DABLEVEL(lev) \
  94. (aug_dab_enabled && \
  95. ((aug_dab_level == DAB_UNKNOWN && \
  96. aug_dab_match(aug_dab_func,aug_dab_file, \
  97. augDAB__LINE__,&aug_dab_level) >= (lev)) || \
  98. aug_dab_level >= (lev)) && \
  99. aug_dab_pushinfo(aug_dab_func,aug_dab_file,augDAB__LINE__))
  100. #define DABL(lev) aug_dab_dummy = DABLEVEL(lev) && aug_dab_fmt
  101. #define DAB DABL(DAB_STD)
  102. #define DABTRACE DABL(DAB_TRACE)
  103. #define DABBULK DABL(DAB_BULK)
  104. #define DABTEXT aug_dab_text
  105. #define DABDUMP aug_dab_dump
  106. #define DABSET(line) aug_dab_set(line)
  107. #define DABRESET() aug_dab_reset()
  108. #define DABLOAD(file) aug_dab_load(file)
  109. extern augBool aug_dab_enabled;
  110. #else
  111. #define DABNAME(name)
  112. #define DABLEVEL(lev) (augFALSE)
  113. #define DABL(lev) (augFALSE) &&
  114. #define DAB DABL(0)
  115. #define DABTRACE DABL(0)
  116. #define DABBULK DABL(0)
  117. #define DABTEXT DABL(0)
  118. #define DABDUMP DABL(0)
  119. #define DABSET(line)
  120. #define DABRESET()
  121. #define DABLOAD(file)
  122. #endif /* augDAB_DEBUG */
  123. extern int aug_dab_match(char *func, char *file, int line, short *plevel);
  124. extern augBool aug_dab_pushinfo(char *func, char *file, int line);
  125. extern augBool aug_dab_fmt(char *fmt, ...);
  126. extern void aug_dab_text(char *text);
  127. extern void aug_dab_dump(char *data, int size);
  128. extern void aug_dab_reset(void);
  129. extern augBool aug_dab_set(char *line);
  130. extern void aug_dab_load(char *file);
  131. #endif /* AUG_DEBUG_H */