X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;f=pc-tools%2Fldc2%2Fsrc%2Ftape_block.hh;h=ebd8f025d2753e1faab44d133c7c1557688f70c4;hb=4741aa72fcdfe52497013c7cbbeaa0bde9be3564;hp=f023ead0d05aa1dd6cbb38f3043599be1c82803a;hpb=6c06db96fb1c7482f8cb7e1d14eee91603fbb894;p=h316.git diff --git a/pc-tools/ldc2/src/tape_block.hh b/pc-tools/ldc2/src/tape_block.hh index f023ead..ebd8f02 100644 --- a/pc-tools/ldc2/src/tape_block.hh +++ b/pc-tools/ldc2/src/tape_block.hh @@ -1,8 +1,19 @@ -#ifndef TAPE_BLOCK_H -#define TAPE_BLOCK_H - -#include -#include +/****************************************************************************** + * + * LDC2 source code + * + * $Date: 2007/03/26 01:00:40 $ + * $Author: hachti $ + * + * $Log: tape_block.hh,v $ + * Revision 2.0 2007/03/26 01:00:40 hachti + * *** empty log message *** + * + * + ******************************************************************************/ + +#ifndef TAPE_BLOCK_HH +#define TAPE_BLOCK_HH using namespace std; @@ -13,51 +24,102 @@ using namespace std; * That may be some kind of data block or a end of tape mark. */ class tape_block{ - + public: // types - - /*! - *\brief Initialisation state. - */ - typedef enum { - TBS_OK, //!< Block successfully initialised - TBS_EOF_LEGAL, //!< Legal EOF while initialising - TBS_EOF_ILLEGAL, //!< Illegal EOF while initialising - TBS_CHECKSUM, //!< Checksum error - TBS_IOERR, //!< I/O-Error while reading - TBS_DEFAULT //!< Block not initialised. - } tb_state_t; - + /*! * Tape block types. */ typedef enum { TBT_DATA=0x10, //!< Data block TBT_EOT, //!< End of tape block - TBT_DISCARD //!< Invalid block, check block_type + TBT_BROKEN, //!< A broken block } tb_type_t; - + + /*! + *\brief Local base class for exceptions. + */ + class exception { + protected: + exception(); + public: + virtual ~exception(); + tape_block * get_block(); + protected: + tape_block * m_broken_block; + }; + + /*! + *\brief Checksum error exception. + */ + class checksum_error_exception + : public exception { + public: + checksum_error_exception(tape_block * block); + }; + + /*! + *\brief EOF while reading block exception. + */ + class eof_illegal_exception + : public exception { + public: + eof_illegal_exception(tape_block * block); + }; + + /*! + *\brief EOF after reading block exception. + */ + class eof_legal_exception + : public exception { + public: + eof_legal_exception(int bytes_consumed); + int get_consumed(); + private: + int bytes_consumed; + tape_block * get_block(); + }; + + /*! + *\brief IO error exception. + */ + class io_error_exception + : exception { + public: + io_error_exception(); + private: + tape_block * get_block(); + }; + public: // methods virtual ~tape_block(); tape_block(tape_block &); void operator=(tape_block &); - - tb_state_t get_state(); + virtual int get_type(); virtual int get_subtype(); virtual vector get_description(); int get_raw_size(); + int get_discarded_bytes(); unsigned char * get_raw_data(); - + virtual int dump_to_fd(int fd); + virtual bool is_endblock(); + virtual vector get_exported_symbols(); + virtual vector get_called_symbols(); + virtual bool has_known_type(); + static tape_block * gen_from_fd(int fd, void(*input_start)(void *)=0, void (*input_stop)(void *)=0, void * start_stop_arg=0 ); - -private: // methods + +protected: // methods tape_block(); + string get_typestring(); + +private: // methods tape_block (int fd_p, void(*input_start)(void *)=0, void (*input_stop)(void *)=0, @@ -66,16 +128,16 @@ private: // methods int init_words(void); int test_checksum(); - + protected: // members int block_type; //!< Type of this block. - tb_state_t init_state; //!< Initialisation state. - int data_read; //!< Total data consumption during intialisation. + bool m_has_known_type; //!< Block is of a documented type. + int discarded_bytes; //!< Amount of bytes discarded before beginning. unsigned char * raw_data; //!< Raw block data in bytes. int raw_size; //!< Size of the raw data. unsigned short * word_data; //!< Data organized in machine words. int word_size; //!< Size of the blocks in machine words. + int poolsize; //!< Amount of data malloc'ed }; // class tape_block - #endif