xref: /trueos/contrib/ntp/include/isc/buffer.h (revision b3db078f21c6b171ca87f55006f0195783756e42)
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1998-2002  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 /* $Id: buffer.h,v 1.39.12.2 2004/03/08 09:04:51 marka Exp $ */
19 
20 #ifndef ISC_BUFFER_H
21 #define ISC_BUFFER_H 1
22 
23 /*****
24  ***** Module Info
25  *****/
26 
27 /*
28  * Buffers
29  *
30  * A buffer is a region of memory, together with a set of related subregions.
31  * Buffers are used for parsing and I/O operations.
32  *
33  * The 'used region' and the 'available' region are disjoint, and their
34  * union is the buffer's region.  The used region extends from the beginning
35  * of the buffer region to the last used byte.  The available region
36  * extends from one byte greater than the last used byte to the end of the
37  * buffer's region.  The size of the used region can be changed using various
38  * buffer commands.  Initially, the used region is empty.
39  *
40  * The used region is further subdivided into two disjoint regions: the
41  * 'consumed region' and the 'remaining region'.  The union of these two
42  * regions is the used region.  The consumed region extends from the beginning
43  * of the used region to the byte before the 'current' offset (if any).  The
44  * 'remaining' region the current pointer to the end of the used
45  * region.  The size of the consumed region can be changed using various
46  * buffer commands.  Initially, the consumed region is empty.
47  *
48  * The 'active region' is an (optional) subregion of the remaining region.
49  * It extends from the current offset to an offset in the remaining region
50  * that is selected with isc_buffer_setactive().  Initially, the active region
51  * is empty.  If the current offset advances beyond the chosen offset, the
52  * active region will also be empty.
53  *
54  *  /------------entire length---------------\
55  *  /----- used region -----\/-- available --\
56  *  +----------------------------------------+
57  *  | consumed  | remaining |                |
58  *  +----------------------------------------+
59  *  a           b     c     d                e
60  *
61  * a == base of buffer.
62  * b == current pointer.  Can be anywhere between a and d.
63  * c == active pointer.  Meaningful between b and d.
64  * d == used pointer.
65  * e == length of buffer.
66  *
67  * a-e == entire length of buffer.
68  * a-d == used region.
69  * a-b == consumed region.
70  * b-d == remaining region.
71  * b-c == optional active region.
72  *
73  * The following invariants are maintained by all routines:
74  *
75  *	length > 0
76  *
77  *	base is a valid pointer to length bytes of memory
78  *
79  *	0 <= used <= length
80  *
81  *	0 <= current <= used
82  *
83  *	0 <= active <= used
84  *	(although active < current implies empty active region)
85  *
86  * MP:
87  *	Buffers have no synchronization.  Clients must ensure exclusive
88  *	access.
89  *
90  * Reliability:
91  *	No anticipated impact.
92  *
93  * Resources:
94  *	Memory: 1 pointer + 6 unsigned integers per buffer.
95  *
96  * Security:
97  *	No anticipated impact.
98  *
99  * Standards:
100  *	None.
101  */
102 
103 /***
104  *** Imports
105  ***/
106 
107 #include <isc/lang.h>
108 #include <isc/magic.h>
109 #include <isc/types.h>
110 
111 /*
112  * To make many functions be inline macros (via #define) define this.
113  * If it is undefined, a function will be used.
114  */
115 #define ISC_BUFFER_USEINLINE
116 
117 ISC_LANG_BEGINDECLS
118 
119 /***
120  *** Magic numbers
121  ***/
122 #define ISC_BUFFER_MAGIC		0x42756621U	/* Buf!. */
123 #define ISC_BUFFER_VALID(b)		ISC_MAGIC_VALID(b, ISC_BUFFER_MAGIC)
124 
125 /*
126  * The following macros MUST be used only on valid buffers.  It is the
127  * caller's responsibility to ensure this by using the ISC_BUFFER_VALID
128  * check above, or by calling another isc_buffer_*() function (rather than
129  * another macro.)
130  */
131 
132 /*
133  * Fundamental buffer elements.  (A through E in the introductory comment.)
134  */
135 #define isc_buffer_base(b)    ((void *)(b)->base)			  /*a*/
136 #define isc_buffer_current(b) \
137 		((void *)((unsigned char *)(b)->base + (b)->current))     /*b*/
138 #define isc_buffer_active(b)  \
139 		((void *)((unsigned char *)(b)->base + (b)->active))      /*c*/
140 #define isc_buffer_used(b)    \
141 		((void *)((unsigned char *)(b)->base + (b)->used))        /*d*/
142 #define isc_buffer_length(b)  ((b)->length)				  /*e*/
143 
144 /*
145  * Derived lengths.  (Described in the introductory comment.)
146  */
147 #define isc_buffer_usedlength(b)	((b)->used)		      /* d-a */
148 #define isc_buffer_consumedlength(b)	((b)->current)		      /* b-a */
149 #define isc_buffer_remaininglength(b)	((b)->used - (b)->current)    /* d-b */
150 #define isc_buffer_activelength(b)	((b)->active - (b)->current)  /* c-b */
151 #define isc_buffer_availablelength(b)	((b)->length - (b)->used)     /* e-d */
152 
153 /*
154  * Note that the buffer structure is public.  This is principally so buffer
155  * operations can be implemented using macros.  Applications are strongly
156  * discouraged from directly manipulating the structure.
157  */
158 
159 struct isc_buffer {
160 	unsigned int		magic;
161 	void		       *base;
162 	/* The following integers are byte offsets from 'base'. */
163 	unsigned int		length;
164 	unsigned int		used;
165 	unsigned int 		current;
166 	unsigned int 		active;
167 	/* linkable */
168 	ISC_LINK(isc_buffer_t)	link;
169 	/* private internal elements */
170 	isc_mem_t	       *mctx;
171 };
172 
173 /***
174  *** Functions
175  ***/
176 
177 isc_result_t
178 isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
179 		    unsigned int length);
180 /*
181  * Allocate a dynamic linkable buffer which has "length" bytes in the
182  * data region.
183  *
184  * Requires:
185  *	"mctx" is valid.
186  *
187  *	"dynbuffer" is non-NULL, and "*dynbuffer" is NULL.
188  *
189  * Returns:
190  *	ISC_R_SUCCESS		- success
191  *	ISC_R_NOMEMORY		- no memory available
192  *
193  * Note:
194  *	Changing the buffer's length field is not permitted.
195  */
196 
197 void
198 isc_buffer_free(isc_buffer_t **dynbuffer);
199 /*
200  * Release resources allocated for a dynamic buffer.
201  *
202  * Requires:
203  *	"dynbuffer" is not NULL.
204  *
205  *	"*dynbuffer" is a valid dynamic buffer.
206  *
207  * Ensures:
208  *	"*dynbuffer" will be NULL on return, and all memory associated with
209  *	the dynamic buffer is returned to the memory context used in
210  *	isc_buffer_allocate().
211  */
212 
213 void
214 isc__buffer_init(isc_buffer_t *b, const void *base, unsigned int length);
215 /*
216  * Make 'b' refer to the 'length'-byte region starting at base.
217  *
218  * Requires:
219  *
220  *	'length' > 0
221  *
222  *	'base' is a pointer to a sequence of 'length' bytes.
223  *
224  */
225 
226 void
227 isc__buffer_invalidate(isc_buffer_t *b);
228 /*
229  * Make 'b' an invalid buffer.
230  *
231  * Requires:
232  *	'b' is a valid buffer.
233  *
234  * Ensures:
235  *	If assertion checking is enabled, future attempts to use 'b' without
236  *	calling isc_buffer_init() on it will cause an assertion failure.
237  */
238 
239 void
240 isc__buffer_region(isc_buffer_t *b, isc_region_t *r);
241 /*
242  * Make 'r' refer to the region of 'b'.
243  *
244  * Requires:
245  *
246  *	'b' is a valid buffer.
247  *
248  *	'r' points to a region structure.
249  */
250 
251 void
252 isc__buffer_usedregion(isc_buffer_t *b, isc_region_t *r);
253 /*
254  * Make 'r' refer to the used region of 'b'.
255  *
256  * Requires:
257  *
258  *	'b' is a valid buffer.
259  *
260  *	'r' points to a region structure.
261  */
262 
263 void
264 isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r);
265 /*
266  * Make 'r' refer to the available region of 'b'.
267  *
268  * Requires:
269  *
270  *	'b' is a valid buffer.
271  *
272  *	'r' points to a region structure.
273  */
274 
275 void
276 isc__buffer_add(isc_buffer_t *b, unsigned int n);
277 /*
278  * Increase the 'used' region of 'b' by 'n' bytes.
279  *
280  * Requires:
281  *
282  *	'b' is a valid buffer
283  *
284  *	used + n <= length
285  *
286  */
287 
288 void
289 isc__buffer_subtract(isc_buffer_t *b, unsigned int n);
290 /*
291  * Decrease the 'used' region of 'b' by 'n' bytes.
292  *
293  * Requires:
294  *
295  *	'b' is a valid buffer
296  *
297  *	used >= n
298  *
299  */
300 
301 void
302 isc__buffer_clear(isc_buffer_t *b);
303 /*
304  * Make the used region empty.
305  *
306  * Requires:
307  *
308  *	'b' is a valid buffer
309  *
310  * Ensures:
311  *
312  *	used = 0
313  *
314  */
315 
316 void
317 isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r);
318 /*
319  * Make 'r' refer to the consumed region of 'b'.
320  *
321  * Requires:
322  *
323  *	'b' is a valid buffer.
324  *
325  *	'r' points to a region structure.
326  */
327 
328 void
329 isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r);
330 /*
331  * Make 'r' refer to the remaining region of 'b'.
332  *
333  * Requires:
334  *
335  *	'b' is a valid buffer.
336  *
337  *	'r' points to a region structure.
338  */
339 
340 void
341 isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r);
342 /*
343  * Make 'r' refer to the active region of 'b'.
344  *
345  * Requires:
346  *
347  *	'b' is a valid buffer.
348  *
349  *	'r' points to a region structure.
350  */
351 
352 void
353 isc__buffer_setactive(isc_buffer_t *b, unsigned int n);
354 /*
355  * Sets the end of the active region 'n' bytes after current.
356  *
357  * Requires:
358  *
359  *	'b' is a valid buffer.
360  *
361  *	current + n <= used
362  */
363 
364 void
365 isc__buffer_first(isc_buffer_t *b);
366 /*
367  * Make the consumed region empty.
368  *
369  * Requires:
370  *
371  *	'b' is a valid buffer
372  *
373  * Ensures:
374  *
375  *	current == 0
376  *
377  */
378 
379 void
380 isc__buffer_forward(isc_buffer_t *b, unsigned int n);
381 /*
382  * Increase the 'consumed' region of 'b' by 'n' bytes.
383  *
384  * Requires:
385  *
386  *	'b' is a valid buffer
387  *
388  *	current + n <= used
389  *
390  */
391 
392 void
393 isc__buffer_back(isc_buffer_t *b, unsigned int n);
394 /*
395  * Decrease the 'consumed' region of 'b' by 'n' bytes.
396  *
397  * Requires:
398  *
399  *	'b' is a valid buffer
400  *
401  *	n <= current
402  *
403  */
404 
405 void
406 isc_buffer_compact(isc_buffer_t *b);
407 /*
408  * Compact the used region by moving the remaining region so it occurs
409  * at the start of the buffer.  The used region is shrunk by the size of
410  * the consumed region, and the consumed region is then made empty.
411  *
412  * Requires:
413  *
414  *	'b' is a valid buffer
415  *
416  * Ensures:
417  *
418  *	current == 0
419  *
420  *	The size of the used region is now equal to the size of the remaining
421  *	region (as it was before the call).  The contents of the used region
422  *	are those of the remaining region (as it was before the call).
423  */
424 
425 isc_uint8_t
426 isc_buffer_getuint8(isc_buffer_t *b);
427 /*
428  * Read an unsigned 8-bit integer from 'b' and return it.
429  *
430  * Requires:
431  *
432  *	'b' is a valid buffer.
433  *
434  *	The length of the available region of 'b' is at least 1.
435  *
436  * Ensures:
437  *
438  *	The current pointer in 'b' is advanced by 1.
439  *
440  * Returns:
441  *
442  *	A 8-bit unsigned integer.
443  */
444 
445 void
446 isc__buffer_putuint8(isc_buffer_t *b, isc_uint8_t val);
447 /*
448  * Store an unsigned 8-bit integer from 'val' into 'b'.
449  *
450  * Requires:
451  *	'b' is a valid buffer.
452  *
453  *	The length of the unused region of 'b' is at least 1.
454  *
455  * Ensures:
456  *	The used pointer in 'b' is advanced by 1.
457  */
458 
459 isc_uint16_t
460 isc_buffer_getuint16(isc_buffer_t *b);
461 /*
462  * Read an unsigned 16-bit integer in network byte order from 'b', convert
463  * it to host byte order, and return it.
464  *
465  * Requires:
466  *
467  *	'b' is a valid buffer.
468  *
469  *	The length of the available region of 'b' is at least 2.
470  *
471  * Ensures:
472  *
473  *	The current pointer in 'b' is advanced by 2.
474  *
475  * Returns:
476  *
477  *	A 16-bit unsigned integer.
478  */
479 
480 void
481 isc__buffer_putuint16(isc_buffer_t *b, isc_uint16_t val);
482 /*
483  * Store an unsigned 16-bit integer in host byte order from 'val'
484  * into 'b' in network byte order.
485  *
486  * Requires:
487  *	'b' is a valid buffer.
488  *
489  *	The length of the unused region of 'b' is at least 2.
490  *
491  * Ensures:
492  *	The used pointer in 'b' is advanced by 2.
493  */
494 
495 isc_uint32_t
496 isc_buffer_getuint32(isc_buffer_t *b);
497 /*
498  * Read an unsigned 32-bit integer in network byte order from 'b', convert
499  * it to host byte order, and return it.
500  *
501  * Requires:
502  *
503  *	'b' is a valid buffer.
504  *
505  *	The length of the available region of 'b' is at least 4.
506  *
507  * Ensures:
508  *
509  *	The current pointer in 'b' is advanced by 4.
510  *
511  * Returns:
512  *
513  *	A 32-bit unsigned integer.
514  */
515 
516 void
517 isc__buffer_putuint32(isc_buffer_t *b, isc_uint32_t val);
518 /*
519  * Store an unsigned 32-bit integer in host byte order from 'val'
520  * into 'b' in network byte order.
521  *
522  * Requires:
523  *	'b' is a valid buffer.
524  *
525  *	The length of the unused region of 'b' is at least 4.
526  *
527  * Ensures:
528  *	The used pointer in 'b' is advanced by 4.
529  */
530 
531 void
532 isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
533 		   unsigned int length);
534 /*
535  * Copy 'length' bytes of memory at 'base' into 'b'.
536  *
537  * Requires:
538  *	'b' is a valid buffer.
539  *
540  *	'base' points to 'length' bytes of valid memory.
541  *
542  */
543 
544 void
545 isc__buffer_putstr(isc_buffer_t *b, const char *source);
546 /*
547  * Copy 'source' into 'b', not including terminating NUL.
548  *
549  * Requires:
550  *	'b' is a valid buffer.
551  *
552  *	'source' to be a valid NULL terminated string.
553  *
554  *	strlen(source) <= isc_buffer_available(b)
555  */
556 
557 isc_result_t
558 isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r);
559 /*
560  * Copy the contents of 'r' into 'b'.
561  *
562  * Requires:
563  *	'b' is a valid buffer.
564  *
565  *	'r' is a valid region.
566  *
567  * Returns:
568  *
569  *	ISC_R_SUCCESS
570  *	ISC_R_NOSPACE			The available region of 'b' is not
571  *					big enough.
572  */
573 
574 ISC_LANG_ENDDECLS
575 
576 /*
577  * Inline macro versions of the functions.  These should never be called
578  * directly by an application, but will be used by the functions within
579  * buffer.c.  The callers should always use "isc_buffer_*()" names, never
580  * ones beginning with "isc__"
581  */
582 
583 /*
584  * XXXDCL Something more could be done with initializing buffers that
585  * point to const data.  For example, a new function, isc_buffer_initconst,
586  * could be used, and a new boolean flag in the buffer structure could
587  * indicate whether the buffer was initialized with that function.
588  * (isc_bufer_init itself would be reprototyped to *not* have its "base"
589  * parameter be const.)  Then if the boolean were true, the isc_buffer_put*
590  * functions could assert a contractual requirement for a non-const buffer.
591  * One drawback is that the isc_buffer_* functions (macros) that return
592  * pointers would still need to return non-const pointers to avoid compiler
593  * warnings, so it would be up to code that uses them to have to deal
594  * with the possibility that the buffer was initialized as const --
595  * a problem that they *already* have to deal with but have absolutely
596  * no ability to.  With a new isc_buffer_isconst() function returning
597  * true/false, they could at least assert a contractual requirement for
598  * non-const buffers when needed.
599  */
600 #define ISC__BUFFER_INIT(_b, _base, _length) \
601 	do { \
602 		union { \
603 			const void *	konst; \
604 			void *		var; \
605 		} _u; \
606 		_u.konst = (_base); \
607 		(_b)->base = _u.var; \
608 		(_b)->length = (_length); \
609 		(_b)->used = 0; \
610 		(_b)->current = 0; \
611 		(_b)->active = 0; \
612 		(_b)->mctx = NULL; \
613 		ISC_LINK_INIT(_b, link); \
614 		(_b)->magic = ISC_BUFFER_MAGIC; \
615 	} while (0)
616 
617 #define ISC__BUFFER_INVALIDATE(_b) \
618 	do { \
619 		(_b)->magic = 0; \
620 		(_b)->base = NULL; \
621 		(_b)->length = 0; \
622 		(_b)->used = 0; \
623 		(_b)->current = 0; \
624 		(_b)->active = 0; \
625 	} while (0)
626 
627 #define ISC__BUFFER_REGION(_b, _r) \
628 	do { \
629 		(_r)->base = (_b)->base; \
630 		(_r)->length = (_b)->length; \
631 	} while (0)
632 
633 #define ISC__BUFFER_USEDREGION(_b, _r) \
634 	do { \
635 		(_r)->base = (_b)->base; \
636 		(_r)->length = (_b)->used; \
637 	} while (0)
638 
639 #define ISC__BUFFER_AVAILABLEREGION(_b, _r) \
640 	do { \
641 		(_r)->base = isc_buffer_used(_b); \
642 		(_r)->length = isc_buffer_availablelength(_b); \
643 	} while (0)
644 
645 #define ISC__BUFFER_ADD(_b, _n) \
646 	do { \
647 		(_b)->used += (_n); \
648 	} while (0)
649 
650 #define ISC__BUFFER_SUBTRACT(_b, _n) \
651 	do { \
652 		(_b)->used -= (_n); \
653 		if ((_b)->current > (_b)->used) \
654 			(_b)->current = (_b)->used; \
655 		if ((_b)->active > (_b)->used) \
656 			(_b)->active = (_b)->used; \
657 	} while (0)
658 
659 #define ISC__BUFFER_CLEAR(_b) \
660 	do { \
661 		(_b)->used = 0; \
662 		(_b)->current = 0; \
663 		(_b)->active = 0; \
664 	} while (0)
665 
666 #define ISC__BUFFER_CONSUMEDREGION(_b, _r) \
667 	do { \
668 		(_r)->base = (_b)->base; \
669 		(_r)->length = (_b)->current; \
670 	} while (0)
671 
672 #define ISC__BUFFER_REMAININGREGION(_b, _r) \
673 	do { \
674 		(_r)->base = isc_buffer_current(_b); \
675 		(_r)->length = isc_buffer_remaininglength(_b); \
676 	} while (0)
677 
678 #define ISC__BUFFER_ACTIVEREGION(_b, _r) \
679 	do { \
680 		if ((_b)->current < (_b)->active) { \
681 			(_r)->base = isc_buffer_current(_b); \
682 			(_r)->length = isc_buffer_activelength(_b); \
683 		} else { \
684 			(_r)->base = NULL; \
685 			(_r)->length = 0; \
686 		} \
687 	} while (0)
688 
689 #define ISC__BUFFER_SETACTIVE(_b, _n) \
690 	do { \
691 		(_b)->active = (_b)->current + (_n); \
692 	} while (0)
693 
694 #define ISC__BUFFER_FIRST(_b) \
695 	do { \
696 		(_b)->current = 0; \
697 	} while (0)
698 
699 #define ISC__BUFFER_FORWARD(_b, _n) \
700 	do { \
701 		(_b)->current += (_n); \
702 	} while (0)
703 
704 #define ISC__BUFFER_BACK(_b, _n) \
705 	do { \
706 		(_b)->current -= (_n); \
707 	} while (0)
708 
709 #define ISC__BUFFER_PUTMEM(_b, _base, _length) \
710 	do { \
711 		memcpy(isc_buffer_used(_b), (_base), (_length)); \
712 		(_b)->used += (_length); \
713 	} while (0)
714 
715 #define ISC__BUFFER_PUTSTR(_b, _source) \
716 	do { \
717 		unsigned int _length; \
718 		unsigned char *_cp; \
719 		_length = strlen(_source); \
720 		_cp = isc_buffer_used(_b); \
721 		memcpy(_cp, (_source), _length); \
722 		(_b)->used += (_length); \
723 	} while (0)
724 
725 #define ISC__BUFFER_PUTUINT8(_b, _val) \
726 	do { \
727 		unsigned char *_cp; \
728 		isc_uint8_t _val2 = (_val); \
729 		_cp = isc_buffer_used(_b); \
730 		(_b)->used++; \
731 		_cp[0] = _val2 & 0x00ff; \
732 	} while (0)
733 
734 #define ISC__BUFFER_PUTUINT16(_b, _val) \
735 	do { \
736 		unsigned char *_cp; \
737 		isc_uint16_t _val2 = (_val); \
738 		_cp = isc_buffer_used(_b); \
739 		(_b)->used += 2; \
740 		_cp[0] = (unsigned char)((_val2 & 0xff00U) >> 8); \
741 		_cp[1] = (unsigned char)(_val2 & 0x00ffU); \
742 	} while (0)
743 
744 #define ISC__BUFFER_PUTUINT32(_b, _val) \
745 	do { \
746 		unsigned char *_cp; \
747 		isc_uint32_t _val2 = (_val); \
748 		_cp = isc_buffer_used(_b); \
749 		(_b)->used += 4; \
750 		_cp[0] = (unsigned char)((_val2 & 0xff000000) >> 24); \
751 		_cp[1] = (unsigned char)((_val2 & 0x00ff0000) >> 16); \
752 		_cp[2] = (unsigned char)((_val2 & 0x0000ff00) >> 8); \
753 		_cp[3] = (unsigned char)((_val2 & 0x000000ff)); \
754 	} while (0)
755 
756 #if defined(ISC_BUFFER_USEINLINE)
757 #define isc_buffer_init			ISC__BUFFER_INIT
758 #define isc_buffer_invalidate		ISC__BUFFER_INVALIDATE
759 #define isc_buffer_region		ISC__BUFFER_REGION
760 #define isc_buffer_usedregion		ISC__BUFFER_USEDREGION
761 #define isc_buffer_availableregion	ISC__BUFFER_AVAILABLEREGION
762 #define isc_buffer_add			ISC__BUFFER_ADD
763 #define isc_buffer_subtract		ISC__BUFFER_SUBTRACT
764 #define isc_buffer_clear		ISC__BUFFER_CLEAR
765 #define isc_buffer_consumedregion	ISC__BUFFER_CONSUMEDREGION
766 #define isc_buffer_remainingregion	ISC__BUFFER_REMAININGREGION
767 #define isc_buffer_activeregion		ISC__BUFFER_ACTIVEREGION
768 #define isc_buffer_setactive		ISC__BUFFER_SETACTIVE
769 #define isc_buffer_first		ISC__BUFFER_FIRST
770 #define isc_buffer_forward		ISC__BUFFER_FORWARD
771 #define isc_buffer_back			ISC__BUFFER_BACK
772 #define isc_buffer_putmem		ISC__BUFFER_PUTMEM
773 #define isc_buffer_putstr		ISC__BUFFER_PUTSTR
774 #define isc_buffer_putuint8		ISC__BUFFER_PUTUINT8
775 #define isc_buffer_putuint16		ISC__BUFFER_PUTUINT16
776 #define isc_buffer_putuint32		ISC__BUFFER_PUTUINT32
777 #else
778 #define isc_buffer_init			isc__buffer_init
779 #define isc_buffer_invalidate		isc__buffer_invalidate
780 #define isc_buffer_region		isc__buffer_region
781 #define isc_buffer_usedregion		isc__buffer_usedregion
782 #define isc_buffer_availableregion	isc__buffer_availableregion
783 #define isc_buffer_add			isc__buffer_add
784 #define isc_buffer_subtract		isc__buffer_subtract
785 #define isc_buffer_clear		isc__buffer_clear
786 #define isc_buffer_consumedregion	isc__buffer_consumedregion
787 #define isc_buffer_remainingregion	isc__buffer_remainingregion
788 #define isc_buffer_activeregion		isc__buffer_activeregion
789 #define isc_buffer_setactive		isc__buffer_setactive
790 #define isc_buffer_first		isc__buffer_first
791 #define isc_buffer_forward		isc__buffer_forward
792 #define isc_buffer_back			isc__buffer_back
793 #define isc_buffer_putmem		isc__buffer_putmem
794 #define isc_buffer_putstr		isc__buffer_putstr
795 #define isc_buffer_putuint8		isc__buffer_putuint8
796 #define isc_buffer_putuint16		isc__buffer_putuint16
797 #define isc_buffer_putuint32		isc__buffer_putuint32
798 #endif
799 
800 #endif /* ISC_BUFFER_H */
801