File: oabextract.c

package info (click to toggle)
libmspack 0.11-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,880 kB
  • sloc: ansic: 8,128; sh: 4,660; perl: 320; makefile: 100
file content (41 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (11)
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
#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 msoab_decompressor *oabd;
    int err;

    setbuf(stdout, NULL);
    setbuf(stderr, NULL);

    MSPACK_SYS_SELFTEST(err);
    if (err) return 0;

    if ((oabd = mspack_create_oab_decompressor(NULL))) {
        if (argc == 3) {
            err = oabd->decompress(oabd, argv[1], argv[2]);
            if (err) fprintf(stderr, "%s -> %s: %s\n", argv[1], argv[2], error_msg(err));
        }
        else if (argc == 4) {
            err = oabd->decompress_incremental(oabd, argv[2], argv[1], argv[3]);
            if (err) fprintf(stderr, "%s + %s -> %s: %s\n", argv[1], argv[2], argv[3], error_msg(err));
        }
        else {
            fprintf(stderr, "Usage: %s <input> <output>\n", *argv);
            fprintf(stderr, "   or  %s <base> <patch> <output>\n", *argv);
        }
        mspack_destroy_oab_decompressor(oabd);
    }
    else {
        fprintf(stderr, "%s: can't make OAB decompressor\n", *argv);
    }
    return 0;
}