summaryrefslogtreecommitdiff
path: root/VP/decomp-slz.cpp
blob: 076d3bdf9fe72f7bd96e1cc4c971a88cd89f0346 (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
#include <stdio.h>
#include <stdlib.h>

#include "lzss.h"
#include "Input.h"
#include "Output.h"
#include "Main.h"

CODE_BEGINS
public:
Appli() : lzss_o(new lzss) {}
virtual ~Appli() {
    delete lzss_o;
}
private:

lzss * lzss_o;

virtual int startup() throw (GeneralException) {
    int sig, l, d, v;
    Handle * fin = &Stdin, * fout = &Stdout;
    
    switch (argc) {
    case 3:
	fout = new Output(argv[2]);
    case 2:
	fin = new Input(argv[1]);
	break;
    case 1:
	break;
    default:
	printm(M_BARE, "Usage: %s [filein] [fileout]\n", argv[0]);
	return -1;
    }
    
    verbosity = M_STATUS;
    
    fin->read(&sig, 4);
    fin->read(&d, 4);
    fin->read(&l, 4);
    switch (sig) {
    case 0x05a4c53:
	printm(M_STATUS, "Detected a SLZ-type 0 file.\n");
	fin->read(&v, 4);
	copy(fin, fout, d);
	return 0;
    case 0x15a4c53:
	lzss_o->change_scheme(lzss_o->schemes[lzss_o->VP_1]);
	printm(M_STATUS, "Detected a SLZ-type 1 file.\n");
	break;
    case 0x25a4c53:
	lzss_o->change_scheme(lzss_o->schemes[lzss_o->VP_2]);
	printm(M_STATUS, "Detected a SLZ-type 2 file.\n");
	break;
    default:
	printm(M_ERROR, "Not a SLZ file.\n");
	return -1;
    }
    
    lzss_o->lzss_decomp(fin, fout, l);
    return 0;
}
CODE_ENDS