Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ztxt.h

Go to the documentation of this file.
00001 #ifndef __ztxt_h
00002 #define __ztxt_h
00003 
00004 #include "CExpander.h"
00005 #include <zlib.h>
00006 #include "pdb.h"
00007 #ifdef _WINDOWS
00008 #include <winsock.h>
00009 #endif
00010 
00011 /*
00012  * Stuff common to both Weasel Reader and makeztxt
00013  *
00014  * $Id: ztxt.h,v 1.11 2004/02/28 11:21:06 tim Exp tim $
00015  *
00016  */
00017 
00018 #ifndef _WEASEL_COMMON_H_
00019 #define _WEASEL_COMMON_H_ 1
00020 
00021 
00022 /* Padding is no good */
00023 #if defined(__GNUC__) && defined(__UNIX__)
00024 //#  pragma pack(2)
00025 #endif
00026 
00027 /*  The default creator is Weasel Reader 'GPlm'  */
00028 #define GPLM_CREATOR_ID         "GPlm"
00029 /*  Databases of type 'zTXT'  */
00030 #define ZTXT_TYPE_ID            "zTXT"
00031 /*  Size of one database record  */
00032 #define RECORD_SIZE             8192
00033 /*  Allow largest WBIT size for data.  Lower with command line options
00034     in makeztxt  */
00035 #define MAXWBITS                15
00036 /* Max length for a bookmark/annotation title */
00037 #define MAX_BMRK_LENGTH         20
00038 
00039 
00040 /*****************************************************
00041  *   This is the zTXT document header (record #0)    *
00042  *            ----zTXT version 1.42----              *
00043  *****************************************************/
00044 typedef struct zTXT_record0Type {
00045     UInt16        version;                /* zTXT format version              */
00046     UInt16        numRecords;             /* Number of data (TEXT) records    */
00047     UInt32        size;                   /* Size in bytes of uncomp. data    */
00048     UInt16        recordSize;             /* Size of a single data record     */
00049     UInt16        numBookmarks;           /* Number of bookmarks in DB        */
00050     UInt16        bookmarkRecord;         /* Record containing bookmarks      */
00051     UInt16        numAnnotations;         /* Number of annotation records     */
00052     UInt16        annotationRecord;       /* Record # of annotation index     */
00053     UInt8         randomAccess;           /* 1 if compressed w/Z_FULL_FLUSH   */
00054     UInt8         padding[0x20 - 19];     /* Pad to a size of 0x20 bytes      */
00055 } zTXT_record0;
00056 
00057 struct zTXTbkmk
00058 {
00059     UInt32 offset;
00060     unsigned char title[MAX_BMRK_LENGTH];
00061 };
00062 
00063 #endif
00064 
00065 
00066 const UInt32 ZTXT_ID = 0x5458547a;
00067 
00068 class ztxt : public Cpdb
00069 {
00070     bool bInit;
00071     UInt32 buffersize;
00072     UInt32 buffercontent;
00073     UInt8* expandedtextbuffer;
00074     UInt8* compressedtextbuffer;
00075     z_stream zstream;
00076     size_t bufferpos;
00077     UInt16 bufferrec;
00078     zTXT_record0 hdr0;
00079     size_t currentpos;
00080     void home();
00081 public:
00082     QString about() { return QString("Weasel codec (c) Tim Wentford"); }
00083     void sizes(unsigned long& _file, unsigned long& _text)
00084         {
00085             _file = file_length;
00086             _text = ntohl(hdr0.size);
00087         }
00088     bool hasrandomaccess() { return (hdr0.randomAccess != 0); }
00089     virtual ~ztxt()
00090         {
00091             if (expandedtextbuffer != NULL) delete [] expandedtextbuffer;
00092             if (compressedtextbuffer != NULL) delete [] compressedtextbuffer;
00093             if (bInit)
00094             {
00095                 inflateEnd(&zstream);
00096             }
00097         }
00098     ztxt();
00099     int OpenFile(const char *src);
00100     int getch();
00101     unsigned int locate();
00102     void locate(unsigned int n);
00103     CList<Bkmk>* getbkmklist();
00104     MarkupType PreferredMarkup()
00105         {
00106             return cTEXT;
00107         }
00108 };
00109 
00110 #endif

Generated on Sat Nov 5 16:16:59 2005 for OPIE by  doxygen 1.4.2