/*************************************** * SZDDD_OPEN *************************************** * opens an SZDD file without decompressing, reads header */ static struct msszddd_header *szddd_open(struct msszdd_decompressor *self, char *filename) { struct msszdd_decompressor_p *this = (struct msszdd_decompressor_p *) self; struct msszddd_header_p *szdd = NULL; struct mspack_system *sys; struct mspack_file *fh; int error; if (!this) return NULL; sys = this->system; if ((fh = sys->open(sys, filename, MSPACK_SYS_OPEN_READ))) { if ((szdd = sys->alloc(sys, sizeof(struct msszddd_header_p)))) { szdd->fh = fh; error = szddd_read_headers(sys, fh, (struct msszddd_header *) szdd); if (error) { szddd_close(self, (struct msszddd_header *) szdd); szdd = NULL; } this->error = error; } else { this->error = MSPACK_ERR_NOMEMORY; } sys->close(fh); } else { this->error = MSPACK_ERR_OPEN; } return (struct msszddd_header *) szdd; }
/*************************************** * SZDDD_DECOMPRESS *************************************** * unpacks directly from input to output */ static int szddd_decompress(struct msszdd_decompressor *base, const char *input, const char *output) { struct msszdd_decompressor_p *self = (struct msszdd_decompressor_p *) base; struct msszddd_header *hdr; int error; if (!self) return MSPACK_ERR_ARGS; if (!(hdr = szddd_open(base, input))) return self->error; error = szddd_extract(base, hdr, output); szddd_close(base, hdr); return self->error = error; }