1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <mspack.h>
9
10 #include <error.h>
11
main(int argc,char * argv[])12 int main(int argc, char *argv[]) {
13 struct msoab_decompressor *oabd;
14 int err;
15
16 setbuf(stdout, NULL);
17 setbuf(stderr, NULL);
18
19 MSPACK_SYS_SELFTEST(err);
20 if (err) return 0;
21
22 if ((oabd = mspack_create_oab_decompressor(NULL))) {
23 if (argc == 3) {
24 err = oabd->decompress(oabd, argv[1], argv[2]);
25 if (err) fprintf(stderr, "%s -> %s: %s\n", argv[1], argv[2], error_msg(err));
26 }
27 else if (argc == 4) {
28 err = oabd->decompress_incremental(oabd, argv[2], argv[1], argv[3]);
29 if (err) fprintf(stderr, "%s + %s -> %s: %s\n", argv[1], argv[2], argv[3], error_msg(err));
30 }
31 else {
32 fprintf(stderr, "Usage: %s <input> <output>\n", *argv);
33 fprintf(stderr, " or %s <base> <patch> <output>\n", *argv);
34 }
35 mspack_destroy_oab_decompressor(oabd);
36 }
37 else {
38 fprintf(stderr, "%s: can't make OAB decompressor\n", *argv);
39 }
40 return 0;
41 }
42