1 /* $OpenBSD: bytebuf.h,v 1.3 2012/05/08 13:15:11 yasuoka Exp $ */ 2 /*- 3 * Copyright (c) 2009 Internet Initiative Japan Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 #ifndef BYTEBUF_H 28 #define BYTEBUF_H 1 29 30 /* $Id: bytebuf.h,v 1.3 2012/05/08 13:15:11 yasuoka Exp $ */ 31 32 typedef struct _bytebuffer bytebuffer; 33 34 extern const void * BYTEBUFFER_PUT_DIRECT; 35 extern void * BYTEBUFFER_GET_DIRECT; 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 bytebuffer *bytebuffer_create (size_t); 42 bytebuffer *bytebuffer_wrap (void *, size_t); 43 void *bytebuffer_unwrap (bytebuffer *); 44 int bytebuffer_realloc (bytebuffer *, size_t); 45 void bytebuffer_compact (bytebuffer *); 46 void *bytebuffer_put (bytebuffer *, const void *, size_t); 47 void *bytebuffer_get (bytebuffer *, void *, size_t); 48 int bytebuffer_position (bytebuffer *); 49 int bytebuffer_limit (bytebuffer *); 50 int bytebuffer_capacity (bytebuffer *); 51 void *bytebuffer_pointer (bytebuffer *); 52 size_t bytebuffer_remaining (bytebuffer *); 53 int bytebuffer_has_remaining (bytebuffer *); 54 void bytebuffer_flip (bytebuffer *); 55 void bytebuffer_rewind (bytebuffer *); 56 void bytebuffer_clear (bytebuffer *); 57 void bytebuffer_destroy (bytebuffer *); 58 void bytebuffer_mark (bytebuffer *); 59 void bytebuffer_reset (bytebuffer *); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif /* !BYTEBUF_H */ 66