Rizin
unix-like reverse engineering framework and cli tools
msexpand.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mspack.h>
#include <error.h>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 13 of file msexpand.c.

13  {
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(* 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

References argv, mskwaj_decompressor::decompress, msszdd_decompressor::decompress, err, mspack_create_kwaj_decompressor(), mspack_create_szdd_decompressor(), mspack_destroy_kwaj_decompressor(), mspack_destroy_szdd_decompressor(), MSPACK_ERR_OK, MSPACK_ERR_SIGNATURE, MSPACK_SYS_SELFTEST, and NULL.