17
#ifndef NO_SWORD_NAMESPACE
18
using namespace sword;
21
class FileCompress: public SWCompress {
29
unsigned long GetChars(char *, unsigned long len);
30
unsigned long SendChars(char *, unsigned long len);
36
FileCompress::FileCompress(char *fname)
44
ufd = open(fname, O_RDWR|O_CREAT|O_BINARY, 00644);
46
sprintf(buf, "%s.zzz", fname);
47
zfd = open(buf, O_RDWR|O_CREAT|O_BINARY, 00644);
51
FileCompress::~FileCompress()
58
unsigned long FileCompress::GetChars(char *buf, unsigned long len)
60
return read(ifd, buf, len);
64
unsigned long FileCompress::SendChars(char *buf, unsigned long len)
66
return write(ofd, buf, len);
70
void FileCompress::Encode()
79
void FileCompress::Decode()
88
int main(int argc, char **argv)
94
fprintf(stderr, "usage: %s <filename|filename.zzz>\n", argv[0]);
98
if (strlen(argv[1]) > 4) {
99
if (!strcmp(&argv[1][strlen(argv[1])-4], ".zzz")) {
100
argv[1][strlen(argv[1])-4] = 0;
105
fobj = new FileCompress(argv[1]);