2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

implement and use isc_buffer_putuint{16,32}()

This commit is contained in:
Michael Graff
1999-01-27 06:18:45 +00:00
parent f0a5bb8f86
commit 22f735acbc
3 changed files with 67 additions and 20 deletions

View File

@@ -294,6 +294,21 @@ isc_buffer_getuint16(isc_buffer_t *b) {
return (result);
}
void
isc_buffer_putuint16(isc_buffer_t *b, isc_uint16_t val)
{
unsigned char *cp;
REQUIRE(VALID_BUFFER(b));
REQUIRE(b->used + 2 <= b->length);
cp = b->base;
cp += b->used;
b->used += 2;
cp[0] = (val & 0xff00) >> 8;
cp[1] = (val & 0x00ff);
}
isc_uint32_t
isc_buffer_getuint32(isc_buffer_t *b) {
unsigned char *cp;
@@ -317,3 +332,20 @@ isc_buffer_getuint32(isc_buffer_t *b) {
return (result);
}
void
isc_buffer_putuint32(isc_buffer_t *b, isc_uint32_t val)
{
unsigned char *cp;
REQUIRE(VALID_BUFFER(b));
REQUIRE(b->used + 4 <= b->length);
cp = b->base;
cp += b->used;
b->used += 4;
cp[0] = (val & 0xff000000) >> 24;
cp[1] = (val & 0x00ff0000) >> 16;
cp[2] = (val & 0x0000ff00) >> 8;
cp[3] = (val & 0x000000ff);
}