izmjene licence
[ossec-hids.git] / src / os_zlib / os_zlib.c
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All rights reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 #include "os_zlib.h"
11
12 unsigned long int os_zlib_compress(const char *src, char *dst, unsigned long int src_size,
13                 unsigned long int dst_size)
14 {
15     if(compress2((Bytef *)dst,
16                  &dst_size,
17                  (const Bytef *)src,
18                  src_size,
19                  Z_BEST_COMPRESSION) == Z_OK)
20     {
21         dst[dst_size] = '\0';
22         return(dst_size);
23     }
24
25     return(0);
26 }
27
28
29 unsigned long int os_zlib_uncompress(const char *src, char *dst, unsigned long int src_size,
30                 unsigned long int dst_size)
31 {
32     if(uncompress((Bytef *)dst,
33                   &dst_size,
34                   (const Bytef *)src,
35                   src_size) == Z_OK)
36     {
37         dst[dst_size] = '\0';
38         return(dst_size);
39     }
40
41     return(0);
42 }
43
44
45 /* EOF */