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