Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / include / isc / region.h
blobfd92ec81157475fe3527d4b148a627a2f0573e45
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1998-2002 Internet Software Consortium.
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: region.h,v 1.16.12.3 2004/03/08 09:04:53 marka Exp */
22 #ifndef ISC_REGION_H
23 #define ISC_REGION_H 1
25 #include <isc/types.h>
27 struct isc_region {
28 unsigned char * base;
29 unsigned int length;
32 struct isc_textregion {
33 char * base;
34 unsigned int length;
37 /* XXXDCL questionable ... bears discussion. we have been putting off
38 * discussing the region api.
40 struct isc_constregion {
41 const void * base;
42 unsigned int length;
45 struct isc_consttextregion {
46 const char * base;
47 unsigned int length;
51 * The region structure is not opaque, and is usually directly manipulated.
52 * Some macros are defined below for convenience.
55 #define isc_region_consume(r,l) \
56 do { \
57 isc_region_t *_r = (r); \
58 unsigned int _l = (l); \
59 INSIST(_r->length >= _l); \
60 _r->base += _l; \
61 _r->length -= _l; \
62 } while (0)
64 #define isc_textregion_consume(r,l) \
65 do { \
66 isc_textregion_t *_r = (r); \
67 unsigned int _l = (l); \
68 INSIST(_r->length >= _l); \
69 _r->base += _l; \
70 _r->length -= _l; \
71 } while (0)
73 #define isc_constregion_consume(r,l) \
74 do { \
75 isc_constregion_t *_r = (r); \
76 unsigned int _l = (l); \
77 INSIST(_r->length >= _l); \
78 _r->base += _l; \
79 _r->length -= _l; \
80 } while (0)
82 int
83 isc_region_compare(isc_region_t *r1, isc_region_t *r2);
85 * Compares the contents of two regions
87 * Requires:
88 * 'r1' is a valid region
89 * 'r2' is a valid region
91 * Returns:
92 * < 0 if r1 is lexicographically less than r2
93 * = 0 if r1 is lexicographically identical to r2
94 * > 0 if r1 is lexicographically greater than r2
97 #endif /* ISC_REGION_H */