static void __comp_fetch_init(void) { char *ptr = NULL; int i; #ifdef USE_SLZ slz_make_crc_table(); slz_prepare_dist_table(); #endif #if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM) global.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U; #endif #ifdef USE_ZLIB HA_SPIN_INIT(&comp_pool_lock); memprintf(&ptr, "Built with zlib version : " ZLIB_VERSION); memprintf(&ptr, "%s\nRunning on zlib version : %s", ptr, zlibVersion()); #elif defined(USE_SLZ) memprintf(&ptr, "Built with libslz for stateless compression."); #else memprintf(&ptr, "Built without compression support (neither USE_ZLIB nor USE_SLZ are set)."); #endif memprintf(&ptr, "%s\nCompression algorithms supported :", ptr); for (i = 0; comp_algos[i].cfg_name; i++) memprintf(&ptr, "%s%s %s(\"%s\")", ptr, (i == 0 ? "" : ","), comp_algos[i].cfg_name, comp_algos[i].ua_name); if (i == 0) memprintf(&ptr, "%s none", ptr); hap_register_build_opts(ptr, 1); cfg_register_keywords(&cfg_kws); }
int slz_deflate( unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen, int level ){ if(!slz_initialized){ slz_prepare_dist_table(); slz_initialized=true; } struct slz_stream strm; slz_init(&strm, level, SLZ_FMT_DEFLATE); *destLen=slz_encode(&strm,dest,source,sourceLen,0); *destLen+=slz_finish(&strm,dest+*destLen); return Z_OK; }