7 #include "libmpq/mpq.h"
9 typedef PerlIO * OutputStream;
10 typedef mpq_archive * Archive__MoPaQ;
13 MODULE = Archive::MoPaQ PACKAGE = Archive::MoPaQ
15 Archive::MoPaQ init(package)
18 RETVAL = malloc(sizeof(mpq_archive));
19 memset(RETVAL, 0, sizeof(mpq_archive));
23 int open(mpqa,filename)
27 RETVAL = libmpq_archive_open(mpqa, filename);
34 RETVAL = libmpq_archive_info(mpqa, LIBMPQ_MPQ_ARCHIVE_SIZE);
38 int get_numfiles(mpqa)
41 RETVAL = libmpq_archive_info(mpqa, LIBMPQ_MPQ_NUMFILES);
45 int listopen(mpqa,listfile)
50 switch (libmpq_listfile_open(mpqa, listfile)) {
51 case LIBMPQ_CONF_EFILE_OPEN:
52 warn("found filelist, but could not open, so disabling listfile\n");
54 case LIBMPQ_CONF_EFILE_CORRUPT:
55 warn("found filelist with errors, so disabling listfile\n");
57 case LIBMPQ_CONF_EFILE_LIST_CORRUPT:
58 warn("found filelist, header matches %s, but filelist is corrupt.\n", mpqa->mpq_l->mpq_name);
60 case LIBMPQ_CONF_EFILE_VERSION:
61 warn("found filelist, but libmpq %s is required.\n", mpqa->mpq_l->mpq_version);
63 case LIBMPQ_CONF_EFILE_NOT_FOUND:
64 warn("Filelist not found");
67 // printf("game: %s, file: %s, version: %s\n", mpqa->mpq_l->mpq_game, mpqa->mpq_l->mpq_name, mpqa->mpq_l->mpq_game_version);
77 if (libmpq_file_check(mpqa, &nr, LIBMPQ_FILE_TYPE_INT)) {
78 warn("file %i not found\n", nr);
80 RETVAL = libmpq_file_extract(mpqa, nr);
88 libmpq_listfile_close(mpqa);
89 libmpq_archive_close(mpqa);