Exemplo n.º 1
0
int main() {
  int selftest;

  MSPACK_SYS_SELFTEST(selftest);
  TEST(selftest == MSPACK_ERR_OK);

  cabd_open_test_01();
  cabd_open_test_02();
  cabd_open_test_03();
  cabd_open_test_04();
  cabd_open_test_05();
  cabd_open_test_06();

  cabd_search_test_01();
  cabd_search_test_02();
  cabd_search_test_03();

  cabd_merge_test_01();
  cabd_merge_test_02();

  /* extract() tests */

  printf("ALL %d TESTS PASSED.\n", test_count);
  return 0;
}
Exemplo n.º 2
0
int main() {
  int selftest;

  MSPACK_SYS_SELFTEST(selftest);
  TEST(selftest == MSPACK_ERR_OK);

  chmd_open_test_01();
  chmd_open_test_02();
  chmd_search_test_01();
  chmd_extract_test_01();

  printf("ALL %d TESTS PASSED.\n", test_count);
  return 0;
}
Exemplo n.º 3
0
int main() {
  struct mscab_decompressor *cabd;
  struct mscabd_cabinet *cab;
  struct mscabd_file *file;
  struct mem_buf source = { &embedded_cab[0], sizeof(embedded_cab) };
  struct mem_buf output;
  int err;

  /* if self-test reveals an error */
  MSPACK_SYS_SELFTEST(err);
  if (err) return 1;

  /* create a cab decompressor using our custom mspack_system interface */
  if ((cabd = mspack_create_cab_decompressor(&mem_system))) {

    /* open a cab file direct from memory */
    if ((cab = cabd->open(cabd, (char *) &source))) {

      /* for all files */
      for (file = cab->files; file; file = file->next) {
	/* fill out our "filename" (memory pointer and length) */
	output.data = (char *) malloc(file->length);
	output.length = file->length;

	/* let cabd extract this file to our memory buffer */
	if (output.data && cabd->extract(cabd, file, (char *) &output)) {
	  exit(1);
	}

	/* dump the memory buffer to stdout (for display purposes) */
	printf("Filename: %s\nContents:\n", file->filename);
	fwrite(output.data, 1, output.length, stdout);

	/* free our buffer */
	free(output.data);
      }
      cabd->close(cabd, cab);
    }
    else {
      fprintf(stderr, "can't open cabinet (%d)\n", cabd->last_error(cabd));
    }
    mspack_destroy_cab_decompressor(cabd);
  }
  else {
    fprintf(stderr, "can't make decompressor\n");
  }
  return 0;

}
Exemplo n.º 4
0
int main(int argc, char *argv[]) {
  struct mscab_decompressor *cabd;
  struct mscabd_cabinet *cab, *c;
  int err;

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

  if ((cabd = mspack_create_cab_decompressor(NULL))) {
    for (argv++; *argv; argv++) {
      if ((cab = cabd->search(cabd, *argv))) {
	for (c = cab; c; c = c->next) rip(*argv, c->base_offset, c->length);
	cabd->close(cabd, cab);
      }
    }
    mspack_destroy_cab_decompressor(cabd);
  }
  return 0;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
/**
 * 
 * Does a self check on the library parameters to make sure that the library
 * compilation is compatible with the client compilation. This is funny scenario
 * and is put in to support different flavours of UNIX operating systems.
 * Essentially the library checks of off_t size.
 *
 * @param         None
 * @return  
 *  On Success    LINUXCAB_SUCCESS
 *  On Error      LINUXCAB_ERR_SEEK, LINUXCAB_ERROR
 *
 **/
unsigned int
SelfTestMspack(void)
{
   int error;
   MSPACK_SYS_SELFTEST(error);

   // test failed ?
   if (error) {
      if (error == MSPACK_ERR_SEEK) { 
         /* Library has been compiled for a different bit version of
          * than the program that uses it. The other explanation
          * is inappropriate .h inclusion, can be solved using configure.h.
          * This is the most common issue, hence addressed specifically
          */
         return LINUXCAB_ERR_SEEK;
      } else {
         // Not a common error. 
         return LINUXCAB_ERROR;
      }
   } 
    
   // Perfectly compatible 
   return LINUXCAB_SUCCESS;
}
Exemplo n.º 7
0
int main(int argc, char *argv[]) {
    struct msszdd_decompressor *szddd;
    struct mskwaj_decompressor *kwajd;
    struct msszddd_header *szdd;
    struct mskwajd_header *kwaj;
    int err;

    if (argc != 3) {
        fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
        return 1;
    }

    /* if self-test reveals an error */
    MSPACK_SYS_SELFTEST(err);
    if (err) {
        fprintf(stderr,"Self test failed err=%d\n",err);
        return 1;
    }

    szddd = mspack_create_szdd_decompressor(NULL);
    kwajd = mspack_create_kwaj_decompressor(NULL);

    if (!szddd || !kwajd) {
        fprintf(stderr, "can't make either SZDD or KWAJ decompressor\n");
        mspack_destroy_szdd_decompressor(szddd);
        mspack_destroy_kwaj_decompressor(kwajd);
        return 1;
    }

    /* open then extract; try SZDD */
    if ((szdd = szddd->open(szddd, argv[1]))) {
        if (szddd->extract(szddd, szdd, argv[2]) != MSPACK_ERR_OK) {
            fprintf(stderr, "%s: SZDD extract error: %s\n", argv[2], ERROR(szddd));
        }
        szddd->close(szddd, szdd);
    }
    else {
        if (szddd->last_error(szddd) == MSPACK_ERR_SIGNATURE) {
            /* try KWAJ */
            if ((kwaj = kwajd->open(kwajd, argv[1]))) {
                if (kwajd->extract(kwajd, kwaj, argv[2]) != MSPACK_ERR_OK) {
                    fprintf(stderr, "%s: KWAJ extract error: %s\n", argv[2], ERROR(kwajd));
                }
                kwajd->close(kwajd, kwaj);
            }
            else {
                fprintf(stderr, "%s: KWAJ open error: %s\n", argv[1], ERROR(kwajd));
            }
        }
        else {
            fprintf(stderr, "%s: SZDD open error: %s\n", argv[1], ERROR(szddd));
        }
    }

    /* decompress in a single step; try KWAJ */
    if (kwajd->decompress(kwajd, argv[1], argv[2]) != MSPACK_ERR_OK) {
        if (kwajd->last_error(kwajd) == MSPACK_ERR_SIGNATURE) {
            if (szddd->decompress(szddd, argv[1], argv[2]) != MSPACK_ERR_OK) {
                fprintf(stderr, "%s -> %s: SZDD decompress error: %s\n", argv[1], argv[2], ERROR(szddd));
            }
        }
        else {
            fprintf(stderr, "%s -> %s: KWAJ decompress error: %s\n", argv[1], argv[2], ERROR(kwajd));
        }
    }

    mspack_destroy_szdd_decompressor(szddd);
    mspack_destroy_kwaj_decompressor(kwajd);
    return 0;
}