lwbuffer.c revision c1ecf4ace2a59be40c68f3f9f58370e124f68763
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * Copyright (C) 2000 Internet Software Consortium.
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * Permission to use, copy, modify, and distribute this software for any
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * purpose with or without fee is hereby granted, provided that the above
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * copyright notice and this permission notice appear in all copies.
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
d25afd60ee2286cb171c4960a790f3d7041b6f85Bob Halley/* $Id: lwbuffer.c,v 1.7 2000/06/26 23:35:00 bwelling Exp $ */
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_init(lwres_buffer_t *b, void *base, unsigned int length)
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley * Make 'b' refer to the 'length'-byte region starting at base.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley * Make 'b' an invalid buffer.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_add(lwres_buffer_t *b, unsigned int n)
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley * Increase the 'used' region of 'b' by 'n' bytes.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_subtract(lwres_buffer_t *b, unsigned int n)
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley * Decrease the 'used' region of 'b' by 'n' bytes.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley * Make the used region empty.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley * Make the consumed region empty.
3740b569ae76295b941d57a724a43beb75b533baBob Halleylwres_buffer_forward(lwres_buffer_t *b, unsigned int n)
577179503f2eb7695ec668d8eeb41889a150e28fBob Halley * Increase the 'consumed' region of 'b' by 'n' bytes.
577179503f2eb7695ec668d8eeb41889a150e28fBob Halleylwres_buffer_back(lwres_buffer_t *b, unsigned int n)
577179503f2eb7695ec668d8eeb41889a150e28fBob Halley * Decrease the 'consumed' region of 'b' by 'n' bytes.
577179503f2eb7695ec668d8eeb41889a150e28fBob Halley unsigned char *cp;
3740b569ae76295b941d57a724a43beb75b533baBob Halley * Read an unsigned 8-bit integer from 'b' and return it.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_putuint8(lwres_buffer_t *b, lwres_uint8_t val)
3740b569ae76295b941d57a724a43beb75b533baBob Halley unsigned char *cp;
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned char *cp;
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley * Read an unsigned 16-bit integer in network byte order from 'b',
3740b569ae76295b941d57a724a43beb75b533baBob Halley * convert it to host byte order, and return it.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_putuint16(lwres_buffer_t *b, lwres_uint16_t val)
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned char *cp;
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned char *cp;
38d2d0e9326a2f70b5893302b89a26978b539405Bob Halley * Read an unsigned 32-bit integer in network byte order from 'b',
3740b569ae76295b941d57a724a43beb75b533baBob Halley * convert it to host byte order, and return it.
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_putuint32(lwres_buffer_t *b, lwres_uint32_t val)
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned char *cp;
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley cp[0] = (unsigned char)((val & 0xff000000) >> 24);
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley cp[1] = (unsigned char)((val & 0x00ff0000) >> 16);
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley cp[2] = (unsigned char)((val & 0x0000ff00) >> 8);
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_putmem(lwres_buffer_t *b, const unsigned char *base,
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned int length)
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned char *cp;
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halleylwres_buffer_getmem(lwres_buffer_t *b, unsigned char *base,
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned int length)
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley unsigned char *cp;