20 #ifndef GNASH_STREAM_H 21 #define GNASH_STREAM_H 71 unsigned read_uint(
unsigned short bitcount);
88 int read_sint(
unsigned short bitcount);
106 float read_short_ufixed();
112 float read_short_sfixed();
118 float read_long_float();
145 unsigned read(
char *buf,
unsigned count);
151 std::uint8_t read_u8();
157 std::int8_t read_s8();
163 std::uint16_t read_u16();
169 std::int16_t read_s16();
175 std::uint32_t read_u32();
182 std::int32_t read_s32();
194 std::uint32_t res = read_u8();
195 if (!(res & 0x00000080))
return res;
198 res = (res & 0x0000007F) | read_u8() << 7;
199 if (!(res & 0x00004000))
return res;
202 res = (res & 0x00003FFF) | read_u8() << 14;
203 if (!(res & 0x00200000))
return res;
206 res = (res & 0x001FFFFF) | read_u8() << 21;
207 if (!(res & 0x10000000))
return res;
210 res = (res & 0x0FFFFFFF) | read_u8() << 28;
223 if (!(read_u8() & 0x80))
return;
225 if (!(read_u8() & 0x80))
return;
227 if (!(read_u8() & 0x80))
return;
229 if (!(read_u8() & 0x80))
return;
231 static_cast<void> (read_u8());
247 unsigned count = read_u8();
265 void read_string(std::string& to);
278 void read_string_with_length(std::string& to);
293 void read_string_with_length(
unsigned len, std::string& to);
304 unsigned long tell();
317 bool seek(
unsigned long pos);
320 unsigned long get_tag_end_position();
349 size_t curpos = tell();
350 return seek(curpos+num);
357 seek(get_tag_end_position());
370 void ensureBytes(
unsigned long needed);
384 #ifndef GNASH_TRUST_SWF_INPUT 385 if ( _tagBoundsStack.empty() )
return;
386 unsigned long int bytesLeft = get_tag_end_position() - tell();
387 unsigned long int bitsLeft = (bytesLeft*8)+m_unused_bits;
388 if ( bitsLeft < needed )
390 std::stringstream ss;
391 ss <<
"premature end of tag: need to read " << needed <<
" bytes, but only " << bitsLeft <<
" left in this tag";
418 std::uint8_t m_current_byte;
419 std::uint8_t m_unused_bits;
421 typedef std::pair<unsigned long,unsigned long> TagBoundaries;
423 std::vector<TagBoundaries> _tagBoundsStack;
430 #endif // GNASH_STREAM_H
A virtual IO channel.
Definition: IOChannel.h:42
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
An SWF parsing exception.
Definition: GnashException.h:89
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
void skip_V32()
Skip a variable length unsigned 32-bit value in the stream. This is faster than doing the bitwise ari...
Definition: SWFStream.h:220
void align()
Consume all bits of current byte.
Definition: SWFStream.h:135
std::uint32_t read_V32()
Read a variable length unsigned 32-bit value from the stream. These values continue until either the ...
Definition: SWFStream.h:191
void ensureBits(unsigned long needed)
Ensure the requested number of bits are available for a bitwise read in currently opened tag...
Definition: SWFStream.h:382
void skip_to_tag_end()
Discard all bytes up to end of tag.
Definition: SWFStream.h:354
#define DSOEXPORT
Definition: dsodefs.h:55
bool skip_bytes(unsigned num)
Discard given number of bytes.
Definition: SWFStream.h:345
SWF stream wrapper class.
Definition: SWFStream.h:58
unsigned read_variable_count()
Read a length in a byte or three.
Definition: SWFStream.h:244