Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

BinaryIO.h

Go to the documentation of this file.
00001 /* 00002 * steghide 0.5.1 - a steganography program 00003 * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at> 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 * 00019 */ 00020 00021 #ifndef SH_BINARYIO_H 00022 #define SH_BINARYIO_H 00023 00024 #include <cstdio> 00025 #include <string> 00026 00027 #include "common.h" 00028 00033 class BinaryIO { 00034 public: 00035 enum MODE { READ, WRITE } ; 00036 00037 BinaryIO (void) ; 00038 00046 BinaryIO (const std::string& fn, MODE m) ; 00047 00048 ~BinaryIO (void) ; 00049 00053 const std::string& getName (void) const 00054 { return Name ; } ; 00055 00059 bool is_open (void) const 00060 { return FileOpen ; } ; 00061 00065 bool is_std (void) const 00066 { return (getStream() != NULL && getName() == "") ; } ; 00067 00071 unsigned long getPos (void) const 00072 { return ftell(getStream()) ; } ; 00073 00077 bool eof (void) const ; 00078 00084 void open (const std::string& fn, MODE m) ; 00085 00089 void close (void) ; 00090 00094 BYTE read8 (void) ; 00095 00099 UWORD16 read16_le (void) ; 00100 00104 UWORD16 read16_be (void) ; 00105 00109 UWORD32 read32_le (void) ; 00110 00114 UWORD32 read32_be (void) ; 00115 00120 UWORD32 read_le (unsigned short n) ; 00121 00125 std::string readstring (unsigned int len) ; 00126 00130 void write8 (BYTE val) ; 00131 00135 void write16_le (UWORD16 val) ; 00136 00140 void write16_be (UWORD16 val) ; 00141 00145 void write32_le (UWORD32 val) ; 00146 00150 void write32_be (UWORD32 val) ; 00151 00157 void write_le (UWORD32 val, unsigned short n) ; 00158 00159 void writestring (const std::string& s) ; 00160 00164 FILE* getStream (void) const 00165 { return Stream ; } ; 00166 00167 protected: 00168 void setStream (FILE* s) 00169 { Stream = s ; } ; 00170 00171 void setName (const std::string& fn) 00172 { Name = fn ; } ; 00173 00174 MODE getMode (void) const 00175 { return Mode ; } ; 00176 00177 void setMode (MODE m) 00178 { Mode = m ; } ; 00179 00180 private: 00181 std::string Name ; 00182 FILE *Stream ; 00183 bool FileOpen ; 00184 MODE Mode ; 00185 00186 void init (void) ; 00187 00188 void set_open (bool o) 00189 { FileOpen = o ; } ; 00190 00194 void checkForce (const std::string& fn) const ; 00195 00200 bool Fileexists (const std::string& fn) const ; 00201 } ; 00202 00203 #endif /* ndef SH_BINARYIO_H */

Generated on Fri Jul 16 19:41:20 2004 for steghide by doxygen 1.3.7