int ey_zlib_stream_pack(ey_zlib_t z, char *i_buf, size_t i_len, ey_zlib_callback cb, void *arg) { if(!z || !cb || !i_buf || !i_len) { zlib_debug(debug_zlib_basic, "bad parameter in ey_zlib_stream_pack\n"); return -1; } ey_zlib_private_t *zp = (ey_zlib_private_t*)z; ey_zlib_format_t format = zp->format; zp->err_msg = NULL; if(format == EY_ZLIB_FORMAT_DEFLATE_PACK) { if(do_deflate(zp, i_buf, i_len, cb, arg)) { zlib_debug(debug_zlib_basic, "find error in deflate: %s\n", zp->err_msg?zp->err_msg:"unkown error"); return -1; } zlib_debug(debug_zlib_basic, "deflate %d bytes successfully\n", i_len); } else if(format == EY_ZLIB_FORMAT_GZIP_PACK) { if(do_gzip(zp, i_buf, i_len, cb, arg)) { zlib_debug(debug_zlib_basic, "find error in gzip: %s\n", zp->err_msg?zp->err_msg:"unkown error"); return -1; } zlib_debug(debug_zlib_basic, "gzip %d bytes successfully\n", i_len); } else { assert(0); } return 0; }
static size_t compresspage(struct page_data *pg, uint32_t *pflags) { if ((*pflags & (DUMP_DH_COMPRESSED)) == 0) switch (compression) { case COMPRESS_ZLIB: *pflags |= DUMP_DH_COMPRESSED_ZLIB; break; case COMPRESS_LZO: *pflags |= DUMP_DH_COMPRESSED_LZO; break; case COMPRESS_SNAPPY: *pflags |= DUMP_DH_COMPRESSED_SNAPPY; break; } #if USE_ZLIB if (*pflags & DUMP_DH_COMPRESSED_ZLIB) return do_gzip(pg); #endif #if USE_LZO if(*pflags & DUMP_DH_COMPRESSED_LZO) return do_lzo(pg); #endif #if USE_SNAPPY if (*pflags & DUMP_DH_COMPRESSED_SNAPPY) return do_snappy(pg); #endif fprintf(stderr, "Unsupported compression flags: %lu\n", (unsigned long) *pflags); return 0; }
int main(int argc, char* argv[]) { ZipFileList zflist; #ifdef _WIN32 boinc_filelist("c:\\temp", "", &zflist, SORT_NAME | SORT_ASCENDING); #else boinc_filelist("/tmp/junk", "", &zflist, SORT_NAME | SORT_ASCENDING); #endif int jj; char strTmp[128], strTmp2[128]; for (jj = 0; jj < zflist.size(); jj++) { printf("%s %d\n", zflist[jj].c_str(), zflist[jj].m_statFile.st_mtime); // now gzip it, silly but see how it goes! sprintf(strTmp, "%s.gz", zflist[jj].c_str()); sprintf(strTmp2, "%s.zip", strTmp); printf("infile=%s outfile=%s\n", strTmp, strTmp2); do_gzip(strTmp, zflist[jj].c_str()); boinc_zip(ZIP_IT, strTmp2, strTmp); } boinc_zip(UNZIP_IT, "/tmp/boinc_zip.zip", "/tmp/junk/boinc_zip"); return 0; }