kpilot

makedoc9.h

Go to the documentation of this file.
00001 #ifndef MAKEDOC_H
00002 #define MAKEDOC_H
00003 // based on: MakeDoc, version 2
00004 // I only took the tBuf class from there and adapted it.
00005 //
00006 // Compresses text files into a format that is ready to export to a Pilot
00007 // and work with Rick Bram's PilotDOC reader.
00008 // Copyright (C) Reinhold Kainhofer, 2002
00009 // Copyrigth (C) Pat Beirne, 2000
00010 //
00011 // Original file (makedoc9.cpp) copyright by:
00012 // Copyright (C) Pat Beirne, 2000.
00013 // Distributable under the GNU General Public License Version 2 or later.
00014 //
00015 // ver 0.6 enforce 31 char limit on database names
00016 // ver 0.7 change header and record0 to structs
00017 // ver 2.0 added category control on the command line
00018 //              changed extensions from .prc to .pdb
00019 
00020 /*
00021 ** This program is free software; you can redistribute it and/or modify
00022 ** it under the terms of the GNU General Public License as published by
00023 ** the Free Software Foundation; either version 2 of the License, or
00024 ** (at your option) any later version.
00025 **
00026 ** This program is distributed in the hope that it will be useful,
00027 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00028 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00029 ** GNU General Public License for more details.
00030 **
00031 ** You should have received a copy of the GNU General Public License
00032 ** along with this program in a file called COPYING; if not, write to
00033 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00034 ** MA 02110-1301, USA.
00035 */
00036 
00037 #include <stdio.h>
00038 
00039 typedef unsigned char byte;
00040 typedef unsigned long DWORD;
00041 typedef unsigned short WORD;
00042 
00043 #define DISP_BITS 11
00044 #define COUNT_BITS 3
00045 
00046 
00047 
00048 
00056 
00057 
00058 class tBuf {
00059  private:
00060 //      byte hichar[10];
00061 //      int hicharnum;
00062 //      bool space;
00063 
00064     byte * buf;
00065     unsigned len;
00066     bool isCompressed;
00067  public:
00068      tBuf() {
00069         buf = 0L;
00070         len=0;
00071         isCompressed=false;
00072     };
00073 
00074     ~tBuf()
00075     {
00076         if (buf)
00077             delete[]buf;
00078     }
00079 
00080     void Clear() {
00081         delete[]buf;
00082         buf = 0L;
00083     }
00084     void setText(const byte * text, unsigned int txtlen =
00085         0, bool txtcomp = false);
00086     byte *text() const {
00087         return buf;
00088     }
00089     unsigned Len() const {
00090         return len;
00091     }
00092     void setCompressed(bool compressed = true) {
00093         isCompressed = compressed;
00094     }
00095     bool compressed() const {
00096         return isCompressed;
00097     }
00098     unsigned RemoveBinary();
00099     unsigned DuplicateCR();
00100 
00101     unsigned Decompress();
00102     unsigned Compress();
00103 
00104  private:
00105     unsigned Issue(byte src, int &bSpace);
00106     void Dump() const {
00107         printf("\nbuffer len=%d", len);
00108 }};
00109 
00110 
00111 #endif