steghide  0.5.1
BinaryIO.h
Go to the documentation of this file.
1 /*
2  * steghide 0.5.1 - a steganography program
3  * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  */
20 
21 #ifndef SH_BINARYIO_H
22 #define SH_BINARYIO_H
23 
24 #include <cstdio>
25 #include <string>
26 
27 #include "common.h"
28 
33 class BinaryIO {
34  public:
35  enum MODE { READ, WRITE } ;
36 
37  BinaryIO (void) ;
38 
46  BinaryIO (const std::string& fn, MODE m) ;
47 
48  ~BinaryIO (void) ;
49 
53  const std::string& getName (void) const
54  { return Name ; } ;
55 
59  bool is_open (void) const
60  { return FileOpen ; } ;
61 
65  bool is_std (void) const
66  { return (getStream() != NULL && getName() == "") ; } ;
67 
71  unsigned long getPos (void) const
72  { return ftell(getStream()) ; } ;
73 
77  bool eof (void) const ;
78 
84  void open (const std::string& fn, MODE m) ;
85 
89  void close (void) ;
90 
94  BYTE read8 (void) ;
95 
99  UWORD16 read16_le (void) ;
100 
104  UWORD16 read16_be (void) ;
105 
109  UWORD32 read32_le (void) ;
110 
114  UWORD32 read32_be (void) ;
115 
120  UWORD32 read_le (unsigned short n) ;
121 
125  std::string readstring (unsigned int len) ;
126 
130  void write8 (BYTE val) ;
131 
135  void write16_le (UWORD16 val) ;
136 
140  void write16_be (UWORD16 val) ;
141 
145  void write32_le (UWORD32 val) ;
146 
150  void write32_be (UWORD32 val) ;
151 
157  void write_le (UWORD32 val, unsigned short n) ;
158 
159  void writestring (const std::string& s) ;
160 
164  FILE* getStream (void) const
165  { return Stream ; } ;
166 
167  protected:
168  void setStream (FILE* s)
169  { Stream = s ; } ;
170 
171  void setName (const std::string& fn)
172  { Name = fn ; } ;
173 
174  MODE getMode (void) const
175  { return Mode ; } ;
176 
177  void setMode (MODE m)
178  { Mode = m ; } ;
179 
180  private:
181  std::string Name ;
182  FILE *Stream ;
183  bool FileOpen ;
185 
186  void init (void) ;
187 
188  void set_open (bool o)
189  { FileOpen = o ; } ;
190 
194  void checkForce (const std::string& fn) const ;
195 
200  bool Fileexists (const std::string& fn) const ;
201 } ;
202 
203 #endif /* ndef SH_BINARYIO_H */
BinaryIO::read32_le
UWORD32 read32_le(void)
Definition: BinaryIO.cc:189
BinaryIO
provides methods for file i/o as needed by the rest of steghide
Definition: BinaryIO.h:33
BinaryIO::is_open
bool is_open(void) const
Definition: BinaryIO.h:59
BinaryIO::~BinaryIO
~BinaryIO(void)
Definition: BinaryIO.cc:45
BinaryIO::FileOpen
bool FileOpen
Definition: BinaryIO.h:183
BinaryIO::BinaryIO
BinaryIO(void)
Definition: BinaryIO.cc:34
UWORD32
unsigned long UWORD32
Definition: common.h:45
BinaryIO::read32_be
UWORD32 read32_be(void)
Definition: BinaryIO.cc:204
BinaryIO::set_open
void set_open(bool o)
Definition: BinaryIO.h:188
BinaryIO::write16_le
void write16_le(UWORD16 val)
Definition: BinaryIO.cc:257
BinaryIO::write32_be
void write32_be(UWORD32 val)
Definition: BinaryIO.cc:293
BinaryIO::write32_le
void write32_le(UWORD32 val)
Definition: BinaryIO.cc:281
BinaryIO::getPos
unsigned long getPos(void) const
Definition: BinaryIO.h:71
UWORD16
unsigned short UWORD16
Definition: common.h:46
BinaryIO::Fileexists
bool Fileexists(const std::string &fn) const
Definition: BinaryIO.cc:52
BinaryIO::is_std
bool is_std(void) const
Definition: BinaryIO.h:65
BinaryIO::write_le
void write_le(UWORD32 val, unsigned short n)
Definition: BinaryIO.cc:305
BinaryIO::write16_be
void write16_be(UWORD16 val)
Definition: BinaryIO.cc:269
BinaryIO::read16_le
UWORD16 read16_le(void)
Definition: BinaryIO.cc:159
BYTE
unsigned char BYTE
Definition: common.h:47
BinaryIO::close
void close(void)
Definition: BinaryIO.cc:131
BinaryIO::read16_be
UWORD16 read16_be(void)
Definition: BinaryIO.cc:174
BinaryIO::writestring
void writestring(const std::string &s)
Definition: BinaryIO.cc:318
BinaryIO::getStream
FILE * getStream(void) const
Definition: BinaryIO.h:164
BinaryIO::setMode
void setMode(MODE m)
Definition: BinaryIO.h:177
BinaryIO::read8
BYTE read8(void)
Definition: BinaryIO.cc:146
BinaryIO::setStream
void setStream(FILE *s)
Definition: BinaryIO.h:168
BinaryIO::eof
bool eof(void) const
Definition: BinaryIO.cc:123
BinaryIO::READ
@ READ
Definition: BinaryIO.h:35
BinaryIO::MODE
MODE
Definition: BinaryIO.h:35
BinaryIO::readstring
std::string readstring(unsigned int len)
Definition: BinaryIO.cc:237
common.h
BinaryIO::Mode
MODE Mode
Definition: BinaryIO.h:184
BinaryIO::getName
const std::string & getName(void) const
Definition: BinaryIO.h:53
BinaryIO::setName
void setName(const std::string &fn)
Definition: BinaryIO.h:171
BinaryIO::checkForce
void checkForce(const std::string &fn) const
Definition: BinaryIO.cc:63
BinaryIO::WRITE
@ WRITE
Definition: BinaryIO.h:35
BinaryIO::read_le
UWORD32 read_le(unsigned short n)
Definition: BinaryIO.cc:219
BinaryIO::write8
void write8(BYTE val)
Definition: BinaryIO.cc:247
BinaryIO::getMode
MODE getMode(void) const
Definition: BinaryIO.h:174
BinaryIO::Stream
FILE * Stream
Definition: BinaryIO.h:182
BinaryIO::init
void init(void)
Definition: BinaryIO.cc:27
BinaryIO::Name
std::string Name
Definition: BinaryIO.h:178
BinaryIO::open
void open(const std::string &fn, MODE m)
Definition: BinaryIO.cc:76