-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLine.h
112 lines (83 loc) · 1.59 KB
/
Line.h
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
112
/*========================================================================*/
/* Compress v1.0 ---- Line Coding */
/*========================================================================*/
/*========================================================================*/
#ifndef _FILE_
#include "file.h"
#endif
/*========================================================================*/
#define _LINE_ 0
#ifndef false
#define false 0
#define true 1
typedef int bool;
#endif
/*========================================================================*/
bool C_Line ();
bool E_Line ();
/*========================================================================*/
bool C_Line ()
{
long l;
char c,ch,t;
int count=0;
c=ReadByte();
for (l=0;l<Rfile.len;l++)
{
ch=ReadByte();
if (c==ch && count<255)
{
count++;
continue;
}
t=c;
c=ch;
ch=t;
WriteByte(ch);
if (count)
{
WriteByte(ch);
WriteByte((unsigned char)count);
count=0;
}
}
FlushFile();
return true;
}
/*========================================================================*/
bool E_Line ()
{
long l;
char c,ch;
int count;
c=ReadByte();
WriteByte(c);
for (l=1;l<Rfile.len;l++)
{
ch=ReadByte();
WriteByte(ch);
if (c==ch && l<Rfile.len-1)
{
count=(unsigned char)ReadByte();
l++;
count--;
while (count)
{
WriteByte(ch);
count--;
}
if (l<Rfile.len-1)
{
c=ReadByte();
WriteByte(c);
l++;
}
}
else
c=ch;
}
FlushFile();
return true;
}
/*========================================================================*/