2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2007-06-25 19:50:25 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2007-06-25 19:50:25 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-06-25 19:50:25 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup imbdds
|
2011-02-27 20:23:21 +00:00
|
|
|
*/
|
|
|
|
|
|
2007-06-25 19:50:25 +00:00
|
|
|
/* simple memory stream functions with buffer overflow check */
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2007-06-25 19:50:25 +00:00
|
|
|
|
2015-04-07 11:25:42 +10:00
|
|
|
struct Stream {
|
2007-06-25 19:50:25 +00:00
|
|
|
unsigned char *mem; /* location in memory */
|
|
|
|
|
unsigned int size; /* size */
|
|
|
|
|
unsigned int pos; /* current position */
|
2019-08-01 13:53:25 +10:00
|
|
|
bool failed; /* error occurred when seeking */
|
2019-04-16 03:39:29 +02:00
|
|
|
Stream(unsigned char *m, unsigned int s) : mem(m), size(s), pos(0), failed(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
unsigned int seek(unsigned int p);
|
2019-04-16 03:39:29 +02:00
|
|
|
void set_failed(const char *msg);
|
2007-06-25 19:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
unsigned int mem_read(Stream &mem, unsigned long long &i);
|
|
|
|
|
unsigned int mem_read(Stream &mem, unsigned int &i);
|
|
|
|
|
unsigned int mem_read(Stream &mem, unsigned short &i);
|
|
|
|
|
unsigned int mem_read(Stream &mem, unsigned char &i);
|
2007-10-12 16:09:59 +00:00
|
|
|
unsigned int mem_read(Stream &mem, unsigned char *i, unsigned int cnt);
|