region.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2007, 2013  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1998-2002  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: region.h,v 1.25 2007/06/19 23:47:18 tbox Exp $ */
00019 
00020 #ifndef ISC_REGION_H
00021 #define ISC_REGION_H 1
00022 
00023 /*! \file isc/region.h */
00024 
00025 #include <isc/types.h>
00026 #include <isc/lang.h>
00027 
00028 struct isc_region {
00029         unsigned char * base;
00030         unsigned int    length;
00031 };
00032 
00033 struct isc_textregion {
00034         char *          base;
00035         unsigned int    length;
00036 };
00037 
00038 /* XXXDCL questionable ... bears discussion.  we have been putting off
00039  * discussing the region api.
00040  */
00041 struct isc_constregion {
00042         const void *    base;
00043         unsigned int    length;
00044 };
00045 
00046 struct isc_consttextregion {
00047         const char *    base;
00048         unsigned int    length;
00049 };
00050 
00051 /*@{*/
00052 /*!
00053  * The region structure is not opaque, and is usually directly manipulated.
00054  * Some macros are defined below for convenience.
00055  */
00056 
00057 #define isc_region_consume(r,l) \
00058         do { \
00059                 isc_region_t *_r = (r); \
00060                 unsigned int _l = (l); \
00061                 INSIST(_r->length >= _l); \
00062                 _r->base += _l; \
00063                 _r->length -= _l; \
00064         } while (0)
00065 
00066 #define isc_textregion_consume(r,l) \
00067         do { \
00068                 isc_textregion_t *_r = (r); \
00069                 unsigned int _l = (l); \
00070                 INSIST(_r->length >= _l); \
00071                 _r->base += _l; \
00072                 _r->length -= _l; \
00073         } while (0)
00074 
00075 #define isc_constregion_consume(r,l) \
00076         do { \
00077                 isc_constregion_t *_r = (r); \
00078                 unsigned int _l = (l); \
00079                 INSIST(_r->length >= _l); \
00080                 _r->base += _l; \
00081                 _r->length -= _l; \
00082         } while (0)
00083 /*@}*/
00084 
00085 ISC_LANG_BEGINDECLS
00086 
00087 int
00088 isc_region_compare(isc_region_t *r1, isc_region_t *r2);
00089 /*%<
00090  * Compares the contents of two regions
00091  *
00092  * Requires:
00093  *\li   'r1' is a valid region
00094  *\li   'r2' is a valid region
00095  *
00096  * Returns:
00097  *\li    < 0 if r1 is lexicographically less than r2
00098  *\li    = 0 if r1 is lexicographically identical to r2
00099  *\li    > 0 if r1 is lexicographically greater than r2
00100  */
00101 
00102 ISC_LANG_ENDDECLS
00103 
00104 #endif /* ISC_REGION_H */

Generated on Tue Apr 28 17:41:04 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha