lwbuffer.c revision 70e5a7403f0e0a3bd292b8287c5fed5772c15270
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2000, 2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * purpose with or without fee is hereby granted, provided that the above
0f467ed4d4a732003941247d26f05596e25f357bAutomatic Updater * copyright notice and this permission notice appear in all copies.
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * PERFORMANCE OF THIS SOFTWARE.
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt/* $Id: lwbuffer.c,v 1.15 2007/06/19 23:47:22 tbox Exp $ */
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * These functions provide bounds checked access to a region of memory
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * where data is being read or written. They are based on, and similar
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * to, the isc_buffer_ functions in the ISC library.
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * A buffer is a region of memory, together with a set of related
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * subregions. The used region and the available region are disjoint, and
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * their union is the buffer's region. The used region extends from the
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * beginning of the buffer region to the last used byte. The available
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * region extends from one byte greater than the last used byte to the
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * end of the buffer's region. The size of the used region can be changed
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt * using various buffer commands. Initially, the used region is empty.
#include <config.h>
#include <string.h>
#include "assert_p.h"
b->used = 0;
b->current = 0;
b->active = 0;
b->magic = 0;
b->length = 0;
b->used = 0;
b->current = 0;
b->active = 0;
b->used += n;
b->used -= n;
b->used = 0;
b->current = 0;
b->active = 0;
b->current = 0;
b->current += n;
b->current -= n;
unsigned char *cp;
return (result);
unsigned char *cp;
/* Read an unsigned 16-bit integer in network byte order from 'b', convert it to host byte order, and return it. */
unsigned char *cp;
return (result);
unsigned char *cp;
/* Read an unsigned 32-bit integer in network byte order from 'b', convert it to host byte order, and return it. */
unsigned char *cp;
return (result);
unsigned char *cp;
unsigned int length)
unsigned char *cp;
unsigned int length)
unsigned char *cp;