region.h 1.54 KB
Newer Older
Bob Halley's avatar
add    
Bob Halley committed
1
/*
Bob Halley's avatar
Bob Halley committed
2
 * Copyright (C) 1998, 1999, 2000  Internet Software Consortium.
Bob Halley's avatar
Bob Halley committed
3
4
5
6
7
8
9
10
11
12
13
14
15
 * 
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
Bob Halley's avatar
add    
Bob Halley committed
16
17
18
19
20
 */

#ifndef ISC_REGION_H
#define ISC_REGION_H 1

21
#include <isc/types.h>
Bob Halley's avatar
Bob Halley committed
22

23
struct isc_region {
Bob Halley's avatar
add    
Bob Halley committed
24
25
	unsigned char *	base;
	unsigned int	length;
26
};
Bob Halley's avatar
add    
Bob Halley committed
27

28
struct isc_textregion {
Bob Halley's avatar
add    
Bob Halley committed
29
30
	char *		base;
	unsigned int	length;
31
};
Bob Halley's avatar
add    
Bob Halley committed
32
33

/*
Bob Halley's avatar
Bob Halley committed
34
35
 * The region structure is not opaque, and is usually directly manipulated.
 * Some macros are defined below for convenience.
Bob Halley's avatar
add    
Bob Halley committed
36
37
 */

Bob Halley's avatar
Bob Halley committed
38
39
#define isc_region_consume(r,l) \
	do { \
40
41
42
43
44
		isc_region_t *_r = (r); \
		unsigned int _l = (l); \
		INSIST(_r->length >= _l); \
		_r->base += _l; \
		_r->length -= _l; \
Bob Halley's avatar
Bob Halley committed
45
46
47
48
	} while (0)

#define isc_textregion_consume(r,l) \
	do { \
49
50
51
52
53
		isc_textregion_t *_r = (r); \
		unsigned int _l = (l); \
		INSIST(_r->length >= _l); \
		_r->base += _l; \
		_r->length -= _l; \
Bob Halley's avatar
Bob Halley committed
54
55
	} while (0)

Bob Halley's avatar
add    
Bob Halley committed
56
#endif /* ISC_REGION_H */