1/*
2Copyright (c) 2003-2006 Hewlett-Packard Development Company, L.P.
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the
9Software is furnished to do so, subject to the following
10conditions:
11
12The above copyright notice and this permission notice shall be
13included in all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
23*/
24
25struct uwx_bstream {
26    copyin_cb copyin;
27    intptr_t cb_token;
28    uint64_t source;
29    uint64_t buf;
30    unsigned char *bufp;
31    int nbuf;
32    unsigned int ntotal;
33    int request;
34    int peekc;
35};
36
37/* uwx_init_bstream: initialize a byte stream for reading */
38
39extern void uwx_init_bstream(
40    struct uwx_bstream *bstream,
41    struct uwx_env *env,
42    uint64_t source,
43    unsigned int len,
44    int request);
45
46
47/* uwx_get_byte: read the next byte from the byte stream */
48
49extern int uwx_get_byte(struct uwx_bstream *bstream);
50
51
52/* uwx_unget_byte: push a byte back onto the byte stream */
53
54extern int uwx_unget_byte(struct uwx_bstream *bstream, int b);
55
56
57/* uwx_get_uleb128: read a ULEB128 value from the byte stream */
58
59extern int uwx_get_uleb128(struct uwx_bstream *bstream, uint64_t *val);
60