home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / isc / assertions.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-09-17  |  3.1 KB  |  124 lines

  1. /*
  2.  * Copyright (C) 2004, 2005  Internet Systems Consortium, Inc. ("ISC")
  3.  * Copyright (C) 1997-2001  Internet Software Consortium.
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software for any
  6.  * purpose with or without fee is hereby granted, provided that the above
  7.  * copyright notice and this permission notice appear in all copies.
  8.  *
  9.  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10.  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11.  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12.  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15.  * PERFORMANCE OF THIS SOFTWARE.
  16.  */
  17.  
  18. /*
  19.  * $Id: assertions.h,v 1.18.18.2 2005/04/29 00:16:52 marka Exp $
  20.  */
  21. /*! \file assertions.h
  22.  */
  23.  
  24. #ifndef ISC_ASSERTIONS_H
  25. #define ISC_ASSERTIONS_H 1
  26.  
  27. #include <isc/lang.h>
  28. #include <isc/platform.h>
  29.  
  30. ISC_LANG_BEGINDECLS
  31.  
  32. /*% isc assertion type */
  33. typedef enum {
  34.     isc_assertiontype_require,
  35.     isc_assertiontype_ensure,
  36.     isc_assertiontype_insist,
  37.     isc_assertiontype_invariant
  38. } isc_assertiontype_t;
  39.  
  40. typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
  41.                     const char *);
  42.  
  43. LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed;
  44.  
  45. void
  46. isc_assertion_setcallback(isc_assertioncallback_t);
  47.  
  48. const char *
  49. isc_assertion_typetotext(isc_assertiontype_t type);
  50.  
  51. #ifdef ISC_CHECK_ALL
  52. #define ISC_CHECK_REQUIRE        1
  53. #define ISC_CHECK_ENSURE        1
  54. #define ISC_CHECK_INSIST        1
  55. #define ISC_CHECK_INVARIANT        1
  56. #endif
  57.  
  58. #ifdef ISC_CHECK_NONE
  59. #define ISC_CHECK_REQUIRE        0
  60. #define ISC_CHECK_ENSURE        0
  61. #define ISC_CHECK_INSIST        0
  62. #define ISC_CHECK_INVARIANT        0
  63. #endif
  64.  
  65. #ifndef ISC_CHECK_REQUIRE
  66. #define ISC_CHECK_REQUIRE        1
  67. #endif
  68.  
  69. #ifndef ISC_CHECK_ENSURE
  70. #define ISC_CHECK_ENSURE        1
  71. #endif
  72.  
  73. #ifndef ISC_CHECK_INSIST
  74. #define ISC_CHECK_INSIST        1
  75. #endif
  76.  
  77. #ifndef ISC_CHECK_INVARIANT
  78. #define ISC_CHECK_INVARIANT        1
  79. #endif
  80.  
  81. #if ISC_CHECK_REQUIRE != 0
  82. #define ISC_REQUIRE(cond) \
  83.     ((void) ((cond) || \
  84.          ((isc_assertion_failed)(__FILE__, __LINE__, \
  85.                      isc_assertiontype_require, \
  86.                      #cond), 0)))
  87. #else
  88. #define ISC_REQUIRE(cond)    ((void) 0)
  89. #endif /* ISC_CHECK_REQUIRE */
  90.  
  91. #if ISC_CHECK_ENSURE != 0
  92. #define ISC_ENSURE(cond) \
  93.     ((void) ((cond) || \
  94.          ((isc_assertion_failed)(__FILE__, __LINE__, \
  95.                      isc_assertiontype_ensure, \
  96.                      #cond), 0)))
  97. #else
  98. #define ISC_ENSURE(cond)    ((void) 0)
  99. #endif /* ISC_CHECK_ENSURE */
  100.  
  101. #if ISC_CHECK_INSIST != 0
  102. #define ISC_INSIST(cond) \
  103.     ((void) ((cond) || \
  104.          ((isc_assertion_failed)(__FILE__, __LINE__, \
  105.                      isc_assertiontype_insist, \
  106.                      #cond), 0)))
  107. #else
  108. #define ISC_INSIST(cond)    ((void) 0)
  109. #endif /* ISC_CHECK_INSIST */
  110.  
  111. #if ISC_CHECK_INVARIANT != 0
  112. #define ISC_INVARIANT(cond) \
  113.     ((void) ((cond) || \
  114.          ((isc_assertion_failed)(__FILE__, __LINE__, \
  115.                      isc_assertiontype_invariant, \
  116.                      #cond), 0)))
  117. #else
  118. #define ISC_INVARIANT(cond)    ((void) 0)
  119. #endif /* ISC_CHECK_INVARIANT */
  120.  
  121. ISC_LANG_ENDDECLS
  122.  
  123. #endif /* ISC_ASSERTIONS_H */
  124.