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
33class 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 */
provides methods for file i/o as needed by the rest of steghide
Definition: BinaryIO.h:33
std::string readstring(unsigned int len)
Definition: BinaryIO.cc:237
MODE getMode(void) const
Definition: BinaryIO.h:174
BinaryIO(void)
Definition: BinaryIO.cc:34
void writestring(const std::string &s)
Definition: BinaryIO.cc:318
BYTE read8(void)
Definition: BinaryIO.cc:146
UWORD32 read_le(unsigned short n)
Definition: BinaryIO.cc:219
MODE
Definition: BinaryIO.h:35
@ WRITE
Definition: BinaryIO.h:35
@ READ
Definition: BinaryIO.h:35
unsigned long getPos(void) const
Definition: BinaryIO.h:71
void write8(BYTE val)
Definition: BinaryIO.cc:247
UWORD32 read32_le(void)
Definition: BinaryIO.cc:189
bool eof(void) const
Definition: BinaryIO.cc:123
void write32_le(UWORD32 val)
Definition: BinaryIO.cc:281
void setStream(FILE *s)
Definition: BinaryIO.h:168
UWORD32 read32_be(void)
Definition: BinaryIO.cc:204
void write_le(UWORD32 val, unsigned short n)
Definition: BinaryIO.cc:305
void write32_be(UWORD32 val)
Definition: BinaryIO.cc:293
void open(const std::string &fn, MODE m)
Definition: BinaryIO.cc:76
void close(void)
Definition: BinaryIO.cc:131
bool is_std(void) const
Definition: BinaryIO.h:65
~BinaryIO(void)
Definition: BinaryIO.cc:45
UWORD16 read16_le(void)
Definition: BinaryIO.cc:159
void setName(const std::string &fn)
Definition: BinaryIO.h:171
FILE * Stream
Definition: BinaryIO.h:182
MODE Mode
Definition: BinaryIO.h:184
void setMode(MODE m)
Definition: BinaryIO.h:177
void write16_be(UWORD16 val)
Definition: BinaryIO.cc:269
bool FileOpen
Definition: BinaryIO.h:183
bool Fileexists(const std::string &fn) const
Definition: BinaryIO.cc:52
bool is_open(void) const
Definition: BinaryIO.h:59
void init(void)
Definition: BinaryIO.cc:27
const std::string & getName(void) const
Definition: BinaryIO.h:53
UWORD16 read16_be(void)
Definition: BinaryIO.cc:174
FILE * getStream(void) const
Definition: BinaryIO.h:164
void checkForce(const std::string &fn) const
Definition: BinaryIO.cc:63
std::string Name
Definition: BinaryIO.h:178
void set_open(bool o)
Definition: BinaryIO.h:188
void write16_le(UWORD16 val)
Definition: BinaryIO.cc:257
unsigned char BYTE
Definition: common.h:47
unsigned long UWORD32
Definition: common.h:45
unsigned short UWORD16
Definition: common.h:46