1115013Smarcel/* 2160157SmarcelCopyright (c) 2003-2006 Hewlett-Packard Development Company, L.P. 3121642SmarcelPermission is hereby granted, free of charge, to any person 4121642Smarcelobtaining a copy of this software and associated documentation 5121642Smarcelfiles (the "Software"), to deal in the Software without 6121642Smarcelrestriction, including without limitation the rights to use, 7121642Smarcelcopy, modify, merge, publish, distribute, sublicense, and/or sell 8121642Smarcelcopies of the Software, and to permit persons to whom the 9121642SmarcelSoftware is furnished to do so, subject to the following 10121642Smarcelconditions: 11115013Smarcel 12121642SmarcelThe above copyright notice and this permission notice shall be 13121642Smarcelincluded in all copies or substantial portions of the Software. 14121642Smarcel 15121642SmarcelTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16121642SmarcelEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17121642SmarcelOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18121642SmarcelNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19121642SmarcelHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20121642SmarcelWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21121642SmarcelFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22121642SmarcelOTHER DEALINGS IN THE SOFTWARE. 23121642Smarcel*/ 24121642Smarcel 25115013Smarcelstruct uwx_bstream { 26115013Smarcel copyin_cb copyin; 27115013Smarcel intptr_t cb_token; 28115013Smarcel uint64_t source; 29115013Smarcel uint64_t buf; 30115013Smarcel unsigned char *bufp; 31115013Smarcel int nbuf; 32115013Smarcel unsigned int ntotal; 33115013Smarcel int request; 34115013Smarcel int peekc; 35115013Smarcel}; 36115013Smarcel 37115013Smarcel/* uwx_init_bstream: initialize a byte stream for reading */ 38115013Smarcel 39115013Smarcelextern void uwx_init_bstream( 40115013Smarcel struct uwx_bstream *bstream, 41115013Smarcel struct uwx_env *env, 42115013Smarcel uint64_t source, 43115013Smarcel unsigned int len, 44115013Smarcel int request); 45115013Smarcel 46115013Smarcel 47115013Smarcel/* uwx_get_byte: read the next byte from the byte stream */ 48115013Smarcel 49115013Smarcelextern int uwx_get_byte(struct uwx_bstream *bstream); 50115013Smarcel 51115013Smarcel 52115013Smarcel/* uwx_unget_byte: push a byte back onto the byte stream */ 53115013Smarcel 54115013Smarcelextern int uwx_unget_byte(struct uwx_bstream *bstream, int b); 55115013Smarcel 56115013Smarcel 57115013Smarcel/* uwx_get_uleb128: read a ULEB128 value from the byte stream */ 58115013Smarcel 59115013Smarcelextern int uwx_get_uleb128(struct uwx_bstream *bstream, uint64_t *val); 60