summaryrefslogtreecommitdiff
path: root/VP/decomp-slz.cpp
diff options
context:
space:
mode:
authorPixel <Pixel>2002-09-27 12:17:57 +0000
committerPixel <Pixel>2002-09-27 12:17:57 +0000
commitbfa5de7eccf4604ff8217f619e9685a09e80d545 (patch)
treea5be5de750ac611145f459a09bda902c3dbc1a70 /VP/decomp-slz.cpp
parent60c1003845035ad4cd0e9ea50862bad7626faf0e (diff)
The week-without-the-network changes
Diffstat (limited to 'VP/decomp-slz.cpp')
-rw-r--r--VP/decomp-slz.cpp52
1 files changed, 29 insertions, 23 deletions
diff --git a/VP/decomp-slz.cpp b/VP/decomp-slz.cpp
index fa09411..076d3bd 100644
--- a/VP/decomp-slz.cpp
+++ b/VP/decomp-slz.cpp
@@ -2,56 +2,62 @@
#include <stdlib.h>
#include "lzss.h"
-#include "fileutils.h"
-#include "generic.h"
+#include "Input.h"
+#include "Output.h"
+#include "Main.h"
-int main(int argc, char ** argv) {
+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;
- FILE * fin = stdin, * fout = stdout;
+ Handle * fin = &Stdin, * fout = &Stdout;
switch (argc) {
case 3:
- if (!(fout = fopen(argv[2], "w"))) {
- printm(M_ERROR, "Error opening file %s.\n", argv[3]);
- exit(-1);
- }
+ fout = new Output(argv[2]);
case 2:
- if (!(fin = fopen(argv[1], "r"))) {
- printm(M_ERROR, "Error opening file %s.\n", argv[2]);
- exit(-1);
- }
+ fin = new Input(argv[1]);
break;
case 1:
break;
default:
printm(M_BARE, "Usage: %s [filein] [fileout]\n", argv[0]);
- exit(-1);
+ return -1;
}
verbosity = M_STATUS;
- fread(&sig, 1, 4, fin);
- fread(&d, 1, 4, fin);
- fread(&l, 1, 4, fin);
+ 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");
- fread(&v, 1, 4, fin);
+ fin->read(&v, 4);
copy(fin, fout, d);
- exit(0);
+ return 0;
case 0x15a4c53:
- scheme = schemes[VP_1];
+ lzss_o->change_scheme(lzss_o->schemes[lzss_o->VP_1]);
printm(M_STATUS, "Detected a SLZ-type 1 file.\n");
break;
case 0x25a4c53:
- scheme = schemes[VP_2];
+ 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");
- exit(-1);
+ return -1;
}
- lzss_decomp(fin, fout, l);
- exit(0);
+ lzss_o->lzss_decomp(fin, fout, l);
+ return 0;
}
+CODE_ENDS