summaryrefslogtreecommitdiffstats
path: root/kpilot/conduits/docconduit/makedoc9.h
blob: 27e3695d4b5509572b3f1f067f24db2d914f3cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef MAKEDOC_H
#define MAKEDOC_H
// based on: MakeDoc, version 2
// I only took the tBuf class from there and adapted it.
//
// Compresses text files into a format that is ready to export to a Pilot
// and work with Rick Bram's PilotDOC reader.
// Copyright (C) Reinhold Kainhofer, 2002
// Copyrigth (C) Pat Beirne, 2000
//
// Original file (makedoc9.cpp) copyright by:
// Copyright (C) Pat Beirne, 2000.
// Distributable under the GNU General Public License Version 2 or later.
//
// ver 0.6 enforce 31 char limit on database names
// ver 0.7 change header and record0 to structs
// ver 2.0 added category control on the command line
//              changed extensions from .prc to .pdb

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

#include <stdio.h>

typedef unsigned char byte;
typedef unsigned long DWORD;
typedef unsigned short WORD;

#define DISP_BITS 11
#define COUNT_BITS 3




/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////                                  //////////////////////
/////////////////////      tBuf class                  //////////////////////
/////////////////////                                  //////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////


class tBuf {
 private:
//      byte hichar[10];
//      int hicharnum;
//      bool space;

	byte * buf;
	unsigned len;
	bool isCompressed;
 public:
	 tBuf() {
		buf = 0L;
		len=0;
		isCompressed=false;
	};

	~tBuf()
	{
		if (buf)
			delete[]buf;
	}

	void Clear() {
		delete[]buf;
		buf = 0L;
	}
	void setText(const byte * text, unsigned int txtlen =
		0, bool txtcomp = false);
	byte *text() const {
		return buf;
	}
	unsigned Len() const {
		return len;
	}
	void setCompressed(bool compressed = true) {
		isCompressed = compressed;
	}
	bool compressed() const {
		return isCompressed;
	}
	unsigned RemoveBinary();
	unsigned DuplicateCR();

	unsigned Decompress();
	unsigned Compress();

 private:
	unsigned Issue(byte src, int &bSpace);
	void Dump() const {
		printf("\nbuffer len=%d", len);
}};


#endif