X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fos_zlib%2Fos_zlib.c;h=5caf680573bcbd88651329815847498f07c48106;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=9ad9516a7b0b85dd408303adb4eaca4e801d3770;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/os_zlib/os_zlib.c b/src/os_zlib/os_zlib.c old mode 100755 new mode 100644 index 9ad9516..5caf680 --- a/src/os_zlib/os_zlib.c +++ b/src/os_zlib/os_zlib.c @@ -1,51 +1,48 @@ -/* @(#) $Id: os_zlib.c,v 1.7 2009/06/24 18:53:06 dcid Exp $ */ - /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ - -#include "shared.h" + #include "os_zlib.h" -/* os_compress: Compress a string with zlib. */ -int os_compress(char *src, char *dst, int src_size, int dst_size) +#ifdef ZLIB_SYSTEM +#include +#else +#include "../external/zlib-1.2.11/zlib.h" +#endif + +unsigned long int os_zlib_compress(const char *src, char *dst, + unsigned long int src_size, + unsigned long int dst_size) { - unsigned long int zl_dst = dst_size; - - /* We make sure to do not allow long sizes */ - if(compress2((unsigned char *)dst, - &zl_dst, - (unsigned char *)src, - (unsigned long int)src_size, 9) == Z_OK) - { - dst[zl_dst] = '\0'; - return(zl_dst); + if (compress2((Bytef *)dst, + &dst_size, + (const Bytef *)src, + src_size, + Z_BEST_COMPRESSION) == Z_OK) { + dst[dst_size] = '\0'; + return (dst_size); } - return(0); + return (0); } - -/* os_uncompress: Uncompress a string with zlib. */ -int os_uncompress(char *src, char *dst, int src_size, int dst_size) +unsigned long int os_zlib_uncompress(const char *src, char *dst, + unsigned long int src_size, + unsigned long int dst_size) { - unsigned long int zl_dst = dst_size; - - if(uncompress((unsigned char *)dst, - &zl_dst, - (unsigned char *)src, - (unsigned long int)src_size) == Z_OK) - { - dst[zl_dst] = '\0'; - return(zl_dst); + if (uncompress((Bytef *)dst, + &dst_size, + (const Bytef *)src, + src_size) == Z_OK) { + dst[dst_size] = '\0'; + return (dst_size); } - return(0); -} + return (0); +} -/* EOF */