/* Allocate a new compressor */ CompressorState *AllocateCompressor(int compression, write_f* writeF) { CompressorState *cs; CompressionAlgorithm alg; int level; ParseCompressionOption(compression, &alg, &level); #ifndef HAVE_LIBZ if (alg == COMPR_ALG_LIBZ) die_horribly(NULL, modulename, "not built with zlib support\n"); #endif cs = (CompressorState *) calloc(1, sizeof(CompressorState)); if (cs == NULL) die_horribly(NULL, modulename, "out of memory\n"); cs->writeF = writeF; cs->comprAlg = alg; /* * Perform compression algorithm specific initialization. */ #ifdef HAVE_LIBZ if (alg == COMPR_ALG_LIBZ) InitCompressorZlib(cs, level); #endif return cs; }
/* Allocate a new compressor */ CompressorState * AllocateCompressor(int compression, WriteFunc writeF) { CompressorState *cs; CompressionAlgorithm alg; int level; ParseCompressionOption(compression, &alg, &level); #ifndef HAVE_LIBZ if (alg == COMPR_ALG_LIBZ) exit_horribly(modulename, "not built with zlib support\n"); #endif cs = (CompressorState *) pg_malloc0(sizeof(CompressorState)); cs->writeF = writeF; cs->comprAlg = alg; /* * Perform compression algorithm specific initialization. */ #ifdef HAVE_LIBZ if (alg == COMPR_ALG_LIBZ) InitCompressorZlib(cs, level); #endif return cs; }
/* * Read all compressed data from the input stream (via readF) and print it * out with ahwrite(). */ void ReadDataFromArchive(ArchiveHandle * AH, int compression, read_f* readF) { CompressionAlgorithm alg; ParseCompressionOption(compression, &alg, NULL); if (alg == COMPR_ALG_NONE) ReadDataFromArchiveNone(AH, readF); if (alg == COMPR_ALG_LIBZ) { #ifdef HAVE_LIBZ ReadDataFromArchiveZlib(AH, readF); #else die_horribly(NULL, modulename, "not built with zlib support\n"); #endif } }