Rizin
unix-like reverse engineering framework and cli tools
msexpand.c
Go to the documentation of this file.
1 /* acts like Microsoft's EXPAND.EXE */
2 #ifdef HAVE_CONFIG_H
3 #include <config.h>
4 #endif
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 
10 #include <mspack.h>
11 #include <error.h>
12 
13 int main(int argc, char *argv[]) {
14  struct msszdd_decompressor *szddd;
15  struct mskwaj_decompressor *kwajd;
16  int err;
17 
18  if (argc != 3) {
19  fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
20  return 1;
21  }
22 
23  /* exit if self-test reveals an error */
25  if (err) return 1;
26 
29 
30  if (szddd && kwajd) {
31  err = szddd->decompress(szddd, argv[1], argv[2]);
32  /* if not SZDD file, try decompressing as KWAJ */
33  if (err == MSPACK_ERR_SIGNATURE) {
34  err = kwajd->decompress(kwajd, argv[1], argv[2]);
35  }
36  if (err != MSPACK_ERR_OK) {
37  fprintf(stderr, "%s -> %s: %s\n", argv[1], argv[2], error_msg(err));
38  }
39  }
40  else {
41  fprintf(stderr, "can't create SZDD/KWAJ decompressor\n");
42  err = 1;
43  }
44 
47  return err ? 1 : 0;
48 }
static bool err
Definition: armass.c:435
#define MSPACK_ERR_OK
Definition: mspack.h:485
#define MSPACK_SYS_SELFTEST(result)
Definition: mspack.h:191
struct msszdd_decompressor * mspack_create_szdd_decompressor(struct mspack_system *sys)
Definition: szddd.c:41
#define MSPACK_ERR_SIGNATURE
Definition: mspack.h:499
void mspack_destroy_szdd_decompressor(struct msszdd_decompressor *self)
Definition: szddd.c:65
struct mskwaj_decompressor * mspack_create_kwaj_decompressor(struct mspack_system *sys)
Definition: kwajd.c:55
void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *self)
Definition: kwajd.c:79
#define NULL
Definition: cris-opc.c:27
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
int main(int argc, char *argv[])
Definition: msexpand.c:13
int(* decompress)(struct mskwaj_decompressor *self, const char *input, const char *output)
Definition: mspack.h:2228
int(* decompress)(struct msszdd_decompressor *self, const char *input, const char *output)
Definition: mspack.h:1949