uwx_bstream.h revision 115013
154359Sroberto/* 254359Sroberto * Copyright (c) 2002,2003 Hewlett-Packard Company 354359Sroberto * 454359Sroberto * Permission is hereby granted, free of charge, to any person obtaining a 554359Sroberto * copy of this software and associated documentation files (the "Software"), 6182007Sroberto * to deal in the Software without restriction, including without limitation 754359Sroberto * the rights to use, copy, modify, merge, publish, distribute, sublicense, 854359Sroberto * and/or sell copies of the Software, and to permit persons to whom the 954359Sroberto * Software is furnished to do so, subject to the following conditions: 1054359Sroberto * 1154359Sroberto * The above copyright notice and this permission notice shall be included 1254359Sroberto * in all copies or substantial portions of the Software. 1354359Sroberto * 1454359Sroberto * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1554359Sroberto * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1654359Sroberto * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1754359Sroberto * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1854359Sroberto * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1954359Sroberto * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2054359Sroberto * DEALINGS IN THE SOFTWARE. 2154359Sroberto */ 2254359Sroberto 2354359Srobertostruct uwx_bstream { 2454359Sroberto copyin_cb copyin; 2554359Sroberto intptr_t cb_token; 2654359Sroberto uint64_t source; 2754359Sroberto uint64_t buf; 2854359Sroberto unsigned char *bufp; 2954359Sroberto int nbuf; 3054359Sroberto unsigned int ntotal; 3154359Sroberto int request; 3254359Sroberto int peekc; 3354359Sroberto}; 3454359Sroberto 3554359Sroberto/* uwx_init_bstream: initialize a byte stream for reading */ 3654359Sroberto 3754359Srobertoextern void uwx_init_bstream( 3854359Sroberto struct uwx_bstream *bstream, 3954359Sroberto struct uwx_env *env, 4054359Sroberto uint64_t source, 4154359Sroberto unsigned int len, 4254359Sroberto int request); 4354359Sroberto 4454359Sroberto 4554359Sroberto/* uwx_get_byte: read the next byte from the byte stream */ 4654359Sroberto 4754359Srobertoextern int uwx_get_byte(struct uwx_bstream *bstream); 4854359Sroberto 4954359Sroberto 5054359Sroberto/* uwx_unget_byte: push a byte back onto the byte stream */ 5154359Sroberto 5254359Srobertoextern int uwx_unget_byte(struct uwx_bstream *bstream, int b); 5354359Sroberto 5454359Sroberto 5554359Sroberto/* uwx_get_uleb128: read a ULEB128 value from the byte stream */ 5654359Sroberto 5754359Srobertoextern int uwx_get_uleb128(struct uwx_bstream *bstream, uint64_t *val); 5854359Sroberto