Commit 71b306bf authored by Brian Wellington's avatar Brian Wellington
Browse files

add isc_buffer_{get,put}uint8

parent 2eed8ba8
......@@ -277,6 +277,40 @@ isc_buffer_compact(isc_buffer_t *b) {
b->used = length;
}
isc_uint8_t
isc_buffer_getuint8(isc_buffer_t *b) {
unsigned char *cp;
isc_uint8_t result;
/*
* Read an unsigned 8-bit integer from 'b' and return it.
*/
REQUIRE(VALID_BUFFER(b));
REQUIRE(b->used - b->current >= 1);
cp = b->base;
cp += b->current;
b->current += 1;
result = ((unsigned int)(cp[0]));
return (result);
}
void
isc_buffer_putuint8(isc_buffer_t *b, isc_uint8_t val)
{
unsigned char *cp;
REQUIRE(VALID_BUFFER(b));
REQUIRE(b->used + 1 <= b->length);
cp = b->base;
cp += b->used;
b->used += 1;
cp[0] = (val & 0x00ff);
}
isc_uint16_t
isc_buffer_getuint16(isc_buffer_t *b) {
unsigned char *cp;
......
......@@ -422,6 +422,40 @@ isc_buffer_compact(isc_buffer_t *b);
* are those of the remaining region (as it was before the call).
*/
isc_uint8_t
isc_buffer_getuint8(isc_buffer_t *b);
/*
* Read an unsigned 8-bit integer from 'b' and return it.
*
* Requires:
*
* 'b' is a valid buffer.
*
* The length of the available region of 'b' is at least 1.
*
* Ensures:
*
* The current pointer in 'b' is advanced by 1.
*
* Returns:
*
* A 8-bit unsigned integer.
*/
void
isc_buffer_putuint8(isc_buffer_t *b, isc_uint8_t val);
/*
* Store an unsigned 8-bit integer from 'val' into 'b'.
*
* Requires:
* 'b' is a valid buffer.
*
* The length of the unused region of 'b' is at least 1.
*
* Ensures:
* The used pointer in 'b' is advanced by 1.
*/
isc_uint16_t
isc_buffer_getuint16(isc_buffer_t *b);
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment