/contrib/bind9/lib/isc/include/isc/region.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 99 lines · 46 code · 14 blank · 39 comment · 3 complexity · a9325b148e3c10325cfb90ac78646142 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 1998-2002 Internet Software Consortium.
  4. *
  5. * Permission to use, copy, modify, and/or 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. /* $Id: region.h,v 1.25 2007/06/19 23:47:18 tbox Exp $ */
  18. #ifndef ISC_REGION_H
  19. #define ISC_REGION_H 1
  20. /*! \file isc/region.h */
  21. #include <isc/types.h>
  22. struct isc_region {
  23. unsigned char * base;
  24. unsigned int length;
  25. };
  26. struct isc_textregion {
  27. char * base;
  28. unsigned int length;
  29. };
  30. /* XXXDCL questionable ... bears discussion. we have been putting off
  31. * discussing the region api.
  32. */
  33. struct isc_constregion {
  34. const void * base;
  35. unsigned int length;
  36. };
  37. struct isc_consttextregion {
  38. const char * base;
  39. unsigned int length;
  40. };
  41. /*@{*/
  42. /*!
  43. * The region structure is not opaque, and is usually directly manipulated.
  44. * Some macros are defined below for convenience.
  45. */
  46. #define isc_region_consume(r,l) \
  47. do { \
  48. isc_region_t *_r = (r); \
  49. unsigned int _l = (l); \
  50. INSIST(_r->length >= _l); \
  51. _r->base += _l; \
  52. _r->length -= _l; \
  53. } while (0)
  54. #define isc_textregion_consume(r,l) \
  55. do { \
  56. isc_textregion_t *_r = (r); \
  57. unsigned int _l = (l); \
  58. INSIST(_r->length >= _l); \
  59. _r->base += _l; \
  60. _r->length -= _l; \
  61. } while (0)
  62. #define isc_constregion_consume(r,l) \
  63. do { \
  64. isc_constregion_t *_r = (r); \
  65. unsigned int _l = (l); \
  66. INSIST(_r->length >= _l); \
  67. _r->base += _l; \
  68. _r->length -= _l; \
  69. } while (0)
  70. /*@}*/
  71. int
  72. isc_region_compare(isc_region_t *r1, isc_region_t *r2);
  73. /*%<
  74. * Compares the contents of two regions
  75. *
  76. * Requires:
  77. *\li 'r1' is a valid region
  78. *\li 'r2' is a valid region
  79. *
  80. * Returns:
  81. *\li < 0 if r1 is lexicographically less than r2
  82. *\li = 0 if r1 is lexicographically identical to r2
  83. *\li > 0 if r1 is lexicographically greater than r2
  84. */
  85. #endif /* ISC_REGION_H */