-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsexpand.c
48 lines (40 loc) · 1.22 KB
/
msexpand.c
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
/* acts like Microsoft's EXPAND.EXE */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mspack.h>
//#include <error.h>
int main(int argc, char *argv[]) {
struct msszdd_decompressor *szddd;
struct mskwaj_decompressor *kwajd;
int err;
if (argc != 3) {
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
return 1;
}
/* exit if self-test reveals an error */
MSPACK_SYS_SELFTEST(err);
if (err) return 1;
szddd = mspack_create_szdd_decompressor(NULL);
kwajd = mspack_create_kwaj_decompressor(NULL);
if (szddd && kwajd) {
err = szddd->decompress(szddd, argv[1], argv[2]);
/* if not SZDD file, try decompressing as KWAJ */
if (err == MSPACK_ERR_SIGNATURE) {
err = kwajd->decompress(kwajd, argv[1], argv[2]);
}
if (err != MSPACK_ERR_OK) {
// fprintf(stderr, "%s -> %s: %s\n", argv[1], argv[2], error_msg(err));
}
}
else {
fprintf(stderr, "can't create SZDD/KWAJ decompressor\n");
err = 1;
}
mspack_destroy_szdd_decompressor(szddd);
mspack_destroy_kwaj_decompressor(kwajd);
return err ? 1 : 0;
}