1 #ifndef ZOIDBERG_MAIL_MESSAGE_IO_H 2 #define ZOIDBERG_MAIL_MESSAGE_IO_H 3 /* MessageIO - Glue code for reading/writing messages directly from the 4 ** protocols but present a BPositionIO interface to the caller, while caching 5 ** the data read/written in a slave file. 6 ** 7 ** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. 8 */ 9 10 11 #include <DataIO.h> 12 #include <Path.h> 13 #include <Message.h> 14 15 class SimpleMailProtocol; 16 17 class BMailMessageIO : public BPositionIO { 18 public: 19 BMailMessageIO(SimpleMailProtocol *protocol, BPositionIO *dump_to, int32 seq_id); 20 ~BMailMessageIO(); 21 22 //----BPositionIO 23 virtual ssize_t ReadAt(off_t pos, void *buffer, size_t amountToRead); 24 virtual ssize_t WriteAt(off_t pos, const void *buffer, size_t amountToWrite); 25 26 virtual off_t Seek(off_t position, uint32 seek_mode); 27 virtual off_t Position() const; 28 29 private: 30 void ResetSize(void); 31 32 BPositionIO *slave; 33 int32 message_id; 34 SimpleMailProtocol *network; 35 36 size_t size; 37 enum MessageIOStateEnum { 38 READ_HEADER_NEXT, 39 READ_BODY_NEXT, 40 ALL_READING_DONE 41 } state; 42 }; 43 44 #endif /* ZOIDBERG_MAIL_MESSAGE_IO_H */ 45